|
@@ -408,7 +408,7 @@ func autoDraw(mode, cluename, phone string, isGroup, isCommerce int) (positionId
|
|
|
sdata := TiDb.SelectBySql(`SELECT b.name,b.position_id,b.seat_number from dwd_d_crm_department_level_succbi a INNER JOIN dwd_f_crm_personnel_management b on a.position_id = b.position_id where a.bi_pcode = (SELECT bi_pcode from dwd_d_crm_department_level_succbi where position_id = ?) and b.role_id = 3`, positionId)
|
|
|
if sdata != nil && len(*sdata) > 0 {
|
|
|
for _, m := range *sdata {
|
|
|
- if !FindUpperLimit(gconv.String(positionId), "positionId") {
|
|
|
+ if !FindUpperLimit(gconv.String(positionId), mode, true) {
|
|
|
positionId = common.Int64All(m["position_id"])
|
|
|
seatNumber = common.ObjToString(m["seat_number"])
|
|
|
saleName = common.ObjToString(m["name"])
|
|
@@ -422,7 +422,7 @@ func autoDraw(mode, cluename, phone string, isGroup, isCommerce int) (positionId
|
|
|
return
|
|
|
}
|
|
|
} else {
|
|
|
- if FindUpperLimit(gconv.String(positionId), "positionId") {
|
|
|
+ if FindUpperLimit(gconv.String(positionId), mode, true) {
|
|
|
isFreeze = true
|
|
|
}
|
|
|
}
|
|
@@ -482,19 +482,15 @@ func autoDraw(mode, cluename, phone string, isGroup, isCommerce int) (positionId
|
|
|
res := int64(0)
|
|
|
countres := 0
|
|
|
for _, v := range *countData {
|
|
|
-
|
|
|
if common.IntAll(v["status"]) == 1 {
|
|
|
- log.Println("222", v, FindUpperLimit(gconv.String(common.Int64All(v["position_id"])), "positionId"))
|
|
|
- if FindUpperLimit(gconv.String(common.Int64All(v["position_id"])), "positionId") {
|
|
|
+ if FindUpperLimit(gconv.String(v["position_id"]), mode, true) {
|
|
|
continue
|
|
|
}
|
|
|
if countres == 0 {
|
|
|
- log.Println("111", v)
|
|
|
res = common.Int64All(v["count"])
|
|
|
positionId = common.Int64All(v["position_id"])
|
|
|
} else {
|
|
|
if common.Int64All(v["count"]) <= res {
|
|
|
- log.Println("3", v)
|
|
|
res = common.Int64All(v["count"])
|
|
|
positionId = common.Int64All(v["position_id"])
|
|
|
}
|
|
@@ -507,7 +503,7 @@ func autoDraw(mode, cluename, phone string, isGroup, isCommerce int) (positionId
|
|
|
} else {
|
|
|
for _, kv := range *data {
|
|
|
positionId1 := gconv.String(kv["position_id"])
|
|
|
- if !FindUpperLimit(positionId1, "positionId") {
|
|
|
+ if !FindUpperLimit(positionId1, "", false) {
|
|
|
saleName = common.ObjToString(kv["name"])
|
|
|
positionId = common.Int64All((*data)[0]["position_id"])
|
|
|
saleName = common.ObjToString((*data)[0]["name"])
|
|
@@ -565,20 +561,18 @@ func GetCompanyType(companyName string) (int, int) {
|
|
|
}
|
|
|
|
|
|
// 查询是否达上限
|
|
|
-func FindUpperLimit(positionId string, dataType string) bool {
|
|
|
+func FindUpperLimit(positionId string, level string, isAdd bool) bool {
|
|
|
if positionId == "" {
|
|
|
return false
|
|
|
}
|
|
|
- if dataType == "positionId" {
|
|
|
- fmt.Println("111", positionId, TiDb.CountBySql(`select count(1) from dwd_f_crm_clue_info where position_id=? and is_assign=1 `, positionId))
|
|
|
- return TiDb.CountBySql(`select count(1) from dwd_f_crm_clue_info where position_id=? and is_assign=1 and trailstatus != '08' `, positionId) >= cfg.AllocationCap
|
|
|
- //return TiDb.CountBySql(`select count(1) from dwd_f_crm_clue_info where position_id=? and is_assign=1 `, positionId) >= cfg.AllocationCap
|
|
|
- } else {
|
|
|
- fmt.Println("222", positionId, TiDb.CountBySql(`select count(1) from dwd_f_crm_clue_info where seatNumber=? and is_assign `, positionId))
|
|
|
- return TiDb.CountBySql(`select count(1) from dwd_f_crm_clue_info where seatNumber=? and is_assign and trailstatus != '08' `, positionId) >= cfg.AllocationCap
|
|
|
- //return TiDb.CountBySql(`select count(1) from dwd_f_crm_clue_info where seatNumber=? and is_assign `, positionId) >= cfg.AllocationCap
|
|
|
+ isFull := false
|
|
|
+ fmt.Println("111", positionId, TiDb.CountBySql(`select count(1) from dwd_f_crm_clue_info where position_id=? and is_assign=1 `, positionId))
|
|
|
+ isFull = TiDb.CountBySql(`select count(1) from dwd_f_crm_clue_info where position_id=? and is_assign=1 and trailstatus != '08' `, positionId) >= cfg.AllocationCap
|
|
|
|
|
|
+ if isFull && isAdd && level != "" {
|
|
|
+ TiDb.UpdateOrDeleteBySql(`update dwd_f_crm_clue_autodraw_record set count = count + 1 where position_id = ? and clue_level = ?`, positionId, level)
|
|
|
}
|
|
|
+ return isFull
|
|
|
}
|
|
|
func getSeatNumberPositionId(seatNumber string) (positionId int64) {
|
|
|
saleData := TiDb.FindOne("dwd_f_crm_personnel_management", map[string]interface{}{"seat_number": seatNumber}, "", "")
|