|
|
|
@ -1318,6 +1318,225 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 通用查询接口 |
|
|
|
|
* @param invoiceAllYhdjDTO |
|
|
|
|
* @param companyservice |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public HXResponse queryResultInfo(InvoiceAllQueryTWODTO invoiceAllYhdjDTO, Companyservice companyservice) { |
|
|
|
|
|
|
|
|
|
// requestId => systemorderid
|
|
|
|
|
String systemOrderNo = invoiceAllYhdjDTO.getRequestId(); |
|
|
|
|
|
|
|
|
|
BillInfo billInfoResult = billInfoMapper.selectBySystemOrderNo(companyservice.getCompanyid(), systemOrderNo); |
|
|
|
|
|
|
|
|
|
// requestId=OutTradeOrderno
|
|
|
|
|
if (StrUtil.isEmpty(billInfoResult.getOutTradeOrderno())) { |
|
|
|
|
return new HXResponse("未获取到开票记录!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 查询用户登记参数
|
|
|
|
|
QueryWrapper<InvoiceAllYhdj> yhdjQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
yhdjQueryWrapper.eq("nsrsbh", companyservice.getSellertax()); |
|
|
|
|
yhdjQueryWrapper.eq("identity", companyservice.getIdentity()); |
|
|
|
|
InvoiceAllYhdj invoiceAllYhdj = yhdjMapper.selectOne(yhdjQueryWrapper); |
|
|
|
|
|
|
|
|
|
if (BeanUtil.isEmpty(invoiceAllYhdj)) { |
|
|
|
|
return new HXResponse("用户未登记!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
QueryTwoDTO queryDTO = new QueryTwoDTO(); |
|
|
|
|
queryDTO.setDqbm(invoiceAllYhdj.getDqbm()); |
|
|
|
|
queryDTO.setAsync("false"); |
|
|
|
|
queryDTO.setBsrysfzjhm(invoiceAllYhdj.getBsrysfzjhm()); |
|
|
|
|
queryDTO.setNsrsbh(invoiceAllYhdj.getNsrsbh()); |
|
|
|
|
queryDTO.setServiceId("tycxjk"); |
|
|
|
|
queryDTO.setRequestId(billInfoResult.getOutTradeOrderno()); |
|
|
|
|
|
|
|
|
|
ValidateUtils.validate(queryDTO); |
|
|
|
|
|
|
|
|
|
String requestId = queryDTO.getRequestId(); |
|
|
|
|
String serviceId = ""; |
|
|
|
|
|
|
|
|
|
cn.hutool.json.JSONObject result = null; |
|
|
|
|
try { |
|
|
|
|
result = ApiHttp.request(WebServiceConstant.TYCXJK, WebServiceConstant.URL, queryDTO, companyservice); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String code = result.get("code") != null ? result.get("code").toString() : ""; |
|
|
|
|
String msg = result.get("msg") != null ? result.get("msg").toString() : ""; |
|
|
|
|
String data = result.get("data") != null ? result.get("data").toString() : ""; |
|
|
|
|
|
|
|
|
|
if ("0000".equals(code) && StrUtil.isNotEmpty(data)) { |
|
|
|
|
|
|
|
|
|
QueryWrapper<InvoiceAllApiLog> apiLogQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
apiLogQueryWrapper.eq("request_id", requestId); |
|
|
|
|
InvoiceAllApiLog allApiLog = allApiLogMapper.selectOne(apiLogQueryWrapper); |
|
|
|
|
if (BeanUtil.isNotEmpty(allApiLog) && StrUtil.isNotEmpty(allApiLog.getRequestId())) { |
|
|
|
|
serviceId = allApiLog.getRequestId(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
HXResponse response = new HXResponse("0000", "查询成功"); |
|
|
|
|
|
|
|
|
|
String finalServiceId = serviceId; |
|
|
|
|
|
|
|
|
|
if (WebServiceConstant.LZFPKJ.equals(finalServiceId)) { |
|
|
|
|
// 蓝字发票开具
|
|
|
|
|
AddInvoiceTWOVO addInvoiceVO = BeanUtil.copyProperties(data, AddInvoiceTWOVO.class); |
|
|
|
|
|
|
|
|
|
if (BeanUtil.isNotEmpty(addInvoiceVO)) { |
|
|
|
|
QueryWrapper<BillInfo> billInfoQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
billInfoQueryWrapper.eq("out_trade_orderno", requestId); |
|
|
|
|
BillInfo billInfoR = billInfoMapper.selectOne(billInfoQueryWrapper); |
|
|
|
|
if (BeanUtil.isNotEmpty(billInfoR)) { |
|
|
|
|
QueryWrapper<Invoice> invoiceQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
invoiceQueryWrapper.eq("out_trade_orderno", requestId); |
|
|
|
|
Invoice invoice = invoiceMapper.selectOne(invoiceQueryWrapper); |
|
|
|
|
if (BeanUtil.isNotEmpty(invoice)) { |
|
|
|
|
invoice = BeanUtil.copyProperties(billInfoResult, Invoice.class); |
|
|
|
|
invoice.setFphm(addInvoiceVO.getFphm()); |
|
|
|
|
invoice.setKprq(DateUtil.parse(addInvoiceVO.getKprq())); |
|
|
|
|
invoice.setZzfpdm(addInvoiceVO.getZzfpdm()); |
|
|
|
|
invoice.setZzfphm(addInvoiceVO.getZzfphm()); |
|
|
|
|
//二维码=二维码下载地址
|
|
|
|
|
invoice.setQrCode(addInvoiceVO.getEwmUrl()); |
|
|
|
|
//发票 pdf 地址=PDF格式下载地址
|
|
|
|
|
invoice.setInvoicePdfUrl(addInvoiceVO.getPdfUrl()); |
|
|
|
|
//发票详情地址=OFD格式下载地址
|
|
|
|
|
invoice.setInvoiceJpgUrl(addInvoiceVO.getOfdUrl()); |
|
|
|
|
//ofdUrl=XML格式下载地址
|
|
|
|
|
invoice.setcOfdUrl(addInvoiceVO.getXmlUrl()); |
|
|
|
|
invoice.setState(2); |
|
|
|
|
invoiceMapper.updateInvoice(invoice); |
|
|
|
|
billInfoR.setState(2); |
|
|
|
|
billInfoMapper.updateById(billInfoR); |
|
|
|
|
} else { |
|
|
|
|
invoice = BeanUtil.copyProperties(billInfoResult, Invoice.class); |
|
|
|
|
invoice.setFphm(addInvoiceVO.getFphm()); |
|
|
|
|
invoice.setKprq(DateUtil.parse(addInvoiceVO.getKprq())); |
|
|
|
|
invoice.setZzfpdm(addInvoiceVO.getZzfpdm()); |
|
|
|
|
invoice.setZzfphm(addInvoiceVO.getZzfphm()); |
|
|
|
|
//二维码=二维码下载地址
|
|
|
|
|
invoice.setQrCode(addInvoiceVO.getEwmUrl()); |
|
|
|
|
//发票 pdf 地址=PDF格式下载地址
|
|
|
|
|
invoice.setInvoicePdfUrl(addInvoiceVO.getPdfUrl()); |
|
|
|
|
//发票详情地址=OFD格式下载地址
|
|
|
|
|
invoice.setInvoiceJpgUrl(addInvoiceVO.getOfdUrl()); |
|
|
|
|
//ofdUrl=XML格式下载地址
|
|
|
|
|
invoice.setcOfdUrl(addInvoiceVO.getXmlUrl()); |
|
|
|
|
invoice.setState(2); |
|
|
|
|
invoiceMapper.insertInvoice(invoice); |
|
|
|
|
billInfoR.setState(2); |
|
|
|
|
billInfoMapper.updateById(billInfoR); |
|
|
|
|
} |
|
|
|
|
// 返回数据
|
|
|
|
|
response.put("data", invoice); |
|
|
|
|
} else { |
|
|
|
|
log.error("【金四服务类】【金财数科】【通用查询接口】API请求异常,billInfo未查询到,requestId={}。", requestId); |
|
|
|
|
return new HXResponse("查询错误!"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else if (WebServiceConstant.FPEWMXZ.equals(finalServiceId)) { |
|
|
|
|
// 获取发票下载地址
|
|
|
|
|
cn.hutool.json.JSONObject json = JSONUtil.parseObj(data); |
|
|
|
|
String ewmUrl = json.getOrDefault("ewmUrl", "").toString(); |
|
|
|
|
String pdfUrl = json.getOrDefault("pdfUrl", "").toString(); |
|
|
|
|
String ofdUrl = json.getOrDefault("ofdUrl", "").toString(); |
|
|
|
|
String xmlUrl = json.getOrDefault("xmlUrl", "").toString(); |
|
|
|
|
if (StrUtil.isNotEmpty(requestId)) { |
|
|
|
|
QueryWrapper<Invoice> invoiceQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
invoiceQueryWrapper.eq("out_trade_orderno", requestId); |
|
|
|
|
Invoice invoice = invoiceMapper.selectOne(invoiceQueryWrapper); |
|
|
|
|
if (BeanUtil.isNotEmpty(invoice)) { |
|
|
|
|
invoice.setInvoicePdfUrl(pdfUrl); |
|
|
|
|
invoice.setcOfdUrl(ofdUrl); |
|
|
|
|
invoiceMapper.updateInvoice(invoice); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// TODO: 2023/3/29 返回数据处理
|
|
|
|
|
} else if (WebServiceConstant.ADD_RED_INVOICE.equals(finalServiceId)) { |
|
|
|
|
// 查找原发票信息
|
|
|
|
|
AddRedInvoiceTWOVO addRedInvoiceVO = BeanUtil.copyProperties(data, AddRedInvoiceTWOVO.class); |
|
|
|
|
QueryWrapper<BillInfo> billInfoQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
billInfoQueryWrapper.eq("fpqqlsh", requestId); |
|
|
|
|
BillInfo billInfoR = billInfoMapper.selectOne(billInfoQueryWrapper); |
|
|
|
|
if (billInfoR != null) { |
|
|
|
|
// return AjaxResult.error("未查询到原发票信息");
|
|
|
|
|
// 根据billInfo获得原发票号码
|
|
|
|
|
QueryWrapper<BillInfo> originBillInfoWrapper = new QueryWrapper<>(); |
|
|
|
|
originBillInfoWrapper.eq("origin_fphm", billInfoR.getOriginFphm()); |
|
|
|
|
BillInfo originBillInfo = billInfoMapper.selectOne(originBillInfoWrapper); |
|
|
|
|
if (originBillInfo != null) { |
|
|
|
|
// return AjaxResult.error("未查询到原发票信息");
|
|
|
|
|
// 查找原发票信息
|
|
|
|
|
Invoice originInvoice = invoiceMapper.selectInvoiceByBillInfoId(originBillInfo.getId()); |
|
|
|
|
Invoice invoice = BeanUtil.copyProperties(originInvoice, Invoice.class); |
|
|
|
|
invoice.setFphm(addRedInvoiceVO.getFphm()); |
|
|
|
|
invoice.setBillInfoId(billInfoResult.getId()); |
|
|
|
|
invoice.setSystemOrderno(billInfoResult.getSystemOrderno()); |
|
|
|
|
invoice.setOutTradeOrderno(billInfoResult.getOutTradeOrderno()); |
|
|
|
|
invoice.setFpqqlsh(billInfoResult.getFpqqlsh()); |
|
|
|
|
invoice.setKprq(DateUtil.parse(addRedInvoiceVO.getKprq())); |
|
|
|
|
invoice.setZzfpdm(addRedInvoiceVO.getZzfpdm()); |
|
|
|
|
invoice.setZzfphm(addRedInvoiceVO.getZzfphm()); |
|
|
|
|
//二维码=二维码下载地址
|
|
|
|
|
invoice.setQrCode(addRedInvoiceVO.getEwmUrl()); |
|
|
|
|
//发票 pdf 地址=PDF格式下载地址
|
|
|
|
|
invoice.setInvoicePdfUrl(addRedInvoiceVO.getPdfUrl()); |
|
|
|
|
//发票详情地址=OFD格式下载地址
|
|
|
|
|
invoice.setInvoiceJpgUrl(addRedInvoiceVO.getOfdUrl()); |
|
|
|
|
//ofdUrl=XML格式下载地址
|
|
|
|
|
invoice.setcOfdUrl(addRedInvoiceVO.getXmlUrl()); |
|
|
|
|
invoice.setState(2); |
|
|
|
|
invoiceMapper.insertInvoice(invoice); |
|
|
|
|
billInfoR.setState(2); |
|
|
|
|
billInfoMapper.updateById(billInfoR); |
|
|
|
|
|
|
|
|
|
response.put("data", invoice); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
else if (WebServiceConstant.KSHC.equals(finalServiceId)) { |
|
|
|
|
// 快速冲红
|
|
|
|
|
// TODO: 后期存库
|
|
|
|
|
// KschVO kschVO = BeanUtil.copyProperties(data,KschVO.class);
|
|
|
|
|
// InvoiceAllKschVO invoiceAllKschVO = BeanUtil.copyProperties(kschVO,InvoiceAllKschVO.class);
|
|
|
|
|
|
|
|
|
|
}else if (WebServiceConstant.SQHZFPXXQRD.equals(finalServiceId)) { |
|
|
|
|
// 申请红字信息表
|
|
|
|
|
// TODO: 后期存库
|
|
|
|
|
}else if (WebServiceConstant.CXHZFPXXQRD.equals(finalServiceId)) { |
|
|
|
|
// 查询红字信息表
|
|
|
|
|
|
|
|
|
|
RedInvoiceQueryAllTWOVO redInvoiceQueryAllTWOVO = BeanUtil.copyProperties(data, RedInvoiceQueryAllTWOVO.class); |
|
|
|
|
// 返回报文转换
|
|
|
|
|
List<Redinfo> resultDownload = parseRedINFO(redInvoiceQueryAllTWOVO); |
|
|
|
|
// TODO: 2023/4/6 数据存储
|
|
|
|
|
response.put("data", resultDownload); |
|
|
|
|
}else if (WebServiceConstant.SHHZFPXXQRD.equals(finalServiceId)) { |
|
|
|
|
// 审核红字信息表
|
|
|
|
|
// TODO: 后期存库
|
|
|
|
|
}else if (WebServiceConstant.QDFPWJHQ.equals(finalServiceId)) { |
|
|
|
|
// 审核红字信息表
|
|
|
|
|
// TODO: 全电发票文件获取
|
|
|
|
|
} |
|
|
|
|
return response; |
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
return new HXResponse(msg); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
log.error("【金四服务类】【金财数科】【通用查询接口】API请求异常,外部报文返回code非0000。错误信息:{}", e.getMessage()); |
|
|
|
|
return new HXResponse("通用查询接口异常"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 简税和金财数科 发票类型互换 |
|
|
|
|
* |
|
|
|
|