Authored by chenchao

fix super entry

... ... @@ -36,4 +36,6 @@ public class ChangePricePrepareDTO {
private String tips;
private boolean isSuper;
}
... ...
... ... @@ -147,6 +147,8 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
log.info("in computePublishPrd, req {}", req);
PriceComputePrepareProcessor.PriceComputeNode pcn = priceComputePrepareProcessor.checkBasePrice(req);
int uid = pcn.getUid();
Integer storageId = pcn.getStorageId();
int num = pcn.getNum();
BigDecimal salePrice = pcn.getPrdPrice();
... ... @@ -157,8 +159,8 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
}catch (UfoServiceException ex){
tips = ex.getErrorMessage();
}
SoldPrdComputeBo spc = buildSoldPrdComputeBo(uid, num, salePrice);
boolean isSuper = sellerService.isSuperEntrySeller(uid);
SoldPrdComputeBo spc = buildSoldPrdComputeBo(uid, num, salePrice, isSuper);
spc.setTips(tips);
return spc;
}
... ... @@ -259,7 +261,8 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
boolean isSurper = sellerService.isSuperEntrySeller(uid);
SellerOrderComputeResult socr = ctx.getSellerOrderComputeResult();
BigDecimal singleEarestMoney = socr.getEarnestMoney().getEarnestMoney();
BigDecimal mEarestMoney = sellerOrderPrepareProcessor.checkNGetMergeEarnestMoney(uid, singleEarestMoney, num, ctx.getSalePrice());
BigDecimal mEarestMoney = sellerOrderPrepareProcessor.checkNGetMergeEarnestMoney(uid, singleEarestMoney,
num, ctx.getSalePrice(), isSurper);
SellerWalletDetail.Type swdType = SellerWalletDetail.Type.PUBLISH;
MerchantOrderAttachInfo moai = MerchantOrderAttachInfo.builder().uid(uid)
.storageId(ctx.getStorageId()).earnestMoney(mEarestMoney)
... ... @@ -484,13 +487,14 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
}
}
private SoldPrdComputeBo buildSoldPrdComputeBo(int uid, int num, BigDecimal prdPrice){
private SoldPrdComputeBo buildSoldPrdComputeBo(int uid, int num, BigDecimal prdPrice, boolean isSuper){
SellerOrderComputeResult computeResult = computeHandler.compute(prdPrice);
/**
* 验证是否是入驻商家
*/
if(sellerOrderPrepareProcessor.checkIsEntry(uid)){
sellerOrderPrepareProcessor.checkNGetMergeEarnestMoney(uid, computeResult.getEarnestMoney().getEarnestMoney(), num, prdPrice);
sellerOrderPrepareProcessor.checkNGetMergeEarnestMoney(uid,
computeResult.getEarnestMoney().getEarnestMoney(), num, prdPrice, isSuper);
}
SoldPrdComputeBo computeBo = SellerOrderConvertor.computeResult2SoldPrdComputeBo(computeResult);
... ... @@ -568,6 +572,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
ChangePricePrepareDTO cppDto = changePricePrepareProcessor.checkAndAcquire(req);
BigDecimal preSalePrice = cppDto.getPreSalePrice(),
salePrice = cppDto.getSalePrice();
boolean isSurper = cppDto.isSuper();
int uid = req.getUid();
Map<Integer, SkupDto> skupMap = cppDto.getSkupMap();
SellerOrderComputeResult computeResult = cppDto.getComputeResult();
... ... @@ -583,7 +588,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
.earnestMoney(totalDiffMoney).productCount(skupMap.size())
.seriNo(String.valueOf(req.getBatchNo()))
.type(swdType.getValue()).build();
boolean isSurper = sellerService.isSuperEntrySeller(uid);
SellerWallet sellerWallet = isSurper ? new SellerWallet() : merchantOrderPaymentService.changePriceUseEarnest(uid, totalDiffMoney, moai);
int successCnt = 0;
int failCnt = 0;
... ...
... ... @@ -19,6 +19,7 @@ import com.yohoufo.order.model.dto.ChangePricePrepareDTO;
import com.yohoufo.order.model.dto.SellerOrderComputeResult;
import com.yohoufo.order.model.dto.SkupDto;
import com.yohoufo.order.service.handler.SellerOrderComputeHandler;
import com.yohoufo.order.service.impl.SellerService;
import com.yohoufo.order.service.proxy.ProductProxyService;
import com.yohoufo.order.utils.LoggerUtils;
import org.apache.commons.collections.CollectionUtils;
... ... @@ -61,6 +62,9 @@ public class ChangePricePrepareProcessor {
@Autowired
private PriceComputePrepareProcessor priceComputePrepareProcessor;
@Autowired
private SellerService sellerService;
public ChangePricePrepareDTO checkAndAcquire(BatchChangePriceReq req) throws GatewayException {
int uid = req.getUid();
if (uid <= 0){
... ... @@ -117,9 +121,9 @@ public class ChangePricePrepareProcessor {
//作为入驻商户 检查钱包
BigDecimal targetEM = computeResult.getEarnestMoney().getEarnestMoney();
BigDecimal diffEarnestMoney = calDiffOfEM(sourceEM,targetEM);
boolean isSuper = sellerService.isSuperEntrySeller(uid);
if (diffEarnestMoney.compareTo(BigDecimal.ZERO)>0){
sellerOrderPrepareProcessor.checkNGetMergeEarnestMoney(uid, diffEarnestMoney, num, salePrice);
sellerOrderPrepareProcessor.checkNGetMergeEarnestMoney(uid, diffEarnestMoney, num, salePrice, isSuper);
}
sellerOrderPrepareProcessor.checkIncome(storageId, computeResult.getIncome());
... ... @@ -131,7 +135,7 @@ public class ChangePricePrepareProcessor {
.computeResult(computeResult)
.preEarnestMoney(sourceEM)
.preSalePrice(preSalePrice)
.tips(tips)
.tips(tips).isSuper(isSuper)
.build();
}
... ...
... ... @@ -218,14 +218,17 @@ public class SellerOrderPrepareProcessor {
}
}
public BigDecimal checkNGetMergeEarnestMoney(int uid, BigDecimal singleEarestMoney, int num, BigDecimal prdPrice){
public BigDecimal checkNGetMergeEarnestMoney(int uid, BigDecimal singleEarestMoney,
int num, BigDecimal prdPrice, boolean isSuper){
BigDecimal mEarestMoney;
mEarestMoney = BigDecimalHelper.halfUp(new BigDecimal(num).multiply(singleEarestMoney));
boolean isEnough = isEnough(uid, mEarestMoney);
if (!isEnough){
log.warn("in checkNGetMergeEarnestMoney,wallet is not enough,uid {} num {} prdPrice {} singleEarestMoney {}",
uid, num, prdPrice, singleEarestMoney);
throw new ServiceException(ServiceError.WALLET_EARNESTMONEY_IS_NOT_ENOUGH);
if(!isSuper) {
boolean isEnough = isEnough(uid, mEarestMoney);
if (!isEnough) {
log.warn("in checkNGetMergeEarnestMoney,wallet is not enough,uid {} num {} prdPrice {} singleEarestMoney {}",
uid, num, prdPrice, singleEarestMoney);
throw new ServiceException(ServiceError.WALLET_EARNESTMONEY_IS_NOT_ENOUGH);
}
}
return mEarestMoney;
}
... ...