Authored by chenchao

filter in-stock of buyer order num 4 buyer

@@ -63,11 +63,18 @@ public interface BuyerOrderMapper { @@ -63,11 +63,18 @@ public interface BuyerOrderMapper {
63 // 修改订单的卖家发货状态 63 // 修改订单的卖家发货状态
64 int updateSellerDeliveryStatusByOrderCode(@Param("orderCode")long orderCode, @Param("uid")int uid, @Param("targetSellerDeliveryStatus")int targetSellerDeliveryStatus); 64 int updateSellerDeliveryStatusByOrderCode(@Param("orderCode")long orderCode, @Param("uid")int uid, @Param("targetSellerDeliveryStatus")int targetSellerDeliveryStatus);
65 65
66 - // 根据uid查询订单总数  
67 - Integer selectOrderNumByUid(@Param("uid")int uid); 66 + /**
  67 + * 根据uid查询订单总数(包含删除 或 未删除)
  68 + */
  69 + Integer selectOrderNumByUid(@Param("uid")int uid,@Param("orderTypes") List<Integer> orderTypes);
68 70
69 BuyerOrder selectAllByOrderCode(@Param("orderCode") Long orderCode); 71 BuyerOrder selectAllByOrderCode(@Param("orderCode") Long orderCode);
70 72
  73 + /**
  74 + * 未删除的订单总数
  75 + * @param uid
  76 + * @return
  77 + */
71 int selectCntByUid(@Param("uid")int uid); 78 int selectCntByUid(@Param("uid")int uid);
72 79
73 @Deprecated 80 @Deprecated
@@ -42,9 +42,7 @@ @@ -42,9 +42,7 @@
42 where id = #{id,jdbcType=INTEGER} 42 where id = #{id,jdbcType=INTEGER}
43 </select> 43 </select>
44 44
45 - <select id="selectCntByUid" resultType="java.lang.Integer">  
46 - select count(*) from buyer_order where uid = #{uid,jdbcType=INTEGER}  
47 - </select> 45 +
48 46
49 <select id="selectCntByUidStatus" resultType="java.lang.Integer"> 47 <select id="selectCntByUidStatus" resultType="java.lang.Integer">
50 select count(*) from buyer_order 48 select count(*) from buyer_order
@@ -440,10 +438,6 @@ @@ -440,10 +438,6 @@
440 where uid = #{uid,jdbcType=INTEGER} and order_code = #{orderCode,jdbcType=BIGINT} 438 where uid = #{uid,jdbcType=INTEGER} and order_code = #{orderCode,jdbcType=BIGINT}
441 </update> 439 </update>
442 440
443 - <select id="selectOrderNumByUid" resultType="java.lang.Integer">  
444 - select count(*) from buyer_order where uid = #{uid,jdbcType=INTEGER} and buyer_order_status = 1  
445 - </select>  
446 -  
447 441
448 <select id="selectCntBySellerUid" resultType="java.lang.Integer"> 442 <select id="selectCntBySellerUid" resultType="java.lang.Integer">
449 select count(*) from buyer_order where seller_uid = #{sellerUid,jdbcType=INTEGER} 443 select count(*) from buyer_order where seller_uid = #{sellerUid,jdbcType=INTEGER}
@@ -461,4 +455,20 @@ @@ -461,4 +455,20 @@
461 where order_code = #{orderCode,jdbcType=BIGINT} 455 where order_code = #{orderCode,jdbcType=BIGINT}
462 limit 1 456 limit 1
463 </select> 457 </select>
  458 +
  459 +
  460 + <select id="selectOrderNumByUid" resultType="java.lang.Integer">
  461 + select count(*) from buyer_order
  462 + where uid = #{uid,jdbcType=INTEGER} and buyer_order_status = 1
  463 + <if test="orderTypes != null">
  464 + and attributes in
  465 + <foreach collection="orderTypes" item="attributes" open="(" close=")" separator=",">
  466 + #{attributes}
  467 + </foreach>
  468 + </if>
  469 + </select>
  470 +
  471 + <select id="selectCntByUid" resultType="java.lang.Integer">
  472 + select count(*) from buyer_order where uid = #{uid,jdbcType=INTEGER}
  473 + </select>
464 </mapper> 474 </mapper>
@@ -271,35 +271,7 @@ public class BuyerOrderController { @@ -271,35 +271,7 @@ public class BuyerOrderController {
271 } 271 }
272 272
273 273
274 - @RequestMapping(params = "method=ufo.order.getAllCnt")  
275 - public ApiResponse getOrderCnt(@RequestParam(name = "uid") int uid,  
276 - @RequestParam("tabType") String tabType,  
277 - @RequestParam(value = "business_client", required = false,defaultValue = "ufo") String businessClient,  
278 - @RequestParam(name = "client_type", required = false) String clientType){  
279 - LOG.info("in ufo.order.getAllCnt, uid {}, clientType is {}", uid, clientType);  
280 - TabType actor = TabType.getTabType(tabType);  
281 - if (Objects.isNull(actor)){  
282 - return new ApiResponse.ApiResponseBuilder().code(400).message("非法的tab").build();  
283 - }  
284 - OrderRequest orderRequest = OrderRequest.builder()  
285 - .uid(uid)  
286 - .tabType(tabType)  
287 - .actor(actor)  
288 - .businessClient(businessClient)  
289 - .build();  
290 - OrderCntResp orderCntResp;  
291 - switch (actor){  
292 - case BUY:  
293 - orderCntResp = buyerOrderService.getOrderCnt(orderRequest, OrderListType.ALL);  
294 - break;  
295 - case SELL:  
296 - orderCntResp = sellerOrderViewService.getOrderCnt(orderRequest, SellerOrderListType.ALL);  
297 - break;  
298 - default:  
299 - orderCntResp = OrderCntResp.builder().uid(uid).cnt(0L).actor(tabType).build();  
300 - }  
301 - return new ApiResponse.ApiResponseBuilder().code(200).data(orderCntResp).message("查询订单数量").build();  
302 - } 274 +
303 275
304 @RequestMapping(params = "method=ufo.buyer.orderListNums") 276 @RequestMapping(params = "method=ufo.buyer.orderListNums")
305 public ApiResponse getBuyerOrderNums(@RequestParam("uid") int uid){ 277 public ApiResponse getBuyerOrderNums(@RequestParam("uid") int uid){
1 package com.yohoufo.order.controller; 1 package com.yohoufo.order.controller;
2 2
3 import com.google.common.collect.Lists; 3 import com.google.common.collect.Lists;
  4 +import com.yohobuy.ufo.model.order.common.OrderListType;
  5 +import com.yohobuy.ufo.model.order.common.SellerOrderListType;
  6 +import com.yohobuy.ufo.model.order.common.TabType;
  7 +import com.yohobuy.ufo.model.order.resp.OrderCntResp;
4 import com.yohoufo.common.ApiResponse; 8 import com.yohoufo.common.ApiResponse;
  9 +import com.yohoufo.order.model.request.OrderRequest;
5 import com.yohoufo.order.model.response.OrderSummaryResp; 10 import com.yohoufo.order.model.response.OrderSummaryResp;
6 import com.yohoufo.order.service.impl.BuyerOrderViewService; 11 import com.yohoufo.order.service.impl.BuyerOrderViewService;
7 import com.yohoufo.order.service.impl.SellerOrderViewService; 12 import com.yohoufo.order.service.impl.SellerOrderViewService;
@@ -13,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestParam; @@ -13,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestParam;
13 import org.springframework.web.bind.annotation.RestController; 18 import org.springframework.web.bind.annotation.RestController;
14 19
15 import java.util.List; 20 import java.util.List;
  21 +import java.util.Objects;
16 22
17 @RestController 23 @RestController
18 public class OrderStatisticController { 24 public class OrderStatisticController {
@@ -58,4 +64,35 @@ public class OrderStatisticController { @@ -58,4 +64,35 @@ public class OrderStatisticController {
58 return new ApiResponse.ApiResponseBuilder().code(200).data(orderSummaryResps).message("查询成功").build(); 64 return new ApiResponse.ApiResponseBuilder().code(200).data(orderSummaryResps).message("查询成功").build();
59 } 65 }
60 66
  67 +
  68 + @RequestMapping(params = "method=ufo.order.getAllCnt")
  69 + public ApiResponse getOrderCnt(@RequestParam(name = "uid") int uid,
  70 + @RequestParam("tabType") String tabType,
  71 + @RequestParam(value = "business_client", required = false,defaultValue = "ufo") String businessClient,
  72 + @RequestParam(name = "client_type", required = false) String clientType){
  73 + logger.info("in ufo.order.getAllCnt, uid {}, clientType {} business_client {}", uid, clientType, businessClient);
  74 + TabType actor = TabType.getTabType(tabType);
  75 + if (Objects.isNull(actor)){
  76 + return new ApiResponse.ApiResponseBuilder().code(400).message("非法的tab").build();
  77 + }
  78 + OrderRequest orderRequest = OrderRequest.builder()
  79 + .uid(uid)
  80 + .tabType(tabType)
  81 + .actor(actor)
  82 + .businessClient(businessClient)
  83 + .build();
  84 + OrderCntResp orderCntResp;
  85 + switch (actor){
  86 + case BUY:
  87 + orderCntResp = buyerOrderViewService.getOrderCnt(orderRequest, OrderListType.ALL);
  88 + break;
  89 + case SELL:
  90 + orderCntResp = sellerOrderViewService.getOrderCnt(orderRequest, SellerOrderListType.ALL);
  91 + break;
  92 + default:
  93 + orderCntResp = OrderCntResp.builder().uid(uid).cnt(0L).actor(tabType).build();
  94 + }
  95 + return new ApiResponse.ApiResponseBuilder().code(200).data(orderCntResp).message("查询订单数量").build();
  96 + }
  97 +
61 } 98 }
@@ -19,8 +19,6 @@ public class OrderViewController { @@ -19,8 +19,6 @@ public class OrderViewController {
19 private OrderViewService orderViewService; 19 private OrderViewService orderViewService;
20 20
21 21
22 -  
23 -  
24 @RequestMapping(params = "method=ufo.order.goodsDetail") 22 @RequestMapping(params = "method=ufo.order.goodsDetail")
25 public ApiResponse orderGoodsDetail(@RequestParam("orderCode") long orderCode, 23 public ApiResponse orderGoodsDetail(@RequestParam("orderCode") long orderCode,
26 @RequestParam("uid") int uid){ 24 @RequestParam("uid") int uid){
@@ -38,4 +36,5 @@ public class OrderViewController { @@ -38,4 +36,5 @@ public class OrderViewController {
38 OrderDetailInfo orderDetailInfo = orderViewService.getPayDetail(uid, orderCode); 36 OrderDetailInfo orderDetailInfo = orderViewService.getPayDetail(uid, orderCode);
39 return new ApiResponse.ApiResponseBuilder().data(orderDetailInfo).code(200).message("成功").build(); 37 return new ApiResponse.ApiResponseBuilder().data(orderDetailInfo).code(200).message("成功").build();
40 } 38 }
  39 +
41 } 40 }
@@ -66,7 +66,7 @@ public interface IBuyerOrderService { @@ -66,7 +66,7 @@ public interface IBuyerOrderService {
66 66
67 void modifyAddressOfDepositOrder(int uid, Long orderCode, String addressIdstr); 67 void modifyAddressOfDepositOrder(int uid, Long orderCode, String addressIdstr);
68 68
69 - OrderCntResp getOrderCnt(OrderRequest req, OrderListType listType); 69 +
70 70
71 71
72 /** 72 /**
@@ -1106,22 +1106,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService { @@ -1106,22 +1106,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
1106 return sellerOrderGoods; 1106 return sellerOrderGoods;
1107 } 1107 }
1108 1108
1109 - @Override  
1110 - public OrderCntResp getOrderCnt(OrderRequest req, OrderListType listType) {  
1111 - logger.info("in buyer getOrderCnt req {} listType {}", req, listType);  
1112 - OrderCntResp resp;  
1113 - int cnt ;  
1114 - switch (listType){  
1115 - case ALL:  
1116 - cnt = buyerOrderMapper.selectCntByUid(req.getUid());  
1117 - break;  
1118 - default:  
1119 - cnt = 0;  
1120 - break;  
1121 - }  
1122 - resp = OrderCntResp.builder().uid(req.getUid()).cnt(cnt).actor(req.getTabType()).build();  
1123 - return resp;  
1124 - } 1109 +
1125 1110
1126 @Override 1111 @Override
1127 public int processOrderDeliverByDepositGoods(BuyerOrderAssistant.PreparedData preparedData, 1112 public int processOrderDeliverByDepositGoods(BuyerOrderAssistant.PreparedData preparedData,
@@ -3,13 +3,12 @@ package com.yohoufo.order.service.impl; @@ -3,13 +3,12 @@ package com.yohoufo.order.service.impl;
3 import com.google.common.collect.Lists; 3 import com.google.common.collect.Lists;
4 import com.yoho.error.ServiceError; 4 import com.yoho.error.ServiceError;
5 import com.yoho.error.exception.ServiceException; 5 import com.yoho.error.exception.ServiceException;
  6 +import com.yohobuy.ufo.model.order.common.OrderListType;
6 import com.yohobuy.ufo.model.order.common.OrderStatus; 7 import com.yohobuy.ufo.model.order.common.OrderStatus;
7 import com.yohobuy.ufo.model.order.common.TabType; 8 import com.yohobuy.ufo.model.order.common.TabType;
  9 +import com.yohobuy.ufo.model.order.constants.BusinessClientEnum;
8 import com.yohobuy.ufo.model.order.constants.ConfirmDesc; 10 import com.yohobuy.ufo.model.order.constants.ConfirmDesc;
9 -import com.yohobuy.ufo.model.order.resp.OrderCancelComputeResult;  
10 -import com.yohobuy.ufo.model.order.resp.OrderDetailInfo;  
11 -import com.yohobuy.ufo.model.order.resp.OrderListInfo;  
12 -import com.yohobuy.ufo.model.order.resp.PageResp; 11 +import com.yohobuy.ufo.model.order.resp.*;
13 import com.yohobuy.ufo.model.order.vo.OrderListVo; 12 import com.yohobuy.ufo.model.order.vo.OrderListVo;
14 import com.yohoufo.dal.order.BuyerOrderGoodsMapper; 13 import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
15 import com.yohoufo.dal.order.BuyerOrderMapper; 14 import com.yohoufo.dal.order.BuyerOrderMapper;
@@ -23,6 +22,7 @@ import com.yohoufo.order.service.IOrderListService; @@ -23,6 +22,7 @@ import com.yohoufo.order.service.IOrderListService;
23 import com.yohoufo.order.service.cache.OrderCacheService; 22 import com.yohoufo.order.service.cache.OrderCacheService;
24 import com.yohoufo.order.service.handler.BuyerCancelCompensateComputeHandler; 23 import com.yohoufo.order.service.handler.BuyerCancelCompensateComputeHandler;
25 import com.yohoufo.order.utils.LoggerUtils; 24 import com.yohoufo.order.utils.LoggerUtils;
  25 +import com.yohoufo.order.utils.OrderAssist;
26 import org.slf4j.Logger; 26 import org.slf4j.Logger;
27 import org.springframework.beans.factory.annotation.Autowired; 27 import org.springframework.beans.factory.annotation.Autowired;
28 import org.springframework.stereotype.Service; 28 import org.springframework.stereotype.Service;
@@ -182,7 +182,9 @@ public class BuyerOrderViewService implements IOrderListService, IOrderDetailSer @@ -182,7 +182,9 @@ public class BuyerOrderViewService implements IOrderListService, IOrderDetailSer
182 public OrderSummaryResp getOrderNumByUid(int uid, String businessClient) { 182 public OrderSummaryResp getOrderNumByUid(int uid, String businessClient) {
183 Integer num =orderCacheService.getOrderSummary(uid, TabType.BUY, businessClient); 183 Integer num =orderCacheService.getOrderSummary(uid, TabType.BUY, businessClient);
184 if (num == null){ 184 if (num == null){
185 - num = buyerOrderMapper.selectOrderNumByUid(uid); 185 + final BusinessClientEnum bce = OrderAssist.findBusinessClient(businessClient);
  186 + List<Integer> orderTypes = OrderAssist.matchOrderTypesByBusinessClient(bce);
  187 + num = buyerOrderMapper.selectOrderNumByUid(uid, orderTypes);
186 } 188 }
187 if (num != null){ 189 if (num != null){
188 orderCacheService.cacheOrderSummary(uid, TabType.BUY, num, businessClient); 190 orderCacheService.cacheOrderSummary(uid, TabType.BUY, num, businessClient);
@@ -208,4 +210,21 @@ public class BuyerOrderViewService implements IOrderListService, IOrderDetailSer @@ -208,4 +210,21 @@ public class BuyerOrderViewService implements IOrderListService, IOrderDetailSer
208 } 210 }
209 return null == num ? new OrderSummaryResp(statKey, 0) : new OrderSummaryResp(statKey, num); 211 return null == num ? new OrderSummaryResp(statKey, 0) : new OrderSummaryResp(statKey, num);
210 } 212 }
  213 +
  214 +
  215 + public OrderCntResp getOrderCnt(OrderRequest req, OrderListType listType) {
  216 + logger.info("in buyer getOrderCnt req {} listType {}", req, listType);
  217 + OrderCntResp resp;
  218 + int cnt ;
  219 + switch (listType){
  220 + case ALL:
  221 + cnt = buyerOrderMapper.selectCntByUid(req.getUid());
  222 + break;
  223 + default:
  224 + cnt = 0;
  225 + break;
  226 + }
  227 + resp = OrderCntResp.builder().uid(req.getUid()).cnt(cnt).actor(req.getTabType()).build();
  228 + return resp;
  229 + }
211 } 230 }