rdluck 4 anos atrás
pai
commit
fbad698107
2 arquivos alterados com 10 adições e 3 exclusões
  1. 5 2
      models/wx_user.go
  2. 5 1
      services/user.go

+ 5 - 2
models/wx_user.go

@@ -44,6 +44,7 @@ type WxUser struct {
 	LoginTime        time.Time `description:"最近一次登录时间"`
 	SessionKey       string    `description:"微信小程序会话密钥"`
 	IsRegister       int       `description:"是否注册:1:已注册,0:未注册"`
+	Source           int       `description:"绑定来源,1:微信端,2:pc网页端,3:查研观向小程序,4:每日咨询"`
 }
 
 //添加用户信息
@@ -72,6 +73,8 @@ type WxUserItem struct {
 	LastUpdatedTime time.Time `description:"最近一次修改时间"`
 	SessionKey      string    `description:"微信小程序会话密钥"`
 	CompanyName     string    `description:"公司名称"`
+	IsRegister      int       `description:"是否注册:1:已注册,0:未注册"`
+	Source          int
 }
 
 func GetWxUserItemByUnionid(unionid string) (item *WxUserItem, err error) {
@@ -197,7 +200,7 @@ func ModifyReportLastViewTime(uid int) (err error) {
 //变更联系人是否已注册状态
 func ModifyWxUserRegisterStatus(userId int) (err error) {
 	o := orm.NewOrm()
-	sql := `UPDATE wx_user SET is_register=?,register_time=NOW() WHERE user_id = ? `
+	sql := `UPDATE wx_user SET is_register=?,source=3,register_time=NOW() WHERE user_id = ? `
 	_, err = o.Raw(sql, 1, userId).Exec()
 	return
-}
+}

+ 5 - 1
services/user.go

@@ -196,6 +196,7 @@ func BindWxUser(openid, mobile, email string) (wxUser *models.WxUserItem, err er
 			Mobile:           mobile,
 			Email:            email,
 			IsRegister:       1,
+			Source:           3,
 		}
 		tmpUserId, addUserErr := models.AddWxUser(user)
 		if err != nil {
@@ -207,8 +208,11 @@ func BindWxUser(openid, mobile, email string) (wxUser *models.WxUserItem, err er
 		wxUser, err = models.GetWxUserItemByUserId(userId)
 	} else {
 		userId = wxUser.UserId
-		models.ModifyWxUserRegisterStatus(userId)
+		if wxUser.IsRegister == 0 {
+			models.ModifyWxUserRegisterStatus(userId)
+		}
 	}
+
 	//如果存在该手机号/邮箱,那么需要校验
 	if userRecord.UserId > 0 && userRecord.UserId != userId {
 		err = errors.New("用户已绑定,不允许重复绑定")