|
@@ -5,6 +5,7 @@ import (
|
|
"fmt"
|
|
"fmt"
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
"log"
|
|
"log"
|
|
|
|
+ "regexp"
|
|
"strings"
|
|
"strings"
|
|
"time"
|
|
"time"
|
|
|
|
|
|
@@ -368,6 +369,8 @@ func FormatData(data map[string]interface{}, item string) (bool, bool, bool) {
|
|
label := gconv.Int64((*uCount)["label"])
|
|
label := gconv.Int64((*uCount)["label"])
|
|
trailstatusCode := gconv.String((*uCount)["trailstatus"])
|
|
trailstatusCode := gconv.String((*uCount)["trailstatus"])
|
|
clueUpdateData := map[string]interface{}{}
|
|
clueUpdateData := map[string]interface{}{}
|
|
|
|
+ e_label := gconv.String((*uCount)["e_label"])
|
|
|
|
+ Ehandle(clueId, uId, userId, cluename, trailstatusCode, e_label)
|
|
if old_name != name && name != "" {
|
|
if old_name != name && name != "" {
|
|
clueUpdateData["name"] = name
|
|
clueUpdateData["name"] = name
|
|
AddChangeRecord(nil, clueId, position_id, "name", "基本信息变更", gconv.String(common.If(name != "", name, "/")), gconv.String(common.If(old_name != "", old_name, "/")), nowTime, BCPCID, -1)
|
|
AddChangeRecord(nil, clueId, position_id, "name", "基本信息变更", gconv.String(common.If(name != "", name, "/")), gconv.String(common.If(old_name != "", old_name, "/")), nowTime, BCPCID, -1)
|
|
@@ -480,6 +483,7 @@ func SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, c
|
|
"label": 1,
|
|
"label": 1,
|
|
"labelChangeTime": time.Now().Format("2006-01-02"),
|
|
"labelChangeTime": time.Now().Format("2006-01-02"),
|
|
})
|
|
})
|
|
|
|
+<<<<<<< HEAD
|
|
updateId1 = AddChangeRecord(tx, clueId, positionId, "", "创建线索", "系统自动创建", "", nowTime, "", -1)
|
|
updateId1 = AddChangeRecord(tx, clueId, positionId, "", "创建线索", "系统自动创建", "", nowTime, "", -1)
|
|
updateId2 = AddChangeRecord(tx, clueId, positionId, "position_id", "所属人变更", saleName, "/", nowTime, "", -1)
|
|
updateId2 = AddChangeRecord(tx, clueId, positionId, "position_id", "所属人变更", saleName, "/", nowTime, "", -1)
|
|
updateId3 = AddChangeRecord(tx, clueId, positionId, "trailstatus", "基本信息变更", "新增", "商机线索", nowTime, "", -1)
|
|
updateId3 = AddChangeRecord(tx, clueId, positionId, "trailstatus", "基本信息变更", "新增", "商机线索", nowTime, "", -1)
|
|
@@ -487,6 +491,71 @@ func SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, c
|
|
updateId5 = AddChangeRecord(tx, clueId, positionId, "top_cluetype", "基本信息变更", "/", topname, nowTime, "", -1)
|
|
updateId5 = AddChangeRecord(tx, clueId, positionId, "top_cluetype", "基本信息变更", "/", topname, nowTime, "", -1)
|
|
updateId6 = AddChangeRecord(tx, clueId, positionId, "sub_cluetype", "基本信息变更", "/", subname, nowTime, "", -1)
|
|
updateId6 = AddChangeRecord(tx, clueId, positionId, "sub_cluetype", "基本信息变更", "/", subname, nowTime, "", -1)
|
|
AddLockeStatusChange(tx, clueId, positionId, 0, 0, isGroup, isCommerce, cluename, nowTime, "delete")
|
|
AddLockeStatusChange(tx, clueId, positionId, 0, 0, isGroup, isCommerce, cluename, nowTime, "delete")
|
|
|
|
+=======
|
|
|
|
+ Ehandle(clueId, uId, userId, cluename, "01", "E")
|
|
|
|
+ uodateId1 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
|
+ "clue_id": clueId,
|
|
|
|
+ "position_id": positionId,
|
|
|
|
+ "change_type": "创建线索",
|
|
|
|
+ "new_value": "系统自动创建",
|
|
|
|
+ "createtime": nowTime,
|
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
|
+ "operator_id": -1,
|
|
|
|
+ })
|
|
|
|
+ uodateId2 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
|
+ "clue_id": clueId,
|
|
|
|
+ "position_id": positionId,
|
|
|
|
+ "change_field": "position_id",
|
|
|
|
+ "change_type": "所属人变更",
|
|
|
|
+ "old_value": "/",
|
|
|
|
+ "new_value": saleName,
|
|
|
|
+ "createtime": nowTime,
|
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
|
+ "operator_id": -1,
|
|
|
|
+ })
|
|
|
|
+ uodateId3 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
|
+ "clue_id": clueId,
|
|
|
|
+ "position_id": positionId,
|
|
|
|
+ "change_field": "trailstatus",
|
|
|
|
+ "change_type": "基本信息变更",
|
|
|
|
+ "old_value": "商机线索",
|
|
|
|
+ "new_value": "新增",
|
|
|
|
+ "createtime": nowTime,
|
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
|
+ "operator_id": -1,
|
|
|
|
+ })
|
|
|
|
+ uodateId4 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
|
+ "clue_id": clueId,
|
|
|
|
+ "position_id": positionId,
|
|
|
|
+ "change_type": "加入任务车",
|
|
|
|
+ "new_value": "线索自动分配" + "-" + topname + "-" + subname,
|
|
|
|
+ "createtime": nowTime,
|
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
|
+ "operator_id": -1,
|
|
|
|
+ })
|
|
|
|
+ uodateId5 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
|
+ "clue_id": clueId,
|
|
|
|
+ "position_id": positionId,
|
|
|
|
+ "change_field": "top_cluetype",
|
|
|
|
+ "change_type": "基本信息变更",
|
|
|
|
+ "old_value": "/",
|
|
|
|
+ "new_value": topname,
|
|
|
|
+ "createtime": nowTime,
|
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
|
+ "operator_id": -1,
|
|
|
|
+ })
|
|
|
|
+ uodateId6 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
|
+ "clue_id": clueId,
|
|
|
|
+ "position_id": positionId,
|
|
|
|
+ "change_field": "sub_cluetype", //222
|
|
|
|
+ "change_type": "基本信息变更",
|
|
|
|
+ "old_value": "/",
|
|
|
|
+ "new_value": subname,
|
|
|
|
+ "createtime": nowTime,
|
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
|
+ "operator_id": -1,
|
|
|
|
+ })
|
|
|
|
+>>>>>>> master
|
|
//冻结处理
|
|
//冻结处理
|
|
return clueId > -1 && updateId1 > -1 && updateId2 > -1 && updateId3 > -1 && updateId4 > -1 && updateId5 > -1 && updateId6 > -1
|
|
return clueId > -1 && updateId1 > -1 && updateId2 > -1 && updateId3 > -1 && updateId4 > -1 && updateId5 > -1 && updateId6 > -1
|
|
}) {
|
|
}) {
|
|
@@ -550,10 +619,45 @@ func SaveClue0(item, userId, uId, top_cluetype, sub_cluetype, topname, subname,
|
|
"label": 1,
|
|
"label": 1,
|
|
"labelChangeTime": time.Now().Format("2006-01-02"),
|
|
"labelChangeTime": time.Now().Format("2006-01-02"),
|
|
})
|
|
})
|
|
|
|
+<<<<<<< HEAD
|
|
uodateId1 = AddChangeRecord(tx, clueId, positionId, "", "创建线索", "系统自动创建", "", nowTime, "", -1)
|
|
uodateId1 = AddChangeRecord(tx, clueId, positionId, "", "创建线索", "系统自动创建", "", nowTime, "", -1)
|
|
uodateId2 = AddChangeRecord(tx, clueId, positionId, "position_id", "所属人变更", "/", "", nowTime, "", -1)
|
|
uodateId2 = AddChangeRecord(tx, clueId, positionId, "position_id", "所属人变更", "/", "", nowTime, "", -1)
|
|
uodateId3 = AddChangeRecord(tx, clueId, positionId, "trailstatus", "基本信息变更", "新增", "商机线索", nowTime, "", -1)
|
|
uodateId3 = AddChangeRecord(tx, clueId, positionId, "trailstatus", "基本信息变更", "新增", "商机线索", nowTime, "", -1)
|
|
AddLockeStatusChange(tx, clueId, positionId, 0, 0, isGroup, isCommerce, cluename, nowTime, "delete")
|
|
AddLockeStatusChange(tx, clueId, positionId, 0, 0, isGroup, isCommerce, cluename, nowTime, "delete")
|
|
|
|
+=======
|
|
|
|
+ Ehandle(clueId, uId, userId, cluename, "01", "E")
|
|
|
|
+ uodateId1 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
|
+ "clue_id": clueId,
|
|
|
|
+ "position_id": positionId,
|
|
|
|
+ "change_type": "创建线索",
|
|
|
|
+ "new_value": "系统自动创建",
|
|
|
|
+ "createtime": nowTime,
|
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
|
+ "operator_id": -1,
|
|
|
|
+ })
|
|
|
|
+ uodateId2 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
|
+ "clue_id": clueId,
|
|
|
|
+ "position_id": positionId,
|
|
|
|
+ "change_field": "position_id",
|
|
|
|
+ "change_type": "所属人变更",
|
|
|
|
+ "old_value": "",
|
|
|
|
+ "new_value": "/",
|
|
|
|
+ "createtime": nowTime,
|
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
|
+ "operator_id": -1,
|
|
|
|
+ })
|
|
|
|
+ uodateId3 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
|
+ "clue_id": clueId,
|
|
|
|
+ "position_id": positionId,
|
|
|
|
+ "change_field": "trailstatus",
|
|
|
|
+ "change_type": "基本信息变更",
|
|
|
|
+ "old_value": "商机线索",
|
|
|
|
+ "new_value": "新增",
|
|
|
|
+ "createtime": nowTime,
|
|
|
|
+ "BCPCID": common.GetRandom(32),
|
|
|
|
+ "operator_id": -1,
|
|
|
|
+ })
|
|
|
|
+>>>>>>> master
|
|
return clueId > -1 && uodateId1 > -1 && uodateId2 > -1 && uodateId3 > -1
|
|
return clueId > -1 && uodateId1 > -1 && uodateId2 > -1 && uodateId3 > -1
|
|
}) {
|
|
}) {
|
|
log.Println("线索分配成功")
|
|
log.Println("线索分配成功")
|
|
@@ -602,8 +706,13 @@ func WorkUpdateClue(data map[string]interface{}, saleData []map[string]interface
|
|
old_top_cluetype := gconv.String(data["top_cluetype"])
|
|
old_top_cluetype := gconv.String(data["top_cluetype"])
|
|
old_sub_cluetype := gconv.String(data["sub_cluetype"])
|
|
old_sub_cluetype := gconv.String(data["sub_cluetype"])
|
|
label := gconv.Int64(data["label"])
|
|
label := gconv.Int64(data["label"])
|
|
|
|
+ e_label := gconv.String(data["e_label"])
|
|
old_topname, old_subname := "", ""
|
|
old_topname, old_subname := "", ""
|
|
|
|
+<<<<<<< HEAD
|
|
lockStatus := common.Int64All(data["lock_status"])
|
|
lockStatus := common.Int64All(data["lock_status"])
|
|
|
|
+=======
|
|
|
|
+ Ehandle(clueId, uId, userId, cluename, trailstatus, e_label)
|
|
|
|
+>>>>>>> master
|
|
is_transfer := common.IntAll(data["is_transfer"])
|
|
is_transfer := common.IntAll(data["is_transfer"])
|
|
if taskstatus == 1 || is_task == 0 {
|
|
if taskstatus == 1 || is_task == 0 {
|
|
taskTime = gconv.String(common.If(item != "users", nowTime, nowTimes)) //任务时间,正常的是当前时间,新用户是当前时间+12个小时
|
|
taskTime = gconv.String(common.If(item != "users", nowTime, nowTimes)) //任务时间,正常的是当前时间,新用户是当前时间+12个小时
|
|
@@ -1002,6 +1111,8 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
is_transfer := common.IntAll(data["is_transfer"])
|
|
is_transfer := common.IntAll(data["is_transfer"])
|
|
oldLabelChangeTime := gconv.String(data["labelChangeTime"])
|
|
oldLabelChangeTime := gconv.String(data["labelChangeTime"])
|
|
label := gconv.Int64(data["label"])
|
|
label := gconv.Int64(data["label"])
|
|
|
|
+ e_label := gconv.String(data["e_label"])
|
|
|
|
+ Ehandle(clueId, uId, userId, cluename, trailstatus, e_label)
|
|
if taskstatus == 1 || is_task == 0 {
|
|
if taskstatus == 1 || is_task == 0 {
|
|
taskTime = gconv.String(common.If(item != "users", nowTime, nowTimes)) //任务时间,正常的是当前时间,新用户是当前时间+12个小时
|
|
taskTime = gconv.String(common.If(item != "users", nowTime, nowTimes)) //任务时间,正常的是当前时间,新用户是当前时间+12个小时
|
|
} else {
|
|
} else {
|
|
@@ -1577,3 +1688,38 @@ func LabelHandel(tx *sql.Tx, oldlabelType, labelType int64, uId, level, oldTrail
|
|
log.Println("线索标签修改", ok)
|
|
log.Println("线索标签修改", ok)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+func Ehandle(clueId int64, uid, userId, clueName, trailstatus, e_label string) {
|
|
|
|
+ if e_label != "" {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ // 最近访问时间:最近1天内
|
|
|
|
+ beforeTime := time.Now().AddDate(0, 0, -1).Format("2006-01-02 15:04:05")
|
|
|
|
+ if TiDb.CountBySql("select count(1) as count from dwd_f_userbase_visit_info where userid=? and date>=? and number>0 ", userId, beforeTime) <= 0 {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ // 最近接通时间:近20天内未被接通
|
|
|
|
+ if TiDb.CountBySql("select count(1) as count from dwd_f_crm_attribute_label where uid=? and noanswer_count>0 ", uid) > 0 {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ // 排除条件:空号停机、拒绝沟通客户
|
|
|
|
+ if trailstatus == "02" || trailstatus == "09" {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ // 线索名称:有企业名称的
|
|
|
|
+ if ValidatePhone(clueName) {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ TiDb.Update("dwd_f_crm_clue_info", map[string]interface{}{
|
|
|
|
+ "id": clueId,
|
|
|
|
+ }, map[string]interface{}{
|
|
|
|
+ "e_label": "E001",
|
|
|
|
+ })
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// 预编译正则表达式提升性能
|
|
|
|
+var phoneRegex = regexp.MustCompile(`^1[3-9]\d{9}$`)
|
|
|
|
+
|
|
|
|
+// ValidatePhone 验证手机号格式是否合法
|
|
|
|
+func ValidatePhone(phone string) bool {
|
|
|
|
+ return phoneRegex.MatchString(phone)
|
|
|
|
+}
|