Pārlūkot izejas kodu

Merge branch 'master' of http://git.ycjcjy.com/default/wechat-conf

胡轶钦 6 gadus atpakaļ
vecāks
revīzija
f5b0cd9454
2 mainītis faili ar 10 papildinājumiem un 6 dzēšanām
  1. 1
    1
      controllers/component.go
  2. 9
    5
      models/wechat.go

+ 1
- 1
controllers/component.go Parādīt failu

@@ -204,7 +204,7 @@ func (c *WechatController) getReplayMessage(replay *model.TaAutoReply, openid st
204 204
 
205 205
 // GetPreAuthCode 获取预授权码
206 206
 func (c *WechatController) GetPreAuthCode() {
207
-	utils.LogError(utils.Component.GetToken())
207
+	beego.Error(utils.Component.GetToken())
208 208
 	code, err := utils.Component.GetPreAuthCode()
209 209
 	if err != nil {
210 210
 		utils.LogError("获取预授权码错误: " + err.Error())

+ 9
- 5
models/wechat.go Parādīt failu

@@ -25,9 +25,12 @@ func ComponentInit() {
25 25
 	d := "0"
26 26
 	if !conf.ExpiresDate.IsZero() {
27 27
 		now := time.Now()
28
-		d = string(conf.ExpiresDate.Sub(now))
28
+		subd := conf.ExpiresDate.Sub(now)
29
+		beego.Error(d)
30
+		d = string(subd)
29 31
 	}
30 32
 
33
+	beego.Error("过期时间:", d)
31 34
 	var cert = map[string]string{
32 35
 		"appid":                 conf.Appid,
33 36
 		"aeskey":                conf.Aeskey,
@@ -51,10 +54,11 @@ func UpdateComponentToken(token map[string]interface{}) {
51 54
 		Token: token["accessToken"].(string),
52 55
 	}
53 56
 
54
-	expires := token["expire_in"].(int)
55
-	beego.Error(expires)
56
-	if expires > 0 {
57
-		expriesTime := time.Now().Local().Add(time.Duration(expires))
57
+	expire := token["expire_in"].(int64)
58
+	if expire > 0 {
59
+		beego.Error(time.Now())
60
+		expriesTime := time.Now().Local().Add(time.Duration(expire) * time.Second)
61
+		beego.Error(expriesTime)
58 62
 		conf.ExpiresDate = expriesTime
59 63
 		sql := `update sys_component_conf set token=?,expires_date=?`
60 64
 		_, err := DBEngine.Exec(sql, conf.Token, conf.ExpiresDate)