...
|
...
|
@@ -35,7 +35,7 @@ import java.util.function.BiConsumer; |
|
|
* @date 2019/1/8 14:07
|
|
|
*/
|
|
|
@Slf4j
|
|
|
public class BuyerOrderCancelHandler {
|
|
|
class BuyerOrderCancelHandler {
|
|
|
|
|
|
private final int uid;
|
|
|
private final long orderCode;
|
...
|
...
|
@@ -55,10 +55,8 @@ public class BuyerOrderCancelHandler { |
|
|
private TransferCase transferCase;
|
|
|
private SellerWalletDetail.Type sellerWalletDetailType;
|
|
|
|
|
|
private BiConsumer<PaymentRequest, BillLogEvent.BillLogEventBuilder> payGoodsMoneyRefundConsumer;
|
|
|
private RefundCase refundCase;
|
|
|
|
|
|
private AlarmConfig refundPayFailAlarm;
|
|
|
private BiConsumer<PaymentRequest, BillLogEvent.BillLogEventBuilder> goodsMoneyRefundConsumer;
|
|
|
private RefundCase goodsMoneyRefundCase;
|
|
|
|
|
|
private SellerNoticeSender sellerNoticeSender;
|
|
|
private SellerOrderGoodsMapper sellerOrderGoodsMapper;
|
...
|
...
|
@@ -66,6 +64,11 @@ public class BuyerOrderCancelHandler { |
|
|
|
|
|
private BuyerRefundCouponEvent.BizCase refundCouponCase;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private AlarmConfig failAlarm;
|
|
|
|
|
|
BuyerOrderCancelHandler(int uid, long orderCode) {
|
|
|
this.uid = uid;
|
|
|
this.orderCode = orderCode;
|
...
|
...
|
@@ -105,14 +108,9 @@ public class BuyerOrderCancelHandler { |
|
|
return this;
|
|
|
}
|
|
|
|
|
|
public BuyerOrderCancelHandler withRefundPay(BiConsumer<PaymentRequest, BillLogEvent.BillLogEventBuilder> payRefundConsumer, RefundCase refundCase) {
|
|
|
this.payGoodsMoneyRefundConsumer = payRefundConsumer;
|
|
|
this.refundCase = refundCase;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
public BuyerOrderCancelHandler withRefundPayFailAlarm(AlarmConfig refundPayFailAlarm) {
|
|
|
this.refundPayFailAlarm = refundPayFailAlarm;
|
|
|
public BuyerOrderCancelHandler withRefundGoodsMoney(BiConsumer<PaymentRequest, BillLogEvent.BillLogEventBuilder> refundConsumer, RefundCase refundCase) {
|
|
|
this.goodsMoneyRefundConsumer = refundConsumer;
|
|
|
this.goodsMoneyRefundCase = refundCase;
|
|
|
return this;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -128,6 +126,11 @@ public class BuyerOrderCancelHandler { |
|
|
return this;
|
|
|
}
|
|
|
|
|
|
public BuyerOrderCancelHandler withFailAlarm(AlarmConfig failAlarm) {
|
|
|
this.failAlarm = failAlarm;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
public void cancel() {
|
|
|
verify();
|
|
|
// 获取买家订单
|
...
|
...
|
@@ -194,13 +197,13 @@ public class BuyerOrderCancelHandler { |
|
|
}
|
|
|
|
|
|
private void refundPayGoodsMoney(BuyerOrder buyerOrder) {
|
|
|
if (Objects.isNull(payGoodsMoneyRefundConsumer)) {
|
|
|
if (Objects.isNull(goodsMoneyRefundConsumer)) {
|
|
|
return;
|
|
|
}
|
|
|
BigDecimal goodsMoney = buyerOrder.getAmount();
|
|
|
val paymentRequest = PaymentRequest.builder()
|
|
|
.uid(uid)
|
|
|
.refundCase(refundCase)
|
|
|
.refundCase(goodsMoneyRefundCase)
|
|
|
.orderCode(orderCode)
|
|
|
.refundAmount(goodsMoney.doubleValue())
|
|
|
.build();
|
...
|
...
|
@@ -209,19 +212,19 @@ public class BuyerOrderCancelHandler { |
|
|
.sellerUid(buyerOrder.getSellerUid())
|
|
|
.orderCode(orderCode)
|
|
|
.payType(buyerOrder.getPayment())
|
|
|
.refundCase(refundCase)
|
|
|
.refundCase(goodsMoneyRefundCase)
|
|
|
.amount(goodsMoney);
|
|
|
try {
|
|
|
payGoodsMoneyRefundConsumer.accept(paymentRequest, billLogEventBuilder.skup(getSkup()));
|
|
|
goodsMoneyRefundConsumer.accept(paymentRequest, billLogEventBuilder.skup(getSkup()));
|
|
|
} catch (Exception ex) {
|
|
|
log.warn("pay refund fail,req {}", paymentRequest, ex);
|
|
|
BillLogEvent billLogEvent = billLogEventBuilder.tradeStatus(BillTradeStatus.FAIL.getCode()).build();
|
|
|
EventBusPublisher.publishEvent(billLogEvent);
|
|
|
|
|
|
if (Objects.nonNull(refundPayFailAlarm)) {
|
|
|
if (Objects.nonNull(failAlarm)) {
|
|
|
SmsAlarmEvent smsAlarmEvent = new SmsAlarmEvent(
|
|
|
refundPayFailAlarm.getRefundName(),
|
|
|
refundPayFailAlarm.name(),
|
|
|
failAlarm.getRefundName(),
|
|
|
failAlarm.name(),
|
|
|
expectStatus.getDesc() + ",取消订单" + orderCode + "退货款失败"
|
|
|
);
|
|
|
EventBusPublisher.publishEvent(smsAlarmEvent);
|
...
|
...
|
|