rdluck 4 years ago
parent
commit
9f0bf25ac5
2 changed files with 5 additions and 3 deletions
  1. 4 2
      controllers/wechat.go
  2. 1 1
      models/wx_user.go

+ 4 - 2
controllers/wechat.go

@@ -60,7 +60,7 @@ func (this *WechatCommonController) WechatLogin() {
 				return
 			}
 			//获取用户信息
-			wxUserInfo, err := services.WxGetUserInfo(openId,accessToken)
+			wxUserInfo, err := services.WxGetUserInfo(openId, accessToken)
 			if err != nil {
 				br.Msg = "获取用户信息失败"
 				br.ErrMsg = "获取微信用户信息失败,Err:" + err.Error()
@@ -76,6 +76,7 @@ func (this *WechatCommonController) WechatLogin() {
 			user.CompanyId = 1
 			user.CreatedTime = time.Now()
 			user.UnionId = wxUserInfo.Unionid
+			user.Unionid = wxUserInfo.Unionid
 			user.Subscribe = wxUserInfo.SubscribeScene
 			user.SubscribeTime = wxUserInfo.SubscribeTime
 			user.NickName = wxUserInfo.Nickname
@@ -86,6 +87,7 @@ func (this *WechatCommonController) WechatLogin() {
 			user.Headimgurl = wxUserInfo.Headimgurl
 			user.Remark = wxUserInfo.Remark
 			user.FirstLogin = 1
+			user.Enabled = 1
 			err = models.AddWxUser(user)
 			if wxUserInfo.Unionid != "" {
 				wxUser, err = models.GetWxUserItemByUnionid(wxUserInfo.Unionid)
@@ -198,4 +200,4 @@ func (this *WechatController) GetWxSign() {
 
 /*
 $app->bag('api/wechat/check', "WechatController@check");
-*/
+*/

+ 1 - 1
models/wx_user.go

@@ -69,7 +69,7 @@ func GetWxUserItemByOpenId(openId string) (item *WxUserItem, err error) {
 }
 
 func GetWxUserItemByUnionid(unionid string) (item *WxUserItem, err error) {
-	sql := `SELECT * FROM wx_user WHERE unionid=? `
+	sql := `SELECT * FROM wx_user WHERE union_id=? `
 	err = orm.NewOrm().Raw(sql, unionid).QueryRow(&item)
 	return
 }