ソースを参照

获取各状态订单数量

chao 3 年 前
コミット
b31726a01a

+ 13 - 2
src/main/java/com/caimei365/order/controller/OrderClubApi.java

@@ -31,6 +31,19 @@ public class OrderClubApi {
 
     private final OrderClubService orderClubService;
 
+    /**
+     * 获取各状态订单数量
+     */
+    @ApiOperation("获取各状态订单数量(旧:/pcCenter/getOrderNum)")
+    @ApiImplicitParam(required = true, name = "userId", value = "用户Id")
+    @GetMapping("/count")
+    public  ResponseJson<Map<String, Object>> getOrderCount(Integer userId) {
+        if (null == userId) {
+            return ResponseJson.error("用户Id不能为空!", null);
+        }
+        return orderClubService.getOrderCount(userId);
+    }
+
     /**
      * 机构订单列表
      */
@@ -312,6 +325,4 @@ public class OrderClubApi {
         }
         return orderClubService.getClauseById(clauseId);
     }
-
-
 }

+ 6 - 0
src/main/java/com/caimei365/order/mapper/OrderClubMapper.java

@@ -102,6 +102,12 @@ public interface OrderClubMapper {
      * @param orderId 订单Id
      */
     void updateLogisticsBatch(Integer orderId);
+    /**
+     * 获取各状态订单数量
+     * @param userId     用户Id
+     * @param orderState 1:待确认,2:待付款,3:待发货,4:已发货,5:退货款
+     */
+    Integer getOrderCount(Integer userId, Integer orderState);
     /**
      * 机构订单列表
      * @param userId     用户Id

+ 33 - 0
src/main/java/com/caimei365/order/service/impl/OrderClubServiceImpl.java

@@ -59,6 +59,39 @@ public class OrderClubServiceImpl implements OrderClubService {
     @Resource
     private OrderCommonService orderCommonService;
 
+    /**
+     * 获取各状态订单数量
+     *
+     * @param userId 用户id
+     */
+    @Override
+    public ResponseJson<Map<String, Object>> getOrderCount(Integer userId) {
+        Map<String, Object> map = new HashMap<>();
+        //全部数量
+        Integer totalCount = orderClubMapper.getOrderCount(userId, 0);
+        map.put("totalCount", totalCount);
+        //待确认数量
+        Integer confirmedCount = orderClubMapper.getOrderCount(userId, 1);
+        map.put("confirmedCount", confirmedCount);
+        //待付款数量
+        Integer paymentCount = orderClubMapper.getOrderCount(userId, 2);
+        paymentCount = paymentCount == null ? 0 : paymentCount;
+        map.put("paymentCount", paymentCount);
+        //待发货数量
+        Integer waitShipmentsCount = orderClubMapper.getOrderCount(userId, 3);
+        waitShipmentsCount = waitShipmentsCount == null ? 0 : waitShipmentsCount;
+        map.put("waitShipmentsCount", waitShipmentsCount);
+        //已发货数量
+        Integer shipmentsCount = orderClubMapper.getOrderCount(userId, 4);
+        shipmentsCount = shipmentsCount == null ? 0 : shipmentsCount;
+        map.put("shipmentsCount", shipmentsCount);
+        //退货款数量
+        Integer salesReturnCount = orderClubMapper.getOrderCount(userId, 5);
+        salesReturnCount = salesReturnCount == null ? 0 : salesReturnCount;
+        map.put("salesReturnCount", salesReturnCount);
+        return ResponseJson.success(map);
+    }
+
     /**
      * 机构订单列表
      *

+ 19 - 0
src/main/resources/mapper/OrderClubMapper.xml

@@ -240,6 +240,25 @@
             #{shopOrderId}
         </foreach>
     </select>
+    <select id="getOrderCount" resultType="java.lang.Integer">
+        SELECT COUNT(*) FROM cm_order
+        WHERE userID = #{userID} AND delFlag = '0'
+        <if test="orderState == 1 ">
+            AND status = '0'
+        </if>
+        <if test="orderState == 2 ">
+            AND status IN(11,12,13,21,22,23)
+        </if>
+        <if test="orderState == 3 ">
+            AND status IN(11,12,21,22,31,32)
+        </if>
+        <if test="orderState == 4 ">
+            AND status IN(12,13,22,23,32,33)
+        </if>
+        <if test="orderState == 5 ">
+            AND refundType IN(1,2)
+        </if>
+    </select>
     <select id="getOrderList" resultType="com.caimei365.order.model.vo.OrderVo">
         SELECT
             orderID AS orderId,