|
@@ -2,6 +2,7 @@ package main
|
|
|
|
|
|
import (
|
|
import (
|
|
"database/sql"
|
|
"database/sql"
|
|
|
|
+ "fmt"
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
"log"
|
|
"log"
|
|
"time"
|
|
"time"
|
|
@@ -509,3 +510,77 @@ func PhoneState(uid, seatNumber, createtime string) bool {
|
|
}
|
|
}
|
|
return false
|
|
return false
|
|
}
|
|
}
|
|
|
|
+func LockHandle() {
|
|
|
|
+ time.Now()
|
|
|
|
+ log.Println("线索锁定定时任务开始")
|
|
|
|
+ timeData := -1 * (db.CornExp8 + 5)
|
|
|
|
+ timeDate := time.Now().Add(time.Duration(timeData) * time.Second)
|
|
|
|
+ timeStr := timeDate.Format("2006-01-02 15:04:05")
|
|
|
|
+ a := 1
|
|
|
|
+ fool := false
|
|
|
|
+ page := 1
|
|
|
|
+ pageSize := 1000
|
|
|
|
+ for !fool {
|
|
|
|
+ sqlStr := fmt.Sprintf(`select id,cluename,position_id,updatetime,company_nature,company_verification,lock_status from dwd_f_crm_clue_info where updatetime>="%s" order by updatetime limit %d OFFSET %d`, timeStr, pageSize, (page-1)*pageSize)
|
|
|
|
+ data := TiDb.SelectBySql(sqlStr)
|
|
|
|
+ if len(*data) == 0 {
|
|
|
|
+ fool = true
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+ for _, v := range *data {
|
|
|
|
+ log.Println(a, gconv.String(v["updatetime"]))
|
|
|
|
+ a++
|
|
|
|
+ clue_id := gconv.Int64(v["id"])
|
|
|
|
+ cluename := gconv.String(v["cluename"])
|
|
|
|
+ position_id := gconv.String(v["position_id"])
|
|
|
|
+ company_nature := gconv.Int64(v["company_nature"])
|
|
|
|
+ company_verification := gconv.Int64(v["company_verification"])
|
|
|
|
+ lock_status := gconv.Int64(v["lock_status"])
|
|
|
|
+ //非集团在工商需要查询其他数据是否分配的有人
|
|
|
|
+ if company_nature == 0 && company_verification == 1 {
|
|
|
|
+ status4Data := TiDb.SelectBySql(fmt.Sprintf(`select GROUP_CONCAT(DISTINCT position_id) as position_id from dwd_f_crm_clue_info where cluename="%s" and position_id>0 `, cluename))
|
|
|
|
+ if len(*status4Data) > 0 || status4Data != nil {
|
|
|
|
+ position_id = gconv.String((*status4Data)[0]["position_id"])
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if company_nature == 1 && lock_status != 3 {
|
|
|
|
+ //无需锁定处理
|
|
|
|
+ if lock_status != 3 {
|
|
|
|
+ go UpdateData(3, map[string]interface{}{
|
|
|
|
+ "id": clue_id,
|
|
|
|
+ }, 3, "")
|
|
|
|
+ }
|
|
|
|
+ } else if company_nature == 0 && company_verification == 1 && position_id != "" {
|
|
|
|
+ //已锁定处理
|
|
|
|
+ if lock_status != 1 {
|
|
|
|
+ go UpdateData(1, map[string]interface{}{
|
|
|
|
+ "cluename": cluename,
|
|
|
|
+ }, 1, position_id)
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ //未锁定处理
|
|
|
|
+ if lock_status != 2 {
|
|
|
|
+ go UpdateData(2, map[string]interface{}{
|
|
|
|
+ "id": clue_id,
|
|
|
|
+ }, 2, "")
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ page++
|
|
|
|
+ }
|
|
|
|
+ log.Println("线索锁定定时任务结束")
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func UpdateData(lockStatus int64, query map[string]interface{}, status int, positionId string) {
|
|
|
|
+ if status != 1 {
|
|
|
|
+ TiDb.Update("dwd_f_crm_clue_info", query, map[string]interface{}{
|
|
|
|
+ "lock_status": lockStatus,
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ TiDb.Update("dwd_f_crm_clue_info", query, map[string]interface{}{
|
|
|
|
+ "lock_status": lockStatus,
|
|
|
|
+ "lock_position_id": positionId,
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|