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/controller/AppUserController.java |   34 ++++++++++++++++++++--------------
 1 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java
index 2c7b14a..cdfeca1 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/AppUserController.java
@@ -57,8 +57,7 @@
 @RestController
 @RequestMapping("/app-user")
 public class AppUserController extends BaseController {
-
-
+    
     @Resource
     private TokenService tokenService;
     @Resource
@@ -92,6 +91,8 @@
     private UserCancellationLogService userCancellationLogService;
     @Resource
     private BalanceChangeRecordService balanceChangeRecordService;
+    @Resource
+    private UserChangeLogService userChangeLogService;
 
 
     @ResponseBody
@@ -569,19 +570,19 @@
         //检查是否达标,不达标继续标红
         VipSetting vipSetting = vipSettingClient.getVipSetting(appUser.getVipId()).getData();
         //消费积分
-        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);
         }
         //返佣积分
-        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);
         }
         //门店业绩
-        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);
@@ -652,8 +653,7 @@
 
     @GetMapping("/detail")
     @ApiOperation(value = "用户列表-详情", tags = {"管理后台"})
-    public R<AppUser> detail(Long id) {
-
+    public R<AppUser> detail(Long id, Integer shopId) {
         Long userid = tokenService.getLoginUser().getUserid();
         SysUser sysUser = sysUserClient.getSysUser(userid).getData();
         AppUser byId = appUserService.getById(id);
@@ -686,7 +686,13 @@
         List<AppUser> list = appUserService.lambdaQuery().eq(AppUser::getInviteUserId, id).list();
         byId.setBottomUsers(list);
         //消费总金额
-        R<List<Order>> orderR = remoteOrderGoodsClient.byShopIdAndUserId(id,byId.getShopId());
+        if(null == shopId || 1 == sysUser.getRoleType()){
+            shopId = -1;
+        }
+        if(null == shopId && 2 == sysUser.getRoleType()){
+            shopId = sysUser.getObjectId();
+        }
+        R<List<Order>> orderR = remoteOrderGoodsClient.byUserId(id, shopId);
         List<Order> orderList = orderR.getData();
         if (!CollectionUtils.isEmpty(orderList)){
             BigDecimal paymentAmount = orderList.stream().map(Order::getPaymentAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
@@ -697,8 +703,7 @@
         return R.ok(byId);
     }
 
-    @Resource
-    private UserChangeLogService userChangeLogService;
+    
 
     @GetMapping("/change/vip")
     @ApiOperation(value = "用户列表-修改会员等级", tags = {"管理后台"})
@@ -736,7 +741,10 @@
     public R<List<Order>> orders(Long id) {
         Long userid = tokenService.getLoginUser().getUserid();
         SysUser sysUser = sysUserClient.getSysUser(userid).getData();
-        Integer shopId = sysUser.getObjectId();
+        Integer shopId = -1;
+        if(sysUser.getRoleType() == 2){
+            shopId = sysUser.getObjectId();
+        }
         R<List<Order>> listR = remoteOrderGoodsClient.byUserId(id,shopId);
         return R.ok(listR.getData());
 
@@ -831,8 +839,6 @@
         if (cd.getStartTime().isAfter(cd.getEndTime())) {
             return R.fail("开始时间不能大于结束时间");
         }
-
-
         Map<String, Map<Integer, BigDecimal>> dailyVipCommissions = new TreeMap<>();
         getDatesBetween(cd.getStartTime(), cd.getEndTime()).forEach(date -> {
             for (int i = 1; i < 8; i++){
@@ -1001,7 +1007,7 @@
      * 检查会员降级
      * @param appUserId
      */
-    @PostMapping("/app-user/vipDemotion")
+    @PostMapping("/vipDemotion")
     public void vipDemotion(@RequestParam("appUserId") Long appUserId){
         appUserService.vipDemotion(appUserId);
     }

--
Gitblit v1.7.1