Browse Source

限制数量

xuzhiheng 1 year ago
parent
commit
023da63fbd
1 changed files with 9 additions and 1 deletions
  1. 9 1
      service/company.go

+ 9 - 1
service/company.go

@@ -46,6 +46,12 @@ func CompanyType(companyName string) (bool, bool) {
 }
 
 func DistributeClueShow(this *biservice.DistributeClueShowReq) *biservice.DistributeClueShowResp {
+	// if DistributeLock.TryLock() {
+	// 	defer DistributeLock.Unlock()
+
+	// } else {
+
+	// }
 	rdata := []*biservice.DistributeClueShowss{}
 	pArr := []string{}
 	for _, c := range this.Datas { //初始化返回数据
@@ -216,6 +222,7 @@ func DistributeClueShow(this *biservice.DistributeClueShowReq) *biservice.Distri
 				count := common.IntAll(v["count"])
 				cluename := common.ObjToString(v["cluename"])
 				minCount, minIndex := int64(0), 0
+				isindexok := false
 				for k, r := range rdata {
 					if this.DataType == 1 {
 						if k == 0 {
@@ -257,11 +264,12 @@ func DistributeClueShow(this *biservice.DistributeClueShowReq) *biservice.Distri
 					rdata[minIndex].ClueCount += int64(count)
 				} else {
 					if rdata[minIndex].CompanyCounts < rdata[minIndex].CompanyCount {
+						isindexok = true
 						rdata[minIndex].CompanyCounts++
 						rdata[minIndex].ClueCount += int64(count)
 					}
 				}
-				if this.DataType == 3 {
+				if this.DataType == 3 && isindexok {
 					iddata := JyBiTidb.SelectBySql(`SELECT id FROM dwd_f_crm_clue_info WHERE cluename = "` + cluename + `" and id in (` + strings.Join(clueArrs1, ",") + `)`)
 					if iddata != nil { //分线索
 						wg := new(sync.WaitGroup)