From c542c56572ea8936301a6bdc736e23b846c8c006 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期六, 04 一月 2025 18:01:58 +0800 Subject: [PATCH] 修改保级功能bug --- ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java | 231 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 195 insertions(+), 36 deletions(-) diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java index 7920fbb..9d47a7a 100644 --- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java +++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java @@ -330,6 +330,7 @@ } appUser.setLavePoint(regisPoint); appUser.setAvailablePoint(regisPoint1); + appUser.setTotalAvailablePoint(regisPoint1); if(null != pointSetting && 1 == pointSetting.getGetRegisPointGift()){ appUser.setTransferablePoint(regisPoint1); } @@ -365,9 +366,10 @@ userPoint.setCreateTime(LocalDateTime.now()); userPoint.setAppUserId(appUser.getId()); userPointService.save(userPoint); - //变更等级 - vipUpgrade(appUser.getId()); } + //变更等级 + vipUpgrade(appUser.getId()); + //拉新分佣 if(0 == old && null != appUser2){ pointSetting = pointSettingClient.getPointSetting(appUser2.getVipId()).getData(); @@ -378,6 +380,7 @@ } appUser2.setLavePoint(appUser2.getLavePoint() + newPoint); appUser2.setAvailablePoint(appUser2.getAvailablePoint() + newPoint1); + appUser2.setTotalAvailablePoint(appUser2.getTotalAvailablePoint() + newPoint1); if(null != pointSetting && 1 == pointSetting.getGetNewPointGift()){ appUser2.setTransferablePoint(appUser2.getTransferablePoint() + newPoint1); } @@ -393,14 +396,15 @@ userPoint.setCreateTime(LocalDateTime.now()); userPoint.setAppUserId(appUser2.getId()); userPointService.save(userPoint); - //变更等级 - vipUpgrade(appUser2.getId()); } + //变更等级 + vipUpgrade(appUser2.getId()); if(null != appUser2.getInviteUserId()){ AppUser appUser3 = this.getById(appUser2.getInviteUserId()); appUser3.setLavePoint(appUser3.getLavePoint() + newPoint); appUser3.setAvailablePoint(appUser3.getAvailablePoint() + newPoint1); + appUser3.setTotalAvailablePoint(appUser3.getTotalAvailablePoint() + newPoint1); if(null != pointSetting && 1 == pointSetting.getGetRegisPointGift()){ appUser3.setTransferablePoint(appUser3.getTransferablePoint() + newPoint1); } @@ -416,9 +420,9 @@ userPoint.setCreateTime(LocalDateTime.now()); userPoint.setAppUserId(appUser3.getId()); userPointService.save(userPoint); - //变更等级 - vipUpgrade(appUser3.getId()); } + //变更等级 + vipUpgrade(appUser3.getId()); } } @@ -427,32 +431,6 @@ weChatUtil.getwxacodeunlimit("pages/login/login", "id=" + appUser.getId(), EnvVersion.TRIAL, filePath + fileName); appUser.setQrCode(accessPath + fileName); this.updateById(appUser); - - //查询当前注册的手机号是都和门店管理员手机号相同 - Shop shop = shopClient.getShopByPhone(registerAccount.getPhone()).getData(); - if(null != shop){ - //添加门店用户关系数据 - AppUserShop appUserShop = appUserShopService.getOne(new LambdaQueryWrapper<AppUserShop>().eq(AppUserShop::getAppUserId, appUser.getId()).eq(AppUserShop::getShopId, shop.getId())); - if(null == appUserShop){ - appUserShop = new AppUserShop(); - appUserShop.setShopId(shop.getId()); - appUserShop.setAppUserId(appUser.getId()); - appUserShopService.save(appUserShop); - //添加管理后台账号 - SysUser user = new SysUser(); - user.setDeptId(1L); - user.setUserName(appUser.getName()); - user.setNickName(appUser.getName()); - user.setPhonenumber(appUser.getPhone()); - user.setAvatar(appUser.getAvatar()); - user.setStatus("0"); - user.setDelFlag("0"); - user.setRoleType(2); - user.setObjectId(shop.getId()); - user.setAppUserId(appUser.getId()); - sysUserClient.saveShopUser(user); - } - } } LoginVo loginVo = new LoginVo(); loginVo.setSkipPage(1); @@ -478,6 +456,37 @@ Integer vipId = appUser.getVipId(); //钻石会员 VipSetting vipSetting3 = vipSettingClient.getVipSetting(3).getData(); + //消费积分满足升级 + if(1 == vipSetting3.getVipLevelUpShopRole() && appUser.getShopPoint() >= vipSetting3.getVipLevelUpShop() && appUser.getVipId() < 3){ + appUser.setVipId(3); + this.updateById(appUser); + //添加等级变化记录 + UserChangeLog userChangeLog = new UserChangeLog(); + userChangeLog.setDelFlag(0); + userChangeLog.setCreateTime(LocalDateTime.now()); + userChangeLog.setAppUserId(appUser.getId()); + userChangeLog.setBeforeVipId(vipId); + userChangeLog.setAfterVipId(appUser.getVipId()); + userChangeLog.setChangeType(1); + userChangeLogService.save(userChangeLog); + return; + } + //返佣积分满足升级 + if(1 == vipSetting3.getVipLevelUpShareRole() && appUser.getSharePoint() >= vipSetting3.getVipLevelUpShare() && appUser.getVipId() < 3){ + appUser.setVipId(3); + this.updateById(appUser); + //添加等级变化记录 + UserChangeLog userChangeLog = new UserChangeLog(); + userChangeLog.setDelFlag(0); + userChangeLog.setCreateTime(LocalDateTime.now()); + userChangeLog.setAppUserId(appUser.getId()); + userChangeLog.setBeforeVipId(vipId); + userChangeLog.setAfterVipId(appUser.getVipId()); + userChangeLog.setChangeType(1); + userChangeLogService.save(userChangeLog); + return; + } + //下级人数满足升级 Integer vipLevelUpNumRole = vipSetting3.getVipLevelUpNumRole(); Integer vipDirectNum = vipSetting3.getVipDirectNum(); Integer vipTeamNum = vipSetting3.getVipTeamNum(); @@ -502,8 +511,40 @@ return; } } + //黄金会员 VipSetting vipSetting2 = vipSettingClient.getVipSetting(2).getData(); + //消费积分满足升级 + if(1 == vipSetting2.getVipLevelUpShopRole() && appUser.getShopPoint() >= vipSetting2.getVipLevelUpShop() && appUser.getVipId() < 2){ + appUser.setVipId(2); + this.updateById(appUser); + //添加等级变化记录 + UserChangeLog userChangeLog = new UserChangeLog(); + userChangeLog.setDelFlag(0); + userChangeLog.setCreateTime(LocalDateTime.now()); + userChangeLog.setAppUserId(appUser.getId()); + userChangeLog.setBeforeVipId(vipId); + userChangeLog.setAfterVipId(appUser.getVipId()); + userChangeLog.setChangeType(1); + userChangeLogService.save(userChangeLog); + return; + } + //返佣积分满足升级 + if(1 == vipSetting2.getVipLevelUpShareRole() && appUser.getSharePoint() >= vipSetting2.getVipLevelUpShare() && appUser.getVipId() < 2){ + appUser.setVipId(2); + this.updateById(appUser); + //添加等级变化记录 + UserChangeLog userChangeLog = new UserChangeLog(); + userChangeLog.setDelFlag(0); + userChangeLog.setCreateTime(LocalDateTime.now()); + userChangeLog.setAppUserId(appUser.getId()); + userChangeLog.setBeforeVipId(vipId); + userChangeLog.setAfterVipId(appUser.getVipId()); + userChangeLog.setChangeType(1); + userChangeLogService.save(userChangeLog); + return; + } + //下级人数满足升级 vipLevelUpNumRole = vipSetting2.getVipLevelUpNumRole(); vipDirectNum = vipSetting2.getVipDirectNum(); vipTeamNum = vipSetting2.getVipTeamNum(); @@ -525,6 +566,7 @@ userChangeLog.setAfterVipId(appUser.getVipId()); userChangeLog.setChangeType(1); userChangeLogService.save(userChangeLog); + return; } } } @@ -575,8 +617,18 @@ if(collect.size() == 0){ return result; }else{ - result.addAll(collect); - List<Long> collect1 = collect.stream().map(AppUser::getId).collect(Collectors.toList()); + List<Long> collect2 = result.stream().map(AppUser::getId).collect(Collectors.toList()); + List<AppUser> list1 = new ArrayList<>(); + for (AppUser appUser : collect) { + if(!collect2.contains(appUser.getId())){ + list1.add(appUser); + } + } + if(list1.size() == 0){ + return result; + } + result.addAll(list1); + List<Long> collect1 = list1.stream().map(AppUser::getId).collect(Collectors.toList()); idss.addAll(collect1); } } @@ -662,7 +714,7 @@ Integer vipCancelDay = vipSetting.getVipCancelDay(); Integer vipChangeDay = vipSetting.getVipChangeDay(); List<AppUser> list = this.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getVipId, 1).eq(AppUser::getDelFlag, 0).isNotNull(AppUser::getInviteUserId) - .eq(AppUser::getStatus, 1).last(" and (UNIX_TIMESTAMP(create_time) + " + vipCancelDay + ") <= UNIX_TIMESTAMP()")); + .eq(AppUser::getStatus, 1).last(" and ADDDATE(create_time,INTERVAL " + vipCancelDay + " DAY) <= now()")); for (AppUser appUser : list) { appUser.setInviteUserId(null); appUser.setShopId(null); @@ -671,7 +723,7 @@ //可更换推广人 list = this.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getVipId, 1).eq(AppUser::getDelFlag, 0).eq(AppUser::getChangePromoter, 0) - .isNull(AppUser::getLastShopTime).eq(AppUser::getStatus, 1).last(" and (UNIX_TIMESTAMP(create_time) + " + vipCancelDay + ") <= UNIX_TIMESTAMP()")); + .isNull(AppUser::getLastShopTime).eq(AppUser::getStatus, 1).last(" and ADDDATE(create_time,INTERVAL " + vipChangeDay + " DAY) <= now()")); for (AppUser appUser : list) { appUser.setChangePromoter(1); this.updateById(appUser); @@ -706,6 +758,7 @@ appUser.setTotalPoint(appUser.getTotalPoint() + hourPoint); appUser.setLavePoint(appUser.getLavePoint() + hourPoint); appUser.setAvailablePoint(appUser.getAvailablePoint() + hourPoint1); + appUser.setTotalAvailablePoint(appUser.getTotalAvailablePoint() + hourPoint1); if(null != pointSetting && 1 == pointSetting.getWorkPointGift()){ appUser.setTransferablePoint(appUser.getTransferablePoint() + hourPoint1); } @@ -747,4 +800,110 @@ return appUserMapper.getAppuserPage1(new Page<>(pageNum, pageSize), appUser,objectId,userIds); } + + + /** + * 降级检测 + */ + @Override + public void demotionDetection() { + //代理 + List<AppUser> appUserList = new ArrayList<>(); + VipSetting vipSetting = vipSettingClient.getVipSetting(5).getData(); + List<AppUser> list = this.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getVipId, 5).eq(AppUser::getStatus, 1).eq(AppUser::getDelFlag, 0).eq(AppUser::getIsDanger, 0)); + for (AppUser appUser : list) { + //消费积分 + List<UserPoint> list1 = userPointService.list(new LambdaQueryWrapper<UserPoint>().eq(UserPoint::getAppUserId, appUser.getId()).eq(UserPoint::getType, 1).last(" and SUBDATE(now(), INTERVAL " + vipSetting.getKeepBuyDay() + " DAY) >= create_time")); + int sum = list1.stream().mapToInt(UserPoint::getVariablePoint).sum(); + if(sum < vipSetting.getKeepBuyPoint()){ + appUser.setIsDanger(1); + appUserList.add(appUser); + continue; + } + //返佣积分 + list1 = userPointService.list(new LambdaQueryWrapper<UserPoint>().eq(UserPoint::getAppUserId, appUser.getId()).eq(UserPoint::getType, 2).last(" and SUBDATE(now(), INTERVAL " + vipSetting.getKeepShareDay() + " DAY) >= create_time")); + sum = list1.stream().mapToInt(UserPoint::getVariablePoint).sum(); + if(sum < vipSetting.getKeepSharePoint()){ + appUser.setIsDanger(1); + appUserList.add(appUser); + continue; + } + //门店业绩 + list1 = userPointService.list(new LambdaQueryWrapper<UserPoint>().eq(UserPoint::getAppUserId, appUser.getId()).eq(UserPoint::getType, 8).last(" and SUBDATE(now(), INTERVAL " + vipSetting.getKeepShopDay() + " DAY) >= create_time")); + sum = list1.stream().mapToInt(UserPoint::getVariablePoint).sum(); + if(sum < vipSetting.getKeepShopPoint()){ + appUser.setIsDanger(1); + appUserList.add(appUser); + } + } + if(appUserList.size() > 0){ + this.updateBatchById(appUserList); + } + + //总代 + appUserList = new ArrayList<>(); + vipSetting = vipSettingClient.getVipSetting(6).getData(); + list = this.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getVipId, 6).eq(AppUser::getStatus, 1).eq(AppUser::getDelFlag, 0).eq(AppUser::getIsDanger, 0)); + for (AppUser appUser : list) { + //消费积分 + List<UserPoint> list1 = userPointService.list(new LambdaQueryWrapper<UserPoint>().eq(UserPoint::getAppUserId, appUser.getId()).eq(UserPoint::getType, 1).last(" and SUBDATE(now(), INTERVAL " + vipSetting.getKeepBuyDay() + " DAY) >= create_time")); + int sum = list1.stream().mapToInt(UserPoint::getVariablePoint).sum(); + if(sum < vipSetting.getKeepBuyPoint()){ + appUser.setIsDanger(1); + appUserList.add(appUser); + continue; + } + //返佣积分 + list1 = userPointService.list(new LambdaQueryWrapper<UserPoint>().eq(UserPoint::getAppUserId, appUser.getId()).eq(UserPoint::getType, 2).last(" and SUBDATE(now(), INTERVAL " + vipSetting.getKeepShareDay() + " DAY) >= create_time")); + sum = list1.stream().mapToInt(UserPoint::getVariablePoint).sum(); + if(sum < vipSetting.getKeepSharePoint()){ + appUser.setIsDanger(1); + appUserList.add(appUser); + continue; + } + //门店业绩 + list1 = userPointService.list(new LambdaQueryWrapper<UserPoint>().eq(UserPoint::getAppUserId, appUser.getId()).eq(UserPoint::getType, 8).last(" and SUBDATE(now(), INTERVAL " + vipSetting.getKeepShopDay() + " DAY) >= create_time")); + sum = list1.stream().mapToInt(UserPoint::getVariablePoint).sum(); + if(sum < vipSetting.getKeepShopPoint()){ + appUser.setIsDanger(1); + appUserList.add(appUser); + } + } + if(appUserList.size() > 0){ + this.updateBatchById(appUserList); + } + + //合伙人 + appUserList = new ArrayList<>(); + vipSetting = vipSettingClient.getVipSetting(7).getData(); + list = this.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getVipId, 7).eq(AppUser::getStatus, 1).eq(AppUser::getDelFlag, 0).eq(AppUser::getIsDanger, 0)); + for (AppUser appUser : list) { + //消费积分 + List<UserPoint> list1 = userPointService.list(new LambdaQueryWrapper<UserPoint>().eq(UserPoint::getAppUserId, appUser.getId()).eq(UserPoint::getType, 1).last(" and SUBDATE(now(), INTERVAL " + vipSetting.getKeepBuyDay() + " DAY) >= create_time")); + int sum = list1.stream().mapToInt(UserPoint::getVariablePoint).sum(); + if(sum < vipSetting.getKeepBuyPoint()){ + appUser.setIsDanger(1); + appUserList.add(appUser); + continue; + } + //返佣积分 + list1 = userPointService.list(new LambdaQueryWrapper<UserPoint>().eq(UserPoint::getAppUserId, appUser.getId()).eq(UserPoint::getType, 2).last(" and SUBDATE(now(), INTERVAL " + vipSetting.getKeepShareDay() + " DAY) >= create_time")); + sum = list1.stream().mapToInt(UserPoint::getVariablePoint).sum(); + if(sum < vipSetting.getKeepSharePoint()){ + appUser.setIsDanger(1); + appUserList.add(appUser); + continue; + } + //门店业绩 + list1 = userPointService.list(new LambdaQueryWrapper<UserPoint>().eq(UserPoint::getAppUserId, appUser.getId()).eq(UserPoint::getType, 8).last(" and SUBDATE(now(), INTERVAL " + vipSetting.getKeepShopDay() + " DAY) >= create_time")); + sum = list1.stream().mapToInt(UserPoint::getVariablePoint).sum(); + if(sum < vipSetting.getKeepShopPoint()){ + appUser.setIsDanger(1); + appUserList.add(appUser); + } + } + if(appUserList.size() > 0){ + this.updateBatchById(appUserList); + } + } } -- Gitblit v1.7.1