1.修复系统用户编辑后密码无法登录的缺陷;
2.修复系统用户编辑时错误提示;
This commit is contained in:
parent
b50abd884b
commit
16c6f1671c
|
@ -333,13 +333,13 @@ func UpdateSysUser(c *gin.Context) {
|
||||||
if req.ShopperCode != "" {
|
if req.ShopperCode != "" {
|
||||||
if len(req.ShopperCode) != 6 {
|
if len(req.ShopperCode) != 6 {
|
||||||
logger.Error("兑换码不是6位")
|
logger.Error("兑换码不是6位")
|
||||||
app.Error(c, http.StatusInternalServerError, err, "兑换码长度不符合要求[6位]")
|
app.Error(c, http.StatusInternalServerError, err, "店员识别码长度不符合要求[6位]")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Uid == 0 {
|
if req.Uid == 0 {
|
||||||
logger.Error("uid为0")
|
logger.Error("uid为0")
|
||||||
app.Error(c, http.StatusInternalServerError, err, "配置店员兑换码需填写小程序账号ID")
|
app.Error(c, http.StatusInternalServerError, err, "配置店员识别码需填写小程序账号ID")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -403,12 +403,10 @@ func UpdateSysUser(c *gin.Context) {
|
||||||
Uid: req.Uid,
|
Uid: req.Uid,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if req.LoginM.UserName.Username == "" {
|
|
||||||
data.LoginM.UserName = sysInfo.LoginM.UserName
|
|
||||||
}
|
|
||||||
|
|
||||||
if req.LoginM.PassWord.Password == "" {
|
// 重置密码时uid赋值为原有的uid
|
||||||
data.LoginM.PassWord = sysInfo.LoginM.PassWord
|
if req.Phone == "" && req.LoginM.PassWord.Password != "" && req.Uid == 0 {
|
||||||
|
data.Uid = sysInfo.Uid
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(req.StoreList) != 0 {
|
if len(req.StoreList) != 0 {
|
||||||
|
@ -425,9 +423,13 @@ func UpdateSysUser(c *gin.Context) {
|
||||||
begin := orm.Eloquent.Begin()
|
begin := orm.Eloquent.Begin()
|
||||||
data.UpdateBy = tools.GetUserIdStr(c)
|
data.UpdateBy = tools.GetUserIdStr(c)
|
||||||
result, err := data.Update(begin, data.UserId)
|
result, err := data.Update(begin, data.UserId)
|
||||||
|
if err != nil {
|
||||||
|
begin.Rollback()
|
||||||
|
}
|
||||||
tools.HasError(err, "修改失败", 500)
|
tools.HasError(err, "修改失败", 500)
|
||||||
|
|
||||||
// 判断是否修改了uid
|
// 判断是否修改了uid
|
||||||
|
if req.Phone != "" { // 手机号目前是必填项,不能为空,否则可能是重置密码
|
||||||
if sysInfo.Uid == 0 && req.Uid != 0 { // 新增uid,直接更新为2即可
|
if sysInfo.Uid == 0 && req.Uid != 0 { // 新增uid,直接更新为2即可
|
||||||
err = models.UpdateUserType(begin, req.Uid, models.UserTypeShopAssistant, uint32(req.RoleId))
|
err = models.UpdateUserType(begin, req.Uid, models.UserTypeShopAssistant, uint32(req.RoleId))
|
||||||
} else if sysInfo.Uid != 0 {
|
} else if sysInfo.Uid != 0 {
|
||||||
|
@ -450,13 +452,14 @@ func UpdateSysUser(c *gin.Context) {
|
||||||
app.Error(c, http.StatusInternalServerError, err, "修改失败")
|
app.Error(c, http.StatusInternalServerError, err, "修改失败")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if req.ShopperCode != "" { // 添加店员兑换码:删除原兑换码,添加新兑换码
|
if req.ShopperCode != "" { // 添加店员兑换码:删除原兑换码,添加新兑换码
|
||||||
err = models.UpdateShopperCode(req, begin, sysInfo)
|
err = models.UpdateShopperCode(req, begin, sysInfo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
begin.Rollback()
|
begin.Rollback()
|
||||||
logger.Error("UpdateShopperCode err:", logger.Field("err", err))
|
logger.Error("UpdateShopperCode err:", logger.Field("err", err))
|
||||||
app.Error(c, http.StatusInternalServerError, err, "修改失败")
|
app.Error(c, http.StatusInternalServerError, err, err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -597,15 +597,16 @@ func (e *SysUser) Update(begin *gorm.DB, id int) (update SysUser, err error) {
|
||||||
|
|
||||||
//参数1:是要修改的数据
|
//参数1:是要修改的数据
|
||||||
//参数2:是修改的数据
|
//参数2:是修改的数据
|
||||||
if e.Password != "" { // 更新密码时其他信息为空,需要update
|
|
||||||
if err = begin.Table(e.TableName()).Model(&update).Updates(&e).Error; err != nil {
|
if err = begin.Table(e.TableName()).Model(&update).Updates(&e).Error; err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if err = begin.Table(e.TableName()).Model(&update).Save(&e).Error; err != nil {
|
if e.Uid == 0 {
|
||||||
|
if err = begin.Table(e.TableName()).Model(&update).UpdateColumn("uid", 0).Error; err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -833,7 +834,7 @@ func UpdateShopperCode(req InsertSysUserReq, begin *gorm.DB, sysInfo *SysUser) e
|
||||||
orm.Eloquent.Debug().Model(&ShopperPromotionCode{}).
|
orm.Eloquent.Debug().Model(&ShopperPromotionCode{}).
|
||||||
Where("code = ? and state = ?", req.ShopperCode, 2).Find(&oldShopperCode)
|
Where("code = ? and state = ?", req.ShopperCode, 2).Find(&oldShopperCode)
|
||||||
if oldShopperCode.ID != 0 && oldShopperCode.Uid != sysInfo.Uid {
|
if oldShopperCode.ID != 0 && oldShopperCode.Uid != sysInfo.Uid {
|
||||||
return errors.New(fmt.Sprintf("兑换码[%s]重复,请更换", req.ShopperCode))
|
return errors.New(fmt.Sprintf("[%s]与已有店员识别码重复", req.ShopperCode))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取有效门店id
|
// 获取有效门店id
|
||||||
|
|
Loading…
Reference in New Issue
Block a user