|
|
@ -106,7 +106,7 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private TdxPlatformCheckLogService platformCheckLogService; |
|
|
|
private TdxPlatformCheckLogService platformCheckLogService; |
|
|
|
|
|
|
|
|
|
|
|
public String pushCheckResultToSAP(String requestParam) throws Exception { |
|
|
|
public String pushCheckResultToSAP(String requestParam) { |
|
|
|
log.info("获取请求参数:{} , 请求地址:{}", requestParam, snYxUrl); |
|
|
|
log.info("获取请求参数:{} , 请求地址:{}", requestParam, snYxUrl); |
|
|
|
String post = HttpUtils.sendPo(snYxUrl, requestParam, userName, password); |
|
|
|
String post = HttpUtils.sendPo(snYxUrl, requestParam, userName, password); |
|
|
|
log.info("获取返回信息:{}", post); |
|
|
|
log.info("获取返回信息:{}", post); |
|
|
@ -114,7 +114,7 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
return post; |
|
|
|
return post; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String pushInvoiceToRecordInvoice(SNInvoice snInvoice, String taxNo, String company, String imageId, String compCode) throws Exception { |
|
|
|
public String pushInvoiceToRecordInvoice(SNInvoice snInvoice, String taxNo, String company, String imageId, String compCode) { |
|
|
|
|
|
|
|
|
|
|
|
TDxInvoiceReimburse recordInvoice = new TDxInvoiceReimburse(); |
|
|
|
TDxInvoiceReimburse recordInvoice = new TDxInvoiceReimburse(); |
|
|
|
// DynamicContextHolder.push(DbConstant.BASICS_READ);
|
|
|
|
// DynamicContextHolder.push(DbConstant.BASICS_READ);
|
|
|
@ -733,7 +733,7 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
log.error("补充查验失败,errormsg:{}", e.getMessage()); |
|
|
|
log.error("补充查验失败,errormsg:{}", e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!checkInvoiceResult.containsKey("code")) { |
|
|
|
if (checkInvoiceResult != null && !checkInvoiceResult.containsKey("code")) { |
|
|
|
if (!checkInvoiceResult.containsKey("cyjg")) { |
|
|
|
if (!checkInvoiceResult.containsKey("cyjg")) { |
|
|
|
checkInvoiceResult.put("invoiceNo", checkInvoiceResult.getString("invoiceNumber")); |
|
|
|
checkInvoiceResult.put("invoiceNo", checkInvoiceResult.getString("invoiceNumber")); |
|
|
|
log.info("补充查验的结果为:{}", checkInvoiceResult); |
|
|
|
log.info("补充查验的结果为:{}", checkInvoiceResult); |
|
|
@ -1018,8 +1018,7 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
* @throws ParseException |
|
|
|
* @throws ParseException |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public ServiceResult<InvoiceInfo> valoremTaxCount(InvoiceInfo invoiceInfo, String isDeductible) |
|
|
|
public ServiceResult<InvoiceInfo> valoremTaxCount(InvoiceInfo invoiceInfo, String isDeductible) { |
|
|
|
throws ParseException { |
|
|
|
|
|
|
|
if (isDeductible == null || StringUtils.isEmpty(isDeductible)) { |
|
|
|
if (isDeductible == null || StringUtils.isEmpty(isDeductible)) { |
|
|
|
logger.error("客票价税计算失败:费用类别或可抵扣标识为空"); |
|
|
|
logger.error("客票价税计算失败:费用类别或可抵扣标识为空"); |
|
|
|
return fail("费用类别或可抵扣标识为空"); |
|
|
|
return fail("费用类别或可抵扣标识为空"); |
|
|
@ -1126,148 +1125,6 @@ public class SNPushCheckRecordService extends AbstractServiceAdapter { |
|
|
|
return typeList; |
|
|
|
return typeList; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @param invoiceInfo |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
* @throws ParseException |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private ServiceResult<?> checkIsDeduction(InvoiceInfo invoiceInfo) throws ParseException { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
String result = verifyInfo(invoiceInfo); |
|
|
|
|
|
|
|
if (!CommonEnum.RESPONSE_INTERFACE_STATUS_CODE_SUCCESS.equals(result)) { |
|
|
|
|
|
|
|
return fail(result); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (Constant.VALUE_ADDED_TAX_INVOICE_ELECTRONIC_CODE.equals(invoiceInfo.getInvoiceTypeCode()) |
|
|
|
|
|
|
|
|| Constant.VALUE_ADDED_TAX_INVOICE_ELECTRONIC_PASSENGER_CODE |
|
|
|
|
|
|
|
.equals(invoiceInfo.getInvoiceTypeCode())) { |
|
|
|
|
|
|
|
if (invoiceInfo.getDetailList() != null) { |
|
|
|
|
|
|
|
if (invoiceInfo.getDetailList() == null || invoiceInfo.getDetailList().isEmpty()) { |
|
|
|
|
|
|
|
return fail("发票明细不可为空"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 校验增值税电子普通发票
|
|
|
|
|
|
|
|
String invoiceTypeCode = invoiceInfo.getInvoiceTypeCode(); |
|
|
|
|
|
|
|
if (invoiceTypeCode.equals(Constant.VALUE_ADDED_TAX_INVOICE_ELECTRONIC_CODE) |
|
|
|
|
|
|
|
|| invoiceTypeCode.equals(Constant.VALUE_ADDED_TAX_INVOICE_ELECTRONIC_PASSENGER_CODE)) { |
|
|
|
|
|
|
|
List<InvoiceDetail> details = invoiceInfo.getDetailList(); |
|
|
|
|
|
|
|
if (details != null && details.size() > 0) { |
|
|
|
|
|
|
|
for (int i = 0, length = details.size(); i < length; i++) { |
|
|
|
|
|
|
|
if (!isRightRule(details.get(i).getGoodsName(), details.get(i).getTaxRate())) { |
|
|
|
|
|
|
|
return fail("发票底账明细中第" + i + 1 + "条名称或税率不正确"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(details.get(i).getTaxRate())) { |
|
|
|
|
|
|
|
if (details.get(i).getTaxRate().contains("%")) { |
|
|
|
|
|
|
|
invoiceInfo.setTaxRate(details.get(i).getTaxRate()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
invoiceInfo.setTaxRate(details.get(i).getTaxRate() + "%"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
return fail("未获取到发票明细"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// // 校验公路、水路、其他运输客票(实名),航空客运电子客票行程单,火车票
|
|
|
|
|
|
|
|
// if (invoiceInfo.getInvoiceTypeCode().equals(Constant.ROAD_TRANSPORT_TICKET_REAL_NAME_CODE)
|
|
|
|
|
|
|
|
// || invoiceInfo.getInvoiceTypeCode().equals(Constant.WATER_TRANSPORT_TICKET_REAL_NAME_CODE)
|
|
|
|
|
|
|
|
// || invoiceInfo.getInvoiceTypeCode().equals(Constant.OTHER_TRANSPORT_TICKET_REAL_NAME_CODE)
|
|
|
|
|
|
|
|
// || invoiceInfo.getInvoiceTypeCode().equals(Constant.AIR_PASSENGER_ELECTRONIC_TICKET_ITINERARY_CODE)
|
|
|
|
|
|
|
|
// || invoiceInfo.getInvoiceTypeCode().equals(Constant.RAILWAY_TICKET_CODE)) {
|
|
|
|
|
|
|
|
// if (StringUtils.isEmpty(invoiceInfo.getIdentityNumber())
|
|
|
|
|
|
|
|
// || StringUtils.isEmpty(invoiceInfo.getPassenger())) {
|
|
|
|
|
|
|
|
// return fail("必填字段为空");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// int count = orgUserInfoDao.countUserByIdentityNumber(invoiceInfo.getIdentityNumber(),
|
|
|
|
|
|
|
|
// invoiceInfo.getPassenger(), enterpriseId);
|
|
|
|
|
|
|
|
// if (count == 0) {
|
|
|
|
|
|
|
|
// return fail("未查询到用户信息");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (count > 1) {
|
|
|
|
|
|
|
|
// return fail("查询到多个用户");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
return ok(); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
logger.error("校验客运发票是否可抵扣异常:" + e.toString()); |
|
|
|
|
|
|
|
return fail("客运发票是否可抵扣校验失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String verifyInfo(InvoiceInfo invoiceInfo) { |
|
|
|
|
|
|
|
String result = "0000"; |
|
|
|
|
|
|
|
if (invoiceInfo == null) { |
|
|
|
|
|
|
|
result = "发票信息不可为空"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(invoiceInfo.getInvoiceTypeCode())) { |
|
|
|
|
|
|
|
result = "发票类型不可为空"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(invoiceInfo.getInvoiceDate().toString())) { |
|
|
|
|
|
|
|
result = "开票日期不可为空"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!CommonEnum.INV_ZZS_ELE_PP.equals(invoiceInfo.getInvoiceTypeCode()) && !CommonEnum.INV_ZZS_ELE_TXF.equals(invoiceInfo.getInvoiceTypeCode())) { |
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(invoiceInfo.getIdentityNumber())) { |
|
|
|
|
|
|
|
result = "用户证件号不可为空"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(invoiceInfo.getPassenger())) { |
|
|
|
|
|
|
|
result = "乘车人不可为空"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(invoiceInfo.getDepartCity())) { |
|
|
|
|
|
|
|
result = "出发城市不可为空"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(invoiceInfo.getArriveCity())) { |
|
|
|
|
|
|
|
result = "到达城市不可为空"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (invoiceInfo.getInvoiceDate() |
|
|
|
|
|
|
|
.compareTo(DateUtil.parse("2019-04-01", DatePattern.NORM_DATE_PATTERN)) < 0) { |
|
|
|
|
|
|
|
result = "开票日期需要晚于2019年4月1日"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DynamicContextHolder.push(DbConstant.BASICS_READ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!invoiceInfo.getInvoiceTypeCode().equals(Constant.VALUE_ADDED_TAX_INVOICE_ELECTRONIC_CODE) |
|
|
|
|
|
|
|
&& !invoiceInfo.getInvoiceTypeCode() |
|
|
|
|
|
|
|
.equals(Constant.VALUE_ADDED_TAX_INVOICE_ELECTRONIC_PASSENGER_CODE)) { |
|
|
|
|
|
|
|
// 港澳台城市
|
|
|
|
|
|
|
|
List<String> hmtList = new ArrayList<>(); |
|
|
|
|
|
|
|
// 香港
|
|
|
|
|
|
|
|
hmtList.add("香港特别行政区"); |
|
|
|
|
|
|
|
hmtList.add("香港"); |
|
|
|
|
|
|
|
// 澳门
|
|
|
|
|
|
|
|
hmtList.add("澳门特别行政区"); |
|
|
|
|
|
|
|
hmtList.add("澳门"); |
|
|
|
|
|
|
|
// 台湾
|
|
|
|
|
|
|
|
hmtList.add("台湾省"); |
|
|
|
|
|
|
|
hmtList.add("台湾"); |
|
|
|
|
|
|
|
// 出发地和到达地是否为非港澳台城市
|
|
|
|
|
|
|
|
List<Area> departCities = areaDao.queryAreaByName(invoiceInfo.getDepartCity()); |
|
|
|
|
|
|
|
List<Area> arriveCities = areaDao.queryAreaByName(invoiceInfo.getArriveCity()); |
|
|
|
|
|
|
|
boolean invHmtListExisted = (StringUtils.isNotEmpty(invoiceInfo.getDepartCity()) |
|
|
|
|
|
|
|
&& hmtList.contains(invoiceInfo.getDepartCity())) |
|
|
|
|
|
|
|
|| (StringUtils.isNotEmpty(invoiceInfo.getArriveCity()) |
|
|
|
|
|
|
|
&& hmtList.contains(invoiceInfo.getArriveCity())); |
|
|
|
|
|
|
|
if (departCities == null || departCities.isEmpty() || arriveCities == null || arriveCities.isEmpty()) { |
|
|
|
|
|
|
|
result = "出发或到达城市不符合标准"; |
|
|
|
|
|
|
|
} else if (invHmtListExisted) { |
|
|
|
|
|
|
|
result = "出发或到达城市不符合标准"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 增值税电子普通发票验证逻辑 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param goodsName |
|
|
|
|
|
|
|
* @param rate |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private Boolean isRightRule(String goodsName, String rate) { |
|
|
|
|
|
|
|
return (goodsName.contains("*运输服务*")) && (rate.contains("3") || rate.contains("9")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static boolean isBigDecimal(String str) { |
|
|
|
public static boolean isBigDecimal(String str) { |
|
|
|
if (str == null || str.trim().length() == 0) { |
|
|
|
if (str == null || str.trim().length() == 0) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|