Authored by sailing-PC\sailing

optimize code

... ... @@ -3,6 +3,7 @@ package com.yohoufo.order.service.impl;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.common.alarm.SmsAlarmEvent;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
import com.yohoufo.dal.order.BuyerOrderMapper;
... ... @@ -189,6 +190,14 @@ public class AppraiseService {
//将卖家的保证金分账给平台和买家
TransferMoneyRequest tmReq = TransferMoneyRequest.builder().buyerOrderCode(orderCode)
.type(TransferCase.APPRAISE_FAIL.getCode()).build();
try{
paymentService.transferMon(tmReq);
}catch (Exception ex){
LOGGER.warn("in appraiseFail ,Transfer fail,req {}", tmReq, ex);
String content = "鉴定不通过时,订单"+ orderCode + "保证金分账失败";
SmsAlarmEvent smsAlarmEvent = new SmsAlarmEvent("buyerOrder.appraiseFail", "cancel", content);
EventBusPublisher.publishEvent(smsAlarmEvent);
}
BigDecimal goodsMoney = buyerOrder.getAmount();
PaymentRequest req = PaymentRequest.builder().uid(buyerUid)
... ... @@ -200,7 +209,7 @@ public class AppraiseService {
.amount(goodsMoney)
.skup(skup);
try{
paymentService.transferMon(tmReq);
paymentService.refund(req);
BillLogEvent buyererBillLogEvent = bleb.tradeStatus(100)
.build();
... ... @@ -210,10 +219,14 @@ public class AppraiseService {
inBoxFacade.buyerGetEarnestMoneyWhenAppraiseFail(buyerUid, buyerOrder.getOrderCode());
}catch (Exception ex){
LOGGER.warn("in appraiseFail ,Transfer or refund fail,req {}", req, ex);
LOGGER.warn("in appraiseFail ,refund fail,req {}", req, ex);
BillLogEvent buyererBillLogEvent = bleb.tradeStatus(200)
.build();
EventBusPublisher.publishEvent(buyererBillLogEvent);
String content = "鉴定不通过时,退用户" + sellerUid + "货款订单"+ orderCode +"失败";
SmsAlarmEvent smsAlarmEvent = new SmsAlarmEvent("buyerOrder.appraiseFail", "cancel", content);
EventBusPublisher.publishEvent(smsAlarmEvent);
}finally {
// 更新买家订单状态 为鉴定不通过
OrderStatus targetStatus = OrderStatus.CHECKING_FAKE;
... ...
... ... @@ -3,6 +3,7 @@ package com.yohoufo.order.service.impl;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.common.alarm.SmsAlarmEvent;
import com.yohoufo.common.utils.DateUtil;
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
import com.yohoufo.dal.order.BuyerOrderMapper;
... ... @@ -249,16 +250,18 @@ public class SellerOrderCancelService {
paymentService.refund(refundReq);
logger.info("in cancelAfterPayButNotBuyAction, refund earnestMoney finish, seller {}, order code {}, skup {}, earnestMoney {}",
sellerUid, orderCode, skup, earnestMoney);
//fail bill log
BillLogEvent sellerBillLogEvent = bleb.tradeStatus(100)
.build();
EventBusPublisher.publishEvent(sellerBillLogEvent);
}catch (Exception ex){
logger.warn("in appraiseSuccess, refund fail, req {}", refundReq, ex);
BillLogEvent sellerBillLogEvent = bleb.tradeStatus(200)
.build();
EventBusPublisher.publishEvent(sellerBillLogEvent);
String content = "用户" + sellerUid + "退保证金订单"+ orderCode +"失败";
SmsAlarmEvent smsAlarmEvent = new SmsAlarmEvent("notPaidSellerOrder.selfCancel", "cancelBeforeBuy", content);
EventBusPublisher.publishEvent(smsAlarmEvent);
}
int result = 0;
SellerOrderStatus targetSOStatus;
... ... @@ -461,7 +464,6 @@ public class SellerOrderCancelService {
BillLogEvent sellerBillLogEvent = bleb.tradeStatus(100)
.build();
EventBusPublisher.publishEvent(sellerBillLogEvent);
inBoxFacade.notifyUnshelfCauseBySpecialReason(sellerUid, psog.getProductName());
}catch (Exception ex){
logger.warn("in yoho Off Shelve Cancel, refund earnestMoney fail, seller {}, order code {}, skup {}, earnestMoney {}",
... ... @@ -469,6 +471,9 @@ public class SellerOrderCancelService {
BillLogEvent sellerBillLogEvent = bleb.tradeStatus(200)
.build();
EventBusPublisher.publishEvent(sellerBillLogEvent);
String content = "下架skup时,退用户" + sellerUid + "保证金订单"+ orderCode +"失败";
SmsAlarmEvent smsAlarmEvent = new SmsAlarmEvent("PaidSellerOrder.PlatformCancel", "cancelBeforeBuy", content);
EventBusPublisher.publishEvent(smsAlarmEvent);
}finally {
final SellerOrderStatus targetSellerOrderStatus = SellerOrderStatus.YOHO_CANCEL_SELL;
//TODO check skup is buy away
... ...