Authored by chenchao

complete build context

... ... @@ -82,4 +82,14 @@ public class SellerAddressService {
return addressInfo;
}
public AddressInfo getNoHiddenAddressInfo(int uid, int skup){
SellerOrderMeta som = somMapper.selectByMetaKey(uid, skup, MetaKey.BACK_2_SELLER_DELIVERY_ADDRESS);
String value;
if(som == null || (value=som.getMetaValue()) == null){
return null;
}
AddressInfo addressInfo = JSONObject.parseObject(value, AddressInfo.class);
return addressInfo;
}
}
... ...
... ... @@ -11,11 +11,13 @@ 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.common.Payment;
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;
import com.yohoufo.order.model.request.PrdQueryReq;
import com.yohoufo.order.service.impl.SellerAddressService;
import com.yohoufo.order.service.seller.OrderComputeHandler;
import com.yohoufo.order.service.seller.PublishPrepareProcessor;
import com.yohoufo.order.utils.AddressHelper;
... ... @@ -41,6 +43,9 @@ public class NESChangePricePublishPrepareProcessor extends AbsPublishPrepareProc
@Autowired
private NESChangePricePrepareProcessor nesChangePricePrepareProcessor;
@Autowired
private SellerAddressService sellerAddressService;
@Override
public NESCPOrderContext buildPublishCtx(NESChangePriceReq im) {
return buildSellerOrderContext(im);
... ... @@ -67,6 +72,13 @@ public class NESChangePricePublishPrepareProcessor extends AbsPublishPrepareProc
logger.warn("in ChangePrice can not find skup in sys, req {}", req);
throw new UfoServiceException(400, "商品不存在");
}
//check payment type
SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(skup);
if (Payment.WALLET.getCode() == sellerOrder.getPayment()){
logger.warn("in ChangePrice seller order paid by wallet, req {}", req);
throw new UfoServiceException(400, "请移步库存管理中变价");
}
//检查是否有买家下单
nesChangePricePrepareProcessor.checkGoodsStatus(psog);
... ... @@ -102,30 +114,19 @@ public class NESChangePricePublishPrepareProcessor extends AbsPublishPrepareProc
SellerOrderComputeResult computeResult = computeHandler.compute(salePrice, pcc);
//check income
priceComputePrepareProcessor.checkIncome(storageId, computeResult.getIncome());
//calculate different of earnest Money
SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(psog.getId());
BigDecimal sourceEM = sellerOrder.getEarnestMoney();
BigDecimal targetEM = computeResult.getEarnestMoney().getEarnestMoney();
BigDecimal diffEarnestMoney = calDiffOfEM(sourceEM,targetEM);
/*
//the address of send back 2 seller
AddressInfo hiddenBackAddress = userProxyService.getHiddenAddressInfo(uid, addressId);
AddressInfo noHiddenBackAddress = userProxyService.getAddressInfoNotHidden(uid, addressId);
if(AddressHelper.isNeedUpdate(noHiddenBackAddress)){
logger.warn("seller submit addressId need update, uid is {}, storageId is {}, addressId is {}",
uid, storageId, addressId);
throw new ServiceException(ServiceError.ORDER_ADDRESS_NEED_UPDATE);
}*/
AddressInfo hiddenBackAddress = sellerAddressService.getHiddenAddressInfo(uid, skup);
AddressInfo noHiddenBackAddress = sellerAddressService.getNoHiddenAddressInfo(uid, skup);
//
NESCPOrderContext context = new NESCPOrderContext();
context.setUid(uid);
context.setStorageId(storageId);
context.setSalePrice(salePrice);
//
//context.setBackAddress(noHiddenBackAddress);
//context.setBackHiddenAddress(hiddenBackAddress);
context.setBackAddress(noHiddenBackAddress);
context.setBackHiddenAddress(hiddenBackAddress);
//
context.setSkupType(skupType);
//step 1: rpc get product detail by storage id
... ... @@ -138,11 +139,11 @@ public class NESChangePricePublishPrepareProcessor extends AbsPublishPrepareProc
}
context.setSoldProduct(goodsInfo);
logger.info("in build not entry Seller Order Context , uid {}, storageId {}, price {}, computeResult {}", uid, storageId,
goodsInfo.getPrice(), computeResult);
context.setSellerOrderComputeResult(computeResult);
context.setSellerOrder(sellerOrder);
context.setPriceOverFlowTips(tips);
return context;
}
... ...