浏览代码

wip:激活微信自动回复

wangshan 1 年之前
父节点
当前提交
3098fc8fb4

+ 1 - 1
src/jfw/modules/app/src/app/front/login.go

@@ -89,7 +89,7 @@ func (l *Login) ActivateLogin(id string) error {
 		sessVal := l.Session().GetMultiple()
 		userid, _ := sessVal["mgoUserId"].(string)
 		uId, err := strconv.Atoi(id)
-		activateInfos := public.BaseMysql.SelectBySql(`SELECT au.user_id,au.phone,au.position_id,ab.id FROM activate_user au LEFT JOIN activate_bidding ab ON au.id = ab.au_id WHERE au.id = ?`, uId)
+		activateInfos := public.BaseMysql.SelectBySql(`SELECT au.user_id,au.phone,au.position_id,ab.id FROM jyactivities.activate_user au LEFT JOIN jyactivities.activate_bidding ab ON au.id = ab.au_id WHERE au.id = ?`, uId)
 		if activateInfos != nil && len(*activateInfos) > 0 {
 			activateInfo := (*activateInfos)[0]
 			biddingId := qutil.InterfaceToStr(activateInfo["id"])

+ 2 - 1
src/jfw/modules/weixin/src/config.json

@@ -163,5 +163,6 @@
   "namePrefix": "JY_%s",
   "userCenterApi": "https://web-zxl.jydev.jianyu360.com",
   "merge": "<a href='%s'>系统检测到您有2个剑鱼标讯账号,为保证您的正常使用,请进行账号合并。</a>",
-  "phrasesReplyText": "%s %s行业专属购买链接:<a href='%s'>点击</a>"
+  "phrasesReplyText": "%s %s行业专属购买链接:<a href='%s'>点击</a>",
+  "miniProgramActivateReplyText": "%s %s 点此查看:<a href='%s'>%s</a>"
 }

文件差异内容过多而无法显示
+ 655 - 654
src/jfw/modules/weixin/src/github.com/wizjin/weixin/weixin.go


+ 29 - 0
src/jfw/modules/weixin/src/tools/minip.go

@@ -0,0 +1,29 @@
+package tools
+
+import (
+	"app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/encrypt"
+	"fmt"
+	"jy/src/jfw/modules/weixin/src/config"
+	"strconv"
+	"time"
+)
+
+// 小程序
+func GetMiniActivateBiddingInfo(id string) (title, url, subTxt string) {
+	if uId, err := strconv.Atoi(id); err == nil && uId > 0 {
+		activateInfos := Mysql.SelectBySql(`SELECT ac.classification,ab.id,ab.title FROM jyactivities.activate_count ac LEFT JOIN jyactivities.activate_bidding ab ON ac.au_id = ab.au_id WHERE au.id = ?`, uId)
+		if activateInfos != nil && len(*activateInfos) > 0 {
+			activateInfo := (*activateInfos)[0]
+			title = common.InterfaceToStr(activateInfo["title"])
+			biddingId := common.InterfaceToStr(activateInfo["id"])
+			subTxt = "感谢关注"
+			if classification := common.IntAll(activateInfo["classification"]); classification > 0 {
+				subTxt = "欢迎回来"
+			}
+			webDomain := config.Sysconfig["webdomain"].(string)
+			url = fmt.Sprintf("%s/article/content/%s.html?miniprogram=%s", webDomain, encrypt.EncodeArticleId2ByCheck(biddingId), encrypt.SE.Encode2Hex(strconv.FormatInt(time.Now().Unix(), 10)))
+		}
+	}
+	return
+}

+ 13 - 1
src/jfw/modules/weixin/src/wx/wx.go

@@ -520,12 +520,20 @@ func Subscribe(w ResponseWriter, r *Request) {
 		log.Println(err)
 		return
 	}
-	var source = ""
+	var (
+		source, biddingTitle, biddingUrl, subTxt string
+	)
 	if strings.Count(r.EventKey, "_") == 1 {
 		source = strings.Split(r.EventKey, "_")[1]
 	} else if strings.Count(r.EventKey, "_") >= 2 {
 		source = strings.SplitN(r.EventKey, "_", 2)[1]
 	}
+	//小程序 二维码  关注对应的招标信息
+	if strings.Contains(r.EventKey, "ac_") {
+		id := strings.Split(r.EventKey, "ac_")[1]
+		source = fmt.Sprintf("ac_%s", id)
+		biddingTitle, biddingUrl, subTxt = tools.GetMiniActivateBiddingInfo(id)
+	}
 	go saveFixedCode(openid, r.Event, source)
 	log.Println("source:", source, "---", r.EventKey)
 	var shareData interface{}
@@ -704,6 +712,10 @@ func Subscribe(w ResponseWriter, r *Request) {
 	if text := service.KeyPhraseReply(openid, source, "sub"); text != "" {
 		w.ReplyText(text)
 	}
+	//P583
+	if biddingUrl != "" && biddingTitle != "" {
+		w.ReplyText(fmt.Sprintf(config.Sysconfig["miniProgramActivateReplyText"].(string), user.Nickname, subTxt, biddingUrl, biddingTitle))
+	}
 }
 
 func saveUserLog(shareId, openid, activeName string, shareflag bool) {

部分文件因为文件数量过多而无法显示