xuzhiheng 1 jaar geleden
bovenliggende
commit
5b322e0999
1 gewijzigde bestanden met toevoegingen van 8 en 6 verwijderingen
  1. 8 6
      service/clue.go

+ 8 - 6
service/clue.go

@@ -591,10 +591,10 @@ func DrawClues(positionId, count1, count2, count3 int64) int {
 		counts, counts1 := 0, 0
 		for {
 			logx.Info("等级1线索领取", count1, counts1, counts)
-			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`)
+					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`, counts1)
+			counts1++
 			if data != nil && len(*data) > 0 {
 				count := batchDraw(*data, nowTime, seatNumber, name, positionId, "2")
 				if count > 0 {
@@ -616,10 +616,10 @@ func DrawClues(positionId, count1, count2, count3 int64) int {
 		counts, counts1 := 0, 0
 		for {
 			logx.Info("等级2线索领取", count2, counts1, counts)
-			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`)
+					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`, counts1)
+			counts1++
 			if data != nil && len(*data) > 0 {
 				count := batchDraw(*data, nowTime, seatNumber, name, positionId, "2")
 				if count > 0 {
@@ -641,10 +641,10 @@ func DrawClues(positionId, count1, count2, count3 int64) int {
 		counts, counts1 := 0, 0
 		for {
 			logx.Info("等级3线索领取", count3, counts1, counts)
-			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`)
+					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`, counts1)
+			counts1++
 			if data != nil && len(*data) > 0 {
 				count := batchDraw(*data, nowTime, seatNumber, name, positionId, "2")
 				if count > 0 {
@@ -674,6 +674,7 @@ 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 {
+					logx.Info("当前线索有在职销售 ", salePositionId)
 					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)
@@ -686,6 +687,7 @@ func batchDraw(data []map[string]interface{}, nowTime, seatNumber, name string,
 							}
 						}
 						if !isOk {
+							logx.Info("当前线索销售离职,只能同部门领取 ", salePositionId)
 							return count
 						}
 					}