From 2474cec7f04390c196c0f7c753d4b70f1d53fcac Mon Sep 17 00:00:00 2001
From: huliguo <2023611923@qq.com>
Date: 星期五, 06 六月 2025 18:43:29 +0800
Subject: [PATCH] 修改bug

---
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java |   67 ++++++++++++++++++++++++++-------
 1 files changed, 52 insertions(+), 15 deletions(-)

diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java
index f68ed57..c08a457 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/OrderController.java
@@ -36,6 +36,7 @@
 import com.ruoyi.system.api.feignClient.SysUserClient;
 import com.ruoyi.system.api.model.LoginUser;
 import io.swagger.annotations.*;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.util.CollectionUtils;
 import org.springframework.web.bind.annotation.*;
 
@@ -161,14 +162,11 @@
      * 扫码校验
      */
     @ApiOperation(value = "扫码校验", tags = {"小程序-个人中心-门店管理"})
-    @ApiImplicitParams({
-            @ApiImplicitParam(value = "分享id", name = "shareId", required = true, dataType = "int", paramType = "query"),
-    })
     @GetMapping("/check/{orderNumber}/{shopId}")
     public R<Boolean> check(@PathVariable("orderNumber") String orderNumber, @PathVariable("shopId") Integer shopId) {
         LoginUser loginUserApplet = tokenService.getLoginUserApplet();
         Order order = orderService.getOne(new LambdaQueryWrapper<Order>()
-                .eq(Order::getOrderNumber, orderNumber));
+                .eq(Order::getId, orderNumber));
         return R.ok(orderService.check(order, shopId, loginUserApplet.getUserid()));
     }
 
@@ -176,12 +174,9 @@
      * 订单核销
      */
     @ApiOperation(value = "订单核销", tags = {"小程序-个人中心-门店管理"})
-    @ApiImplicitParams({
-            @ApiImplicitParam(value = "订单id", name = "id", required = true, dataType = "String"),
-    })
     @GetMapping("/writeOff")
-    public R<Void> writeOff(String code, Integer shopId) {
-        orderService.writeOff(code, shopId);
+    public R<Void> writeOff(@ApiParam("id") String id, @ApiParam("shopId") Integer shopId) {
+        orderService.writeOff(id, shopId);
         return R.ok();
     }
 
@@ -583,7 +578,26 @@
             orderPage.setAppUserIds(orderPage.getAppUserIds().stream().distinct().collect(Collectors.toList()));
         }
 
-
+        //搜索条件 店铺名称
+        if (StringUtils.isNotEmpty(orderPage.getShopName())){
+            List<Integer> shopSet = new ArrayList<>(shopClient.getShopIdByName(orderPage.getShopName()).getData());
+            if (CollectionUtils.isEmpty(shopSet)) {
+                return ;
+            }
+            if (null != orderPage.getShopIds()) {
+                List<Integer> shopIds = orderPage.getShopIds();
+                if (!containsIntegerAny(shopIds, shopSet)) {
+                    return ;
+                }
+                shopIds.addAll(shopSet);
+                orderPage.setShopIds(shopIds);
+            } else {
+                orderPage.setShopIds(shopSet);
+            }
+        }
+        if (null != orderPage.getShopIds()) {
+            orderPage.setShopIds(orderPage.getShopIds().stream().distinct().collect(Collectors.toList()));
+        }
 
         List<OrderExport> orderExportList = orderMapper.getOrderExportList(orderPage);
         orderExportList.forEach(orderExport -> {
@@ -628,6 +642,27 @@
         // 如果没有找到共同元素,返回 false
         return false;
     }
+    /**
+     * 判断 list1 是否包含 list2 中的至少一个元素
+     *
+     * @param list1 第一个列表
+     * @param list2 第二个列表
+     * @return 如果 list1 包含 list2 中的至少一个元素,返回 true;否则返回 false
+     */
+    private boolean containsIntegerAny(List<Integer> list1, List<Integer> list2) {
+        // 将 list1 转换为 HashSet 以提高查询效率
+        Set<Integer> set1 = new HashSet<>(list1);
+
+        // 遍历 list2,检查是否有元素存在于 set1 中
+        for (Integer element : list2) {
+            if (set1.contains(element)) {
+                return true;
+            }
+        }
+
+        // 如果没有找到共同元素,返回 false
+        return false;
+    }
 
 
     /**
@@ -639,8 +674,10 @@
     @PostMapping("/getOrderCountByAppUserId")
     public R<Long> getOrderCountByAppUserId(@RequestParam("id") Long appUserId) {
         long count = orderService.count(new LambdaQueryWrapper<Order>().eq(Order::getDelFlag, 0)
-                .eq(Order::getAppUserId, appUserId).in(Order::getOrderStatus, Arrays.asList(1, 2, 3, 4, 7, 8))
-                .eq(Order::getPayStatus, 2));
+                .eq(Order::getAppUserId, appUserId)
+                .in(Order::getOrderStatus, Arrays.asList(1, 2, 3, 4, 7, 8))
+                .eq(Order::getPayStatus, 2)
+        );
         return R.ok(count);
     }
 
@@ -719,7 +756,7 @@
 
 
         //折线图
-        List<OrderStatisticsDetail> orderStatisticsDetailList=orderService.getOrderListGroupByDate(shopAnalysisDTO.getStartTime(), shopAnalysisDTO.getEndTime());
+        List<OrderStatisticsDetail> orderStatisticsDetailList=orderService.getOrderListGroupByDate(shopAnalysisDTO.getStartTime(), shopAnalysisDTO.getEndTime(),shopAnalysisDTO.getShopId());
         shopAnalysisVO.setOrderStatisticsDetailList(orderStatisticsDetailList);
         return R.ok(shopAnalysisVO);
     }
@@ -727,7 +764,7 @@
     /**
      * 统计用户总消费积分数和现金支付金额
      */
-    @GetMapping("/getOrderCountByAppUserId/")
+    @GetMapping("/getConsumeScoreAndPayAmount")
     R<Map<String ,Object>> getConsumeScoreAndPayAmount(@RequestParam(value = "userId",required = false) Long userId){
         QueryWrapper<Order> queryWrapper = new QueryWrapper<>();
         // 条件构造  统计充值积分
@@ -736,7 +773,7 @@
         queryWrapper.in("order_status", Arrays.asList(3,4,8));//待核销  已完成  已评价
         queryWrapper.eq("pay_status",2);
         if (userId != null) {
-            queryWrapper.eq("user_id", userId);
+            queryWrapper.eq("app_user_id", userId);
         }
         return R.ok(orderService.getMap(queryWrapper));
     }

--
Gitblit v1.7.1