From c9c63baa6aca084be7a9302f240c080c9ab1454b Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期五, 24 一月 2025 16:46:50 +0800 Subject: [PATCH] 修改bug --- ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java | 44 +++++++++++++++++++++++++++++++------------- 1 files changed, 31 insertions(+), 13 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 9c336ce..2561d96 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 @@ -25,6 +25,7 @@ import com.ruoyi.common.redis.annotation.DistributedLock; import com.ruoyi.common.redis.service.RedisService; import com.ruoyi.common.security.service.TokenService; +import com.ruoyi.order.feignClient.OrderClient; import com.ruoyi.other.api.domain.*; import com.ruoyi.other.api.feignClient.*; import com.ruoyi.system.api.domain.SysUser; @@ -111,6 +112,9 @@ private RedisTemplate redisTemplate; @Resource private BalancePaymentService balancePaymentService; + + @Resource + private OrderClient orderClient; /** @@ -673,7 +677,7 @@ return; } } - if(appUser.getVipId() > 2){ + if(appUser.getVipId() >= 2){ appUser.setVipId(1); this.updateById(appUser); //添加等级变化记录 @@ -865,7 +869,6 @@ @Override public void unbindThePromoter() { //注册X天后没有升级成黄金会员则自动解绑推广人 - //解绑推广人 Set<Long> unbind_promoter = redisTemplate.opsForZSet().rangeByScore("unbind_promoter", 0, LocalDateTime.now().toEpochSecond(ZoneOffset.UTC)); if(unbind_promoter.size() > 0){ @@ -876,16 +879,21 @@ updateWrapper.set("invite_user_id", null).set("shop_id", null).eq("id", appUser.getId()); this.update(updateWrapper); } + redisTemplate.opsForZSet().remove("unbind_promoter", unbind_promoter.toArray()); } //可更换推广人 Set<Long> replaceable = redisTemplate.opsForZSet().rangeByScore("replaceable", 0, LocalDateTime.now().toEpochSecond(ZoneOffset.UTC)); if(replaceable.size() > 0){ List<AppUser> list = this.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getDelFlag, 0).eq(AppUser::getChangePromoter, 0) - .eq(AppUser::getStatus, 1).in(AppUser::getId, unbind_promoter)); + .eq(AppUser::getStatus, 1).in(AppUser::getId, replaceable)); for (AppUser appUser : list) { - appUser.setChangePromoter(1); - this.updateById(appUser); + Long data = orderClient.getOrderCountByAppUserId(appUser.getId()).getData(); + if(data == 0){ + appUser.setChangePromoter(1); + this.updateById(appUser); + } } + redisTemplate.opsForZSet().remove("replaceable", replaceable.toArray()); } } @@ -898,13 +906,20 @@ Long userid = tokenService.getLoginUserApplet().getUserid(); Object cacheObject = redisService.getCacheObject("ONLINE_" + userid); if(null == cacheObject){ - redisService.setCacheObject("ONLINE_" + userid, System.currentTimeMillis(), 1L, TimeUnit.HOURS); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("time", System.currentTimeMillis()); + jsonObject.put("online", 0); + redisService.setCacheObject("ONLINE_" + userid, jsonObject, 1L, TimeUnit.HOURS); }else{ - Long duration = (Long) cacheObject; - long time = (System.currentTimeMillis() - duration) / 3600000; + JSONObject jsonObject = (JSONObject) cacheObject; + long time = System.currentTimeMillis() - jsonObject.getInteger("time"); + Integer online = jsonObject.getInteger("online"); + online += 10; //满足一个小时,开始发放积分,计时归0 - if(1 >= time){ - redisService.setCacheObject("ONLINE_" + userid, System.currentTimeMillis(), 1L, TimeUnit.HOURS); + if(time >= 3600000L && 60 <= online){ + jsonObject.put("time", System.currentTimeMillis()); + jsonObject.put("online", 0); + redisService.setCacheObject("ONLINE_" + userid, jsonObject, 1L, TimeUnit.HOURS); AppUser appUser = this.getById(userid); PointSetting pointSetting = pointSettingClient.getPointSetting(appUser.getVipId()).getData(); if(null != pointSetting){ @@ -937,6 +952,9 @@ //变更等级 vipUpgrade(appUser.getId()); } + }else{ + jsonObject.put("online", online); + redisService.setCacheObject("ONLINE_" + userid, jsonObject, 1L, TimeUnit.HOURS); } } } @@ -972,7 +990,7 @@ List<AppUser> list = this.list(new LambdaQueryWrapper<AppUser>().eq(AppUser::getVipId, i).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")); + 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); @@ -980,7 +998,7 @@ 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")); + 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); @@ -988,7 +1006,7 @@ 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")); + 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); -- Gitblit v1.7.1