Browse Source

Merge branch 'dev/v1.0.6' of BaseService/biService into feature/v1.0.6

xuzhiheng 2 years ago
parent
commit
02b19dd50d
1 changed files with 68 additions and 68 deletions
  1. 68 68
      service/clue.go

+ 68 - 68
service/clue.go

@@ -81,24 +81,20 @@ func DistributeClueMore(saleMap map[string]map[string]interface{}, distributedAr
 				if isAssign == 1 {
 					oldpositionId := common.Int64All((*clueData)["position_id"])
 					updateClue := map[string]interface{}{
-						"position_id": positionId,
-						"seatNumber":  seatNumber,
-						"is_assign":   1,
-						"updatetime":  nowTime,
-						"comeintime":  nowTime,
+						"position_id":          positionId,
+						"seatNumber":           seatNumber,
+						"is_assign":            1,
+						"updatetime":           nowTime,
+						"comeintime":           nowTime,
+						"comeinsource_private": 4,
 					}
-					JyBiTidb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": v}, updateClue)
-					ok := JyBiTidb.Update("dwd_f_crm_private_sea", map[string]interface{}{"clue_id": v}, map[string]interface{}{
-						"position_id":  positionId,
-						"seatNumber":   seatNumber,
-						"comeinsource": 4,
-						"comeintime":   nowTime,
-						// "is_task":      1,
-						// "task_time":    nowTime,
-						// "tasktime":     nowTime,
-						// "taskstatus":   0,
-						// "tasksource":   "线索批量分配",
-					})
+					ok := JyBiTidb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": v}, updateClue)
+					// ok := JyBiTidb.Update("dwd_f_crm_private_sea", map[string]interface{}{"clue_id": v}, map[string]interface{}{
+					// 	"position_id":  positionId,
+					// 	"seatNumber":   seatNumber,
+					// 	"comeinsource": 4,
+					// 	"comeintime":   nowTime,
+					// })
 					if ok {
 						JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
 							"clue_id":      v,
@@ -138,30 +134,33 @@ func DistributeClueMore(saleMap map[string]map[string]interface{}, distributedAr
 					}
 				} else {
 					updateClue := map[string]interface{}{
-						"position_id": positionId,
-						"seatNumber":  seatNumber,
-						"is_assign":   1,
-						"updatetime":  nowTime,
-						"comeintime":  nowTime,
+						"position_id":          positionId,
+						"seatNumber":           seatNumber,
+						"is_assign":            1,
+						"updatetime":           nowTime,
+						"comeintime":           nowTime,
+						"comeinsource_private": 4,
+						"is_task":              0,
+						"taskstatus":           0,
 					}
 					if trailstatus != "08" {
 						updateClue["trailstatus"] = "01"
 					}
-					JyBiTidb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": v}, updateClue)
-					seaId := JyBiTidb.Insert("dwd_f_crm_private_sea", map[string]interface{}{
-						"clue_id":      v,
-						"position_id":  positionId,
-						"seatNumber":   seatNumber,
-						"comeinsource": 4,
-						"comeintime":   nowTime,
-						"is_task":      0,
-						// "task_time":    nowTime,
-						// "tasktime":     nowTime,
-						"taskstatus": 0,
-						// "tasksource":   "线索批量分配",
-					})
-					if seaId > 0 {
-						JyBiTidb.Delete("dwd_f_crm_open_sea", map[string]interface{}{"clue_id": v})
+					ok := JyBiTidb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": v}, updateClue)
+					// seaId := JyBiTidb.Insert("dwd_f_crm_private_sea", map[string]interface{}{
+					// 	"clue_id":      v,
+					// 	"position_id":  positionId,
+					// 	"seatNumber":   seatNumber,
+					// 	"comeinsource": 4,
+					// 	"comeintime":   nowTime,
+					// 	"is_task":      0,
+					// 	// "task_time":    nowTime,
+					// 	// "tasktime":     nowTime,
+					// 	"taskstatus": 0,
+					// 	// "tasksource":   "线索批量分配",
+					// })
+					if ok {
+						// JyBiTidb.Delete("dwd_f_crm_open_sea", map[string]interface{}{"clue_id": v})
 						JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
 							"clue_id":      v,
 							"position_id":  positionId,
@@ -211,9 +210,8 @@ func DrawClue(this *biservice.DrawClueReq) *biservice.AddProjectResp {
 func DrawClueSync(this *biservice.DrawClueReq) (int, int) {
 	if DataLock.TryLock() {
 		defer DataLock.Unlock()
-		count1 := JyBiTidb.Count("dwd_f_crm_open_sea", map[string]interface{}{"level": 1})
-		count2 := JyBiTidb.Count("dwd_f_crm_open_sea", map[string]interface{}{"level": 2})
-		// count3 := JyBiTidb.Count("dwd_f_crm_open_sea", map[string]interface{}{"level": 3})
+		count1 := JyBiTidb.Count("dwd_f_crm_clue_info", map[string]interface{}{"level": 1, "is_assign": 0})
+		count2 := JyBiTidb.Count("dwd_f_crm_clue_info", map[string]interface{}{"level": 2, "is_assign": 0})
 		counts1, counts2, counts3 := int64(0), int64(0), int64(0)
 		counts1 = int64(math.Ceil(float64(this.Count) / float64(10) * 5))
 		if this.Count-counts1 == 0 {
@@ -246,13 +244,13 @@ func DrawClueSync(this *biservice.DrawClueReq) (int, int) {
 func DrawClues(positionId, count1, count2, count3 int64) int {
 	data1, data2, data3, drawCount := &[]map[string]interface{}{}, &[]map[string]interface{}{}, &[]map[string]interface{}{}, 0
 	if count1 > 0 {
-		data1 = JyBiTidb.Find("dwd_f_crm_open_sea", map[string]interface{}{"level": 1}, "", "comeintime desc", 0, int(count1))
+		data1 = JyBiTidb.Find("dwd_f_crm_clue_info", map[string]interface{}{"level": 1, "is_assign": 0}, "", "", 0, int(count1))
 	}
 	if count2 > 0 {
-		data2 = JyBiTidb.Find("dwd_f_crm_open_sea", map[string]interface{}{"level": 2}, "", "comeintime desc", 0, int(count2))
+		data2 = JyBiTidb.Find("dwd_f_crm_clue_info", map[string]interface{}{"level": 2, "is_assign": 0}, "", "", 0, int(count2))
 	}
 	if count3 > 0 {
-		data3 = JyBiTidb.Find("dwd_f_crm_open_sea", map[string]interface{}{"level": 3}, "", "comeintime desc", 0, int(count3))
+		data3 = JyBiTidb.Find("dwd_f_crm_clue_info", map[string]interface{}{"level": 3, "is_assign": 0}, "", "", 0, int(count3))
 	}
 	nowTime := time.Now().Format("2006-01-02 15:04:05")
 	seatNumber, name := getSeatNumber(positionId)
@@ -282,37 +280,39 @@ func batchDraw(data []map[string]interface{}, nowTime, seatNumber, name string,
 				wg.Done()
 				<-ch
 			}()
-			clueId := common.Int64All(v["clue_id"])
-			trailstatus := ""
-			cluedata := JyBiTidb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, "", "")
-			if cluedata != nil && len(*cluedata) > 0 {
-				trailstatus = common.ObjToString((*cluedata)["trailstatus"])
-			}
+			clueId := common.Int64All(v["id"])
+			trailstatus := common.ObjToString(v["trailstatus"])
 			if JyBiMysql.ExecTx("领取线索等", func(tx *sql.Tx) bool {
 				updateClue := map[string]interface{}{
-					"position_id": positionId,
-					"seatNumber":  seatNumber,
-					"is_assign":   1,
-					"updatetime":  nowTime,
-					"comeintime":  nowTime,
+					"position_id":          positionId,
+					"seatNumber":           seatNumber,
+					"is_assign":            1,
+					"updatetime":           nowTime,
+					"comeintime":           nowTime,
+					"comeinsource_private": 3,
+					"is_task":              1,
+					"task_time":            nowTime,
+					"tasktime":             nowTime,
+					"taskstatus":           0,
+					"tasksource":           "领取公海线索",
 				}
 				if trailstatus != "08" {
 					updateClue["trailstatus"] = "01"
 				}
 				ok1 := JyBiTidb.UpdateByTx(tx, "dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, updateClue)
-				ok2 := JyBiTidb.DeleteByTx(tx, "dwd_f_crm_open_sea", map[string]interface{}{"clue_id": clueId})
-				seaId := JyBiTidb.InsertByTx(tx, "dwd_f_crm_private_sea", map[string]interface{}{
-					"clue_id":      clueId,
-					"seatNumber":   seatNumber,
-					"position_id":  positionId,
-					"comeintime":   nowTime,
-					"comeinsource": 3,
-					"is_task":      1,
-					"task_time":    nowTime,
-					"tasktime":     nowTime,
-					"taskstatus":   0,
-					"tasksource":   "领取公海线索",
-				})
+				// ok2 := JyBiTidb.DeleteByTx(tx, "dwd_f_crm_open_sea", map[string]interface{}{"clue_id": clueId})
+				// seaId := JyBiTidb.InsertByTx(tx, "dwd_f_crm_private_sea", map[string]interface{}{
+				// 	"clue_id":      clueId,
+				// 	"seatNumber":   seatNumber,
+				// 	"position_id":  positionId,
+				// 	"comeintime":   nowTime,
+				// 	"comeinsource": 3,
+				// 	"is_task":      1,
+				// 	"task_time":    nowTime,
+				// 	"tasktime":     nowTime,
+				// 	"taskstatus":   0,
+				// 	"tasksource":   "领取公海线索",
+				// })
 				recordId := JyBiTidb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
 					"clue_id":      clueId,
 					"position_id":  positionId,
@@ -366,7 +366,7 @@ func batchDraw(data []map[string]interface{}, nowTime, seatNumber, name string,
 						"operator_id":  positionId,
 					})
 				}
-				return ok1 && ok2 && seaId > 0 && recordId > 0 && recordId1 > 0 && recordId2 > 0 && recordId3 > -1 && recordId4 > -1
+				return ok1 && recordId > 0 && recordId1 > 0 && recordId2 > 0 && recordId3 > -1 && recordId4 > -1
 			}) {
 				log.Println("领取线索成功")
 			} else {