Explorar o código

fix(新注册用户):入库时,新增国际区号

Roc %!s(int64=3) %!d(string=hai) anos
pai
achega
2a0a1d5bce
Modificáronse 4 ficheiros con 22 adicións e 13 borrados
  1. 1 1
      controllers/user.go
  2. 1 1
      controllers/user_pc.go
  3. 6 0
      models/wx_user.go
  4. 14 11
      services/user.go

+ 1 - 1
controllers/user.go

@@ -328,7 +328,7 @@ func (this *UserNotAuthController) Login() {
 		br.ErrMsg = "无效的登录方式,Err:" + err.Error()
 		return
 	}
-	user, err = services.BindWxUser(openId, req.Mobile, req.Email, 1)
+	user, err = services.BindWxUser(openId, req.Mobile, req.Email, req.AreaNum, 1)
 	if err != nil && err.Error() != utils.ErrNoRow() {
 		br.Msg = "登录失败,系统处理中,请稍后重试"
 		br.ErrMsg = "登录失败:" + err.Error()

+ 1 - 1
controllers/user_pc.go

@@ -500,7 +500,7 @@ func (this *UserPcNotAuthController) PcBind() {
 		return
 	}
 
-	user, err := services.BindWxUser(openId, req.Mobile, req.Email, 2)
+	user, err := services.BindWxUser(openId, req.Mobile, req.Email, req.AreaNum, 2)
 	if err != nil {
 		br.Msg = "绑定失败:" + err.Error()
 		return

+ 6 - 0
models/wx_user.go

@@ -47,6 +47,10 @@ type WxUser struct {
 	LoginTime        time.Time `description:"最近一次登录时间"`
 	IsRegister       int       `description:"是否注册:1:已注册,0:未注册"`
 	Source           int       `description:"绑定来源,1:微信端,2:pc网页端,3:查研观向小程序,4:每日咨询"`
+
+	CountryCode         string `description:"区号,86、852、886等"`
+	OutboundMobile      string `description:"外呼手机号"`
+	OutboundCountryCode string `description:"外呼手机号区号,86、852、886等"`
 }
 
 type WxUserItem struct {
@@ -190,6 +194,7 @@ type LoginReq struct {
 	LoginType int    `description:"登录方式:1:手机,2:邮箱"`
 	Mobile    string `description:"手机号"`
 	Email     string `description:"邮箱"`
+	AreaNum   string `description:"国际区号"`
 }
 
 type LoginResp struct {
@@ -405,6 +410,7 @@ type BindReq struct {
 	BindType   int    `description:"绑定方式:1:手机,2:邮箱"`
 	Mobile     string `description:"手机号"`
 	Email      string `description:"邮箱"`
+	AreaNum    string `description:"国际区号"`
 	VerifyCode string `description:"短信/邮箱 验证码"`
 }
 

+ 14 - 11
services/user.go

@@ -159,7 +159,7 @@ func formatWxUser(wxUser *models.WxUserItem, platform int) {
 }
 
 //用户绑定
-func BindWxUser(openid, mobile, email string, registerPlatform int) (wxUser *models.WxUserItem, err error) {
+func BindWxUser(openid, mobile, email, areaNum string, registerPlatform int) (wxUser *models.WxUserItem, err error) {
 	source := 1 //绑定来源,1:微信端,2:pc网页端,3:查研观向小程序,4:每日咨询
 	if mobile == "" && email == "" {
 		err = errors.New("手机号或邮箱必填一个")
@@ -204,16 +204,19 @@ func BindWxUser(openid, mobile, email string, registerPlatform int) (wxUser *mod
 		}
 		utils.Rc.SetNX(key, "ok", time.Second*300)
 		user := &models.WxUser{
-			CompanyId:        1,
-			CreatedTime:      time.Now(),
-			FirstLogin:       1,
-			Enabled:          1,
-			RegisterPlatform: registerPlatform, //账号注册来源,注册平台,1:微信端,2:PC网页端
-			RegisterTime:     time.Now(),
-			Mobile:           mobile,
-			Email:            email,
-			IsRegister:       1,
-			Source:           source,
+			CompanyId:           1,
+			CreatedTime:         time.Now(),
+			FirstLogin:          1,
+			Enabled:             1,
+			RegisterPlatform:    registerPlatform, //账号注册来源,注册平台,1:微信端,2:PC网页端
+			RegisterTime:        time.Now(),
+			Mobile:              mobile,
+			Email:               email,
+			IsRegister:          1,
+			Source:              source,
+			CountryCode:         areaNum,
+			OutboundMobile:      mobile,
+			OutboundCountryCode: areaNum,
 		}
 		tmpUserId, addUserErr := models.AddWxUser(user)
 		//添加完成,清除缓存