|
|
@@ -2,6 +2,8 @@ package user_controller
|
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
+ "strconv"
|
|
|
+
|
|
|
// "strconv"
|
|
|
// // "bufio"
|
|
|
"crypto/md5"
|
|
|
@@ -433,3 +435,60 @@ func (self *UserController) ShopApplication() {
|
|
|
self.Data["json"] = ret
|
|
|
self.ServeJSON()
|
|
|
}
|
|
|
+
|
|
|
+//修改交易密码
|
|
|
+func (self *UserController) SysUserBind() {
|
|
|
+ _id := self.Ctx.Input.Param(":invite_wxid")
|
|
|
+ wxId, _ := strconv.ParseInt(_id, 10, 64)
|
|
|
+ userNo := self.GetString("user_no")
|
|
|
+ remark := self.GetString("remark")
|
|
|
+
|
|
|
+ useCache, _ := self.GetBool("cache", false)
|
|
|
+ //wxUser := self.GetCurrentWxUser(useCache)
|
|
|
+ // if inviteWxId == 0 {
|
|
|
+ // self.ReturnError(403, apps.NoExist, "", nil)
|
|
|
+ // }
|
|
|
+ // wxUser := user_model.GetWxUserById(inviteWxId, useCache)
|
|
|
+ wxUser := user_model.GetWxUserById(wxId, useCache)
|
|
|
+ if wxUser == nil {
|
|
|
+ self.ReturnError(403, apps.NoExist, "", nil)
|
|
|
+ }
|
|
|
+ bindUser := user_model.GetBindUserByUserNo(userNo)
|
|
|
+ if bindUser != nil {
|
|
|
+ self.ReturnError(403, apps.HasBind, "", nil)
|
|
|
+ }
|
|
|
+
|
|
|
+ sysWxUser := user_model.GetWxUserByUserNo(userNo)
|
|
|
+ //同步会员资料--原会员迁移至新会员(除ID,invite_id之外)
|
|
|
+ sysWxUser.UserId = wxUser.UserId
|
|
|
+ sysWxUser.MpOpenid = wxUser.MpOpenid
|
|
|
+ sysWxUser.Openid = wxUser.Openid
|
|
|
+ sysWxUser.Nickname = wxUser.Nickname
|
|
|
+ sysWxUser.Unionid = wxUser.Unionid
|
|
|
+ sysWxUser.City = wxUser.City
|
|
|
+ sysWxUser.Country = wxUser.Country
|
|
|
+ sysWxUser.Province = wxUser.Province
|
|
|
+ sysWxUser.Sex = wxUser.Sex
|
|
|
+ sysWxUser.Head = wxUser.Head
|
|
|
+ sysWxUser.ChannelQrcodeId = wxUser.ChannelQrcodeId
|
|
|
+ sysWxUser.ShowInviteMode = wxUser.ShowInviteMode
|
|
|
+ sysWxUser.Rank = wxUser.Rank
|
|
|
+ err := sysWxUser.Save()
|
|
|
+ if err != nil {
|
|
|
+ self.ReturnError(403, apps.BindFail, "", nil)
|
|
|
+ }
|
|
|
+ //迁移该会员至备份表,删除微信表记录
|
|
|
+ wxUser.MigrateWxUsers()
|
|
|
+ //创建绑定记录
|
|
|
+ record := new(user_model.BindUser).Create(wxUser.Id, userNo, remark)
|
|
|
+ if record == nil {
|
|
|
+ self.ReturnError(403, apps.BindFail, "", nil)
|
|
|
+ }
|
|
|
+
|
|
|
+ type Ret struct {
|
|
|
+ Result bool `json:"result"`
|
|
|
+ }
|
|
|
+ ret := &Ret{Result: true}
|
|
|
+ self.Data["json"] = ret
|
|
|
+ self.ServeJSON()
|
|
|
+}
|