Browse Source

标签处理

WH01243 7 months ago
parent
commit
96f0762ce0
2 changed files with 22 additions and 12 deletions
  1. 20 10
      service/clue.go
  2. 2 2
      service/company.go

+ 20 - 10
service/clue.go

@@ -765,7 +765,7 @@ func batchDraw(data []map[string]interface{}, nowTime, seatNumber, name string,
 			labelChangeTime := gconv.String(v["labelChangeTime"])
 			labelChangeTime := gconv.String(v["labelChangeTime"])
 			label := gconv.Int64(v["label"])
 			label := gconv.Int64(v["label"])
 			trailstatusCode := gconv.String(v["trailstatus"])
 			trailstatusCode := gconv.String(v["trailstatus"])
-			LabelHandel(label, 3, clueId, "", "01", trailstatusCode, labelChangeTime)
+			LabelHandel(tx, label, 3, clueId, "", "01", trailstatusCode, labelChangeTime)
 			return ok1 && recordId > 0 && recordId1 > 0 && recordId2 > 0 && recordId3 > -1 && recordId4 > -1
 			return ok1 && recordId > 0 && recordId1 > 0 && recordId2 > 0 && recordId3 > -1 && recordId4 > -1
 		}) {
 		}) {
 			logx.Info("领取线索成功")
 			logx.Info("领取线索成功")
@@ -1100,7 +1100,7 @@ func ClueImportSync(this *biservice.ClueImportReq) (string, int) {
 									"BCPCID":       common.GetRandom(32),
 									"BCPCID":       common.GetRandom(32),
 									"operator_id":  this.PositionId,
 									"operator_id":  this.PositionId,
 								})
 								})
-								LabelHandel(label, 2, clueId, level, trailstatusCode, trailstatusCode, labelChangeTime)
+								LabelHandel(nil, label, 2, clueId, level, trailstatusCode, trailstatusCode, labelChangeTime)
 							}
 							}
 							JyBiTidb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, updateData)
 							JyBiTidb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, updateData)
 						} else if is_assign == 1 {
 						} else if is_assign == 1 {
@@ -1176,7 +1176,7 @@ func ClueImportSync(this *biservice.ClueImportReq) (string, int) {
 									"BCPCID":       common.GetRandom(32),
 									"BCPCID":       common.GetRandom(32),
 									"operator_id":  this.PositionId,
 									"operator_id":  this.PositionId,
 								})
 								})
-								LabelHandel(label, 2, positionId, level, trailstatusCode, trailstatusCode, labelChangeTime)
+								LabelHandel(nil, label, 2, positionId, level, trailstatusCode, trailstatusCode, labelChangeTime)
 							}
 							}
 							if sub_cluetype != "" && sub_cluetype != old_sub_cluetype {
 							if sub_cluetype != "" && sub_cluetype != old_sub_cluetype {
 								updateData["position"] = position
 								updateData["position"] = position
@@ -1273,7 +1273,7 @@ func FindClueInfo(in *biservice.FindClueInfoReq) (map[string]interface{}, int64)
 }
 }
 
 
 // 线索标签修改 label  labelChangeTime
 // 线索标签修改 label  labelChangeTime
-func LabelHandel(oldlabelType, labelType, clueId int64, level, oldTrailstatusCode, trailstatusCode, labelChangeTime string) {
+func LabelHandel(tx *sql.Tx, oldlabelType, labelType, clueId int64, level, oldTrailstatusCode, trailstatusCode, labelChangeTime string) {
 	log.Println("线索标签修改:", oldlabelType, labelType, clueId, level, trailstatusCode, labelChangeTime)
 	log.Println("线索标签修改:", oldlabelType, labelType, clueId, level, trailstatusCode, labelChangeTime)
 	//先查询以前什么类型
 	//先查询以前什么类型
 	if trailstatusCode != "01" && oldTrailstatusCode != "01" {
 	if trailstatusCode != "01" && oldTrailstatusCode != "01" {
@@ -1315,11 +1315,21 @@ func LabelHandel(oldlabelType, labelType, clueId int64, level, oldTrailstatusCod
 		}
 		}
 	}
 	}
 	if updateLabelType > 0 {
 	if updateLabelType > 0 {
-		JyBiTidb.Update("dwd_f_crm_clue_info", map[string]interface{}{
-			"id": clueId,
-		}, map[string]interface{}{
-			"label":           updateLabelType,
-			"labelChangeTime": nowStr,
-		})
+		ok := false
+		if tx == nil {
+			ok = TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{
+				"uid": uId,
+			}, map[string]interface{}{
+				"label":           updateLabelType,
+				"labelChangeTime": nowStr,
+			})
+		} else {
+			ok = TiDb.UpdateByTx(tx, "dwd_f_crm_clue_info", map[string]interface{}{
+				"uid": uId,
+			}, map[string]interface{}{
+				"label":           updateLabelType,
+				"labelChangeTime": nowStr,
+			})
+		}
 	}
 	}
 }
 }

+ 2 - 2
service/company.go

@@ -265,7 +265,7 @@ func dclue(v, positionId, isTask, thispositionId int64) {
 				//标签变更
 				//标签变更
 				labelChangeTime := gconv.String((*clueData)["labelChangeTime"])
 				labelChangeTime := gconv.String((*clueData)["labelChangeTime"])
 				label := gconv.Int64((*clueData)["label"])
 				label := gconv.Int64((*clueData)["label"])
-				LabelHandel(label, 3, v, "", trailstatus, trailstatus, labelChangeTime)
+				LabelHandel(nil, label, 3, v, "", trailstatus, trailstatus, labelChangeTime)
 				JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
 				JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
 					"clue_id":      v,
 					"clue_id":      v,
 					"position_id":  oldpositionId,
 					"position_id":  oldpositionId,
@@ -341,7 +341,7 @@ func dclue(v, positionId, isTask, thispositionId int64) {
 				})
 				})
 				labelChangeTime := gconv.String((*clueData)["labelChangeTime"])
 				labelChangeTime := gconv.String((*clueData)["labelChangeTime"])
 				label := gconv.Int64((*clueData)["label"])
 				label := gconv.Int64((*clueData)["label"])
-				LabelHandel(label, 3, v, "", trailstatus, trailstatus, labelChangeTime)
+				LabelHandel(nil, label, 3, v, "", trailstatus, trailstatus, labelChangeTime)
 				JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
 				JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
 					"clue_id":      v,
 					"clue_id":      v,
 					"position_id":  positionId,
 					"position_id":  positionId,