Authored by chenchao

Merge branch 'master' of http://git.yoho.cn/ufo/yohoufo-fore

@@ -31,7 +31,7 @@ public interface BuyerOrderMapper { @@ -31,7 +31,7 @@ public interface BuyerOrderMapper {
31 31
32 int updateByOrderCode(BuyerOrder record); 32 int updateByOrderCode(BuyerOrder record);
33 33
34 - int selectCntByUidStatus(@Param("uid") int uid, @Param("orderCode") Long orderCode, @Param("status") List<Integer> status); 34 + int selectCntByUidStatus(@Param("uid") int uid, @Param("status") List<Integer> status);
35 35
36 List<BuyerOrder> selectListByUidStatus(@Param("uid") int uid, @Param("orderCode") Long orderCode, @Param("status") List<Integer> status, 36 List<BuyerOrder> selectListByUidStatus(@Param("uid") int uid, @Param("orderCode") Long orderCode, @Param("status") List<Integer> status,
37 @Param("offset")Integer offset, @Param("limit")Integer limit); 37 @Param("offset")Integer offset, @Param("limit")Integer limit);
@@ -76,10 +76,12 @@ public class ErpGWOrderController { @@ -76,10 +76,12 @@ public class ErpGWOrderController {
76 switch (actor){ 76 switch (actor){
77 case BUY: 77 case BUY:
78 orderListRequest.setType(OrderListType.ALL.getType()); // 默认全部 78 orderListRequest.setType(OrderListType.ALL.getType()); // 默认全部
  79 + //TODO 换成独立的service 继承共同的抽象服务类, 除了必要的复用,尽量从service 到 dao 独立隔离;
79 orderListInfoRsp = buyerOrderService.getOrderListForErpGW(orderListRequest); 80 orderListInfoRsp = buyerOrderService.getOrderListForErpGW(orderListRequest);
80 break; 81 break;
81 case SELL: 82 case SELL:
82 orderListRequest.setType(SellerOrderListType.ALL.getType()); // 默认全部 83 orderListRequest.setType(SellerOrderListType.ALL.getType()); // 默认全部
  84 + //TODO 换成独立的service 继承共同的抽象服务类, 除了必要的复用,尽量从service 到 dao 独立隔离;
83 orderListInfoRsp = sellerOrderService.getOrderListForErpGW(orderListRequest); 85 orderListInfoRsp = sellerOrderService.getOrderListForErpGW(orderListRequest);
84 break; 86 break;
85 default: 87 default:
@@ -43,7 +43,7 @@ public abstract class AbsOrderListService extends AbsOrderViewService implements @@ -43,7 +43,7 @@ public abstract class AbsOrderListService extends AbsOrderViewService implements
43 43
44 abstract List<Integer> initOrderListRequest(OrderListRequest request); 44 abstract List<Integer> initOrderListRequest(OrderListRequest request);
45 45
46 - abstract int getTotal(int uid, Long orderCode, List<Integer> statusQuery); 46 + abstract int getTotal(int uid, List<Integer> statusQuery);
47 47
48 abstract List<BuyerOrder> getOrderList(int uid, Long orderCode, List<Integer> statusQuery, int offset, int limit); 48 abstract List<BuyerOrder> getOrderList(int uid, Long orderCode, List<Integer> statusQuery, int offset, int limit);
49 49
@@ -79,7 +79,7 @@ public abstract class AbsOrderListService extends AbsOrderViewService implements @@ -79,7 +79,7 @@ public abstract class AbsOrderListService extends AbsOrderViewService implements
79 // check and init请求参数 79 // check and init请求参数
80 List<Integer> statusQuery = initOrderListRequest(request); 80 List<Integer> statusQuery = initOrderListRequest(request);
81 TabType actor = request.getActor(); 81 TabType actor = request.getActor();
82 - int total = getTotal(request.getUid(), request.getOrderCode(), statusQuery); 82 + int total = getTotal(request.getUid(), statusQuery);
83 int limit = request.getLimit(); 83 int limit = request.getLimit();
84 PageResp.PageRespBuilder respBuilder = PageResp.builder() 84 PageResp.PageRespBuilder respBuilder = PageResp.builder()
85 .page(request.getPage()) 85 .page(request.getPage())
@@ -87,8 +87,8 @@ public class BuyerOrderListServiceImpl extends AbsOrderListService implements IO @@ -87,8 +87,8 @@ public class BuyerOrderListServiceImpl extends AbsOrderListService implements IO
87 } 87 }
88 88
89 @Override 89 @Override
90 - int getTotal(int uid, Long orderCode, List<Integer> statusQuery){  
91 - return buyerOrderMapper.selectCntByUidStatus(uid, orderCode, statusQuery); 90 + int getTotal(int uid, List<Integer> statusQuery){
  91 + return buyerOrderMapper.selectCntByUidStatus(uid, statusQuery);
92 } 92 }
93 93
94 @Override 94 @Override
@@ -363,7 +363,7 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde @@ -363,7 +363,7 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
363 } 363 }
364 364
365 @Override 365 @Override
366 - int getTotal(int uid, Long orderCode, List<Integer> statusQuery) { 366 + int getTotal(int uid, List<Integer> statusQuery) {
367 return buyerOrderMapper.selectCntBySellerUidStatus(uid, statusQuery); 367 return buyerOrderMapper.selectCntBySellerUidStatus(uid, statusQuery);
368 } 368 }
369 369
  1 +package com.yohoufo.order.service.impl;
  2 +
  3 +import com.yohobuy.ufo.model.order.common.OrderStatus;
  4 +import com.yohoufo.common.exception.UfoServiceException;
  5 +import com.yohoufo.dal.order.BuyerOrderMapper;
  6 +import com.yohoufo.order.utils.LoggerUtils;
  7 +import org.slf4j.Logger;
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.stereotype.Component;
  10 +
  11 +import java.util.ArrayList;
  12 +import java.util.List;
  13 +
  14 +/**
  15 + * 购物分控
  16 + */
  17 +@Component
  18 +public class ShoppingRiskWatchDog {
  19 +
  20 + private Logger logger = LoggerUtils.getBuyerOrderLogger();
  21 +
  22 + private static final int waitingPayCnt = 1;
  23 +
  24 + @Autowired
  25 + private BuyerOrderMapper buyerOrderMapper;
  26 +
  27 + public void checkWaitingPayCnt(int uid){
  28 + logger.info("in ShoppingRiskWatchDog.checkWaitingPayCnt uid {}", uid);
  29 + List<Integer> statusList = new ArrayList<>(1);
  30 + statusList.add(OrderStatus.WAITING_PAY.getCode());
  31 +
  32 + int cnt = buyerOrderMapper.selectCntByUidStatus(uid, statusList);
  33 + if (cnt >= waitingPayCnt){
  34 + logger.warn("in ShoppingRiskWatchDog.checkWaitingPayCnt try monopolizing skup another time,uid {} waiting pay cnt {}",
  35 + uid, cnt);
  36 + throw new UfoServiceException(512, "您有未支付的订单,支付或取消后可提交新的订单");
  37 + }
  38 + }
  39 +}
@@ -107,6 +107,9 @@ public class ShoppingServiceImpl implements IShoppingService { @@ -107,6 +107,9 @@ public class ShoppingServiceImpl implements IShoppingService {
107 107
108 @Autowired 108 @Autowired
109 private CouponService couponService; 109 private CouponService couponService;
  110 +
  111 + @Autowired
  112 + private ShoppingRiskWatchDog shoppingRiskWatchDog;
110 /** 113 /**
111 * 结算页数据 114 * 结算页数据
112 * @param request 115 * @param request
@@ -120,7 +123,7 @@ public class ShoppingServiceImpl implements IShoppingService { @@ -120,7 +123,7 @@ public class ShoppingServiceImpl implements IShoppingService {
120 logger.warn("payment uid or skup is null"); 123 logger.warn("payment uid or skup is null");
121 throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY); 124 throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
122 } 125 }
123 - 126 + shoppingRiskWatchDog.checkWaitingPayCnt(uid);
124 // 检查 商品sku是否可售 127 // 检查 商品sku是否可售
125 SellerOrderGoods skupGood = checkSkupSellOrNot(request.getSkup()); 128 SellerOrderGoods skupGood = checkSkupSellOrNot(request.getSkup());
126 129
@@ -269,7 +272,7 @@ public class ShoppingServiceImpl implements IShoppingService { @@ -269,7 +272,7 @@ public class ShoppingServiceImpl implements IShoppingService {
269 logger.warn("submit param is null"); 272 logger.warn("submit param is null");
270 throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY); 273 throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
271 } 274 }
272 - 275 + shoppingRiskWatchDog.checkWaitingPayCnt(uid);
273 //查询并校验用户地址 276 //查询并校验用户地址
274 Pair<AddressInfo, AddressInfo> userAddressPair = getAndCheckAddressInfo(shoppingRequest); 277 Pair<AddressInfo, AddressInfo> userAddressPair = getAndCheckAddressInfo(shoppingRequest);
275 278