Authored by chenjian

门店订单支付后即完成

... ... @@ -30,6 +30,7 @@ import com.yohoufo.order.service.cache.CacheKeyBuilder;
import com.yohoufo.order.service.impl.SellerAddressService;
import com.yohoufo.order.service.proxy.InBoxFacade;
import com.yohoufo.order.service.proxy.OrderStatusFlowService;
import com.yohoufo.order.utils.BuyerOrderUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
... ... @@ -78,21 +79,35 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
BuyerOrder buyerOrder = new BuyerOrder();
buyerOrder.setOrderCode(orderInfo.getOrderCode());
buyerOrder.setUid(uid);
buyerOrder.setStatus(OrderStatus.HAS_PAYED.getCode());
int orderStatusCode = OrderStatus.HAS_PAYED.getCode();
//门店订单支付后直接完成
if(BuyerOrderUtils.isOffline(orderInfo)) {
orderStatusCode = OrderStatus.DONE.getCode();
}
buyerOrder.setStatus(orderStatusCode);
buyerOrder.setUpdateTime(DateUtil.getCurrentTimeSecond());
int result = buyerOrderMapper.updateByOrderCode(buyerOrder);
//
if(result>0){
//记录状态信息
logger.info("in updateOrderStatusPaid record status change, orderCode {}", orderInfo.getOrderCode());
orderStatusFlowService.addAsy(orderInfo.getOrderCode(), OrderStatus.HAS_PAYED.getCode());
logger.info("in updateOrderStatusPaid record status change, orderCode {}, status: {}",
orderInfo.getOrderCode(), orderStatusCode);
orderStatusFlowService.addAsy(orderInfo.getOrderCode(), orderStatusCode);
}
orderInfo.setStatus(OrderStatus.HAS_PAYED.getCode());
orderInfo.setStatus(orderStatusCode);
return result;
}
@Override
public void processAfterPay(OrderInfo orderInfo) {
if(BuyerOrderUtils.isOrderDone(orderInfo)) {
logger.info("order status is Done, orderCode: {}, uid: {}", orderInfo.getOrderCode(), orderInfo.getUid());
return;
}
Integer uid = orderInfo.getUid();
Integer sellerUid = orderInfo.getSellerUid();
long orderCode = orderInfo.getOrderCode();
... ... @@ -289,6 +304,7 @@ public class BuyerOrderPaymentService extends AbstractOrderPaymentService {
.amount(buyerOrder.getAmount())
.createTime(buyerOrder.getCreateTime())
.orderCodeType(OrderCodeType.BUYER_TYPE)
.attributes(buyerOrder.getAttributes())
.sourceStatus(buyerOrder.getStatus())
.payExpireTime(DelayTime.BUYER_ORDER_WAITING_PAY)
.build();
... ...
package com.yohoufo.order.utils;
import com.yohobuy.ufo.model.order.bo.OrderInfo;
import com.yohobuy.ufo.model.order.common.OrderAttributes;
import com.yohobuy.ufo.model.order.common.OrderStatus;
public class BuyerOrderUtils {
/**
* 订单状态是否已完成
*/
public static boolean isOrderDone(int status) {
return status == OrderStatus.DONE.getCode();
}
/**
* 订单状态是否已完成
*/
public static boolean isOrderDone(OrderInfo orderInfo) {
if(orderInfo == null)
return false;
return isOrderDone(orderInfo.getStatus());
}
/**
* 是否门店订单
*/
public static boolean isOffline(Integer attributes) {
if(OrderAttributes.getOrderAttributes(attributes) == OrderAttributes.OFFLINE)
return true;
return false;
}
/**
* 是否门店订单
*/
public static boolean isOffline(OrderInfo orderInfo) {
if(orderInfo == null)
return false;
return isOffline(orderInfo.getAttributes());
}
}
... ...