Authored by wujiexiang

求购 -- 增加订单状态

... ... @@ -357,6 +357,9 @@
<if test="originalStatus != null">
and status = #{originalStatus,jdbcType=INTEGER}
</if>
<if test="bidType != null">
and bid_type = #{bidType,jdbcType=INTEGER}
</if>
</update>
... ...
package com.yohoufo.order.controller;
import com.yohoufo.common.ApiResponse;
import com.yohoufo.common.annotation.IgnoreSession;
import com.yohoufo.common.annotation.IgnoreSignature;
import com.yohoufo.order.service.IBuyerOrderService;
import com.yohoufo.order.utils.LoggerUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/erp")
public class ErpGWSkupController {
private final Logger logger = LoggerUtils.getOrderCloseLogger();
@Autowired
private IBuyerOrderService buyerOrderService;
/**
* 客服根据skup取消求购中的订单
*
* @return
*/
@RequestMapping(value = "/bid/cancelBiding")
@IgnoreSession
@IgnoreSignature
public ApiResponse cancelBidingByCS(@RequestParam(name = "skup") int skup) {
logger.info("method cs cancel biding order by skup in, skup is {}", skup);
// 检查
if (skup <= 0) {
return new ApiResponse.ApiResponseBuilder().code(400).message("参数校验不通过").build();
}
buyerOrderService.cancelBidingBySkup(skup);
return new ApiResponse.ApiResponseBuilder().code(200).build();
}
}
... ...
package com.yohoufo.order.model.request;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohoufo.order.common.Operator;
import com.yohoufo.order.event.OrderCancelEvent;
import lombok.AllArgsConstructor;
import lombok.Data;
... ... @@ -27,8 +26,4 @@ public class OrderRequest {
OrderCancelEvent orderCancelEvent;
String appVersion;
//操作者
Operator operator;
}
... ...
package com.yohoufo.order.mq.consumer;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohoufo.order.common.Operator;
import com.yohoufo.order.event.OrderCancelEvent;
import com.yohoufo.order.model.request.OrderRequest;
import com.yohoufo.order.mq.TopicConstants;
import com.yohoufo.order.service.IBuyerOrderService;
import com.yohoufo.order.service.BuyerOrderStateChangers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
... ... @@ -12,7 +12,7 @@ import org.springframework.stereotype.Component;
public class BuyerOrderAutoCancelDelayNDayMsgConsumer extends AbsOrderAutoCancelDelayMsgConsumer {
@Autowired
private IBuyerOrderService buyerOrderService;
private BuyerOrderStateChangers buyerOrderStateChangers;
@Override
public String getTopic() {
... ... @@ -23,8 +23,7 @@ public class BuyerOrderAutoCancelDelayNDayMsgConsumer extends AbsOrderAutoCancel
public void cancel(OrderCancelEvent event) {
int uid = event.getUid();
long orderCode = event.getOrderCode();
OrderRequest req = OrderRequest.builder().uid(uid).orderCode(orderCode).operator(Operator.SYSTEM).build();
buyerOrderService.cancelBiding(req);
buyerOrderStateChangers.selectOneToChange(uid, orderCode, OrderStatus.BIDING, OrderStatus.SYSTEM_CLOSE_BID, Operator.SYSTEM);
}
@Override
... ...
... ... @@ -34,10 +34,10 @@ public interface IBuyerOrderService {
void cancelByAuto(OrderRequest orderRequest);
/**
* 取消求购中的订单
* @param orderRequest
* 通过skup取消求购中的订单
* @param skup
*/
void cancelBiding(OrderRequest orderRequest);
void cancelBidingBySkup(int skup);
/**
* 提交订单
... ...
... ... @@ -7,15 +7,10 @@ import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.dal.order.SellerOrderGoodsMapper;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.convert.GoodsInfoConvertor;
import com.yohoufo.order.model.SellerOrderContext;
import com.yohoufo.order.model.bo.SubmitSellerOrder;
import com.yohoufo.order.service.seller.SkupService;
import com.yohoufo.order.utils.LoggerUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
/**
... ...
... ... @@ -42,6 +42,7 @@ import com.yohoufo.order.service.proxy.*;
import com.yohoufo.order.service.seller.SkupService;
import com.yohoufo.order.service.seller.deposit.SellerDepositOrderService;
import com.yohoufo.order.service.seller.orderMeta.SellerOrderMetaService;
import com.yohoufo.order.service.support.BuyerOrderGoodsMapperSupport;
import com.yohoufo.order.utils.BuyerOrderUtils;
import com.yohoufo.order.utils.LoggerUtils;
import com.yohoufo.order.utils.SellerGoodsHelper;
... ... @@ -145,6 +146,9 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
@Autowired
private BuyerOrderStateChangers buyerOrderStateChangers;
@Autowired
private BuyerOrderGoodsMapperSupport buyerOrderGoodsMapperSupport;
/**
* 提交订单
* @param orderRequest
... ... @@ -422,14 +426,10 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
orderStatusFlowService.addAsy(orderRequest.getOrderCode(), targetStatus.getCode());
}
/**
* 取消求购订单
*
* @param orderRequest
*/
@Override
public void cancelBiding(OrderRequest orderRequest) {
buyerOrderStateChangers.selectOneToChange(orderRequest.getUid(), orderRequest.getOrderCode(), OrderStatus.BIDING, OrderStatus.BUYER_BID_CLOSE, orderRequest.getOperator());
public void cancelBidingBySkup(int skup) {
BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapperSupport.selectBuyerOrderGoodsBySkup(skup);
buyerOrderStateChangers.selectOneToChange(buyerOrderGoods.getUid(), buyerOrderGoods.getOrderCode(), OrderStatus.BIDING, OrderStatus.PLATFORM_CLOSE_BID, Operator.CS);
}
private void doCancelBidByAuto(BuyerOrder buyerOrder, OrderCancelEvent orderCancelEvent, OrderStatus sourceStatus, OrderStatus targetStatus) {
... ... @@ -478,11 +478,11 @@ public class BuyerOrderServiceImpl implements IBuyerOrderService {
boolean useDepositGoods = node.useDepositGoods;
switch (expectStatus){
case WAITING_PAY_DEPOSIT:
targetStatus = OrderStatus.BUYER_BID_CLOSE;
targetStatus = OrderStatus.BUYER_CANCEL_BEFORE_DEPOSIT_PAY;
buyerOrderStateChangers.selectOneToChange(buyerOrder, OrderStatus.WAITING_PAY_DEPOSIT, targetStatus);
break;
case BIDING:
targetStatus = OrderStatus.BUYER_BID_CLOSE;
targetStatus = OrderStatus.BUYER_CLOSE_BID;
//求购中取消
buyerOrderStateChangers.selectOneToChange(buyerOrder, OrderStatus.BIDING, targetStatus);
break;
... ...
... ... @@ -6,6 +6,7 @@ import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yohobuy.ufo.model.order.common.Payment;
import com.yohobuy.ufo.model.order.common.SellerOrderStatus;
import com.yohobuy.ufo.model.order.constants.OrderConstant;
import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.common.utils.DateUtil;
... ... @@ -15,8 +16,8 @@ import com.yohoufo.order.common.DelStatus;
import com.yohoufo.order.constants.MetaKey;
import com.yohoufo.order.model.bo.SubmitSellerOrder;
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
import com.yohoufo.order.service.support.BuyerOrderGoodsMapperSupport;
import com.yohoufo.order.utils.LoggerUtils;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
... ... @@ -80,7 +81,7 @@ public class SellerBidOrderBindService {
private SellerOrderMetaMapper somMapper;
@Autowired
private BuyerOrderGoodsMapper buyerOrderGoodsMapper;
private BuyerOrderGoodsMapperSupport buyerOrderGoodsMapperSupport;
@Autowired
private BuyerOrderMapper buyerOrderMapper;
... ... @@ -198,32 +199,18 @@ public class SellerBidOrderBindService {
}
protected void bindSellerUidWithBuyerOrder(int skup, int sellerUid) {
BuyerOrderGoods buyerOrderGoods = getBuyerOrderGoods(skup);
BuyerOrderGoods buyerOrderGoods = buyerOrderGoodsMapperSupport.selectBuyerOrderGoodsBySkup(skup);
BuyerOrder buyerOrder = new BuyerOrder();
buyerOrder.setUid(buyerOrderGoods.getUid());
buyerOrder.setOrderCode(buyerOrderGoods.getOrderCode());
buyerOrder.setSellerUid(sellerUid);
buyerOrder.setBidType(OrderConstant.BUYER_BID_TYPE);
boolean success = buyerOrderMapper.updateByOrderCode(buyerOrder) > 0;
if (!success) {
logger.warn("[{}] buyer order is bind with sellerUid:{} fail ", buyerOrderGoods.getOrderCode());
throw new UfoServiceException(500, "操作失败");
}
logger.warn("[{}] buyer order is bind with sellerUid:{} success ", buyerOrderGoods.getOrderCode());
}
private BuyerOrderGoods getBuyerOrderGoods(int skup) {
List<BuyerOrderGoods> buyerOrderGoodsList = buyerOrderGoodsMapper.selectOrderBySkups(skup);
if (CollectionUtils.isEmpty(buyerOrderGoodsList)) {
logger.warn("not find buyer order goods by skup:{}", skup);
return null;
}
if (buyerOrderGoodsList.size() != 1) {
logger.warn("is impossible,buyer order goods size != 1 by skup:{}", skup);
return null;
}
return buyerOrderGoodsList.get(0);
logger.info("[{}] buyer order is bind with sellerUid:{} success ", buyerOrderGoods.getOrderCode());
}
}
}
\ No newline at end of file
... ...
... ... @@ -76,6 +76,6 @@ public class BuyerOrderBidingCancelChanger extends AbstractBuyerOrderStateChange
public boolean isSupport(RequestedStatusChangeBuyerOrder statusChangeBuyerOrder) {
OrderStatus sourceStatus = statusChangeBuyerOrder.getSourceStatus();
OrderStatus targetStatus = statusChangeBuyerOrder.getTargetStatus();
return sourceStatus == BIDING && targetStatus == BUYER_BID_CLOSE;
return sourceStatus == BIDING && (targetStatus == BUYER_CLOSE_BID || targetStatus == SYSTEM_CLOSE_BID || targetStatus == PLATFORM_CLOSE_BID);
}
}
... ...
... ... @@ -37,7 +37,7 @@ public class BuyerOrderWaitingPayDepositCancelChanger extends AbstractBuyerOrder
public boolean isSupport(RequestedStatusChangeBuyerOrder statusChangeBuyerOrder) {
OrderStatus sourceStatus = statusChangeBuyerOrder.getSourceStatus();
OrderStatus targetStatus = statusChangeBuyerOrder.getTargetStatus();
return sourceStatus == WAITING_PAY_DEPOSIT && targetStatus == BUYER_BID_CLOSE ;
return sourceStatus == WAITING_PAY_DEPOSIT && targetStatus == BUYER_CANCEL_BEFORE_DEPOSIT_PAY ;
}
private void processIfExistChangePriceRecord(long orderCode, Operator operator) {
... ...
package com.yohoufo.order.service.support;
import com.yohoufo.dal.order.BuyerOrderGoodsMapper;
import com.yohoufo.dal.order.model.BuyerOrderGoods;
import com.yohoufo.order.utils.LoggerUtils;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public class BuyerOrderGoodsMapperSupport {
private final static Logger logger = LoggerUtils.getBuyerOrderLogger();
@Autowired
private BuyerOrderGoodsMapper buyerOrderGoodsMapper;
public BuyerOrderGoods selectBuyerOrderGoodsBySkup(int skup) {
List<BuyerOrderGoods> buyerOrderGoodsList = buyerOrderGoodsMapper.selectOrderBySkups(skup);
if (CollectionUtils.isEmpty(buyerOrderGoodsList)) {
logger.warn("not find buyer order goods by skup:{}", skup);
return null;
}
if (buyerOrderGoodsList.size() != 1) {
logger.warn("is impossible,buyer order goods size != 1 by skup:{}", skup);
return null;
}
return buyerOrderGoodsList.get(0);
}
}
... ...