Эх сурвалжийг харах

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

王浩 7 сар өмнө
parent
commit
0c47242f0f
1 өөрчлөгдсөн 26 нэмэгдсэн , 15 устгасан
  1. 26 15
      clueSync/job.go

+ 26 - 15
clueSync/job.go

@@ -472,7 +472,7 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
 							"BCPCID":       BCPCID,
 							"BCPCID":       BCPCID,
 							"operator_id":  -1})
 							"operator_id":  -1})
 						//标签处理
 						//标签处理
-						LabelHandel(label, 2, uId, level, trailstatusCode, gconv.String(clueUpdateData["trailstatus"]), labelChangeTime)
+						LabelHandel(nil, label, 2, uId, level, trailstatusCode, gconv.String(clueUpdateData["trailstatus"]), labelChangeTime)
 					}
 					}
 					clueUpdateData["company_nature"] = isGroup
 					clueUpdateData["company_nature"] = isGroup
 					clueUpdateData["company_verification"] = isCommerce
 					clueUpdateData["company_verification"] = isCommerce
@@ -1273,13 +1273,13 @@ func WorkUpdateClue(data map[string]interface{}, saleData []map[string]interface
 			})
 			})
 			//标签处理
 			//标签处理
 			if old_position_id != positionId && newPositionId > 0 {
 			if old_position_id != positionId && newPositionId > 0 {
-				LabelHandel(label, 1, uId, level, trailstatus, gconv.String(clueUpdateData["trailstatus"]), oldLabelChangeTime)
+				LabelHandel(tx, label, 1, uId, level, trailstatus, gconv.String(clueUpdateData["trailstatus"]), oldLabelChangeTime)
 			} else {
 			} else {
-				LabelHandel(label, 2, uId, level, trailstatus, gconv.String(clueUpdateData["trailstatus"]), oldLabelChangeTime)
+				LabelHandel(tx, label, 2, uId, level, trailstatus, gconv.String(clueUpdateData["trailstatus"]), oldLabelChangeTime)
 			}
 			}
 		} else {
 		} else {
 			if old_position_id != positionId && newPositionId > 0 {
 			if old_position_id != positionId && newPositionId > 0 {
-				LabelHandel(label, 1, uId, level, trailstatus, gconv.String(clueUpdateData["trailstatus"]), oldLabelChangeTime)
+				LabelHandel(tx, label, 1, uId, level, trailstatus, gconv.String(clueUpdateData["trailstatus"]), oldLabelChangeTime)
 			}
 			}
 		}
 		}
 		return ok && updateId1 > -1 && updateId2 > -1 && updateId3 > -1 && updateId4 > -1 && updateId5 > -1 && updateId6 > -1 && updateId7 > -1 && updateId8 > -1 && updateId9 > -1 && updateId10 > -1 && updateId11 > -1 && updateId12 > -1 && updateId13 > -1 && updateId14
 		return ok && updateId1 > -1 && updateId2 > -1 && updateId3 > -1 && updateId4 > -1 && updateId5 > -1 && updateId6 > -1 && updateId7 > -1 && updateId8 > -1 && updateId9 > -1 && updateId10 > -1 && updateId11 > -1 && updateId12 > -1 && updateId13 > -1 && updateId14
@@ -1906,13 +1906,13 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
 				"operator_id":  -1,
 				"operator_id":  -1,
 			})
 			})
 			if old_position_id != newPositionId && newPositionId > 0 {
 			if old_position_id != newPositionId && newPositionId > 0 {
-				LabelHandel(label, 1, uId, level, trailstatus, gconv.String(clueUpdateData["trailstatus"]), oldLabelChangeTime)
+				LabelHandel(tx, label, 1, uId, level, trailstatus, gconv.String(clueUpdateData["trailstatus"]), oldLabelChangeTime)
 			} else {
 			} else {
-				LabelHandel(label, 2, uId, level, trailstatus, gconv.String(clueUpdateData["trailstatus"]), oldLabelChangeTime)
+				LabelHandel(tx, label, 2, uId, level, trailstatus, gconv.String(clueUpdateData["trailstatus"]), oldLabelChangeTime)
 			}
 			}
 		} else {
 		} else {
 			if old_position_id != newPositionId && newPositionId > 0 {
 			if old_position_id != newPositionId && newPositionId > 0 {
-				LabelHandel(label, 1, uId, level, trailstatus, gconv.String(clueUpdateData["trailstatus"]), oldLabelChangeTime)
+				LabelHandel(tx, label, 1, uId, level, trailstatus, gconv.String(clueUpdateData["trailstatus"]), oldLabelChangeTime)
 			}
 			}
 		}
 		}
 		return ok && updateId1 > -1 && updateId2 > -1 && updateId3 > -1 && updateId4 > -1 && updateId5 > -1 && updateId6 > -1 && updateId7 > -1 && updateId8 > -1 && updateId9 > -1 && updateId10 > -1 && updateId11 > -1 && updateId12 > -1 && updateId13 > -1 && updateId14
 		return ok && updateId1 > -1 && updateId2 > -1 && updateId3 > -1 && updateId4 > -1 && updateId5 > -1 && updateId6 > -1 && updateId7 > -1 && updateId8 > -1 && updateId9 > -1 && updateId10 > -1 && updateId11 > -1 && updateId12 > -1 && updateId13 > -1 && updateId14
@@ -2111,7 +2111,7 @@ func clueInfoUpdate(data ClueMapEntity) bool {
 				"BCPCID":       BCPCID,
 				"BCPCID":       BCPCID,
 				"operator_id":  -1,
 				"operator_id":  -1,
 			})
 			})
-			LabelHandel(data.Label, 1, data.UId, data.Level, data.Trailstatus, data.Trailstatus, data.LabelChangeTime)
+			LabelHandel(tx, data.Label, 1, data.UId, data.Level, data.Trailstatus, data.Trailstatus, data.LabelChangeTime)
 		}
 		}
 		return ok && updateId1 > -1 && updateId2 > -1 && updateId3 > -1 && updateId4 > -1 && updateId5 > -1 && updateId6 > -1 && updateId7 > -1 && updateId8 > -1 && updateId9 > -1 && updateId10 > -1 && updateId11 > -1 && updateId12 > -1 && updateId13 > -1
 		return ok && updateId1 > -1 && updateId2 > -1 && updateId3 > -1 && updateId4 > -1 && updateId5 > -1 && updateId6 > -1 && updateId7 > -1 && updateId8 > -1 && updateId9 > -1 && updateId10 > -1 && updateId11 > -1 && updateId12 > -1 && updateId13 > -1
 	}) {
 	}) {
@@ -2135,7 +2135,7 @@ func clueInfoUpdate(data ClueMapEntity) bool {
 }
 }
 
 
 // 线索标签修改 label  labelChangeTime
 // 线索标签修改 label  labelChangeTime
-func LabelHandel(oldlabelType, labelType int64, uId, level, oldTrailstatusCode, trailstatusCode, labelChangeTime string) {
+func LabelHandel(tx *sql.Tx, oldlabelType, labelType int64, uId, level, oldTrailstatusCode, trailstatusCode, labelChangeTime string) {
 	log.Println("线索标签修改:", oldlabelType, labelType, uId, level, oldTrailstatusCode, trailstatusCode, labelChangeTime)
 	log.Println("线索标签修改:", oldlabelType, labelType, uId, level, oldTrailstatusCode, trailstatusCode, labelChangeTime)
 	//先查询以前什么类型
 	//先查询以前什么类型
 	if trailstatusCode != "01" && oldTrailstatusCode != "01" {
 	if trailstatusCode != "01" && oldTrailstatusCode != "01" {
@@ -2177,12 +2177,23 @@ func LabelHandel(oldlabelType, labelType int64, uId, level, oldTrailstatusCode,
 		}
 		}
 	}
 	}
 	if updateLabelType > 0 {
 	if updateLabelType > 0 {
-		ok := TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{
-			"uid": uId,
-		}, 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,
+			})
+		}
+
 		log.Println("线索标签修改", ok)
 		log.Println("线索标签修改", ok)
 	}
 	}
 }
 }