Pārlūkot izejas kodu

E类线索处理

WH01243 4 mēneši atpakaļ
vecāks
revīzija
2b9e8b11fa
2 mainītis faili ar 38 papildinājumiem un 1 dzēšanām
  1. 37 0
      clueSync/job.go
  2. 1 1
      clueSync/kc.go

+ 37 - 0
clueSync/job.go

@@ -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)
+}

+ 1 - 1
clueSync/kc.go

@@ -1247,7 +1247,7 @@ func CustomerChange() {
 		}
 		return true
 	}, `select operator_id, clue_id,position_id,old_value,new_value,createtime from   dwd_f_crm_clue_change_record  where    createtime>?  and change_type="客户成功经理"   order by  createtime`, startTime)
-	//}, `select operator_id, clue_id,position_id,old_value,new_value,createtime from   dwd_f_crm_clue_change_record  where   id=?   order by  createtime`, 21921661)
+	//}, `select operator_id, clue_id,position_id,old_value,new_value,createtime from   dwd_f_crm_clue_change_record  where   id=?   order by  createtime`, 57668123)
 	if len(customMap1) > 0 {
 		ChangeSendKc(customMap1, 1)
 	}