From fd7b8fb7c89832c28a838b0449bbb8a392433ee2 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期二, 22 四月 2025 14:33:02 +0800 Subject: [PATCH] 将华为云短信替换成阿里云短信 --- ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java | 180 ++++++++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 120 insertions(+), 60 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 7d2c4ab..69105c6 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 @@ -99,6 +99,8 @@ @Resource private BalanceChangeRecordService balanceChangeRecordService; @Resource + private BalanceChangeRecordCopyService balanceChangeRecordCopyService; + @Resource private UserChangeLogService userChangeLogService; @Resource private RedisService redisService; @@ -323,7 +325,11 @@ //获取绑定上级 if (user.getInviteUserId() != null) { AppUser byId = appUserService.getById(user.getInviteUserId()); - user.setTopUser(byId); + if(null != byId){ + user.setTopUser(byId); + }else{ + user.setTopUser(new AppUser()); + } }else { AppUser topUser = new AppUser(); user.setTopUser(topUser); @@ -371,7 +377,6 @@ .eq(AppUser::getDelFlag, 0) .ne(AppUser::getStatus, 3) .count(); - vip1Count1 += count1; Long count2 = appUserService.lambdaQuery() .eq(AppUser::getVipId, 2) @@ -379,42 +384,36 @@ .eq(AppUser::getDelFlag, 0) .ne(AppUser::getStatus, 3) .count(); - vip1Count2 += count2; Long count3 = appUserService.lambdaQuery() .eq(AppUser::getVipId, 3) .eq(AppUser::getInviteUserId, appUser.getId()) .eq(AppUser::getDelFlag, 0) .ne(AppUser::getStatus, 3) .count(); - vip1Count3 += count3; Long count4 = appUserService.lambdaQuery() .eq(AppUser::getVipId, 4) .eq(AppUser::getInviteUserId, appUser.getId()) .eq(AppUser::getDelFlag, 0) .ne(AppUser::getStatus, 3) .count(); - vip1Count4 += count4; Long count5 = appUserService.lambdaQuery() .eq(AppUser::getVipId, 5) .eq(AppUser::getInviteUserId, appUser.getId()) .eq(AppUser::getDelFlag, 0) .ne(AppUser::getStatus, 3) .count(); - vip1Count5 += count5; Long count6 = appUserService.lambdaQuery() .eq(AppUser::getVipId, 6) .eq(AppUser::getInviteUserId, appUser.getId()) .eq(AppUser::getDelFlag, 0) .ne(AppUser::getStatus, 3) .count(); - vip1Count6 += count6; Long count7 = appUserService.lambdaQuery() .eq(AppUser::getVipId, 7) .eq(AppUser::getInviteUserId, appUser.getId()) .eq(AppUser::getDelFlag, 0) .ne(AppUser::getStatus, 3) .count(); - vip1Count7 += count7; appUser.setCount1(count1); appUser.setCount2(count2); appUser.setCount3(count3); @@ -423,6 +422,7 @@ appUser.setCount6(count6); appUser.setCount7(count7); } + user.setBottomUsers(list); user.setCount1(vip1Count1); user.setCount2(vip1Count2); @@ -512,42 +512,23 @@ ArrayList<Long> userIds = new ArrayList<>(); userIds.add(userId); // 获取当前用户的所有下级 - List<AppUser> allSubordinates = getAllSubordinates(userId); - // 统计下级中每种会员类型的人数 - Map<Integer, Long> countMap = allSubordinates.stream() - .collect(Collectors.groupingBy(AppUser::getVipId, Collectors.counting())); - countMap.forEach((vipId, count) -> { - switch (vipId) { - case 1: - Long count1 = user.getCount1() == null ? 0 : user.getCount1(); - user.setCount1(count1 + count); - break; - case 2: - Long count2 = user.getCount2() == null ? 0 : user.getCount2(); - user.setCount2(count2 + count); - break; - case 3: - Long count3 = user.getCount3() == null ? 0 : user.getCount3(); - user.setCount3(count3 + count); - break; - case 4: - Long count4 = user.getCount4() == null ? 0 : user.getCount4(); - user.setCount4(count4 + count); - break; - case 5: - Long count5 = user.getCount5() == null ? 0 : user.getCount5(); - user.setCount5(count5 + count); - break; - case 6: - Long count6 = user.getCount6() == null ? 0 : user.getCount6(); - user.setCount6(count6 + count); - break; - case 7: - Long count7 = user.getCount7() == null ? 0 : user.getCount7(); - user.setCount7(count7 + count); - break; - } - }); + List<AppUser> allSubordinates = appUserService.list(new LambdaQueryWrapper<AppUser>() + .eq(AppUser::getInviteUserId, user.getId()).eq(AppUser::getDelFlag, 0) + .ne(AppUser::getStatus, 3)); + Long count1 = allSubordinates.stream().filter(s->s.getVipId() == 1).count(); + user.setCount1(count1); + Long count2 = allSubordinates.stream().filter(s->s.getVipId() == 2).count(); + user.setCount2(count2); + Long count3 = allSubordinates.stream().filter(s->s.getVipId() == 3).count(); + user.setCount3(count3); + Long count4 = allSubordinates.stream().filter(s->s.getVipId() == 4).count(); + user.setCount4(count4); + Long count5 = allSubordinates.stream().filter(s->s.getVipId() == 5).count(); + user.setCount5(count5); + Long count6 = allSubordinates.stream().filter(s->s.getVipId() == 6).count(); + user.setCount6(count6); + Long count7 = allSubordinates.stream().filter(s->s.getVipId() == 7).count(); + user.setCount7(count7); List<UserSignRecord> list = userSignRecordService.lambdaQuery().eq(UserSignRecord::getSignDay, LocalDate.now()) .eq(UserSignRecord::getAppUserId,userId).list(); if (!list.isEmpty()) { @@ -595,10 +576,42 @@ } return allSubordinates; } - - - - + + + /** + * 获取门店作为服务商的所有用户 + * @param shopId + * @return + */ + public Set<Long> getShopServerUser(Integer shopId){ + Shop shop = shopClient.getShopById(shopId).getData(); + List<Shop> shopList = shopClient.getAllShop().getData(); + List<Long> appUserIds = shopList.stream().map(Shop::getAppUserId).collect(Collectors.toList()); + Long appUserId = shop.getAppUserId(); + //所有未开店的用户 + List<AppUser> list = appUserService.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0) + .ne(AppUser::getStatus, 3).notIn(AppUser::getId, appUserIds)); + Set<Long> ids = new HashSet<>(); + getShopServerUser(appUserId, list, ids); + return ids; + } + + + + public void getShopServerUser(Long appUserId, List<AppUser> appUserList, Set<Long> ids){ + List<AppUser> collect = appUserList.stream().filter(s->s.getInviteUserId().equals(appUserId)).collect(Collectors.toList()); + if(collect.size() == 0){ + return; + } + Set<Long> appUserSet = collect.stream().map(AppUser::getId).collect(Collectors.toSet()); + if(ids.containsAll(appUserSet)){ + return; + } + ids.addAll(appUserSet); + for (AppUser appUser : collect) { + getShopServerUser(appUser.getId(), appUserList, ids); + } + } @@ -704,6 +717,9 @@ Integer shopId = data.getObjectId(); List<Order> orders = orderClient.getRedeemedOrdersByShop(shopId).getData(); List<Long> userIds = orders.stream().map(Order::getAppUserId).collect(Collectors.toList()); + //门店作为服务商的用户 + Set<Long> shopServerUser = getShopServerUser(shopId); + userIds.addAll(shopServerUser); queryWrapper.in(!CollectionUtils.isEmpty(userIds), "id", userIds) .like(StringUtils.isNotEmpty( appUser.getName()),"name", appUser.getName()); } @@ -736,19 +752,20 @@ appUser.setExcludeStatus(3); IPage<AppUser> appuserPage = appUserService.getAppuserPage(pageNum, pageSize, appUser, shopId, userId); for (AppUser record : appuserPage.getRecords()) { + List<AppUserGiveawayTemporary> list = appUserGiveawayTemporaryService.list(new LambdaQueryWrapper<AppUserGiveawayTemporary>().eq(AppUserGiveawayTemporary::getAppUserId, record.getId())); + int sum = list.stream().mapToInt(AppUserGiveawayTemporary::getTotalPoint).sum(); if (record.getInviteUserId() != null) { AppUser byId1 = appUserService.getById(record.getInviteUserId()); if (byId1!=null) { record.setInviteUserName(byId1.getName()); } } - if (record.getShopId()!=null){ - R<Shop> shopById = shopClient.getShopById(record.getShopId()); - if (shopById.getData()!=null){ - record.setShopName(shopById.getData().getName()); - } + Shop shop1 = shopClient.getServiceProvider(record.getId()).getData(); + if(null != shop1){ + record.setShopName(shop1.getName()); + record.setShopId(shop1.getId()); } - record.setTotalPoint(record.getUserTotalPoint()); + record.setTotalPoint(record.getUserTotalPoint() + sum); } return R.ok(appuserPage); } @@ -807,8 +824,10 @@ for (Order datum : listR.getData()) { userIds.add(datum.getAppUserId()); } + Set<Long> shopServerUser = getShopServerUser(objectId); + userIds.addAll(shopServerUser); } - IPage<AppUser> appuserPage = appUserService.getAppuserPage1(pageCurr, pageSize, appUser, objectId, userIds); + IPage<AppUser> appuserPage = appUserService.getAppuserPage1(pageCurr, pageSize, appUser, userIds); return R.ok(appuserPage); } @@ -975,9 +994,10 @@ Long userid = tokenService.getLoginUser().getUserid(); SysUser sysUser = sysUserClient.getSysUser(userid).getData(); AppUser byId = appUserService.getById(id); - Shop shop1 = shopClient.getServiceProvider(id).getData(); + Shop shop1 = shopClient.getServiceProvider(byId.getId()).getData(); if(null != shop1){ byId.setShopName(shop1.getName()); + byId.setShopId(shop1.getId()); } R<List<Shop>> shopByUserId = shopClient.getShopByUserId(id); if (shopByUserId.getData() != null) { @@ -1147,6 +1167,11 @@ Integer shopId = data.getObjectId(); List<Order> orders = orderClient.getRedeemedOrdersByShop(shopId).getData(); List<Long> userIds = orders.stream().map(Order::getAppUserId).collect(Collectors.toList()); + Set<Long> shopServerUser = getShopServerUser(shopId); + userIds.addAll(shopServerUser); + if(userIds.size() == 0){ + userIds.add(-1L); + } queryWrapper.in(!CollectionUtils.isEmpty(userIds), "id", userIds); // userIds 不为空时,查询 id 在 userIds 中 } queryWrapper.eq("del_flag", 0); @@ -1190,8 +1215,8 @@ public R<UserStatisticsDetail> statisticsDetail(@ApiParam(value = "用户id") Long userId) { Long userid = tokenService.getLoginUser().getUserid(); SysUser data = sysUserClient.getSysUser(userid).getData(); - Integer shopId = null; - Set<Long> userIds = null; + Integer shopId = 0; + Set<Long> userIds = new HashSet<>(); if(null != userId){ userIds = new HashSet<>(); userIds.add(userId); @@ -1200,12 +1225,18 @@ shopId = data.getObjectId(); if(null == userId){ userIds = orderClient.getAppUserByShoppingShop(shopId).getData(); + Set<Long> shopServerUser = getShopServerUser(shopId); + userIds.addAll(shopServerUser); }else{ userIds = new HashSet<>(); userIds.add(userId); } + } - UserStatisticsDetail userStatisticsDetail = appUserMapper.getUserStatisticsDetail(shopId, userIds); + UserStatisticsDetail userStatisticsDetail = appUserMapper.getUserStatisticsDetail(null, userIds); + List<Order> orderList = orderClient.getOrderByAppUserIdsAndWriteOffShop(shopId, userIds).getData(); + BigDecimal shopAmount = orderList.stream().map(Order::getPaymentAmount).reduce(BigDecimal.ZERO, BigDecimal::add); + userStatisticsDetail.setShopAmount(shopAmount); return R.ok(userStatisticsDetail); } @@ -1233,7 +1264,7 @@ .eq(BalanceChangeRecord::getVipId, i); if(sysUser.getRoleType() == 2){ Integer objectId = sysUser.getObjectId(); - List<AppUser> list = appUserService.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getShopId, objectId).eq(AppUser::getDelFlag, 0).eq(AppUser::getStatus, 1)); + List<AppUser> list = appUserService.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getShopId, objectId).eq(AppUser::getDelFlag, 0).ne(AppUser::getStatus, 1)); List<Long> appUserIds = list.stream().map(AppUser::getId).collect(Collectors.toList()); Set<Long> data = orderClient.getAppUserByShoppingShop(objectId).getData(); if(null != data){ @@ -1245,6 +1276,35 @@ queryWrapper.in(BalanceChangeRecord::getAppUserId, appUserIds); } List<BalanceChangeRecord> list = balanceChangeRecordService.list(queryWrapper); + for (BalanceChangeRecord balanceChangeRecord : list) { + balanceChangeRecord.setChangeAmount(balanceChangeRecord.getChangeAmount().multiply(new BigDecimal(balanceChangeRecord.getChangeDirection()))); + } + + LambdaQueryWrapper<BalanceChangeRecordCopy> queryWrapper1 = new LambdaQueryWrapper<BalanceChangeRecordCopy>() + .between(BalanceChangeRecordCopy::getCreateTime, date, date.plusDays(1)) + .eq(BalanceChangeRecordCopy::getChangeType, 4) + .eq(BalanceChangeRecordCopy::getVipId, i); + if(sysUser.getRoleType() == 2){ + Integer objectId = sysUser.getObjectId(); + List<AppUser> list1 = appUserService.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getShopId, objectId).eq(AppUser::getDelFlag, 0).ne(AppUser::getStatus, 1)); + List<Long> appUserIds = list1.stream().map(AppUser::getId).collect(Collectors.toList()); + Set<Long> data = orderClient.getAppUserByShoppingShop(objectId).getData(); + if(null != data){ + appUserIds.addAll(data); + } + if(appUserIds.size() == 0){ + appUserIds.add(-1L); + } + queryWrapper1.in(BalanceChangeRecordCopy::getAppUserId, appUserIds); + } + List<BalanceChangeRecordCopy> list2 = balanceChangeRecordCopyService.list(queryWrapper1); + for (BalanceChangeRecordCopy balanceChangeRecordCopy : list2) { + BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord(); + BeanUtils.copyProperties(balanceChangeRecordCopy, balanceChangeRecord); + balanceChangeRecord.setChangeAmount(balanceChangeRecord.getChangeAmount().multiply(new BigDecimal(balanceChangeRecord.getChangeDirection()))); + list.add(balanceChangeRecord); + } + BigDecimal reduce = list.stream().map(BalanceChangeRecord::getChangeAmount).reduce(BigDecimal.ZERO, BigDecimal::add); String dateKey = date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); dailyVipCommissions.computeIfAbsent(dateKey, k -> new HashMap<>()) -- Gitblit v1.7.1