Authored by chenchao

fix: 卖家从个人卖家升级到超级后操作之前订单,不退还保证金

@@ -5,9 +5,11 @@ import com.yohobuy.ufo.model.order.common.SellerOrderStatus; @@ -5,9 +5,11 @@ import com.yohobuy.ufo.model.order.common.SellerOrderStatus;
5 import com.yohoufo.common.alarm.EventBusPublisher; 5 import com.yohoufo.common.alarm.EventBusPublisher;
6 import com.yohoufo.common.alarm.SmsAlarmEvent; 6 import com.yohoufo.common.alarm.SmsAlarmEvent;
7 import com.yohoufo.order.common.BillTradeStatus; 7 import com.yohoufo.order.common.BillTradeStatus;
  8 +import com.yohoufo.order.common.RefundCase;
8 import com.yohoufo.order.convert.builder.AlarmEventBuilder; 9 import com.yohoufo.order.convert.builder.AlarmEventBuilder;
9 import com.yohoufo.order.event.BillLogEvent; 10 import com.yohoufo.order.event.BillLogEvent;
10 import com.yohoufo.order.model.request.PaymentRequest; 11 import com.yohoufo.order.model.request.PaymentRequest;
  12 +import com.yohoufo.order.utils.PaymentHelper;
11 import org.slf4j.Logger; 13 import org.slf4j.Logger;
12 14
13 import java.util.Objects; 15 import java.util.Objects;
@@ -65,6 +67,13 @@ public class RefundEarnestMoneyHandler extends AbsRefundOrderHandler{ @@ -65,6 +67,13 @@ public class RefundEarnestMoneyHandler extends AbsRefundOrderHandler{
65 public boolean refund(){ 67 public boolean refund(){
66 68
67 try { 69 try {
  70 + boolean toSeller = paymentRequest.getRefundCase() !=null
  71 + && RefundCase.SELLER_EARNEST_MONEY == paymentRequest.getRefundCase();
  72 + boolean isWalletPay = PaymentHelper.isWallet(paymentRequest.getPayment());
  73 + if(paymentRequest.isSuper() && toSeller && isWalletPay){
  74 + logger.warn("in RefundEarnestMoneyHandler.refund no need refund, refundReq {}", paymentRequest);
  75 + return false;
  76 + }
68 refundConsumer.accept(paymentRequest, bleb); 77 refundConsumer.accept(paymentRequest, bleb);
69 return true; 78 return true;
70 }catch (Exception ex){ 79 }catch (Exception ex){
@@ -565,9 +565,11 @@ public class AppraiseService { @@ -565,9 +565,11 @@ public class AppraiseService {
565 //退保证金给卖家 565 //退保证金给卖家
566 private PaymentRequest refundEarnestMoney(SellerWalletDetail.Type swdType,Long orderCode,Integer sellerUid ,SellerOrder sellerOrder,int skup,Integer buyerUid,SellerOrderStatus targetSoStatus ,double refundMoney){ 566 private PaymentRequest refundEarnestMoney(SellerWalletDetail.Type swdType,Long orderCode,Integer sellerUid ,SellerOrder sellerOrder,int skup,Integer buyerUid,SellerOrderStatus targetSoStatus ,double refundMoney){
567 Long sellerOrderCode = sellerOrder.getOrderCode(); 567 Long sellerOrderCode = sellerOrder.getOrderCode();
  568 + Integer sop = sellerOrder.getPayment() == null ? 0 : sellerOrder.getPayment();
568 PaymentRequest refundReqOfSeller = PaymentRequest.builder().uid(sellerUid) 569 PaymentRequest refundReqOfSeller = PaymentRequest.builder().uid(sellerUid)
569 .refundCase(RefundCase.SELLER_EARNEST_MONEY) 570 .refundCase(RefundCase.SELLER_EARNEST_MONEY)
570 .orderCode(sellerOrderCode).refundAmount(refundMoney) 571 .orderCode(sellerOrderCode).refundAmount(refundMoney)
  572 + .payment(sop)
571 .build(); 573 .build();
572 boolean sellerIsSuper = sellerService.isSuperEntrySeller(sellerUid); 574 boolean sellerIsSuper = sellerService.isSuperEntrySeller(sellerUid);
573 refundReqOfSeller.setSuper(sellerIsSuper); 575 refundReqOfSeller.setSuper(sellerIsSuper);
@@ -575,7 +577,7 @@ public class AppraiseService { @@ -575,7 +577,7 @@ public class AppraiseService {
575 ,orderCode ,swdType, 577 ,orderCode ,swdType,
576 sellerUid,sellerIsSuper, sellerOrderCode, skup, refundMoney ,refundReqOfSeller); 578 sellerUid,sellerIsSuper, sellerOrderCode, skup, refundMoney ,refundReqOfSeller);
577 579
578 - if (!sellerIsSuper && PaymentHelper.isWallet(sellerOrder.getPayment())){ 580 + if (!sellerIsSuper && PaymentHelper.isWallet(sop)){
579 LOGGER.info("in refundEarnestMoney begin set MerchantOrderAttachInfo orderCode {} ,swdType {} seller uid {},sellerIsSuper {},seller order code {}, skup {}, refundMoney {},refundReqOfSeller {}" 581 LOGGER.info("in refundEarnestMoney begin set MerchantOrderAttachInfo orderCode {} ,swdType {} seller uid {},sellerIsSuper {},seller order code {}, skup {}, refundMoney {},refundReqOfSeller {}"
580 ,orderCode ,swdType, 582 ,orderCode ,swdType,
581 sellerUid,sellerIsSuper, sellerOrderCode, skup, refundMoney ,refundReqOfSeller); 583 sellerUid,sellerIsSuper, sellerOrderCode, skup, refundMoney ,refundReqOfSeller);
@@ -598,7 +600,7 @@ public class AppraiseService { @@ -598,7 +600,7 @@ public class AppraiseService {
598 sellerUid,sellerIsSuper, sellerOrderCode, skup, refundMoney ,refundReqOfSeller); 600 sellerUid,sellerIsSuper, sellerOrderCode, skup, refundMoney ,refundReqOfSeller);
599 BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder() 601 BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder()
600 .buyerUid(buyerUid).sellerUid(sellerUid).orderCode(sellerOrder.getOrderCode()) 602 .buyerUid(buyerUid).sellerUid(sellerUid).orderCode(sellerOrder.getOrderCode())
601 - .payType(sellerOrder.getPayment()).refundCase(RefundCase.SELLER_EARNEST_MONEY) 603 + .payType(sop).refundCase(RefundCase.SELLER_EARNEST_MONEY)
602 .skup(skup); 604 .skup(skup);
603 605
604 new RefundEarnestMoneyHandler() 606 new RefundEarnestMoneyHandler()
@@ -288,12 +288,14 @@ public class BuyerOrderCancelService { @@ -288,12 +288,14 @@ public class BuyerOrderCancelService {
288 int sellerUid = sellerOrder.getUid(); 288 int sellerUid = sellerOrder.getUid();
289 long sellerOrderCode = sellerOrder.getOrderCode(); 289 long sellerOrderCode = sellerOrder.getOrderCode();
290 BigDecimal earnestMoney = sellerOrder.getEarnestMoney(); 290 BigDecimal earnestMoney = sellerOrder.getEarnestMoney();
  291 + Integer sop = sellerOrder.getPayment() == null ? 0 : sellerOrder.getPayment();
291 PaymentRequest refundReqOfSeller = PaymentRequest.builder().uid(sellerUid).refundCase(RefundCase.SELLER_EARNEST_MONEY) 292 PaymentRequest refundReqOfSeller = PaymentRequest.builder().uid(sellerUid).refundCase(RefundCase.SELLER_EARNEST_MONEY)
292 .orderCode(sellerOrderCode).refundAmount(earnestMoney.doubleValue()) 293 .orderCode(sellerOrderCode).refundAmount(earnestMoney.doubleValue())
  294 + .payment(sop)
293 .build(); 295 .build();
294 boolean sellerIsSuper = sellerService.isSuperEntrySeller(sellerUid); 296 boolean sellerIsSuper = sellerService.isSuperEntrySeller(sellerUid);
295 refundReqOfSeller.setSuper(sellerIsSuper); 297 refundReqOfSeller.setSuper(sellerIsSuper);
296 - if (!sellerIsSuper && PaymentHelper.isWallet(sellerOrder.getPayment())){ 298 + if (!sellerIsSuper && PaymentHelper.isWallet(sop)){
297 299
298 MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(sellerUid) 300 MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(sellerUid)
299 .orderCode(sellerOrderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney()) 301 .orderCode(sellerOrderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney())
@@ -9,6 +9,7 @@ import com.yohoufo.order.model.PayRefundBo; @@ -9,6 +9,7 @@ import com.yohoufo.order.model.PayRefundBo;
9 import com.yohoufo.order.model.request.PaymentRequest; 9 import com.yohoufo.order.model.request.PaymentRequest;
10 import com.yohoufo.order.service.IPaymentService; 10 import com.yohoufo.order.service.IPaymentService;
11 import com.yohoufo.order.utils.LoggerUtils; 11 import com.yohoufo.order.utils.LoggerUtils;
  12 +import com.yohoufo.order.utils.PaymentHelper;
12 import org.slf4j.Logger; 13 import org.slf4j.Logger;
13 import org.springframework.beans.factory.annotation.Autowired; 14 import org.springframework.beans.factory.annotation.Autowired;
14 import org.springframework.stereotype.Service; 15 import org.springframework.stereotype.Service;
@@ -26,10 +27,7 @@ public class PayRefundService { @@ -26,10 +27,7 @@ public class PayRefundService {
26 27
27 public PayRefundBo refund(PaymentRequest refundReq, BillLogEvent.BillLogEventBuilder bleBuilder){ 28 public PayRefundBo refund(PaymentRequest refundReq, BillLogEvent.BillLogEventBuilder bleBuilder){
28 logger.info("in pay refund, refundReq {}", refundReq); 29 logger.info("in pay refund, refundReq {}", refundReq);
29 - boolean toSeller = refundReq.getRefundCase() !=null && RefundCase.SELLER_EARNEST_MONEY == refundReq.getRefundCase();  
30 - if(refundReq.isSuper() && toSeller){  
31 - return null;  
32 - } 30 +
33 PayRefundBo refundResp = paymentService.refund(refundReq); 31 PayRefundBo refundResp = paymentService.refund(refundReq);
34 32
35 33
@@ -343,11 +343,14 @@ public class SellerOrderCancelService { @@ -343,11 +343,14 @@ public class SellerOrderCancelService {
343 if(result > 0 ){ 343 if(result > 0 ){
344 double earnestMoney = sellerOrder.getEarnestMoney().doubleValue(); 344 double earnestMoney = sellerOrder.getEarnestMoney().doubleValue();
345 boolean isSuper = sellerService.isSuperEntrySeller(sellerUid); 345 boolean isSuper = sellerService.isSuperEntrySeller(sellerUid);
  346 + Integer sop = sellerOrder.getPayment() == null ? 0 : sellerOrder.getPayment();
346 PaymentRequest refundReq = PaymentRequest.builder().uid(sellerUid) 347 PaymentRequest refundReq = PaymentRequest.builder().uid(sellerUid)
347 .orderCode(orderCode).isSuper(isSuper) 348 .orderCode(orderCode).isSuper(isSuper)
  349 + .refundCase(RefundCase.SELLER_EARNEST_MONEY)
  350 + .payment(sop)
348 .refundAmount(earnestMoney).build(); 351 .refundAmount(earnestMoney).build();
349 352
350 - if (!isSuper && PaymentHelper.isWallet(sellerOrder.getPayment())){ 353 + if (!isSuper && PaymentHelper.isWallet(sop)){
351 SellerWalletDetail.Type swdType = SellerWalletDetail.Type.SELLER_OFF; 354 SellerWalletDetail.Type swdType = SellerWalletDetail.Type.SELLER_OFF;
352 MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(sellerUid) 355 MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(sellerUid)
353 .orderCode(orderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney()) 356 .orderCode(orderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney())
@@ -652,15 +655,16 @@ public class SellerOrderCancelService { @@ -652,15 +655,16 @@ public class SellerOrderCancelService {
652 cacheCleaner.cleanSellerDetail(psog); 655 cacheCleaner.cleanSellerDetail(psog);
653 double earnestMoney = sellerOrder.getEarnestMoney().doubleValue(); 656 double earnestMoney = sellerOrder.getEarnestMoney().doubleValue();
654 657
655 - 658 + Integer sop = sellerOrder.getPayment() == null ? 0 : sellerOrder.getPayment();
656 PaymentRequest refundReq = PaymentRequest.builder().uid(sellerUid) 659 PaymentRequest refundReq = PaymentRequest.builder().uid(sellerUid)
657 .orderCode(orderCode) 660 .orderCode(orderCode)
  661 + .refundCase(RefundCase.SELLER_EARNEST_MONEY)
  662 + .payment(sop)
658 .refundAmount(earnestMoney).build(); 663 .refundAmount(earnestMoney).build();
659 - Integer payment = sellerOrder.getPayment();  
660 boolean sellerIsSurper = sellerService.isSuperEntrySeller(sellerUid); 664 boolean sellerIsSurper = sellerService.isSuperEntrySeller(sellerUid);
661 refundReq.setSuper(sellerIsSurper); 665 refundReq.setSuper(sellerIsSurper);
662 // 666 //
663 - if(!sellerIsSurper && PaymentHelper.isWallet(payment)){ 667 + if(!sellerIsSurper && PaymentHelper.isWallet(sop)){
664 MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(sellerUid) 668 MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(sellerUid)
665 .orderCode(orderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney()) 669 .orderCode(orderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney())
666 .type(SellerWalletDetail.Type.SYSTEM_OFF.getValue()).build(); 670 .type(SellerWalletDetail.Type.SYSTEM_OFF.getValue()).build();