From 0449a6264819bce3869f47b9e5bd3729f158db54 Mon Sep 17 00:00:00 2001 From: luofl <1442745593@qq.com> Date: 星期五, 14 三月 2025 16:05:24 +0800 Subject: [PATCH] 迭代版本:2.28 --- ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java | 115 +++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 87 insertions(+), 28 deletions(-) diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java index 9c9444c..e99289b 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java @@ -2,9 +2,9 @@ import cn.hutool.core.collection.CollectionUtil; -import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; @@ -33,7 +33,6 @@ import com.ruoyi.other.api.domain.VipSetting; import com.ruoyi.other.api.feignClient.ShopBalanceStatementClient; import com.ruoyi.other.api.feignClient.ShopClient; -import com.ruoyi.other.api.feignClient.StoreClient; import com.ruoyi.other.api.feignClient.VipSettingClient; import com.ruoyi.system.api.domain.SysUser; import com.ruoyi.system.api.feignClient.SysUserClient; @@ -56,8 +55,6 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import static com.ruoyi.common.core.constant.SecurityConstants.USER_APPLET_KEY; - /** * <p> * 前端控制器 @@ -77,8 +74,6 @@ @Resource private AppUserService appUserService; @Resource - private StoreClient storeClient; - @Resource private UserCouponService userCouponService; @Resource @@ -87,8 +82,6 @@ private VipSettingClient vipSettingClient; @Resource private UserPointService userPointService; - @Resource - private VipSettingService vipSettingService; @Resource private AppUserMapper appUserMapper; @Resource @@ -112,6 +105,9 @@ @Resource private WeChatUtil weChatUtil; + + @Resource + private IAppUserGiveawayTemporaryService appUserGiveawayTemporaryService; @Value("${file.upload.location}") private String filePath; @@ -176,7 +172,7 @@ @PostMapping("/getCouponCount") public R<Long> getCouponCount(@RequestParam("userId") Long userId, @RequestParam("couponId") Integer couponId) { LambdaQueryChainWrapper<UserCoupon> chainWrapper = userCouponService.lambdaQuery().eq(UserCoupon::getCouponId, couponId); - if(null != userId && -1 == userId){ + if(null != userId && -1 != userId){ chainWrapper.eq(UserCoupon::getAppUserId, userId); } Long count = chainWrapper.count(); @@ -559,6 +555,11 @@ } else { user.setIsSign(0); } + + List<AppUserGiveawayTemporary> temporaryList = appUserGiveawayTemporaryService.list(new LambdaQueryWrapper<AppUserGiveawayTemporary>() + .eq(AppUserGiveawayTemporary::getAppUserId, userId)); + + user.setLavePoint(temporaryList.stream().mapToInt(AppUserGiveawayTemporary::getTotalPoint).sum() + user.getTotalPoint()); return R.ok(user); } @@ -688,14 +689,42 @@ return R.ok(list); } + + @GetMapping("/getUserPointsPage") + @ApiOperation(value = "用户列表", tags = {"管理后台"}) + public R<IPage<AppUser>> getUserPointsPage(@ApiParam("页码") @RequestParam Integer pageNum, + @ApiParam("每一页数据大小") Integer pageSize, + AppUser appUser) { + + Long userId = tokenService.getLoginUser().getUserid(); + SysUser data = sysUserClient.getSysUser(userId).getData(); + + QueryWrapper<AppUser> queryWrapper = new QueryWrapper<>(); + if (data.getRoleType() == 2) { + Integer shopId = data.getObjectId(); + List<Order> orders = orderClient.getRedeemedOrdersByShop(shopId).getData(); + List<Long> userIds = orders.stream().map(Order::getAppUserId).collect(Collectors.toList()); + queryWrapper.in(!CollectionUtils.isEmpty(userIds), "id", userIds) + .like(StringUtils.isNotEmpty( appUser.getName()),"name", appUser.getName()); + } + queryWrapper.eq("del_flag", 0); + queryWrapper.ne("status", 3); + + List<AppUser> appUserList = appUserService.list(queryWrapper); + Page<AppUser> objectPage = Page.of(pageNum, pageSize); + objectPage.setRecords(appUserList); + return R.ok(objectPage); + + } + /** * 获取用户列表 */ @GetMapping("/getAppuserPage") - @ApiOperation(value = "用户列表", tags = {"管理后台"}) public R<IPage<AppUser>> getAppuserPage(@ApiParam("页码") @RequestParam Integer pageNum, - @ApiParam("每一页数据大小") Integer pageSize, - AppUser appUser) { + @ApiParam("每一页数据大小") Integer pageSize, + AppUser appUser){ + Long userid = tokenService.getLoginUser().getUserid(); SysUser sysUser = sysUserClient.getSysUser(userid).getData(); Integer shopId = null; @@ -721,6 +750,8 @@ } return R.ok(appuserPage); } + + @GetMapping("/shop/getAppuserPage") @ApiOperation(value = "用户列表", tags = {"门店后台"}) @@ -1072,22 +1103,46 @@ @GetMapping("/statistics") @ApiOperation(value = "用户统计", tags = {"管理后台-首页统计-用户统计"}) public R<UserStatistics> statistics() { - Long userid = tokenService.getLoginUser().getUserid(); - SysUser data = sysUserClient.getSysUser(userid).getData(); - Integer shopId = null; - Set<Long> userId = null; - if(data.getRoleType() == 2){ - shopId = data.getObjectId(); - userId = orderClient.getAppUserByShoppingShop(shopId).getData(); + Long userId = tokenService.getLoginUser().getUserid(); + SysUser data = sysUserClient.getSysUser(userId).getData(); + + QueryWrapper<AppUser> queryWrapper = new QueryWrapper<>(); + if (data.getRoleType() == 2) { + Integer shopId = data.getObjectId(); + List<Order> orders = orderClient.getRedeemedOrdersByShop(shopId).getData(); + List<Long> userIds = orders.stream().map(Order::getAppUserId).collect(Collectors.toList()); + queryWrapper.in(!CollectionUtils.isEmpty(userIds), "id", userIds); // userIds 不为空时,查询 id 在 userIds 中 } - UserStatistics userStatistics = appUserMapper.getUserStatistics(shopId, userId); - List<Shop> shopList = shopClient.getAllShop().getData(); - if (CollectionUtil.isNotEmpty(shopList)){ - long count = shopList.stream().map(Shop::getAppUserId).distinct().count(); - userStatistics.setShopUser((int) count); - }else { - userStatistics.setShopUser(0); - } + queryWrapper.eq("del_flag", 0); + queryWrapper.ne("status", 3); + List<AppUser> appUserList = appUserService.list(queryWrapper); + + Map<Integer, Long> vipIdCountMap = appUserList.stream() + .collect(Collectors.groupingBy(AppUser::getVipId, Collectors.counting())); + + UserStatistics userStatistics = new UserStatistics(); + userStatistics.setTotalUser(appUserList.size()); + userStatistics.setConsumerUser(vipIdCountMap.getOrDefault(0, 0L).intValue() + + vipIdCountMap.getOrDefault(1, 0L).intValue() + + vipIdCountMap.getOrDefault(2, 0L).intValue() + + vipIdCountMap.getOrDefault(3, 0L).intValue()); + userStatistics.setCommonUser(vipIdCountMap.getOrDefault(1, 0L).intValue()); + userStatistics.setGoldUser(vipIdCountMap.getOrDefault(2, 0L).intValue()); + userStatistics.setDiamondUser(vipIdCountMap.getOrDefault(3, 0L).intValue()); + userStatistics.setEntrepreneurUser(vipIdCountMap.getOrDefault(4, 0L).intValue() + + vipIdCountMap.getOrDefault(5, 0L).intValue() + + vipIdCountMap.getOrDefault(6, 0L).intValue() + + vipIdCountMap.getOrDefault(7, 0L).intValue()); + userStatistics.setProxyUser(vipIdCountMap.getOrDefault(4, 0L).intValue()); + userStatistics.setAgentUser(vipIdCountMap.getOrDefault(5, 0L).intValue()); + userStatistics.setTotalAgentUser(vipIdCountMap.getOrDefault(6, 0L).intValue()); + userStatistics.setPartnerUser(vipIdCountMap.getOrDefault(7, 0L).intValue()); + + long shopUserCount = appUserList.stream() + .filter(appUser -> appUser.getUserType() == 2) + .count(); + userStatistics.setShopUser((int) shopUserCount); + return R.ok(userStatistics); } @@ -1315,7 +1370,11 @@ public void vipUpgrade(@RequestParam("appUserId") Long appUserId){ appUserService.vipUpgrade(appUserId); } - + + @PostMapping("/vipConsumption") + public void vipConsumption(@RequestParam("appUserId") Long appUserId){ + appUserService.vipConsumption(appUserId); + } /** * 检查会员降级 -- Gitblit v1.7.1