优化 用户查询

This commit is contained in:
wangw 2025-09-26 17:22:40 +08:00
parent 006dbc8dde
commit 1b826b2782
3 changed files with 137 additions and 117 deletions

View File

@ -32,124 +32,129 @@ public class ShopUserController {
@Resource @Resource
private ShopUserFlowService shopUserFlowService; private ShopUserFlowService shopUserFlowService;
/** // /**
* 获取店铺用户概述信息 // * 获取店铺用户概述信息
* // *
* @param isVip 0 非vip 1 vip // * @param isVip 0 非vip 1 vip
* @return 概述信息 // * @return 概述信息
*/ // */
@SaAdminCheckPermission(value = "shopUser:summary", name = "店铺用户概述信息") // @SaAdminCheckPermission(value = "shopUser:summary", name = "店铺用户概述信息")
@GetMapping("/summary") // @GetMapping("/summary")
// @SaStaffCheckPermission("yun_xu_guan_li_hui_yuan_xin_xi") //// @SaStaffCheckPermission("yun_xu_guan_li_hui_yuan_xin_xi")
public CzgResult<ShopUserSummaryDTO> summary(Integer isVip) { // public CzgResult<ShopUserSummaryDTO> summary(Integer isVip) {
return CzgResult.success(shopUserService.getSummary(StpKit.USER.getHeadShopIdBySession(), isVip)); // return CzgResult.success(shopUserService.getSummary(StpKit.USER.getHeadShopIdBySession(), isVip));
// }
//
// /**
// * 获取店铺用户充值记录
// * @param userId 用户id
// * @param startTime 开始时间
// * @param endTime 结束时间
// * @param bizCode 充值类型 类型
// * cashIn 现金充值
// * wechatIn 微信小程序充值
// * alipayIn 支付宝小程序充值
// * awardIn 充值奖励
// * rechargeRefund 充值退款
// * orderPay 订单消费
// * orderRefund 订单退款
// * adminIn 管理员充值
// * adminOut管理员消费
// * @return 充值记录
// */
// @SaAdminCheckPermission(value = "shopUser:flow", name = "店铺用户充值记录")
// @GetMapping("/flow")
//// @SaStaffCheckPermission("yun_xu_guan_li_hui_yuan_xin_xi")
// public CzgResult<Page<ShopUserFlowVO>> flow(Integer userId, String bizCode, String startTime, String endTime) {
// return CzgResult.success(shopUserFlowService.pageInfo(StpKit.USER.getHeadShopIdBySession(), userId, bizCode, startTime, endTime));
// }
//
// /**
// * 余额明细记录导出
// * @param userId 用户id
// * @param bizCode 代码
// * @param startTime 开始时间
// * @param endTime 结束时间
// * @param response 响应
// * @throws IOException 异常
// */
// @SaAdminCheckPermission(value = "shopUser:flow:downLoad", name = "店铺用户充值记录导出")
// @GetMapping("/flow/download")
//// @SaStaffCheckPermission("yun_xu_guan_li_hui_yuan_xin_xi")
// public void flowDownload(Integer userId, String bizCode, String startTime, String endTime, HttpServletResponse response) throws IOException {
// shopUserFlowService.flowDownload(StpKit.USER.getHeadShopIdBySession(), userId, bizCode, startTime, endTime, response);
// }
//
// /**
// * 获取店铺用户列表
// *
// * @param key 昵称或手机号
// * @param isVip 0 非vip 1 vip
// * @return 用户列表
// */
//// @SaStaffCheckPermission("yun_xu_guan_li_hui_yuan_xin_xi")
// @SaAdminCheckPermission(value = "shopUser:list", name = "店铺用户列表")
// @GetMapping
// public CzgResult<Page<ShopUserDTO>> list(String key, Integer isVip, BigDecimal amount) {
// return CzgResult.success(shopUserService.getPage(key, isVip, amount));
// }
@GetMapping("/getPage")
public CzgResult<Page<ShopUser>> getPage(@RequestParam(required = false)String key,@RequestParam(required = false) Integer isVip) {
return CzgResult.success(shopUserService.getPage(key, isVip));
} }
/** // /**
* 获取店铺用户充值记录 // * 获取店铺用户详情
* @param userId 用户id // * @param id 会员用户id
* @param startTime 开始时间 // * @param userId 用户id
* @param endTime 结束时间 // * @return 用户详情
* @param bizCode 充值类型 类型 // */
* cashIn 现金充值 //// @SaStaffCheckPermission("yun_xu_guan_li_hui_yuan_xin_xi")
* wechatIn 微信小程序充值 // @SaAdminCheckPermission(value = "shopUser:detail", name = "店铺用户详情")
* alipayIn 支付宝小程序充值 // @GetMapping("/detail")
* awardIn 充值奖励 // public CzgResult<ShopUser> detail(Integer id, Integer userId) {
* rechargeRefund 充值退款 // if (id == null && userId == null) {
* orderPay 订单消费 // return CzgResult.failure("id和userId不能重复为空");
* orderRefund 订单退款 // }
* adminIn 管理员充值 // return CzgResult.success(shopUserService.getDetail(id, userId));
* adminOut管理员消费 // }
* @return 充值记录 //
*/ // /**
@SaAdminCheckPermission(value = "shopUser:flow", name = "店铺用户充值记录") // * 店铺用户信息添加
@GetMapping("/flow") // *
// @SaStaffCheckPermission("yun_xu_guan_li_hui_yuan_xin_xi") // * @return 是否成功
public CzgResult<Page<ShopUserFlowVO>> flow(Integer userId, String bizCode, String startTime, String endTime) { // */
return CzgResult.success(shopUserFlowService.pageInfo(StpKit.USER.getHeadShopIdBySession(), userId, bizCode, startTime, endTime)); //// @SaStaffCheckPermission("yun_xu_guan_li_hui_yuan_xin_xi")
} // @SaAdminCheckPermission(value = "shopUser:add", name = "店铺用户添加")
// @PostMapping
/** // public CzgResult<Boolean> add(@RequestBody @Validated ShopUserAddDTO shopUserAddDTO) {
* 余额明细记录导出 // return CzgResult.success(shopUserService.add(StpKit.USER.getHeadShopIdBySession(), shopUserAddDTO));
* @param userId 用户id // }
* @param bizCode 代码 //
* @param startTime 开始时间 // /**
* @param endTime 结束时间 // * 店铺用户信息修改
* @param response 响应 // *
* @throws IOException 异常 // * @return 是否成功
*/ // */
@SaAdminCheckPermission(value = "shopUser:flow:downLoad", name = "店铺用户充值记录导出") //// @SaStaffCheckPermission("yun_xu_guan_li_hui_yuan_xin_xi")
@GetMapping("/flow/download") // @SaAdminCheckPermission(value = "shopUser:edit", name = "店铺用户修改")
// @SaStaffCheckPermission("yun_xu_guan_li_hui_yuan_xin_xi") // @PutMapping
public void flowDownload(Integer userId, String bizCode, String startTime, String endTime, HttpServletResponse response) throws IOException { // public CzgResult<Boolean> edit(@RequestBody @Validated ShopUserEditDTO shopUserEditDTO) {
shopUserFlowService.flowDownload(StpKit.USER.getHeadShopIdBySession(), userId, bizCode, startTime, endTime, response); // return CzgResult.success(shopUserService.updateInfo(StpKit.USER.getHeadShopIdBySession(), shopUserEditDTO));
} // }
//
/** // /**
* 获取店铺用户列表 // * 店铺用户余额修改
* // *
* @param key 昵称或手机号 // * @return 是否成功
* @param isVip 0 非vip 1 vip // */
* @return 用户列表 //// @SaStaffCheckPermission("yun_xu_xiu_gai_hui_yuan_yu_e")
*/ // @SaAdminCheckPermission(value = "shopUser:editFlow", name = "店铺用户余额修改")
// @SaStaffCheckPermission("yun_xu_guan_li_hui_yuan_xin_xi") // @PutMapping("/money")
@SaAdminCheckPermission(value = "shopUser:list", name = "店铺用户列表") // public CzgResult<Boolean> editMoney(@RequestBody @Validated ShopUserMoneyEditDTO shopUserMoneyEditDTO) {
@GetMapping // shopUserMoneyEditDTO.setBizEnum(ShopUserFlowBizEnum.ADMIN_IN);
public CzgResult<Page<ShopUserDTO>> list(String key, Integer isVip, BigDecimal amount) { // return CzgResult.success(shopUserService.updateMoney(shopUserMoneyEditDTO) > 0L);
return CzgResult.success(shopUserService.getPage(key, isVip, amount)); // }
}
/**
* 获取店铺用户详情
* @param id 会员用户id
* @param userId 用户id
* @return 用户详情
*/
// @SaStaffCheckPermission("yun_xu_guan_li_hui_yuan_xin_xi")
@SaAdminCheckPermission(value = "shopUser:detail", name = "店铺用户详情")
@GetMapping("/detail")
public CzgResult<ShopUser> detail(Integer id, Integer userId) {
if (id == null && userId == null) {
return CzgResult.failure("id和userId不能重复为空");
}
return CzgResult.success(shopUserService.getDetail(id, userId));
}
/**
* 店铺用户信息添加
*
* @return 是否成功
*/
// @SaStaffCheckPermission("yun_xu_guan_li_hui_yuan_xin_xi")
@SaAdminCheckPermission(value = "shopUser:add", name = "店铺用户添加")
@PostMapping
public CzgResult<Boolean> add(@RequestBody @Validated ShopUserAddDTO shopUserAddDTO) {
return CzgResult.success(shopUserService.add(StpKit.USER.getHeadShopIdBySession(), shopUserAddDTO));
}
/**
* 店铺用户信息修改
*
* @return 是否成功
*/
// @SaStaffCheckPermission("yun_xu_guan_li_hui_yuan_xin_xi")
@SaAdminCheckPermission(value = "shopUser:edit", name = "店铺用户修改")
@PutMapping
public CzgResult<Boolean> edit(@RequestBody @Validated ShopUserEditDTO shopUserEditDTO) {
return CzgResult.success(shopUserService.updateInfo(StpKit.USER.getHeadShopIdBySession(), shopUserEditDTO));
}
/**
* 店铺用户余额修改
*
* @return 是否成功
*/
// @SaStaffCheckPermission("yun_xu_xiu_gai_hui_yuan_yu_e")
@SaAdminCheckPermission(value = "shopUser:editFlow", name = "店铺用户余额修改")
@PutMapping("/money")
public CzgResult<Boolean> editMoney(@RequestBody @Validated ShopUserMoneyEditDTO shopUserMoneyEditDTO) {
shopUserMoneyEditDTO.setBizEnum(ShopUserFlowBizEnum.ADMIN_IN);
return CzgResult.success(shopUserService.updateMoney(shopUserMoneyEditDTO) > 0L);
}
} }

View File

@ -16,6 +16,8 @@ import java.math.BigDecimal;
*/ */
public interface AShopUserService { public interface AShopUserService {
Page<ShopUser> getPage(String key, Integer isVip);
Page<ShopUserDTO> getPage(String key, Integer isVip, BigDecimal amount); Page<ShopUserDTO> getPage(String key, Integer isVip, BigDecimal amount);
Boolean add(Long shopId, ShopUserAddDTO shopUserAddDTO); Boolean add(Long shopId, ShopUserAddDTO shopUserAddDTO);

View File

@ -65,6 +65,19 @@ public class AShopUserServiceImpl implements AShopUserService {
return shopUser; return shopUser;
} }
@Override
public Page<ShopUser> getPage(String key, Integer isVip) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq(ShopUser::getMainShopId, StpKit.USER.getHeadShopIdBySession());
queryWrapper.eq(ShopUser::getIsVip, isVip);
queryWrapper.and(q -> {
q.like(ShopUser::getNickName, key).or(r -> {
r.like(ShopUser::getNickName, key);
});
});
return shopUserService.page(PageUtil.buildPage(), queryWrapper);
}
@Override @Override
public Page<ShopUserDTO> getPage(String key, Integer isVip, BigDecimal amount) { public Page<ShopUserDTO> getPage(String key, Integer isVip, BigDecimal amount) {
PageHelper.startPage(PageUtil.buildPageHelp()); PageHelper.startPage(PageUtil.buildPageHelp());