|
|
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, "您有未支付的订单,支付或取消后可提交新的订单");
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|