Просмотр исходного кода

Merge commit 'c3e3398e20bda3dc5814a8e6c7e9ac5deb059659' into feature/v1.5.2

* commit 'c3e3398e20bda3dc5814a8e6c7e9ac5deb059659':
  冻结问题修改
  冻结问题修改
Jianghan 1 год назад
Родитель
Сommit
4e8a086c5a
2 измененных файлов с 113 добавлено и 6 удалено
  1. 105 3
      clueSync/job.go
  2. 8 3
      clueSync/jobutil.go

+ 105 - 3
clueSync/job.go

@@ -257,6 +257,15 @@ func FormatData(data map[string]interface{}, item string) (bool, bool) {
 			return false, false
 		}
 	} else {
+		if isFreeze {
+			//达上限放公海处理
+			uCount, oks := TiDb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"uid": uId}, "", ""), true //查当前线索是否已存在
+			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)
+			}
+			return true, true
+		}
 		return true, false
 	}
 	return true, true
@@ -371,8 +380,8 @@ func SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, c
 			"BCPCID":       common.GetRandom(32),
 			"operator_id":  -1,
 		})
-		//冻结处理
-		if isFreeze {
+		////冻结处理
+		/*if isFreeze {
 			TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
 				"createtime":  nowTime,
 				"BCPCID":      common.GetRandom(32),
@@ -384,7 +393,8 @@ func SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, c
 			})
 			//消息发送
 			AssFail(positionId, cluename, phone)
-		}
+		}*/
+		AssFail(positionId, cluename, phone)
 		return clueId > -1 && uodateId1 > -1 && uodateId2 > -1 && uodateId3 > -1 && uodateId4 > -1 && uodateId5 > -1 && uodateId6 > -1
 	}) {
 		log.Println("线索分配成功")
@@ -405,6 +415,98 @@ func SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, c
 		return false
 	}
 }
+func SaveClue0(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, cluename, name, saleName, phone, position, department, departments, industry, follow_project_area, role, seatNumber string, positionId int64, source, sourceCode, remark string, keyword []string, belong_to string, isGroup, isCommerce int, isFreeze bool) bool {
+	nowTime := time.Now().Format("2006-01-02 15:04:05")
+	clueId, uodateId1, uodateId2, uodateId3 := int64(0), int64(0), int64(0), int64(0)
+	if TiDb.ExecTx("保存线索", func(tx *sql.Tx) bool {
+		keywords := ""
+		if sourceCode == "app_xzcyh" {
+			if len(keyword) > 0 && keyword[0] != "" {
+				keywords = strings.Join(keyword, ",")
+			}
+		}
+		if cluename == "" {
+			cluename = phone
+		}
+		clueId = TiDb.InsertByTx(tx, "dwd_f_crm_clue_info", map[string]interface{}{
+			"userid":               userId,
+			"uid":                  uId,
+			"seatNumber":           "",
+			"position_id":          0,
+			"is_assign":            0,
+			"comeintime":           nowTime,
+			"createtime":           nowTime,
+			"updatetime":           nowTime,
+			"cluename":             cluename,
+			"top_cluetype":         top_cluetype,
+			"sub_cluetype":         sub_cluetype,
+			"trailstatus":          "01",
+			"name":                 name,
+			"phone":                phone,
+			"position":             position,
+			"department":           common.If(sourceCode == "app_xzcyh", departments, department),
+			"industry":             industry,
+			"follow_project_area":  follow_project_area,
+			"role":                 role,
+			"comeinsource_private": 2,
+			"business_scope":       common.If(sourceCode == "app_xzcyh", keywords, nil),
+			"company_nature":       isGroup,
+			"company_verification": isCommerce,
+			"remark":               remark,
+			"FREEZE_TIME":          nowTime,
+		})
+		uodateId1 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
+			"clue_id":     clueId,
+			"position_id": positionId,
+			"change_type": "创建线索",
+			"new_value":   "系统自动创建",
+			"createtime":  nowTime,
+			"BCPCID":      common.GetRandom(32),
+			"operator_id": -1,
+		})
+		uodateId2 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
+			"clue_id":      clueId,
+			"position_id":  positionId,
+			"change_field": "position_id",
+			"change_type":  "所属人变更",
+			"old_value":    "",
+			"new_value":    "/",
+			"createtime":   nowTime,
+			"BCPCID":       common.GetRandom(32),
+			"operator_id":  -1,
+		})
+		uodateId3 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
+			"clue_id":      clueId,
+			"position_id":  positionId,
+			"change_field": "trailstatus",
+			"change_type":  "基本信息变更",
+			"old_value":    "商机线索",
+			"new_value":    "新增",
+			"createtime":   nowTime,
+			"BCPCID":       common.GetRandom(32),
+			"operator_id":  -1,
+		})
+		AssFail(positionId, cluename, phone)
+		return clueId > -1 && uodateId1 > -1 && uodateId2 > -1 && uodateId3 > -1
+	}) {
+		log.Println("线索分配成功")
+		if TiDb.Count("dwd_f_userbase_contacts", map[string]interface{}{"phone": phone}) == 0 {
+			TiDb.Insert("dwd_f_userbase_contacts", map[string]interface{}{
+				"status":      1,
+				"is_delete":   1,
+				"createtime":  nowTime,
+				"updatetime":  nowTime,
+				"phone":       phone,
+				"baseinfo_id": uId,
+				"SOURCE":      source,
+			})
+		}
+		return true
+	} else {
+		log.Println("线索分配失败!!!", clueId, uodateId1, uodateId2, uodateId3, " 用户信息 ", item, position, seatNumber, uId, userId, phone)
+		return false
+	}
+}
 
 func UpdateClue(data map[string]interface{}, saleData []map[string]interface{}, item, userId, uId, top_cluetype, sub_cluetype, topname, subname, cluename, name, saleName, phone, position, department, departments, industry, follow_project_area, role, seatNumber, level string, positionId int64, source, sourceCode, remark string, keyword []string, belong_to string, isGroup, isCommerce int, pIsOk bool) bool {
 	nowTime := time.Now().Format("2006-01-02 15:04:05")

+ 8 - 3
clueSync/jobutil.go

@@ -423,11 +423,15 @@ func autoDraw(mode, cluename, phone string, isGroup, isCommerce int) (positionId
 									if FindUpperLimit(gconv.String(positionId), "positionId") {
 										isFreeze = true
 									}
-
 								}
 							}
 						}
 					}
+					if isFreeze {
+						positionId = 0
+						seatNumber = ""
+						saleName = ""
+					}
 					return
 				}
 			}
@@ -476,6 +480,7 @@ func autoDraw(mode, cluename, phone string, isGroup, isCommerce int) (positionId
 				res := int64(0)
 				countres := 0
 				for _, v := range *countData {
+
 					if common.IntAll(v["status"]) == 1 {
 						log.Println("222", v, FindUpperLimit(gconv.String(common.Int64All(v["position_id"])), "positionId"))
 						if FindUpperLimit(gconv.String(common.Int64All(v["position_id"])), "positionId") {
@@ -487,7 +492,7 @@ func autoDraw(mode, cluename, phone string, isGroup, isCommerce int) (positionId
 							positionId = common.Int64All(v["position_id"])
 						} else {
 							if common.Int64All(v["count"]) <= res {
-								log.Println("3333", v)
+								log.Println("3", v)
 								res = common.Int64All(v["count"])
 								positionId = common.Int64All(v["position_id"])
 							}
@@ -495,7 +500,7 @@ func autoDraw(mode, cluename, phone string, isGroup, isCommerce int) (positionId
 						countres++
 					}
 				}
-				log.Println(444, res, positionId)
+				log.Println(444, res)
 			}
 		} else {
 			for _, kv := range *data {