Browse Source

上传代码

master
zhaoyiran 2 months ago
parent
commit
a6294a6a32
  1. 22
      src/main/java/com/win/bank/domain/BasicInvoiceDO.java
  2. 33
      src/main/java/com/win/bank/enums/CmbFinInvoiceTypeEnum.java
  3. 6
      src/main/java/com/win/bank/service/MainService.java
  4. 76
      src/main/java/com/win/bank/service/cmb/CmbServiceImpl.java
  5. 4
      src/main/java/com/win/bank/service/cmb/entity/SaleInvoice.java
  6. 4
      src/main/java/com/win/bank/service/cmb/entity/TicketInvoice.java
  7. 16
      src/main/resources/application-dev.yml

22
src/main/java/com/win/bank/domain/BasicInvoiceDO.java

@ -198,4 +198,26 @@ public class BasicInvoiceDO {
// 财政票据类型 // 财政票据类型
private String finInvoiceType; private String finInvoiceType;
private String queryType;
private String queryTypeName;
// 银行税率
private BigDecimal bankTaxRate;
// 税率
private BigDecimal taxRate;
// 合计金额
private BigDecimal totalAmountWin;
// 合计税额
private BigDecimal totalTaxWin;
// 价税合计
private BigDecimal amountTaxWin;
private String originalUserName;
} }

33
src/main/java/com/win/bank/enums/CmbFinInvoiceTypeEnum.java

@ -0,0 +1,33 @@
package com.win.bank.enums;
public enum CmbFinInvoiceTypeEnum {
GENERAL_NOTES_FOR_NON_TAX_RECEIPTS("01", "非税收入通用票据"), SPECIAL_INSTRUMENT_FOR_NON_TAX_RECEIPTS("02", "非税收入专用票据"), FUND_CLEARING_INSTRUMENT("04", "资金往来结算票据"),
CHARITABLE_DONATION_TICKET("05", "公益事业捐赠票据"), MEDICAL_BILL("06", "医疗收费票据"), SOCIAL_GROUP_MEMBERSHIP_NOTES("07", "社会团体会费票据"), SOCIAL_INSURANCE_FUND_NOTES("08", "社会保险基金票据"),
RECEIPT_OF_TRADE_UNION_FUNDS("09", "工会经费收入票据"), OTHER_FINANCIAL_INSTRUMENTS("99", "其他财政票据");
private final String code;
private final String description;
CmbFinInvoiceTypeEnum(String code, String description) {
this.code = code;
this.description = description;
}
public String getCode() {
return code;
}
public String getDescription() {
return description;
}
public static CmbFinInvoiceTypeEnum getByCode(String code) {
for (CmbFinInvoiceTypeEnum enumValue : values()) {
if (enumValue.code.equals(code)) {
return enumValue;
}
}
return null;
}
}

6
src/main/java/com/win/bank/service/MainService.java

@ -18,7 +18,7 @@ public class MainService {
@Resource @Resource
private BankService bankService; private BankService bankService;
// @Scheduled(cron = "0 0/1 * * * ? ") @Scheduled(cron = "${cmb.cron.pay}")
public void payTask() { public void payTask() {
List<BankDO> bankDOList = bankService.listByStatus(PaymentStatusEnum.UNPROCESSED.getCode()); List<BankDO> bankDOList = bankService.listByStatus(PaymentStatusEnum.UNPROCESSED.getCode());
for (BankDO bankDO : bankDOList) { for (BankDO bankDO : bankDOList) {
@ -28,7 +28,7 @@ public class MainService {
} }
} }
// @Scheduled(cron = "30 0/1 * * * ? ") @Scheduled(cron = "${cmb.cron.query}")
public void queryPaymentResult() { public void queryPaymentResult() {
List<BankDO> bankDOList = bankService.listByStatus(PaymentStatusEnum.PAYING.getCode()); List<BankDO> bankDOList = bankService.listByStatus(PaymentStatusEnum.PAYING.getCode());
for (BankDO bankDO : bankDOList) { for (BankDO bankDO : bankDOList) {
@ -40,7 +40,7 @@ public class MainService {
} }
} }
@Scheduled(cron = "0 0/1 * * * ? ") @Scheduled(cron = "${cmb.cron.invoice}")
public void getInvoice() { public void getInvoice() {
BaseBankService baseBankService = BaseBankServiceUtil.get("cmb".toUpperCase()); BaseBankService baseBankService = BaseBankServiceUtil.get("cmb".toUpperCase());
baseBankService.getInvoice(); baseBankService.getInvoice();

76
src/main/java/com/win/bank/service/cmb/CmbServiceImpl.java

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

4
src/main/java/com/win/bank/service/cmb/entity/SaleInvoice.java

@ -116,4 +116,8 @@ public class SaleInvoice {
// 备注 // 备注
private String remark; private String remark;
private String userRemark;
private BigDecimal taxRate;
} }

4
src/main/java/com/win/bank/service/cmb/entity/TicketInvoice.java

@ -118,4 +118,8 @@ public class TicketInvoice {
// 其它税费 // 其它税费
private BigDecimal otherTax; private BigDecimal otherTax;
private String remark;
private String userRemark;
} }

16
src/main/resources/application-dev.yml

@ -20,7 +20,7 @@ spring:
datasource: datasource:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
url: jdbc:sqlserver://192.168.0.142:1433;database=ExChangeCenter_Test;encrypt=false url: jdbc:sqlserver://192.168.0.142:1433;database=ExChangeCenter;encrypt=false
username: sa username: sa
password: BPM@#123!@# password: BPM@#123!@#
@ -46,6 +46,20 @@ cmb:
# 业务模式,前置机查看 # 业务模式,前置机查看
busMod: "00001" busMod: "00001"
url: http://192.168.0.142:8080/cdcserver/api/v2 url: http://192.168.0.142:8080/cdcserver/api/v2
# 发票相关配置
invoice:
# 火车票税率
trainTaxRate: "0.09"
# 查询当前日期多少天之内的发票
daysToSubtract: 7
# 定时任务表达式
cron:
# 支付
pay: 0 0/1 * * * ?
# 查询支付结果
query: 30 0/1 * * * ?
# 查询发票
invoice: 0 0/1 * * * ?
# 交通银行 # 交通银行
bocom: bocom:

Loading…
Cancel
Save