From a7efd939762321cf0a1718812c9005efb9f6fc48 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Wed, 21 Jul 2021 16:39:53 +0800
Subject: [PATCH] fix
---
 gc-order/src/main/java/com/xzx/gc/order/mapper/JhyOrderMapper.java            |    2 +-
 gc-order/src/main/resources/mapper/order/JhyOrderMapper.xml                   |   18 ++++++++++++++++--
 gc-order/src/main/java/com/xzx/gc/order/controller/ApiJhyOrderController.java |    6 +++---
 gc-order/src/main/java/com/xzx/gc/order/service/JhyOrderService.java          |    4 ++--
 4 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/gc-order/src/main/java/com/xzx/gc/order/controller/ApiJhyOrderController.java b/gc-order/src/main/java/com/xzx/gc/order/controller/ApiJhyOrderController.java
index 7556b78..cfc924f 100644
--- a/gc-order/src/main/java/com/xzx/gc/order/controller/ApiJhyOrderController.java
+++ b/gc-order/src/main/java/com/xzx/gc/order/controller/ApiJhyOrderController.java
@@ -84,9 +84,9 @@
     }
 
     @ApiOperation("订单状态数量")
-    @PostMapping(value = "/jhy/order/orderStatusCnt")
-    public JsonResult<Map<Integer, Integer>> orderStatusCnt(HttpServletRequest request) {
-        return JsonResult.success(jhyOrderService.orderStatusCount(getUserId(request)));
+    @PostMapping(value = "/jhy/order/orderStatusCnt/{type}")
+    public JsonResult<Map<Integer, Integer>> orderStatusCnt(@PathVariable("type") Integer type, HttpServletRequest request) {
+        return JsonResult.success(jhyOrderService.orderStatusCount(type, getUserId(request)));
     }
 
 }
diff --git a/gc-order/src/main/java/com/xzx/gc/order/mapper/JhyOrderMapper.java b/gc-order/src/main/java/com/xzx/gc/order/mapper/JhyOrderMapper.java
index c60b730..c9d1739 100644
--- a/gc-order/src/main/java/com/xzx/gc/order/mapper/JhyOrderMapper.java
+++ b/gc-order/src/main/java/com/xzx/gc/order/mapper/JhyOrderMapper.java
@@ -15,5 +15,5 @@
 
     List<JhyOrderListVo> selectJhyOrderList(@Param("record") JhyOrderListDto jhyOrderListDto);
 
-    List<JhyStatusCountVo> selectOrderStatusCount(@Param("userId") String userId);
+    List<JhyStatusCountVo> selectOrderStatusCount(@Param("type") Integer type, @Param("userId") String userId);
 }
diff --git a/gc-order/src/main/java/com/xzx/gc/order/service/JhyOrderService.java b/gc-order/src/main/java/com/xzx/gc/order/service/JhyOrderService.java
index ee3c7f3..e875b28 100644
--- a/gc-order/src/main/java/com/xzx/gc/order/service/JhyOrderService.java
+++ b/gc-order/src/main/java/com/xzx/gc/order/service/JhyOrderService.java
@@ -237,8 +237,8 @@
         distribService.distribRecord(order.getId(), order.getUserId());
     }
 
-    public Map<Integer, Integer> orderStatusCount(String userId) {
-        List<JhyStatusCountVo> count = jhyOrderMapper.selectOrderStatusCount(userId);
+    public Map<Integer, Integer> orderStatusCount(Integer type, String userId) {
+        List<JhyStatusCountVo> count = jhyOrderMapper.selectOrderStatusCount(type, userId);
 
         Map<Integer, Integer> map = new HashMap<>();
         for (int i = 1; i < 6; i++) {
diff --git a/gc-order/src/main/resources/mapper/order/JhyOrderMapper.xml b/gc-order/src/main/resources/mapper/order/JhyOrderMapper.xml
index 01997c5..dac82a6 100644
--- a/gc-order/src/main/resources/mapper/order/JhyOrderMapper.xml
+++ b/gc-order/src/main/resources/mapper/order/JhyOrderMapper.xml
@@ -48,13 +48,27 @@
         select
            status,
            count(1) cnt
-        from xzx_jhy_order where status=1
+        from xzx_jhy_order
+        <where>
+            status=1
+            <if test="type == 2">
+                and user_id=#{userId}
+            </if>
+        </where>
+        group by status
         union  all
         select
            status,
            count(1) cnt
         from xzx_jhy_order
-        where user_id=#{userId}
+        <where>
+            <if test="type == 1">
+                and jhy_id=#{userId}
+            </if>
+            <if test="type == 2" >
+                and user_id=#{userId}
+            </if>
+        </where>
         group by status
     </select>
 </mapper>
\ No newline at end of file
--
Gitblit v1.9.1