Authored by chenchao

filter in-stock of buyer order num 4 buyer

... ... @@ -63,11 +63,18 @@ public interface BuyerOrderMapper {
// 修改订单的卖家发货状态
int updateSellerDeliveryStatusByOrderCode(@Param("orderCode")long orderCode, @Param("uid")int uid, @Param("targetSellerDeliveryStatus")int targetSellerDeliveryStatus);
// 根据uid查询订单总数
Integer selectOrderNumByUid(@Param("uid")int uid);
/**
* 根据uid查询订单总数(包含删除 或 未删除)
*/
Integer selectOrderNumByUid(@Param("uid")int uid,@Param("orderTypes") List<Integer> orderTypes);
BuyerOrder selectAllByOrderCode(@Param("orderCode") Long orderCode);
/**
* 未删除的订单总数
* @param uid
* @return
*/
int selectCntByUid(@Param("uid")int uid);
@Deprecated
... ...
... ... @@ -42,9 +42,7 @@
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectCntByUid" resultType="java.lang.Integer">
select count(*) from buyer_order where uid = #{uid,jdbcType=INTEGER}
</select>
<select id="selectCntByUidStatus" resultType="java.lang.Integer">
select count(*) from buyer_order
... ... @@ -440,10 +438,6 @@
where uid = #{uid,jdbcType=INTEGER} and order_code = #{orderCode,jdbcType=BIGINT}
</update>
<select id="selectOrderNumByUid" resultType="java.lang.Integer">
select count(*) from buyer_order where uid = #{uid,jdbcType=INTEGER} and buyer_order_status = 1
</select>
<select id="selectCntBySellerUid" resultType="java.lang.Integer">
select count(*) from buyer_order where seller_uid = #{sellerUid,jdbcType=INTEGER}
... ... @@ -461,4 +455,20 @@
where order_code = #{orderCode,jdbcType=BIGINT}
limit 1
</select>
<select id="selectOrderNumByUid" resultType="java.lang.Integer">
select count(*) from buyer_order
where uid = #{uid,jdbcType=INTEGER} and buyer_order_status = 1
<if test="orderTypes != null">
and attributes in
<foreach collection="orderTypes" item="attributes" open="(" close=")" separator=",">
#{attributes}
</foreach>
</if>
</select>
<select id="selectCntByUid" resultType="java.lang.Integer">
select count(*) from buyer_order where uid = #{uid,jdbcType=INTEGER}
</select>
</mapper>
\ No newline at end of file
... ...
... ... @@ -271,35 +271,7 @@ public class BuyerOrderController {
}
@RequestMapping(params = "method=ufo.order.getAllCnt")
public ApiResponse getOrderCnt(@RequestParam(name = "uid") int uid,
@RequestParam("tabType") String tabType,
@RequestParam(value = "business_client", required = false,defaultValue = "ufo") String businessClient,
@RequestParam(name = "client_type", required = false) String clientType){
LOG.info("in ufo.order.getAllCnt, uid {}, clientType is {}", uid, clientType);
TabType actor = TabType.getTabType(tabType);
if (Objects.isNull(actor)){
return new ApiResponse.ApiResponseBuilder().code(400).message("非法的tab").build();
}
OrderRequest orderRequest = OrderRequest.builder()
.uid(uid)
.tabType(tabType)
.actor(actor)
.businessClient(businessClient)
.build();
OrderCntResp orderCntResp;
switch (actor){
case BUY:
orderCntResp = buyerOrderService.getOrderCnt(orderRequest, OrderListType.ALL);
break;
case SELL:
orderCntResp = sellerOrderViewService.getOrderCnt(orderRequest, SellerOrderListType.ALL);
break;
default:
orderCntResp = OrderCntResp.builder().uid(uid).cnt(0L).actor(tabType).build();
}
return new ApiResponse.ApiResponseBuilder().code(200).data(orderCntResp).message("查询订单数量").build();
}
@RequestMapping(params = "method=ufo.buyer.orderListNums")
public ApiResponse getBuyerOrderNums(@RequestParam("uid") int uid){
... ...
package com.yohoufo.order.controller;
import com.google.common.collect.Lists;
import com.yohobuy.ufo.model.order.common.OrderListType;
import com.yohobuy.ufo.model.order.common.SellerOrderListType;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohobuy.ufo.model.order.resp.OrderCntResp;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.order.model.request.OrderRequest;
import com.yohoufo.order.model.response.OrderSummaryResp;
import com.yohoufo.order.service.impl.BuyerOrderViewService;
import com.yohoufo.order.service.impl.SellerOrderViewService;
... ... @@ -13,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Objects;
@RestController
public class OrderStatisticController {
... ... @@ -58,4 +64,35 @@ public class OrderStatisticController {
return new ApiResponse.ApiResponseBuilder().code(200).data(orderSummaryResps).message("查询成功").build();
}
@RequestMapping(params = "method=ufo.order.getAllCnt")
public ApiResponse getOrderCnt(@RequestParam(name = "uid") int uid,
@RequestParam("tabType") String tabType,
@RequestParam(value = "business_client", required = false,defaultValue = "ufo") String businessClient,
@RequestParam(name = "client_type", required = false) String clientType){
logger.info("in ufo.order.getAllCnt, uid {}, clientType {} business_client {}", uid, clientType, businessClient);
TabType actor = TabType.getTabType(tabType);
if (Objects.isNull(actor)){
return new ApiResponse.ApiResponseBuilder().code(400).message("非法的tab").build();
}
OrderRequest orderRequest = OrderRequest.builder()
.uid(uid)
.tabType(tabType)
.actor(actor)
.businessClient(businessClient)
.build();
OrderCntResp orderCntResp;
switch (actor){
case BUY:
orderCntResp = buyerOrderViewService.getOrderCnt(orderRequest, OrderListType.ALL);
break;
case SELL:
orderCntResp = sellerOrderViewService.getOrderCnt(orderRequest, SellerOrderListType.ALL);
break;
default:
orderCntResp = OrderCntResp.builder().uid(uid).cnt(0L).actor(tabType).build();
}
return new ApiResponse.ApiResponseBuilder().code(200).data(orderCntResp).message("查询订单数量").build();
}
}
... ...
... ... @@ -19,8 +19,6 @@ public class OrderViewController {
private OrderViewService orderViewService;
@RequestMapping(params = "method=ufo.order.goodsDetail")
public ApiResponse orderGoodsDetail(@RequestParam("orderCode") long orderCode,
@RequestParam("uid") int uid){
... ... @@ -38,4 +36,5 @@ public class OrderViewController {
OrderDetailInfo orderDetailInfo = orderViewService.getPayDetail(uid, orderCode);
return new ApiResponse.ApiResponseBuilder().data(orderDetailInfo).code(200).message("成功").build();
}
}
... ...
... ... @@ -66,7 +66,7 @@ public interface IBuyerOrderService {
void modifyAddressOfDepositOrder(int uid, Long orderCode, String addressIdstr);
OrderCntResp getOrderCnt(OrderRequest req, OrderListType listType);
/**
... ...
... ... @@ -1106,22 +1106,7 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
return sellerOrderGoods;
}
@Override
public OrderCntResp getOrderCnt(OrderRequest req, OrderListType listType) {
logger.info("in buyer getOrderCnt req {} listType {}", req, listType);
OrderCntResp resp;
int cnt ;
switch (listType){
case ALL:
cnt = buyerOrderMapper.selectCntByUid(req.getUid());
break;
default:
cnt = 0;
break;
}
resp = OrderCntResp.builder().uid(req.getUid()).cnt(cnt).actor(req.getTabType()).build();
return resp;
}
@Override
public int processOrderDeliverByDepositGoods(BuyerOrderAssistant.PreparedData preparedData,
... ...
... ... @@ -3,13 +3,12 @@ package com.yohoufo.order.service.impl;
import com.google.common.collect.Lists;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.common.OrderListType;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohobuy.ufo.model.order.constants.BusinessClientEnum;
import com.yohobuy.ufo.model.order.constants.ConfirmDesc;
import com.yohobuy.ufo.model.order.resp.OrderCancelComputeResult;
import com.yohobuy.ufo.model.order.resp.OrderDetailInfo;
import com.yohobuy.ufo.model.order.resp.OrderListInfo;
import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohobuy.ufo.model.order.resp.*;
import com.yohobuy.ufo.model.order.vo.OrderListVo;
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
import com.yohoufo.dal.order.BuyerOrderMapper;
... ... @@ -23,6 +22,7 @@ import com.yohoufo.order.service.IOrderListService;
import com.yohoufo.order.service.cache.OrderCacheService;
import com.yohoufo.order.service.handler.BuyerCancelCompensateComputeHandler;
import com.yohoufo.order.utils.LoggerUtils;
import com.yohoufo.order.utils.OrderAssist;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
... ... @@ -182,7 +182,9 @@ public class BuyerOrderViewService implements IOrderListService, IOrderDetailSer
public OrderSummaryResp getOrderNumByUid(int uid, String businessClient) {
Integer num =orderCacheService.getOrderSummary(uid, TabType.BUY, businessClient);
if (num == null){
num = buyerOrderMapper.selectOrderNumByUid(uid);
final BusinessClientEnum bce = OrderAssist.findBusinessClient(businessClient);
List<Integer> orderTypes = OrderAssist.matchOrderTypesByBusinessClient(bce);
num = buyerOrderMapper.selectOrderNumByUid(uid, orderTypes);
}
if (num != null){
orderCacheService.cacheOrderSummary(uid, TabType.BUY, num, businessClient);
... ... @@ -208,4 +210,21 @@ public class BuyerOrderViewService implements IOrderListService, IOrderDetailSer
}
return null == num ? new OrderSummaryResp(statKey, 0) : new OrderSummaryResp(statKey, num);
}
public OrderCntResp getOrderCnt(OrderRequest req, OrderListType listType) {
logger.info("in buyer getOrderCnt req {} listType {}", req, listType);
OrderCntResp resp;
int cnt ;
switch (listType){
case ALL:
cnt = buyerOrderMapper.selectCntByUid(req.getUid());
break;
default:
cnt = 0;
break;
}
resp = OrderCntResp.builder().uid(req.getUid()).cnt(cnt).actor(req.getTabType()).build();
return resp;
}
}
... ...