Prechádzať zdrojové kódy

Merge branch 'master' of http://8.136.199.33:3000/hongze/hz_crm_api into debug

zhangchuanxing 2 mesiacov pred
rodič
commit
91ce5cb895

+ 18 - 14
controllers/statistic/rai_data_summary.go

@@ -83,12 +83,14 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
 	}
 	var condition string
 	var pars []interface{}
+	var conditionEnSeller string // 手动禁用的销售
 
+	conditionEnSeller = " AND  real_name  NOT  IN  ('余晔', '于卓铭', '张怡', '王芳6') "
 	mapsellerDevelop := make(map[int]bool) // 开拓组销售Map
 	mapsellerService := make(map[int]bool) // 服务组销售Map
 	var sellerIds []string
 	var sellerServiceIds []string
-	condition = " AND role_type_code IN ('rai_seller','rai_group')   "
+	condition = " AND role_type_code IN ('rai_seller','rai_group')    " + conditionEnSeller
 	sellerListAll, err := system.GetSysUserItemsOrderByCreated(condition, pars)
 	if err != nil {
 		br.Msg = "获取管理账号失败"
@@ -106,7 +108,7 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
 		}
 	}
 
-	condition = " AND role_type_code IN ('rai_seller','rai_group') AND enabled = 1 AND  rai_enabled = 1  "
+	condition = " AND role_type_code IN ('rai_seller','rai_group') AND enabled = 1 AND  rai_enabled = 1  " + conditionEnSeller
 
 	if adminId != "" {
 		serviceAdminId = ""
@@ -156,6 +158,7 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
 		isCustomizeDate = true
 		startYear = 1
 		endYear = 1
+		dataTypeArr = []string{""}
 	}
 
 	//新签部分的数据
@@ -354,17 +357,17 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
 
 	//续约部分的数据(服务组)
 	for _, v := range listInheritData {
-		if len(serviceAdminIdArr) > 0 && !utils.InArrayByStr(serviceAdminIdArr, strconv.Itoa(v.ShareSellerIdLast)) {
+		if len(serviceAdminIdArr) > 0 && !utils.InArrayByStr(serviceAdminIdArr, strconv.Itoa(v.ShareSellerIdInit)) {
 			continue
 		}
-		if !mapsellerService[v.ShareSellerIdLast] {
+		if !mapsellerService[v.ShareSellerIdInit] {
 			continue
 		}
 		yearStr := getYearStar(utils.StrDateToDate(v.InheritEndDate), dataType, isCustomizeDate)
 
-		keyMap = fmt.Sprint(yearStr, "_Server_", v.ShareSellerIdLast)
-		keyMapCompany = fmt.Sprint(yearStr, "_Server_", v.ShareSellerIdLast, "_CID_", v.CompanyId)
-		keySigned = fmt.Sprint(yearStr, "_Server_", v.CompanyId, "_SID_", v.ShareSellerIdLast)
+		keyMap = fmt.Sprint(yearStr, "_Server_", v.ShareSellerIdInit)
+		keyMapCompany = fmt.Sprint(yearStr, "_Server_", v.ShareSellerIdInit, "_CID_", v.CompanyId)
+		keySigned = fmt.Sprint(yearStr, "_Server_", v.CompanyId, "_SID_", v.ShareSellerIdInit)
 		keyMapTtoal = fmt.Sprint(yearStr, "_Server_")
 
 		//续约合同 数据
@@ -559,7 +562,7 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
 		}
 	}
 
-	conditionTry := ` AND a.create_time >= ? AND a.create_time <= ? AND a.operation in ( "add","receive","apply_receive" )  AND a.sys_user_id IN ( SELECT  admin_id FROM admin  WHERE  role_type_code IN ( 'rai_seller', 'rai_group' , 'rai_admin') ) `
+	conditionTry := ` AND a.create_time >= ? AND a.create_time <= ? AND a.operation in ( "add","receive","apply_receive" )  AND a.sys_user_id IN ( SELECT  admin_id FROM admin  WHERE  role_type_code IN ( 'rai_seller', 'rai_group' , 'rai_admin') ` + conditionEnSeller + ` ) `
 	var parsTry []interface{}
 	parsTry = append(parsTry, startDate, endDate)
 	//列表页数据
@@ -570,6 +573,7 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryList() {
 		return
 	}
 	for _, v := range tryList {
+
 		startDateTime := utils.StrTimeToTime(v.CreateTime)
 		monthNum := startDateTime.Month()
 		yearStr := strconv.Itoa(startDateTime.Year())
@@ -1142,9 +1146,9 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
 	case "续约合同":
 		if sellerId != "" {
 			if isServerSeller {
-				condition += ` AND a.share_seller_id_last  IN (` + sellerId + `) `
+				condition += ` AND a.share_seller_id_init  IN (` + sellerId + `) `
 			} else {
-				condition += ` AND a.seller_id_last  IN (` + sellerId + `) `
+				condition += ` AND a.seller_id_init  IN (` + sellerId + `) `
 			}
 		}
 		condition += ` AND  a.status = 1  AND a.inherit_end_date >= ?  AND a.inherit_end_date <= ?  AND  a.inherit_company_contract_id > 0  AND a.rai_contract_type = '续约合同'  AND a.company_contract_id NOT  IN (` + utils.GetOrmInReplace(lenArrCompany) + `)  `
@@ -1205,10 +1209,10 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
 		var parsEnd []interface{}
 		if sellerId != "" {
 			if isServerSeller {
-				condition += ` AND a.share_seller_id_last 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_last IN (` + sellerId + `) `
+				condition += ` AND a.seller_id_init IN (` + sellerId + `) `
 				conditionEnd += ` AND a.seller_id_last  IN (` + sellerId + `) `
 			}
 		}
@@ -1361,10 +1365,10 @@ func (this *StatisticRaiDataSummaryController) RaiDataSummaryDetail() {
 		var parsEnd []interface{}
 		if sellerId != "" {
 			if isServerSeller {
-				condition += ` AND a.share_seller_id_last  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_last  IN (` + sellerId + `) `
+				condition += ` AND a.seller_id_init  IN (` + sellerId + `) `
 				conditionEnd += ` AND a.seller_id_last  IN (` + sellerId + `) `
 			}
 

+ 1 - 1
services/company_contract.go

@@ -712,7 +712,7 @@ func UpdateCompanyContractDueEndDate(companyContractId int) {
 
 	var condition string
 	var pars []interface{}
-	condition = `  AND  product_id = 2 AND status =1  AND  merge_company_contract_id = 0   AND company_contract_id < ? AND company_id = ? 
+	condition = `  AND  product_id = 2 AND status =1  AND  merge_company_contract_id = 0  AND rai_contract_type  = '续约合同'   AND company_contract_id < ? AND company_id = ? 
 				AND DATE_ADD( end_date, INTERVAL - 1 YEAR ) < ? AND DATE_ADD( end_date, INTERVAL 1 YEAR ) > ? 
 				AND DATE_ADD( start_date, INTERVAL - 1 YEAR ) < ? AND DATE_ADD( start_date, INTERVAL 1 YEAR ) > ?
 				ORDER BY company_contract_id DESC,  end_date  DESC LIMIT	 1  `