|
@@ -38,16 +38,6 @@ func GetWxUserItemByOpenId(openid string) (item *models.WxUserItem, err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- if userRecord.UserId <= 0 {
|
|
|
- userRecordCygx, userRecordErrCygx := models.GetUserRecordByUnionId(userRecord.UnionId, 4)
|
|
|
-
|
|
|
- if userRecordErrCygx != nil && userRecordErrCygx.Error() != utils.ErrNoRow() {
|
|
|
- err = userRecordErrCygx
|
|
|
- }
|
|
|
- userRecord = userRecordCygx
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
if userRecord.UserId <= 0 {
|
|
|
err = ERR_USER_NOT_BIND
|
|
@@ -292,13 +282,29 @@ QUERY_WX_USER:
|
|
|
wxUser, wxUserErr := GetWxUserItemByOpenId(openId)
|
|
|
fmt.Println("wxUserErr", wxUserErr)
|
|
|
if wxUserErr == ERR_NO_USER_RECORD {
|
|
|
-
|
|
|
- _, recordErr := AddUserRecord(openId, unionId, wxUserInfo.Nickname, "", wxUserInfo.Province, wxUserInfo.City, wxUserInfo.Country, wxUserInfo.Headimgurl, wxUserInfo.SessionKey, utils.WxPlatform, wxUserInfo.Sex, 0)
|
|
|
-
|
|
|
- if recordErr != nil {
|
|
|
- err = recordErr
|
|
|
+
|
|
|
+ userRecordCygx, userRecordErrCygx := models.GetUserRecordByUnionId(unionId, 4)
|
|
|
+ if userRecordErrCygx != nil && userRecordErrCygx.Error() != utils.ErrNoRow() {
|
|
|
+ err = userRecordErrCygx
|
|
|
return
|
|
|
}
|
|
|
+ if userRecordCygx != nil {
|
|
|
+ _, recordErr := AddUserRecordByCygx(openId, unionId, wxUserInfo.Nickname, userRecordCygx.RealName, wxUserInfo.Province, wxUserInfo.City, wxUserInfo.Country, wxUserInfo.Headimgurl, wxUserInfo.SessionKey, utils.WxPlatform, wxUserInfo.Sex, 0, userRecordCygx.UserId)
|
|
|
+
|
|
|
+ if recordErr != nil {
|
|
|
+ err = recordErr
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+
|
|
|
+
|
|
|
+ _, recordErr := AddUserRecord(openId, unionId, wxUserInfo.Nickname, "", wxUserInfo.Province, wxUserInfo.City, wxUserInfo.Country, wxUserInfo.Headimgurl, wxUserInfo.SessionKey, utils.WxPlatform, wxUserInfo.Sex, 0)
|
|
|
+
|
|
|
+ if recordErr != nil {
|
|
|
+ err = recordErr
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
goto QUERY_WX_USER
|
|
|
} else if wxUserErr == ERR_USER_NOT_BIND {
|
|
@@ -374,7 +380,7 @@ QUERY_WX_USER:
|
|
|
loginLog.OpenId = openId
|
|
|
loginLog.UnionId = unionId
|
|
|
loginLog.CreateTime = time.Now()
|
|
|
- loginLog.Handle = "wechat_login_cygx"
|
|
|
+ loginLog.Handle = "wechat_login_mfyx"
|
|
|
loginLog.Remark = token
|
|
|
go models.AddWxUserLog(loginLog)
|
|
|
}
|
|
@@ -418,6 +424,40 @@ func AddUserRecord(openId, unionId, nickName, realName, province, city, country,
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+func AddUserRecordByCygx(openId, unionId, nickName, realName, province, city, country, headimgurl, sessionKey string, platform, sex, subscribe, userId int) (userRecord *models.UserRecord, err error) {
|
|
|
+ find, err := models.GetUserRecordByOpenId(openId)
|
|
|
+ if err != nil && err.Error() != utils.ErrNoRow() {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if find != nil {
|
|
|
+ userRecord = find
|
|
|
+ return
|
|
|
+ }
|
|
|
+ userRecord = &models.UserRecord{
|
|
|
+ OpenId: openId,
|
|
|
+ UnionId: unionId,
|
|
|
+ Subscribe: subscribe,
|
|
|
+ NickName: nickName,
|
|
|
+ RealName: realName,
|
|
|
+ Sex: sex,
|
|
|
+ Province: province,
|
|
|
+ City: city,
|
|
|
+ Country: country,
|
|
|
+ Headimgurl: headimgurl,
|
|
|
+ CreateTime: time.Now(),
|
|
|
+ CreatePlatform: platform,
|
|
|
+ SessionKey: sessionKey,
|
|
|
+ UserId: userId,
|
|
|
+ }
|
|
|
+ recordId, err := models.AddUserRecord(userRecord)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ userRecord.UserRecordId = int(recordId)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
func SendEmailUserWhiteListChange(cont context.Context) (err error) {
|
|
|
var msg string
|