Authored by chenchao

merge exception

... ... @@ -93,7 +93,7 @@ public class BigDecimalHelper {
Matcher matcher = pattern.matcher(numStr);
return matcher.matches();
}
public static void main(String[] args) {
System.out.println(isDigitalNumber("11111"));
... ...
... ... @@ -149,19 +149,16 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
int uid = pcn.getUid();
Integer storageId = pcn.getStorageId();
int num = pcn.getNum();
BigDecimal prdPrice = pcn.getPrdPrice();
BigDecimal salePrice = pcn.getPrdPrice();
String tips = null;
ProductProxyService.PrdPrice prdPrice = sellerOrderPrepareProcessor.checkPrice(storageId, salePrice);
try {
sellerOrderPrepareProcessor.checkPrice(storageId, prdPrice, false);
sellerOrderPrepareProcessor.checkSuggestPrice(prdPrice, salePrice);
}catch (Exception ex){
if (ex instanceof UfoServiceException && ((UfoServiceException) ex).getCode() == SellerOrderPrepareProcessor.TIPS_ERROR_CODE){
tips = ((UfoServiceException) ex).getMessage();
}else{
throw ex;
}
tips = ex.getMessage();
}
SoldPrdComputeBo spc = buildSoldPrdComputeBo(uid, num, prdPrice);
SoldPrdComputeBo spc = buildSoldPrdComputeBo(uid, num, salePrice);
spc.setTips(tips);
return spc;
}
... ...
... ... @@ -103,17 +103,12 @@ public class ChangePricePrepareProcessor {
int storageId = sampleSog.getStorageId();
String tips = null;
ProductProxyService.PrdPrice prdPrice = null;
ProductProxyService.PrdPrice prdPrice;
prdPrice = sellerOrderPrepareProcessor.checkPrice(storageId, salePrice);
try {
prdPrice = sellerOrderPrepareProcessor.checkPrice(storageId, salePrice, true);
sellerOrderPrepareProcessor.checkSuggestPrice(prdPrice, salePrice);
}catch (Exception ex){
if (ex instanceof UfoServiceException
&& ((UfoServiceException) ex).getCode() == SellerOrderPrepareProcessor.TIPS_ERROR_CODE){
tips = ((UfoServiceException) ex).getMessage();
}else{
throw ex;
}
tips = ex.getMessage();
}
// compute every fee from price
SellerOrderComputeResult computeResult = computeHandler.compute(salePrice);
... ...
... ... @@ -130,19 +130,14 @@ public class SellerOrderPrepareProcessor {
throw new ServiceException(ServiceError.ORDER_ORDERS_GOODS_IS_EMPTY);
}
context.setSoldProduct(goodsInfo);
ProductProxyService.PrdPrice prdPrice = null;
ProductProxyService.PrdPrice prdPrice = checkPrice(storageId, salePrice);;
try {
prdPrice = checkPrice(storageId, salePrice, true);
checkSuggestPrice(prdPrice, salePrice);
}catch (Exception ex){
if (ex instanceof UfoServiceException
&& ((UfoServiceException) ex).getCode() == SellerOrderPrepareProcessor.TIPS_ERROR_CODE){
context.setPriceOverFlowTips(((UfoServiceException) ex).getMessage());
}else{
throw ex;
}
context.setPriceOverFlowTips( ex.getMessage());
}
// compute every fee from price
SellerOrderComputeResult computeResult = computeHandler.compute(goodsInfo.getPrice());
checkIncome(storageId, computeResult.getIncome());
... ... @@ -189,7 +184,7 @@ public class SellerOrderPrepareProcessor {
public static final int TIPS_ERROR_CODE = 505;
public ProductProxyService.PrdPrice checkPrice(int storageId, BigDecimal prdPrice, boolean validateMaxPrice) {
public ProductProxyService.PrdPrice checkPrice(int storageId, BigDecimal prdPrice) {
ProductProxyService.PrdPrice prdPriceRange = productProxyService.getPrdPriceRange(storageId);
log.info("in checkPrice, prdPrice {}, storageId {} prdPriceRange {}", prdPrice, storageId, prdPriceRange);
BigDecimal minPrice = prdPriceRange.getMinPrice();
... ... @@ -199,16 +194,19 @@ public class SellerOrderPrepareProcessor {
throw new UfoServiceException(501, "您的出价过低");
}
if (validateMaxPrice && prdPrice.subtract(maxPrice).doubleValue() > 0D){
if (prdPrice.subtract(maxPrice).doubleValue() > 0D){
log.warn("in computePublishPrd,maxPrice {}, storageId {}", maxPrice, storageId);
throw new UfoServiceException(501, "您的出价过高");
}
BigDecimal suggestMaxPrice = prdPriceRange.getSuggestMaxPrice();
if (isOverSuggestMaxPrice(suggestMaxPrice, prdPrice)){
log.warn("in computePublishPrd,prdPrice {}, storageId {} prdPriceRange {}", prdPrice, storageId, prdPriceRange);
return prdPriceRange;
}
public void checkSuggestPrice(ProductProxyService.PrdPrice prdPrice, BigDecimal salePrice){
BigDecimal suggestMaxPrice = prdPrice.getSuggestMaxPrice();
if (isOverSuggestMaxPrice(suggestMaxPrice, salePrice)){
log.warn("in computePublishPrd,prdPrice {}, prdPriceRange {}", salePrice, prdPrice);
throw new UfoServiceException(TIPS_ERROR_CODE, "您的出价已超出建议售价,此商品将不会给顾客展示!");
}
return prdPriceRange;
}
public void checkIncome(int storageId, BigDecimal income) throws GatewayException {
... ...