xingzai 11 meses atrás
pai
commit
6105c19b43
3 arquivos alterados com 8 adições e 11 exclusões
  1. 1 5
      controllers/user.go
  2. 1 5
      controllers/wechat.go
  3. 6 1
      services/user.go

+ 1 - 5
controllers/user.go

@@ -46,7 +46,6 @@ func (this *UserController) Login() {
 		br.Ret = 408
 		return
 	}
-	inviteShareCode := req.InviteShareCode
 	unionId := this.User.UnionId
 	openId := this.User.OpenId
 	if unionId == "" {
@@ -114,7 +113,7 @@ func (this *UserController) Login() {
 	if len(req.Mobile) >= 11 && req.CountryCode == "" {
 		req.CountryCode = "86"
 	}
-	user, err = services.BindWxUser(openId, req.Mobile, req.Email, req.CountryCode)
+	user, err = services.BindWxUser(openId, req.Mobile, req.Email, req.CountryCode, "")
 	if err != nil {
 		br.Msg = "登录失败"
 		br.ErrMsg = "绑定手机号失败:" + err.Error()
@@ -190,9 +189,6 @@ func (this *UserController) Login() {
 
 	{
 		services.UpdateCygxSubscribe(userId, unionId) //先关注后登录,更新用户是否关注过查研观向小助手公众号
-		if inviteShareCode != "" {                    //记录分享来源
-			go services.AddCygxUserAdminShareHistory(user, "login", "", inviteShareCode, 0) //记录分享来源
-		}
 	}
 
 	resp := new(models.LoginResp)

+ 1 - 5
controllers/wechat.go

@@ -437,17 +437,13 @@ func (this *WechatController) Getuserphonenumber() {
 		return
 	}
 
-	user, err = services.BindWxUser(openId, mobile, "", countryCode)
+	user, err = services.BindWxUser(openId, mobile, "", countryCode, inviteShareCode)
 	if err != nil {
 		br.Msg = "登录失败"
 		br.ErrMsg = "绑定手机号失败:" + err.Error()
 		return
 	}
 
-	if inviteShareCode != "" { //记录分享来源
-		go services.AddCygxUserAdminShareHistory(user, "login", "", inviteShareCode, 0) //记录分享来源
-	}
-
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "登录成功"

+ 6 - 1
services/user.go

@@ -171,7 +171,7 @@ func formatWxUser(wxUser *models.WxUserItem, platform int) {
 }
 
 // 用户绑定
-func BindWxUser(openid, mobile, email, countryCode string) (wxUser *models.WxUserItem, err error) {
+func BindWxUser(openid, mobile, email, countryCode, inviteShareCode string) (wxUser *models.WxUserItem, err error) {
 	if mobile == "" && email == "" {
 		err = errors.New("手机号或邮箱必填一个")
 		return
@@ -230,6 +230,11 @@ func BindWxUser(openid, mobile, email, countryCode string) (wxUser *models.WxUse
 		user.UserId = int(tmpUserId)
 		userId = int(tmpUserId)
 		wxUser, err = models.GetWxUserItemByUserId(userId)
+
+		if inviteShareCode != "" { //记录分享来源
+			go AddCygxUserAdminShareHistory(wxUser, "login", "", inviteShareCode, 0) //记录分享来源
+		}
+
 	} else {
 		userId = wxUser.UserId
 		err = models.BindUserOutboundMobile(mobile, countryCode, userId)