|
@@ -7,6 +7,7 @@ import (
|
|
"fmt"
|
|
"fmt"
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
"io/ioutil"
|
|
"io/ioutil"
|
|
|
|
+ "log"
|
|
"math"
|
|
"math"
|
|
"net/http"
|
|
"net/http"
|
|
"net/url"
|
|
"net/url"
|
|
@@ -540,8 +541,13 @@ func DrawClues(positionId, count1, count2, count3 int64) int {
|
|
counts, counts1 := 0, 0
|
|
counts, counts1 := 0, 0
|
|
for {
|
|
for {
|
|
logx.Info("等级1线索领取", count1, counts1, counts)
|
|
logx.Info("等级1线索领取", count1, counts1, counts)
|
|
|
|
+<<<<<<< HEAD
|
|
data := JyBiTidb.SelectBySql(`SELECT a.last_ring_time as ctime,a.id,a.trailstatus,a.cluename FROM dwd_f_crm_clue_info a
|
|
data := JyBiTidb.SelectBySql(`SELECT a.last_ring_time as ctime,a.id,a.trailstatus,a.cluename FROM dwd_f_crm_clue_info a
|
|
WHERE a.level_open = 1 AND a.is_assign=0 and (a.lock_position_id is null or a.lock_position_id=? ) AND a.uid !="" AND a.is_transfer != 1 GROUP BY a.id ORDER BY ctime asc limit ?,1`, counts1, positionId)
|
|
WHERE a.level_open = 1 AND a.is_assign=0 and (a.lock_position_id is null or a.lock_position_id=? ) AND a.uid !="" AND a.is_transfer != 1 GROUP BY a.id ORDER BY ctime asc limit ?,1`, counts1, positionId)
|
|
|
|
+=======
|
|
|
|
+ data := JyBiTidb.SelectBySql(`SELECT a.label,a.labelChangeTime,a.last_ring_time as ctime,a.id,a.trailstatus,a.cluename FROM dwd_f_crm_clue_info a
|
|
|
|
+ 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)
|
|
|
|
+>>>>>>> master
|
|
counts1++
|
|
counts1++
|
|
if data != nil && len(*data) > 0 {
|
|
if data != nil && len(*data) > 0 {
|
|
count := batchDraw(*data, nowTime, seatNumber, name, positionId, "2")
|
|
count := batchDraw(*data, nowTime, seatNumber, name, positionId, "2")
|
|
@@ -564,8 +570,13 @@ func DrawClues(positionId, count1, count2, count3 int64) int {
|
|
counts, counts1 := 0, 0
|
|
counts, counts1 := 0, 0
|
|
for {
|
|
for {
|
|
logx.Info("等级2线索领取", count2, counts1, counts)
|
|
logx.Info("等级2线索领取", count2, counts1, counts)
|
|
|
|
+<<<<<<< HEAD
|
|
data := JyBiTidb.SelectBySql(`SELECT a.last_ring_time as ctime,a.id,a.trailstatus,a.cluename FROM dwd_f_crm_clue_info a
|
|
data := JyBiTidb.SelectBySql(`SELECT a.last_ring_time as ctime,a.id,a.trailstatus,a.cluename FROM dwd_f_crm_clue_info a
|
|
WHERE a.level_open = 2 AND a.is_assign=0 and (a.lock_position_id is null or a.lock_position_id=? ) AND a.uid !="" AND a.is_transfer != 1 GROUP BY a.id ORDER BY ctime asc limit ?,1`, counts1, positionId)
|
|
WHERE a.level_open = 2 AND a.is_assign=0 and (a.lock_position_id is null or a.lock_position_id=? ) AND a.uid !="" AND a.is_transfer != 1 GROUP BY a.id ORDER BY ctime asc limit ?,1`, counts1, positionId)
|
|
|
|
+=======
|
|
|
|
+ data := JyBiTidb.SelectBySql(`SELECT a.label,a.labelChangeTime,a.last_ring_time as ctime,a.id,a.trailstatus,a.cluename FROM dwd_f_crm_clue_info a
|
|
|
|
+ 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)
|
|
|
|
+>>>>>>> master
|
|
counts1++
|
|
counts1++
|
|
if data != nil && len(*data) > 0 {
|
|
if data != nil && len(*data) > 0 {
|
|
count := batchDraw(*data, nowTime, seatNumber, name, positionId, "2")
|
|
count := batchDraw(*data, nowTime, seatNumber, name, positionId, "2")
|
|
@@ -588,7 +599,7 @@ func DrawClues(positionId, count1, count2, count3 int64) int {
|
|
counts, counts1 := 0, 0
|
|
counts, counts1 := 0, 0
|
|
for {
|
|
for {
|
|
logx.Info("等级3线索领取", count3, counts1, counts)
|
|
logx.Info("等级3线索领取", count3, counts1, counts)
|
|
- data := JyBiTidb.SelectBySql(`SELECT a.last_ring_time as ctime,a.id,a.trailstatus,a.cluename FROM dwd_f_crm_clue_info a
|
|
|
|
|
|
+ data := JyBiTidb.SelectBySql(`SELECT a.label,a.labelChangeTime, a.last_ring_time as ctime,a.id,a.trailstatus,a.cluename FROM dwd_f_crm_clue_info a
|
|
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)
|
|
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++
|
|
counts1++
|
|
if data != nil && len(*data) > 0 {
|
|
if data != nil && len(*data) > 0 {
|
|
@@ -771,7 +782,11 @@ func batchDraw(data []map[string]interface{}, nowTime, seatNumber, name string,
|
|
"BCPCID": common.GetRandom(32),
|
|
"BCPCID": common.GetRandom(32),
|
|
"operator_id": positionId,
|
|
"operator_id": positionId,
|
|
})
|
|
})
|
|
-
|
|
|
|
|
|
+ //标签处理
|
|
|
|
+ labelChangeTime := gconv.String(v["labelChangeTime"])
|
|
|
|
+ label := gconv.Int64(v["label"])
|
|
|
|
+ trailstatusCode := gconv.String(v["trailstatus"])
|
|
|
|
+ LabelHandel(tx, label, 3, clueId, "", "01", trailstatusCode, labelChangeTime)
|
|
return ok1 && recordId > 0 && recordId1 > 0 && recordId2 > 0 && recordId3 > -1 && recordId4 > -1
|
|
return ok1 && recordId > 0 && recordId1 > 0 && recordId2 > 0 && recordId3 > -1 && recordId4 > -1
|
|
}) {
|
|
}) {
|
|
logx.Info("领取线索成功")
|
|
logx.Info("领取线索成功")
|
|
@@ -903,6 +918,7 @@ func ClueImportSync(this *biservice.ClueImportReq) (string, int) {
|
|
pcode := common.ObjToString((*sourceData)["pcode"])
|
|
pcode := common.ObjToString((*sourceData)["pcode"])
|
|
dataMap["top_cluetype"] = pcode
|
|
dataMap["top_cluetype"] = pcode
|
|
dataMap["sub_cluetype"] = code
|
|
dataMap["sub_cluetype"] = code
|
|
|
|
+ dataMap["clue_level"] = gconv.String((*sourceData)["clue_level"])
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if isOK {
|
|
if isOK {
|
|
@@ -924,6 +940,7 @@ func ClueImportSync(this *biservice.ClueImportReq) (string, int) {
|
|
phone := common.ObjToString(v["phone"])
|
|
phone := common.ObjToString(v["phone"])
|
|
cluename := common.ObjToString(v["cluename"])
|
|
cluename := common.ObjToString(v["cluename"])
|
|
name := common.ObjToString(v["name"])
|
|
name := common.ObjToString(v["name"])
|
|
|
|
+ level := gconv.String(v["clue_level"])
|
|
position := common.ObjToString(v["position"])
|
|
position := common.ObjToString(v["position"])
|
|
isGroup, isCommerce, _ := CompanyType(cluename)
|
|
isGroup, isCommerce, _ := CompanyType(cluename)
|
|
clueData := JyBiTidb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone}, "", "")
|
|
clueData := JyBiTidb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone}, "", "")
|
|
@@ -1004,6 +1021,9 @@ func ClueImportSync(this *biservice.ClueImportReq) (string, int) {
|
|
old_sub_cluetype := common.ObjToString((*clueData)["sub_cluetype"])
|
|
old_sub_cluetype := common.ObjToString((*clueData)["sub_cluetype"])
|
|
top_cluetype := common.ObjToString(v["top_cluetype"])
|
|
top_cluetype := common.ObjToString(v["top_cluetype"])
|
|
sub_cluetype := common.ObjToString(v["sub_cluetype"])
|
|
sub_cluetype := common.ObjToString(v["sub_cluetype"])
|
|
|
|
+ labelChangeTime := gconv.String(v["labelChangeTime"])
|
|
|
|
+ label := gconv.Int64(v["label"])
|
|
|
|
+ trailstatusCode := gconv.String(v["trailstatus"])
|
|
old_topname, old_subname := "", ""
|
|
old_topname, old_subname := "", ""
|
|
if old_top_cluetype != "" {
|
|
if old_top_cluetype != "" {
|
|
pcodeData := JyBiTidb.FindOne("dwd_d_crm_cluetype_code", map[string]interface{}{"code": old_top_cluetype}, "", "")
|
|
pcodeData := JyBiTidb.FindOne("dwd_d_crm_cluetype_code", map[string]interface{}{"code": old_top_cluetype}, "", "")
|
|
@@ -1093,7 +1113,7 @@ func ClueImportSync(this *biservice.ClueImportReq) (string, int) {
|
|
JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
"clue_id": clueId,
|
|
"clue_id": clueId,
|
|
"position_id": -1,
|
|
"position_id": -1,
|
|
- "change_field": "sub_cluetype",
|
|
|
|
|
|
+ "change_field": "sub_cluetype", //111
|
|
"change_type": "基本信息变更",
|
|
"change_type": "基本信息变更",
|
|
"old_value": common.If(old_subname == "", "/", old_subname),
|
|
"old_value": common.If(old_subname == "", "/", old_subname),
|
|
"new_value": v["clueSource"],
|
|
"new_value": v["clueSource"],
|
|
@@ -1101,6 +1121,7 @@ func ClueImportSync(this *biservice.ClueImportReq) (string, int) {
|
|
"BCPCID": common.GetRandom(32),
|
|
"BCPCID": common.GetRandom(32),
|
|
"operator_id": this.PositionId,
|
|
"operator_id": this.PositionId,
|
|
})
|
|
})
|
|
|
|
+ LabelHandel(nil, label, 2, clueId, level, trailstatusCode, trailstatusCode, labelChangeTime)
|
|
}
|
|
}
|
|
JyBiTidb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, updateData)
|
|
JyBiTidb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, updateData)
|
|
} else if is_assign == 1 {
|
|
} else if is_assign == 1 {
|
|
@@ -1176,13 +1197,14 @@ func ClueImportSync(this *biservice.ClueImportReq) (string, int) {
|
|
"BCPCID": common.GetRandom(32),
|
|
"BCPCID": common.GetRandom(32),
|
|
"operator_id": this.PositionId,
|
|
"operator_id": this.PositionId,
|
|
})
|
|
})
|
|
|
|
+ LabelHandel(nil, label, 2, positionId, level, trailstatusCode, trailstatusCode, labelChangeTime)
|
|
}
|
|
}
|
|
if sub_cluetype != "" && sub_cluetype != old_sub_cluetype {
|
|
if sub_cluetype != "" && sub_cluetype != old_sub_cluetype {
|
|
updateData["position"] = position
|
|
updateData["position"] = position
|
|
JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
"clue_id": clueId,
|
|
"clue_id": clueId,
|
|
"position_id": positionId,
|
|
"position_id": positionId,
|
|
- "change_field": "sub_cluetype",
|
|
|
|
|
|
+ "change_field": "sub_cluetype", //222
|
|
"change_type": "基本信息变更",
|
|
"change_type": "基本信息变更",
|
|
"old_value": common.If(old_subname == "", "/", old_subname),
|
|
"old_value": common.If(old_subname == "", "/", old_subname),
|
|
"new_value": v["clueSource"],
|
|
"new_value": v["clueSource"],
|
|
@@ -1190,6 +1212,7 @@ func ClueImportSync(this *biservice.ClueImportReq) (string, int) {
|
|
"BCPCID": common.GetRandom(32),
|
|
"BCPCID": common.GetRandom(32),
|
|
"operator_id": this.PositionId,
|
|
"operator_id": this.PositionId,
|
|
})
|
|
})
|
|
|
|
+
|
|
}
|
|
}
|
|
JyBiTidb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, updateData)
|
|
JyBiTidb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, updateData)
|
|
JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
@@ -1269,3 +1292,66 @@ func FindClueInfo(in *biservice.FindClueInfoReq) (map[string]interface{}, int64)
|
|
}
|
|
}
|
|
return data, 0
|
|
return data, 0
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// 线索标签修改 label labelChangeTime
|
|
|
|
+func LabelHandel(tx *sql.Tx, oldlabelType, labelType, clueId int64, level, oldTrailstatusCode, trailstatusCode, labelChangeTime string) {
|
|
|
|
+ log.Println("线索标签修改:", oldlabelType, labelType, clueId, level, trailstatusCode, labelChangeTime)
|
|
|
|
+ //先查询以前什么类型
|
|
|
|
+ if trailstatusCode != "01" && oldTrailstatusCode != "01" {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ updateLabelType := int64(0)
|
|
|
|
+ nowStr := time.Now().Format("2006-01-02")
|
|
|
|
+ if labelType == 1 {
|
|
|
|
+ //直接更新
|
|
|
|
+ if labelChangeTime == nowStr {
|
|
|
|
+ if oldlabelType != 1 {
|
|
|
|
+ updateLabelType = labelType
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ updateLabelType = labelType
|
|
|
|
+ }
|
|
|
|
+ } else if labelType == 2 {
|
|
|
|
+ if level != "A" && level != "B" && level != "C" {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ //查询以前是什么数据
|
|
|
|
+ if labelChangeTime == nowStr {
|
|
|
|
+ //同一天修改过
|
|
|
|
+ if oldlabelType != 1 {
|
|
|
|
+ updateLabelType = labelType
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ updateLabelType = labelType
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ //查询以前是什么数据
|
|
|
|
+ if labelChangeTime == nowStr {
|
|
|
|
+ //同一天修改过
|
|
|
|
+ if oldlabelType != 3 {
|
|
|
|
+ updateLabelType = oldlabelType
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ updateLabelType = labelType
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if updateLabelType > 0 {
|
|
|
|
+ ok := false
|
|
|
|
+ if tx == nil {
|
|
|
|
+ ok = JyBiTidb.Update("dwd_f_crm_clue_info", map[string]interface{}{
|
|
|
|
+ "id": clueId,
|
|
|
|
+ }, map[string]interface{}{
|
|
|
|
+ "label": updateLabelType,
|
|
|
|
+ "labelChangeTime": nowStr,
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ ok = JyBiTidb.UpdateByTx(tx, "dwd_f_crm_clue_info", map[string]interface{}{
|
|
|
|
+ "id": clueId,
|
|
|
|
+ }, map[string]interface{}{
|
|
|
|
+ "label": updateLabelType,
|
|
|
|
+ "labelChangeTime": nowStr,
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ log.Println("线索标签修改:", ok)
|
|
|
|
+ }
|
|
|
|
+}
|