Authored by chenchao

support first publish 4 nes

package com.yohoufo.order.model;
import com.yohoufo.dal.order.model.SellerOrder;
import lombok.Data;
/**
* Created by chao.chen on 2019/3/22.
*/
@Data
public class NESCPOrderContext extends SellerOrderContext{
private SellerOrder sellerOrder;
}
... ...
... ... @@ -14,7 +14,6 @@ import java.math.BigDecimal;
*/
@Data
public class SellerOrderContext {
private int uid;
... ...
... ... @@ -212,7 +212,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic
private OrderSubmitResp publishSinglePrd(SellerOrderSubmitReq req, SellerOrderContext context) throws GatewayException {
public OrderSubmitResp publishSinglePrd(SellerOrderSubmitReq req, SellerOrderContext context){
int storageId = context.getStorageId();
int uid = context.getUid();
// step 2: create order, set status(not pay)
... ...
package com.yohoufo.order.service.seller.changePrice;
import com.yohobuy.ufo.model.order.req.NESChangePriceReq;
import com.yohobuy.ufo.model.order.req.SellerOrderSubmitReq;
import com.yohoufo.order.model.SellerOrderContext;
import com.yohoufo.order.model.response.OrderSubmitResp;
import com.yohoufo.order.service.impl.SellerOrderService;
import com.yohoufo.order.service.seller.PublishExcutor;
import com.yohoufo.order.service.seller.processor.NESChangePricePublishPrepareProcessor;
import com.yohoufo.order.utils.LoggerUtils;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -14,18 +14,24 @@ import org.springframework.stereotype.Service;
* Created by chao.chen on 2019/3/22.
*/
@Service
public class NESChangePricePublishExcutor implements PublishExcutor<NESChangePriceReq, OrderSubmitResp> {
public class NESChangePricePublishExcutor implements PublishExcutor<SellerOrderContext, OrderSubmitResp> {
private Logger logger = LoggerUtils.getSellerOrderLogger();
@Autowired
NESChangePricePublishPrepareProcessor nesChangePricePublishPrepareProcessor;
SellerOrderService sellerOrderService;
@Override
public OrderSubmitResp publish(NESChangePriceReq nesChangePriceReq) {
SellerOrderContext ctx = nesChangePricePublishPrepareProcessor.buildPublishCtx(nesChangePriceReq);
public OrderSubmitResp publish(SellerOrderContext ctx) {
return null;
SellerOrderSubmitReq req = SellerOrderSubmitReq.builder()
.uid(ctx.getUid())
.storageId(ctx.getStorageId()).build();
OrderSubmitResp resp = sellerOrderService.publishSinglePrd(req, ctx);
logger.info("out NESChangePricePublishExcutor.publish req {} OrderSubmitResp {}",
req, resp);
return resp;
}
}
... ...
... ... @@ -9,9 +9,11 @@ import com.yohoufo.dal.order.model.SellerChangePriceRecord;
import com.yohoufo.dal.order.model.SellerOrder;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.convert.SellerOrderConvertor;
import com.yohoufo.order.model.NESCPOrderContext;
import com.yohoufo.order.model.dto.ChangePricePrepareDTO;
import com.yohoufo.order.model.response.OrderSubmitResp;
import com.yohoufo.order.service.seller.processor.NESChangePricePrepareProcessor;
import com.yohoufo.order.service.seller.processor.NESChangePricePublishPrepareProcessor;
import com.yohoufo.order.utils.LoggerUtils;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
... ... @@ -49,6 +51,12 @@ public class NotEntrySellerChangePriceService {
@Autowired
private NESChangePricePrepareProcessor nesChangePricePrepareProcessor;
@Autowired
NESChangePricePublishPrepareProcessor nesChangePricePublishPrepareProcessor;
@Autowired
NESChangePricePublishExcutor nesChangePricePublishExcutor;
public boolean isChangePriceOrder(int skup){
... ... @@ -81,7 +89,7 @@ public class NotEntrySellerChangePriceService {
*/
public OrderSubmitResp changePrice(NESChangePriceReq req){
logger.info("in NotEntrySellerChangePriceService.changePrice, req {}", req);
ChangePricePrepareDTO cppDto = nesChangePricePrepareProcessor.checkAndAcquire(req);
NESCPOrderContext ctx = nesChangePricePublishPrepareProcessor.buildPublishCtx(req);
//TODO
/*
step 1. 检查变价记录 seller_change_price_record
... ... @@ -94,9 +102,9 @@ public class NotEntrySellerChangePriceService {
step 5. 记录变价记录(新的订单号,新skup)
*/
SellerOrderGoods psog = cppDto.getBaseSellerOrderGoods();
SellerOrderGoods psog = ctx.getSellerOrderGoods();
int skup = psog.getId();
SellerOrder sellerOrder = cppDto.getSkupMap().get(skup).getSellerOrder();
SellerOrder sellerOrder = ctx.getSellerOrder();
Long preOrderCode = sellerOrder.getOrderCode();
List<Short> scprs = Lists.newArrayListWithCapacity(2);
scprs.add(ChangePriceStatus.WAITING_DEAL.getCode());
... ... @@ -105,7 +113,7 @@ public class NotEntrySellerChangePriceService {
List<SellerChangePriceRecord> scprList = sellerChangePriceRecordMapper.selectByPreOrderCodeNStatus(preOrderCode, scprs);
if (CollectionUtils.isEmpty(scprList)){
//首次 或 全部失败
return nesChangePricePublishExcutor.publish(ctx);
}
//存在成功处理,有且只有一条才对(不完全正确,多终端操作同一个待变价商品)
... ...
... ... @@ -11,6 +11,7 @@ import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.common.utils.AddressUtil;
import com.yohoufo.dal.order.model.SellerOrder;
import com.yohoufo.dal.order.model.SellerOrderGoods;
import com.yohoufo.order.model.NESCPOrderContext;
import com.yohoufo.order.model.SellerOrderContext;
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
import com.yohoufo.order.model.dto.SkupDto;
... ... @@ -41,11 +42,11 @@ public class NESChangePricePublishPrepareProcessor extends AbsPublishPrepareProc
private NESChangePricePrepareProcessor nesChangePricePrepareProcessor;
@Override
public SellerOrderContext buildPublishCtx(NESChangePriceReq im) {
public NESCPOrderContext buildPublishCtx(NESChangePriceReq im) {
return buildSellerOrderContext(im);
}
private SellerOrderContext buildSellerOrderContext(NESChangePriceReq req) {
private NESCPOrderContext buildSellerOrderContext(NESChangePriceReq req) {
int uid = req.getUid();
if (uid <= 0){
... ... @@ -118,7 +119,7 @@ public class NESChangePricePublishPrepareProcessor extends AbsPublishPrepareProc
throw new ServiceException(ServiceError.ORDER_ADDRESS_NEED_UPDATE);
}*/
//
SellerOrderContext context = new SellerOrderContext();
NESCPOrderContext context = new NESCPOrderContext();
context.setUid(uid);
context.setStorageId(storageId);
context.setSalePrice(salePrice);
... ...