xuzhiheng 1 年之前
父節點
當前提交
4e99b397ae
共有 1 個文件被更改,包括 14 次插入5 次删除
  1. 14 5
      service/clue.go

+ 14 - 5
service/clue.go

@@ -587,8 +587,9 @@ func DrawClues(positionId, count1, count2, count3 int64) int {
 	}
 	//
 	if count1 > 0 {
-		counts := 0
+		counts, counts1 := 0, 0
 		for {
+			counts1++
 			data := JyBiTidb.SelectBySql(`SELECT max(c.createTime) as ctime,a.id,a.trailstatus,a.cluename FROM dwd_f_crm_clue_info a 
 					LEFT JOIN Call_Accounting.voice_record c ON c.CalledNo = a.phone
 					WHERE a.level_open = 1 AND a.is_assign = 0 AND a.uid !="" AND a.is_transfer != 1 GROUP BY a.id ORDER BY ctime asc limit 1`)
@@ -602,11 +603,16 @@ func DrawClues(positionId, count1, count2, count3 int64) int {
 				drawCount += int(count1)
 				break
 			}
+			if counts1 > 4*int(count1) {
+				count2 += count1 - int64(counts)
+				break
+			}
 		}
 	}
 	if count2 > 0 {
-		counts := 0
+		counts, counts1 := 0, 0
 		for {
+			counts1++
 			data := JyBiTidb.SelectBySql(`SELECT max(c.createTime) as ctime,a.id,a.trailstatus FROM dwd_f_crm_clue_info a 
 					LEFT JOIN Call_Accounting.voice_record c ON c.CalledNo = a.phone
 					WHERE a.level_open = 2 AND a.is_assign = 0 AND a.uid !="" AND a.is_transfer != 1 GROUP BY a.id ORDER BY ctime asc limit 1`)
@@ -620,11 +626,16 @@ func DrawClues(positionId, count1, count2, count3 int64) int {
 				drawCount += int(count2)
 				break
 			}
+			if counts1 > 4*int(count2) {
+				count3 += count2 - int64(counts)
+				break
+			}
 		}
 	}
 	if count3 > 0 {
-		counts := 0
+		counts, counts1 := 0, 0
 		for {
+			counts1++
 			data := JyBiTidb.SelectBySql(`SELECT max(c.createTime) as ctime,a.id,a.trailstatus FROM dwd_f_crm_clue_info a 
 					LEFT JOIN Call_Accounting.voice_record c ON c.CalledNo = a.phone
 					WHERE a.level_open = 3 AND a.is_assign = 0 AND a.uid !="" AND a.is_transfer != 1 GROUP BY a.id ORDER BY ctime asc limit 1`)
@@ -639,7 +650,6 @@ func DrawClues(positionId, count1, count2, count3 int64) int {
 				break
 			}
 		}
-
 	}
 	return drawCount
 }
@@ -654,7 +664,6 @@ func batchDraw(data []map[string]interface{}, nowTime, seatNumber, name string,
 			if cdata != nil && len(*cdata) > 0 {
 				salePositionId := common.Int64All((*cdata)["position_id"])
 				if pcount := JyBiMysql.Count("dwd_f_crm_personnel_management", map[string]interface{}{"resign": 0, "position_id": salePositionId}); pcount > 0 {
-					//
 					return count
 				} else {
 					saledata := JyBiMysql.SelectBySql(`SELECT position_id from dwd_d_crm_department_level_succbi WHERE bi_pcode in (SELECT bi_pcode from dwd_d_crm_department_level_succbi WHERE position_id = ?) AND resign = 0`, salePositionId)