Authored by chenchao

check publish auth

... ... @@ -182,7 +182,7 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServic
PrdQueryReq pqr = PrdQueryReq.builder().uid(uid)
.storageId(storageId).prdPrice(salePrice).build();
PrdPrice prdPrice = priceComputePrepareProcessor.checkPriceRange(pqr, true);
PrdPrice prdPrice = priceComputePrepareProcessor.checkPulishAuthNPriceRange(pqr, true);
SkupType skupType = SkupType.getSkupType(req.getSkupType());
try {
priceComputePrepareProcessor.checkSuggestPrice(prdPrice, salePrice, skupType);
... ...
... ... @@ -108,7 +108,25 @@ public class PriceComputePrepareProcessor {
return new PriceComputeNode(uid, storageId, num, prdPrice);
}
public void checkPublishAuth(Integer uid,int storageId, BigDecimal prdPrice, PrdPrice prdPriceRange){
if(!prdPriceRange.isCanPublish()){
log.warn("in checkPriceRange can not publish,uid {} prdPrice {}, storageId {} prdPriceRange {}",
uid, prdPrice, storageId, prdPriceRange);
throw new UfoServiceException(501, "您暂时没有权限出售");
}
}
public PrdPrice checkPulishAuthNPriceRange(PrdQueryReq prdQueryReq, boolean isShowError) {
int storageId = prdQueryReq.getStorageId();
BigDecimal prdPrice = prdQueryReq.getPrdPrice();
Integer uid = prdQueryReq.getUid();
PrdPrice prdPriceRange = productProxyService.getPrdPriceRange(uid, storageId);
log.info("in checkPulishAuthNPriceRange,uid {} prdPrice {}, storageId {} prdPriceRange {}",
uid, prdPrice, storageId, prdPriceRange);
checkPublishAuth(uid, storageId, prdPrice, prdPriceRange);
checkBasePriceRange(uid, storageId, prdPrice, prdPriceRange, isShowError);
return prdPriceRange;
}
/**
* 判定商品的价格上下限,skc维度,由平台控制
* @param prdQueryReq
... ... @@ -120,21 +138,29 @@ public class PriceComputePrepareProcessor {
BigDecimal prdPrice = prdQueryReq.getPrdPrice();
Integer uid = prdQueryReq.getUid();
PrdPrice prdPriceRange = productProxyService.getPrdPriceRange(uid, storageId);
log.info("in checkPrice, prdPrice {}, storageId {} prdPriceRange {}", prdPrice, storageId, prdPriceRange);
log.info("in checkPriceRange,uid {} prdPrice {}, storageId {} prdPriceRange {}",
uid, prdPrice, storageId, prdPriceRange);
checkBasePriceRange(uid, storageId, prdPrice, prdPriceRange, isShowError);
return prdPriceRange;
}
private void checkBasePriceRange(Integer uid,int storageId, BigDecimal prdPrice, PrdPrice prdPriceRange, boolean isShowError){
BigDecimal minPrice = prdPriceRange.getMinPrice();
BigDecimal maxPrice = prdPriceRange.getMaxPrice();
if (prdPrice.subtract(minPrice).doubleValue() < 0D){
log.warn("in computePublishPrd,minPrice {}, storageId {}", minPrice, storageId);
log.warn("in computePublishPrd,uid {} minPrice {}, storageId {}",
uid, minPrice, storageId);
if (isShowError)
throw new UfoServiceException(501, "您的出价过低");
}
if (prdPrice.subtract(maxPrice).doubleValue() > 0D){
log.warn("in computePublishPrd,maxPrice {}, storageId {}", maxPrice, storageId);
log.warn("in computePublishPrd,uid {} maxPrice {}, storageId {}",
uid, maxPrice, storageId);
if (isShowError)
throw new UfoServiceException(501, "您的出价过高");
}
return prdPriceRange;
}
public void checkSuggestPrice(PrdPrice prdPrice, BigDecimal salePrice, SkupType skupType){
... ...
... ... @@ -131,7 +131,7 @@ public class SellerOrderPrepareProcessor extends AbsPublishPrepareProcessor<Sell
PrdQueryReq pqr = PrdQueryReq.builder()
.uid(uid).prdPrice(salePrice).storageId(storageId).build();
PrdPrice prdPrice = priceComputePrepareProcessor.checkPriceRange(pqr, true);
PrdPrice prdPrice = priceComputePrepareProcessor.checkPulishAuthNPriceRange(pqr, true);
try {
priceComputePrepareProcessor.checkSuggestPrice(prdPrice, salePrice, skupType);
... ...