|
|
|
@ -330,14 +330,14 @@ public class ImageSubmitServiceImpl implements ImageSubmitService { |
|
|
|
|
* @param taxRate |
|
|
|
|
* @return 去掉%的小数 |
|
|
|
|
*/ |
|
|
|
|
public BigDecimal getTaxRate(String taxRate) { |
|
|
|
|
public static BigDecimal getTaxRate(String taxRate) { |
|
|
|
|
if (StringUtils.isBlank(taxRate) || Constant.ZERO_TAXRATE_VALUE.contains(taxRate)) { |
|
|
|
|
taxRate = "0"; |
|
|
|
|
} else { |
|
|
|
|
taxRate = taxRate.replace("%", ""); |
|
|
|
|
// 判断是不是数字 不是数字的就给0
|
|
|
|
|
if (!isNumeric(taxRate)) { |
|
|
|
|
taxRate = "0.00"; |
|
|
|
|
taxRate = "0"; |
|
|
|
|
} else { |
|
|
|
|
// 不知道库里存的是13% 还是0.13 所以加一个判断
|
|
|
|
|
if (new BigDecimal(taxRate).compareTo(BigDecimal.ONE) >= 0) { |
|
|
|
@ -352,19 +352,21 @@ public class ImageSubmitServiceImpl implements ImageSubmitService { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static boolean isNumeric(String str){ |
|
|
|
|
for (int i = str.length();--i>=0;){ |
|
|
|
|
if (!Character.isDigit(str.charAt(i))){ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
Double.parseDouble(str); |
|
|
|
|
return true; |
|
|
|
|
} catch (NumberFormatException e) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
|
BigDecimal a = new BigDecimal(0.13); |
|
|
|
|
String tax = a.multiply(new BigDecimal(100)).setScale(4,BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString(); |
|
|
|
|
System.out.println(tax); |
|
|
|
|
System.out.println(StringUtils.isNumeric("13.00")); |
|
|
|
|
System.out.println(isNumeric("1e1")); |
|
|
|
|
System.out.println(getTaxRate("13.00")); |
|
|
|
|
System.out.println(TaxRateCodeEnum.getCode(tax)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|