Authored by LUOXC

refactor

1 package com.yohoufo.order.constants; 1 package com.yohoufo.order.constants;
2 2
3 -public enum CutomsClearanceFailType {  
4 - PLATFORM,BUYER 3 +public enum ClearanceFailType {
  4 + PLATFORM, BUYER
5 } 5 }
@@ -12,7 +12,7 @@ import com.yohobuy.ufo.model.order.resp.PageResp; @@ -12,7 +12,7 @@ import com.yohobuy.ufo.model.order.resp.PageResp;
12 import com.yohoufo.common.ApiResponse; 12 import com.yohoufo.common.ApiResponse;
13 import com.yohoufo.common.annotation.IgnoreSession; 13 import com.yohoufo.common.annotation.IgnoreSession;
14 import com.yohoufo.common.annotation.IgnoreSignature; 14 import com.yohoufo.common.annotation.IgnoreSignature;
15 -import com.yohoufo.order.constants.CutomsClearanceFailType; 15 +import com.yohoufo.order.constants.ClearanceFailType;
16 import com.yohoufo.order.model.request.OrderListRequest; 16 import com.yohoufo.order.model.request.OrderListRequest;
17 import com.yohoufo.order.model.request.OrderRequest; 17 import com.yohoufo.order.model.request.OrderRequest;
18 import com.yohoufo.order.model.request.SaveQualityCheckInfoRequest; 18 import com.yohoufo.order.model.request.SaveQualityCheckInfoRequest;
@@ -168,9 +168,7 @@ public class ErpGWOrderController { @@ -168,9 +168,7 @@ public class ErpGWOrderController {
168 @IgnoreSignature 168 @IgnoreSignature
169 @RequestMapping(value = "/cancelOverseasOrderForBuyerClearFail") 169 @RequestMapping(value = "/cancelOverseasOrderForBuyerClearFail")
170 public ApiResponse cancelOverseasOrderForBuyerClearFail(@RequestBody BuyerOrderCancelReq request) { 170 public ApiResponse cancelOverseasOrderForBuyerClearFail(@RequestBody BuyerOrderCancelReq request) {
171 - LOG.info("api cancelClearFailOrderManual in, req is {}", request);  
172 - buyerOrderCancelService.cancelOverseasOrder(request.getOrderCode(), request.getCancelReason(), CutomsClearanceFailType.BUYER);  
173 - LOG.info("api cancelClearFailOrderManual out, req is {}", request); 171 + buyerOrderCancelService.clearanceFail(request.getOrderCode(), request.getCancelReason(), ClearanceFailType.BUYER);
174 return new ApiResponse.ApiResponseBuilder().code(200).message("取消海外直邮订单成功").build(); 172 return new ApiResponse.ApiResponseBuilder().code(200).message("取消海外直邮订单成功").build();
175 } 173 }
176 174
@@ -181,24 +179,18 @@ public class ErpGWOrderController { @@ -181,24 +179,18 @@ public class ErpGWOrderController {
181 @IgnoreSignature 179 @IgnoreSignature
182 @RequestMapping(value = "/cancelOverseasOrder") 180 @RequestMapping(value = "/cancelOverseasOrder")
183 public ApiResponse cancelOverseasOrder(@RequestBody BuyerOrderCancelReq request) { 181 public ApiResponse cancelOverseasOrder(@RequestBody BuyerOrderCancelReq request) {
184 - LOG.info("api cancelOverseasOrder in, req is {}", request);  
185 int cancelType = request.getCancelType(); 182 int cancelType = request.getCancelType();
186 final OrderStatus orderStatus = OrderStatus.getOrderStatus(cancelType); 183 final OrderStatus orderStatus = OrderStatus.getOrderStatus(cancelType);
187 - CutomsClearanceFailType ccft = null; 184 + ClearanceFailType clearanceFailType = null;
188 switch (orderStatus){ 185 switch (orderStatus){
189 case PLATFORM_BLOWN_CUSTOMS_CLEARANCE: 186 case PLATFORM_BLOWN_CUSTOMS_CLEARANCE:
190 - ccft = CutomsClearanceFailType.PLATFORM; 187 + clearanceFailType = ClearanceFailType.PLATFORM;
191 break; 188 break;
192 case BUYER_BLOWN_CUSTOMS_CLEARANCE: 189 case BUYER_BLOWN_CUSTOMS_CLEARANCE:
193 - ccft = CutomsClearanceFailType.BUYER; 190 + clearanceFailType = ClearanceFailType.BUYER;
194 break; 191 break;
195 } 192 }
196 - if (ccft == null){  
197 - LOG.warn("in api cancelOverseasOrder CutomsClearanceFailType null, req {}", request);  
198 - return new ApiResponse.ApiResponseBuilder().code(400).message("param cancelType wrong").build();  
199 - }  
200 - buyerOrderCancelService.cancelOverseasOrder(request.getOrderCode(), request.getCancelReason(), ccft);  
201 - LOG.info("api cancelOverseasOrder out, req is {}", request); 193 + buyerOrderCancelService.clearanceFail(request.getOrderCode(), request.getCancelReason(), clearanceFailType);
202 return new ApiResponse.ApiResponseBuilder().code(200).message("取消海外直邮订单成功").build(); 194 return new ApiResponse.ApiResponseBuilder().code(200).message("取消海外直邮订单成功").build();
203 } 195 }
204 196
@@ -20,7 +20,7 @@ import com.yohoufo.dal.order.model.*; @@ -20,7 +20,7 @@ import com.yohoufo.dal.order.model.*;
20 import com.yohoufo.order.common.RefundCase; 20 import com.yohoufo.order.common.RefundCase;
21 import com.yohoufo.order.common.TransferCase; 21 import com.yohoufo.order.common.TransferCase;
22 import com.yohoufo.order.constants.AlarmConfig; 22 import com.yohoufo.order.constants.AlarmConfig;
23 -import com.yohoufo.order.constants.CutomsClearanceFailType; 23 +import com.yohoufo.order.constants.ClearanceFailType;
24 import com.yohoufo.order.constants.MetaKey; 24 import com.yohoufo.order.constants.MetaKey;
25 import com.yohoufo.order.event.*; 25 import com.yohoufo.order.event.*;
26 import com.yohoufo.order.model.PayRefundBo; 26 import com.yohoufo.order.model.PayRefundBo;
@@ -347,8 +347,8 @@ public class BuyerOrderCancelService { @@ -347,8 +347,8 @@ public class BuyerOrderCancelService {
347 } 347 }
348 348
349 349
350 - public void cancelOverseasOrder(long orderCode, String failReason, CutomsClearanceFailType failType){  
351 - new CancelOverseasOrderModel(orderCode, failReason, failType).invoke().cancel(); 350 + public void clearanceFail(long orderCode, String failReason, ClearanceFailType failType){
  351 + new ClearanceFailModel(orderCode, failReason, failType).invoke().cancel();
352 } 352 }
353 353
354 private void compensateCoupon2Buyer(BigDecimal goodsAmount, int uid, long orderCode) { 354 private void compensateCoupon2Buyer(BigDecimal goodsAmount, int uid, long orderCode) {
@@ -543,10 +543,10 @@ public class BuyerOrderCancelService { @@ -543,10 +543,10 @@ public class BuyerOrderCancelService {
543 EventBusPublisher.publishEvent(buyerRefundCouponEvent); 543 EventBusPublisher.publishEvent(buyerRefundCouponEvent);
544 } 544 }
545 545
546 - private class CancelOverseasOrderModel { 546 + private class ClearanceFailModel {
547 private final long orderCode; 547 private final long orderCode;
548 private final String failReason; 548 private final String failReason;
549 - private final CutomsClearanceFailType failType; 549 + private final ClearanceFailType failType;
550 550
551 551
552 String logTag; 552 String logTag;
@@ -554,18 +554,18 @@ public class BuyerOrderCancelService { @@ -554,18 +554,18 @@ public class BuyerOrderCancelService {
554 private Consumer<RefundGoodsAmountNode> refundGoodsAmountConsumer; 554 private Consumer<RefundGoodsAmountNode> refundGoodsAmountConsumer;
555 private BuyerOrder buyerOrder; 555 private BuyerOrder buyerOrder;
556 556
557 - CancelOverseasOrderModel(long orderCode, String failReason, CutomsClearanceFailType failType) { 557 + ClearanceFailModel(long orderCode, String failReason, ClearanceFailType failType) {
558 this.orderCode = orderCode; 558 this.orderCode = orderCode;
559 this.failReason = failReason; 559 this.failReason = failReason;
560 this.failType = failType; 560 this.failType = failType;
561 } 561 }
562 562
563 - public CancelOverseasOrderModel invoke() {  
564 - logTag = String.format("cancel overseas order %s", orderCode); 563 + public ClearanceFailModel invoke() {
  564 + logTag = String.format("clearance fail %s", orderCode);
565 logger.info("{} failType is {} failReason is {}", logTag, failType, failReason); 565 logger.info("{} failType is {} failReason is {}", logTag, failType, failReason);
566 566
567 throwServiceExceptionIf(orderCode <= 0L, "订单号不存在"); 567 throwServiceExceptionIf(orderCode <= 0L, "订单号不存在");
568 - throwServiceExceptionIf(StringUtils.isBlank(failReason), "失败原因不能为空"); 568 + throwServiceExceptionIf(StringUtils.isBlank(failReason), "清关失败原因不能为空");
569 targetStatus = null; 569 targetStatus = null;
570 refundGoodsAmountConsumer = null; 570 refundGoodsAmountConsumer = null;
571 switch (failType) { 571 switch (failType) {
@@ -578,7 +578,7 @@ public class BuyerOrderCancelService { @@ -578,7 +578,7 @@ public class BuyerOrderCancelService {
578 refundGoodsAmountConsumer = refundGoodsAmountNode -> userReason(refundGoodsAmountNode); 578 refundGoodsAmountConsumer = refundGoodsAmountNode -> userReason(refundGoodsAmountNode);
579 break; 579 break;
580 default: 580 default:
581 - throwServiceException("无效的目标状态"); 581 + throwServiceException("无效的清关失败原因");
582 } 582 }
583 583
584 buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode); 584 buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
@@ -708,7 +708,7 @@ public class BuyerOrderCancelService { @@ -708,7 +708,7 @@ public class BuyerOrderCancelService {
708 Long orderCode = buyerOrder.getOrderCode(); 708 Long orderCode = buyerOrder.getOrderCode();
709 // 709 //
710 710
711 - logger.info("cancelOverseasOrder refundGoodsAmount begin payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} refundAmount {}", 711 + logger.info("clearanceFail refundGoodsAmount begin payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} refundAmount {}",
712 buyerUid, orderCode, skup, leftBuyerMoney ); 712 buyerUid, orderCode, skup, leftBuyerMoney );
713 713
714 new RefundGoodsMoneyHandler().loadLogger(logger) 714 new RefundGoodsMoneyHandler().loadLogger(logger)
@@ -717,7 +717,7 @@ public class BuyerOrderCancelService { @@ -717,7 +717,7 @@ public class BuyerOrderCancelService {
717 .loadTargetOrderStatus(targetOrderStatus) 717 .loadTargetOrderStatus(targetOrderStatus)
718 .loadSellerOrderGoods(sellerUid, skup) 718 .loadSellerOrderGoods(sellerUid, skup)
719 .refund(); 719 .refund();
720 - logger.info("cancelOverseasOrder refundGoodsAmount after payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} refundAmount {}", 720 + logger.info("clearanceFail refundGoodsAmount after payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} refundAmount {}",
721 buyerUid, orderCode, skup, leftBuyerMoney ); 721 buyerUid, orderCode, skup, leftBuyerMoney );
722 } 722 }
723 } 723 }