...
|
...
|
@@ -2,6 +2,7 @@ package com.yohoufo.order.service.impl; |
|
|
|
|
|
import com.yohobuy.ufo.model.order.common.OrderStatus;
|
|
|
import com.yohobuy.ufo.model.order.common.SkupStatus;
|
|
|
import com.yohobuy.ufo.model.order.common.TabType;
|
|
|
import com.yohoufo.common.utils.DateUtil;
|
|
|
import com.yohoufo.dal.order.BuyerOrderMapper;
|
|
|
import com.yohoufo.dal.order.OrderCouponMapper;
|
...
|
...
|
@@ -21,6 +22,8 @@ import com.yohoufo.order.model.bo.CouponBo; |
|
|
import com.yohoufo.order.model.request.PaymentRequest;
|
|
|
import com.yohoufo.order.model.request.TransferMoneyRequest;
|
|
|
import com.yohoufo.order.service.IPaymentService;
|
|
|
import com.yohoufo.order.service.cache.CacheCleaner;
|
|
|
import com.yohoufo.order.service.cache.CacheKeyBuilder;
|
|
|
import com.yohoufo.order.service.concurrent.ThreadPoolFactory;
|
|
|
import com.yohoufo.order.service.proxy.CouponProxyService;
|
|
|
import com.yohoufo.order.utils.LoggerUtils;
|
...
|
...
|
@@ -30,6 +33,7 @@ import org.springframework.stereotype.Service; |
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.concurrent.Callable;
|
|
|
import java.util.concurrent.Future;
|
|
|
|
...
|
...
|
@@ -65,18 +69,24 @@ public class BuyerOrderCancelService { |
|
|
@Autowired
|
|
|
private PayRefundService payRefundService;
|
|
|
|
|
|
@Autowired
|
|
|
private CacheCleaner cacheCleaner;
|
|
|
|
|
|
|
|
|
public void cancel(BeforeSellerDeliverEvent bsdEvent){
|
|
|
OrderDynamicConfig.BuyerCancelCompensateNode compensate = orderDynamicConfig.getBeforeSellerDeliverBCCN();
|
|
|
|
|
|
logger.info("in buyer cancel BeforeSellerDeliver, event {} compensate {}", bsdEvent, compensate);
|
|
|
int buyerUid = bsdEvent.getBuyerUid();
|
|
|
int sellerUid = bsdEvent.getSellerUid();
|
|
|
long orderCode = bsdEvent.getOrderCode();
|
|
|
OrderStatus target = bsdEvent.getTarget();
|
|
|
OrderStatus expected = bsdEvent.getExpected();
|
|
|
int currentTime = DateUtil.getCurrentTimeSecond();
|
|
|
int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expected.getCode(), target.getCode(), currentTime);
|
|
|
if (rows>0) {
|
|
|
//退还优惠券
|
|
|
refundCouponIfNeed(buyerUid, orderCode);
|
|
|
int skup = bsdEvent.getSkup();
|
|
|
SellerOrderGoods targetGoods = new SellerOrderGoods();
|
|
|
targetGoods.setId(skup);
|
...
|
...
|
@@ -92,7 +102,12 @@ public class BuyerOrderCancelService { |
|
|
BuyerCancelAfterProcessTask bcapt = new BuyerCancelAfterProcessTask(buyerUid, orderCode, skup,
|
|
|
compensate, transferCase);
|
|
|
Future<PayRefundBo> future = ThreadPoolFactory.getBuyerCancelThreadPool().submit(bcapt);
|
|
|
|
|
|
SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
|
|
|
cacheCleaner.delete(Arrays.asList(CacheKeyBuilder.orderListKey(sellerUid, TabType.SELL.getValue()),
|
|
|
CacheKeyBuilder.orderListKey(buyerUid, TabType.BUY.getValue()),
|
|
|
CacheKeyBuilder.sellerOrderDetailKey(psog),
|
|
|
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderCode),
|
|
|
CacheKeyBuilder.orderDetailKey(buyerUid, TabType.BUY.getValue(), orderCode)));
|
|
|
logger.info("use one thread to execute buyer cancel BeforeSellerDeliver buyerUid {}, orderCode {}, skup {}, compensate {}, transferCase {}",
|
|
|
buyerUid, orderCode, skup, compensate, transferCase);
|
|
|
}
|
...
|
...
|
@@ -106,10 +121,14 @@ public class BuyerOrderCancelService { |
|
|
OrderStatus target = bdrEvent.getTarget();
|
|
|
OrderStatus expected = bdrEvent.getExpected();
|
|
|
int buyerUid = bdrEvent.getBuyerUid();
|
|
|
int sellerUid = bdrEvent.getSellerUid();
|
|
|
long orderCode = bdrEvent.getOrderCode();
|
|
|
int currentTime = DateUtil.getCurrentTimeSecond();
|
|
|
int rows = buyerOrderMapper.updateStatusByOrderCode(orderCode, buyerUid, expected.getCode(), target.getCode(), currentTime);
|
|
|
if (rows>0) {
|
|
|
//退还优惠券
|
|
|
refundCouponIfNeed(buyerUid, orderCode);
|
|
|
|
|
|
int skup = bdrEvent.getSkup();
|
|
|
SellerOrderGoods targetGoods = new SellerOrderGoods();
|
|
|
targetGoods.setId(skup);
|
...
|
...
|
@@ -125,7 +144,12 @@ public class BuyerOrderCancelService { |
|
|
BuyerCancelAfterProcessTask bcapt = new BuyerCancelAfterProcessTask(buyerUid, orderCode, skup,
|
|
|
compensate, transferCase);
|
|
|
Future<PayRefundBo> future = ThreadPoolFactory.getBuyerCancelThreadPool().submit(bcapt);
|
|
|
|
|
|
SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
|
|
|
cacheCleaner.delete(Arrays.asList(CacheKeyBuilder.orderListKey(sellerUid, TabType.SELL.getValue()),
|
|
|
CacheKeyBuilder.orderListKey(buyerUid, TabType.BUY.getValue()),
|
|
|
CacheKeyBuilder.sellerOrderDetailKey(psog),
|
|
|
CacheKeyBuilder.orderDetailKey(sellerUid, TabType.SELL.getValue(), orderCode),
|
|
|
CacheKeyBuilder.orderDetailKey(buyerUid, TabType.BUY.getValue(), orderCode)));
|
|
|
logger.info("use one thread to execute buyer cancel BeforeDepotReceive buyerUid {}, orderCode {}, skup {}, compensate {}, transferCase {}",
|
|
|
buyerUid, orderCode, skup, compensate, transferCase);
|
|
|
}
|
...
|
...
|
|