|
|
package com.yohoufo.order.service.impl;
|
|
|
|
|
|
import com.yoho.core.common.utils.DateUtil;
|
|
|
import com.yoho.error.ServiceError;
|
|
|
import com.yoho.error.exception.ServiceException;
|
|
|
import com.yohobuy.ufo.model.order.bo.OrderInfo;
|
|
|
import com.yohobuy.ufo.model.order.common.OrderCodeType;
|
|
|
import com.yohobuy.ufo.model.order.common.OrderStatus;
|
|
|
import com.yohobuy.ufo.model.order.constants.StorageDepositStatusEnum;
|
|
|
import com.yohoufo.dal.order.model.DepositOrder;
|
|
|
import com.yohoufo.dal.order.model.EntrySellerRechargeOrder;
|
|
|
import com.yohoufo.dal.order.model.StorageDeposit;
|
|
|
import com.yohoufo.order.model.request.PaymentRequest;
|
|
|
import com.yohoufo.order.model.response.PrepayResponse;
|
|
|
import com.yohoufo.order.service.AbstractOrderPaymentService;
|
|
|
import com.yohoufo.order.service.DepositService;
|
|
|
import com.yohoufo.order.service.deposit.DepositOrderService;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@Service
|
|
|
public class DeposiOrderPaymentService extends AbstractOrderPaymentService {
|
|
|
private final Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
|
@Autowired
|
|
|
private DepositOrderService depositOrderService;
|
|
|
|
|
|
@Autowired
|
|
|
private DepositService depositService;
|
|
|
|
|
|
@Override
|
|
|
public boolean isTimeoutCancelStatus(OrderInfo orderInfo) {
|
|
|
return false;
|
...
|
...
|
@@ -15,7 +37,14 @@ public class DeposiOrderPaymentService extends AbstractOrderPaymentService { |
|
|
|
|
|
@Override
|
|
|
public OrderInfo getOrderInfo(long orderCode, int uid) {
|
|
|
return null;
|
|
|
DepositOrder order = depositOrderService.selectByOrderCodeUid(orderCode, uid);
|
|
|
|
|
|
if (order == null){
|
|
|
logger.warn("getOrderInfo order not exist, orderCode is {}, uid is {}", orderCode, uid);
|
|
|
throw new ServiceException(ServiceError.ORDER_NULL);
|
|
|
}
|
|
|
|
|
|
return buildOrderInfo(order);
|
|
|
}
|
|
|
|
|
|
@Override
|
...
|
...
|
@@ -25,12 +54,19 @@ public class DeposiOrderPaymentService extends AbstractOrderPaymentService { |
|
|
|
|
|
@Override
|
|
|
public void checkOrderStatus(OrderInfo orderInfo) {
|
|
|
|
|
|
// 订单不是未付款的状态
|
|
|
if (orderInfo.getStatus() == null || orderInfo.getStatus().intValue() != OrderStatus.WAITING_PAY.getCode()){
|
|
|
logger.warn("payment status not allow {}, orderCode is {}, uid is {}", orderInfo.getStatus(),
|
|
|
orderInfo.getOrderCode(), orderInfo.getUid());
|
|
|
throw new ServiceException(ServiceError.ORDER_PAY_NOT_ALLOW);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void updatePayment(OrderInfo orderInfo, int payment) {
|
|
|
|
|
|
DepositOrder order = DepositOrder.builder().orderCode(orderInfo.getOrderCode()).uid(orderInfo.getUid())
|
|
|
.payment(payment).updateTime(DateUtil.getCurrentTimeSecond()).build();
|
|
|
depositOrderService.updateByOrderCode(order);
|
|
|
}
|
|
|
|
|
|
@Override
|
...
|
...
|
@@ -45,6 +81,9 @@ public class DeposiOrderPaymentService extends AbstractOrderPaymentService { |
|
|
|
|
|
@Override
|
|
|
public boolean isOrderWaitingPay(OrderInfo orderInfo) {
|
|
|
if (orderInfo.getStatus() != null && orderInfo.getStatus().intValue() == OrderStatus.WAITING_PAY.getCode()){
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -60,11 +99,39 @@ public class DeposiOrderPaymentService extends AbstractOrderPaymentService { |
|
|
|
|
|
@Override
|
|
|
public int updateOrderStatusPaid(OrderInfo orderInfo) {
|
|
|
return 0;
|
|
|
DepositOrder order = DepositOrder.builder().orderCode(orderInfo.getOrderCode()).initStatus(OrderStatus.WAITING_PAY.getCode())
|
|
|
.status(OrderStatus.HAS_PAYED.getCode()).updateTime(DateUtil.getCurrentTimeSecond()).build();
|
|
|
|
|
|
int result = depositOrderService.updateStatusByOrderCode(order);
|
|
|
orderInfo.setStatus(OrderStatus.HAS_PAYED.getCode());
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 更新库存表的状态为待拣货状态
|
|
|
* @param orderInfo
|
|
|
*/
|
|
|
@Override
|
|
|
public void processAfterPay(OrderInfo orderInfo) {
|
|
|
DepositOrder depositOrder = depositOrderService.selectByOrderCode(orderInfo.getOrderCode());
|
|
|
|
|
|
depositService.changeStorageStatus(depositOrder.getDepositCode(), StorageDepositStatusEnum.WAITING_QUERY.getCode());
|
|
|
}
|
|
|
|
|
|
private OrderInfo buildOrderInfo(DepositOrder order) {
|
|
|
OrderInfo orderInfo = OrderInfo.builder()
|
|
|
.id(order.getId())
|
|
|
.uid(order.getUid())
|
|
|
.orderCode(order.getOrderCode())
|
|
|
.payment(order.getPayment())
|
|
|
.status(order.getStatus())
|
|
|
.amount(order.getAmount())
|
|
|
.createTime(order.getCreateTime())
|
|
|
.orderCodeType(OrderCodeType.STORAGE_MANAGEMENT)
|
|
|
.sourceStatus(order.getStatus())
|
|
|
.payExpireTime(30)
|
|
|
.build();
|
|
|
|
|
|
return orderInfo;
|
|
|
}
|
|
|
} |
...
|
...
|
|