fix:拦截城阳开票金额,限制开票金额、项目名称、发票类型

master
路明慧 1 year ago
parent 95f1a23277
commit b9d4b907e8
  1. 6
      jianshui-admin/src/main/resources/application.yml
  2. 78
      jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/adapter/request/AisinoInvoiceRequestAdapterImpl.java
  3. 40
      jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/adapter/request/Nuonuo2InvoiceRequestAdapterImpl.java

@ -119,3 +119,9 @@ srm:
# basic的账户密码
username: rendertopod
pwd: renderpod!2
billing:
limit:
nsrsbh: 92370214MACAAEK16E
kpje: 10
xmmc: 维修费
invoiceType: 82

@ -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<String> shList = Arrays.asList(nsrsbhs.split(","));
if (shList.contains(billInfo.getSellerTaxnum())){
List<BillDetail> 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<BillDetail> 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<String> shList = Arrays.asList(nsrsbhs.split(","));
if (shList.contains(billInfo.getSellerTaxnum())){
List<BillDetail> 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<BillDetail> 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);

@ -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<String> shList = Arrays.asList(nsrsbhs.split(","));
if (shList.contains(billInfo.getSellerTaxnum())){
List<BillDetail> 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<BillDetail> 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);
}

Loading…
Cancel
Save