银行账号、名称拆分方式

beta
kk 2 years ago
parent 053eafab6f
commit b78b44e8af
  1. 11
      jianshui-admin/src/main/java/com/jianshui/api/controller/http/invoice/v1/InvoiceController.java
  2. 35
      jianshui-common/src/main/java/com/jianshui/common/utils/IdcardUtils.java
  3. 97
      jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/adapter/request/AisinoInvoiceRequestAdapterImpl.java
  4. 8
      jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/adapter/request/Nuonuo2InvoiceRequestAdapterImpl.java

@ -620,7 +620,16 @@ public class InvoiceController {
useAisino = true;
}
HXResponse result = preHandleDecryptResult(decryptResult, "batch_print", companyservice);
// HXResponse result = preHandleDecryptResult(decryptResult, "batch_print", companyservice);
PrintDTO billInfo = decryptResult.toJavaObject(PrintDTO.class);
if (billInfo == null) {
throw new JianshuiParamErrorException(ErrorCode.ERROR_PARAMS, companyservice, "invoice");
}
// 获得请求实例,并且进行扣费
String serviceKey = serviceManageService.getCompanyServiceSupplier("invoice", companyservice.getCompanyid());
serviceManageService.companyConsume("invoice", companyservice.getCompanyid());
IInvoiceApiService invoiceService = invoiceServiceFactory.getService(serviceKey);
HXResponse result = invoiceService.batchPrint(billInfo, companyservice);
String responseAdapterKey = serviceManageService.getResponseAdapterKey("invoice", companyservice.getCompanyid());
IInvoiceResponseService invoiceResponseService = null;

@ -3,7 +3,11 @@ package com.jianshui.common.utils;
import cn.hutool.core.util.ReUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @Description 身份证工具类
@ -104,4 +108,35 @@ public class IdcardUtils {
return "";
}
/** 解析银行账号-名称*/
public static Map<String,String> getBankNoAndName(String input){
Map<String,String> resultMap = new HashMap<>();
String regex = "(\\p{InCJK_Unified_Ideographs})|(\\d+)";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(input);
StringBuilder chineseBuilder = new StringBuilder();
StringBuilder numberBuilder = new StringBuilder();
while (matcher.find()) {
String match = matcher.group();
if (match.matches("\\p{InCJK_Unified_Ideographs}")) {
chineseBuilder.append(match);
} else {
numberBuilder.append(match);
}
}
String chinese = chineseBuilder.toString().replaceAll("\\s", "");
String numbers = numberBuilder.toString().replaceAll("\\s", "");
resultMap.put("bankNo", numbers);
resultMap.put("bankName", chinese);
return resultMap;
}
}

@ -140,7 +140,7 @@ public class AisinoInvoiceRequestAdapterImpl implements IInvoiceRequestService {
// throw new JianshuiParamErrorException(ErrorCode.IDENTITY_NOT_MATCH,"invoice);
// }
// 红字查询
if (StringUtils.equals(serviceKey,"find_redinfo")){
if (StringUtils.equals(serviceKey, "find_redinfo")) {
return json;
}
// 如果是开票或者查询
@ -149,17 +149,27 @@ public class AisinoInvoiceRequestAdapterImpl implements IInvoiceRequestService {
HxBillInfoDTO hxBillInfo = json.toJavaObject(HxBillInfoDTO.class);
BillInfo billInfo = new BillInfo();
BeanUtils.copyProperties(hxBillInfo, billInfo);
if(StringUtils.isNotEmpty(hxBillInfo.getEmail())){
if (StringUtils.isNotEmpty(hxBillInfo.getEmail())) {
billInfo.setBuyerEmail(hxBillInfo.getEmail());
}
if (StringUtils.isEmpty(billInfo.getBuyerBank()) && StringUtils.isNotEmpty(billInfo.getBuyerAccount())) {
// TODO: 2023/11/24 银行处理
/*if (StringUtils.isEmpty(billInfo.getBuyerBank()) && StringUtils.isNotEmpty(billInfo.getBuyerAccount())) {
String bankNo = IdcardUtils.getBankNo(billInfo.getBuyerAccount());
if (StringUtils.isNotEmpty(bankNo)) {
String raw = billInfo.getBuyerAccount();
billInfo.setBuyerAccount(bankNo);
billInfo.setBuyerBank(raw.replace(bankNo, ""));
}
}*/
// 银行处理
if (StringUtils.isEmpty(billInfo.getBuyerBank()) && StringUtils.isNotEmpty(billInfo.getBuyerAccount())) {
Map<String, String> bank = IdcardUtils.getBankNoAndName(billInfo.getBuyerAccount());
billInfo.setBuyerAccount(bank.getOrDefault("bankNo", ""));
billInfo.setBuyerBank(bank.getOrDefault("bankName", ""));
}
// 处理detail
List<HxBillDetailDTO> hxBillDetailList = hxBillInfo.getDetail();
List<BillDetail> detailList = new ArrayList<>();
@ -172,13 +182,19 @@ public class AisinoInvoiceRequestAdapterImpl implements IInvoiceRequestService {
billInfo.setBillDetailList(detailList);
}
if (StringUtils.isEmpty(billInfo.getBuyerBank()) && StringUtils.isNotEmpty(billInfo.getBuyerAccount())) {
/*if (StringUtils.isEmpty(billInfo.getBuyerBank()) && StringUtils.isNotEmpty(billInfo.getBuyerAccount())) {
String bankNo = IdcardUtils.getBankNo(billInfo.getBuyerAccount());
if (StringUtils.isNotEmpty(bankNo)) {
String raw = billInfo.getBuyerAccount();
billInfo.setBuyerAccount(bankNo);
billInfo.setBuyerBank(raw.replace(bankNo, ""));
}
}*/
// 银行处理
if (StringUtils.isEmpty(billInfo.getBuyerBank()) && StringUtils.isNotEmpty(billInfo.getBuyerAccount())) {
Map<String, String> bank = IdcardUtils.getBankNoAndName(billInfo.getBuyerAccount());
billInfo.setBuyerAccount(bank.getOrDefault("bankNo", ""));
billInfo.setBuyerBank(bank.getOrDefault("bankName", ""));
}
// 处理销方信息
if (StringUtils.isEmpty(billInfo.getSellerBank()) && StringUtils.isNotEmpty(billInfo.getSellerAccount())) {
@ -193,7 +209,7 @@ public class AisinoInvoiceRequestAdapterImpl implements IInvoiceRequestService {
json = (JSONObject) JSONObject.toJSON(billInfo);
}
if (StringUtils.equals(serviceKey, "addBatch") ) {
if (StringUtils.equals(serviceKey, "addBatch")) {
JSONArray billInfoList = JSONUtil.parseArray(json.get("billInfo"));
JSONArray billInfoResult = new JSONArray();
for (Object billInfoTemp : billInfoList) {
@ -203,16 +219,22 @@ public class AisinoInvoiceRequestAdapterImpl implements IInvoiceRequestService {
HxBillInfoDTO hxBillInfo = orderJsonTemp.toJavaObject(HxBillInfoDTO.class);
BillInfo billInfo = new BillInfo();
BeanUtils.copyProperties(hxBillInfo, billInfo);
if(StringUtils.isNotEmpty(hxBillInfo.getEmail())){
if (StringUtils.isNotEmpty(hxBillInfo.getEmail())) {
billInfo.setBuyerEmail(hxBillInfo.getEmail());
}
if (StringUtils.isEmpty(billInfo.getBuyerBank()) && StringUtils.isNotEmpty(billInfo.getBuyerAccount())) {
/*if (StringUtils.isEmpty(billInfo.getBuyerBank()) && StringUtils.isNotEmpty(billInfo.getBuyerAccount())) {
String bankNo = IdcardUtils.getBankNo(billInfo.getBuyerAccount());
if (StringUtils.isNotEmpty(bankNo)) {
String raw = billInfo.getBuyerAccount();
billInfo.setBuyerAccount(bankNo);
billInfo.setBuyerBank(raw.replace(bankNo, ""));
}
}*/
// 银行处理
if (StringUtils.isEmpty(billInfo.getBuyerBank()) && StringUtils.isNotEmpty(billInfo.getBuyerAccount())) {
Map<String, String> bank = IdcardUtils.getBankNoAndName(billInfo.getBuyerAccount());
billInfo.setBuyerAccount(bank.getOrDefault("bankNo", ""));
billInfo.setBuyerBank(bank.getOrDefault("bankName", ""));
}
// 处理detail
List<HxBillDetailDTO> hxBillDetailList = hxBillInfo.getDetail();
@ -226,13 +248,19 @@ public class AisinoInvoiceRequestAdapterImpl implements IInvoiceRequestService {
billInfo.setBillDetailList(detailList);
}
if (StringUtils.isEmpty(billInfo.getBuyerBank()) && StringUtils.isNotEmpty(billInfo.getBuyerAccount())) {
/*if (StringUtils.isEmpty(billInfo.getBuyerBank()) && StringUtils.isNotEmpty(billInfo.getBuyerAccount())) {
String bankNo = IdcardUtils.getBankNo(billInfo.getBuyerAccount());
if (StringUtils.isNotEmpty(bankNo)) {
String raw = billInfo.getBuyerAccount();
billInfo.setBuyerAccount(bankNo);
billInfo.setBuyerBank(raw.replace(bankNo, ""));
}
}*/
// 银行处理
if (StringUtils.isEmpty(billInfo.getBuyerBank()) && StringUtils.isNotEmpty(billInfo.getBuyerAccount())) {
Map<String, String> bank = IdcardUtils.getBankNoAndName(billInfo.getBuyerAccount());
billInfo.setBuyerAccount(bank.getOrDefault("bankNo", ""));
billInfo.setBuyerBank(bank.getOrDefault("bankName", ""));
}
// 处理销方信息
if (StringUtils.isEmpty(billInfo.getSellerBank()) && StringUtils.isNotEmpty(billInfo.getSellerAccount())) {
@ -249,7 +277,7 @@ public class AisinoInvoiceRequestAdapterImpl implements IInvoiceRequestService {
}
// 清除数据,重新组装
json.clear();
json.put("billInfo",billInfoResult);
json.put("billInfo", billInfoResult);
}
@ -265,7 +293,7 @@ public class AisinoInvoiceRequestAdapterImpl implements IInvoiceRequestService {
List<HxRedInfoDetailsDTO> hxBillDetailList = hxBillInfo.getRedinfodetailList();
List<Redinfodetail> detailList = new ArrayList<>();
if(CollectionUtil.isNotEmpty(hxBillDetailList)){
if (CollectionUtil.isNotEmpty(hxBillDetailList)) {
for (int i = 0; i < hxBillDetailList.size(); i++) {
HxRedInfoDetailsDTO detial = hxBillDetailList.get(i);
Redinfodetail temp = new Redinfodetail();
@ -313,10 +341,10 @@ public class AisinoInvoiceRequestAdapterImpl implements IInvoiceRequestService {
}
@Override
public JSONObject decryptZq(String identity,String order, Companyservice companyservice, String serviceKey) {
public JSONObject decryptZq(String identity, String order, Companyservice companyservice, String serviceKey) {
log.info("【航信转invoice请求适配器】客户请求报文原始数据:{},销方id:{},serviceKey:{},identity={}", order, companyservice.getCompanyid(), serviceKey,identity);
log.info("【航信转invoice请求适配器】客户请求报文原始数据:{},销方id:{},serviceKey:{},identity={}", order, companyservice.getCompanyid(), serviceKey, identity);
// 开始解析报文
if (order == null || "".equals(order.trim())) {
@ -356,7 +384,7 @@ public class AisinoInvoiceRequestAdapterImpl implements IInvoiceRequestService {
json = orderJson;
// 红字查询
if (StringUtils.equals(serviceKey,"find_redinfo")){
if (StringUtils.equals(serviceKey, "find_redinfo")) {
return json;
}
// 如果是开票或者查询
@ -365,16 +393,22 @@ public class AisinoInvoiceRequestAdapterImpl implements IInvoiceRequestService {
HxBillInfoDTO hxBillInfo = json.toJavaObject(HxBillInfoDTO.class);
BillInfo billInfo = new BillInfo();
BeanUtils.copyProperties(hxBillInfo, billInfo);
if(StringUtils.isNotEmpty(hxBillInfo.getEmail())){
if (StringUtils.isNotEmpty(hxBillInfo.getEmail())) {
billInfo.setBuyerEmail(hxBillInfo.getEmail());
}
if (StringUtils.isEmpty(billInfo.getBuyerBank()) && StringUtils.isNotEmpty(billInfo.getBuyerAccount())) {
/*if (StringUtils.isEmpty(billInfo.getBuyerBank()) && StringUtils.isNotEmpty(billInfo.getBuyerAccount())) {
String bankNo = IdcardUtils.getBankNo(billInfo.getBuyerAccount());
if (StringUtils.isNotEmpty(bankNo)) {
String raw = billInfo.getBuyerAccount();
billInfo.setBuyerAccount(bankNo);
billInfo.setBuyerBank(raw.replace(bankNo, ""));
}
}*/
// 银行处理
if (StringUtils.isEmpty(billInfo.getBuyerBank()) && StringUtils.isNotEmpty(billInfo.getBuyerAccount())) {
Map<String, String> bank = IdcardUtils.getBankNoAndName(billInfo.getBuyerAccount());
billInfo.setBuyerAccount(bank.getOrDefault("bankNo", ""));
billInfo.setBuyerBank(bank.getOrDefault("bankName", ""));
}
// 处理detail
List<HxBillDetailDTO> hxBillDetailList = hxBillInfo.getDetail();
@ -388,13 +422,19 @@ public class AisinoInvoiceRequestAdapterImpl implements IInvoiceRequestService {
billInfo.setBillDetailList(detailList);
}
if (StringUtils.isEmpty(billInfo.getBuyerBank()) && StringUtils.isNotEmpty(billInfo.getBuyerAccount())) {
/*if (StringUtils.isEmpty(billInfo.getBuyerBank()) && StringUtils.isNotEmpty(billInfo.getBuyerAccount())) {
String bankNo = IdcardUtils.getBankNo(billInfo.getBuyerAccount());
if (StringUtils.isNotEmpty(bankNo)) {
String raw = billInfo.getBuyerAccount();
billInfo.setBuyerAccount(bankNo);
billInfo.setBuyerBank(raw.replace(bankNo, ""));
}
}*/
// 银行处理
if (StringUtils.isEmpty(billInfo.getBuyerBank()) && StringUtils.isNotEmpty(billInfo.getBuyerAccount())) {
Map<String, String> bank = IdcardUtils.getBankNoAndName(billInfo.getBuyerAccount());
billInfo.setBuyerAccount(bank.getOrDefault("bankNo", ""));
billInfo.setBuyerBank(bank.getOrDefault("bankName", ""));
}
// 处理销方信息
if (StringUtils.isEmpty(billInfo.getSellerBank()) && StringUtils.isNotEmpty(billInfo.getSellerAccount())) {
@ -409,7 +449,7 @@ public class AisinoInvoiceRequestAdapterImpl implements IInvoiceRequestService {
json = (JSONObject) JSONObject.toJSON(billInfo);
}
if (StringUtils.equals(serviceKey, "addBatch") ) {
if (StringUtils.equals(serviceKey, "addBatch")) {
JSONArray billInfoList = JSONUtil.parseArray(json.get("billInfo"));
//开票条数限制
@ -425,16 +465,22 @@ public class AisinoInvoiceRequestAdapterImpl implements IInvoiceRequestService {
HxBillInfoDTO hxBillInfo = orderJsonTemp.toJavaObject(HxBillInfoDTO.class);
BillInfo billInfo = new BillInfo();
BeanUtils.copyProperties(hxBillInfo, billInfo);
if(StringUtils.isNotEmpty(hxBillInfo.getEmail())){
if (StringUtils.isNotEmpty(hxBillInfo.getEmail())) {
billInfo.setBuyerEmail(hxBillInfo.getEmail());
}
if (StringUtils.isEmpty(billInfo.getBuyerBank()) && StringUtils.isNotEmpty(billInfo.getBuyerAccount())) {
/*if (StringUtils.isEmpty(billInfo.getBuyerBank()) && StringUtils.isNotEmpty(billInfo.getBuyerAccount())) {
String bankNo = IdcardUtils.getBankNo(billInfo.getBuyerAccount());
if (StringUtils.isNotEmpty(bankNo)) {
String raw = billInfo.getBuyerAccount();
billInfo.setBuyerAccount(bankNo);
billInfo.setBuyerBank(raw.replace(bankNo, ""));
}
}*/
// 银行处理
if (StringUtils.isEmpty(billInfo.getBuyerBank()) && StringUtils.isNotEmpty(billInfo.getBuyerAccount())) {
Map<String, String> bank = IdcardUtils.getBankNoAndName(billInfo.getBuyerAccount());
billInfo.setBuyerAccount(bank.getOrDefault("bankNo", ""));
billInfo.setBuyerBank(bank.getOrDefault("bankName", ""));
}
// 处理detail
List<HxBillDetailDTO> hxBillDetailList = hxBillInfo.getDetail();
@ -448,13 +494,19 @@ public class AisinoInvoiceRequestAdapterImpl implements IInvoiceRequestService {
billInfo.setBillDetailList(detailList);
}
if (StringUtils.isEmpty(billInfo.getBuyerBank()) && StringUtils.isNotEmpty(billInfo.getBuyerAccount())) {
/*if (StringUtils.isEmpty(billInfo.getBuyerBank()) && StringUtils.isNotEmpty(billInfo.getBuyerAccount())) {
String bankNo = IdcardUtils.getBankNo(billInfo.getBuyerAccount());
if (StringUtils.isNotEmpty(bankNo)) {
String raw = billInfo.getBuyerAccount();
billInfo.setBuyerAccount(bankNo);
billInfo.setBuyerBank(raw.replace(bankNo, ""));
}
}*/
// 银行处理
if (StringUtils.isEmpty(billInfo.getBuyerBank()) && StringUtils.isNotEmpty(billInfo.getBuyerAccount())) {
Map<String, String> bank = IdcardUtils.getBankNoAndName(billInfo.getBuyerAccount());
billInfo.setBuyerAccount(bank.getOrDefault("bankNo", ""));
billInfo.setBuyerBank(bank.getOrDefault("bankName", ""));
}
// 处理销方信息
if (StringUtils.isEmpty(billInfo.getSellerBank()) && StringUtils.isNotEmpty(billInfo.getSellerAccount())) {
@ -471,7 +523,7 @@ public class AisinoInvoiceRequestAdapterImpl implements IInvoiceRequestService {
}
// 清除数据,重新组装
json.clear();
json.put("billInfo",billInfoResult);
json.put("billInfo", billInfoResult);
}
@ -487,7 +539,7 @@ public class AisinoInvoiceRequestAdapterImpl implements IInvoiceRequestService {
List<HxRedInfoDetailsDTO> hxBillDetailList = hxBillInfo.getRedinfodetailList();
List<Redinfodetail> detailList = new ArrayList<>();
if(CollectionUtil.isNotEmpty(hxBillDetailList)){
if (CollectionUtil.isNotEmpty(hxBillDetailList)) {
for (int i = 0; i < hxBillDetailList.size(); i++) {
HxRedInfoDetailsDTO detial = hxBillDetailList.get(i);
Redinfodetail temp = new Redinfodetail();
@ -535,7 +587,6 @@ public class AisinoInvoiceRequestAdapterImpl implements IInvoiceRequestService {
}
@Override
public String covertMethodName(String method) {
return null;

@ -71,13 +71,19 @@ public class Nuonuo2InvoiceRequestAdapterImpl implements IInvoiceRequestService
BeanUtils.copyProperties(nuonuo2BillInfoDTO, billInfo);
// 处理BillInfo字段
billInfo.setCompanyId(companyservice.getCompanyid());
if (StringUtils.isEmpty(billInfo.getBuyerBank()) && StringUtils.isNotEmpty(billInfo.getBuyerAccount())) {
/*if (StringUtils.isEmpty(billInfo.getBuyerBank()) && StringUtils.isNotEmpty(billInfo.getBuyerAccount())) {
String bankNo = IdcardUtils.getBankNo(billInfo.getBuyerAccount());
if (StringUtils.isNotEmpty(bankNo)) {
String raw = billInfo.getBuyerAccount();
billInfo.setBuyerAccount(bankNo);
billInfo.setBuyerBank(raw.replace(bankNo, ""));
}
}*/
// 银行处理
if (StringUtils.isEmpty(billInfo.getBuyerBank()) && StringUtils.isNotEmpty(billInfo.getBuyerAccount())) {
Map<String, String> bank = IdcardUtils.getBankNoAndName(billInfo.getBuyerAccount());
billInfo.setBuyerAccount(bank.getOrDefault("bankNo", ""));
billInfo.setBuyerBank(bank.getOrDefault("bankName", ""));
}
// 处理销方信息
if (StringUtils.isEmpty(billInfo.getSellerBank()) && StringUtils.isNotEmpty(billInfo.getSellerAccount())) {

Loading…
Cancel
Save