Sfoglia il codice sorgente

Merge branch 'dev2.10.8' of http://192.168.3.207:10080/qmx/jy into dev2.10.8

zhangxinlei1996 5 anni fa
parent
commit
108c77bff4

+ 9 - 1
src/jfw/active/live.go

@@ -122,6 +122,12 @@ func (this *Active) LivePage() error {
 				}
 			}
 		}
+		if this.Session().Get("s_m_openid") == nil {
+			checkIsSubscribeFlag = false
+		}
+	} else {
+		//是否为关注用户
+		checkIsSubscribeFlag = CheckUserIsSubscribe(openid)
 	}
 	this.T["checkIsSubscribeFlag"] = checkIsSubscribeFlag
 	this.T["Live_Active_Start"] = util.FormatDateByInt64(&config.ActiveConfig.Live_Active_Start, "2006/01/02/15:04") //直播活动开始时间
@@ -142,7 +148,9 @@ func (this *Active) LivePage() error {
 		}
 		return this.Render("/active/livePage/live_online_wx.html", &this.T)
 	} else if now.Unix() > config.ActiveConfig.Live_Preheat_Start { //预热活动进行中
-		if checkIsSubscribeFlag && this.Session().Get("userId").(string) != "" {
+		userId, _ := this.Session().Get("userId").(string)
+		this.T["order_status"] = 0
+		if checkIsSubscribeFlag && userId != "" {
 			var query = map[string]interface{}{
 				"s_userid":   this.Session().Get("userId").(string),
 				"order_type": "wx", //微信预约

+ 6 - 6
src/jfw/modules/weixin/src/config.json

@@ -2,17 +2,17 @@
     "mongodbServers": "192.168.3.128:27080",
     "mongodbPoolSize": "5",
     "mongodbName": "qfw",
-    "redisServers": "sso=192.168.3.128:1712,other=192.168.3.128:1712,jyop_other=192.168.3.128:1712,push=192.168.3.128:1712",
+    "redisServers": "sso=192.168.3.128:1712,other=192.168.3.128:1712,jyop_other=192.168.3.128:1712,push=192.168.3.128:1712,wxtoken=192.168.3.128:1712",
     "redisLogin": "login=192.168.3.128:1712",
     "weixinport": "82",
     "weixinrpcport": "8083",
     "webrpcport": "127.0.0.1:8084",
     "jyop_webrpcport": "127.0.0.1:8012",
-    "webdomain": "http://web-jydev-zyx.jianyu360.cn",
-    "appid": "wx113d0d389bbda22e",
-    "apptoken": "top20192019",
-    "appsecret": "56a05dd04f3d1973aac8def7194ca817",
-    "proxysess": "http://web-jydev-zyx.jianyu360.cn/front/sess/%s",
+    "webdomain": "http://web-jydev-wcj.jianyu360.cn",
+    "appid": "wx76e1309b01a7b17e",
+    "apptoken": "top2020top2020",
+    "appsecret": "dd00e71cb2370432d9de848b674eb8e7",
+    "proxysess": "http://web-jydev-wcj.jianyu360.cn/front/sess/%s",
     "followCompany": 10,
     "welcomemsg": "用剑鱼标讯,所有功能完全免费,\n和传统的会员制说再见!\n\n<a href='%s'>点击这里</a>设置关键词,或直接回复“订阅 关键词”,如“订阅 教学设备”,您将随时随地接收招标信息!\n\n剑鱼标讯,让投标无限可能!",
     "tpl_subscribe_push_id": "IY_RWWzMlwDK6hcd6RAzTec6qre8n5r8PNOOUM_hgk0",

+ 12 - 7
src/jfw/modules/weixin/src/github.com/wizjin/weixin/weixin.go

@@ -102,6 +102,9 @@ const (
 	requestQRScene         = `{"expire_seconds":%d,"action_name":"QR_SCENE","action_info":{"scene":{"scene_id":%d}}}`
 	requestQRLimitScene    = `{"action_name":"QR_LIMIT_SCENE","action_info":{"scene":{"scene_id":%d}}}`
 	requestQRLimitSceneStr = `{"action_name":"QR_LIMIT_SCENE","action_info":{"scene":{"scene_str":%s}}}`
+
+	//
+	RedisCode = "wxtoken"
 )
 
 // Common message header
@@ -305,13 +308,13 @@ func New(token string, appid string, secret string) *Weixin {
 				select {
 				case t := <-wx.refreshTokenChan:
 					log.Println("重新获取 access token")
-					c := redis.RedisPool["sso"].Get()
-					c.Do("PUBLISH", "WxRefreshSub", fmt.Sprintf("token_%s %s", wx.appId, t))
+					c := redis.RedisPool[RedisCode].Get()
+					c.Do("PUBLISH", "WxRefreshSub_"+wx.appId, fmt.Sprintf("token_%s", t))
 					c.Close()
 				case <-wx.refreshTicketChan:
 					log.Println("重新获取 jsApi ticket")
-					c := redis.RedisPool["sso"].Get()
-					c.Do("PUBLISH", "WxRefreshSub", fmt.Sprintf("ticket_%s", wx.appId))
+					c := redis.RedisPool[RedisCode].Get()
+					c.Do("PUBLISH", "WxRefreshSub_"+wx.appId, "ticket")
 					c.Close()
 				}
 			}
@@ -848,7 +851,7 @@ func checkSignature(t string, w http.ResponseWriter, r *http.Request) bool {
 
 func authAccessToken(appid, t string, r chan string) (string, int64, int64) {
 	r <- t
-	ret, err := redis.GetNewBytes("sso", fmt.Sprintf("WxToken_%s", appid))
+	ret, err := redis.GetNewBytes(RedisCode, fmt.Sprintf("WxToken_%s", appid))
 	if err != nil {
 		log.Println("redis中获取Token出错", err)
 	} else if ret != nil {
@@ -892,7 +895,7 @@ func authAccessToken(appid, t string, r chan string) (string, int64, int64) {
 }*/
 func getJsApiTicket(appid string, r chan bool) (*jsApiTicket, error) {
 	r <- true
-	ret, err := redis.GetNewBytes("sso", fmt.Sprintf("WxTicket_%s", appid))
+	ret, err := redis.GetNewBytes(RedisCode, fmt.Sprintf("WxTicket_%s", appid))
 	if err != nil {
 		log.Println("redis中获取Token出错", err)
 	} else if ret != nil {
@@ -944,14 +947,16 @@ func createAccessToken(c chan accessToken, appid string, refresh *bool, r chan s
 				}
 				reTry++
 				subToken := ""
+				forceRefresh := false
 				if *refresh || *token.lasttime == -1 {
+					forceRefresh = true
 					subToken = token.token
 				}
 				*refresh = false
 				var expires int64
 				var lasttime int64
 				token.token, expires, lasttime = authAccessToken(appid, subToken, r)
-				if (*refresh || *token.lasttime == -1) && token.expires.Unix() == expires {
+				if forceRefresh && token.expires.Unix() == expires {
 					continue
 				}
 				token.expires = time.Unix(expires, 0)

+ 3 - 3
src/jfw/modules/wxtoken/src/config.json

@@ -1,9 +1,9 @@
 {
 	"wxs":[
 		{
-			"appid":"wx5b1c6e7cc4dac0e4",
-			"appsecret":"b026103ffebd2291b3edb7a269612112"
+			"appid":"wx76e1309b01a7b17e",
+			"appsecret":"dd00e71cb2370432d9de848b674eb8e7"
 		}
 	],
-	"redis":"sso=192.168.3.128:1712"
+	"redis":"wxtoken=192.168.3.128:1712"
 }

+ 52 - 51
src/jfw/modules/wxtoken/src/main.go

@@ -20,7 +20,7 @@ const (
 	weixinJsApiTicketURL = "https://api.weixin.qq.com/cgi-bin/ticket/getticket"
 	WxTokenKey           = "WxToken_%s"
 	WxTicketKey          = "WxTicket_%s"
-	RedisCode            = "sso"
+	RedisCode            = "wxtoken"
 	MaxExpSec            = 5400
 	retryMaxN            = 3
 )
@@ -76,6 +76,57 @@ func init() {
 		v.TicketChan = make(chan jsApiTicket)
 		AllWxs[v.Appid] = v
 		AllCountT[v.Appid] = &countTocken{0, 0, time.Now().Day()}
+		//
+		go func(appid string) {
+			for {
+				defer util.Catch()
+			L:
+				for {
+					conn := redis.RedisPool[RedisCode].Get()
+					if conn.Err() == nil {
+						psc := redigo.PubSubConn{Conn: conn}
+						if err := psc.Subscribe(redigo.Args{}.AddFlat("WxRefreshSub_" + appid)...); err != nil {
+							log.Println(appid, "redis AddFlat error", err)
+							conn.Close()
+							time.Sleep(1 * time.Second)
+							continue
+						}
+						for {
+							msg := psc.Receive()
+							switch n := msg.(type) {
+							case error:
+								log.Println(appid, "redis Receive error", msg)
+								conn.Close()
+								break L
+							case redigo.Message:
+								res := string(n.Data)
+								if flag := "token_"; strings.HasPrefix(res, flag) {
+									c := AllWxs[appid]
+									if c != nil {
+										token := <-c.TokenChan
+										//意外情况,导致token失效,需要重新获取token
+										if token.Token != "" && token.Token == strings.TrimLeft(res, flag) {
+											refreshAccessToken(appid)
+										}
+									} else {
+										log.Println("appid", appid, "不存在")
+									}
+								} else if res == "ticket" {
+									c := AllWxs[appid]
+									if c != nil {
+										<-c.TicketChan
+									} else {
+										log.Println("appid", appid, "不存在")
+									}
+								}
+							}
+						}
+					}
+					time.Sleep(1 * time.Second)
+				}
+				time.Sleep(500 * time.Millisecond)
+			}
+		}(v.Appid)
 	}
 	go func() {
 		for {
@@ -89,56 +140,6 @@ func init() {
 			time.Sleep(30 * time.Second)
 		}
 	}()
-	go func() {
-		for {
-			defer util.Catch()
-		L:
-			for {
-				conn := redis.RedisPool[RedisCode].Get()
-				if conn.Err() == nil {
-					psc := redigo.PubSubConn{Conn: conn}
-					if err := psc.Subscribe(redigo.Args{}.AddFlat("WxRefreshSub")...); err != nil {
-						log.Println(err)
-					}
-					for {
-						msg := psc.Receive()
-						switch n := msg.(type) {
-						case error:
-							log.Println("redis receive error", msg)
-							conn.Close()
-							break L
-						case redigo.Message:
-							res := string(n.Data)
-							if flag := "token_"; strings.HasPrefix(res, flag) {
-								params := strings.Split(strings.TrimLeft(res, flag), " ")
-								appid := params[0]
-								c := AllWxs[appid]
-								if c != nil {
-									token := <-c.TokenChan
-									//意外情况,导致token失效,需要重新获取token
-									if token.Token == params[1] {
-										refreshAccessToken(appid)
-									}
-								} else {
-									log.Println("appid", appid, "不存在")
-								}
-							} else if flag := "ticket_"; strings.HasPrefix(res, flag) {
-								appid := strings.TrimLeft(res, flag)
-								c := AllWxs[appid]
-								if c != nil {
-									<-c.TicketChan
-								} else {
-									log.Println("appid", appid, "不存在")
-								}
-							}
-						}
-					}
-				}
-				time.Sleep(1 * time.Second)
-			}
-			time.Sleep(500 * time.Millisecond)
-		}
-	}()
 }
 func main() {
 	log.Println("程序启动。。。")

BIN
src/web/staticres/images/pc/live_preheat.png


BIN
src/web/staticres/images/pc/live_preheat_close.png


+ 9 - 2
src/web/templates/active/livePage/live_preheat_wx.html

@@ -105,8 +105,12 @@
         </div>
         <div class="j-footer">
             <div class="j-button-group">
+              {{if .T.checkIsSubscribeFlag}}
+                <a href="javascript:;" class="j-button-confirm">了解VIP订阅</a>
+              {{else}}
                 <a href="javascript:;" class="j-button-cancel jy">了解剑鱼标讯</a>
                 <a href="javascript:;" class="j-button-confirm">了解VIP订阅</a>
+              {{end}}
             </div>
         </div>
         <!--  actionSheet -->
@@ -165,8 +169,10 @@
     			data: {},
     			dataType: "json",
     			success: function(data){
-    				if(data.userId!=""){
-              isSub=true;
+    				if(data.userId!=undefined&&data.userId!=""){
+              isSub = true;
+            }else{
+              isSub = false;
             }
             //是否已预约
             if(data.order_status){
@@ -242,6 +248,7 @@
                 //点击预约按钮
                 $('.appointment-btn').on('click', function () {
                     var $this = $(this)
+                    console.log(isSub+"----------")
                     if (isSub) {
                       $(".js_dialog").fadeIn();
                     } else {