1、系统列表优化,增加小程序ID展示和筛选;
2、新增系统用户时,如果是店员则同步更新user表的店员姓名;
This commit is contained in:
parent
eb9a6e3a7d
commit
54eb867d40
|
@ -29,6 +29,7 @@ import (
|
|||
// @Param nickName query string false "昵称"
|
||||
// @Param storeId query string false "门店id"
|
||||
// @Param shopper_code query string false "店员兑换码"
|
||||
// @Param uid query string false "小程序ID"
|
||||
// @Param is_export query string false "是否导出:1-导出"
|
||||
// @Success 200 {object} models.SysUserListResp
|
||||
// @Router /api/v1/sysUserList [get]
|
||||
|
@ -48,14 +49,16 @@ func GetSysUserList(c *gin.Context) {
|
|||
if index != "" {
|
||||
pageIndex, err = tools.StringToInt(index)
|
||||
}
|
||||
data.Username = c.Request.FormValue("username") // 用户名称
|
||||
data.Status = c.Request.FormValue("status") // 状态
|
||||
data.Phone = c.Request.FormValue("phone") // 手机号
|
||||
strRoleId := c.Request.FormValue("roleId") // 用户角色
|
||||
data.NickName = c.Request.FormValue("nickName") // 用户昵称
|
||||
strStoreId := c.Request.FormValue("storeId") // 门店id
|
||||
data.ShopperCode = c.Request.FormValue("shopper_code") // 店员兑换码
|
||||
exportFlag := c.Request.FormValue("is_export") // 是否导出excel
|
||||
data.Username = c.Request.FormValue("username") // 用户名称
|
||||
data.Status = c.Request.FormValue("status") // 状态
|
||||
data.Phone = c.Request.FormValue("phone") // 手机号
|
||||
strRoleId := c.Request.FormValue("roleId") // 用户角色
|
||||
data.NickName = c.Request.FormValue("nickName") // 用户昵称
|
||||
strStoreId := c.Request.FormValue("storeId") // 门店id
|
||||
data.ShopperCode = c.Request.FormValue("shopper_code") // 店员兑换码
|
||||
UidFlag, _ := tools.StringToInt(c.Request.FormValue("uid")) // 小程序ID
|
||||
data.Uid = uint32(UidFlag)
|
||||
exportFlag := c.Request.FormValue("is_export") // 是否导出excel
|
||||
export := 0
|
||||
if exportFlag != "" {
|
||||
export, _ = tools.StringToInt(exportFlag)
|
||||
|
@ -301,7 +304,8 @@ func InsertSysUser(c *gin.Context) {
|
|||
|
||||
// 如果添加了小程序id,则需要更新user表的user_type字段为2-店员
|
||||
if req.Uid != 0 {
|
||||
err = models.UpdateUserType(begin, req.Uid, models.UserTypeShopAssistant, uint32(req.RoleId))
|
||||
err = models.UpdateUserTypeAndShopperName(begin, req.Uid, models.UserTypeShopAssistant, uint32(req.RoleId),
|
||||
req.NickName)
|
||||
if err != nil {
|
||||
begin.Rollback()
|
||||
logger.Error("UpdateUserType err:", logger.Field("err", err))
|
||||
|
|
|
@ -688,6 +688,22 @@ func UpdateUserType(begin *gorm.DB, uid, nType, roleId uint32) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// UpdateUserTypeAndShopperName 更新uid的user_type为2 和 店员名称
|
||||
func UpdateUserTypeAndShopperName(begin *gorm.DB, uid, nType, roleId uint32, shopperName string) error {
|
||||
// 更新库存表
|
||||
err := begin.Table("user").Where("uid = ?", uid).
|
||||
Updates(map[string]interface{}{
|
||||
"user_type": nType,
|
||||
"xcx_role_id": roleId,
|
||||
"shop_assistant_name": shopperName,
|
||||
}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetUserEffectiveStore 获取店员当前的有效门店(邀请客户时使用)
|
||||
func GetUserEffectiveStore(uid uint32) ([]StoreInfo, error) {
|
||||
user := new(SysUser)
|
||||
|
|
Loading…
Reference in New Issue
Block a user