Parcourir la source

fix:共享客户列表接口

Roc il y a 1 an
Parent
commit
f1e7c9a029

+ 36 - 6
controllers/company_share.go

@@ -88,11 +88,13 @@ func (this *CompanyController) CompanyShare() {
 	br.Msg = "设置成功"
 }
 
+// CompanyShareList
 // @Title 共享客户列表
 // @Description 共享客户列表接口
 // @Param   SellerId   query   string  false       "选择的销售id"
+// @Param   OriginalSellerId   query   string  false       "选择的原销售id"
 // @Param   Keyword   query   string  true       "搜索关键词"
-// @Param   ListParam   query   int  false       "筛选字段参数,用来筛选的字段, 枚举值:0:全部 、 1:已分配 、 2:未分配  "
+// @Param   ListParam   query   int  false       "筛选字段参数,用来筛选的字段, 枚举值:0:全部 、 1:已分配 、 2:未分配 、 3:未共享 "
 // @Param   SortParam   query   string  false       "排序字段参数,用来排序的字段, 枚举值:'viewTotal':总阅读次数 、 'viewTime':阅读时间 、 'roadShowTotal':累计路演次数 、`expireDay:到期时间` 、 `createTime:创建时间` 、 'formalTime': 转正时间 、 'freezeTime':冻结时间 、'lossTime':流失时间  、'tryOutDay':试用天数"
 // @Param   SortType   query   string  true       "如何排序,是正序还是倒序,枚举值:`asc 正序`,`desc 倒叙`"
 // @Param   PageSize   query   int  true       "每页数据条数"
@@ -116,6 +118,7 @@ func (this *CompanyController) CompanyShareList() {
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
 	sellerIds := this.GetString("SellerId")
+	originalSellerIds := this.GetString("OriginalSellerId")
 	keyword := this.GetString("Keyword")
 	//排序参数
 	sortParam := this.GetString("SortParam")
@@ -150,6 +153,14 @@ func (this *CompanyController) CompanyShareList() {
 		}
 	}
 
+	// 咨询组的分组id
+	groupId := 0
+	if utils.RunMode == "release" {
+		groupId = 37
+	} else {
+		groupId = 61
+	}
+
 	roleTypeCode := sysUser.RoleTypeCode
 	productId := services.GetProductId(roleTypeCode)
 	//权限控制
@@ -171,17 +182,36 @@ func (this *CompanyController) CompanyShareList() {
 		}
 	}
 
+	if listParam == 0 {
+		if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_SELLER || sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_GROUP || sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_TEAM {
+			//非咨询组销售,那么默认查看“未共享”的客户
+			if sysUser.GroupId != groupId {
+				listParam = 3
+				condition += ` AND b.seller_id = ? `
+				pars = append(pars, sysUser.AdminId)
+			} else {
+				condition += ` AND a.is_share=1 `
+			}
+		} else if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_ADMIN || sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_FICC_ADMIN {
+			// 管理员,默认查看“待分配”客户
+			listParam = 2
+		}
+	}
+
 	if listParam == 1 {
-		condition += ` AND a.share_seller <> '' AND a.is_share=1 `
+		condition += ` AND a.share_seller_id > 0 AND a.is_share=1 `
 	} else if listParam == 2 {
-		condition += ` AND a.share_seller = '' AND a.is_share=1 `
-	} else {
-		condition += ` AND a.is_share=1 `
+		condition += ` AND a.share_seller_id = 0 AND a.is_share=1 `
+	} else if listParam == 3 { // 未共享
+		condition += ` AND a.is_share=0 and b.status="正式"`
 	}
 
 	if sellerIds != "" {
 		condition += ` AND a.share_seller_id IN (` + sellerIds + `) `
 	}
+	if originalSellerIds != "" {
+		condition += ` AND b.seller_id IN (` + originalSellerIds + `) `
+	}
 
 	total, err := company.GetShareCompanyListCount(condition, pars)
 	if err != nil {
@@ -1008,4 +1038,4 @@ func (this *CompanyController) CompanyShareListByCity() {
 	br.Msg = "获取成功"
 	br.Data = resp
 
-}
+}

+ 2 - 2
models/company/company_renewal_record.go

@@ -27,7 +27,7 @@ func GetUnusualRenewCompanyList(startDate, endDate time.Time, productId int) (li
 	a.seller_id,a.share_seller_id,
 	count(
 	DISTINCT ( a.company_id )) num,
-	GROUP_CONCAT( DISTINCT c.company_id SEPARATOR ',' ) AS company_ids 
+	GROUP_CONCAT( DISTINCT a.company_id SEPARATOR ',' ) AS company_ids 
 	FROM
 	company_renewal_record as a
 WHERE
@@ -36,7 +36,7 @@ WHERE
     AND a.source = 1 
 	AND a.product_id = ?
 GROUP BY
-	p.seller_id;
+	a.seller_id;
 `
 	_, err = o.Raw(sql, startDate, endDate, productId).QueryRows(&list)
 

+ 1 - 1
models/contract/contract.go

@@ -636,7 +636,7 @@ AND	b.product_id=?
 AND b.status = 1
 GROUP BY
 	a.company_id
-)
+) z
 `
 	err = o.Raw(sql, productId, productId, endDate).QueryRow(&total)
 

+ 4 - 3
services/statistic_report/renew_company.go

@@ -109,6 +109,10 @@ func GetRenewTimeIntervalData(productId int, startDate, endDate string) (adminDa
 // getRenewSectionData 获取周期数据
 func getRenewSectionData(productId int, startDate, endDate time.Time, ch chan CompanyRenewDataMap) (adminDataMap CompanyRenewDataMap, err error) {
 	defer func() {
+		if err != nil {
+			utils.FileLog.Error("getRenewSectionData,err:" + err.Error())
+			fmt.Println(err)
+		}
 		ch <- adminDataMap
 	}()
 	notRenewMap := make(map[int]int)
@@ -129,7 +133,6 @@ func getRenewSectionData(productId int, startDate, endDate time.Time, ch chan Co
 	var unusualRenewCompanyTotal, formalCompanyTotal int //续约异常客户总数  , 当前正式的客户数
 	formalCompanyTotal, err = contract.GetCountFormalCompany(endDate, productId)
 	if err != nil {
-		utils.FileLog.Error(err.Error())
 		return
 	}
 
@@ -248,10 +251,8 @@ func getRenewSectionData(productId int, startDate, endDate time.Time, ch chan Co
 		}
 		contractId := strings.Join(contractIds, ",")
 		data, tmpErr := company.GetRenewCompanyGroupList(startDate, endDate, contractId)
-
 		if tmpErr != nil {
 			err = tmpErr
-			utils.FileLog.Error(err.Error())
 			return
 		}
 		var renewIdSlice []string