From b9f26b3f2ea4ebc3344868b2ab2bcc399df0bde5 Mon Sep 17 00:00:00 2001
From: luodangjia <luodangjia>
Date: 星期五, 24 一月 2025 16:15:29 +0800
Subject: [PATCH] 12.18

---
 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java |   30 ++++++++++++++++++++----------
 1 files changed, 20 insertions(+), 10 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..57e7593 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
@@ -673,7 +673,7 @@
 				return;
 			}
 		}
-		if(appUser.getVipId() > 2){
+		if(appUser.getVipId() >= 2){
 			appUser.setVipId(1);
 			this.updateById(appUser);
 			//添加等级变化记录
@@ -881,7 +881,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 +898,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 +944,9 @@
 					//变更等级
 					vipUpgrade(appUser.getId());
 				}
+			}else{
+				jsonObject.put("online", online);
+				redisService.setCacheObject("ONLINE_" + userid, jsonObject, 1L, TimeUnit.HOURS);
 			}
 		}
 	}
@@ -972,7 +982,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 +990,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 +998,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