Authored by LUOXC

添加日志

... ... @@ -2,7 +2,6 @@ package com.yohoufo.order.service.impl;
import com.google.common.base.Verify;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.common.alarm.SmsAlarmEvent;
... ... @@ -30,11 +29,13 @@ import java.math.BigDecimal;
import java.util.Objects;
import java.util.function.BiConsumer;
import static com.yohoufo.order.utils.ServiceExceptions.throwServiceException;
/**
* @author LUOXC
* @date 2019/1/8 14:07
*/
@Slf4j
@Slf4j(topic = "orderCloseLog")
class BuyerOrderCancelHandler {
private final int uid;
... ... @@ -65,8 +66,6 @@ class BuyerOrderCancelHandler {
private BuyerRefundCouponEvent.BizCase refundCouponCase;
private AlarmConfig failAlarm;
BuyerOrderCancelHandler(int uid, long orderCode) {
... ... @@ -132,12 +131,18 @@ class BuyerOrderCancelHandler {
}
public void cancel() {
log.info("cancel order {} from {} to {}", orderCode, expectStatus, targetStatus);
verify();
// 获取买家订单
BuyerOrder buyerOrder = buyerOrderMapper.selectByOrderCodeUid(orderCode, uid);
if (Objects.isNull(buyerOrder)) {
log.info("cancel order {} fail, order is not exist", orderCode);
throwServiceException(ServiceError.ORDER_NOT_EXIST);
}
// 当前状态不可取消订单
if (expectStatus.getCode() != buyerOrder.getStatus()) {
throw new ServiceException(ServiceError.ORDER_SERVICE_ERROR);
log.info("cancel order {} fail, order status is not expect", orderCode);
throwServiceException("当前状态不可取消订单");
}
// 更新订单状态成功
if (updateBuyerOrderStatus()) {
... ... @@ -145,6 +150,9 @@ class BuyerOrderCancelHandler {
transfer();
refundPayGoodsMoney(buyerOrder);
noticeSeller();
} else {
log.info("cancel order {} fail, order status has changed", orderCode);
throwServiceException("当前状态不可取消订单");
}
}
... ... @@ -180,6 +188,7 @@ class BuyerOrderCancelHandler {
.uid(uid)
.orderCode(orderCode)
.build();
log.info("refund coupon by order {} request is {}", orderCode, buyerRefundCouponEvent);
EventBusPublisher.publishEvent(buyerRefundCouponEvent);
}
... ... @@ -193,6 +202,7 @@ class BuyerOrderCancelHandler {
.transferCase(transferCase)
.swdType(sellerWalletDetailType)
.build();
log.info("transfer by order {} request is {}", orderCode, transferMoneyRequest);
transferService.transfer(transferMoneyRequest);
}
... ... @@ -215,9 +225,11 @@ class BuyerOrderCancelHandler {
.refundCase(goodsMoneyRefundCase)
.amount(goodsMoney);
try {
log.info("refund pay goods money by order {} request is {} ", orderCode, paymentRequest);
goodsMoneyRefundConsumer.accept(paymentRequest, billLogEventBuilder.skup(getSkup()));
} catch (Exception ex) {
log.warn("pay refund fail,req {}", paymentRequest, ex);
log.info("refund pay goods money by order {} success", orderCode);
} catch (Exception e) {
log.info("refund pay goods money by order {} fail request is {}", orderCode, paymentRequest, e);
BillLogEvent billLogEvent = billLogEventBuilder.tradeStatus(BillTradeStatus.FAIL.getCode()).build();
EventBusPublisher.publishEvent(billLogEvent);
... ... @@ -235,10 +247,11 @@ class BuyerOrderCancelHandler {
private void noticeSeller() {
if (Objects.nonNull(sellerNoticeSender)) {
try {
log.info("notice seller buyer order has closed by order {}", orderCode);
SellerOrderGoods sog = getSellerOrderGoods();
sellerNoticeSender.notice(sog, orderCode, sellerNoticeSenderTimes);
} catch (Exception ex) {
log.warn("seller deliver notice fail,times {} order code is {}", sellerNoticeSenderTimes, orderCode, ex);
} catch (Exception e) {
log.info("notice seller buyer order has closed by order {} fail", orderCode, e);
}
}
}
... ...
package com.yohoufo.order.utils;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
/**
* @author LUOXC
* @date 2019/1/9 11:14
*/
public class ServiceExceptions {
public static void throwServiceException(String message) {
ServiceException serviceException = new ServiceException(ServiceError.ORDER_SERVICE_ERROR);
serviceException.setParams(message);
throw serviceException;
}
public static void throwServiceException(ServiceError serviceError) {
throw new ServiceException(serviceError);
}
}
... ...