Browse Source

Merge branch 'dev_v1.5.2_wh' of jianyu/datatools into feature/v1.5.2

王浩 1 year ago
parent
commit
b36dbf4b02
3 changed files with 33 additions and 4 deletions
  1. 24 2
      clueSync/job.go
  2. 4 1
      clueSync/jobutil.go
  3. 5 1
      clueSync/kc.go

+ 24 - 2
clueSync/job.go

@@ -233,7 +233,7 @@ func FormatData(data map[string]interface{}, item string) (bool, bool) {
 		log.Println("线索分配失败,线索过滤top_cluetype!!", item, uId, phone, userId)
 		return true, true
 	}
-	position_id, seatNumber, saleName, saleData, pIsOk, isFreeze := autoDraw(level, cluename, phone, isGroup, isCommerce) //查询当前分配次数最少的,如果当前线索有销售,此次找出的不会+1
+	position_id, seatNumber, saleName, saleData, pIsOk, isFreeze, noticePositionId := autoDraw(level, cluename, phone, isGroup, isCommerce) //查询当前分配次数最少的,如果当前线索有销售,此次找出的不会+1
 	log.Println("data -------", position_id, seatNumber, saleName)
 	if position_id > 0 && seatNumber != "" {
 		uCount, oks := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"uid": uId}, "", ""), true //查当前线索是否已存在
@@ -257,9 +257,31 @@ func FormatData(data map[string]interface{}, item string) (bool, bool) {
 		if isFreeze {
 			//达上限放公海处理
 			uCount, oks := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"uid": uId}, "", ""), true //查当前线索是否已存在
-			if uCount == nil || len(*uCount) == 0 {                                                              //已存在,走更新
+			if uCount == nil || len(*uCount) == 0 {
 				oks = SaveClue0(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, cluename, name, saleName, phone, position, department, departments, industry, follow_project_area, role, seatNumber, position_id, source, sourceCode, remark, keyword, belong_to, isGroup, isCommerce, isFreeze)
 				log.Println(oks)
+				AssFail(noticePositionId, cluename, phone)
+			} else {
+				//留资线索更新
+				if item != "orders" && item != "users" { //新用户和订单之外的替换一下新的留资信息
+					clueUpdateData := map[string]interface{}{}
+					if name != "" {
+						clueUpdateData["name"] = name
+					}
+					if position != "" {
+						clueUpdateData["position"] = position
+					}
+					if department != "" {
+						clueUpdateData["department"] = department
+					}
+					if follow_project_area != "" {
+						clueUpdateData["follow_project_area"] = follow_project_area
+					}
+					if role != "" {
+						clueUpdateData["role"] = role
+					}
+					TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{"uid": uId}, clueUpdateData)
+				}
 			}
 			return true, true
 		}

+ 4 - 1
clueSync/jobutil.go

@@ -19,6 +19,7 @@ func orders() {
 	lastOrderId := cfg.LastOrderId
 	selectTimeStart := time.Unix(time.Now().Unix()-7200, 0).Format(date.Date_Full_Layout)
 	selectTimeEnd := time.Unix(time.Now().Unix()-3600, 0).Format(date.Date_Full_Layout)
+
 	sql := fmt.Sprintf(`select * from dataexport_order where create_time <= "%s" and create_time >= "%s" and id > %s`, selectTimeEnd, selectTimeStart, fmt.Sprint(lastOrderId))
 	data := Mysql.SelectBySql(sql)
 	if data != nil && *data != nil && len(*data) > 0 {
@@ -386,7 +387,7 @@ func getClueType(item string, data map[string]interface{}, sourceCode string, so
 }
 
 // 获取自动分配的人
-func autoDraw(mode, cluename, phone string, isGroup, isCommerce int) (positionId int64, seatNumber, saleName string, saleData []map[string]interface{}, isOk, isFreeze bool) {
+func autoDraw(mode, cluename, phone string, isGroup, isCommerce int) (positionId int64, seatNumber, saleName string, saleData []map[string]interface{}, isOk, isFreeze bool, noticePositionId int64) {
 	isOk = false
 	isFreeze = false
 	if TiDb.Count("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone, "is_assign": 1}) == 0 { //线索没销售进入,有销售走分配次数最少的逻辑
@@ -395,6 +396,7 @@ func autoDraw(mode, cluename, phone string, isGroup, isCommerce int) (positionId
 			if cdata != nil && len(*cdata) > 0 { //找到了公司有人在跟进
 				isOk = true
 				positionId = common.Int64All((*cdata)["position_id"])
+				noticePositionId = positionId
 				seatNumber = common.ObjToString((*cdata)["seatNumber"])
 				log.Println("positionId seatNumber ", positionId, seatNumber)
 				if positionId > 0 {
@@ -410,6 +412,7 @@ func autoDraw(mode, cluename, phone string, isGroup, isCommerce int) (positionId
 										for _, m := range *sdata {
 											if !FindUpperLimit(gconv.String(positionId), mode, true) {
 												positionId = common.Int64All(m["position_id"])
+												noticePositionId = positionId
 												seatNumber = common.ObjToString(m["seat_number"])
 												saleName = common.ObjToString(m["name"])
 												return

+ 5 - 1
clueSync/kc.go

@@ -835,7 +835,11 @@ func refundAuto() {
 							mailContent := ""
 							if cluename != "" {
 								if phone != "" {
-									mailContent = fmt.Sprintf("%s(%s)", cluename, phone)
+									if cluename == phone {
+										mailContent = phone
+									} else {
+										mailContent = fmt.Sprintf("%s(%s)", cluename, phone)
+									}
 								} else {
 									mailContent = cluename
 								}