From 15953749b8a560df36395e7721302fed2b987ab0 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期五, 17 一月 2025 19:03:38 +0800
Subject: [PATCH] 修改bug

---
 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/AppUserServiceImpl.java |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 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..e58f5d1 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
@@ -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