|
|
|
@ -1,6 +1,7 @@ |
|
|
|
|
package com.jianshui.invoice.service.impl.api; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
@ -159,7 +160,7 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("【金四服务类】【金财数科】【蓝字发票开具】API请求异常,外部报文返回code非0000。错误信息:{}", e.getMessage()); |
|
|
|
|
return new HXResponse(ErrorCode.INCOME_ERROR.toString()); |
|
|
|
|
return new HXResponse("蓝字发票开具异常"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -205,7 +206,193 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public HXResponse queryInvoice(QueryBillInfoDTO billInfo, Companyservice companyservice) {return null;} |
|
|
|
|
public HXResponse queryInvoice(QueryBillInfoDTO billInfo, Companyservice companyservice) { |
|
|
|
|
|
|
|
|
|
// TODO: 2023/3/28 查询存库Invoice表
|
|
|
|
|
|
|
|
|
|
String systemOrderNo = billInfo.getSystemOrderno(); |
|
|
|
|
BillInfo billInfoResult = billInfoMapper.selectBySystemOrderNo(companyservice.getCompanyid(),systemOrderNo); |
|
|
|
|
|
|
|
|
|
QueryDTO queryDTO = BeanUtil.copyProperties(invoiceAllQueryDTO, QueryDTO.class); |
|
|
|
|
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)) { |
|
|
|
|
|
|
|
|
|
// 2022/12/13 这里所有的接口都走,需要根据具体的id判断接口来存库。
|
|
|
|
|
|
|
|
|
|
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)) { |
|
|
|
|
// 蓝字发票开具
|
|
|
|
|
AddInvoiceVO addInvoiceVO = BeanUtil.copyProperties(data, AddInvoiceVO.class); |
|
|
|
|
|
|
|
|
|
if(BeanUtil.isNotEmpty(addInvoiceVO)){ |
|
|
|
|
QueryWrapper<BillInfo> billInfoQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
billInfoQueryWrapper.eq("out_trade_orderno", requestId); |
|
|
|
|
BillInfo billInfo = billInfoMapper.selectOne(billInfoQueryWrapper); |
|
|
|
|
if (BeanUtil.isNotEmpty(billInfo)) { |
|
|
|
|
QueryWrapper<Invoice> invoiceQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
invoiceQueryWrapper.eq("out_trade_orderno", requestId); |
|
|
|
|
Invoice invoice = invoiceMapper.selectOne(invoiceQueryWrapper); |
|
|
|
|
if (BeanUtil.isNotEmpty(invoice)) { |
|
|
|
|
invoice = BeanUtil.copyProperties(billInfo, 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); |
|
|
|
|
billInfo.setState(2); |
|
|
|
|
billInfoMapper.updateById(billInfo); |
|
|
|
|
} else { |
|
|
|
|
invoice = BeanUtil.copyProperties(billInfo, 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); |
|
|
|
|
billInfo.setState(2); |
|
|
|
|
billInfoMapper.updateById(billInfo); |
|
|
|
|
} |
|
|
|
|
// 返回数据
|
|
|
|
|
response.put("data", invoice); |
|
|
|
|
} else { |
|
|
|
|
log.error("【金四服务类】【金财数科】【通用查询接口】API请求异常,billInfo未查询到,requestId={}。", requestId); |
|
|
|
|
// return AjaxResult.error(ErrorCode.INCOME_ERROR);
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} /*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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
/*else if (WebServiceConstant.ADD_RED_INVOICE.equals(finalServiceId)) { |
|
|
|
|
// 查找原发票信息
|
|
|
|
|
AddRedInvoiceVO addRedInvoiceVO = BeanUtil.copyProperties(data, AddRedInvoiceVO.class); |
|
|
|
|
QueryWrapper<BillInfo> billInfoQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
billInfoQueryWrapper.eq("fpqqlsh", requestId); |
|
|
|
|
BillInfo billInfo = billInfoMapper.selectOne(billInfoQueryWrapper); |
|
|
|
|
if (billInfo != null) { |
|
|
|
|
// return AjaxResult.error("未查询到原发票信息");
|
|
|
|
|
// 根据billInfo获得原发票号码
|
|
|
|
|
QueryWrapper<BillInfo> originBillInfoWrapper = new QueryWrapper<>(); |
|
|
|
|
originBillInfoWrapper.eq("origin_fphm", billInfo.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(billInfo.getId()); |
|
|
|
|
invoice.setSystemOrderno(billInfo.getSystemOrderno()); |
|
|
|
|
invoice.setOutTradeOrderno(billInfo.getOutTradeOrderno()); |
|
|
|
|
invoice.setFpqqlsh(billInfo.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); |
|
|
|
|
billInfo.setState(2); |
|
|
|
|
billInfoMapper.updateById(billInfo); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
response.put("data", JSONUtil.parseObj(data)); |
|
|
|
|
|
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
/*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)) { |
|
|
|
|
// 查询红字信息表
|
|
|
|
|
// TODO: 后期存库
|
|
|
|
|
}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("通用查询接口异常"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 发票批量查询 |
|
|
|
|