ariesy 修复查验票池已存在数据税率为整数的情况

release
yefei 2 years ago
parent 78b1bdc6a0
commit f56e4e42de
  1. 31
      dxhy-erp/src/main/java/com/dxhy/erp/controller/SDNYMainProcessController.java
  2. 13
      dxhy-erp/src/main/java/com/dxhy/erp/utils/CheckUtil.java

@ -20,6 +20,7 @@ import com.dxhy.erp.model.InvoiceDetailInfo;
import com.dxhy.erp.service.*; import com.dxhy.erp.service.*;
import com.dxhy.erp.service.impl.GatherServiceImpl; import com.dxhy.erp.service.impl.GatherServiceImpl;
import com.dxhy.erp.utils.Base64; import com.dxhy.erp.utils.Base64;
import com.dxhy.erp.utils.CheckUtil;
import com.dxhy.erp.utils.HmacSHA1Util; import com.dxhy.erp.utils.HmacSHA1Util;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -494,20 +495,22 @@ public class SDNYMainProcessController extends AbstractController {
if (detail.get("taxRate") != null && StringUtils.isNoneBlank(detail.get("taxRate").toString())) { if (detail.get("taxRate") != null && StringUtils.isNoneBlank(detail.get("taxRate").toString())) {
taxRateDetail = detail.get("taxRate").toString(); taxRateDetail = detail.get("taxRate").toString();
if (!"0".equals(taxRateDetail)) { if (!"0".equals(taxRateDetail)) {
if (StringUtils.isNoneBlank(taxRateDetail)) { // if (StringUtils.isNoneBlank(taxRateDetail)) {
int index = taxRateDetail.indexOf("%"); // int index = taxRateDetail.indexOf("%");
if (index > 0) { // if (index > 0) {
taxRateDetail = taxRateDetail.substring(0, taxRateDetail.length() - 1); // taxRateDetail = taxRateDetail.substring(0, taxRateDetail.length() - 1);
Float num = Float.parseFloat(taxRateDetail); // Float num = Float.parseFloat(taxRateDetail);
if (num > 9) { // if (num > 9) {
taxRateDetail = "0." + taxRateDetail; // taxRateDetail = "0." + taxRateDetail;
} else { // } else {
if (!taxRateDetail.startsWith("0")) { // if (!taxRateDetail.startsWith("0")) {
taxRateDetail = "0.0" + taxRateDetail; // taxRateDetail = "0.0" + taxRateDetail;
} // }
} // }
} // }
} // }
taxRateDetail = CheckUtil.formatPercentSl(taxRateDetail);
} }
if ("11".equals(invoiceType)) { if ("11".equals(invoiceType)) {

@ -1,5 +1,6 @@
package com.dxhy.erp.utils; package com.dxhy.erp.utils;
import com.alibaba.cloud.commons.lang.StringUtils;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.dxhy.erp.entity.CheckInvoiceParam; import com.dxhy.erp.entity.CheckInvoiceParam;
import com.dxhy.erp.entity.FP; import com.dxhy.erp.entity.FP;
@ -8,6 +9,8 @@ import cn.hutool.core.codec.Base64;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.text.NumberFormat;
/** /**
* @author dxhy * @author dxhy
*/ */
@ -16,6 +19,8 @@ public class CheckUtil {
private static final String URL = "https://cypt.ele-cloud.com/recipt/checkFp/barcode"; private static final String URL = "https://cypt.ele-cloud.com/recipt/checkFp/barcode";
public static final NumberFormat NF = NumberFormat.getPercentInstance();
public static FP getCheck(CheckInvoiceParam checkInvoiceParam) throws Exception { public static FP getCheck(CheckInvoiceParam checkInvoiceParam) throws Exception {
String hmacsha1 = CheckHmacsha1Util.getHmacsha1(checkInvoiceParam); String hmacsha1 = CheckHmacsha1Util.getHmacsha1(checkInvoiceParam);
String json = HttpUtil.post(URL, hmacsha1, 30000); String json = HttpUtil.post(URL, hmacsha1, 30000);
@ -28,4 +33,12 @@ public class CheckUtil {
} }
return null; return null;
} }
public static String formatPercentSl(String sl) {
if (StringUtils.isNotEmpty(sl)) {
NF.setMaximumFractionDigits(3);
sl = NF.format(Double.valueOf(sl));
}
return sl;
}
} }

Loading…
Cancel
Save