Commit d4f79d98 authored by shiyu's avatar shiyu

直接换商品限制每人一单

parent e5d84c26
......@@ -17,7 +17,6 @@ public class DistributionEnum {
SIGNED(90, "已签收"),
FINISH(100, "已完成"),
CANCEL(101, "已取消"),
;
private int code;
......
......@@ -173,6 +173,13 @@ public interface DistributionOrderDao {
*/
List<DistributionOrderNum> countGroupByStateForExchange(long userId);
/**
* 统计和平台交换的订单数量
* @param userId
* @return
*/
long countExchangeOrderNum(long userId, long sellerId);
boolean isBuyItem(long buyerId, long itemId);
}
......@@ -236,6 +236,17 @@ public class DistributionOrderDaoImpl implements DistributionOrderDao {
return distributionOrderMapper.countGroupByStateForExchange(userId);
}
@Override
public long countExchangeOrderNum(long userId, long sellerId) {
DistributionOrderExample example = new DistributionOrderExample();
DistributionOrderExample.Criteria criteria = example.createCriteria();
criteria.andBuyerIdEqualTo(userId);
criteria.andSellerIdEqualTo(sellerId);
criteria.andTypeEqualTo(7);
criteria.andStateIn(Arrays.asList(6, 8, 10, 20 ,30, 90, 100));
return distributionOrderMapper.countByExample(example);
}
@Override
public boolean isBuyItem(long buyerId, long itemId) {
DistributionOrderExample example = new DistributionOrderExample();
......
......@@ -459,7 +459,7 @@ public class ExchangeApplyOrderServiceImpl implements ExchangeApplyOrderService
long diffInMillies = Math.abs(new Date().getTime() - exchangeApplyOrder.getCreateTime().getTime());
//超出48小时未处理审批单,订单取消
long diffInHours = diffInMillies / (60 * 1000 * 60);
if (diffInHours >= 48) {
if (diffInHours >= 192) {
//取消申请单,把订单明细设置为无效
exchangeApplyOrderDao.updateState(orderId, ExchangeApplyOrderEnum.StateEnum.DISAGREE.getCode());
exchangeApplyOrderDetailDao.updateInValid(orderId);
......@@ -476,7 +476,7 @@ public class ExchangeApplyOrderServiceImpl implements ExchangeApplyOrderService
long diffInMillies = Math.abs(new Date().getTime() - exchangeApplyOrder.getCreateTime().getTime());
//超出48小时未处理审批单,订单取消
long diffInHours = diffInMillies / (60 * 1000 * 60);
if (diffInHours >= 48) {
if (diffInHours >= 192) {
//取消申请单,把订单明细设置为无效
exchangeApplyOrderDao.updateState(orderId, ExchangeApplyOrderEnum.StateEnum.DISAGREE.getCode());
exchangeApplyOrderDetailDao.updateInValid(orderId);
......@@ -495,7 +495,7 @@ public class ExchangeApplyOrderServiceImpl implements ExchangeApplyOrderService
long diffInMillies = Math.abs(new Date().getTime() - exchangeApplyOrder.getCreateTime().getTime());
//超出48小时未处理审批单,订单取消
long diffInHours = diffInMillies / (60 * 1000 * 60);
if (diffInHours >= 48) {
if (diffInHours >= 192) {
//取消申请单,把订单明细设置为无效
exchangeApplyOrderDao.updateState(exchangeApplyOrderId, ExchangeApplyOrderEnum.StateEnum.DISAGREE.getCode());
exchangeApplyOrderDetailDao.updateInValid(exchangeApplyOrderId);
......
......@@ -276,7 +276,7 @@ public class ExchangeOrderServiceImpl implements ExchangeOrderService {
long diffInMillies = Math.abs(new Date().getTime() - distributionOrder.getCreateTime().getTime());
//超出48小时未寄出,订单取消
long diffInHours = diffInMillies / (60 * 1000 * 60);
if (diffInHours >= 48) {
if (diffInHours >= 192) {
//换藏的品取消订单后恢复库存
ExchangeApplyOrder exchangeApplyOrder = exchangeApplyOrderDao.findByExchangeOrderId(orderId);
if (exchangeApplyOrder != null) {
......
......@@ -37,6 +37,8 @@ public class ExchangeServiceImpl implements ExchangeService {
private static final Logger logger = LoggerFactory.getLogger(DistributorProfitServiceImpl.class);
private static final List<Long> BLACK_USER_LIST = Arrays.asList(40151043L, 39965054L);
@Autowired
DistributionOrderDao distributionOrderDao;
......@@ -238,6 +240,15 @@ public class ExchangeServiceImpl implements ExchangeService {
try {
Long exchangeItemId = null;
long exchangeItemPrice = 0;
if (BLACK_USER_LIST.contains(dto.getUserId())) {
return Result.failed("可直接换的商品每人限换一单");
}
//判断是否有和平台交换的订单
long orderNum = distributionOrderDao.countExchangeOrderNum(dto.getUserId(), CommConsts.SELF_SUPPORT_ACCOUNT);
if (orderNum > 0) {
return Result.failed("可直接换的商品每人限换一单");
}
if (dto.getIsMultiple()) {
//多商品场景在受理方订单中出现,别人用多件商品换受理方的一件商品,对于受理方而言等于是一个订单买了多件商品,
// 由于在创建申请方订单时已经扣除过库存,所以这里无需扣减库存,也不校验库存
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment