Explorar el Código

Merge branch 'dev_v1.5.27.3_wh' of jianyu/datatools into hotfix/v1.5.27.3

王浩 hace 5 meses
padre
commit
e70e0ab6d2
Se han modificado 1 ficheros con 25 adiciones y 30 borrados
  1. 25 30
      clueSync/kc.go

+ 25 - 30
clueSync/kc.go

@@ -712,8 +712,8 @@ func refundAuto() {
 			if isRenewalProtection == 0 {
 				orderData := TiDb.SelectBySql(`select * from dwd_f_userbase_order_info where uid=?   and (product_type = "企业商机管理" or product_type = "大会员") and order_status = 1  and  refund_status!=1 ORDER BY   vip_endtime  desc  `, uid)
 				if orderData != nil && len(*orderData) > 0 {
-					endDate := time.Now().AddDate(0, 0, -db.ExpirationPeriod+1).Unix()
-					startDate := time.Now().AddDate(0, 0, -db.ExpirationPeriod).Unix()
+					endDate := time.Now().AddDate(0, 0, -db.ExpirationPeriod+3).Unix()
+					startDate := time.Now().AddDate(0, 0, -db.ExpirationPeriod+2).Unix()
 					vipEndDate, _ := time.ParseInLocation(time.DateTime, gconv.String((*orderData)[0]["vip_endtime"]), time.Local)
 					log.Println(vipEndDate.Unix() > startDate, vipEndDate.Unix() < endDate)
 					log.Println(vipEndDate.Unix(), startDate, endDate)
@@ -723,17 +723,17 @@ func refundAuto() {
 							"company_name": company_name,
 							"phone":        phone,
 							"userName":     userName,
-							"remrk":        "1天后即将移交",
+							"remrk":        "3天后即将移交",
 							"reason":       "成交客户续费失败",
 						})
-						salesEmailData[saleId] = append(salesEmailData[saleId], map[string]interface{}{
+						/*salesEmailData[saleId] = append(salesEmailData[saleId], map[string]interface{}{
 							"company_name": company_name,
 							"phone":        phone,
 							"userName":     userName,
 							"remrk":        "1天后即将移交",
 							"reason":       "成交客户续费失败",
 							"cluename":     cluename,
-						})
+						})*/
 						continue
 					}
 				}
@@ -826,29 +826,20 @@ func refundAuto() {
 							renewalInt := renewalTime.Unix()
 							log.Println("申请保护期时间", clueId, renewalInt)
 							log.Println("申请保护期时间222", time.Now().Unix()-vip_endtimes.Unix(), (db.HandoverCycle-1)*86400, (db.HandoverCycle)*86400)
-							log.Println("申请保护期时间333", (db.HandoverCycle-1)*86400 < time.Now().Unix()-vip_endtimes.Unix(), time.Now().Unix()-vip_endtimes.Unix() < (db.HandoverCycle)*86400)
 							//查看服务到期时间
 							if renewalInt != 0 && renewalInt < db.CustomerTime {
 								//三个月
 								if time.Now().Unix()-vip_endtimes.Unix() < 3*30*86400 {
 									isOk = true
 								}
-							} else if (db.HandoverCycle-2)*86400 < time.Now().Unix()-vip_endtimes.Unix() && time.Now().Unix()-vip_endtimes.Unix() < (db.HandoverCycle-1)*86400 {
+							} else if (db.HandoverCycle-5)*86400 < time.Now().Unix()-vip_endtimes.Unix() && time.Now().Unix()-vip_endtimes.Unix() < (db.HandoverCycle-4)*86400 {
 								//提前一天提示
 								mailData[name] = append(mailData[name], map[string]interface{}{
 									"company_name": company_name,
 									"phone":        phone,
 									"userName":     userName,
-									"remrk":        "1天后即将移交",
-									"reason":       "成交客户续费失败",
-								})
-								salesEmailData[saleId] = append(salesEmailData[saleId], map[string]interface{}{
-									"company_name": company_name,
-									"phone":        phone,
-									"userName":     userName,
-									"remrk":        "1天后即将移交",
+									"remrk":        "3天后即将移交",
 									"reason":       "成交客户续费失败",
-									"cluename":     cluename,
 								})
 								isOk = true
 							} else if time.Now().Unix()-vip_endtimes.Unix() < db.HandoverCycle*86400 {
@@ -1265,25 +1256,29 @@ func CustomerChange() {
 				data["positionName"] = personMap[positionId]
 			}
 			if operatorId > 0 {
+				//手动分配 客成收邮件
 				data["operatorName"] = personMap[operatorId]
-			}
-			if (oldPerson == "" || oldPerson == "/") && newPerson != "" && newPerson != "/" && positionId > 0 {
-				//之前没有可成人员
-				saleNobodyCustomMapMap[positionId] = append(saleNobodyCustomMapMap[positionId], data)
+				if newPerson != "" && newPerson != "/" {
+					customMap2[newPerson] = append(customMap2[newPerson], data)
+				}
+				if oldPerson != "" && oldPerson != "/" {
+					customMap1[oldPerson] = append(customMap1[oldPerson], data)
+				}
+			} else {
+				//自动分配  销售收邮件
+				if (oldPerson == "" || oldPerson == "/") && newPerson != "" && newPerson != "/" && positionId > 0 {
+					//之前没有可成人员
+					saleNobodyCustomMapMap[positionId] = append(saleNobodyCustomMapMap[positionId], data)
 
-			} else if newPerson != "" && newPerson != "/" && oldPerson != "" && oldPerson != "/" && positionId > 0 {
-				//之前有客成
-				saleMap[positionId] = append(saleMap[positionId], data)
-			}
-			if newPerson != "" && newPerson != "/" {
-				customMap2[newPerson] = append(customMap2[newPerson], data)
-			}
-			if oldPerson != "" && oldPerson != "/" {
-				customMap1[oldPerson] = append(customMap1[oldPerson], data)
+				} else if newPerson != "" && newPerson != "/" && oldPerson != "" && oldPerson != "/" && positionId > 0 {
+					//之前有客成
+					saleMap[positionId] = append(saleMap[positionId], data)
+				}
 			}
+
 		}
 		return true
-	}, `select operator_id, clue_id,position_id,old_value,new_value,createtime from   dwd_f_crm_clue_change_record  where    createtime>?  and change_type="客户成功经理"  and  operator_id>0  order by  createtime`, startTime)
+	}, `select operator_id, clue_id,position_id,old_value,new_value,createtime from   dwd_f_crm_clue_change_record  where    createtime>?  and change_type="客户成功经理"   order by  createtime`, startTime)
 	if len(customMap1) > 0 {
 		ChangeSendKc(customMap1, 1)
 	}