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); }