|
|
@ -10,6 +10,7 @@ import com.jianshui.common.exception.jianshui.JianshuiParamErrorException; |
|
|
|
import com.jianshui.common.utils.IdcardUtils; |
|
|
|
import com.jianshui.common.utils.IdcardUtils; |
|
|
|
import com.jianshui.common.utils.StringUtils; |
|
|
|
import com.jianshui.common.utils.StringUtils; |
|
|
|
import com.jianshui.common.utils.encrypt.JianshuiInvoiceDecryptUtil; |
|
|
|
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.BillDetail; |
|
|
|
import com.jianshui.invoice.domain.BillInfo; |
|
|
|
import com.jianshui.invoice.domain.BillInfo; |
|
|
|
import com.jianshui.invoice.domain.Redinfo; |
|
|
|
import com.jianshui.invoice.domain.Redinfo; |
|
|
@ -24,10 +25,13 @@ import com.jianshui.system.service.ICompanyserviceService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
|
|
import org.springframework.core.env.Environment; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @Description 航信入口报文适配器 |
|
|
|
* @Description 航信入口报文适配器 |
|
|
@ -212,6 +216,44 @@ public class AisinoInvoiceRequestAdapterImpl implements IInvoiceRequestService { |
|
|
|
if (StringUtils.isBlank(billInfo.getSellerAccount())){ |
|
|
|
if (StringUtils.isBlank(billInfo.getSellerAccount())){ |
|
|
|
billInfo.setSellerAccount(json.getString("xsfyhzh")); |
|
|
|
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); |
|
|
|
json = (JSONObject) JSONObject.toJSON(billInfo); |
|
|
|
} |
|
|
|
} |
|
|
@ -278,6 +320,42 @@ public class AisinoInvoiceRequestAdapterImpl implements IInvoiceRequestService { |
|
|
|
billInfo.setSellerBank(raw.replace(bankNo, "")); |
|
|
|
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); |
|
|
|
json = (JSONObject) JSONObject.toJSON(billInfo); |
|
|
|
billInfoResult.add(json); |
|
|
|
billInfoResult.add(json); |
|
|
|