Authored by LUOXC

添加卖家取消订单

@@ -47,6 +47,7 @@ public class SellerWalletDetail { @@ -47,6 +47,7 @@ public class SellerWalletDetail {
47 SELLER_CANCEL("卖家不卖了", 31), 47 SELLER_CANCEL("卖家不卖了", 31),
48 SELLER_OVER_TIME("卖家发货超时", 32), 48 SELLER_OVER_TIME("卖家发货超时", 32),
49 APPRAISE_FAIL("鉴定不通过", 33), 49 APPRAISE_FAIL("鉴定不通过", 33),
  50 + CS_CANCEL_BEFORE_DEPOT_RECEIVE("鉴定中心收货前客服取消", 34),
50 BUYER_CANCEL_NO_DELIVERY("买家取消(无物流)", 41), 51 BUYER_CANCEL_NO_DELIVERY("买家取消(无物流)", 41),
51 BUYER_CANCEL_DELIVERY("买家取消(有物流)", 42), 52 BUYER_CANCEL_DELIVERY("买家取消(有物流)", 42),
52 APPRAISE_OK("鉴定通过", 51), 53 APPRAISE_OK("鉴定通过", 51),
@@ -2,6 +2,8 @@ package com.yohoufo.order.common; @@ -2,6 +2,8 @@ package com.yohoufo.order.common;
2 2
3 import java.util.HashMap; 3 import java.util.HashMap;
4 import java.util.Map; 4 import java.util.Map;
  5 +import java.util.Optional;
  6 +import java.util.function.Supplier;
5 7
6 /** 8 /**
7 * 1:鉴定通过(货款-->卖家 + 平台); 9 * 1:鉴定通过(货款-->卖家 + 平台);
@@ -20,7 +22,8 @@ public enum TransferCase { @@ -20,7 +22,8 @@ public enum TransferCase {
20 SELLER_PLAY_BUYER(3,"有买家时卖家不卖[保证金->买家]"), 22 SELLER_PLAY_BUYER(3,"有买家时卖家不卖[保证金->买家]"),
21 DELIVER_TIME_OUT(4,"卖家超时发货[保证金->买家]"), 23 DELIVER_TIME_OUT(4,"卖家超时发货[保证金->买家]"),
22 BUYER_CANCEL_BEFORE_SELLER_DELIVER(5,"卖家未发货时买家取消[部分货款->卖家]"), 24 BUYER_CANCEL_BEFORE_SELLER_DELIVER(5,"卖家未发货时买家取消[部分货款->卖家]"),
23 - BUYER_CANCEL_BEFORE_DEPOT_RECEIVE(6,"卖家已发货时买家取消[部分货款->卖家]"); 25 + BUYER_CANCEL_BEFORE_DEPOT_RECEIVE(6,"卖家已发货时买家取消[部分货款->卖家]"),
  26 + CS_CANCEL_BEFORE_DEPOT_RECEIVE(7,"鉴定中心收货前客服取消[保证金->买家]");
24 27
25 private int code; 28 private int code;
26 private String info; 29 private String info;
@@ -50,4 +53,9 @@ public enum TransferCase { @@ -50,4 +53,9 @@ public enum TransferCase {
50 public static TransferCase getTransferCase(Integer code){ 53 public static TransferCase getTransferCase(Integer code){
51 return cache.get(code); 54 return cache.get(code);
52 } 55 }
  56 +
  57 + public static TransferCase getTransferCaseOrElseThrow(Integer code, Supplier<RuntimeException> exceptionSupplier){
  58 + return Optional.ofNullable(getTransferCase(code)).orElseThrow(exceptionSupplier);
  59 + }
  60 +
53 } 61 }
@@ -9,7 +9,8 @@ public enum AlarmConfig { @@ -9,7 +9,8 @@ public enum AlarmConfig {
9 APPRAISE_SUCCESS("buyerOrder.transferGoodsMoney","buyerOrder.refundEarnestMoney"), 9 APPRAISE_SUCCESS("buyerOrder.transferGoodsMoney","buyerOrder.refundEarnestMoney"),
10 APPRAISE_FAIL("buyerOrder.transferEarnestMoney","buyerOrder.refundGoodsMoney"), 10 APPRAISE_FAIL("buyerOrder.transferEarnestMoney","buyerOrder.refundGoodsMoney"),
11 SELLER_PLAY_BUYER("buyerOrder.transferEarnestMoney","buyerOrder.refundGoodsMoney"), 11 SELLER_PLAY_BUYER("buyerOrder.transferEarnestMoney","buyerOrder.refundGoodsMoney"),
12 - DELIVER_TIME_OUT("buyerOrder.transferEarnestMoney","buyerOrder.refundGoodsMoney"); 12 + DELIVER_TIME_OUT("buyerOrder.transferEarnestMoney","buyerOrder.refundGoodsMoney"),
  13 + CS_CANCEL_BEFORE_DEPOT_RECEIVE("buyerOrder.transferEarnestMoney","buyerOrder.refundGoodsMoney");
13 14
14 private String transferName; 15 private String transferName;
15 private String refundName; 16 private String refundName;
@@ -15,7 +15,7 @@ import lombok.experimental.Builder; @@ -15,7 +15,7 @@ import lombok.experimental.Builder;
15 @AllArgsConstructor 15 @AllArgsConstructor
16 public class BuyerRefundCouponEvent extends Event { 16 public class BuyerRefundCouponEvent extends Event {
17 public enum BizCase{ 17 public enum BizCase{
18 - APPRAISE_FAIL, SELLER_DELIVER_TIMEOUT, SELLER_PLAY_BUYER, BUYER_CANCEL_BSD, BUYER_CANCEL_BDR 18 + APPRAISE_FAIL, SELLER_DELIVER_TIMEOUT, SELLER_PLAY_BUYER, BUYER_CANCEL_BSD, BUYER_CANCEL_BDR,CS_CANCEL_BEFORE_DEPOT_RECEIVE
19 } 19 }
20 Integer uid; 20 Integer uid;
21 21
@@ -621,7 +621,8 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { @@ -621,7 +621,8 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
621 logger.info("{}修改钱包,uid={},增加保证金场合:", type.getName(), uid); 621 logger.info("{}修改钱包,uid={},增加保证金场合:", type.getName(), uid);
622 } else if (type == SellerWalletDetail.Type.SELLER_CANCEL 622 } else if (type == SellerWalletDetail.Type.SELLER_CANCEL
623 || type == SellerWalletDetail.Type.SELLER_OVER_TIME 623 || type == SellerWalletDetail.Type.SELLER_OVER_TIME
624 - || type == SellerWalletDetail.Type.APPRAISE_FAIL) { 624 + || type == SellerWalletDetail.Type.APPRAISE_FAIL
  625 + || type == SellerWalletDetail.Type.CS_CANCEL_BEFORE_DEPOT_RECEIVE) {
625 // 处罚保证金 626 // 处罚保证金
626 lockAmount = money.multiply(new BigDecimal("-1")); 627 lockAmount = money.multiply(new BigDecimal("-1"));
627 tradeAmount = lockAmount; 628 tradeAmount = lockAmount;
@@ -35,7 +35,7 @@ import java.util.function.BiConsumer; @@ -35,7 +35,7 @@ import java.util.function.BiConsumer;
35 * @date 2019/1/8 14:07 35 * @date 2019/1/8 14:07
36 */ 36 */
37 @Slf4j 37 @Slf4j
38 -public class BuyerOrderCancelHandler { 38 +class BuyerOrderCancelHandler {
39 39
40 private final int uid; 40 private final int uid;
41 private final long orderCode; 41 private final long orderCode;
@@ -55,10 +55,8 @@ public class BuyerOrderCancelHandler { @@ -55,10 +55,8 @@ public class BuyerOrderCancelHandler {
55 private TransferCase transferCase; 55 private TransferCase transferCase;
56 private SellerWalletDetail.Type sellerWalletDetailType; 56 private SellerWalletDetail.Type sellerWalletDetailType;
57 57
58 - private BiConsumer<PaymentRequest, BillLogEvent.BillLogEventBuilder> payGoodsMoneyRefundConsumer;  
59 - private RefundCase refundCase;  
60 -  
61 - private AlarmConfig refundPayFailAlarm; 58 + private BiConsumer<PaymentRequest, BillLogEvent.BillLogEventBuilder> goodsMoneyRefundConsumer;
  59 + private RefundCase goodsMoneyRefundCase;
62 60
63 private SellerNoticeSender sellerNoticeSender; 61 private SellerNoticeSender sellerNoticeSender;
64 private SellerOrderGoodsMapper sellerOrderGoodsMapper; 62 private SellerOrderGoodsMapper sellerOrderGoodsMapper;
@@ -66,6 +64,11 @@ public class BuyerOrderCancelHandler { @@ -66,6 +64,11 @@ public class BuyerOrderCancelHandler {
66 64
67 private BuyerRefundCouponEvent.BizCase refundCouponCase; 65 private BuyerRefundCouponEvent.BizCase refundCouponCase;
68 66
  67 +
  68 +
  69 +
  70 + private AlarmConfig failAlarm;
  71 +
69 BuyerOrderCancelHandler(int uid, long orderCode) { 72 BuyerOrderCancelHandler(int uid, long orderCode) {
70 this.uid = uid; 73 this.uid = uid;
71 this.orderCode = orderCode; 74 this.orderCode = orderCode;
@@ -105,14 +108,9 @@ public class BuyerOrderCancelHandler { @@ -105,14 +108,9 @@ public class BuyerOrderCancelHandler {
105 return this; 108 return this;
106 } 109 }
107 110
108 - public BuyerOrderCancelHandler withRefundPay(BiConsumer<PaymentRequest, BillLogEvent.BillLogEventBuilder> payRefundConsumer, RefundCase refundCase) {  
109 - this.payGoodsMoneyRefundConsumer = payRefundConsumer;  
110 - this.refundCase = refundCase;  
111 - return this;  
112 - }  
113 -  
114 - public BuyerOrderCancelHandler withRefundPayFailAlarm(AlarmConfig refundPayFailAlarm) {  
115 - this.refundPayFailAlarm = refundPayFailAlarm; 111 + public BuyerOrderCancelHandler withRefundGoodsMoney(BiConsumer<PaymentRequest, BillLogEvent.BillLogEventBuilder> refundConsumer, RefundCase refundCase) {
  112 + this.goodsMoneyRefundConsumer = refundConsumer;
  113 + this.goodsMoneyRefundCase = refundCase;
116 return this; 114 return this;
117 } 115 }
118 116
@@ -128,6 +126,11 @@ public class BuyerOrderCancelHandler { @@ -128,6 +126,11 @@ public class BuyerOrderCancelHandler {
128 return this; 126 return this;
129 } 127 }
130 128
  129 + public BuyerOrderCancelHandler withFailAlarm(AlarmConfig failAlarm) {
  130 + this.failAlarm = failAlarm;
  131 + return this;
  132 + }
  133 +
131 public void cancel() { 134 public void cancel() {
132 verify(); 135 verify();
133 // 获取买家订单 136 // 获取买家订单
@@ -194,13 +197,13 @@ public class BuyerOrderCancelHandler { @@ -194,13 +197,13 @@ public class BuyerOrderCancelHandler {
194 } 197 }
195 198
196 private void refundPayGoodsMoney(BuyerOrder buyerOrder) { 199 private void refundPayGoodsMoney(BuyerOrder buyerOrder) {
197 - if (Objects.isNull(payGoodsMoneyRefundConsumer)) { 200 + if (Objects.isNull(goodsMoneyRefundConsumer)) {
198 return; 201 return;
199 } 202 }
200 BigDecimal goodsMoney = buyerOrder.getAmount(); 203 BigDecimal goodsMoney = buyerOrder.getAmount();
201 val paymentRequest = PaymentRequest.builder() 204 val paymentRequest = PaymentRequest.builder()
202 .uid(uid) 205 .uid(uid)
203 - .refundCase(refundCase) 206 + .refundCase(goodsMoneyRefundCase)
204 .orderCode(orderCode) 207 .orderCode(orderCode)
205 .refundAmount(goodsMoney.doubleValue()) 208 .refundAmount(goodsMoney.doubleValue())
206 .build(); 209 .build();
@@ -209,19 +212,19 @@ public class BuyerOrderCancelHandler { @@ -209,19 +212,19 @@ public class BuyerOrderCancelHandler {
209 .sellerUid(buyerOrder.getSellerUid()) 212 .sellerUid(buyerOrder.getSellerUid())
210 .orderCode(orderCode) 213 .orderCode(orderCode)
211 .payType(buyerOrder.getPayment()) 214 .payType(buyerOrder.getPayment())
212 - .refundCase(refundCase) 215 + .refundCase(goodsMoneyRefundCase)
213 .amount(goodsMoney); 216 .amount(goodsMoney);
214 try { 217 try {
215 - payGoodsMoneyRefundConsumer.accept(paymentRequest, billLogEventBuilder.skup(getSkup())); 218 + goodsMoneyRefundConsumer.accept(paymentRequest, billLogEventBuilder.skup(getSkup()));
216 } catch (Exception ex) { 219 } catch (Exception ex) {
217 log.warn("pay refund fail,req {}", paymentRequest, ex); 220 log.warn("pay refund fail,req {}", paymentRequest, ex);
218 BillLogEvent billLogEvent = billLogEventBuilder.tradeStatus(BillTradeStatus.FAIL.getCode()).build(); 221 BillLogEvent billLogEvent = billLogEventBuilder.tradeStatus(BillTradeStatus.FAIL.getCode()).build();
219 EventBusPublisher.publishEvent(billLogEvent); 222 EventBusPublisher.publishEvent(billLogEvent);
220 223
221 - if (Objects.nonNull(refundPayFailAlarm)) { 224 + if (Objects.nonNull(failAlarm)) {
222 SmsAlarmEvent smsAlarmEvent = new SmsAlarmEvent( 225 SmsAlarmEvent smsAlarmEvent = new SmsAlarmEvent(
223 - refundPayFailAlarm.getRefundName(),  
224 - refundPayFailAlarm.name(), 226 + failAlarm.getRefundName(),
  227 + failAlarm.name(),
225 expectStatus.getDesc() + ",取消订单" + orderCode + "退货款失败" 228 expectStatus.getDesc() + ",取消订单" + orderCode + "退货款失败"
226 ); 229 );
227 EventBusPublisher.publishEvent(smsAlarmEvent); 230 EventBusPublisher.publishEvent(smsAlarmEvent);
@@ -264,12 +264,13 @@ public class BuyerOrderCancelService { @@ -264,12 +264,13 @@ public class BuyerOrderCancelService {
264 .withSkup(skup) 264 .withSkup(skup)
265 .withSellerOrderGoods(sellerOrderGoods) 265 .withSellerOrderGoods(sellerOrderGoods)
266 .withBuyerOrderSupplier(buyerOrderMapper, buyerOrderGoodsMapper) 266 .withBuyerOrderSupplier(buyerOrderMapper, buyerOrderGoodsMapper)
  267 + // 已付款 -> 超时未发货取消
267 .withStateTransition(OrderStatus.HAS_PAYED, OrderStatus.SEND_OUT_TIMEOUT, orderStatusFlowService) 268 .withStateTransition(OrderStatus.HAS_PAYED, OrderStatus.SEND_OUT_TIMEOUT, orderStatusFlowService)
268 // 保证金分账给平台和买家 269 // 保证金分账给平台和买家
269 .withTransfer(transferService, TransferCase.SELLER_PLAY_BUYER.getCode(), TransferCase.DELIVER_TIME_OUT, SellerWalletDetail.Type.SELLER_OVER_TIME) 270 .withTransfer(transferService, TransferCase.SELLER_PLAY_BUYER.getCode(), TransferCase.DELIVER_TIME_OUT, SellerWalletDetail.Type.SELLER_OVER_TIME)
270 // 退买家货款 271 // 退买家货款
271 - .withRefundPay(payRefundService::refund, RefundCase.BUYER_GOODS_MONEY)  
272 - .withRefundPayFailAlarm(AlarmConfig.DELIVER_TIME_OUT) 272 + .withRefundGoodsMoney(payRefundService::refund, RefundCase.BUYER_GOODS_MONEY)
  273 + .withFailAlarm(AlarmConfig.DELIVER_TIME_OUT)
273 // 通知卖家商品发货超时 274 // 通知卖家商品发货超时
274 .withNoticeSeller(inBoxFacade::sellerDeliverNotice, 3, sellerOrderGoodsMapper) 275 .withNoticeSeller(inBoxFacade::sellerDeliverNotice, 3, sellerOrderGoodsMapper)
275 // 退优惠券 276 // 退优惠券
@@ -280,16 +281,17 @@ public class BuyerOrderCancelService { @@ -280,16 +281,17 @@ public class BuyerOrderCancelService {
280 public void cancelForCsBeforeDepotReceive(int uid, long orderCode){ 281 public void cancelForCsBeforeDepotReceive(int uid, long orderCode){
281 new BuyerOrderCancelHandler(uid, orderCode) 282 new BuyerOrderCancelHandler(uid, orderCode)
282 .withBuyerOrderSupplier(buyerOrderMapper, buyerOrderGoodsMapper) 283 .withBuyerOrderSupplier(buyerOrderMapper, buyerOrderGoodsMapper)
  284 + // 卖家发货 -> 鉴定中心收货前客服取消
283 .withStateTransition(OrderStatus.SELLER_SEND_OUT, OrderStatus.CS_CANCEL_BEFORE_DEPOT_RECEIVE, orderStatusFlowService) 285 .withStateTransition(OrderStatus.SELLER_SEND_OUT, OrderStatus.CS_CANCEL_BEFORE_DEPOT_RECEIVE, orderStatusFlowService)
284 // 保证金分账给平台和买家 286 // 保证金分账给平台和买家
285 - .withTransfer(transferService, TransferCase.SELLER_PLAY_BUYER.getCode(), TransferCase.DELIVER_TIME_OUT, SellerWalletDetail.Type.SELLER_OVER_TIME) 287 + .withTransfer(transferService, TransferCase.CS_CANCEL_BEFORE_DEPOT_RECEIVE.getCode(), TransferCase.CS_CANCEL_BEFORE_DEPOT_RECEIVE, SellerWalletDetail.Type.CS_CANCEL_BEFORE_DEPOT_RECEIVE)
286 // 退买家货款 288 // 退买家货款
287 - .withRefundPay(payRefundService::refund, RefundCase.BUYER_GOODS_MONEY)  
288 - .withRefundPayFailAlarm(AlarmConfig.DELIVER_TIME_OUT) 289 + .withRefundGoodsMoney(payRefundService::refund, RefundCase.BUYER_GOODS_MONEY)
289 // 通知卖家涉及虚假发货 290 // 通知卖家涉及虚假发货
290 - .withNoticeSeller(inBoxFacade::sellerDeliverNotice, 3, sellerOrderGoodsMapper) 291 + .withNoticeSeller(inBoxFacade::sellerDeliverNotice, 4, sellerOrderGoodsMapper)
291 // 退优惠券 292 // 退优惠券
292 - .withRefundCoupon(BuyerRefundCouponEvent.BizCase.SELLER_DELIVER_TIMEOUT) 293 + .withRefundCoupon(BuyerRefundCouponEvent.BizCase.CS_CANCEL_BEFORE_DEPOT_RECEIVE)
  294 + .withFailAlarm(AlarmConfig.CS_CANCEL_BEFORE_DEPOT_RECEIVE)
293 .cancel(); 295 .cancel();
294 } 296 }
295 297
@@ -499,8 +499,7 @@ public class PaymentServiceImpl implements IPaymentService { @@ -499,8 +499,7 @@ public class PaymentServiceImpl implements IPaymentService {
499 throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY); 499 throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
500 } 500 }
501 // 类型检查 501 // 类型检查
502 - int transferType = request.getType();  
503 - TransferCase transferCase = TransferCase.getTransferCase(transferType); 502 + TransferCase transferCase = TransferCase.getTransferCase(request.getType());
504 if (transferCase == null) { 503 if (transferCase == null) {
505 logger.warn("transferMonErr transferType invalid"); 504 logger.warn("transferMonErr transferType invalid");
506 throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY); 505 throw new ServiceException(ServiceError.ORDER_REQUEST_PARM_IS_EMPTY);
@@ -529,9 +528,10 @@ public class PaymentServiceImpl implements IPaymentService { @@ -529,9 +528,10 @@ public class PaymentServiceImpl implements IPaymentService {
529 Integer sellerUid = sellerOrder.getUid(); 528 Integer sellerUid = sellerOrder.getUid();
530 long sellerOrderCode = sellerOrder.getOrderCode(); 529 long sellerOrderCode = sellerOrder.getOrderCode();
531 punishEarnest(request.getSwdType(), sellerOrder); 530 punishEarnest(request.getSwdType(), sellerOrder);
532 - TargetUserType targetUserType = (transferType == TransferCase.APPRAISE_FAIL.getCode()  
533 - || transferType == TransferCase.SELLER_PLAY_BUYER.getCode()) ? TargetUserType.buyer : TargetUserType.seller;  
534 - //Integer targetUserType = (transferType == 2 || transferType == 3) ? 1 : 2; 531 + TargetUserType targetUserType = (transferCase == TransferCase.APPRAISE_FAIL
  532 + || transferCase == TransferCase.SELLER_PLAY_BUYER
  533 + || transferCase == TransferCase.DELIVER_TIME_OUT
  534 + || transferCase == TransferCase.CS_CANCEL_BEFORE_DEPOT_RECEIVE) ? TargetUserType.buyer : TargetUserType.seller;
535 Integer targetUid = targetUserType == TargetUserType.buyer ? buyerOrder.getUid() : sellerUid; 535 Integer targetUid = targetUserType == TargetUserType.buyer ? buyerOrder.getUid() : sellerUid;
536 536
537 if (targetUid == null || targetUid < 1) { 537 if (targetUid == null || targetUid < 1) {
@@ -551,7 +551,7 @@ public class PaymentServiceImpl implements IPaymentService { @@ -551,7 +551,7 @@ public class PaymentServiceImpl implements IPaymentService {
551 transfer.setSellerOrderCode(sellerOrderCode); 551 transfer.setSellerOrderCode(sellerOrderCode);
552 transfer.setAlipayTradeId(""); 552 transfer.setAlipayTradeId("");
553 transfer.setAlipayTradeResult(""); 553 transfer.setAlipayTradeResult("");
554 - transfer.setTransferType(transferType); 554 + transfer.setTransferType(transferCase.getCode());
555 transfer.setUid(targetUid); 555 transfer.setUid(targetUid);
556 transfer.setAmount(BigDecimal.ZERO); 556 transfer.setAmount(BigDecimal.ZERO);
557 transfer.setCreateTime(now); 557 transfer.setCreateTime(now);
@@ -571,7 +571,8 @@ public class PaymentServiceImpl implements IPaymentService { @@ -571,7 +571,8 @@ public class PaymentServiceImpl implements IPaymentService {
571 record.setOrderCode(buyerOrderCode); 571 record.setOrderCode(buyerOrderCode);
572 record.setUserType(targetUserType.getCode()); 572 record.setUserType(targetUserType.getCode());
573 record.setPayType(1); 573 record.setPayType(1);
574 - record.setTradeType(transferType == 1 ? 2 : 3); 574 + // 如果鉴定通过[货款->卖家],否则[补偿款->卖家或买家] 2:货款;3:补偿款
  575 + record.setTradeType(transferCase == TransferCase.APPRAISE_SUCCESS ? 2 : 3);
575 record.setIncomeOutcome(1); 576 record.setIncomeOutcome(1);
576 record.setTradeStatus(0); 577 record.setTradeStatus(0);
577 record.setCreateTime(now); 578 record.setCreateTime(now);
@@ -582,7 +583,7 @@ public class PaymentServiceImpl implements IPaymentService { @@ -582,7 +583,7 @@ public class PaymentServiceImpl implements IPaymentService {
582 logger.info("transferMon计算费用结果为 {}", transferAmount); 583 logger.info("transferMon计算费用结果为 {}", transferAmount);
583 if (transferAmount == null) { 584 if (transferAmount == null) {
584 logger.warn("transferMonErr transferMon计算费用结果为 null, 不合法的金额"); 585 logger.warn("transferMonErr transferMon计算费用结果为 null, 不合法的金额");
585 - alarm("转账金额不合法", "ufo.order.transferMon", "订单号:" + buyerOrderCode + "操作类型(" + transferType + ")计算金额结果为null"); 586 + alarm("转账金额不合法", "ufo.order.transferMon", "订单号:" + buyerOrderCode + "操作类型(" + transferCase.getCode() + ")计算金额结果为null");
586 record.setTradeStatus(202); 587 record.setTradeStatus(202);
587 addTradeBills(record); 588 addTradeBills(record);
588 throw new ServiceException(400, "计算金额错误!:"); 589 throw new ServiceException(400, "计算金额错误!:");
@@ -593,7 +594,7 @@ public class PaymentServiceImpl implements IPaymentService { @@ -593,7 +594,7 @@ public class PaymentServiceImpl implements IPaymentService {
593 record.setSystemAmount(transferAmount.multiply(new BigDecimal("-1"))); 594 record.setSystemAmount(transferAmount.multiply(new BigDecimal("-1")));
594 if (transferAmount.compareTo(new BigDecimal("0.1")) < 0) { 595 if (transferAmount.compareTo(new BigDecimal("0.1")) < 0) {
595 logger.warn("transferMonErr transferMon计算费用结果为 {}, 小于0.1", transferAmount); 596 logger.warn("transferMonErr transferMon计算费用结果为 {}, 小于0.1", transferAmount);
596 - alarm("转账金额小于0.1", "ufo.order.transferMon", "订单号:" + buyerOrderCode + "操作类型(" + transferType + ")计算金额结果为" + transferAmount); 597 + alarm("转账金额小于0.1", "ufo.order.transferMon", "订单号:" + buyerOrderCode + "操作类型(" + transferCase.getCode() + ")计算金额结果为" + transferAmount);
597 record.setTradeStatus(202); 598 record.setTradeStatus(202);
598 addTradeBills(record); 599 addTradeBills(record);
599 throw new ServiceException(400, "不合法的金额:" + transferAmount); 600 throw new ServiceException(400, "不合法的金额:" + transferAmount);
@@ -74,6 +74,12 @@ public class TransferService { @@ -74,6 +74,12 @@ public class TransferService {
74 alarmConfig = AlarmConfig.DELIVER_TIME_OUT; 74 alarmConfig = AlarmConfig.DELIVER_TIME_OUT;
75 break; 75 break;
76 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 +
77 default: 83 default:
78 return null; 84 return null;
79 } 85 }
@@ -15,7 +15,10 @@ import org.springframework.stereotype.Service; @@ -15,7 +15,10 @@ import org.springframework.stereotype.Service;
15 15
16 import java.util.Arrays; 16 import java.util.Arrays;
17 import java.util.List; 17 import java.util.List;
18 -import java.util.concurrent.*; 18 +import java.util.concurrent.ArrayBlockingQueue;
  19 +import java.util.concurrent.ExecutorService;
  20 +import java.util.concurrent.ThreadPoolExecutor;
  21 +import java.util.concurrent.TimeUnit;
19 22
20 /** 23 /**
21 * Created by chenchao on 2018/10/8. 24 * Created by chenchao on 2018/10/8.
@@ -655,26 +658,30 @@ public class InBoxFacade { @@ -655,26 +658,30 @@ public class InBoxFacade {
655 Integer sellerUid = sog.getUid(); 658 Integer sellerUid = sog.getUid();
656 String prdName = sog.getProductName(); 659 String prdName = sog.getProductName();
657 String sizeName = sog.getSizeName(); 660 String sizeName = sog.getSizeName();
  661 + InboxBusinessTypeEnum ibt;
  662 + InboxBusinessTypeEnum smsInboxBusinessTypeEnum;
  663 + if (times == 2) {
  664 + ibt = InboxBusinessTypeEnum.NOTICE_SELLER_DELIVER_GOODS;
  665 + smsInboxBusinessTypeEnum = InboxBusinessTypeEnum.SMS_NOTIFIED_SEND_SECOND;
  666 + } else if (times == 3) {
  667 + ibt = InboxBusinessTypeEnum.NOTICE_SELLER_DELIVER_GOODS_FAIL;
  668 + smsInboxBusinessTypeEnum = InboxBusinessTypeEnum.SMS_NOTIFIED_SEND_FAILED;
  669 + } else if (times == 4) {
  670 + ibt = InboxBusinessTypeEnum.NOTICE_SELLER_CS_CANCEL_ORDER_TRADE_FAIL;
  671 + smsInboxBusinessTypeEnum = InboxBusinessTypeEnum.SMS_NOTICE_SELLER_CS_CANCEL_ORDER_TRADE_FAIL;
  672 + }else {
  673 + return;
  674 + }
658 try { 675 try {
659 executorService.execute(() -> { 676 executorService.execute(() -> {
660 logger.info("record sellerDeliverNotice inbox sms msg,sellerUid {}, prdName {}, times {}", 677 logger.info("record sellerDeliverNotice inbox sms msg,sellerUid {}, prdName {}, times {}",
661 sellerUid, prdName, times); 678 sellerUid, prdName, times);
662 679
663 -  
664 - if(times == 2 || times == 3){  
665 - InboxBusinessTypeEnum ibt = null;  
666 - if (times == 2) {  
667 - ibt = InboxBusinessTypeEnum.NOTICE_SELLER_DELIVER_GOODS;  
668 - }  
669 - if(times == 3){  
670 - ibt = InboxBusinessTypeEnum.NOTICE_SELLER_DELIVER_GOODS_FAIL;  
671 - }  
672 String params = buildParams(prdName, sizeName); 680 String params = buildParams(prdName, sizeName);
673 InboxReqVO req = buildInboxReqVO(sellerUid, params, ibt); 681 InboxReqVO req = buildInboxReqVO(sellerUid, params, ibt);
674 InBoxResponse resp = inBoxSDK.addInbox(req); 682 InBoxResponse resp = inBoxSDK.addInbox(req);
675 logger.info("record sellerDeliverNotice inbox msg,sellerUid {}, prdName {},sizeName {} times {},resp {}", 683 logger.info("record sellerDeliverNotice inbox msg,sellerUid {}, prdName {},sizeName {} times {},resp {}",
676 sellerUid, prdName, sizeName, times, resp); 684 sellerUid, prdName, sizeName, times, resp);
677 - }  
678 685
679 String phone = userProxyService.getMobile(sellerUid); 686 String phone = userProxyService.getMobile(sellerUid);
680 if (StringUtils.isBlank(phone)){ 687 if (StringUtils.isBlank(phone)){
@@ -683,22 +690,10 @@ public class InBoxFacade { @@ -683,22 +690,10 @@ public class InBoxFacade {
683 return; 690 return;
684 } 691 }
685 List<String> mobileList = Arrays.asList(phone); 692 List<String> mobileList = Arrays.asList(phone);
686 -  
687 - if(times == 2 || times == 3){  
688 - String content = null;  
689 - if (times == 2) {  
690 - content = getReplacedContent(InboxBusinessTypeEnum.SMS_NOTIFIED_SEND_SECOND.getContent(),prdName,orderCode);  
691 - }  
692 -  
693 - if (times == 3) {  
694 - content = getReplacedContent(InboxBusinessTypeEnum.SMS_NOTIFIED_SEND_FAILED.getContent(),prdName,orderCode);  
695 - } 693 + String content = getReplacedContent(smsInboxBusinessTypeEnum.getContent(),prdName,orderCode);
696 sendSmsService.smsSendByMobile(content, mobileList); 694 sendSmsService.smsSendByMobile(content, mobileList);
697 logger.info("record sellerDeliverNotice inbox sms msg,sellerUid {}, prdName {}, times {},resp {}", 695 logger.info("record sellerDeliverNotice inbox sms msg,sellerUid {}, prdName {}, times {},resp {}",
698 sellerUid, prdName, times); 696 sellerUid, prdName, times);
699 - }  
700 -  
701 -  
702 }); 697 });
703 } catch (Exception e) { 698 } catch (Exception e) {
704 logger.warn("InBoxFacade sellerDeliverNotice error inbox msg, sellerUid {}, prdName {} ", 699 logger.warn("InBoxFacade sellerDeliverNotice error inbox msg, sellerUid {}, prdName {} ",