rdluck 4 жил өмнө
parent
commit
0f0d8594c1

+ 2 - 2
controllers/wechat.go

@@ -384,7 +384,7 @@ func (this *WechatController) GetUserInfo() {
 	fmt.Println("sessionKey:", sessionKey)
 	fmt.Println(sessionKey, req.RawData, req.EncryptedData, req.Signature, req.Iv)
 	userInfo, err := weapp.DecryptUserInfo(sessionKey, req.RawData, req.EncryptedData, req.Signature, req.Iv)
-	fmt.Println("weapp.DecryptUserInfo ",err)
+	fmt.Println("weapp.DecryptUserInfo ", err)
 
 	if err != nil {
 		br.Msg = "解析用户信息失败"
@@ -392,7 +392,7 @@ func (this *WechatController) GetUserInfo() {
 		return
 	}
 	//修改用户微信信息
-	err = models.ModifyUserRecordInfo(userInfo.OpenID, userInfo.Nickname, userInfo.Avatar, userInfo.City, userInfo.Province, userInfo.Country, userInfo.Gender, userId)
+	err = models.ModifyUserRecordByDetail(userInfo.OpenID, userInfo.UnionID, userInfo.Nickname, userInfo.Avatar, userInfo.City, userInfo.Province, userInfo.Country, userInfo.Gender, userId)
 	if err != nil {
 		br.Msg = "授权失败"
 		br.ErrMsg = "授权失败,修改用户信息失败:" + err.Error()

+ 8 - 0
models/user_record.go

@@ -60,3 +60,11 @@ func ModifyUserRecordInfo(openId, nickName, headimgUrl, city, province, country,
 	_, err = o.Raw(sql, nickName, headimgUrl, sex, city, province, country, sessionKey, userId, openId).Exec()
 	return
 }
+
+//修改用户微信信息
+func ModifyUserRecordByDetail(openId, unionId, nickName, headimgUrl, city, province, country string, sex, userId int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE user_record SET union_id=?, nick_name=?,headimgurl=?,sex=?,city=?,province=?,country=? WHERE user_id=? and open_id=? `
+	_, err = o.Raw(sql, unionId, nickName, headimgUrl, sex, city, province, country, userId, openId).Exec()
+	return
+}

+ 1 - 1
services/elastic.go

@@ -327,7 +327,7 @@ func EsMatchFunctionScoreQuery(indexName, keyWord string, startSize, pageSize in
 	highlight = highlight.PreTags("<font color='red'>").PostTags("</font>")
 	request := client.Search(indexName).Highlight(highlight).From(startSize).Size(pageSize).Query(boolquery)
 	searchByMatch, err := request.Do(context.Background())
-	searchJson, err := json.Marshal(searchByMatch)
+	//searchJson, err := json.Marshal(searchByMatch)
 	if searchByMatch != nil {
 		if searchByMatch.Hits != nil {
 			for _, v := range searchByMatch.Hits.Hits {

+ 1 - 1
services/user.go

@@ -242,7 +242,7 @@ func WxLogin(code, openId, unionId string, wxUserInfo *WxUserInfo) (token string
 		return
 	}
 	if wxUserInfo != nil && wxUserInfo.Nickname != "" {
-		go models.ModifyUserRecordInfo(openId, wxUserInfo.Nickname, wxUserInfo.Headimgurl, wxUserInfo.City, wxUserInfo.Province, wxUserInfo.Country, wxUserInfo.SessionKey, wxUserInfo.Sex, userId)
+		models.ModifyUserRecordInfo(openId, wxUserInfo.Nickname, wxUserInfo.Headimgurl, wxUserInfo.City, wxUserInfo.Province, wxUserInfo.Country, wxUserInfo.SessionKey, wxUserInfo.Sex, userId)
 	}
 	//如果已经登录注册绑定的情况下
 	if wxUser != nil && wxUserErr == nil {