|
@ -1,6 +1,10 @@ |
|
|
package com.win.bank.service.cmb; |
|
|
package com.win.bank.service.cmb; |
|
|
|
|
|
|
|
|
|
|
|
import static com.win.bank.enums.CmbInvoiceQueryTypeEnum.*; |
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
import java.io.IOException; |
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
|
import java.math.RoundingMode; |
|
|
import java.net.URLEncoder; |
|
|
import java.net.URLEncoder; |
|
|
import java.nio.charset.StandardCharsets; |
|
|
import java.nio.charset.StandardCharsets; |
|
|
import java.time.LocalDate; |
|
|
import java.time.LocalDate; |
|
@ -22,6 +26,7 @@ import com.google.gson.JsonObject; |
|
|
import com.google.gson.JsonParser; |
|
|
import com.google.gson.JsonParser; |
|
|
import com.win.bank.domain.BankDO; |
|
|
import com.win.bank.domain.BankDO; |
|
|
import com.win.bank.domain.BasicInvoiceDO; |
|
|
import com.win.bank.domain.BasicInvoiceDO; |
|
|
|
|
|
import com.win.bank.enums.CmbFinInvoiceTypeEnum; |
|
|
import com.win.bank.enums.CmbInvoiceQueryTypeEnum; |
|
|
import com.win.bank.enums.CmbInvoiceQueryTypeEnum; |
|
|
import com.win.bank.enums.PaymentStatusEnum; |
|
|
import com.win.bank.enums.PaymentStatusEnum; |
|
|
import com.win.bank.service.BaseBankService; |
|
|
import com.win.bank.service.BaseBankService; |
|
@ -53,6 +58,14 @@ public class CmbServiceImpl implements BaseBankService { |
|
|
@Value("${cmb.busMod}") |
|
|
@Value("${cmb.busMod}") |
|
|
private String busMod; |
|
|
private String busMod; |
|
|
|
|
|
|
|
|
|
|
|
// 火车票税率
|
|
|
|
|
|
@Value("${cmb.invoice.trainTaxRate:0.09}") |
|
|
|
|
|
private String trainTaxRate; |
|
|
|
|
|
|
|
|
|
|
|
// 火车票税率
|
|
|
|
|
|
@Value("${cmb.invoice.daysToSubtract:7}") |
|
|
|
|
|
private String daysToSubtract; |
|
|
|
|
|
|
|
|
// 算法,固定为国密算法
|
|
|
// 算法,固定为国密算法
|
|
|
private static final String alg = "SM"; |
|
|
private static final String alg = "SM"; |
|
|
private static final String SUCCESS_CODE = "SUC0000"; |
|
|
private static final String SUCCESS_CODE = "SUC0000"; |
|
@ -157,7 +170,7 @@ public class CmbServiceImpl implements BaseBankService { |
|
|
|
|
|
|
|
|
LocalDate currentDate = LocalDate.now(); |
|
|
LocalDate currentDate = LocalDate.now(); |
|
|
// 获取当前日期前7天的日期
|
|
|
// 获取当前日期前7天的日期
|
|
|
LocalDate previousDate = currentDate.minusDays(7); |
|
|
LocalDate previousDate = currentDate.minusDays(Integer.parseInt(daysToSubtract)); |
|
|
Set<String> oldIds = basicInvoiceService.getInvoiceId(previousDate); |
|
|
Set<String> oldIds = basicInvoiceService.getInvoiceId(previousDate); |
|
|
|
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
|
@ -175,6 +188,9 @@ public class CmbServiceImpl implements BaseBankService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private int getInvoice(String data, CmbInvoiceQueryTypeEnum type, String funCode, Set<String> oldIds) { |
|
|
private int getInvoice(String data, CmbInvoiceQueryTypeEnum type, String funCode, Set<String> oldIds) { |
|
|
|
|
|
Set<String> specialTicket = new HashSet<>(Set.of("a", "b", "s", "85")); |
|
|
|
|
|
|
|
|
|
|
|
BigDecimal zero = new BigDecimal("0.00"); |
|
|
int totalPage = 0; |
|
|
int totalPage = 0; |
|
|
LocalDate currentDate = LocalDate.now(); |
|
|
LocalDate currentDate = LocalDate.now(); |
|
|
logger.info("发送给招商银行的数据" + JsonUtil.formatJson(data)); |
|
|
logger.info("发送给招商银行的数据" + JsonUtil.formatJson(data)); |
|
@ -204,6 +220,25 @@ public class CmbServiceImpl implements BaseBankService { |
|
|
BasicInvoiceDO basicInvoiceDO = new BasicInvoiceDO(); |
|
|
BasicInvoiceDO basicInvoiceDO = new BasicInvoiceDO(); |
|
|
BeanUtils.copyProperties(saleInvoice, basicInvoiceDO); |
|
|
BeanUtils.copyProperties(saleInvoice, basicInvoiceDO); |
|
|
basicInvoiceDO.setSystemCreateTime(currentDate); |
|
|
basicInvoiceDO.setSystemCreateTime(currentDate); |
|
|
|
|
|
basicInvoiceDO.setQueryType(A.getCode()); |
|
|
|
|
|
basicInvoiceDO.setQueryTypeName(A.getDescription()); |
|
|
|
|
|
basicInvoiceDO.setOriginalUserName(saleInvoice.getUserName()); |
|
|
|
|
|
if (StringUtils.isNotEmpty(saleInvoice.getUserRemark())) { |
|
|
|
|
|
basicInvoiceDO.setUserName(saleInvoice.getUserRemark()); |
|
|
|
|
|
} |
|
|
|
|
|
basicInvoiceDO.setBankTaxRate(saleInvoice.getTaxRate()); |
|
|
|
|
|
if (specialTicket.contains(saleInvoice.getInvoiceType())) { |
|
|
|
|
|
basicInvoiceDO.setTaxRate(saleInvoice.getTaxRate()); |
|
|
|
|
|
|
|
|
|
|
|
basicInvoiceDO.setTotalAmountWin(saleInvoice.getTotalAmount()); |
|
|
|
|
|
basicInvoiceDO.setTotalTaxWin(saleInvoice.getTotalTax()); |
|
|
|
|
|
basicInvoiceDO.setAmountTaxWin(saleInvoice.getAmountTax()); |
|
|
|
|
|
} else { |
|
|
|
|
|
basicInvoiceDO.setTaxRate(zero); |
|
|
|
|
|
basicInvoiceDO.setTotalAmountWin(saleInvoice.getAmountTax()); |
|
|
|
|
|
basicInvoiceDO.setTotalTaxWin(zero); |
|
|
|
|
|
basicInvoiceDO.setAmountTaxWin(saleInvoice.getAmountTax()); |
|
|
|
|
|
} |
|
|
invoiceDOList.add(basicInvoiceDO); |
|
|
invoiceDOList.add(basicInvoiceDO); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
@ -215,6 +250,20 @@ public class CmbServiceImpl implements BaseBankService { |
|
|
BasicInvoiceDO basicInvoiceDO = new BasicInvoiceDO(); |
|
|
BasicInvoiceDO basicInvoiceDO = new BasicInvoiceDO(); |
|
|
BeanUtils.copyProperties(financialInvoice, basicInvoiceDO); |
|
|
BeanUtils.copyProperties(financialInvoice, basicInvoiceDO); |
|
|
basicInvoiceDO.setSystemCreateTime(currentDate); |
|
|
basicInvoiceDO.setSystemCreateTime(currentDate); |
|
|
|
|
|
basicInvoiceDO.setQueryType(I.getCode()); |
|
|
|
|
|
basicInvoiceDO.setQueryTypeName(I.getDescription()); |
|
|
|
|
|
basicInvoiceDO.setOriginalUserName(financialInvoice.getUserName()); |
|
|
|
|
|
if (StringUtils.isNotEmpty(financialInvoice.getUserRemark())) { |
|
|
|
|
|
basicInvoiceDO.setUserName(financialInvoice.getUserRemark()); |
|
|
|
|
|
} |
|
|
|
|
|
basicInvoiceDO.setInvoiceTypeName(Objects.requireNonNull(CmbFinInvoiceTypeEnum.getByCode(basicInvoiceDO.getFinInvoiceType())).getDescription()); |
|
|
|
|
|
basicInvoiceDO.setBankTaxRate(zero); |
|
|
|
|
|
basicInvoiceDO.setTotalAmountWin(financialInvoice.getTotalAmount()); |
|
|
|
|
|
basicInvoiceDO.setTaxRate(zero); |
|
|
|
|
|
basicInvoiceDO.setTotalTaxWin(zero); |
|
|
|
|
|
basicInvoiceDO.setAmountTax(financialInvoice.getTotalAmount()); |
|
|
|
|
|
basicInvoiceDO.setTotalAmount(null); |
|
|
|
|
|
basicInvoiceDO.setAmountTaxWin(financialInvoice.getTotalAmount()); |
|
|
invoiceDOList.add(basicInvoiceDO); |
|
|
invoiceDOList.add(basicInvoiceDO); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
@ -230,6 +279,31 @@ public class CmbServiceImpl implements BaseBankService { |
|
|
basicInvoiceDO.setInvoiceType(ticketInvoice.getTicketType()); |
|
|
basicInvoiceDO.setInvoiceType(ticketInvoice.getTicketType()); |
|
|
basicInvoiceDO.setInvoiceTypeName(ticketInvoice.getTicketTypeName()); |
|
|
basicInvoiceDO.setInvoiceTypeName(ticketInvoice.getTicketTypeName()); |
|
|
basicInvoiceDO.setInvoiceDate(ticketInvoice.getTicketDate()); |
|
|
basicInvoiceDO.setInvoiceDate(ticketInvoice.getTicketDate()); |
|
|
|
|
|
basicInvoiceDO.setQueryType(T.getCode()); |
|
|
|
|
|
basicInvoiceDO.setQueryTypeName(T.getDescription()); |
|
|
|
|
|
basicInvoiceDO.setAmountTax(basicInvoiceDO.getTotalAmount()); |
|
|
|
|
|
basicInvoiceDO.setTotalAmount(null); |
|
|
|
|
|
basicInvoiceDO.setOriginalUserName(ticketInvoice.getUserName()); |
|
|
|
|
|
if (StringUtils.isNotEmpty(ticketInvoice.getUserRemark())) { |
|
|
|
|
|
basicInvoiceDO.setUserName(ticketInvoice.getUserRemark()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
basicInvoiceDO.setBankTaxRate(zero); |
|
|
|
|
|
basicInvoiceDO.setAmountTaxWin(basicInvoiceDO.getAmountTax()); |
|
|
|
|
|
if ("u".equals(basicInvoiceDO.getInvoiceType())) { |
|
|
|
|
|
BigDecimal taxRate = new BigDecimal(trainTaxRate); |
|
|
|
|
|
basicInvoiceDO.setTaxRate(taxRate); |
|
|
|
|
|
// 税额 = 价税合计 / (1 + 税率) * 税率
|
|
|
|
|
|
// 合计金额 = 价税合计 - 税额
|
|
|
|
|
|
BigDecimal totalTax = |
|
|
|
|
|
basicInvoiceDO.getAmountTaxWin().divide(BigDecimal.ONE.add(taxRate), 2, RoundingMode.HALF_UP).multiply(taxRate).setScale(2, RoundingMode.HALF_UP); |
|
|
|
|
|
basicInvoiceDO.setTotalTaxWin(totalTax); |
|
|
|
|
|
basicInvoiceDO.setTotalAmountWin(basicInvoiceDO.getAmountTaxWin().subtract(totalTax)); |
|
|
|
|
|
} else { |
|
|
|
|
|
basicInvoiceDO.setTaxRate(zero); |
|
|
|
|
|
basicInvoiceDO.setTotalAmountWin(basicInvoiceDO.getAmountTax()); |
|
|
|
|
|
basicInvoiceDO.setTotalTaxWin(zero); |
|
|
|
|
|
} |
|
|
invoiceDOList.add(basicInvoiceDO); |
|
|
invoiceDOList.add(basicInvoiceDO); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|