From 4f97bdbaadcdc19df9dfb0971b930d799c4aeddc Mon Sep 17 00:00:00 2001 From: luofl <1442745593@qq.com> Date: 星期四, 13 三月 2025 14:52:26 +0800 Subject: [PATCH] 迭代版本:2.28 --- ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java | 151 +++++++++++++++++++++++++++++++++++++------------- 1 files changed, 112 insertions(+), 39 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 7f61832..0ef6e50 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 @@ -1,6 +1,7 @@ package com.ruoyi.account.controller; +import cn.hutool.core.collection.CollectionUtil; import com.alibaba.fastjson2.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; @@ -31,7 +32,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; @@ -73,8 +73,6 @@ @Resource private AppUserService appUserService; @Resource - private StoreClient storeClient; - @Resource private UserCouponService userCouponService; @Resource @@ -83,8 +81,6 @@ private VipSettingClient vipSettingClient; @Resource private UserPointService userPointService; - @Resource - private VipSettingService vipSettingService; @Resource private AppUserMapper appUserMapper; @Resource @@ -108,6 +104,9 @@ @Resource private WeChatUtil weChatUtil; + + @Resource + private IAppUserGiveawayTemporaryService appUserGiveawayTemporaryService; @Value("${file.upload.location}") private String filePath; @@ -276,19 +275,57 @@ Long userId = tokenService.getLoginUserApplet().getUserid(); //获取绑定门店 AppUser user = appUserService.getById(userId); - if (user.getShopId() != null) { - R<Shop> storeById = storeClient.getStoreById(user.getShopId()); - if (storeById.getData() != null) { - user.setShopName(storeById.getData().getName()); - user.setShopCover(storeById.getData().getHomePicture()); - user.setShopAddress(storeById.getData().getAddress()); + + + //当前用户的推荐人信息(指导老师) + List<AppUser> allSuperiors = getAllSuperiors(userId); + //当前绑定门店的店铺信息 + for (AppUser allSuperior : allSuperiors) { + List<Shop> shopList = shopClient.getShopByUserId(allSuperior.getId()).getData(); + if (!CollectionUtils.isEmpty(shopList)){ + user.setShopName(shopList.get(0).getName()); + user.setShopCover(shopList.get(0).getHomePicture()); + user.setShopAddress(shopList.get(0).getAddress()); + break; } } + + if (user.getShopName() == null){ + user.setShopName(""); + } + if (user.getShopCover() == null){ + user.setShopCover(""); + } + if (user.getShopAddress() == null){ + user.setShopAddress(""); + } + + //指导老师 + allSuperiors.stream() + .filter(superiors -> superiors.getVipId() != null && superiors.getVipId() > 3) + .findFirst() + .ifPresent(superiors -> { + user.setTeacher(superiors.getName()); + user.setTeacherPhone(superiors.getPhone()); + }); + + if (user.getTeacher() == null){ + user.setTeacher(""); + } + if (user.getTeacherPhone() == null){ + user.setTeacherPhone(""); + } + + + //获取绑定上级 if (user.getInviteUserId() != null) { AppUser byId = appUserService.getById(user.getInviteUserId()); user.setTopUser(byId); + }else { + AppUser topUser = new AppUser(); + user.setTopUser(topUser); } //获取绑定下级列表 List<AppUser> list = appUserService.lambdaQuery() @@ -456,19 +493,21 @@ appUserService.updateById(user); } - //当前用户的推荐人信息 - if (user.getInviteUserId() != null) { - AppUser inviteUser = appUserService.getById(user.getInviteUserId()); - user.setInviteUserName(inviteUser.getName()); + //指导老师 + List<AppUser> allSuperiors = getAllSuperiors(userId); + allSuperiors.stream() + .filter(superiors -> superiors.getVipId() != null && superiors.getVipId() > 3) + .findFirst() + .ifPresent(superiors -> { + user.setTeacher(superiors.getName()); + }); + + Shop shop1 = shopClient.getServiceProvider(userId).getData(); + if(null != shop1){ + user.setShopName(shop1.getName()); + user.setShopId(shop1.getId()); } - //当前绑定门店的店铺信息 - if (user.getShopId() != null) { - R<Shop> storeById = shopClient.getShopById(user.getShopId()); - if (storeById.getData() != null) { - Shop shop = storeById.getData(); - user.setShopName(shop.getName()); - } - } + ArrayList<Long> userIds = new ArrayList<>(); userIds.add(userId); // 获取当前用户的所有下级 @@ -515,8 +554,32 @@ } 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); } + + + public List<AppUser> getAllSuperiors(Long userId) { + List<AppUser> allSuperiors = new ArrayList<>(); + + // 获取当前用户的直接上级 + AppUser currentUser = appUserService.getById(userId); + if (currentUser != null && currentUser.getInviteUserId() != null) { + AppUser superior = appUserService.getById(currentUser.getInviteUserId()); + if (superior != null) { + allSuperiors.add(superior); // 添加直接上级 + allSuperiors.addAll(getAllSuperiors(superior.getId())); // 递归添加上级的上级 + } + } + + return allSuperiors; + } + + // 递归获取指定用户的所有下级 public List<AppUser> getAllSubordinates(Long userId) { @@ -765,17 +828,17 @@ } private void loginout(Long userId) { + // 获取所有符合模式的缓存键 Collection<String> keys = redisService.keys(CacheConstants.LOGIN_TOKEN_KEY + "*"); - if (!CollectionUtils.isEmpty(keys)) { - for (String key : keys) { - LoginUser user = redisService.getCacheObject(key); - if (user == null || user.getUserid() == null) { - continue; - } - if (user.getUserid().equals(userId)) { - redisService.deleteObject(key); - break; - } + if (CollectionUtils.isEmpty(keys)) { + return; // 如果没有匹配的键,直接返回 + } + + // 遍历所有键并删除与指定用户ID相关的登录信息 + for (String key : keys) { + LoginUser user = redisService.getCacheObject(key); + if (user != null && userId.equals(user.getUserid())) { + redisService.deleteObject(key); } } } @@ -845,11 +908,9 @@ Long userid = tokenService.getLoginUser().getUserid(); SysUser sysUser = sysUserClient.getSysUser(userid).getData(); AppUser byId = appUserService.getById(id); - if (byId.getShopId() != null) { - R<Shop> shopById = shopClient.getShopById(Integer.parseInt(String.valueOf(byId.getShopId()))); - if (shopById.getData() != null) { - byId.setShopName(shopById.getData().getName()); - } + Shop shop1 = shopClient.getServiceProvider(id).getData(); + if(null != shop1){ + byId.setShopName(shop1.getName()); } R<List<Shop>> shopByUserId = shopClient.getShopByUserId(id); if (shopByUserId.getData() != null) { @@ -1020,6 +1081,13 @@ userId = orderClient.getAppUserByShoppingShop(shopId).getData(); } 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); + } return R.ok(userStatistics); } @@ -1247,7 +1315,11 @@ public void vipUpgrade(@RequestParam("appUserId") Long appUserId){ appUserService.vipUpgrade(appUserId); } - + + @PostMapping("/vipConsumption") + public void vipConsumption(@RequestParam("appUserId") Long appUserId){ + appUserService.vipConsumption(appUserId); + } /** * 检查会员降级 @@ -1280,5 +1352,6 @@ .set(AppUser::getUserType,1)); return R.ok(); } + } -- Gitblit v1.7.1