Commit d4f79d98 authored by shiyu's avatar shiyu

直接换商品限制每人一单

parent e5d84c26
...@@ -17,7 +17,6 @@ public class DistributionEnum { ...@@ -17,7 +17,6 @@ public class DistributionEnum {
SIGNED(90, "已签收"), SIGNED(90, "已签收"),
FINISH(100, "已完成"), FINISH(100, "已完成"),
CANCEL(101, "已取消"), CANCEL(101, "已取消"),
; ;
private int code; private int code;
......
...@@ -173,6 +173,13 @@ public interface DistributionOrderDao { ...@@ -173,6 +173,13 @@ public interface DistributionOrderDao {
*/ */
List<DistributionOrderNum> countGroupByStateForExchange(long userId); List<DistributionOrderNum> countGroupByStateForExchange(long userId);
/**
* 统计和平台交换的订单数量
* @param userId
* @return
*/
long countExchangeOrderNum(long userId, long sellerId);
boolean isBuyItem(long buyerId, long itemId); boolean isBuyItem(long buyerId, long itemId);
} }
...@@ -236,6 +236,17 @@ public class DistributionOrderDaoImpl implements DistributionOrderDao { ...@@ -236,6 +236,17 @@ public class DistributionOrderDaoImpl implements DistributionOrderDao {
return distributionOrderMapper.countGroupByStateForExchange(userId); 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 @Override
public boolean isBuyItem(long buyerId, long itemId) { public boolean isBuyItem(long buyerId, long itemId) {
DistributionOrderExample example = new DistributionOrderExample(); DistributionOrderExample example = new DistributionOrderExample();
......
...@@ -459,7 +459,7 @@ public class ExchangeApplyOrderServiceImpl implements ExchangeApplyOrderService ...@@ -459,7 +459,7 @@ public class ExchangeApplyOrderServiceImpl implements ExchangeApplyOrderService
long diffInMillies = Math.abs(new Date().getTime() - exchangeApplyOrder.getCreateTime().getTime()); long diffInMillies = Math.abs(new Date().getTime() - exchangeApplyOrder.getCreateTime().getTime());
//超出48小时未处理审批单,订单取消 //超出48小时未处理审批单,订单取消
long diffInHours = diffInMillies / (60 * 1000 * 60); long diffInHours = diffInMillies / (60 * 1000 * 60);
if (diffInHours >= 48) { if (diffInHours >= 192) {
//取消申请单,把订单明细设置为无效 //取消申请单,把订单明细设置为无效
exchangeApplyOrderDao.updateState(orderId, ExchangeApplyOrderEnum.StateEnum.DISAGREE.getCode()); exchangeApplyOrderDao.updateState(orderId, ExchangeApplyOrderEnum.StateEnum.DISAGREE.getCode());
exchangeApplyOrderDetailDao.updateInValid(orderId); exchangeApplyOrderDetailDao.updateInValid(orderId);
...@@ -476,7 +476,7 @@ public class ExchangeApplyOrderServiceImpl implements ExchangeApplyOrderService ...@@ -476,7 +476,7 @@ public class ExchangeApplyOrderServiceImpl implements ExchangeApplyOrderService
long diffInMillies = Math.abs(new Date().getTime() - exchangeApplyOrder.getCreateTime().getTime()); long diffInMillies = Math.abs(new Date().getTime() - exchangeApplyOrder.getCreateTime().getTime());
//超出48小时未处理审批单,订单取消 //超出48小时未处理审批单,订单取消
long diffInHours = diffInMillies / (60 * 1000 * 60); long diffInHours = diffInMillies / (60 * 1000 * 60);
if (diffInHours >= 48) { if (diffInHours >= 192) {
//取消申请单,把订单明细设置为无效 //取消申请单,把订单明细设置为无效
exchangeApplyOrderDao.updateState(orderId, ExchangeApplyOrderEnum.StateEnum.DISAGREE.getCode()); exchangeApplyOrderDao.updateState(orderId, ExchangeApplyOrderEnum.StateEnum.DISAGREE.getCode());
exchangeApplyOrderDetailDao.updateInValid(orderId); exchangeApplyOrderDetailDao.updateInValid(orderId);
...@@ -495,7 +495,7 @@ public class ExchangeApplyOrderServiceImpl implements ExchangeApplyOrderService ...@@ -495,7 +495,7 @@ public class ExchangeApplyOrderServiceImpl implements ExchangeApplyOrderService
long diffInMillies = Math.abs(new Date().getTime() - exchangeApplyOrder.getCreateTime().getTime()); long diffInMillies = Math.abs(new Date().getTime() - exchangeApplyOrder.getCreateTime().getTime());
//超出48小时未处理审批单,订单取消 //超出48小时未处理审批单,订单取消
long diffInHours = diffInMillies / (60 * 1000 * 60); long diffInHours = diffInMillies / (60 * 1000 * 60);
if (diffInHours >= 48) { if (diffInHours >= 192) {
//取消申请单,把订单明细设置为无效 //取消申请单,把订单明细设置为无效
exchangeApplyOrderDao.updateState(exchangeApplyOrderId, ExchangeApplyOrderEnum.StateEnum.DISAGREE.getCode()); exchangeApplyOrderDao.updateState(exchangeApplyOrderId, ExchangeApplyOrderEnum.StateEnum.DISAGREE.getCode());
exchangeApplyOrderDetailDao.updateInValid(exchangeApplyOrderId); exchangeApplyOrderDetailDao.updateInValid(exchangeApplyOrderId);
......
...@@ -276,7 +276,7 @@ public class ExchangeOrderServiceImpl implements ExchangeOrderService { ...@@ -276,7 +276,7 @@ public class ExchangeOrderServiceImpl implements ExchangeOrderService {
long diffInMillies = Math.abs(new Date().getTime() - distributionOrder.getCreateTime().getTime()); long diffInMillies = Math.abs(new Date().getTime() - distributionOrder.getCreateTime().getTime());
//超出48小时未寄出,订单取消 //超出48小时未寄出,订单取消
long diffInHours = diffInMillies / (60 * 1000 * 60); long diffInHours = diffInMillies / (60 * 1000 * 60);
if (diffInHours >= 48) { if (diffInHours >= 192) {
//换藏的品取消订单后恢复库存 //换藏的品取消订单后恢复库存
ExchangeApplyOrder exchangeApplyOrder = exchangeApplyOrderDao.findByExchangeOrderId(orderId); ExchangeApplyOrder exchangeApplyOrder = exchangeApplyOrderDao.findByExchangeOrderId(orderId);
if (exchangeApplyOrder != null) { if (exchangeApplyOrder != null) {
......
...@@ -37,6 +37,8 @@ public class ExchangeServiceImpl implements ExchangeService { ...@@ -37,6 +37,8 @@ public class ExchangeServiceImpl implements ExchangeService {
private static final Logger logger = LoggerFactory.getLogger(DistributorProfitServiceImpl.class); private static final Logger logger = LoggerFactory.getLogger(DistributorProfitServiceImpl.class);
private static final List<Long> BLACK_USER_LIST = Arrays.asList(40151043L, 39965054L);
@Autowired @Autowired
DistributionOrderDao distributionOrderDao; DistributionOrderDao distributionOrderDao;
...@@ -238,6 +240,15 @@ public class ExchangeServiceImpl implements ExchangeService { ...@@ -238,6 +240,15 @@ public class ExchangeServiceImpl implements ExchangeService {
try { try {
Long exchangeItemId = null; Long exchangeItemId = null;
long exchangeItemPrice = 0; 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()) { 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