Authored by chenchao

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

... ... @@ -31,7 +31,7 @@ public interface BuyerOrderMapper {
int updateByOrderCode(BuyerOrder record);
int selectCntByUidStatus(@Param("uid") int uid, @Param("orderCode") Long orderCode, @Param("status") List<Integer> status);
int selectCntByUidStatus(@Param("uid") int uid, @Param("status") List<Integer> status);
List<BuyerOrder> selectListByUidStatus(@Param("uid") int uid, @Param("orderCode") Long orderCode, @Param("status") List<Integer> status,
@Param("offset")Integer offset, @Param("limit")Integer limit);
... ...
... ... @@ -76,10 +76,12 @@ public class ErpGWOrderController {
switch (actor){
case BUY:
orderListRequest.setType(OrderListType.ALL.getType()); // 默认全部
//TODO 换成独立的service 继承共同的抽象服务类, 除了必要的复用,尽量从service 到 dao 独立隔离;
orderListInfoRsp = buyerOrderService.getOrderListForErpGW(orderListRequest);
break;
case SELL:
orderListRequest.setType(SellerOrderListType.ALL.getType()); // 默认全部
//TODO 换成独立的service 继承共同的抽象服务类, 除了必要的复用,尽量从service 到 dao 独立隔离;
orderListInfoRsp = sellerOrderService.getOrderListForErpGW(orderListRequest);
break;
default:
... ...
... ... @@ -43,7 +43,7 @@ public abstract class AbsOrderListService extends AbsOrderViewService implements
abstract List<Integer> initOrderListRequest(OrderListRequest request);
abstract int getTotal(int uid, Long orderCode, List<Integer> statusQuery);
abstract int getTotal(int uid, List<Integer> statusQuery);
abstract List<BuyerOrder> getOrderList(int uid, Long orderCode, List<Integer> statusQuery, int offset, int limit);
... ... @@ -79,7 +79,7 @@ public abstract class AbsOrderListService extends AbsOrderViewService implements
// check and init请求参数
List<Integer> statusQuery = initOrderListRequest(request);
TabType actor = request.getActor();
int total = getTotal(request.getUid(), request.getOrderCode(), statusQuery);
int total = getTotal(request.getUid(), statusQuery);
int limit = request.getLimit();
PageResp.PageRespBuilder respBuilder = PageResp.builder()
.page(request.getPage())
... ...
... ... @@ -87,8 +87,8 @@ public class BuyerOrderListServiceImpl extends AbsOrderListService implements IO
}
@Override
int getTotal(int uid, Long orderCode, List<Integer> statusQuery){
return buyerOrderMapper.selectCntByUidStatus(uid, orderCode, statusQuery);
int getTotal(int uid, List<Integer> statusQuery){
return buyerOrderMapper.selectCntByUidStatus(uid, statusQuery);
}
@Override
... ...
... ... @@ -363,7 +363,7 @@ public class SellerOrderListService extends AbsOrderListService implements IOrde
}
@Override
int getTotal(int uid, Long orderCode, List<Integer> statusQuery) {
int getTotal(int uid, List<Integer> statusQuery) {
return buyerOrderMapper.selectCntBySellerUidStatus(uid, statusQuery);
}
... ...
package com.yohoufo.order.service.impl;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.dal.order.BuyerOrderMapper;
import com.yohoufo.order.utils.LoggerUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
/**
* 购物分控
*/
@Component
public class ShoppingRiskWatchDog {
private Logger logger = LoggerUtils.getBuyerOrderLogger();
private static final int waitingPayCnt = 1;
@Autowired
private BuyerOrderMapper buyerOrderMapper;
public void checkWaitingPayCnt(int uid){
logger.info("in ShoppingRiskWatchDog.checkWaitingPayCnt uid {}", uid);
List<Integer> statusList = new ArrayList<>(1);
statusList.add(OrderStatus.WAITING_PAY.getCode());
int cnt = buyerOrderMapper.selectCntByUidStatus(uid, statusList);
if (cnt >= waitingPayCnt){
logger.warn("in ShoppingRiskWatchDog.checkWaitingPayCnt try monopolizing skup another time,uid {} waiting pay cnt {}",
uid, cnt);
throw new UfoServiceException(512, "您有未支付的订单,支付或取消后可提交新的订单");
}
}
}
... ...
... ... @@ -107,6 +107,9 @@ public class ShoppingServiceImpl implements IShoppingService {
@Autowired
private CouponService couponService;
@Autowired
private ShoppingRiskWatchDog shoppingRiskWatchDog;
/**
* 结算页数据
* @param request
... ... @@ -120,7 +123,7 @@ public class ShoppingServiceImpl implements IShoppingService {
logger.warn("payment uid or skup is null");
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
}
shoppingRiskWatchDog.checkWaitingPayCnt(uid);
// 检查 商品sku是否可售
SellerOrderGoods skupGood = checkSkupSellOrNot(request.getSkup());
... ... @@ -269,7 +272,7 @@ public class ShoppingServiceImpl implements IShoppingService {
logger.warn("submit param is null");
throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
}
shoppingRiskWatchDog.checkWaitingPayCnt(uid);
//查询并校验用户地址
Pair<AddressInfo, AddressInfo> userAddressPair = getAndCheckAddressInfo(shoppingRequest);
... ...