Authored by chenchao

complete build context

@@ -82,4 +82,14 @@ public class SellerAddressService { @@ -82,4 +82,14 @@ public class SellerAddressService {
82 return addressInfo; 82 return addressInfo;
83 } 83 }
84 84
  85 + public AddressInfo getNoHiddenAddressInfo(int uid, int skup){
  86 + SellerOrderMeta som = somMapper.selectByMetaKey(uid, skup, MetaKey.BACK_2_SELLER_DELIVERY_ADDRESS);
  87 + String value;
  88 + if(som == null || (value=som.getMetaValue()) == null){
  89 + return null;
  90 + }
  91 + AddressInfo addressInfo = JSONObject.parseObject(value, AddressInfo.class);
  92 + return addressInfo;
  93 + }
  94 +
85 } 95 }
@@ -11,11 +11,13 @@ import com.yohoufo.common.exception.UfoServiceException; @@ -11,11 +11,13 @@ import com.yohoufo.common.exception.UfoServiceException;
11 import com.yohoufo.common.utils.AddressUtil; 11 import com.yohoufo.common.utils.AddressUtil;
12 import com.yohoufo.dal.order.model.SellerOrder; 12 import com.yohoufo.dal.order.model.SellerOrder;
13 import com.yohoufo.dal.order.model.SellerOrderGoods; 13 import com.yohoufo.dal.order.model.SellerOrderGoods;
  14 +import com.yohoufo.order.common.Payment;
14 import com.yohoufo.order.model.NESCPOrderContext; 15 import com.yohoufo.order.model.NESCPOrderContext;
15 import com.yohoufo.order.model.SellerOrderContext; 16 import com.yohoufo.order.model.SellerOrderContext;
16 import com.yohoufo.order.model.dto.SellerOrderComputeResult; 17 import com.yohoufo.order.model.dto.SellerOrderComputeResult;
17 import com.yohoufo.order.model.dto.SkupDto; 18 import com.yohoufo.order.model.dto.SkupDto;
18 import com.yohoufo.order.model.request.PrdQueryReq; 19 import com.yohoufo.order.model.request.PrdQueryReq;
  20 +import com.yohoufo.order.service.impl.SellerAddressService;
19 import com.yohoufo.order.service.seller.OrderComputeHandler; 21 import com.yohoufo.order.service.seller.OrderComputeHandler;
20 import com.yohoufo.order.service.seller.PublishPrepareProcessor; 22 import com.yohoufo.order.service.seller.PublishPrepareProcessor;
21 import com.yohoufo.order.utils.AddressHelper; 23 import com.yohoufo.order.utils.AddressHelper;
@@ -41,6 +43,9 @@ public class NESChangePricePublishPrepareProcessor extends AbsPublishPrepareProc @@ -41,6 +43,9 @@ public class NESChangePricePublishPrepareProcessor extends AbsPublishPrepareProc
41 @Autowired 43 @Autowired
42 private NESChangePricePrepareProcessor nesChangePricePrepareProcessor; 44 private NESChangePricePrepareProcessor nesChangePricePrepareProcessor;
43 45
  46 + @Autowired
  47 + private SellerAddressService sellerAddressService;
  48 +
44 @Override 49 @Override
45 public NESCPOrderContext buildPublishCtx(NESChangePriceReq im) { 50 public NESCPOrderContext buildPublishCtx(NESChangePriceReq im) {
46 return buildSellerOrderContext(im); 51 return buildSellerOrderContext(im);
@@ -67,6 +72,13 @@ public class NESChangePricePublishPrepareProcessor extends AbsPublishPrepareProc @@ -67,6 +72,13 @@ public class NESChangePricePublishPrepareProcessor extends AbsPublishPrepareProc
67 logger.warn("in ChangePrice can not find skup in sys, req {}", req); 72 logger.warn("in ChangePrice can not find skup in sys, req {}", req);
68 throw new UfoServiceException(400, "商品不存在"); 73 throw new UfoServiceException(400, "商品不存在");
69 } 74 }
  75 + //check payment type
  76 + SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(skup);
  77 + if (Payment.WALLET.getCode() == sellerOrder.getPayment()){
  78 + logger.warn("in ChangePrice seller order paid by wallet, req {}", req);
  79 + throw new UfoServiceException(400, "请移步库存管理中变价");
  80 + }
  81 +
70 //检查是否有买家下单 82 //检查是否有买家下单
71 nesChangePricePrepareProcessor.checkGoodsStatus(psog); 83 nesChangePricePrepareProcessor.checkGoodsStatus(psog);
72 84
@@ -102,30 +114,19 @@ public class NESChangePricePublishPrepareProcessor extends AbsPublishPrepareProc @@ -102,30 +114,19 @@ public class NESChangePricePublishPrepareProcessor extends AbsPublishPrepareProc
102 SellerOrderComputeResult computeResult = computeHandler.compute(salePrice, pcc); 114 SellerOrderComputeResult computeResult = computeHandler.compute(salePrice, pcc);
103 //check income 115 //check income
104 priceComputePrepareProcessor.checkIncome(storageId, computeResult.getIncome()); 116 priceComputePrepareProcessor.checkIncome(storageId, computeResult.getIncome());
105 - //calculate different of earnest Money  
106 - SellerOrder sellerOrder = sellerOrderMapper.selectBySkup(psog.getId());  
107 - BigDecimal sourceEM = sellerOrder.getEarnestMoney();  
108 - BigDecimal targetEM = computeResult.getEarnestMoney().getEarnestMoney();  
109 - BigDecimal diffEarnestMoney = calDiffOfEM(sourceEM,targetEM);  
110 -  
111 117
112 - /*  
113 //the address of send back 2 seller 118 //the address of send back 2 seller
114 - AddressInfo hiddenBackAddress = userProxyService.getHiddenAddressInfo(uid, addressId);  
115 - AddressInfo noHiddenBackAddress = userProxyService.getAddressInfoNotHidden(uid, addressId);  
116 - if(AddressHelper.isNeedUpdate(noHiddenBackAddress)){  
117 - logger.warn("seller submit addressId need update, uid is {}, storageId is {}, addressId is {}",  
118 - uid, storageId, addressId);  
119 - throw new ServiceException(ServiceError.ORDER_ADDRESS_NEED_UPDATE);  
120 - }*/ 119 + AddressInfo hiddenBackAddress = sellerAddressService.getHiddenAddressInfo(uid, skup);
  120 + AddressInfo noHiddenBackAddress = sellerAddressService.getNoHiddenAddressInfo(uid, skup);
  121 +
121 // 122 //
122 NESCPOrderContext context = new NESCPOrderContext(); 123 NESCPOrderContext context = new NESCPOrderContext();
123 context.setUid(uid); 124 context.setUid(uid);
124 context.setStorageId(storageId); 125 context.setStorageId(storageId);
125 context.setSalePrice(salePrice); 126 context.setSalePrice(salePrice);
126 // 127 //
127 - //context.setBackAddress(noHiddenBackAddress);  
128 - //context.setBackHiddenAddress(hiddenBackAddress); 128 + context.setBackAddress(noHiddenBackAddress);
  129 + context.setBackHiddenAddress(hiddenBackAddress);
129 // 130 //
130 context.setSkupType(skupType); 131 context.setSkupType(skupType);
131 //step 1: rpc get product detail by storage id 132 //step 1: rpc get product detail by storage id
@@ -138,11 +139,11 @@ public class NESChangePricePublishPrepareProcessor extends AbsPublishPrepareProc @@ -138,11 +139,11 @@ public class NESChangePricePublishPrepareProcessor extends AbsPublishPrepareProc
138 } 139 }
139 context.setSoldProduct(goodsInfo); 140 context.setSoldProduct(goodsInfo);
140 141
141 -  
142 -  
143 logger.info("in build not entry Seller Order Context , uid {}, storageId {}, price {}, computeResult {}", uid, storageId, 142 logger.info("in build not entry Seller Order Context , uid {}, storageId {}, price {}, computeResult {}", uid, storageId,
144 goodsInfo.getPrice(), computeResult); 143 goodsInfo.getPrice(), computeResult);
145 context.setSellerOrderComputeResult(computeResult); 144 context.setSellerOrderComputeResult(computeResult);
  145 +
  146 + context.setSellerOrder(sellerOrder);
146 context.setPriceOverFlowTips(tips); 147 context.setPriceOverFlowTips(tips);
147 return context; 148 return context;
148 } 149 }