Authored by chenchao

buyer cancel use new calculate args

@@ -18,6 +18,7 @@ public class BuyerPenaltyCalResult { @@ -18,6 +18,7 @@ public class BuyerPenaltyCalResult {
18 private Integer uid; 18 private Integer uid;
19 private Long orderCode; 19 private Long orderCode;
20 private BigDecimal orderActualAmount; 20 private BigDecimal orderActualAmount;
  21 + private BigDecimal goodsActualAmount;
21 private BigDecimal penaltyAmount; 22 private BigDecimal penaltyAmount;
22 private BigDecimal leftAmount; 23 private BigDecimal leftAmount;
23 private BigDecimal penaltyRate; 24 private BigDecimal penaltyRate;
@@ -69,7 +69,7 @@ public class BuyerOrderCancelService { @@ -69,7 +69,7 @@ public class BuyerOrderCancelService {
69 private CouponProxyService couponProxyService; 69 private CouponProxyService couponProxyService;
70 70
71 @Autowired 71 @Autowired
72 - private IPaymentService paymentService; 72 + private TransferService transferService;
73 73
74 @Autowired 74 @Autowired
75 private SellerOrderMapper sellerOrderMapper; 75 private SellerOrderMapper sellerOrderMapper;
@@ -100,6 +100,7 @@ public class BuyerOrderCancelService { @@ -100,6 +100,7 @@ public class BuyerOrderCancelService {
100 */ 100 */
101 public BuyerPenaltyCalResult calBuyerPenalty(Integer buyerUid, Long orderCode, OrderStatus orderStatus, 101 public BuyerPenaltyCalResult calBuyerPenalty(Integer buyerUid, Long orderCode, OrderStatus orderStatus,
102 BigDecimal orderActualAmount, 102 BigDecimal orderActualAmount,
  103 + BigDecimal shipFee,
103 OrderAttributes orderAttributes 104 OrderAttributes orderAttributes
104 ){ 105 ){
105 if (Objects.isNull(orderAttributes)){ 106 if (Objects.isNull(orderAttributes)){
@@ -144,7 +145,7 @@ public class BuyerOrderCancelService { @@ -144,7 +145,7 @@ public class BuyerOrderCancelService {
144 } 145 }
145 } 146 }
146 //TODO quick deliver 147 //TODO quick deliver
147 - BuyerPenaltyCalResult bpcr = calBuyerPenalty( mfee,buyerUid, orderCode, orderActualAmount); 148 + BuyerPenaltyCalResult bpcr = calBuyerPenalty( mfee,buyerUid, orderCode, orderActualAmount, shipFee);
148 if (bpcr.getLeftAmount().compareTo(BigDecimal.ZERO)<=0){ 149 if (bpcr.getLeftAmount().compareTo(BigDecimal.ZERO)<=0){
149 throw new UfoServiceException(501, "left amount not enough"); 150 throw new UfoServiceException(501, "left amount not enough");
150 } 151 }
@@ -152,16 +153,19 @@ public class BuyerOrderCancelService { @@ -152,16 +153,19 @@ public class BuyerOrderCancelService {
152 } 153 }
153 154
154 public BuyerPenaltyCalResult calBuyerPenalty(BuyerPenalty.Fee mfee,Integer buyerUid, Long orderCode, 155 public BuyerPenaltyCalResult calBuyerPenalty(BuyerPenalty.Fee mfee,Integer buyerUid, Long orderCode,
155 - BigDecimal orderActualAmount){ 156 + BigDecimal orderActualAmount, BigDecimal shipFee){
156 BigDecimal penaltyRate = mfee.getRate(); 157 BigDecimal penaltyRate = mfee.getRate();
157 - BigDecimal penaltyAmount = BigDecimalHelper.halfUp(orderActualAmount.multiply(penaltyRate)); 158 + BigDecimal goodsActualAmount = orderActualAmount.subtract(shipFee);
  159 + BigDecimal penaltyAmount = BigDecimalHelper.halfUp(goodsActualAmount.multiply(penaltyRate));
158 BuyerPenalty.Range moneyRange = mfee.getMoneyRange(); 160 BuyerPenalty.Range moneyRange = mfee.getMoneyRange();
159 if (penaltyAmount.compareTo(moneyRange.getMin()) < 0){ 161 if (penaltyAmount.compareTo(moneyRange.getMin()) < 0){
160 penaltyAmount = moneyRange.getMin(); 162 penaltyAmount = moneyRange.getMin();
161 } 163 }
162 BigDecimal leftAmount = orderActualAmount.subtract(penaltyAmount); 164 BigDecimal leftAmount = orderActualAmount.subtract(penaltyAmount);
163 BuyerPenaltyCalResult bpcr = BuyerPenaltyCalResult.builder().uid(buyerUid).orderCode(orderCode) 165 BuyerPenaltyCalResult bpcr = BuyerPenaltyCalResult.builder().uid(buyerUid).orderCode(orderCode)
164 - .orderActualAmount(orderActualAmount).penaltyRate(penaltyRate) 166 + .orderActualAmount(orderActualAmount)
  167 + .goodsActualAmount(goodsActualAmount)
  168 + .penaltyRate(penaltyRate)
165 .penaltyAmount(penaltyAmount).leftAmount(leftAmount).build(); 169 .penaltyAmount(penaltyAmount).leftAmount(leftAmount).build();
166 logger.info("calBuyerPenalty mfee {} BuyerPenaltyCalResult {}", mfee, bpcr); 170 logger.info("calBuyerPenalty mfee {} BuyerPenaltyCalResult {}", mfee, bpcr);
167 return bpcr; 171 return bpcr;
@@ -331,6 +335,87 @@ public class BuyerOrderCancelService { @@ -331,6 +335,87 @@ public class BuyerOrderCancelService {
331 this.transferCase = transferCase; 335 this.transferCase = transferCase;
332 } 336 }
333 337
  338 + private PayRefundBo refundSellerEarnestMoney(SellerOrder sellerOrder){
  339 + PayRefundBo prb = null;
  340 + int sellerUid = sellerOrder.getUid();
  341 + long sellerOrderCode = sellerOrder.getOrderCode();
  342 + BigDecimal earnestMoney = sellerOrder.getEarnestMoney();
  343 + PaymentRequest refundReqOfSeller = PaymentRequest.builder().uid(sellerUid).refundCase(RefundCase.SELLER_EARNEST_MONEY)
  344 + .orderCode(sellerOrderCode).refundAmount(earnestMoney.doubleValue())
  345 + .build();
  346 + boolean sellerIsSuper = sellerService.isSuperEntrySeller(sellerUid);
  347 + refundReqOfSeller.setSuper(sellerIsSuper);
  348 + if (!sellerIsSuper && PaymentHelper.isWallet(sellerOrder.getPayment())){
  349 +
  350 + MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(sellerUid)
  351 + .orderCode(sellerOrderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney())
  352 + .type(swdType.getValue()).build();
  353 + refundReqOfSeller.setRefundattch(moai);
  354 + }
  355 +
  356 + BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder()
  357 + .buyerUid(buyerUid).sellerUid(sellerUid).orderCode(sellerOrder.getOrderCode())
  358 + .payType(sellerOrder.getPayment()).refundCase(RefundCase.SELLER_EARNEST_MONEY)
  359 + .skup(skup);
  360 + logger.info("in BuyerCancelAfterProcessTask call begin payRefundService.refund seller, buyerUid {}, orderCode {}, skup {} refundReqOfSeller {}",
  361 + buyerUid, orderCode, skup, refundReqOfSeller );
  362 + try {
  363 + prb = payRefundService.refund(refundReqOfSeller, bleb);
  364 + }catch (Exception ex){
  365 + if (!sellerIsSuper) {
  366 + BillLogEvent sellerBillLogEvent = bleb.tradeStatus(BillTradeStatus.FAIL.getCode())
  367 + .build();
  368 + EventBusPublisher.publishEvent(sellerBillLogEvent);
  369 + }
  370 + String content = "用户" + sellerUid + "退保证金订单"+ orderCode +"失败";
  371 + SmsAlarmEvent smsAlarmEvent = new SmsAlarmEvent("buyerPaidOrder.selfCancel", "cancel", content);
  372 + EventBusPublisher.publishEvent(smsAlarmEvent);
  373 + }
  374 + logger.info("in BuyerCancelAfterProcessTask call after payRefundService.refund seller, buyerUid {}, orderCode {}, skup {} refundReqOfSeller {}",
  375 + buyerUid, orderCode, skup, refundReqOfSeller );
  376 + return prb;
  377 + }
  378 +
  379 + void transferPenalty(BuyerPenaltyCalResult bpcr){
  380 + TranseferCellNode transeferCellNode = new TranseferCellNode();
  381 + transeferCellNode.setUid(buyerUid);
  382 + transeferCellNode.setAmount(bpcr.getPenaltyAmount());
  383 + TransferMoneyRequest tmReq = TransferMoneyRequest.builder().buyerOrderCode(orderCode)
  384 + .type(transferCase.getCode()).transferCase(transferCase)
  385 + .transeferCellNode(transeferCellNode).build();
  386 + logger.info("in BuyerCancelAfterProcessTask call begin paymentService.transferMon, buyerUid {}, orderCode {}, skup {} refundReqOfSeller {}",
  387 + buyerUid, orderCode, skup, tmReq );
  388 + transferService.transfer(tmReq);
  389 + logger.info("in BuyerCancelAfterProcessTask call after paymentService.transferMon, buyerUid {}, orderCode {}, skup {} refundReqOfSeller {}",
  390 + buyerUid, orderCode, skup, tmReq );
  391 + }
  392 +
  393 + void refundLeftOrderAmount(BuyerPenaltyCalResult bpcr, BuyerOrder buyerOrder){
  394 + Integer sellerUid = buyerOrder.getSellerUid();
  395 + BigDecimal leftBuyerMoney = bpcr.getLeftAmount();
  396 + PaymentRequest rprOfBuyer = PaymentRequest.builder().uid(buyerUid)
  397 + .orderCode(orderCode).refundAmount(leftBuyerMoney.doubleValue())
  398 + .build();
  399 + BillLogEvent.BillLogEventBuilder blebOfBuyer = BillLogEvent.builder()
  400 + .buyerUid(buyerUid).sellerUid(sellerUid).orderCode(orderCode)
  401 + .payType(buyerOrder.getPayment()).refundCase(RefundCase.BUYER_GOODS_MONEY)
  402 + .amount(leftBuyerMoney)
  403 + .skup(skup);
  404 + logger.info("in BuyerCancelAfterProcessTask call begin payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} refundReqOfSeller {}",
  405 + buyerUid, orderCode, skup, rprOfBuyer );
  406 + try {
  407 + payRefundService.refund(rprOfBuyer, blebOfBuyer);
  408 + }catch (Exception ex){
  409 + BillLogEvent buyerBillLogEvent = blebOfBuyer.tradeStatus(BillTradeStatus.FAIL.getCode()).build();
  410 + EventBusPublisher.publishEvent(buyerBillLogEvent);
  411 + String content = "用户" + buyerUid + "订单"+ orderCode +"退货款失败";
  412 + SmsAlarmEvent smsAlarmEvent = new SmsAlarmEvent("buyerPaidOrder.selfCancel", "cancel", content);
  413 + EventBusPublisher.publishEvent(smsAlarmEvent);
  414 + }
  415 + logger.info("in BuyerCancelAfterProcessTask call after payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} refundReqOfSeller {}",
  416 + buyerUid, orderCode, skup, rprOfBuyer );
  417 + }
  418 +
334 @Override 419 @Override
335 public PayRefundBo call() throws Exception { 420 public PayRefundBo call() throws Exception {
336 // 整个过程异步去执行(考虑退费依赖订单状态) 421 // 整个过程异步去执行(考虑退费依赖订单状态)
@@ -342,80 +427,21 @@ public class BuyerOrderCancelService { @@ -342,80 +427,21 @@ public class BuyerOrderCancelService {
342 SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(skup); 427 SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(skup);
343 logger.info("in BuyerCancelAfterProcessTask call sellerOrderMapper.selectBySkup, buyerUid {}, orderCode {}, skup {}", 428 logger.info("in BuyerCancelAfterProcessTask call sellerOrderMapper.selectBySkup, buyerUid {}, orderCode {}, skup {}",
344 buyerUid, orderCode, skup ); 429 buyerUid, orderCode, skup );
345 - int sellerUid = sellerOrder.getUid();  
346 - long sellerOrderCode = sellerOrder.getOrderCode();  
347 - BigDecimal earnestMoney = sellerOrder.getEarnestMoney();  
348 - PaymentRequest refundReqOfSeller = PaymentRequest.builder().uid(sellerUid).refundCase(RefundCase.SELLER_EARNEST_MONEY)  
349 - .orderCode(sellerOrderCode).refundAmount(earnestMoney.doubleValue())  
350 - .build();  
351 - boolean sellerIsSuper = sellerService.isSuperEntrySeller(sellerUid);  
352 - refundReqOfSeller.setSuper(sellerIsSuper);  
353 - if (!sellerIsSuper && PaymentHelper.isWallet(sellerOrder.getPayment())){  
354 -  
355 - MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(sellerUid)  
356 - .orderCode(sellerOrderCode).skup(skup).earnestMoney(sellerOrder.getEarnestMoney())  
357 - .type(swdType.getValue()).build();  
358 - refundReqOfSeller.setRefundattch(moai);  
359 - } 430 + prb = refundSellerEarnestMoney(sellerOrder);
360 431
361 - BillLogEvent.BillLogEventBuilder bleb = BillLogEvent.builder()  
362 - .buyerUid(buyerUid).sellerUid(sellerUid).orderCode(sellerOrder.getOrderCode())  
363 - .payType(sellerOrder.getPayment()).refundCase(RefundCase.SELLER_EARNEST_MONEY)  
364 - .skup(skup);  
365 - logger.info("in BuyerCancelAfterProcessTask call begin payRefundService.refund seller, buyerUid {}, orderCode {}, skup {} refundReqOfSeller {}",  
366 - buyerUid, orderCode, skup, refundReqOfSeller );  
367 - try {  
368 - prb = payRefundService.refund(refundReqOfSeller, bleb);  
369 - }catch (Exception ex){  
370 - if (!sellerIsSuper) {  
371 - BillLogEvent sellerBillLogEvent = bleb.tradeStatus(BillTradeStatus.FAIL.getCode())  
372 - .build();  
373 - EventBusPublisher.publishEvent(sellerBillLogEvent);  
374 - }  
375 - String content = "用户" + sellerUid + "退保证金订单"+ orderCode +"失败";  
376 - SmsAlarmEvent smsAlarmEvent = new SmsAlarmEvent("buyerPaidOrder.selfCancel", "cancel", content);  
377 - EventBusPublisher.publishEvent(smsAlarmEvent);  
378 - }  
379 - logger.info("in BuyerCancelAfterProcessTask call after payRefundService.refund seller, buyerUid {}, orderCode {}, skup {} refundReqOfSeller {}",  
380 - buyerUid, orderCode, skup, refundReqOfSeller );  
381 //(转账)瓜分指定赔偿款给卖家和平台 432 //(转账)瓜分指定赔偿款给卖家和平台
382 -  
383 - TransferMoneyRequest tmReq = TransferMoneyRequest.builder().buyerOrderCode(orderCode)  
384 - .type(transferCase.getCode()).transferCase(transferCase).build();  
385 - logger.info("in BuyerCancelAfterProcessTask call begin paymentService.transferMon, buyerUid {}, orderCode {}, skup {} refundReqOfSeller {}",  
386 - buyerUid, orderCode, skup, tmReq );  
387 - paymentService.transferMon(tmReq);  
388 - logger.info("in BuyerCancelAfterProcessTask call after paymentService.transferMon, buyerUid {}, orderCode {}, skup {} refundReqOfSeller {}",  
389 - buyerUid, orderCode, skup, tmReq );  
390 -  
391 - //(退费)扣除赔偿款,计算剩余的货款,退给买家  
392 - BigDecimal compensateMoney = compensate.getBuyerCompensateMoney();  
393 BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode); 433 BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
394 logger.info("in BuyerCancelAfterProcessTask call begin buyerOrderMapper.selectByOrderCode, buyerUid {}, orderCode {}, skup {} buyerOrder {}", 434 logger.info("in BuyerCancelAfterProcessTask call begin buyerOrderMapper.selectByOrderCode, buyerUid {}, orderCode {}, skup {} buyerOrder {}",
395 buyerUid, orderCode, skup, buyerOrder ); 435 buyerUid, orderCode, skup, buyerOrder );
396 - BigDecimal leftBuyerMoney = buyerOrder.getAmount().subtract(compensateMoney);  
397 - PaymentRequest rprOfBuyer = PaymentRequest.builder().uid(buyerUid)  
398 - .orderCode(orderCode).refundAmount(leftBuyerMoney.doubleValue())  
399 - .build();  
400 - BillLogEvent.BillLogEventBuilder blebOfBuyer = BillLogEvent.builder()  
401 - .buyerUid(buyerUid).sellerUid(sellerUid).orderCode(orderCode)  
402 - .payType(buyerOrder.getPayment()).refundCase(RefundCase.BUYER_GOODS_MONEY)  
403 - .amount(leftBuyerMoney)  
404 - .skup(skup);  
405 - logger.info("in BuyerCancelAfterProcessTask call begin payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} refundReqOfSeller {}",  
406 - buyerUid, orderCode, skup, rprOfBuyer );  
407 - try {  
408 - payRefundService.refund(rprOfBuyer, blebOfBuyer);  
409 - }catch (Exception ex){  
410 - BillLogEvent buyerBillLogEvent = blebOfBuyer.tradeStatus(BillTradeStatus.FAIL.getCode()).build();  
411 - EventBusPublisher.publishEvent(buyerBillLogEvent);  
412 - String content = "用户" + buyerUid + "订单"+ orderCode +"退货款失败";  
413 - SmsAlarmEvent smsAlarmEvent = new SmsAlarmEvent("buyerPaidOrder.selfCancel", "cancel", content);  
414 - EventBusPublisher.publishEvent(smsAlarmEvent);  
415 - }  
416 - logger.info("in BuyerCancelAfterProcessTask call after payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} refundReqOfSeller {}",  
417 - buyerUid, orderCode, skup, rprOfBuyer );  
418 - 436 + OrderStatus orderStatus = OrderStatus.getOrderStatus(buyerOrder.getStatus());
  437 + BigDecimal orderActualAmount = buyerOrder.getAmount();
  438 + BigDecimal shipFee = buyerOrder.getShipFee();
  439 + OrderAttributes orderAttributes = OrderAttributes.getOrderAttributes(buyerOrder.getAttributes());
  440 + //TODO try catch to record fail transfer
  441 + BuyerPenaltyCalResult bpcr = calBuyerPenalty(buyerUid, orderCode, orderStatus, orderActualAmount, shipFee, orderAttributes);
  442 + transferPenalty(bpcr);
  443 + //(退费)扣除赔偿款,计算剩余的货款,退给买家
  444 + refundLeftOrderAmount(bpcr, buyerOrder);
419 logger.info("out BuyerCancelAfterProcessTask call buyerUid {}, orderCode {}, skup {}, transferCase {}, compensate {}", 445 logger.info("out BuyerCancelAfterProcessTask call buyerUid {}, orderCode {}, skup {}, transferCase {}, compensate {}",
420 buyerUid, orderCode, skup, transferCase, compensate); 446 buyerUid, orderCode, skup, transferCase, compensate);
421 }catch (Exception ex){ 447 }catch (Exception ex){
@@ -423,7 +449,6 @@ public class BuyerOrderCancelService { @@ -423,7 +449,6 @@ public class BuyerOrderCancelService {
423 buyerUid, orderCode, skup, transferCase, compensate, ex); 449 buyerUid, orderCode, skup, transferCase, compensate, ex);
424 } 450 }
425 return prb; 451 return prb;
426 -  
427 } 452 }
428 } 453 }
429 454
@@ -24,6 +24,7 @@ import com.yohoufo.order.model.PayQueryBo; @@ -24,6 +24,7 @@ import com.yohoufo.order.model.PayQueryBo;
24 import com.yohoufo.order.model.PayRefundBo; 24 import com.yohoufo.order.model.PayRefundBo;
25 import com.yohoufo.order.model.PaymentData; 25 import com.yohoufo.order.model.PaymentData;
26 import com.yohoufo.order.model.request.PaymentRequest; 26 import com.yohoufo.order.model.request.PaymentRequest;
  27 +import com.yohoufo.order.model.request.TranseferCellNode;
27 import com.yohoufo.order.model.request.TransferMoneyRequest; 28 import com.yohoufo.order.model.request.TransferMoneyRequest;
28 import com.yohoufo.order.model.response.PaymentConfirmRsp; 29 import com.yohoufo.order.model.response.PaymentConfirmRsp;
29 import com.yohoufo.order.model.response.PrepayResponse; 30 import com.yohoufo.order.model.response.PrepayResponse;
@@ -577,8 +578,10 @@ public class PaymentServiceImpl implements IPaymentService { @@ -577,8 +578,10 @@ public class PaymentServiceImpl implements IPaymentService {
577 record.setCreateTime(now); 578 record.setCreateTime(now);
578 579
579 logger.info("transferMon参数检查成功!插入初始化转账信息成功,接下来计算费用"); 580 logger.info("transferMon参数检查成功!插入初始化转账信息成功,接下来计算费用");
  581 + TranseferCellNode transeferCellNode = request.getTranseferCellNode();
580 // 算费 582 // 算费
581 - BigDecimal transferAmount = calcTransferAmount(sellerOrder.getUid(), sellerOrder.getSkup(), transferCase); 583 + BigDecimal transferAmount = calcTransferAmount(sellerOrder.getUid(),
  584 + sellerOrder.getSkup(), transferCase, transeferCellNode);
582 logger.info("transferMon计算费用结果为 {}", transferAmount); 585 logger.info("transferMon计算费用结果为 {}", transferAmount);
583 if (transferAmount == null) { 586 if (transferAmount == null) {
584 logger.warn("transferMonErr transferMon计算费用结果为 null, 不合法的金额"); 587 logger.warn("transferMonErr transferMon计算费用结果为 null, 不合法的金额");
@@ -1151,21 +1154,15 @@ public class PaymentServiceImpl implements IPaymentService { @@ -1151,21 +1154,15 @@ public class PaymentServiceImpl implements IPaymentService {
1151 addTradeBills(record); 1154 addTradeBills(record);
1152 } 1155 }
1153 1156
1154 - private BigDecimal getBuyerCancelBeforeSellerDeliver(){  
1155 - //todo  
1156 - return buyerCancelCompensateComputeHandler.calBeforeSellerDeliver();  
1157 - }  
1158 - private BigDecimal getBuyerCancelBeforeDepotReceive(){  
1159 - //todo  
1160 - return buyerCancelCompensateComputeHandler.calBeforeDepotReceive();  
1161 - }  
1162 1157
1163 - private BigDecimal calcTransferAmount(Integer sellerUid, Integer skup, TransferCase transferCase) {  
1164 - if (transferCase == TransferCase.BUYER_CANCEL_BEFORE_SELLER_DELIVER) {  
1165 - return getBuyerCancelBeforeSellerDeliver();  
1166 - }  
1167 - if (transferCase == TransferCase.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE) {  
1168 - return getBuyerCancelBeforeDepotReceive(); 1158 +
  1159 + private BigDecimal calcTransferAmount(Integer sellerUid, Integer skup,
  1160 + TransferCase transferCase,TranseferCellNode transeferCellNode) {
  1161 + //buyer cancel is first priory
  1162 + boolean isBuyerCancel = transferCase == TransferCase.BUYER_CANCEL_BEFORE_SELLER_DELIVER
  1163 + || transferCase == TransferCase.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE;
  1164 + if (isBuyerCancel) {
  1165 + return transeferCellNode.getAmount();
1169 } 1166 }
1170 1167
1171 SellerOrderMeta meta = sellerOrderMetaMapper.selectByMetaKey(sellerUid, skup, "fee"); 1168 SellerOrderMeta meta = sellerOrderMetaMapper.selectByMetaKey(sellerUid, skup, "fee");
@@ -30,9 +30,10 @@ public class BuyerOrderCancelServiceTest extends BaseWebTest { @@ -30,9 +30,10 @@ public class BuyerOrderCancelServiceTest extends BaseWebTest {
30 BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode); 30 BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
31 Integer buyerUid = buyerOrder.getUid(); 31 Integer buyerUid = buyerOrder.getUid();
32 OrderStatus orderStatus = OrderStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER; 32 OrderStatus orderStatus = OrderStatus.BUYER_CANCEL_BEFORE_SELLER_DELIVER;
33 - BigDecimal orderActualAmount = buyerOrder.getAmount().subtract(buyerOrder.getShipFee()); 33 + BigDecimal orderActualAmount = buyerOrder.getAmount(), shipFee = buyerOrder.getShipFee();
34 OrderAttributes orderAttributes = OrderAttributes.getOrderAttributes(buyerOrder.getAttributes()); 34 OrderAttributes orderAttributes = OrderAttributes.getOrderAttributes(buyerOrder.getAttributes());
35 - BuyerPenaltyCalResult bpcr = buyerOrderCancelService.calBuyerPenalty(buyerUid, orderCode, orderStatus, orderActualAmount, orderAttributes); 35 + BuyerPenaltyCalResult bpcr = buyerOrderCancelService.calBuyerPenalty(buyerUid, orderCode, orderStatus,
  36 + orderActualAmount, shipFee, orderAttributes);
36 System.out.println(JSONObject.toJSONString(bpcr)); 37 System.out.println(JSONObject.toJSONString(bpcr));
37 } 38 }
38 39
@@ -43,9 +44,10 @@ public class BuyerOrderCancelServiceTest extends BaseWebTest { @@ -43,9 +44,10 @@ public class BuyerOrderCancelServiceTest extends BaseWebTest {
43 BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode); 44 BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCode(orderCode);
44 Integer buyerUid = buyerOrder.getUid(); 45 Integer buyerUid = buyerOrder.getUid();
45 OrderStatus orderStatus = OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE; 46 OrderStatus orderStatus = OrderStatus.BUYER_CANCEL_BEFORE_DEPOT_RECEIVE;
46 - BigDecimal orderActualAmount = buyerOrder.getAmount().subtract(buyerOrder.getShipFee()); 47 + BigDecimal orderActualAmount = buyerOrder.getAmount(), shipFee = buyerOrder.getShipFee();
47 OrderAttributes orderAttributes = OrderAttributes.getOrderAttributes(buyerOrder.getAttributes()); 48 OrderAttributes orderAttributes = OrderAttributes.getOrderAttributes(buyerOrder.getAttributes());
48 - BuyerPenaltyCalResult bpcr = buyerOrderCancelService.calBuyerPenalty(buyerUid, orderCode, orderStatus, orderActualAmount, orderAttributes); 49 + BuyerPenaltyCalResult bpcr = buyerOrderCancelService.calBuyerPenalty(buyerUid, orderCode,
  50 + orderStatus, orderActualAmount,shipFee, orderAttributes);
49 System.out.println(JSONObject.toJSONString(bpcr)); 51 System.out.println(JSONObject.toJSONString(bpcr));
50 } 52 }
51 } 53 }