Authored by LUOXC

refactor

package com.yohoufo.order.constants;
public enum CutomsClearanceFailType {
PLATFORM,BUYER
public enum ClearanceFailType {
PLATFORM, BUYER
}
... ...
... ... @@ -12,7 +12,7 @@ import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.annotation.IgnoreSession;
import com.yohoufo.common.annotation.IgnoreSignature;
import com.yohoufo.order.constants.CutomsClearanceFailType;
import com.yohoufo.order.constants.ClearanceFailType;
import com.yohoufo.order.model.request.OrderListRequest;
import com.yohoufo.order.model.request.OrderRequest;
import com.yohoufo.order.model.request.SaveQualityCheckInfoRequest;
... ... @@ -168,9 +168,7 @@ public class ErpGWOrderController {
@IgnoreSignature
@RequestMapping(value = "/cancelOverseasOrderForBuyerClearFail")
public ApiResponse cancelOverseasOrderForBuyerClearFail(@RequestBody BuyerOrderCancelReq request) {
LOG.info("api cancelClearFailOrderManual in, req is {}", request);
buyerOrderCancelService.cancelOverseasOrder(request.getOrderCode(), request.getCancelReason(), CutomsClearanceFailType.BUYER);
LOG.info("api cancelClearFailOrderManual out, req is {}", request);
buyerOrderCancelService.clearanceFail(request.getOrderCode(), request.getCancelReason(), ClearanceFailType.BUYER);
return new ApiResponse.ApiResponseBuilder().code(200).message("取消海外直邮订单成功").build();
}
... ... @@ -181,24 +179,18 @@ public class ErpGWOrderController {
@IgnoreSignature
@RequestMapping(value = "/cancelOverseasOrder")
public ApiResponse cancelOverseasOrder(@RequestBody BuyerOrderCancelReq request) {
LOG.info("api cancelOverseasOrder in, req is {}", request);
int cancelType = request.getCancelType();
final OrderStatus orderStatus = OrderStatus.getOrderStatus(cancelType);
CutomsClearanceFailType ccft = null;
ClearanceFailType clearanceFailType = null;
switch (orderStatus){
case PLATFORM_BLOWN_CUSTOMS_CLEARANCE:
ccft = CutomsClearanceFailType.PLATFORM;
clearanceFailType = ClearanceFailType.PLATFORM;
break;
case BUYER_BLOWN_CUSTOMS_CLEARANCE:
ccft = CutomsClearanceFailType.BUYER;
clearanceFailType = ClearanceFailType.BUYER;
break;
}
if (ccft == null){
LOG.warn("in api cancelOverseasOrder CutomsClearanceFailType null, req {}", request);
return new ApiResponse.ApiResponseBuilder().code(400).message("param cancelType wrong").build();
}
buyerOrderCancelService.cancelOverseasOrder(request.getOrderCode(), request.getCancelReason(), ccft);
LOG.info("api cancelOverseasOrder out, req is {}", request);
buyerOrderCancelService.clearanceFail(request.getOrderCode(), request.getCancelReason(), clearanceFailType);
return new ApiResponse.ApiResponseBuilder().code(200).message("取消海外直邮订单成功").build();
}
... ...
... ... @@ -20,7 +20,7 @@ import com.yohoufo.dal.order.model.*;
import com.yohoufo.order.common.RefundCase;
import com.yohoufo.order.common.TransferCase;
import com.yohoufo.order.constants.AlarmConfig;
import com.yohoufo.order.constants.CutomsClearanceFailType;
import com.yohoufo.order.constants.ClearanceFailType;
import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.event.*;
import com.yohoufo.order.model.PayRefundBo;
... ... @@ -347,8 +347,8 @@ public class BuyerOrderCancelService {
}
public void cancelOverseasOrder(long orderCode, String failReason, CutomsClearanceFailType failType){
new CancelOverseasOrderModel(orderCode, failReason, failType).invoke().cancel();
public void clearanceFail(long orderCode, String failReason, ClearanceFailType failType){
new ClearanceFailModel(orderCode, failReason, failType).invoke().cancel();
}
private void compensateCoupon2Buyer(BigDecimal goodsAmount, int uid, long orderCode) {
... ... @@ -543,10 +543,10 @@ public class BuyerOrderCancelService {
EventBusPublisher.publishEvent(buyerRefundCouponEvent);
}
private class CancelOverseasOrderModel {
private class ClearanceFailModel {
private final long orderCode;
private final String failReason;
private final CutomsClearanceFailType failType;
private final ClearanceFailType failType;
String logTag;
... ... @@ -554,18 +554,18 @@ public class BuyerOrderCancelService {
private Consumer<RefundGoodsAmountNode> refundGoodsAmountConsumer;
private BuyerOrder buyerOrder;
CancelOverseasOrderModel(long orderCode, String failReason, CutomsClearanceFailType failType) {
ClearanceFailModel(long orderCode, String failReason, ClearanceFailType failType) {
this.orderCode = orderCode;
this.failReason = failReason;
this.failType = failType;
}
public CancelOverseasOrderModel invoke() {
logTag = String.format("cancel overseas order %s", orderCode);
public ClearanceFailModel invoke() {
logTag = String.format("clearance fail %s", orderCode);
logger.info("{} failType is {} failReason is {}", logTag, failType, failReason);
throwServiceExceptionIf(orderCode <= 0L, "订单号不存在");
throwServiceExceptionIf(StringUtils.isBlank(failReason), "失败原因不能为空");
throwServiceExceptionIf(StringUtils.isBlank(failReason), "清关失败原因不能为空");
targetStatus = null;
refundGoodsAmountConsumer = null;
switch (failType) {
... ... @@ -578,7 +578,7 @@ public class BuyerOrderCancelService {
refundGoodsAmountConsumer = refundGoodsAmountNode -> userReason(refundGoodsAmountNode);
break;
default:
throwServiceException("无效的目标状态");
throwServiceException("无效的清关失败原因");
}
buyerOrder = buyerOrderMapper.selectOnlyByOrderCode(orderCode);
... ... @@ -708,7 +708,7 @@ public class BuyerOrderCancelService {
Long orderCode = buyerOrder.getOrderCode();
//
logger.info("cancelOverseasOrder refundGoodsAmount begin payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} refundAmount {}",
logger.info("clearanceFail refundGoodsAmount begin payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} refundAmount {}",
buyerUid, orderCode, skup, leftBuyerMoney );
new RefundGoodsMoneyHandler().loadLogger(logger)
... ... @@ -717,7 +717,7 @@ public class BuyerOrderCancelService {
.loadTargetOrderStatus(targetOrderStatus)
.loadSellerOrderGoods(sellerUid, skup)
.refund();
logger.info("cancelOverseasOrder refundGoodsAmount after payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} refundAmount {}",
logger.info("clearanceFail refundGoodsAmount after payRefundService.refund buyer, buyerUid {}, orderCode {}, skup {} refundAmount {}",
buyerUid, orderCode, skup, leftBuyerMoney );
}
}
... ...