Browse Source

Merge remote-tracking branch 'origin/14.6'

Roc 1 year ago
parent
commit
276c7d9a73

+ 9 - 1
models/company/company_renewal_record.go

@@ -20,8 +20,16 @@ type CompanyRenewalRecord struct {
 	ModifyTime      time.Time `description:"修改时间"`
 }
 
+type UnusualRenewCompanyGroup struct {
+	SellerId      int `description:"所属销售id"`
+	ShareSellerId int `description:"所属共享销售id"`
+	//AdminName string `description:"所属销售名称"`
+	Num        int    `description:"汇总次数"`
+	CompanyIds string `description:"客户id字符串"`
+}
+
 // GetUnusualRenewCompanyList 获取销售未续约数据
-func GetUnusualRenewCompanyList(startDate, endDate time.Time, productId int) (list []*CompanyRenewalRecord, err error) {
+func GetUnusualRenewCompanyList(startDate, endDate time.Time, productId int) (list []*UnusualRenewCompanyGroup, err error) {
 	o := orm.NewOrm()
 	sql := `	SELECT
 	a.seller_id,a.share_seller_id,

+ 2 - 2
services/statistic_report/renew_company.go

@@ -298,13 +298,13 @@ func getRenewSectionData(productId int, startDate, endDate time.Time, ch chan Co
 			if !ok {
 				tmpCompanyIdList = make([]string, 0)
 			}
-			unusualRenewCompanyIdListMap[v.SellerId] = append(tmpCompanyIdList, fmt.Sprint(v.CompanyId))
+			unusualRenewCompanyIdListMap[v.SellerId] = append(tmpCompanyIdList, fmt.Sprint(v.CompanyIds))
 
 			tmpCompanyIdList2, ok := unusualRenewCompanyIdListMap[v.ShareSellerId]
 			if !ok {
 				tmpCompanyIdList2 = make([]string, 0)
 			}
-			unusualRenewCompanyIdListMap[v.ShareSellerId] = append(tmpCompanyIdList2, fmt.Sprint(v.CompanyId))
+			unusualRenewCompanyIdListMap[v.ShareSellerId] = append(tmpCompanyIdList2, fmt.Sprint(v.CompanyIds))
 
 			unusualRenewCompanyTotal++
 		}

+ 8 - 18
services/statistic_report/unusual_renew_company.go

@@ -127,33 +127,23 @@ func getUnusualRenewSectionData(productId int, startDate, endDate time.Time, ch
 
 		unusualRenewCompanyIdListMap := make(map[int][]string) // 续约异常客户
 		for _, v := range data {
-			tmp, ok := unusualRenewMap[v.SellerId]
-			if !ok {
-				tmp = 0
+			// 共享人id为空
+			if v.ShareSellerId <= 0 {
+				continue
 			}
-			unusualRenewMap[v.SellerId] = tmp + 1
-
 			// 共享人id不为空,且不是所属销售
-			if v.ShareSellerId > 0 && v.ShareSellerId != v.SellerId {
-				tmp2, ok := unusualRenewMap[v.ShareSellerId]
-				if !ok {
-					tmp = 0
-				}
-				unusualRenewMap[v.ShareSellerId] = tmp2 + 1
-			}
-
-			// 客户id
-			tmpCompanyIdList, ok := unusualRenewCompanyIdListMap[v.SellerId]
+			tmp, ok := unusualRenewMap[v.ShareSellerId]
 			if !ok {
-				tmpCompanyIdList = make([]string, 0)
+				tmp = 0
 			}
-			unusualRenewCompanyIdListMap[v.SellerId] = append(tmpCompanyIdList, fmt.Sprint(v.CompanyId))
+			unusualRenewMap[v.ShareSellerId] = tmp + 1
 
+			// 客户id
 			tmpCompanyIdList2, ok := unusualRenewCompanyIdListMap[v.ShareSellerId]
 			if !ok {
 				tmpCompanyIdList2 = make([]string, 0)
 			}
-			unusualRenewCompanyIdListMap[v.ShareSellerId] = append(tmpCompanyIdList2, fmt.Sprint(v.CompanyId))
+			unusualRenewCompanyIdListMap[v.ShareSellerId] = append(tmpCompanyIdList2, fmt.Sprint(v.CompanyIds))
 
 			unusualRenewCompanyTotal++
 		}