From b9d4b907e8603d3a5fb7c42cebd0afb660e0723d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B7=AF=E6=98=8E=E6=85=A7?= <1191093413@qq.com> Date: Tue, 23 Apr 2024 11:22:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=8B=A6=E6=88=AA=E5=9F=8E=E9=98=B3?= =?UTF-8?q?=E5=BC=80=E7=A5=A8=E9=87=91=E9=A2=9D=EF=BC=8C=E9=99=90=E5=88=B6?= =?UTF-8?q?=E5=BC=80=E7=A5=A8=E9=87=91=E9=A2=9D=E3=80=81=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E3=80=81=E5=8F=91=E7=A5=A8=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application.yml | 6 ++ .../AisinoInvoiceRequestAdapterImpl.java | 78 +++++++++++++++++++ .../Nuonuo2InvoiceRequestAdapterImpl.java | 40 ++++++++++ 3 files changed, 124 insertions(+) diff --git a/jianshui-admin/src/main/resources/application.yml b/jianshui-admin/src/main/resources/application.yml index aa11daa..8c96f99 100644 --- a/jianshui-admin/src/main/resources/application.yml +++ b/jianshui-admin/src/main/resources/application.yml @@ -119,3 +119,9 @@ srm: # basic的账户密码 username: rendertopod pwd: renderpod!2 +billing: + limit: + nsrsbh: 92370214MACAAEK16E + kpje: 10 + xmmc: 维修费 + invoiceType: 82 diff --git a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/adapter/request/AisinoInvoiceRequestAdapterImpl.java b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/adapter/request/AisinoInvoiceRequestAdapterImpl.java index ed342dd..cc03842 100644 --- a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/adapter/request/AisinoInvoiceRequestAdapterImpl.java +++ b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/adapter/request/AisinoInvoiceRequestAdapterImpl.java @@ -10,6 +10,7 @@ import com.jianshui.common.exception.jianshui.JianshuiParamErrorException; import com.jianshui.common.utils.IdcardUtils; import com.jianshui.common.utils.StringUtils; import com.jianshui.common.utils.encrypt.JianshuiInvoiceDecryptUtil; +import com.jianshui.common.utils.spring.SpringUtils; import com.jianshui.invoice.domain.BillDetail; import com.jianshui.invoice.domain.BillInfo; import com.jianshui.invoice.domain.Redinfo; @@ -24,10 +25,13 @@ import com.jianshui.system.service.ICompanyserviceService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; import java.util.*; +import java.util.stream.Collectors; /** * @Description 航信入口报文适配器 @@ -212,6 +216,44 @@ public class AisinoInvoiceRequestAdapterImpl implements IInvoiceRequestService { if (StringUtils.isBlank(billInfo.getSellerAccount())){ billInfo.setSellerAccount(json.getString("xsfyhzh")); } + if (StringUtils.equals(serviceKey, "add")){ + Environment environment = SpringUtils.getBean(Environment.class); + String nsrsbhs = environment.getProperty("billing.limit.nsrsbh"); + List shList = Arrays.asList(nsrsbhs.split(",")); + if (shList.contains(billInfo.getSellerTaxnum())){ + List billDetailList = billInfo.getBillDetailList(); + if (billInfo.getTaxfreeamt() != null && billInfo.getTaxfreeamt().compareTo(new BigDecimal("10"))>0){ + throw new RuntimeException("发票金额不能大于10元"); + } + if (billInfo.getTaxamt() != null && billInfo.getTaxamt().compareTo(new BigDecimal("12"))>0){ + throw new RuntimeException("发票金额不能大于10元"); + } + if (billInfo.getTaxfreeamt() == null && billInfo.getTaxamt() == null){ + BigDecimal taxAmount = new BigDecimal("0"); + if ("1".equals(billInfo.getHsbz())){ + billDetailList.forEach(e->taxAmount.add(e.getTaxfreeamt())); + if (taxAmount.compareTo(new BigDecimal("10"))>0){ + throw new RuntimeException("发票金额不能大于10元"); + } + }else { + billDetailList.forEach(e->taxAmount.add(e.getTaxamt())); + if (taxAmount.compareTo(new BigDecimal("12"))>0){ + throw new RuntimeException("发票金额不能大于10元"); + } + } + + } + if (StringUtils.isNoneBlank(billInfo.getInvoiceType()) && !environment.getProperty("billing.limit.nsrsbh").equals(billInfo.getInvoiceType())){ + throw new RuntimeException("所开发票不是普票,请选择发票种类为普票"); + } + if (billDetailList != null && billDetailList.size() > 0){ + List mxList = billDetailList.stream().filter(e -> !e.getGoodName().contains(environment.getProperty("billing.limit.xmmc"))).collect(Collectors.toList()); + if (mxList != null && mxList.size() > 0){ + throw new RuntimeException("发票明细中包含非" + environment.getProperty("billing.limit.xmmc") + ",请删除后重试"); + } + } + } + } json = (JSONObject) JSONObject.toJSON(billInfo); } @@ -278,6 +320,42 @@ public class AisinoInvoiceRequestAdapterImpl implements IInvoiceRequestService { billInfo.setSellerBank(raw.replace(bankNo, "")); } } + Environment environment = SpringUtils.getBean(Environment.class); + String nsrsbhs = environment.getProperty("billing.limit.nsrsbh"); + List shList = Arrays.asList(nsrsbhs.split(",")); + if (shList.contains(billInfo.getSellerTaxnum())){ + List billDetailList = billInfo.getBillDetailList(); + if (billInfo.getTaxfreeamt() != null && billInfo.getTaxfreeamt().compareTo(new BigDecimal("10"))>0){ + throw new RuntimeException("发票金额不能大于10元"); + } + if (billInfo.getTaxamt() != null && billInfo.getTaxamt().compareTo(new BigDecimal("12"))>0){ + throw new RuntimeException("发票金额不能大于10元"); + } + if (billInfo.getTaxfreeamt() == null && billInfo.getTaxamt() == null){ + BigDecimal taxAmount = new BigDecimal("0"); + if ("1".equals(billInfo.getHsbz())){ + billDetailList.forEach(e->taxAmount.add(e.getTaxfreeamt())); + if (taxAmount.compareTo(new BigDecimal("10"))>0){ + throw new RuntimeException("发票金额不能大于10元"); + } + }else { + billDetailList.forEach(e->taxAmount.add(e.getTaxamt())); + if (taxAmount.compareTo(new BigDecimal("12"))>0){ + throw new RuntimeException("发票金额不能大于10元"); + } + } + + } + if (StringUtils.isNoneBlank(billInfo.getInvoiceType()) && !environment.getProperty("billing.limit.nsrsbh").equals(billInfo.getInvoiceType())){ + throw new RuntimeException("所开发票不是普票,请选择发票种类为普票"); + } + if (billDetailList != null && billDetailList.size() > 0){ + List mxList = billDetailList.stream().filter(e -> !e.getGoodName().contains(environment.getProperty("billing.limit.xmmc"))).collect(Collectors.toList()); + if (mxList != null && mxList.size() > 0){ + throw new RuntimeException("发票明细中包含非" + environment.getProperty("billing.limit.xmmc") + ",请删除后重试"); + } + } + } json = (JSONObject) JSONObject.toJSON(billInfo); billInfoResult.add(json); diff --git a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/adapter/request/Nuonuo2InvoiceRequestAdapterImpl.java b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/adapter/request/Nuonuo2InvoiceRequestAdapterImpl.java index dddb36c..c94ee6a 100644 --- a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/adapter/request/Nuonuo2InvoiceRequestAdapterImpl.java +++ b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/adapter/request/Nuonuo2InvoiceRequestAdapterImpl.java @@ -9,6 +9,7 @@ import com.jianshui.common.utils.DateUtils; import com.jianshui.common.utils.IdcardUtils; import com.jianshui.common.utils.StringUtils; import com.jianshui.common.utils.http.HttpHelper; +import com.jianshui.common.utils.spring.SpringUtils; import com.jianshui.invoice.domain.BillDetail; import com.jianshui.invoice.domain.BillInfo; import com.jianshui.invoice.domain.Redinfo; @@ -20,10 +21,13 @@ import com.jianshui.system.service.ICompanyserviceService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; import java.util.*; +import java.util.stream.Collectors; /** * @Description 航信入口报文适配器 @@ -101,6 +105,42 @@ public class Nuonuo2InvoiceRequestAdapterImpl implements IInvoiceRequestService } billInfo.setBillDetailList(detailList); } + Environment environment = SpringUtils.getBean(Environment.class); + String nsrsbhs = environment.getProperty("billing.limit.nsrsbh"); + List shList = Arrays.asList(nsrsbhs.split(",")); + if (shList.contains(billInfo.getSellerTaxnum())){ + List billDetailList = billInfo.getBillDetailList(); + if (billInfo.getTaxfreeamt() != null && billInfo.getTaxfreeamt().compareTo(new BigDecimal("10"))>0){ + throw new RuntimeException("发票金额不能大于10元"); + } + if (billInfo.getTaxamt() != null && billInfo.getTaxamt().compareTo(new BigDecimal("12"))>0){ + throw new RuntimeException("发票金额不能大于10元"); + } + if (billInfo.getTaxfreeamt() == null && billInfo.getTaxamt() == null){ + BigDecimal taxAmount = new BigDecimal("0"); + if ("1".equals(billInfo.getHsbz())){ + billDetailList.forEach(e->taxAmount.add(e.getTaxfreeamt())); + if (taxAmount.compareTo(new BigDecimal("10"))>0){ + throw new RuntimeException("发票金额不能大于10元"); + } + }else { + billDetailList.forEach(e->taxAmount.add(e.getTaxamt())); + if (taxAmount.compareTo(new BigDecimal("12"))>0){ + throw new RuntimeException("发票金额不能大于10元"); + } + } + + } + if (StringUtils.isNoneBlank(billInfo.getInvoiceType()) && !environment.getProperty("billing.limit.nsrsbh").equals(billInfo.getInvoiceType())){ + throw new RuntimeException("所开发票不是普票,请选择发票种类为普票"); + } + if (billDetailList != null && billDetailList.size() > 0){ + List mxList = billDetailList.stream().filter(e -> !e.getGoodName().contains(environment.getProperty("billing.limit.xmmc"))).collect(Collectors.toList()); + if (mxList != null && mxList.size() > 0){ + throw new RuntimeException("发票明细中包含非" + environment.getProperty("billing.limit.xmmc") + ",请删除后重试"); + } + } + } result = (JSONObject) JSONObject.toJSON(billInfo); }