Переглянути джерело

Merge branch 'master' into hotfix/v1.5.35.2

yuelujie 2 місяців тому
батько
коміт
adcc743a68
4 змінених файлів з 79 додано та 8 видалено
  1. 1 0
      clueSync/config.go
  2. 28 1
      clueSync/config.json
  3. 1 0
      clueSync/main.go
  4. 49 7
      clueSync/tag.go

+ 1 - 0
clueSync/config.go

@@ -17,6 +17,7 @@ type (
 		LastUserTime            string  `json:"lastUserTime"`
 		LastSubscribeId         string  `json:"lastSubscribeId"`
 		LastMessageTime         string  `json:"lastMessageTime"`
+		LastMessageButtonTime   string  `json:"lastMessageButtonTime"`
 		LastkcTime              string  `json:"lastkcTime"`
 		LastEverythingTime      string  `json:"lastEverythingTime"`
 		LastEventRegTime        string  `json:"lastEventRegTime"`

+ 28 - 1
clueSync/config.json

@@ -1 +1,28 @@
-{"lastOrderId":260273,"lastOrderClueId":"2024-09-19 11:51:37","lastUserId":"2024-05-20 15:40:02","lastXcxUserId":"2024-07-09 14:59:37","lastId":"66cd4d3ae83797f8bf5e7ca2","lastOrderTime":"2023-04-25 00:00:00","lastUserTime":"2024-07-09 11:54:02","lastSubscribeId":"6459d89a8edef707156e9cc6","lastMessageTime":"2024-07-16 14:26:26","lastkcTime":"2025-01-08 11:18:00","lastEverythingTime":"","lastEventRegTime":"","lastReadClueTime":"","bigSaleTime":1718241923,"bigOrderTime":"2024-06-12 17:01:39","marketSaleTime":1708160200,"advisoryCommitteeTime":1724136683,"selectionDepartmentTime":0,"allocationTime":"2024-07-01 14:59:37","allocationRatio":2,"activeTime":"2024-07-01 14:59:37","rebindTime":"2024-08-27 16:10:27","inviteTime":"2024-11-20 14:42:11","lastKcChangeTime":"2025-01-22 15:22:05"}
+{
+  "lastOrderId": 261915,
+  "lastOrderClueId": "2025-05-16 10:05:24",
+  "lastUserId": "2025-04-15 15:20:01",
+  "lastXcxUserId": "2025-04-17 15:03:03",
+  "lastId": "67f8808952d21982ca5970cb",
+  "lastOrderTime": "2025-04-21 10:41:30",
+  "lastUserTime": "2025-04-21 13:30:02",
+  "lastSubscribeId": "67fcb9c1cdf0004e40e69cba",
+  "lastMessageTime": "2025-04-02 10:21:06",
+  "lastkcTime": "2025-05-17 15:18:00",
+  "lastEverythingTime": "2024-11-20 13:40:21",
+  "lastEventRegTime": "2024-11-20 13:40:21",
+  "lastReadClueTime": "2025-03-25 14:43:42",
+  "bigSaleTime": 1747293636,
+  "bigOrderTime": "2025-04-29 15:18:31",
+  "marketSaleTime": 1745218148,
+  "advisoryCommitteeTime": 1745216244,
+  "selectionDepartmentTime": 1745216244,
+  "allocationTime": "2024-11-20 13:40:21",
+  "allocationRatio": 2,
+  "activeTime": "2025-04-14 22:00:00",
+  "rebindTime": "2025-04-09 11:11:56",
+  "inviteTime": "2025-04-21 00:00:00",
+  "activityTime": "2025-04-03 16:59:23",
+  "lastKcChangeTime": "2025-04-14 15:00:27.000",
+  "lastMessageButtonTime": "2025-05-28 16:59:23"
+}

+ 1 - 0
clueSync/main.go

@@ -164,6 +164,7 @@ func main() {
 			orders()      //未支付订单
 			messageSync() //聊天记录进线索
 			userbase()    //新绑定手机号进线索
+			customerButton()
 		})
 		//5分钟一次
 		go p.VarTimeTask.RunInTimeSection("5分钟定时任务1", db.CornExp2Start, db.CornExp2End, db.CornExp2, func(dayFirst bool) {

+ 49 - 7
clueSync/tag.go

@@ -160,7 +160,7 @@ func FormatTag(data map[string]interface{}, count int) {
 	keyStr := ""
 	phoneRegexp := regexp.MustCompile(`^1[0-9]{10}$`)
 	keyMap := map[string]bool{}
-	match := "会员,费,数据,价格,合作,大会员,超级订阅,功能,账号,如何,订阅,充值,试用,报价,买,意向,超前项目,附件,拟招标,个人办,vip,套餐,权益"
+	matchArr := Base.SelectBySql(`select  aa.name  from  socialize_keyword  aa where  aa.mold=0 and  aa.state=0 and  FIND_IN_SET(2,aa.group)  `)
 	sqls := fmt.Sprintf(`select b.content from socialize_message_mailbox a LEFT JOIN socialize_message b on b.id = a.messag_id where a.type in (4,5,7) and a.own_type = 2 and a.own_id = %d and b.title = "文本" and a.send_user_type = 2 and a.create_time >= "%s"`, base_user_id, time.Now().AddDate(0, 0, -30).Format("2006-01-02 15:04:05"))
 	mData := Base.SelectBySql(sqls)
 	if mData != nil && *mData != nil && len(*mData) > 0 {
@@ -169,9 +169,10 @@ func FormatTag(data map[string]interface{}, count int) {
 			if phoneRegexp.MatchString(content) {
 				keyMap[content] = true
 			}
-			for _, vvv := range strings.Split(match, ",") {
-				if strings.Contains(strings.ToUpper(content), strings.ToUpper(vvv)) {
-					keyMap[vvv] = true
+			for _, vvv := range *matchArr {
+				key := gconv.String(vvv["name"])
+				if strings.Contains(strings.ToUpper(content), strings.ToUpper(key)) {
+					keyMap[key] = true
 					break
 				}
 			}
@@ -318,9 +319,10 @@ func messageSync() {
 		for _, v := range *data {
 			isOk := false
 			content := common.ObjToString(v["content"])
-			match := "会员,费,数据,价格,合作,大会员,超级订阅,功能,账号,如何,订阅,充值,试用,报价,买,意向,超前项目,附件,拟招标,个人办,vip,套餐,权益"
-			for _, vv := range strings.Split(match, ",") {
-				if strings.Contains(strings.ToUpper(content), strings.ToUpper(vv)) || phoneRegexp.MatchString(content) {
+			matchArr := Base.SelectBySql(`select  aa.name  from  socialize_keyword aa where  aa.mold=0 and  aa.state=0 and  FIND_IN_SET(2,aa.group)  `)
+			for _, vv := range *matchArr {
+				key := gconv.String(vv["name"])
+				if strings.Contains(strings.ToUpper(content), strings.ToUpper(key)) || phoneRegexp.MatchString(content) {
 					isOk = true
 				}
 			}
@@ -347,3 +349,43 @@ func messageSync() {
 	common.WriteSysConfig(&cfg)
 	log.Println("在线客服聊天记录定时任务结束")
 }
+
+// 客服按钮处理
+func customerButton() {
+	log.Println("在线客服按钮定时任务开始")
+	sql := fmt.Sprintf(`select * from socialize_message where title = "点击按钮" and create_time > "%s"`, cfg.LastMessageButtonTime)
+	data := Base.SelectBySql(sql)
+	if data != nil && *data != nil && len(*data) > 0 {
+		for _, v := range *data {
+			isOk := false
+			content := common.ObjToString(v["content"])
+			matchArr := Base.SelectBySql(`select  aa.name  from  socialize_keyword  aa where  aa.mold=1 and  aa.state=1 and  FIND_IN_SET(2,aa.group)  `)
+			for _, vv := range *matchArr {
+				key := gconv.String(vv["name"])
+				if strings.Contains(strings.ToUpper(content), strings.ToUpper(key)) {
+					isOk = true
+				}
+			}
+			if isOk {
+				messag_id := common.Int64All(v["id"])
+				mData := Base.FindOne("socialize_message_mailbox", map[string]interface{}{"messag_id": messag_id, "own_type": 2}, "", "")
+				if mData != nil && len(*mData) > 0 {
+					own_id := common.Int64All((*mData)["own_id"])
+					if own_id > 0 {
+						ok1, ok2, _ := FormatData(*mData, "message")
+						if !ok1 {
+							log.Println("线索卡点", "message", mData, messag_id)
+						} else {
+							if !ok2 {
+								log.Println("用户分配已达上限", "message", mData, messag_id)
+							}
+						}
+					}
+				}
+			}
+			cfg.LastMessageButtonTime = common.ObjToString(v["create_time"])
+		}
+	}
+	common.WriteSysConfig(&cfg)
+	log.Println("在线客服按钮定时任务结束")
+}