...
|
...
|
@@ -40,7 +40,10 @@ import com.yohoufo.order.service.seller.support.SkupTypeCodeSupport; |
|
|
import com.yohoufo.order.utils.LoggerUtils;
|
|
|
import com.yohoufo.order.utils.OrderAssist;
|
|
|
import com.yohoufo.order.utils.PaymentHelper;
|
|
|
import lombok.Builder;
|
|
|
import lombok.Data;
|
|
|
import lombok.Setter;
|
|
|
import lombok.val;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
...
|
...
|
@@ -137,7 +140,7 @@ public class BuyerOrderCancelService { |
|
|
boolean noResponsibility = Objects.isNull(penaltyAmount)
|
|
|
|| BigDecimal.ZERO.compareTo(penaltyAmount) == 0;
|
|
|
//退还优惠券
|
|
|
refundCouponIfNeed(buyerUid, orderCode);
|
|
|
asyncRefundCoupon(buyerUid, orderCode, BuyerRefundCouponEvent.BizCase.BUYER_CANCEL_BSD);
|
|
|
int skup = bsdEvent.getSkup();
|
|
|
SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(skup);
|
|
|
int targetGoodsStatus = SkupStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER.getCode();
|
...
|
...
|
@@ -275,7 +278,7 @@ public class BuyerOrderCancelService { |
|
|
boolean noResponsibility = Objects.isNull(penaltyAmount)
|
|
|
|| BigDecimal.ZERO.compareTo(penaltyAmount) == 0;
|
|
|
//退还优惠券
|
|
|
refundCouponIfNeed(buyerUid, orderCode);
|
|
|
asyncRefundCoupon(buyerUid, orderCode, BuyerRefundCouponEvent.BizCase.BUYER_CANCEL_BDR);
|
|
|
|
|
|
int skup = bdrEvent.getSkup();
|
|
|
SellerOrderGoods targetGoods = new SellerOrderGoods();
|
...
|
...
|
@@ -346,10 +349,12 @@ public class BuyerOrderCancelService { |
|
|
return;
|
|
|
}
|
|
|
OrderStatus targetStatus = null;
|
|
|
Consumer<BuyerOrder> consumer = null;
|
|
|
Consumer<RefundGoodsAmoutNode> consumer = null;
|
|
|
boolean needCompensateCoupon = false;
|
|
|
switch (failType){
|
|
|
case PLATFORM:
|
|
|
targetStatus = OrderStatus.PLATFORM_BLOWN_CUSTOMS_CLEARANCE;
|
|
|
needCompensateCoupon = true;
|
|
|
consumer = (buyerOrder1) -> cancelOverseasOrderByPlatform(buyerOrder1);
|
|
|
break;
|
|
|
case BUYER:
|
...
|
...
|
@@ -372,9 +377,23 @@ public class BuyerOrderCancelService { |
|
|
logger.warn("cancelOverseasOrder fail -> buyerOrderMapper.updateStatusByOrderCode, orderCode {}", orderCode);
|
|
|
return;
|
|
|
}
|
|
|
BigDecimal leftGoodsMoney = buyerOrder.getAmount();
|
|
|
|
|
|
BuyerOrderGoods pbog = buyerOrderGoodsMapper.selectOnlyByOrderCode(orderCode);
|
|
|
Integer skup = pbog.getSkup();
|
|
|
//
|
|
|
buyerOrder.setStatus(targetStatus.getCode());
|
|
|
consumer.accept(buyerOrder);
|
|
|
|
|
|
RefundGoodsAmoutNode rgaNode = RefundGoodsAmoutNode.builder()
|
|
|
.buyerOrder(buyerOrder)
|
|
|
.skup(skup)
|
|
|
.targetOrderStatus(targetStatus)
|
|
|
.leftBuyerMoney(leftGoodsMoney)
|
|
|
.needCompensateCoupon(needCompensateCoupon)
|
|
|
.build();
|
|
|
|
|
|
//
|
|
|
consumer.accept(rgaNode);
|
|
|
//
|
|
|
orderStatusFlowService.addAsy(orderCode,targetStatus.getCode());
|
|
|
}
|
...
|
...
|
@@ -384,20 +403,42 @@ public class BuyerOrderCancelService { |
|
|
* 货品平台自己吃了
|
|
|
* 买家钱退给买家
|
|
|
* 赔偿卖家ufo券 券金额还未定
|
|
|
* @param buyerOrder
|
|
|
* @param rgaNode
|
|
|
*/
|
|
|
private void cancelOverseasOrderByPlatform(BuyerOrder buyerOrder){
|
|
|
private void cancelOverseasOrderByPlatform(RefundGoodsAmoutNode rgaNode){
|
|
|
BuyerOrder buyerOrder = rgaNode.buyerOrder;
|
|
|
int skup = rgaNode.skup;
|
|
|
OrderStatus targetOrderStatus = rgaNode.targetOrderStatus;
|
|
|
BigDecimal leftBuyerMoney = rgaNode.leftBuyerMoney;
|
|
|
boolean needCompensateCoupon = rgaNode.needCompensateCoupon;
|
|
|
if (needCompensateCoupon){
|
|
|
asyncRefundCoupon(buyerOrder.getUid(), buyerOrder.getOrderCode(), BuyerRefundCouponEvent.BizCase.PLATFORM_BLOWN_CUSTOMS_CLEARANCE);
|
|
|
}
|
|
|
|
|
|
refundGoodsAmount(buyerOrder, skup, targetOrderStatus, leftBuyerMoney);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 买家原因失败
|
|
|
* 货品平台自己吃了
|
|
|
* 货款钱退给买家
|
|
|
* @param buyerOrder
|
|
|
* @param rgaNode
|
|
|
*/
|
|
|
private void cancelOverseasOrderByBuyer(BuyerOrder buyerOrder){
|
|
|
private void cancelOverseasOrderByBuyer(RefundGoodsAmoutNode rgaNode){
|
|
|
BuyerOrder buyerOrder = rgaNode.buyerOrder;
|
|
|
int skup = rgaNode.skup;
|
|
|
OrderStatus targetOrderStatus = rgaNode.targetOrderStatus;
|
|
|
BigDecimal leftBuyerMoney = rgaNode.leftBuyerMoney;
|
|
|
refundGoodsAmount(buyerOrder, skup, targetOrderStatus, leftBuyerMoney);
|
|
|
}
|
|
|
|
|
|
@Data@Builder
|
|
|
private static class RefundGoodsAmoutNode{
|
|
|
BuyerOrder buyerOrder;
|
|
|
int skup;
|
|
|
OrderStatus targetOrderStatus;
|
|
|
BigDecimal leftBuyerMoney;
|
|
|
boolean needCompensateCoupon;
|
|
|
}
|
|
|
|
|
|
private void refundGoodsAmount(BuyerOrder buyerOrder,int skup, OrderStatus targetOrderStatus, BigDecimal leftBuyerMoney){
|
...
|
...
|
@@ -428,7 +469,8 @@ public class BuyerOrderCancelService { |
|
|
BuyerOrder buyerOrder;
|
|
|
TransferCase transferCase;
|
|
|
OrderStatus targetOrderStatus;
|
|
|
boolean reSellFlag;//重新上架标志,重新上架则不退保证金了
|
|
|
//重新上架标志,重新上架则不退保证金了
|
|
|
boolean reSellFlag;
|
|
|
|
|
|
@Setter
|
|
|
SellerWalletDetail.Type swdType;
|
...
|
...
|
@@ -578,4 +620,14 @@ public class BuyerOrderCancelService { |
|
|
logger.warn("refund coupon error,uid:{},orderCode:{}", uid, orderCode, ex);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void asyncRefundCoupon(int uid, long orderCode, BuyerRefundCouponEvent.BizCase refundCouponCase) {
|
|
|
val buyerRefundCouponEvent = BuyerRefundCouponEvent.builder()
|
|
|
.bizCase(refundCouponCase)
|
|
|
.uid(uid)
|
|
|
.orderCode(orderCode)
|
|
|
.build();
|
|
|
logger.info("async refund coupon by order {} request is {}", orderCode, buyerRefundCouponEvent);
|
|
|
EventBusPublisher.publishEvent(buyerRefundCouponEvent);
|
|
|
}
|
|
|
} |
...
|
...
|
|