فهرست منبع

绑定用户手机号区号

xingzai 3 سال پیش
والد
کامیت
2b329d33b4
2فایلهای تغییر یافته به همراه12 افزوده شده و 0 حذف شده
  1. 8 0
      models/user.go
  2. 4 0
      services/user.go

+ 8 - 0
models/user.go

@@ -252,3 +252,11 @@ func AddOutboundMobile(item *OutboundMobileItem, userId int) (err error) {
 	}
 	return
 }
+
+//用户绑定手机号时同时绑定外呼手机号
+func BindUserOutboundMobile(mobile, countryCode string, userId int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE wx_user SET outbound_mobile=? ,outbound_country_code = ?, country_code= ? WHERE user_id=? `
+	_, err = o.Raw(sql, mobile, countryCode, countryCode, userId).Exec()
+	return
+}

+ 4 - 0
services/user.go

@@ -226,6 +226,10 @@ func BindWxUser(openid, mobile, email, countryCode string) (wxUser *models.WxUse
 		wxUser, err = models.GetWxUserItemByUserId(userId)
 	} else {
 		userId = wxUser.UserId
+		err = models.BindUserOutboundMobile(mobile, countryCode, userId)
+		if err != nil {
+			return
+		}
 		if wxUser.IsRegister == 0 {
 			models.ModifyWxUserRegisterStatus(userId)
 		}