Преглед изворни кода

Merge branch 'dev_v1.5.35_wh' of jianyu/datatools into feature/v1.5.35

王浩 пре 2 месеци
родитељ
комит
38221860e4
1 измењених фајлова са 45 додато и 8 уклоњено
  1. 45 8
      clueSync/tag.go

+ 45 - 8
clueSync/tag.go

@@ -160,11 +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.Find("socialize_keyword", map[string]interface{}{
-		"mold":  0,
-		"state": 0,
-	}, "name", "", -1, -1)
+	matchArr := Base.SelectBySql(`select  name  from  socialize_keyword where  mold=0 and  state=0 and  FIND_IN_SET(group,2)  `)
 	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 {
@@ -323,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  name  from  socialize_keyword where  mold=0 and  state=0 and  FIND_IN_SET(group,2)  `)
+			for _, vv := range *matchArr {
+				key := gconv.String(vv["name"])
+				if strings.Contains(strings.ToUpper(content), strings.ToUpper(key)) || phoneRegexp.MatchString(content) {
 					isOk = true
 				}
 			}
@@ -352,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  name  from  socialize_keyword where  mold=0 and  state=1 and  FIND_IN_SET(group,2)  `)
+			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("在线客服按钮定时任务结束")
+}