Authored by chenchao

fix super entry

@@ -36,4 +36,6 @@ public class ChangePricePrepareDTO { @@ -36,4 +36,6 @@ public class ChangePricePrepareDTO {
36 36
37 37
38 private String tips; 38 private String tips;
  39 +
  40 + private boolean isSuper;
39 } 41 }
@@ -147,6 +147,8 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi @@ -147,6 +147,8 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
147 log.info("in computePublishPrd, req {}", req); 147 log.info("in computePublishPrd, req {}", req);
148 PriceComputePrepareProcessor.PriceComputeNode pcn = priceComputePrepareProcessor.checkBasePrice(req); 148 PriceComputePrepareProcessor.PriceComputeNode pcn = priceComputePrepareProcessor.checkBasePrice(req);
149 int uid = pcn.getUid(); 149 int uid = pcn.getUid();
  150 +
  151 +
150 Integer storageId = pcn.getStorageId(); 152 Integer storageId = pcn.getStorageId();
151 int num = pcn.getNum(); 153 int num = pcn.getNum();
152 BigDecimal salePrice = pcn.getPrdPrice(); 154 BigDecimal salePrice = pcn.getPrdPrice();
@@ -157,8 +159,8 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi @@ -157,8 +159,8 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
157 }catch (UfoServiceException ex){ 159 }catch (UfoServiceException ex){
158 tips = ex.getErrorMessage(); 160 tips = ex.getErrorMessage();
159 } 161 }
160 -  
161 - SoldPrdComputeBo spc = buildSoldPrdComputeBo(uid, num, salePrice); 162 + boolean isSuper = sellerService.isSuperEntrySeller(uid);
  163 + SoldPrdComputeBo spc = buildSoldPrdComputeBo(uid, num, salePrice, isSuper);
162 spc.setTips(tips); 164 spc.setTips(tips);
163 return spc; 165 return spc;
164 } 166 }
@@ -259,7 +261,8 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi @@ -259,7 +261,8 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
259 boolean isSurper = sellerService.isSuperEntrySeller(uid); 261 boolean isSurper = sellerService.isSuperEntrySeller(uid);
260 SellerOrderComputeResult socr = ctx.getSellerOrderComputeResult(); 262 SellerOrderComputeResult socr = ctx.getSellerOrderComputeResult();
261 BigDecimal singleEarestMoney = socr.getEarnestMoney().getEarnestMoney(); 263 BigDecimal singleEarestMoney = socr.getEarnestMoney().getEarnestMoney();
262 - BigDecimal mEarestMoney = sellerOrderPrepareProcessor.checkNGetMergeEarnestMoney(uid, singleEarestMoney, num, ctx.getSalePrice()); 264 + BigDecimal mEarestMoney = sellerOrderPrepareProcessor.checkNGetMergeEarnestMoney(uid, singleEarestMoney,
  265 + num, ctx.getSalePrice(), isSurper);
263 SellerWalletDetail.Type swdType = SellerWalletDetail.Type.PUBLISH; 266 SellerWalletDetail.Type swdType = SellerWalletDetail.Type.PUBLISH;
264 MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(uid) 267 MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(uid)
265 .storageId(ctx.getStorageId()).earnestMoney(mEarestMoney) 268 .storageId(ctx.getStorageId()).earnestMoney(mEarestMoney)
@@ -484,13 +487,14 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi @@ -484,13 +487,14 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
484 } 487 }
485 } 488 }
486 489
487 - private SoldPrdComputeBo buildSoldPrdComputeBo(int uid, int num, BigDecimal prdPrice){ 490 + private SoldPrdComputeBo buildSoldPrdComputeBo(int uid, int num, BigDecimal prdPrice, boolean isSuper){
488 SellerOrderComputeResult computeResult = computeHandler.compute(prdPrice); 491 SellerOrderComputeResult computeResult = computeHandler.compute(prdPrice);
489 /** 492 /**
490 * 验证是否是入驻商家 493 * 验证是否是入驻商家
491 */ 494 */
492 if(sellerOrderPrepareProcessor.checkIsEntry(uid)){ 495 if(sellerOrderPrepareProcessor.checkIsEntry(uid)){
493 - sellerOrderPrepareProcessor.checkNGetMergeEarnestMoney(uid, computeResult.getEarnestMoney().getEarnestMoney(), num, prdPrice); 496 + sellerOrderPrepareProcessor.checkNGetMergeEarnestMoney(uid,
  497 + computeResult.getEarnestMoney().getEarnestMoney(), num, prdPrice, isSuper);
494 } 498 }
495 499
496 SoldPrdComputeBo computeBo = SellerOrderConvertor.computeResult2SoldPrdComputeBo(computeResult); 500 SoldPrdComputeBo computeBo = SellerOrderConvertor.computeResult2SoldPrdComputeBo(computeResult);
@@ -568,6 +572,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi @@ -568,6 +572,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
568 ChangePricePrepareDTO cppDto = changePricePrepareProcessor.checkAndAcquire(req); 572 ChangePricePrepareDTO cppDto = changePricePrepareProcessor.checkAndAcquire(req);
569 BigDecimal preSalePrice = cppDto.getPreSalePrice(), 573 BigDecimal preSalePrice = cppDto.getPreSalePrice(),
570 salePrice = cppDto.getSalePrice(); 574 salePrice = cppDto.getSalePrice();
  575 + boolean isSurper = cppDto.isSuper();
571 int uid = req.getUid(); 576 int uid = req.getUid();
572 Map<Integer, SkupDto> skupMap = cppDto.getSkupMap(); 577 Map<Integer, SkupDto> skupMap = cppDto.getSkupMap();
573 SellerOrderComputeResult computeResult = cppDto.getComputeResult(); 578 SellerOrderComputeResult computeResult = cppDto.getComputeResult();
@@ -583,7 +588,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi @@ -583,7 +588,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
583 .earnestMoney(totalDiffMoney).productCount(skupMap.size()) 588 .earnestMoney(totalDiffMoney).productCount(skupMap.size())
584 .seriNo(String.valueOf(req.getBatchNo())) 589 .seriNo(String.valueOf(req.getBatchNo()))
585 .type(swdType.getValue()).build(); 590 .type(swdType.getValue()).build();
586 - boolean isSurper = sellerService.isSuperEntrySeller(uid); 591 +
587 SellerWallet sellerWallet = isSurper ? new SellerWallet() : merchantOrderPaymentService.changePriceUseEarnest(uid, totalDiffMoney, moai); 592 SellerWallet sellerWallet = isSurper ? new SellerWallet() : merchantOrderPaymentService.changePriceUseEarnest(uid, totalDiffMoney, moai);
588 int successCnt = 0; 593 int successCnt = 0;
589 int failCnt = 0; 594 int failCnt = 0;
@@ -19,6 +19,7 @@ import com.yohoufo.order.model.dto.ChangePricePrepareDTO; @@ -19,6 +19,7 @@ import com.yohoufo.order.model.dto.ChangePricePrepareDTO;
19 import com.yohoufo.order.model.dto.SellerOrderComputeResult; 19 import com.yohoufo.order.model.dto.SellerOrderComputeResult;
20 import com.yohoufo.order.model.dto.SkupDto; 20 import com.yohoufo.order.model.dto.SkupDto;
21 import com.yohoufo.order.service.handler.SellerOrderComputeHandler; 21 import com.yohoufo.order.service.handler.SellerOrderComputeHandler;
  22 +import com.yohoufo.order.service.impl.SellerService;
22 import com.yohoufo.order.service.proxy.ProductProxyService; 23 import com.yohoufo.order.service.proxy.ProductProxyService;
23 import com.yohoufo.order.utils.LoggerUtils; 24 import com.yohoufo.order.utils.LoggerUtils;
24 import org.apache.commons.collections.CollectionUtils; 25 import org.apache.commons.collections.CollectionUtils;
@@ -61,6 +62,9 @@ public class ChangePricePrepareProcessor { @@ -61,6 +62,9 @@ public class ChangePricePrepareProcessor {
61 @Autowired 62 @Autowired
62 private PriceComputePrepareProcessor priceComputePrepareProcessor; 63 private PriceComputePrepareProcessor priceComputePrepareProcessor;
63 64
  65 + @Autowired
  66 + private SellerService sellerService;
  67 +
64 public ChangePricePrepareDTO checkAndAcquire(BatchChangePriceReq req) throws GatewayException { 68 public ChangePricePrepareDTO checkAndAcquire(BatchChangePriceReq req) throws GatewayException {
65 int uid = req.getUid(); 69 int uid = req.getUid();
66 if (uid <= 0){ 70 if (uid <= 0){
@@ -117,9 +121,9 @@ public class ChangePricePrepareProcessor { @@ -117,9 +121,9 @@ public class ChangePricePrepareProcessor {
117 //作为入驻商户 检查钱包 121 //作为入驻商户 检查钱包
118 BigDecimal targetEM = computeResult.getEarnestMoney().getEarnestMoney(); 122 BigDecimal targetEM = computeResult.getEarnestMoney().getEarnestMoney();
119 BigDecimal diffEarnestMoney = calDiffOfEM(sourceEM,targetEM); 123 BigDecimal diffEarnestMoney = calDiffOfEM(sourceEM,targetEM);
120 - 124 + boolean isSuper = sellerService.isSuperEntrySeller(uid);
121 if (diffEarnestMoney.compareTo(BigDecimal.ZERO)>0){ 125 if (diffEarnestMoney.compareTo(BigDecimal.ZERO)>0){
122 - sellerOrderPrepareProcessor.checkNGetMergeEarnestMoney(uid, diffEarnestMoney, num, salePrice); 126 + sellerOrderPrepareProcessor.checkNGetMergeEarnestMoney(uid, diffEarnestMoney, num, salePrice, isSuper);
123 } 127 }
124 sellerOrderPrepareProcessor.checkIncome(storageId, computeResult.getIncome()); 128 sellerOrderPrepareProcessor.checkIncome(storageId, computeResult.getIncome());
125 129
@@ -131,7 +135,7 @@ public class ChangePricePrepareProcessor { @@ -131,7 +135,7 @@ public class ChangePricePrepareProcessor {
131 .computeResult(computeResult) 135 .computeResult(computeResult)
132 .preEarnestMoney(sourceEM) 136 .preEarnestMoney(sourceEM)
133 .preSalePrice(preSalePrice) 137 .preSalePrice(preSalePrice)
134 - .tips(tips) 138 + .tips(tips).isSuper(isSuper)
135 .build(); 139 .build();
136 } 140 }
137 141
@@ -218,14 +218,17 @@ public class SellerOrderPrepareProcessor { @@ -218,14 +218,17 @@ public class SellerOrderPrepareProcessor {
218 } 218 }
219 } 219 }
220 220
221 - public BigDecimal checkNGetMergeEarnestMoney(int uid, BigDecimal singleEarestMoney, int num, BigDecimal prdPrice){ 221 + public BigDecimal checkNGetMergeEarnestMoney(int uid, BigDecimal singleEarestMoney,
  222 + int num, BigDecimal prdPrice, boolean isSuper){
222 BigDecimal mEarestMoney; 223 BigDecimal mEarestMoney;
223 mEarestMoney = BigDecimalHelper.halfUp(new BigDecimal(num).multiply(singleEarestMoney)); 224 mEarestMoney = BigDecimalHelper.halfUp(new BigDecimal(num).multiply(singleEarestMoney));
224 - boolean isEnough = isEnough(uid, mEarestMoney);  
225 - if (!isEnough){  
226 - log.warn("in checkNGetMergeEarnestMoney,wallet is not enough,uid {} num {} prdPrice {} singleEarestMoney {}",  
227 - uid, num, prdPrice, singleEarestMoney);  
228 - throw new ServiceException(ServiceError.WALLET_EARNESTMONEY_IS_NOT_ENOUGH); 225 + if(!isSuper) {
  226 + boolean isEnough = isEnough(uid, mEarestMoney);
  227 + if (!isEnough) {
  228 + log.warn("in checkNGetMergeEarnestMoney,wallet is not enough,uid {} num {} prdPrice {} singleEarestMoney {}",
  229 + uid, num, prdPrice, singleEarestMoney);
  230 + throw new ServiceException(ServiceError.WALLET_EARNESTMONEY_IS_NOT_ENOUGH);
  231 + }
229 } 232 }
230 return mEarestMoney; 233 return mEarestMoney;
231 } 234 }