Merge branch 'dev6.8.5-cancelorder' into test6.8.5
Showing
9 changed files
with
90 additions
and
90 deletions
@@ -6,24 +6,20 @@ import java.util.Optional; | @@ -6,24 +6,20 @@ import java.util.Optional; | ||
6 | import java.util.function.Supplier; | 6 | import java.util.function.Supplier; |
7 | 7 | ||
8 | /** | 8 | /** |
9 | - * 1:鉴定通过(货款-->卖家 + 平台); | 9 | + * 1:鉴定通过(货款-->卖家 + 平台); |
10 | * 2:鉴定不通过(保证金 --> 买家 + 平台); | 10 | * 2:鉴定不通过(保证金 --> 买家 + 平台); |
11 | - * 3:有买家时卖家不卖了(保证金 --> 买家+ 平台) | ||
12 | - * 4:超时发货(保证金 --> 买家 + 平台) | ||
13 | - * Created by chenchao on 2018/10/9. | ||
14 | - * 5:买家付款后[卖家未发货],取消订单(货款部分-->卖家); | 11 | + * 3:保证金 --> 买家+ 平台 |
12 | + * 5:买家付款后[卖家未发货],取消订单(货款部分-->卖家); | ||
15 | * 6:买家付款后[卖家已发货],取消订单(货款部分-->卖家); | 13 | * 6:买家付款后[卖家已发货],取消订单(货款部分-->卖家); |
14 | + * 100:保证金->买家 | ||
16 | */ | 15 | */ |
17 | public enum TransferCase { | 16 | public enum TransferCase { |
18 | 17 | ||
19 | - | ||
20 | APPRAISE_SUCCESS(1, "鉴定通过[货款->卖家]"), | 18 | APPRAISE_SUCCESS(1, "鉴定通过[货款->卖家]"), |
21 | APPRAISE_FAIL(2, "鉴定不通过[保证金->买家]"), | 19 | APPRAISE_FAIL(2, "鉴定不通过[保证金->买家]"), |
22 | - SELLER_PLAY_BUYER(3,"有买家时卖家不卖[保证金->买家]"), | ||
23 | - DELIVER_TIME_OUT(4,"卖家超时发货[保证金->买家]"), | 20 | + EARNEST_MONEY_TO_BUYER(3,"保证金->买家"), |
24 | BUYER_CANCEL_BEFORE_SELLER_DELIVER(5,"卖家未发货时买家取消[部分货款->卖家]"), | 21 | BUYER_CANCEL_BEFORE_SELLER_DELIVER(5,"卖家未发货时买家取消[部分货款->卖家]"), |
25 | - BUYER_CANCEL_BEFORE_DEPOT_RECEIVE(6,"卖家已发货时买家取消[部分货款->卖家]"), | ||
26 | - CS_CANCEL_BEFORE_DEPOT_RECEIVE(7,"鉴定中心收货前客服取消[保证金->买家]"); | 22 | + BUYER_CANCEL_BEFORE_DEPOT_RECEIVE(6,"卖家已发货时买家取消[部分货款->卖家]"); |
27 | 23 | ||
28 | private int code; | 24 | private int code; |
29 | private String info; | 25 | private String info; |
1 | package com.yohoufo.order.constants; | 1 | package com.yohoufo.order.constants; |
2 | 2 | ||
3 | +import lombok.Getter; | ||
4 | + | ||
3 | /** | 5 | /** |
4 | * Created by chenchao on 2018/10/16. | 6 | * Created by chenchao on 2018/10/16. |
5 | */ | 7 | */ |
6 | public enum AlarmConfig { | 8 | public enum AlarmConfig { |
7 | 9 | ||
10 | + APPRAISE_SUCCESS("鉴定通过", | ||
11 | + "buyerOrder.transferGoodsMoney", | ||
12 | + "buyerOrder.refundEarnestMoney"), | ||
13 | + | ||
14 | + APPRAISE_FAIL("鉴定不通过", | ||
15 | + "buyerOrder.transferEarnestMoney", | ||
16 | + "buyerOrder.refundGoodsMoney"), | ||
17 | + | ||
18 | + SELLER_PLAY_BUYER("卖家取消", | ||
19 | + "buyerOrder.transferEarnestMoney", | ||
20 | + "buyerOrder.refundGoodsMoney"), | ||
21 | + | ||
22 | + DELIVER_TIME_OUT("卖家发货超时", | ||
23 | + "buyerOrder.transferEarnestMoney", | ||
24 | + "buyerOrder.refundGoodsMoney"), | ||
8 | 25 | ||
9 | - APPRAISE_SUCCESS("buyerOrder.transferGoodsMoney","buyerOrder.refundEarnestMoney"), | ||
10 | - APPRAISE_FAIL("buyerOrder.transferEarnestMoney","buyerOrder.refundGoodsMoney"), | ||
11 | - SELLER_PLAY_BUYER("buyerOrder.transferEarnestMoney","buyerOrder.refundGoodsMoney"), | ||
12 | - DELIVER_TIME_OUT("buyerOrder.transferEarnestMoney","buyerOrder.refundGoodsMoney"), | ||
13 | - CS_CANCEL_BEFORE_DEPOT_RECEIVE("buyerOrder.transferEarnestMoney","buyerOrder.refundGoodsMoney"); | 26 | + CS_CANCEL_BEFORE_DEPOT_RECEIVE("鉴定中心收货前客服取消", |
27 | + "buyerOrder.transferEarnestMoney", | ||
28 | + "buyerOrder.refundGoodsMoney"); | ||
14 | 29 | ||
30 | + @Getter | ||
31 | + private String desc; | ||
15 | private String transferName; | 32 | private String transferName; |
16 | private String refundName; | 33 | private String refundName; |
17 | 34 | ||
18 | - AlarmConfig(String transferName, String refundName) { | 35 | + AlarmConfig(String desc, String transferName, String refundName) { |
36 | + this.desc = desc; | ||
19 | this.transferName = transferName; | 37 | this.transferName = transferName; |
20 | this.refundName = refundName; | 38 | this.refundName = refundName; |
21 | } | 39 | } |
@@ -2,6 +2,7 @@ package com.yohoufo.order.model.request; | @@ -2,6 +2,7 @@ package com.yohoufo.order.model.request; | ||
2 | 2 | ||
3 | import com.yohoufo.dal.order.model.SellerWalletDetail; | 3 | import com.yohoufo.dal.order.model.SellerWalletDetail; |
4 | import com.yohoufo.order.common.TransferCase; | 4 | import com.yohoufo.order.common.TransferCase; |
5 | +import com.yohoufo.order.constants.AlarmConfig; | ||
5 | import lombok.AllArgsConstructor; | 6 | import lombok.AllArgsConstructor; |
6 | import lombok.Data; | 7 | import lombok.Data; |
7 | import lombok.NoArgsConstructor; | 8 | import lombok.NoArgsConstructor; |
@@ -37,9 +38,12 @@ public class TransferMoneyRequest { | @@ -37,9 +38,12 @@ public class TransferMoneyRequest { | ||
37 | 38 | ||
38 | private TransferCase transferCase; | 39 | private TransferCase transferCase; |
39 | 40 | ||
41 | + private AlarmConfig alarmConfig; | ||
42 | + | ||
40 | public TransferMoneyRequest(long buyerOrderCode, long sellerOrderCode, int type) { | 43 | public TransferMoneyRequest(long buyerOrderCode, long sellerOrderCode, int type) { |
41 | this.buyerOrderCode = buyerOrderCode; | 44 | this.buyerOrderCode = buyerOrderCode; |
42 | this.sellerOrderCode = sellerOrderCode; | 45 | this.sellerOrderCode = sellerOrderCode; |
43 | this.type = type; | 46 | this.type = type; |
44 | } | 47 | } |
48 | + | ||
45 | } | 49 | } |
@@ -141,8 +141,12 @@ public class AppraiseService { | @@ -141,8 +141,12 @@ public class AppraiseService { | ||
141 | tso.setExceptStatus(expectSOStatus.getCode()); | 141 | tso.setExceptStatus(expectSOStatus.getCode()); |
142 | int soCnt = sellerOrderMapper.updateByOrderCode(tso); | 142 | int soCnt = sellerOrderMapper.updateByOrderCode(tso); |
143 | TransferCase transferCase = TransferCase.APPRAISE_SUCCESS; | 143 | TransferCase transferCase = TransferCase.APPRAISE_SUCCESS; |
144 | - TransferMoneyRequest tmReq = TransferMoneyRequest.builder().buyerOrderCode(orderCode) | ||
145 | - .type(transferCase.getCode()).transferCase(transferCase).build(); | 144 | + TransferMoneyRequest tmReq = TransferMoneyRequest.builder() |
145 | + .buyerOrderCode(orderCode) | ||
146 | + .type(transferCase.getCode()) | ||
147 | + .transferCase(transferCase) | ||
148 | + .alarmConfig(AlarmConfig.APPRAISE_SUCCESS) | ||
149 | + .build(); | ||
146 | 150 | ||
147 | //先校验,提前把错误抛出 | 151 | //先校验,提前把错误抛出 |
148 | paymentService.transferMonCheck(tmReq); | 152 | paymentService.transferMonCheck(tmReq); |
@@ -491,8 +495,13 @@ public class AppraiseService { | @@ -491,8 +495,13 @@ public class AppraiseService { | ||
491 | 495 | ||
492 | //将卖家的保证金分账给平台和买家 | 496 | //将卖家的保证金分账给平台和买家 |
493 | TransferCase transferCase = TransferCase.APPRAISE_FAIL; | 497 | TransferCase transferCase = TransferCase.APPRAISE_FAIL; |
494 | - TransferMoneyRequest tmReq = TransferMoneyRequest.builder().buyerOrderCode(orderCode) | ||
495 | - .type(transferCase.getCode()).swdType(SellerWalletDetail.Type.APPRAISE_FAIL).transferCase(transferCase).build(); | 498 | + TransferMoneyRequest tmReq = TransferMoneyRequest.builder() |
499 | + .buyerOrderCode(orderCode) | ||
500 | + .type(transferCase.getCode()) | ||
501 | + .transferCase(transferCase) | ||
502 | + .swdType(SellerWalletDetail.Type.APPRAISE_FAIL) | ||
503 | + .alarmConfig(AlarmConfig.APPRAISE_FAIL) | ||
504 | + .build(); | ||
496 | 505 | ||
497 | //先校验,提前把错误抛出 | 506 | //先校验,提前把错误抛出 |
498 | paymentService.transferMonCheck(tmReq); | 507 | paymentService.transferMonCheck(tmReq); |
@@ -54,7 +54,6 @@ class BuyerOrderCancelHandler { | @@ -54,7 +54,6 @@ class BuyerOrderCancelHandler { | ||
54 | private BuyerOrderGoodsMapper buyerOrderGoodsMapper; | 54 | private BuyerOrderGoodsMapper buyerOrderGoodsMapper; |
55 | 55 | ||
56 | private TransferService transferService; | 56 | private TransferService transferService; |
57 | - private int transferType; | ||
58 | private TransferCase transferCase; | 57 | private TransferCase transferCase; |
59 | private SellerWalletDetail.Type sellerWalletDetailType; | 58 | private SellerWalletDetail.Type sellerWalletDetailType; |
60 | 59 | ||
@@ -85,11 +84,9 @@ class BuyerOrderCancelHandler { | @@ -85,11 +84,9 @@ class BuyerOrderCancelHandler { | ||
85 | } | 84 | } |
86 | 85 | ||
87 | public BuyerOrderCancelHandler withTransfer(TransferService transferService, | 86 | public BuyerOrderCancelHandler withTransfer(TransferService transferService, |
88 | - int transferType, | ||
89 | TransferCase transferCase, | 87 | TransferCase transferCase, |
90 | SellerWalletDetail.Type sellerWalletDetailType) { | 88 | SellerWalletDetail.Type sellerWalletDetailType) { |
91 | this.transferService = transferService; | 89 | this.transferService = transferService; |
92 | - this.transferType = transferType; | ||
93 | this.transferCase = transferCase; | 90 | this.transferCase = transferCase; |
94 | this.sellerWalletDetailType = sellerWalletDetailType; | 91 | this.sellerWalletDetailType = sellerWalletDetailType; |
95 | return this; | 92 | return this; |
@@ -182,9 +179,10 @@ class BuyerOrderCancelHandler { | @@ -182,9 +179,10 @@ class BuyerOrderCancelHandler { | ||
182 | } | 179 | } |
183 | val transferMoneyRequest = TransferMoneyRequest.builder() | 180 | val transferMoneyRequest = TransferMoneyRequest.builder() |
184 | .buyerOrderCode(orderCode) | 181 | .buyerOrderCode(orderCode) |
185 | - .type(transferType) | 182 | + .type(transferCase.getCode()) |
186 | .transferCase(transferCase) | 183 | .transferCase(transferCase) |
187 | .swdType(sellerWalletDetailType) | 184 | .swdType(sellerWalletDetailType) |
185 | + .alarmConfig(failAlarm) | ||
188 | .build(); | 186 | .build(); |
189 | log.info("transfer by order {} request is {}", orderCode, transferMoneyRequest); | 187 | log.info("transfer by order {} request is {}", orderCode, transferMoneyRequest); |
190 | transferService.transfer(transferMoneyRequest); | 188 | transferService.transfer(transferMoneyRequest); |
@@ -155,7 +155,7 @@ public class BuyerOrderCancelService { | @@ -155,7 +155,7 @@ public class BuyerOrderCancelService { | ||
155 | // 已付款 -> 超时未发货取消 | 155 | // 已付款 -> 超时未发货取消 |
156 | .withStateTransition(OrderStatus.HAS_PAYED, OrderStatus.SEND_OUT_TIMEOUT, orderStatusFlowService) | 156 | .withStateTransition(OrderStatus.HAS_PAYED, OrderStatus.SEND_OUT_TIMEOUT, orderStatusFlowService) |
157 | // 保证金分账给平台和买家 | 157 | // 保证金分账给平台和买家 |
158 | - .withTransfer(transferService, TransferCase.SELLER_PLAY_BUYER.getCode(), TransferCase.DELIVER_TIME_OUT, SellerWalletDetail.Type.SELLER_OVER_TIME) | 158 | + .withTransfer(transferService, TransferCase.EARNEST_MONEY_TO_BUYER, SellerWalletDetail.Type.SELLER_OVER_TIME) |
159 | // 退买家货款 | 159 | // 退买家货款 |
160 | .withRefundGoodsMoney(payRefundService::refund).refundCase(RefundCase.BUYER_GOODS_MONEY).skup(skup).and() | 160 | .withRefundGoodsMoney(payRefundService::refund).refundCase(RefundCase.BUYER_GOODS_MONEY).skup(skup).and() |
161 | .withFailAlarm(AlarmConfig.DELIVER_TIME_OUT) | 161 | .withFailAlarm(AlarmConfig.DELIVER_TIME_OUT) |
@@ -172,7 +172,7 @@ public class BuyerOrderCancelService { | @@ -172,7 +172,7 @@ public class BuyerOrderCancelService { | ||
172 | // 卖家发货 -> 鉴定中心收货前客服取消 | 172 | // 卖家发货 -> 鉴定中心收货前客服取消 |
173 | .withStateTransition(OrderStatus.SELLER_SEND_OUT, OrderStatus.CS_CANCEL_BEFORE_DEPOT_RECEIVE, orderStatusFlowService) | 173 | .withStateTransition(OrderStatus.SELLER_SEND_OUT, OrderStatus.CS_CANCEL_BEFORE_DEPOT_RECEIVE, orderStatusFlowService) |
174 | // 保证金分账给平台和买家 | 174 | // 保证金分账给平台和买家 |
175 | - .withTransfer(transferService, TransferCase.CS_CANCEL_BEFORE_DEPOT_RECEIVE.getCode(), TransferCase.CS_CANCEL_BEFORE_DEPOT_RECEIVE, SellerWalletDetail.Type.CS_CANCEL_BEFORE_DEPOT_RECEIVE) | 175 | + .withTransfer(transferService, TransferCase.EARNEST_MONEY_TO_BUYER, SellerWalletDetail.Type.CS_CANCEL_BEFORE_DEPOT_RECEIVE) |
176 | // 退买家货款 | 176 | // 退买家货款 |
177 | .withRefundGoodsMoney(payRefundService::refund).refundCase(RefundCase.BUYER_GOODS_MONEY).and() | 177 | .withRefundGoodsMoney(payRefundService::refund).refundCase(RefundCase.BUYER_GOODS_MONEY).and() |
178 | // 通知卖家涉及虚假发货 | 178 | // 通知卖家涉及虚假发货 |
@@ -46,17 +46,13 @@ import com.yohoufo.order.utils.PaymentHelper; | @@ -46,17 +46,13 @@ import com.yohoufo.order.utils.PaymentHelper; | ||
46 | import org.apache.commons.collections.CollectionUtils; | 46 | import org.apache.commons.collections.CollectionUtils; |
47 | import org.apache.commons.lang3.StringUtils; | 47 | import org.apache.commons.lang3.StringUtils; |
48 | import org.slf4j.Logger; | 48 | import org.slf4j.Logger; |
49 | -import org.slf4j.LoggerFactory; | ||
50 | import org.springframework.beans.factory.annotation.Autowired; | 49 | import org.springframework.beans.factory.annotation.Autowired; |
51 | -import org.springframework.beans.factory.annotation.Value; | ||
52 | import org.springframework.stereotype.Service; | 50 | import org.springframework.stereotype.Service; |
53 | 51 | ||
54 | import java.math.BigDecimal; | 52 | import java.math.BigDecimal; |
55 | import java.util.Date; | 53 | import java.util.Date; |
56 | import java.util.Objects; | 54 | import java.util.Objects; |
57 | 55 | ||
58 | -import javax.annotation.PostConstruct; | ||
59 | - | ||
60 | 56 | ||
61 | @Service | 57 | @Service |
62 | public class PaymentServiceImpl implements IPaymentService { | 58 | public class PaymentServiceImpl implements IPaymentService { |
@@ -530,9 +526,7 @@ public class PaymentServiceImpl implements IPaymentService { | @@ -530,9 +526,7 @@ public class PaymentServiceImpl implements IPaymentService { | ||
530 | long sellerOrderCode = sellerOrder.getOrderCode(); | 526 | long sellerOrderCode = sellerOrder.getOrderCode(); |
531 | punishEarnest(request.getSwdType(), sellerOrder); | 527 | punishEarnest(request.getSwdType(), sellerOrder); |
532 | TargetUserType targetUserType = (transferCase == TransferCase.APPRAISE_FAIL | 528 | TargetUserType targetUserType = (transferCase == TransferCase.APPRAISE_FAIL |
533 | - || transferCase == TransferCase.SELLER_PLAY_BUYER | ||
534 | - || transferCase == TransferCase.DELIVER_TIME_OUT | ||
535 | - || transferCase == TransferCase.CS_CANCEL_BEFORE_DEPOT_RECEIVE) ? TargetUserType.buyer : TargetUserType.seller; | 529 | + || transferCase == TransferCase.EARNEST_MONEY_TO_BUYER) ? TargetUserType.buyer : TargetUserType.seller; |
536 | Integer targetUid = targetUserType == TargetUserType.buyer ? buyerOrder.getUid() : sellerUid; | 530 | Integer targetUid = targetUserType == TargetUserType.buyer ? buyerOrder.getUid() : sellerUid; |
537 | 531 | ||
538 | if (targetUid == null || targetUid < 1) { | 532 | if (targetUid == null || targetUid < 1) { |
@@ -435,8 +435,11 @@ public class SellerOrderCancelService { | @@ -435,8 +435,11 @@ public class SellerOrderCancelService { | ||
435 | result += buyerOrderMapper.updateStatusByOrderCode(buyerOrderCode, buyerUid, buyerOrderStatus, | 435 | result += buyerOrderMapper.updateStatusByOrderCode(buyerOrderCode, buyerUid, buyerOrderStatus, |
436 | targetBOStatus.getCode(), currentDT); | 436 | targetBOStatus.getCode(), currentDT); |
437 | if(result > 0) { | 437 | if(result > 0) { |
438 | - BuyerRefundCouponEvent brce = BuyerRefundCouponEvent.builder().bizCase(BuyerRefundCouponEvent.BizCase.SELLER_PLAY_BUYER) | ||
439 | - .uid(buyerUid).orderCode(buyerOrderCode).build(); | 438 | + BuyerRefundCouponEvent brce = BuyerRefundCouponEvent.builder() |
439 | + .bizCase(BuyerRefundCouponEvent.BizCase.SELLER_PLAY_BUYER) | ||
440 | + .uid(buyerUid) | ||
441 | + .orderCode(buyerOrderCode) | ||
442 | + .build(); | ||
440 | EventBusPublisher.publishEvent(brce); | 443 | EventBusPublisher.publishEvent(brce); |
441 | 444 | ||
442 | SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(sellerOrder.getSkup()); | 445 | SellerOrderGoods psog = sellerOrderGoodsMapper.selectByPrimaryKey(sellerOrder.getSkup()); |
@@ -473,9 +476,14 @@ public class SellerOrderCancelService { | @@ -473,9 +476,14 @@ public class SellerOrderCancelService { | ||
473 | .skup(sellerOrder.getSkup()); | 476 | .skup(sellerOrder.getSkup()); |
474 | try{ | 477 | try{ |
475 | //分赃(分账) 有待考虑使用2比对 | 478 | //分赃(分账) 有待考虑使用2比对 |
476 | - TransferCase transferCase = TransferCase.SELLER_PLAY_BUYER; | ||
477 | - TransferMoneyRequest tmReq = TransferMoneyRequest.builder().buyerOrderCode(buyerOrderCode) | ||
478 | - .type(transferCase.getCode()).swdType(SellerWalletDetail.Type.SELLER_CANCEL).transferCase(transferCase).build(); | 479 | + TransferCase transferCase = TransferCase.EARNEST_MONEY_TO_BUYER; |
480 | + TransferMoneyRequest tmReq = TransferMoneyRequest.builder() | ||
481 | + .buyerOrderCode(buyerOrderCode) | ||
482 | + .type(transferCase.getCode()) | ||
483 | + .transferCase(transferCase) | ||
484 | + .swdType(SellerWalletDetail.Type.SELLER_CANCEL) | ||
485 | + .alarmConfig(AlarmConfig.SELLER_PLAY_BUYER) | ||
486 | + .build(); | ||
479 | transferService.transfer(tmReq); | 487 | transferService.transfer(tmReq); |
480 | PayRefundBo refundResp = payRefundService.refund(refundReq, bleb); | 488 | PayRefundBo refundResp = payRefundService.refund(refundReq, bleb); |
481 | 489 |
@@ -4,90 +4,63 @@ import com.yohoufo.common.alarm.EventBusPublisher; | @@ -4,90 +4,63 @@ import com.yohoufo.common.alarm.EventBusPublisher; | ||
4 | import com.yohoufo.common.alarm.SmsAlarmEvent; | 4 | import com.yohoufo.common.alarm.SmsAlarmEvent; |
5 | import com.yohoufo.order.common.TransferCase; | 5 | import com.yohoufo.order.common.TransferCase; |
6 | import com.yohoufo.order.constants.AlarmConfig; | 6 | import com.yohoufo.order.constants.AlarmConfig; |
7 | -import com.yohoufo.order.event.BillLogEvent; | ||
8 | import com.yohoufo.order.model.request.TransferMoneyRequest; | 7 | import com.yohoufo.order.model.request.TransferMoneyRequest; |
9 | import com.yohoufo.order.service.IPaymentService; | 8 | import com.yohoufo.order.service.IPaymentService; |
10 | -import com.yohoufo.order.utils.LoggerUtils; | ||
11 | import org.slf4j.Logger; | 9 | import org.slf4j.Logger; |
12 | import org.slf4j.LoggerFactory; | 10 | import org.slf4j.LoggerFactory; |
13 | import org.springframework.beans.factory.annotation.Autowired; | 11 | import org.springframework.beans.factory.annotation.Autowired; |
14 | import org.springframework.stereotype.Service; | 12 | import org.springframework.stereotype.Service; |
15 | 13 | ||
14 | +import java.util.Objects; | ||
15 | + | ||
16 | /** | 16 | /** |
17 | * Created by chenchao on 2018/10/16. | 17 | * Created by chenchao on 2018/10/16. |
18 | */ | 18 | */ |
19 | @Service | 19 | @Service |
20 | public class TransferService { | 20 | public class TransferService { |
21 | 21 | ||
22 | - private final Logger closeLogger = LoggerUtils.getOrderCloseLogger(); | ||
23 | - | ||
24 | private final Logger logger = LoggerFactory.getLogger(getClass()); | 22 | private final Logger logger = LoggerFactory.getLogger(getClass()); |
25 | 23 | ||
26 | @Autowired | 24 | @Autowired |
27 | private IPaymentService paymentService; | 25 | private IPaymentService paymentService; |
28 | 26 | ||
29 | - public boolean transfer(TransferMoneyRequest req){ | 27 | + public boolean transfer(TransferMoneyRequest req) { |
28 | + logger.info("in transfer, req is {}", req); | ||
30 | TransferCase transferCase = req.getTransferCase(); | 29 | TransferCase transferCase = req.getTransferCase(); |
31 | - | ||
32 | - if (transferCase == null){ | 30 | + if (transferCase == null) { |
33 | return true; | 31 | return true; |
34 | } | 32 | } |
35 | - boolean transferFlag=true; | ||
36 | - try{ | 33 | + boolean transferFlag = true; |
34 | + try { | ||
37 | paymentService.transferMon(req); | 35 | paymentService.transferMon(req); |
38 | - }catch (Exception ex){ | 36 | + } catch (Exception ex) { |
39 | transferFlag = false; | 37 | transferFlag = false; |
40 | logger.warn("in transfer, transfer fail,req {}", req, ex); | 38 | logger.warn("in transfer, transfer fail,req {}", req, ex); |
41 | - | ||
42 | SmsAlarmEvent smsAlarmEvent = getSmsAlarmEvent(req, transferCase); | 39 | SmsAlarmEvent smsAlarmEvent = getSmsAlarmEvent(req, transferCase); |
43 | EventBusPublisher.publishEvent(smsAlarmEvent); | 40 | EventBusPublisher.publishEvent(smsAlarmEvent); |
44 | } | 41 | } |
45 | return transferFlag; | 42 | return transferFlag; |
46 | } | 43 | } |
47 | 44 | ||
48 | - SmsAlarmEvent getSmsAlarmEvent(TransferMoneyRequest req, TransferCase transferCase){ | ||
49 | - String content; | ||
50 | - SmsAlarmEvent smsAlarmEvent; | ||
51 | - AlarmConfig alarmConfig ; | ||
52 | - switch (transferCase){ | ||
53 | - case APPRAISE_SUCCESS: | ||
54 | - content = "鉴定通过时,订单"+ req.getBuyerOrderCode() + "货款分账失败"; | ||
55 | - alarmConfig = AlarmConfig.APPRAISE_SUCCESS; | ||
56 | - | ||
57 | - break; | ||
58 | - | ||
59 | - case APPRAISE_FAIL: | ||
60 | - content = "鉴定不通过时,订单"+ req.getBuyerOrderCode() + "保证金分账失败"; | ||
61 | - alarmConfig = AlarmConfig.APPRAISE_FAIL; | ||
62 | - break; | ||
63 | - | ||
64 | - case SELLER_PLAY_BUYER: | ||
65 | - closeLogger.warn("in cancelAfterPayExistBuyAction , transfer fail,req {}", req); | ||
66 | - content = "卖家取消,订单"+ req.getBuyerOrderCode() + "保证金分账失败"; | ||
67 | - alarmConfig = AlarmConfig.SELLER_PLAY_BUYER; | ||
68 | - break; | ||
69 | - | ||
70 | - | ||
71 | - case DELIVER_TIME_OUT: | ||
72 | - closeLogger.warn("in deliver timeout , transfer fail,req {}", req); | ||
73 | - content = "卖家发货超时,订单"+ req.getBuyerOrderCode() + "保证金分账失败"; | ||
74 | - alarmConfig = AlarmConfig.DELIVER_TIME_OUT; | ||
75 | - break; | ||
76 | - | ||
77 | - case CS_CANCEL_BEFORE_DEPOT_RECEIVE: | ||
78 | - closeLogger.warn("in deliver timeout , transfer fail,req {}", req); | ||
79 | - content = "鉴定中心收货前客服取消,订单"+ req.getBuyerOrderCode() + "保证金分账失败"; | ||
80 | - alarmConfig = AlarmConfig.CS_CANCEL_BEFORE_DEPOT_RECEIVE; | ||
81 | - break; | ||
82 | - | ||
83 | - default: | ||
84 | - return null; | 45 | + SmsAlarmEvent getSmsAlarmEvent(TransferMoneyRequest req, TransferCase transferCase) { |
46 | + AlarmConfig alarmConfig = req.getAlarmConfig(); | ||
47 | + if (Objects.isNull(alarmConfig)) { | ||
48 | + switch (transferCase) { | ||
49 | + case APPRAISE_FAIL: | ||
50 | + alarmConfig = AlarmConfig.APPRAISE_FAIL; | ||
51 | + break; | ||
52 | + default: | ||
53 | + return null; | ||
54 | + } | ||
55 | + } | ||
56 | + if (Objects.nonNull(alarmConfig)) { | ||
57 | + String content = alarmConfig.getDesc() + "分账失败,订单" + req.getBuyerOrderCode(); | ||
58 | + return new SmsAlarmEvent(alarmConfig.getTransferName(), alarmConfig.name(), content); | ||
59 | + } else { | ||
60 | + String content = "买家订单分账失败,订单" + req.getBuyerOrderCode(); | ||
61 | + return new SmsAlarmEvent("buyerOrder.transfer", "transfer", content); | ||
85 | } | 62 | } |
86 | - | ||
87 | - smsAlarmEvent = new SmsAlarmEvent(alarmConfig.getTransferName(), alarmConfig.name(), content); | ||
88 | - return smsAlarmEvent; | ||
89 | } | 63 | } |
90 | 64 | ||
91 | 65 | ||
92 | - | ||
93 | } | 66 | } |
-
Please register or login to post a comment