|
@@ -5,6 +5,7 @@ import (
|
|
|
"fmt"
|
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
|
"log"
|
|
|
+ "regexp"
|
|
|
"strings"
|
|
|
"time"
|
|
|
|
|
@@ -551,6 +552,7 @@ func SaveClue(item, userId, uId, top_cluetype, sub_cluetype, topname, subname, c
|
|
|
"label": 1,
|
|
|
"labelChangeTime": time.Now().Format("2006-01-02"),
|
|
|
})
|
|
|
+ Ehandle(clueId, uId, userId, cluename, "01")
|
|
|
uodateId1 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
"clue_id": clueId,
|
|
|
"position_id": positionId,
|
|
@@ -676,6 +678,7 @@ func SaveClue0(item, userId, uId, top_cluetype, sub_cluetype, topname, subname,
|
|
|
"label": 1,
|
|
|
"labelChangeTime": time.Now().Format("2006-01-02"),
|
|
|
})
|
|
|
+ Ehandle(clueId, uId, userId, cluename, "01")
|
|
|
uodateId1 = TiDb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
|
|
|
"clue_id": clueId,
|
|
|
"position_id": positionId,
|
|
@@ -755,6 +758,7 @@ func WorkUpdateClue(data map[string]interface{}, saleData []map[string]interface
|
|
|
old_sub_cluetype := gconv.String(data["sub_cluetype"])
|
|
|
label := gconv.Int64(data["label"])
|
|
|
old_topname, old_subname := "", ""
|
|
|
+ Ehandle(clueId, uId, userId, cluename, trailstatus)
|
|
|
is_transfer := common.IntAll(data["is_transfer"])
|
|
|
if taskstatus == 1 || is_task == 0 {
|
|
|
taskTime = gconv.String(common.If(item != "users", nowTime, nowTimes)) //任务时间,正常的是当前时间,新用户是当前时间+12个小时
|
|
@@ -1349,6 +1353,7 @@ func UpdateClue(data map[string]interface{}, saleData []map[string]interface{},
|
|
|
is_transfer := common.IntAll(data["is_transfer"])
|
|
|
oldLabelChangeTime := gconv.String(data["labelChangeTime"])
|
|
|
label := gconv.Int64(data["label"])
|
|
|
+ Ehandle(clueId, uId, userId, cluename, trailstatus)
|
|
|
if taskstatus == 1 || is_task == 0 {
|
|
|
taskTime = gconv.String(common.If(item != "users", nowTime, nowTimes)) //任务时间,正常的是当前时间,新用户是当前时间+12个小时
|
|
|
} else {
|
|
@@ -2197,3 +2202,35 @@ func LabelHandel(tx *sql.Tx, oldlabelType, labelType int64, uId, level, oldTrail
|
|
|
log.Println("线索标签修改", ok)
|
|
|
}
|
|
|
}
|
|
|
+func Ehandle(clueId int64, uid, userId, clueName, trailstatus string) {
|
|
|
+ // 最近访问时间:最近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)
|
|
|
+}
|