中交建-销项合并测试:通用查询接口

beta-enc
dongxiaoke 2 years ago
parent ed695bed65
commit 2213fb2825
  1. 34
      jianshui-admin/src/main/java/com/jianshui/api/controller/http/invoice/v1/InvoiceController.java
  2. 1
      jianshui-invoice/src/main/java/com/jianshui/invoice/domain/dto/api/jcsk/QueryTwoDTO.java
  3. 9
      jianshui-invoice/src/main/java/com/jianshui/invoice/service/IInvoiceApiService.java
  4. 2
      jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/adapter/request/AisinoInvoiceRequestAdapterImpl.java
  5. 5
      jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/AisinoConsoleInvoiceApiServiceImpl.java
  6. 5
      jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiServiceImpl.java
  7. 219
      jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/JcskInvoiceApiServiceImpl.java
  8. 2
      jianshui-invoice/src/main/java/com/jianshui/invoice/utils/JcskTest.java
  9. 4
      jianshui-invoice/src/main/java/com/jianshui/invoice/utils/aisino/console/AisinoConsoleUtil.java

@ -866,6 +866,40 @@ public class InvoiceController {
// TODO: 2023/4/6 全电接口
// @ApiOperation("通用异步查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "identity", value = "身份认证", dataType = "string", example = "1130", required = true),
@ApiImplicitParam(name = "order", value = "请求体", required = true)})
@PostMapping({"/api/invoice/v2/queryResultInfo/{identity}", "/api/invoice/v2/queryResultInfo"})
public Object queryResultInfo(HttpServletRequest request, String identity) throws Exception {
if (StringUtils.isEmpty(identity)) {
return AjaxResult.error(ErrorCode.EMPTY_IDENTITY);
}
Companyservice companyservice = iCompanyserviceService.selectCompanyserviceByIdentity(identity);
if (companyservice == null) {
return AjaxResult.error(ErrorCode.COMPANY_NOT_FOUND);
}
// 获得入口报文适配器
String requestAdapterKey = serviceManageService.getRequestAdapterKey("invoice", companyservice.getCompanyid());
IInvoiceRequestService invoiceRequestService = invoiceRequestFactory.getService(requestAdapterKey);
JSONObject decryptResult = invoiceRequestService.decrypt(request, companyservice, "");
// 获得请求实例,并且进行扣费
String serviceKey = serviceManageService.getCompanyServiceSupplier("invoice", companyservice.getCompanyid());
serviceManageService.companyConsume("invoice", companyservice.getCompanyid());
InvoiceAllQueryTWODTO invoiceAllYhdjDTO = decryptResult.toJavaObject(InvoiceAllQueryTWODTO.class);
IInvoiceApiService invoiceService = invoiceServiceFactory.getService(serviceKey);
HXResponse result = invoiceService.queryResultInfo(invoiceAllYhdjDTO, companyservice);
String responseAdapterKey = serviceManageService.getResponseAdapterKey("invoice", companyservice.getCompanyid());
IInvoiceResponseService invoiceResponseService = invoiceResponseFactory.getService(responseAdapterKey);
return invoiceResponseService.response(result, companyservice, "");
}
// @ApiOperation("获取发票下载地址")
@ApiImplicitParams({

@ -13,7 +13,6 @@ import javax.validation.constraints.NotEmpty;
@Data
public class QueryTwoDTO {
@NotEmpty
@ApiModelProperty(value = "渠道标识")
private String appkey;

@ -262,4 +262,13 @@ public interface IInvoiceApiService {
* @return
*/
HXResponse queryRedInfoDetail(InvoiceAllRedInvoiceDetailTWODTO invoiceAllRedInvoiceDetailDTO, Companyservice companyservice);
/**
* 异步通用查询
* @param invoiceAllYhdjDTO
* @param companyservice
* @return
*/
HXResponse queryResultInfo(InvoiceAllQueryTWODTO invoiceAllYhdjDTO, Companyservice companyservice);
}

@ -102,7 +102,7 @@ public class AisinoInvoiceRequestAdapterImpl implements IInvoiceRequestService {
// 平台解密
try {
// TODO: 2023/4/23 调试屏蔽
// order = AisinoInvoiceDecryptUtil.decrypt(order, JKey);
order = AisinoInvoiceDecryptUtil.decrypt(order, JKey);
} catch (Exception e) {
e.printStackTrace();
throw new JianshuiParamErrorException(ErrorCode.DECRYPT_ERROR, companyservice, "invoice");

@ -976,5 +976,10 @@ public class AisinoConsoleInvoiceApiServiceImpl implements IInvoiceApiService {
return null;
}
@Override
public HXResponse queryResultInfo(InvoiceAllQueryTWODTO invoiceAllYhdjDTO, Companyservice companyservice) {
return null;
}
}

@ -1784,5 +1784,10 @@ public class ElephantInvoiceApiServiceImpl implements IInvoiceApiService {
return null;
}
@Override
public HXResponse queryResultInfo(InvoiceAllQueryTWODTO invoiceAllYhdjDTO, Companyservice companyservice) {
return null;
}
}

@ -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("通用查询接口异常");
}
}
/**
* 简税和金财数科 发票类型互换
*

@ -162,7 +162,7 @@ public class JcskTest {
" \"async\": false,\n" +
" \"bsrysfzjhm\":\"37028519930620441X\",\n" +
" \"nsrsbh\": \"92370214MACAAEK16E\",\n" +
" \"requestId\": \"133a4003-5039-4cb0-9282-2eca56523a73\",\n" +
" \"requestId\": \"bac8903e-25e5-491f-838e-cb5d0919b782\",\n" +
" \"serviceId\": \"tycxjk\"\n" +
"}";
System.out.println(order);

@ -113,8 +113,8 @@ public class AisinoConsoleUtil {
throw new JianshuiServiceException("未获取到企业信息,请联系管理员!");
}
//JSON明文BASE64加密,字符集GB2312,替换+为-
String param = Base64.encode(JSONUtil.toJsonStr(SIDParam),"GB2312").replace("+", "_");
//JSON明文BASE64加密,字符集GBK,替换+为-
String param = Base64.encode(JSONUtil.toJsonStr(SIDParam),"GBK").replace("+", "_");
//获取请求地址
List<CompanyserviceDetail> companyserviceDetailList = companyservice.getCompanyserviceDetailList();
if(CollectionUtils.isEmpty(companyserviceDetailList)){

Loading…
Cancel
Save