Explorar el Código

special depart add 29

abiao hace 4 años
padre
commit
05a74c1db8

+ 13 - 10
go/gopath/src/fohow.com/apps/controllers/permit_controller/permit_controller.go

@@ -2,6 +2,7 @@ package permit_controller
 
 import (
 	"fmt"
+	"fohow.com/libs/lib_redis"
 	"strconv"
 
 	// "math/rand"
@@ -301,6 +302,12 @@ func (self *PermitController) XcxLogin() {
 	if self.CruSession == nil {
 		self.ReturnError(200, apps.NoExist, "", nil)
 	}
+	//设置code对应的 redis openId unionId 值
+	openid_key := lib_redis.GetOpenIdRedisKey(code)
+	unionid_key := lib_redis.GetUnionIdRedisKey(code)
+	lib_redis.SetRedisValue(openid_key, code, time.Duration(60*60)*time.Second)
+	lib_redis.SetRedisValue(unionid_key, code, time.Duration(60*60)*time.Second)
+
 	sId := self.CruSession.SessionID()
 	// beego.BeeLogger.Warn("XcxLogin sId=%s", sId)
 	type Ret struct {
@@ -314,17 +321,13 @@ func (self *PermitController) XcxLogin() {
 
 //小程序登录
 func GetXcxLoginInfo(code string) (openId, unionId string) {
-	appId := beego.AppConfig.String("WxFohowXcxAppId")
-	appSecret := beego.AppConfig.String("WxFohowXcxAppSecret")
-	key := wx_mp.GetXcxSessionKey(appId, appSecret, code)
-	if key == nil {
-		return "", ""
-	}
-	beego.BeeLogger.Warn("XcxLogin key=%s", key)
-	beego.BeeLogger.Warn("XcxLogin key=%s, key.Openid=%s", key, key.Openid)
-	beego.BeeLogger.Warn("XcxLogin key=%s, key.Unionid=%s", key, key.Unionid)
+	openid_key := lib_redis.GetOpenIdRedisKey(code)
+	unionid_key := lib_redis.GetUnionIdRedisKey(code)
+
+	_, openid := lib_redis.GetSimpleValue(openid_key)
+	_, unionid := lib_redis.GetSimpleValue(unionid_key)
 
-	return key.Openid, key.Unionid
+	return openid, unionid
 }
 
 //生成订单ID