Authored by chenchao

fix platform off shelve bug

@@ -19,15 +19,18 @@ public class AlarmEventBuilder { @@ -19,15 +19,18 @@ public class AlarmEventBuilder {
19 SmsAlarmEvent smsAlarmEvent = null; 19 SmsAlarmEvent smsAlarmEvent = null;
20 String content = null; 20 String content = null;
21 switch(targetSOStatus){ 21 switch(targetSOStatus){
22 -  
23 case PLAY_SELF: 22 case PLAY_SELF:
24 content = "卖家" + sellerUid + "退保证金订单"+ sellerOrderCode +"失败"; 23 content = "卖家" + sellerUid + "退保证金订单"+ sellerOrderCode +"失败";
25 smsAlarmEvent = new SmsAlarmEvent("notPaidSellerOrder.selfCancel", "cancelBeforeBuy", content); 24 smsAlarmEvent = new SmsAlarmEvent("notPaidSellerOrder.selfCancel", "cancelBeforeBuy", content);
26 break; 25 break;
27 case FINISH: 26 case FINISH:
28 - content = "鉴定通过时,卖家订单"+ sellerOrderCode + "退还保证金失败"; 27 + content = "鉴定通过时,卖家订单"+ sellerOrderCode + "退还保证金失败";
29 AlarmConfig alarmConfig = AlarmConfig.APPRAISE_SUCCESS; 28 AlarmConfig alarmConfig = AlarmConfig.APPRAISE_SUCCESS;
30 - smsAlarmEvent = new SmsAlarmEvent(alarmConfig.getRefundName(), alarmConfig.name(), content); 29 + smsAlarmEvent = new SmsAlarmEvent(alarmConfig.getRefundName(), alarmConfig.name(), content);
  30 + break;
  31 + case YOHO_CANCEL_SELL:
  32 + content = "下架skup时,退用户" + sellerUid + "保证金订单"+ sellerOrderCode +"失败";
  33 + smsAlarmEvent = new SmsAlarmEvent("PaidSellerOrder.PlatformCancel", "cancelBeforeBuy", content);
31 break; 34 break;
32 } 35 }
33 return smsAlarmEvent; 36 return smsAlarmEvent;
@@ -35,16 +38,14 @@ public class AlarmEventBuilder { @@ -35,16 +38,14 @@ public class AlarmEventBuilder {
35 38
36 39
37 public static SmsAlarmEvent buildRefundSellerEarnestMoneyAlarmEvent(OrderStatus orderStatus,Integer sellerUid, 40 public static SmsAlarmEvent buildRefundSellerEarnestMoneyAlarmEvent(OrderStatus orderStatus,Integer sellerUid,
38 -  
39 Long buyerOrderCode){ 41 Long buyerOrderCode){
40 42
41 SmsAlarmEvent smsAlarmEvent = null; 43 SmsAlarmEvent smsAlarmEvent = null;
42 String content = null; 44 String content = null;
43 switch(orderStatus){ 45 switch(orderStatus){
44 -  
45 case BUYER_CANCEL_BEFORE_SELLER_DELIVER: 46 case BUYER_CANCEL_BEFORE_SELLER_DELIVER:
46 case BUYER_CANCEL_BEFORE_DEPOT_RECEIVE: 47 case BUYER_CANCEL_BEFORE_DEPOT_RECEIVE:
47 - content = "用户" + sellerUid + "退保证金订单"+ buyerOrderCode +"失败"; 48 + content = "买家取消订单"+ buyerOrderCode +"给卖家" + sellerUid + "退保证金失败";
48 smsAlarmEvent = new SmsAlarmEvent("buyerPaidOrder.selfCancel", "cancel", content); 49 smsAlarmEvent = new SmsAlarmEvent("buyerPaidOrder.selfCancel", "cancel", content);
49 break; 50 break;
50 } 51 }
@@ -37,11 +37,11 @@ public class BatchPublishTailHandler implements IEventHandler<BatchPublishTailEv @@ -37,11 +37,11 @@ public class BatchPublishTailHandler implements IEventHandler<BatchPublishTailEv
37 } 37 }
38 38
39 private void batchPublishTailProcess(SellerOrderSubmitHandler.ForkJoinResult fjr, 39 private void batchPublishTailProcess(SellerOrderSubmitHandler.ForkJoinResult fjr,
40 - SellerWallet sellerWallet, boolean isSurper, 40 + SellerWallet sellerWallet, boolean isSuper,
41 int sellerUid){ 41 int sellerUid){
42 42
43 // (异步实现)记录保证金流水 43 // (异步实现)记录保证金流水
44 - if(!isSurper) { 44 + if(!isSuper) {
45 List<OrderInfo> orderList = fjr.getSellerOrderList().parallelStream().map(sellerOrder -> 45 List<OrderInfo> orderList = fjr.getSellerOrderList().parallelStream().map(sellerOrder ->
46 OrderInfo.builder().orderCode(sellerOrder.getOrderCode()) 46 OrderInfo.builder().orderCode(sellerOrder.getOrderCode())
47 .amount(sellerOrder.getEarnestMoney()).build() 47 .amount(sellerOrder.getEarnestMoney()).build()
@@ -859,7 +859,6 @@ public class AppraiseService { @@ -859,7 +859,6 @@ public class AppraiseService {
859 .loadRefundAction(payRefundService::refund) 859 .loadRefundAction(payRefundService::refund)
860 .loadBillLogEventBuilder(bleb) 860 .loadBillLogEventBuilder(bleb)
861 .loadPaymentRequest(refundReqOfSeller) 861 .loadPaymentRequest(refundReqOfSeller)
862 - .loadBuyer(null, null, null)  
863 .loadSeller(sellerUid, sellerIsSuper, orderCode, targetSoStatus) 862 .loadSeller(sellerUid, sellerIsSuper, orderCode, targetSoStatus)
864 .loadLogger(LOGGER) 863 .loadLogger(LOGGER)
865 .refund(); 864 .refund();
@@ -5,7 +5,6 @@ import com.yoho.error.exception.ServiceException; @@ -5,7 +5,6 @@ import com.yoho.error.exception.ServiceException;
5 import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo; 5 import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo;
6 import com.yohobuy.ufo.model.order.common.*; 6 import com.yohobuy.ufo.model.order.common.*;
7 import com.yohoufo.common.alarm.EventBusPublisher; 7 import com.yohoufo.common.alarm.EventBusPublisher;
8 -import com.yohoufo.common.alarm.SmsAlarmEvent;  
9 import com.yohoufo.common.alarm.UfoInfluxdbEvent; 8 import com.yohoufo.common.alarm.UfoInfluxdbEvent;
10 import com.yohoufo.common.alarm.UfoInfluxdbVo; 9 import com.yohoufo.common.alarm.UfoInfluxdbVo;
11 import com.yohoufo.common.constant.InfluxdbFieldEnum; 10 import com.yohoufo.common.constant.InfluxdbFieldEnum;
@@ -14,11 +13,13 @@ import com.yohoufo.common.exception.UfoServiceException; @@ -14,11 +13,13 @@ import com.yohoufo.common.exception.UfoServiceException;
14 import com.yohoufo.common.utils.DateUtil; 13 import com.yohoufo.common.utils.DateUtil;
15 import com.yohoufo.dal.order.*; 14 import com.yohoufo.dal.order.*;
16 import com.yohoufo.dal.order.model.*; 15 import com.yohoufo.dal.order.model.*;
17 -import com.yohoufo.order.common.*; 16 +import com.yohoufo.order.common.ActionStatusHold;
  17 +import com.yohoufo.order.common.Payment;
  18 +import com.yohoufo.order.common.RefundCase;
  19 +import com.yohoufo.order.common.TransferCase;
18 import com.yohoufo.order.constants.AlarmConfig; 20 import com.yohoufo.order.constants.AlarmConfig;
19 import com.yohoufo.order.event.*; 21 import com.yohoufo.order.event.*;
20 import com.yohoufo.order.model.PayQueryBo; 22 import com.yohoufo.order.model.PayQueryBo;
21 -import com.yohoufo.order.model.PayRefundBo;  
22 import com.yohoufo.order.model.request.OrderRequest; 23 import com.yohoufo.order.model.request.OrderRequest;
23 import com.yohoufo.order.model.request.PaymentRequest; 24 import com.yohoufo.order.model.request.PaymentRequest;
24 import com.yohoufo.order.model.request.TranseferCellNode; 25 import com.yohoufo.order.model.request.TranseferCellNode;
@@ -477,7 +478,6 @@ public class SellerOrderCancelService { @@ -477,7 +478,6 @@ public class SellerOrderCancelService {
477 .loadRefundAction(payRefundService::refund) 478 .loadRefundAction(payRefundService::refund)
478 .loadBillLogEventBuilder(bleb) 479 .loadBillLogEventBuilder(bleb)
479 .loadPaymentRequest(refundReq) 480 .loadPaymentRequest(refundReq)
480 - .loadBuyer(null, null, null)  
481 .loadSeller(sellerUid, isSuper, orderCode, targetSOStatus) 481 .loadSeller(sellerUid, isSuper, orderCode, targetSOStatus)
482 .loadLogger(logger) 482 .loadLogger(logger)
483 .refund(); 483 .refund();
@@ -715,8 +715,8 @@ public class SellerOrderCancelService { @@ -715,8 +715,8 @@ public class SellerOrderCancelService {
715 } 715 }
716 716
717 SkupStatus expectSkupStatus = SkupStatus.CAN_SELL; 717 SkupStatus expectSkupStatus = SkupStatus.CAN_SELL;
718 - boolean isPayEarnestMoney = expectSkupStatus.getCode() == skupStatus;  
719 - if (!isPayEarnestMoney){ 718 + boolean earnestMoneyPaidFlag = expectSkupStatus.getCode() == skupStatus;
  719 + if (!earnestMoneyPaidFlag){
720 logger.warn("in offShelveCancelCase, SellerOrderGoods status illegal, skup {}, status {}", skup, skupStatus); 720 logger.warn("in offShelveCancelCase, SellerOrderGoods status illegal, skup {}, status {}", skup, skupStatus);
721 return; 721 return;
722 } 722 }
@@ -750,42 +750,41 @@ public class SellerOrderCancelService { @@ -750,42 +750,41 @@ public class SellerOrderCancelService {
750 double earnestMoney = sellerOrder.getEarnestMoney().doubleValue(); 750 double earnestMoney = sellerOrder.getEarnestMoney().doubleValue();
751 751
752 Integer sop = sellerOrder.getPayment() == null ? 0 : sellerOrder.getPayment(); 752 Integer sop = sellerOrder.getPayment() == null ? 0 : sellerOrder.getPayment();
753 - PaymentRequest refundReq = PaymentRequest.builder().uid(sellerUid)  
754 - .orderCode(orderCode)  
755 - .refundCase(RefundCase.SELLER_EARNEST_MONEY)  
756 - .payment(sop)  
757 - .refundAmount(earnestMoney).build();  
758 - boolean sellerIsSurper = sellerService.isSuperEntrySeller(sellerUid);  
759 - refundReq.setSuper(sellerIsSurper);  
760 - //  
761 - if(!sellerIsSurper && PaymentHelper.isWallet(sop)){  
762 - MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(sellerUid) 753 +
  754 + boolean sellerIsSuper = sellerService.isSuperEntrySeller(sellerUid);
  755 +
  756 + //不是超级卖家 ,上架商品用钱包支付保证金
  757 + MerchantOrderAttachInfo moai = null;
  758 + if(!sellerIsSuper && PaymentHelper.isWallet(sop)){
  759 + moai = MerchantOrderAttachInfo.builder().uid(sellerUid)
763 .orderCode(orderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney()) 760 .orderCode(orderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney())
764 .type(SellerWalletDetail.Type.SYSTEM_OFF.getValue()).build(); 761 .type(SellerWalletDetail.Type.SYSTEM_OFF.getValue()).build();
765 - refundReq.setRefundattch(moai);  
766 } 762 }
767 763
768 BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder() 764 BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder()
769 .sellerUid(sellerUid).orderCode(orderCode) 765 .sellerUid(sellerUid).orderCode(orderCode)
770 - .payType(sellerOrder.getPayment()).refundCase(RefundCase.SELLER_EARNEST_MONEY) 766 + .payType(sellerOrder.getPayment())
  767 + .refundCase(RefundCase.SELLER_EARNEST_MONEY)
771 .skup(skup); 768 .skup(skup);
  769 + PaymentRequest refundReq = PaymentRequest.builder().uid(sellerUid)
  770 + .orderCode(orderCode)
  771 + .refundCase(RefundCase.SELLER_EARNEST_MONEY)
  772 + .payment(sop)
  773 + .refundAmount(earnestMoney)
  774 + .isSuper(sellerIsSuper)
  775 + .refundattch(moai)
  776 + .build();
772 777
773 - try {  
774 - PayRefundBo payRefundBo = payRefundService.refund(refundReq, bleb);  
775 - logger.info("in yoho Off Shelve Cancel , refund earnestMoney finish, seller {}, order code {}, skup {}, earnestMoney {}",  
776 - sellerUid, orderCode, skup, earnestMoney); 778 + boolean refundEarnMoneyFlag = new RefundEarnestMoneyHandler()
  779 + .loadRefundAction(payRefundService::refund)
  780 + .loadBillLogEventBuilder(bleb)
  781 + .loadPaymentRequest(refundReq)
  782 + .loadSeller(sellerUid, sellerIsSuper, orderCode, targetSellerOrderStatus)
  783 + .loadLogger(logger)
  784 + .refund();
  785 +
  786 + if (refundEarnMoneyFlag){
777 inBoxFacade.notifyUnshelfCauseBySpecialReason(sellerUid, psog); 787 inBoxFacade.notifyUnshelfCauseBySpecialReason(sellerUid, psog);
778 - }catch (Exception ex){  
779 - logger.warn("in yoho Off Shelve Cancel, refund earnestMoney fail, seller {}, order code {}, skup {}, earnestMoney {}",  
780 - sellerUid, orderCode, skup, earnestMoney, ex);  
781 - if(!sellerIsSurper) {  
782 - BillLogEvent sellerBillLogEvent = bleb.tradeStatus(BillTradeStatus.FAIL.getCode())  
783 - .build();  
784 - EventBusPublisher.publishEvent(sellerBillLogEvent);  
785 - }  
786 - String content = "下架skup时,退用户" + sellerUid + "保证金订单"+ orderCode +"失败";  
787 - SmsAlarmEvent smsAlarmEvent = new SmsAlarmEvent("PaidSellerOrder.PlatformCancel", "cancelBeforeBuy", content);  
788 - EventBusPublisher.publishEvent(smsAlarmEvent);  
789 } 788 }
790 } 789 }
791 790
@@ -776,15 +776,15 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic @@ -776,15 +776,15 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic
776 776
777 private SellerWallet sellerWallet; 777 private SellerWallet sellerWallet;
778 778
779 - private boolean isSurper; 779 + private boolean isSuper;
780 780
781 public BatchProcessTask(SellerOrderContext ctx, CountDownLatch countDownLatch, 781 public BatchProcessTask(SellerOrderContext ctx, CountDownLatch countDownLatch,
782 - int num, SellerWallet sellerWallet, boolean isSurper) { 782 + int num, SellerWallet sellerWallet, boolean isSuper) {
783 this.ctx = ctx; 783 this.ctx = ctx;
784 this.countDownLatch = countDownLatch; 784 this.countDownLatch = countDownLatch;
785 this.num = num; 785 this.num = num;
786 this.sellerWallet = sellerWallet; 786 this.sellerWallet = sellerWallet;
787 - this.isSurper = isSurper; 787 + this.isSuper = isSuper;
788 } 788 }
789 789
790 @Override 790 @Override
@@ -802,7 +802,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic @@ -802,7 +802,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic
802 //(异步实现)同步数据到prd,记录支付, 802 //(异步实现)同步数据到prd,记录支付,
803 BatchPublishTailEvent bpte = BatchPublishTailEvent.builder() 803 BatchPublishTailEvent bpte = BatchPublishTailEvent.builder()
804 .sellerUid(uid) 804 .sellerUid(uid)
805 - .isSurper(isSurper) 805 + .isSurper(isSuper)
806 .fjr(fjr).sellerWallet(sellerWallet).build(); 806 .fjr(fjr).sellerWallet(sellerWallet).build();
807 EventBusPublisher.publishEvent(bpte); 807 EventBusPublisher.publishEvent(bpte);
808 808