Forráskód Böngészése

Merge branch 'master' of http://8.136.199.33:3000/hongze/hz_crm_api into crm/crm_16.0

zhangchuanxing 2 hónapja
szülő
commit
63a2b1cfdd

+ 10 - 7
controllers/statistic_company_merge.go

@@ -360,7 +360,10 @@ func (this *StatisticCompanyMergerController) MergeCompanyList() {
 		condition1 += condition
 		pars1 = append(pars1, pars)
 
-		condition1 += `  AND a.not_renewal_hide = 0  AND a.status = 1 AND a.start_date >= '2020-01-01' AND  a.end_date >= ? AND a.end_date  <= ? `
+		if isConfirm != 2 {
+			condition1 += `  AND a.not_renewal_hide = 0 `
+		}
+		condition1 += `    AND a.status = 1 AND a.start_date >= '2020-01-01' AND  a.end_date >= ? AND a.end_date  <= ? `
 		pars1 = append(pars1, startDate, endDate)
 		//condition1 += ` AND a.operation = ? `
 		//pars1 = append(pars1, "try_out")
@@ -368,7 +371,7 @@ func (this *StatisticCompanyMergerController) MergeCompanyList() {
 
 		//销售筛选条件
 		if adminId != "" {
-			condition1 += ` AND c.seller_id_last in  (` + adminId + `) `
+			condition1 += ` AND a.seller_id_last in  (` + adminId + `) `
 		} else {
 			condition1, pars1 = getQueryParamsLast(condition1, pars1, sysUser, "c.")
 		}
@@ -1961,7 +1964,7 @@ func (this *StatisticCompanyMergerController) CompanyContractPercentageListExpor
 	if exportType == 1 {
 		//条件
 		if adminId != "" {
-			condition += ` AND a.seller_id_init in  (` + adminId + `) `
+			condition += ` AND a.seller_id_last in  (` + adminId + `) `
 		}
 	}
 
@@ -2003,11 +2006,11 @@ func (this *StatisticCompanyMergerController) CompanyContractPercentageListExpor
 	var companyContractIds []int
 	for _, v := range listRenewal {
 		companyContractIds = append(companyContractIds, v.CompanyContractId)
-		v.SellerId = v.SellerIdInit
+		v.SellerId = v.SellerIdLast
 	}
 	for _, v := range listEndDate {
 		companyContractIds = append(companyContractIds, v.CompanyContractId)
-		v.SellerId = v.SellerIdInit
+		v.SellerId = v.SellerIdLast
 	}
 
 	//合同归因标签
@@ -2100,9 +2103,9 @@ func (this *StatisticCompanyMergerController) CompanyContractPercentageListExpor
 				cellBData := row.AddCell()
 				cellBData.Value = item.ProductStatus
 				cellCData := row.AddCell()
-				cellCData.Value = item.SellerName
+				cellCData.Value = item.SellerNameLast
 				cellCSellerData := row.AddCell()
-				cellCSellerData.Value = item.ShareSeller
+				cellCSellerData.Value = item.ShareSellerLast
 				cellDData := row.AddCell()
 				cellDData.Value = item.StartDate + "~" + item.EndDate
 				cellEData := row.AddCell()

+ 2 - 2
controllers/statistic_report.go

@@ -199,7 +199,7 @@ func getQueryParamsLast(condition string, pars []interface{}, sysUser *system.Ad
 		//如果不是研究员,那么去找对应的 部门、小组、销售
 		if sysUser.Authority == 0 {
 			//普通用户
-			condition += " AND c.seller_id_last=?"
+			condition += " AND a.seller_id_last=?"
 			pars = append(pars, sysUser.AdminId)
 		} else if sysUser.Authority == 1 {
 			//部门主管
@@ -249,7 +249,7 @@ func getQueryParamsLast(condition string, pars []interface{}, sysUser *system.Ad
 			pars = append(pars, sysUser.GroupId)
 		} else {
 			//不知道什么类型的用户(后面新增的位置类型客户)
-			condition += " AND c.seller_id_last=?"
+			condition += " AND a.seller_id_last=?"
 			pars = append(pars, sysUser.AdminId)
 		}
 	}

+ 5 - 2
models/statistic_report.go

@@ -392,7 +392,9 @@ type IncrementalList struct {
 	RegionType           string                             `description:"企业客户所属区域;可选范围:国内,海外"`
 	SellerId             int                                `description:"归属销售id"`
 	SellerName           string                             `description:"归属销售名称"`
-	ShareSeller          string                             `description:"共享销售员"`
+	SellerNameLast       string                             `description:"合同到期之前最后所属归属销售名称"`
+	ShareSeller          string                             `description:"合同到期之前最后所属共享销售员"`
+	ShareSellerLast      string                             `description:"共享销售员"`
 	ExpireDay            string                             `description:"剩余可用天数"`
 	PermissionList       []*company.CompanyReportPermission `description:"产品权限"`
 	Count                int                                `json:"-" description:"合同数"`
@@ -410,6 +412,7 @@ type IncrementalList struct {
 	IsUserMaker     int    `description:"近四周之内是否包含决策人互动过 ,0否,1是"`
 	SellerNameInit  string `description:"权益初始化销售"`
 	SellerIdInit    int    `description:"权益初始化销售ID"`
+	SellerIdLast    int    `description:"合同到期之前最后所属销售ID"`
 	ShareSellerInit string `description:"共享销售员"`
 }
 
@@ -930,7 +933,7 @@ func GetIncrementalCompanyListByOperationRecordMerge(condition string, pars []in
 	o := orm.NewOrm()
 
 	//查询真正的数据
-	sql := `SELECT a.company_contract_id,a.contract_type ,a.company_product_id ,a.contract_code ,a.pay_method ,a.pay_channel ,a.package_difference ,a.company_id, a.start_date, a.end_date, a.money, b.company_name, a.seller_id_last as seller_id, c.seller_name_last as  seller_name, c.share_seller_last as  share_seller, a.product_id, a.product_name, a.create_time, b.region_type, c.renewal_reason, c.renewal_todo, c.status  FROM company_contract a
+	sql := `SELECT a.company_contract_id,a.contract_type ,a.company_product_id ,a.contract_code ,a.pay_method ,a.pay_channel ,a.package_difference ,a.company_id, a.start_date, a.end_date, a.money, b.company_name, a.seller_id_last as seller_id, a.seller_name_last as  seller_name, a.share_seller_last as  share_seller, a.product_id, a.product_name, a.create_time, b.region_type, c.renewal_reason, c.renewal_todo, c.status  FROM company_contract a
 		RIGHT JOIN company b ON a.company_id = b.company_id
 		JOIN company_product c ON b.company_id = c.company_id 
 		AND a.product_id = c.product_id  where 1=1  `