luodangjia
2025-01-24 047e974de3509cbfa8a8f6558c970d3b2492972c
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java
@@ -282,6 +282,12 @@
      if(null != appUser1 && appUser1.getStatus() == 2){
         return R.fail("手机号已注册,请直接登录!");
      }
      String avatar = registerAccount.getAvatar();
      if (StringUtils.isEmpty(avatar)){
         avatar = "http://qijishenghuiyuan.obs.cn-southwest-2.myhuaweicloud.com/admin/aedfbbb41280471f8d9fa7905298b65f.png";
      }
      //如果手机号已注册,但是没有微信号,则将微信号添加到已有账户上
      if(null != appUser1 && StringUtils.isEmpty(appUser1.getWxOpenid())){
         appUser1.setWxOpenid(openid);
@@ -289,7 +295,7 @@
         appUser = appUser1;
      }else if(null == appUser){
         appUser = new AppUser();
         appUser.setAvatar(registerAccount.getAvatar());
         appUser.setAvatar(avatar);
         appUser.setName(registerAccount.getName());
         appUser.setPhone(registerAccount.getPhone());
         appUser.setWxOpenid(openid);
@@ -673,7 +679,7 @@
            return;
         }
      }
      if(appUser.getVipId() > 2){
      if(appUser.getVipId() >= 2){
         appUser.setVipId(1);
         this.updateById(appUser);
         //添加等级变化记录
@@ -881,7 +887,7 @@
      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);
@@ -898,13 +904,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 +950,9 @@
               //变更等级
               vipUpgrade(appUser.getId());
            }
         }else{
            jsonObject.put("online", online);
            redisService.setCacheObject("ONLINE_" + userid, jsonObject, 1L, TimeUnit.HOURS);
         }
      }
   }
@@ -972,7 +988,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 +996,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 +1004,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);