Authored by wujiexiang

求购订单取消时,若存在未完成的调价记录,则不需要取消

... ... @@ -5,6 +5,7 @@ import com.yohobuy.ufo.model.enums.InboxBusinessTypeEnum;
import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.constants.OrderConstant;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.dal.order.model.*;
import com.yohoufo.dal.product.model.Product;
import com.yohoufo.order.common.RefundCase;
... ... @@ -13,14 +14,17 @@ import com.yohoufo.order.model.PayRefundBo;
import com.yohoufo.order.model.RequestedStatusChangeBuyerOrder;
import com.yohoufo.order.model.request.PaymentRequest;
import com.yohoufo.order.service.AbstractBuyerOrderStateChanger;
import com.yohoufo.order.service.impl.BuyerChangePriceRecordService;
import com.yohoufo.order.service.impl.PayRefundService;
import lombok.val;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import static com.yoho.message.sdk.common.constants.UFOMessageScene.*;
import static com.yohobuy.ufo.model.order.common.OrderStatus.*;
... ... @@ -37,6 +41,9 @@ public class BuyerOrderBidingCancelChanger extends AbstractBuyerOrderStateChange
@Autowired
private PayRefundService payRefundService;
@Autowired
private BuyerChangePriceRecordService buyerChangePriceRecordService;
/**
* @param statusChangeBuyerOrder
* @return
... ... @@ -44,6 +51,15 @@ public class BuyerOrderBidingCancelChanger extends AbstractBuyerOrderStateChange
@Override
protected boolean beforeChange(RequestedStatusChangeBuyerOrder statusChangeBuyerOrder) {
BuyerOrder buyerOrder = statusChangeBuyerOrder.getBuyerOrder();
/**
* 调价未完成,会将原skup重新上架,如果不判断是否有待处理的调价记录,会导致买家订单取消了,但求购skup还在求购状态中
*/
List<BuyerChangePriceRecord> buyerChangePriceRecords = buyerChangePriceRecordService.queryWaitingRecordsByPreOrderCode(buyerOrder.getOrderCode());
if (CollectionUtils.isNotEmpty(buyerChangePriceRecords)) {
logger.warn("[{}] orderCode exist waiting deal change price record,can't cancel", buyerOrder.getOrderCode());
throw new UfoServiceException(500, "有未完成的调价");
}
BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapper.selectByOrderCode(buyerOrder.getUid(), buyerOrder.getOrderCode());
SellerOrderGoods sellerOrderGoods = sellerOrderGoodsMapper.selectByPrimaryKey(buyerOrderGoods.getSkup());
/**
... ...
... ... @@ -45,6 +45,11 @@ public class BuyerOrderWaitingPayDepositCancelChanger extends AbstractBuyerOrder
if (buyerChangePriceRecord == null) {
return;
}
//还原原skup为可售状态
logger.info("[{}] bid skup need to be reset saleable status", buyerChangePriceRecord.getPreSkup());
bidProductProxyService.resetSaleableFromUserCancel(buyerChangePriceRecord.getPreSkup());
ChangePriceStatus targetStatus;
switch (operator) {
case CS:
... ... @@ -56,10 +61,6 @@ public class BuyerOrderWaitingPayDepositCancelChanger extends AbstractBuyerOrder
}
//状态变成取消
buyerChangePriceRecordService.changeRecordStatus(buyerChangePriceRecord.getOrderCode(), ChangePriceStatus.WAITING_DEAL, targetStatus);
//还原原skup为可售状态
logger.info("[{}] bid skup need to be reset saleable status", buyerChangePriceRecord.getPreSkup());
bidProductProxyService.resetSaleableFromUserCancel(buyerChangePriceRecord.getPreSkup());
}
private BuyerChangePriceRecord getWaitingDealBuyerChangePriceRecord(long orderCode) {
... ...