diff --git a/jianshui-admin/src/main/java/com/jianshui/api/controller/http/invoice/v1/InvoiceController.java b/jianshui-admin/src/main/java/com/jianshui/api/controller/http/invoice/v1/InvoiceController.java index 58a78fc..b3f12a2 100644 --- a/jianshui-admin/src/main/java/com/jianshui/api/controller/http/invoice/v1/InvoiceController.java +++ b/jianshui-admin/src/main/java/com/jianshui/api/controller/http/invoice/v1/InvoiceController.java @@ -399,7 +399,19 @@ public class InvoiceController { IInvoiceRequestService invoiceRequestService = invoiceRequestFactory.getService(requestAdapterKey); JSONObject decryptResult = invoiceRequestService.decrypt(request, companyservice, "download_redinfo"); - HXResponse result = preHandleDecryptResult(decryptResult, "download_redinfo", companyservice); + DownloadRedInfoDTO billInfo = decryptResult.toJavaObject(DownloadRedInfoDTO.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); + billInfo.setServiceKey(serviceKey); + HXResponse result = invoiceService.downloadRedInfo(billInfo, companyservice); + +// HXResponse result = preHandleDecryptResult(decryptResult, "download_redinfo", companyservice); String responseAdapterKey = serviceManageService.getResponseAdapterKey("invoice", companyservice.getCompanyid()); IInvoiceResponseService invoiceResponseService = invoiceResponseFactory.getService(responseAdapterKey); diff --git a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/JcskInvoiceApiServiceImpl.java b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/JcskInvoiceApiServiceImpl.java index 26e3759..793d18c 100644 --- a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/JcskInvoiceApiServiceImpl.java +++ b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/JcskInvoiceApiServiceImpl.java @@ -101,20 +101,16 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { String kpType = billInfo.getKptype(); // 查询用户登记参数 - QueryWrapper 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("用户未登记!"); + InvoiceAllYhdj yhdj = getUserInfo(companyservice); + if (BeanUtil.isEmpty(yhdj)) { + return new HXResponse("未查询到登记信息!"); } QueryTwoDTO queryDTO = new QueryTwoDTO(); - queryDTO.setDqbm(invoiceAllYhdj.getDqbm()); + queryDTO.setDqbm(yhdj.getDqbm()); queryDTO.setAsync("false"); - queryDTO.setBsrysfzjhm(invoiceAllYhdj.getBsrysfzjhm()); - queryDTO.setNsrsbh(invoiceAllYhdj.getNsrsbh()); + queryDTO.setBsrysfzjhm(yhdj.getBsrysfzjhm()); + queryDTO.setNsrsbh(yhdj.getNsrsbh()); queryDTO.setRequestId("tycxjk"); if ("1".equals(kpType)) { @@ -382,20 +378,16 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { // 金财数科数据处理 start // 查询用户登记参数 - QueryWrapper 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("用户未登记!"); + InvoiceAllYhdj yhdj = getUserInfo(companyservice); + if (BeanUtil.isEmpty(yhdj)) { + return new HXResponse("未查询到登记信息!"); } SqhzTwoDTO sqhzDTO = BeanUtil.copyProperties(redinfo, SqhzTwoDTO.class); sqhzDTO.setAsync("true"); - sqhzDTO.setBsrysfzjhm(invoiceAllYhdj.getBsrysfzjhm()); - sqhzDTO.setDqbm(invoiceAllYhdj.getDqbm()); - sqhzDTO.setNsrsbh(invoiceAllYhdj.getNsrsbh()); + sqhzDTO.setBsrysfzjhm(yhdj.getBsrysfzjhm()); + sqhzDTO.setDqbm(yhdj.getDqbm()); + sqhzDTO.setNsrsbh(yhdj.getNsrsbh()); ValidateUtils.validate(sqhzDTO); SqhzJsonDataTwoDTO sqhzJsonDataTwoDTO = BeanUtil.copyProperties(redinfo, SqhzJsonDataTwoDTO.class); @@ -519,23 +511,19 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { return response; } - // TODO: 组装进数科需要的报文。 待处理。 // 查询用户登记参数 - QueryWrapper 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("用户未登记!"); + InvoiceAllYhdj yhdj = getUserInfo(companyservice); + if (BeanUtil.isEmpty(yhdj)) { + return new HXResponse("未查询到登记信息!"); } // 这里直接用传入的报文进行转换 CxhzTwoDTO cxhzDTO = BeanUtil.copyProperties(downloadRedInfoDTO, CxhzTwoDTO.class); cxhzDTO.setAsync("true"); - cxhzDTO.setNsrsbh(invoiceAllYhdj.getNsrsbh()); - cxhzDTO.setDqbm(invoiceAllYhdj.getDqbm()); + cxhzDTO.setNsrsbh(yhdj.getNsrsbh()); + cxhzDTO.setDqbm(yhdj.getDqbm()); + cxhzDTO.setBsrysfzjhm(yhdj.getBsrysfzjhm()); CxhzJsonDataTwoDTO cxhzJsonDataDTO = BeanUtil.copyProperties(downloadRedInfoDTO, CxhzJsonDataTwoDTO.class); @@ -560,9 +548,6 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { return new HXResponse(msg); } - // TODO: 2023/4/3 数据库存储:根据业务调整 - - InvoiceAllApiLog allApiLog = new InvoiceAllApiLog(); allApiLog.setUrl(WebServiceConstant.CXHZFPXXQRD); allApiLog.setSendMsg(cxhzDTO.toString()); @@ -1243,20 +1228,16 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { String systemOrderNo = invoiceAllYhdjDTO.getRequestId(); // 查询用户登记参数 - QueryWrapper 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("用户未登记!"); + InvoiceAllYhdj yhdj = getUserInfo(companyservice); + if (BeanUtil.isEmpty(yhdj)) { + return new HXResponse("未查询到登记信息!"); } QueryTwoDTO queryDTO = new QueryTwoDTO(); - queryDTO.setDqbm(invoiceAllYhdj.getDqbm()); + queryDTO.setDqbm(yhdj.getDqbm()); queryDTO.setAsync("false"); - queryDTO.setBsrysfzjhm(invoiceAllYhdj.getBsrysfzjhm()); - queryDTO.setNsrsbh(invoiceAllYhdj.getNsrsbh()); + queryDTO.setBsrysfzjhm(yhdj.getBsrysfzjhm()); + queryDTO.setNsrsbh(yhdj.getNsrsbh()); queryDTO.setServiceId("tycxjk"); queryDTO.setRequestId(systemOrderNo);