|
@@ -270,13 +270,17 @@ func DistributeClueShow(this *biservice.DistributeClueShowReq, allocationCap int
|
|
|
for _, v := range *cdata {
|
|
|
count := common.IntAll(v["count"])
|
|
|
cluename := common.ObjToString(v["cluename"])
|
|
|
- minCount, minIndex := int64(0), 0
|
|
|
+ minCount, minIndex := int64(0), -1
|
|
|
isindexok := false
|
|
|
- for k, r := range rdata {
|
|
|
+ k1 := 0
|
|
|
+ for _, r := range rdata {
|
|
|
+ minCount, minIndex = int64(0), -1
|
|
|
if !r.FullStatus {
|
|
|
if this.DataType == 1 {
|
|
|
- if k == 0 {
|
|
|
+ if k1 == 0 {
|
|
|
+ log.Println(r)
|
|
|
minCount = r.CompanyCounts
|
|
|
+ break
|
|
|
}
|
|
|
} else {
|
|
|
if r.CompanyCounts < r.CompanyCount {
|
|
@@ -299,53 +303,58 @@ func DistributeClueShow(this *biservice.DistributeClueShowReq, allocationCap int
|
|
|
}
|
|
|
}
|
|
|
for k, r := range rdata {
|
|
|
- countNumber := rdata[minIndex].ExistingCount + rdata[minIndex].ClueCount + int64(count)
|
|
|
- fmt.Println(1111, k, rdata[minIndex], rdata[minIndex].ExistingCount, rdata[minIndex].ClueCount, int64(count))
|
|
|
- if countNumber >= allocationCap || r.FullStatus {
|
|
|
- if gconv.Int(allocationCap-rdata[minIndex].ExistingCount-rdata[minIndex].ClueCount) == 0 {
|
|
|
- r.FullStatus = true
|
|
|
- minIndex = minIndex + 1
|
|
|
- continue
|
|
|
- } else {
|
|
|
- r.FullStatus = true
|
|
|
- count = gconv.Int(allocationCap - rdata[minIndex].ExistingCount - rdata[minIndex].ClueCount)
|
|
|
- }
|
|
|
- if this.UpdatePositionID == rdata[minIndex].PositionId {
|
|
|
- return &biservice.DistributeClueShowResp{
|
|
|
- ErrorCode: 1,
|
|
|
- ErrorMsg: "超出私海线索上限",
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
- if this.DataType == 1 {
|
|
|
+ countNumber := r.ExistingCount + r.ClueCount + int64(count)
|
|
|
+ if this.DataType == 1 {
|
|
|
+ if countNumber <= allocationCap {
|
|
|
if r.CompanyCounts <= minCount {
|
|
|
minCount = r.CompanyCounts
|
|
|
minIndex = k
|
|
|
}
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if countNumber <= allocationCap {
|
|
|
if r.CompanyCounts <= minCount && r.CompanyCounts < r.CompanyCount {
|
|
|
minCount = r.CompanyCounts
|
|
|
minIndex = k
|
|
|
}
|
|
|
- }
|
|
|
+ } /* else {
|
|
|
+ if this.DataType == 2 {
|
|
|
+ if r.CompanyCounts <= minCount && r.CompanyCounts < r.CompanyCount && this.UpdatePositionID == r.PositionId {
|
|
|
+ return &biservice.DistributeClueShowResp{
|
|
|
+ ErrorCode: 1,
|
|
|
+ ErrorMsg: "超出私海线索上限",
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }*/
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
fmt.Println(222, minIndex)
|
|
|
- if minIndex >= len(rdata) {
|
|
|
+ if minIndex == -1 {
|
|
|
continue
|
|
|
}
|
|
|
if this.DataType == 1 {
|
|
|
+ countNumber := rdata[minIndex].ExistingCount + rdata[minIndex].ClueCount + int64(count)
|
|
|
+ if countNumber == allocationCap {
|
|
|
+ rdata[minIndex].FullStatus = true
|
|
|
+ }
|
|
|
rdata[minIndex].CompanyCount++
|
|
|
rdata[minIndex].CompanyCounts++
|
|
|
rdata[minIndex].ClueCount += int64(count)
|
|
|
} else {
|
|
|
+ countNumber := rdata[minIndex].ExistingCount + rdata[minIndex].ClueCount + int64(count)
|
|
|
if rdata[minIndex].CompanyCounts < rdata[minIndex].CompanyCount {
|
|
|
isindexok = true
|
|
|
rdata[minIndex].CompanyCounts++
|
|
|
rdata[minIndex].ClueCount += int64(count)
|
|
|
+ if countNumber == allocationCap {
|
|
|
+ rdata[minIndex].FullStatus = true
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
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, ",") + `) ORDER BY createtime DESC LIMIT ` + gconv.String(count))
|
|
|
if iddata != nil { //分线索
|
|
@@ -370,6 +379,18 @@ func DistributeClueShow(this *biservice.DistributeClueShowReq, allocationCap int
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if this.DataType == 2 {
|
|
|
+ for _, v := range rdata {
|
|
|
+ if this.UpdatePositionID == v.PositionId {
|
|
|
+ if v.CompanyCounts < v.CompanyCount {
|
|
|
+ return &biservice.DistributeClueShowResp{
|
|
|
+ ErrorCode: 1,
|
|
|
+ ErrorMsg: "超出私海线索上限",
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return &biservice.DistributeClueShowResp{
|
|
|
ErrorCode: 0,
|
|
|
Data: rdata,
|