zwxi 9 miesięcy temu
rodzic
commit
fe469995ec
1 zmienionych plików z 12 dodań i 11 usunięć
  1. 12 11
      controllers/wechat.go

+ 12 - 11
controllers/wechat.go

@@ -122,14 +122,6 @@ func (this *WechatCommonController) WechatLoginByGzh() {
 			}
 		}
 	}
-	if mfyxUserRecord == nil {
-		_, err = models.AddMfyxGzhUserRecord(items)
-		if err != nil {
-			br.Msg = "获取用户信息失败"
-			br.ErrMsg = "添加openid失败,Err:" + err.Error()
-			return
-		}
-	}
 	userRecord := &models.UserRecord{
 		OpenId:         openId,  //用户open_id
 		UnionId:        unionId, //用户union_id
@@ -145,10 +137,19 @@ func (this *WechatCommonController) WechatLoginByGzh() {
 		CreatePlatform: 12,   //注册平台,1:日度点评公众号,2:管理后台,3:pc端网站,4:查研观向小程序;默认:1
 		SessionKey:     wxUserInfo.SessionKey, //微信小程序会话密钥,最大长度:255
 	}
-	_, err = models.AddUserRecord(userRecord)
-	if err != nil {
-		return
+	if mfyxUserRecord == nil {
+		_, err = models.AddMfyxGzhUserRecord(items)
+		if err != nil {
+			br.Msg = "获取用户信息失败"
+			br.ErrMsg = "添加openid失败,Err:" + err.Error()
+			return
+		}
+		_, err = models.AddUserRecord(userRecord)
+		if err != nil {
+			return
+		}
 	}
+
 	timeUnix := time.Now().Unix()
 	timeUnixStr := strconv.FormatInt(timeUnix, 10)