浏览代码

未续约客户去除打分派点

zhangchuanxing 1 周之前
父节点
当前提交
a03bdfb9c8

+ 14 - 13
controllers/statistic/rai_data_summary.go

@@ -206,8 +206,8 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
 	var conditionConfirm string
 	var parsConfirm []interface{}
 	mapNoRenewedcompanyContractIds := make(map[int]bool) //已经确定未续约的合同ID
-	conditionConfirm = " AND company_ascribe_id != 9  "
-	companyConfirmList, err := company.GetCompanyContractNoRenewedAscribeList(conditionConfirm, parsConfirm, 0, 0)
+	conditionConfirm = "  AND a.company_ascribe_id != 9  AND b.contract_type != '打分派点' "
+	companyConfirmList, err := company.GetCompanyContractNoRenewedAscribeListJoin(conditionConfirm, parsConfirm, 0, 0)
 	if err != nil && err.Error() != utils.ErrNoRow() {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取失败,GetCompanyNoRenewedAscribeList Err:" + err.Error()
@@ -1376,23 +1376,24 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
 		var parsEnd []interface{}
 		if sellerId != "" {
 			if isServerSeller {
-				condition += ` AND a.share_seller_id_init  IN (` + sellerId + `) `
+				//condition += ` AND a.share_seller_id_init  IN (` + sellerId + `) `
 				conditionEnd += ` AND a.share_seller_id_last  IN (` + sellerId + `) `
 			} else {
-				condition += ` AND a.seller_id_init  IN (` + sellerId + `) `
+				//condition += ` AND a.seller_id_init  IN (` + sellerId + `) `
 				conditionEnd += ` AND a.seller_id_last  IN (` + sellerId + `) `
 			}
 
 		}
 
-		condition += ` AND  a.product_id = 2  AND  a.status = 1 AND a.contract_type != '打分派点'  AND  a.end_date >= ?  AND  a.end_date <= ? AND a.end_date <= ?  `
-		pars = append(pars, startDate, endDate, time.Now().Format(utils.FormatDate))
-		listRaiData, err := statistic_report.GetRaiDataSummaryList(condition, pars)
-		if err != nil {
-			br.Msg = "获取数据信息失败"
-			br.ErrMsg = "获取数据信息失败,Err:" + err.Error()
-			return
-		}
+		//condition += ` AND  a.product_id = 2  AND  a.status = 1 AND a.contract_type != '打分派点'  AND  a.end_date >= ?  AND  a.end_date <= ? AND a.end_date <= ?  `
+		//pars = append(pars, startDate, endDate, time.Now().Format(utils.FormatDate))
+		//listRaiData, err := statistic_report.GetRaiDataSummaryList(condition, pars)
+		//if err != nil {
+		//	br.Msg = "获取数据信息失败"
+		//	br.ErrMsg = "获取数据信息失败,Err:" + err.Error()
+		//	return
+		//}
+		//fmt.Println(len(listRaiData))
 
 		conditionEnd += `  AND  a.product_id = 2  AND  a.status = 1  AND a.contract_type != '打分派点'  AND a.due_end_date >= ?  AND a.due_end_date <= ?   AND a.end_date < ? `
 		parsEnd = append(parsEnd, startDate, endDate, time.Now().Format(utils.FormatDate))
@@ -1412,7 +1413,7 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
 		var expiredContractCompany float64 // 到期客户数
 		mapexpiredContractCompany := make(map[int]bool)
 
-		for _, v := range listRaiData {
+		for _, v := range listEndData {
 			if noRenewedcompanyContractIdsMap[v.CompanyContractId] {
 				norenewedContractMoney += v.Money
 				if !mapnorenewedContractCompany[v.CompanyId] {

+ 23 - 0
models/company/company_contract_no_renewed_ascribe.go

@@ -157,3 +157,26 @@ func GetCompanyContractNoRenewedAscribeList(condition string, pars []interface{}
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }
+
+// 列表
+func GetCompanyContractNoRenewedAscribeListJoin(condition string, pars []interface{}, startSize, pageSize int) (items []*CompanyContractNoRenewedAscribeResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT
+			a.* 
+		FROM
+			company_contract_no_renewed_ascribe AS a 
+			INNER JOIN company_contract as  b ON a.company_contract_id = b.company_contract_id 
+		WHERE
+			1 = 1
+			 AND a.company_ascribe_id != 9 
+			 AND b.contract_type != '打分派点' `
+	if condition != "" {
+		sql += condition
+	}
+	if startSize+pageSize > 0 {
+		sql += ` LIMIT ?,?  `
+		_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	}
+	_, err = o.Raw(sql, pars).QueryRows(&items)
+	return
+}

+ 5 - 5
services/company_ascribe.go

@@ -110,10 +110,10 @@ func GetCompanyContractNoRenewedAscribeListMap() (mapCountResp map[int]bool) {
 	}()
 	var condition string
 	var pars []interface{}
-	condition = ` AND company_ascribe_id != 9 `
-	list, e := company.GetCompanyContractNoRenewedAscribeList(condition, pars, 0, 0)
+	condition = `  AND a.company_ascribe_id != 9  AND b.contract_type != '打分派点' `
+	list, e := company.GetCompanyContractNoRenewedAscribeListJoin(condition, pars, 0, 0)
 	if e != nil && e.Error() != utils.ErrNoRow() {
-		err = errors.New("GetCompanyContractNoRenewedAscribeList, Err: " + e.Error())
+		err = errors.New("GetCompanyContractNoRenewedAscribeListJoin, Err: " + e.Error())
 		return
 	}
 	mapCountResp = make(map[int]bool, 0)
@@ -134,8 +134,8 @@ func GetCompanyContractNoRenewedAscribeListArr() (companyContractIds []int) {
 	}()
 	var condition string
 	var pars []interface{}
-	condition = ` AND company_ascribe_id != 9 `
-	list, e := company.GetCompanyContractNoRenewedAscribeList(condition, pars, 0, 0)
+	condition = ` AND a.company_ascribe_id != 9  AND b.contract_type != '打分派点'  `
+	list, e := company.GetCompanyContractNoRenewedAscribeListJoin(condition, pars, 0, 0)
 	if e != nil && e.Error() != utils.ErrNoRow() {
 		err = errors.New("GetCompanyContractNoRenewedAscribeList, Err: " + e.Error())
 		return