|
|
|
@ -1742,6 +1742,72 @@ public class InvoiceController { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 批量: 开票请求接口-(蓝字发票开具,红字发票开具) |
|
|
|
|
* |
|
|
|
|
* @param request |
|
|
|
|
* @param identity |
|
|
|
|
* @return |
|
|
|
|
* @throws Exception |
|
|
|
|
*/ |
|
|
|
|
@Validated |
|
|
|
|
@ApiOperation("开票请求接口-(蓝字发票开具,红字发票开具)") |
|
|
|
|
@ApiImplicitParams({ |
|
|
|
|
@ApiImplicitParam(name = "identity", value = "身份认证", dataType = "java.lang.Void", example = "1130", required = true), |
|
|
|
|
@ApiImplicitParam(name = "order", value = "请求体", dataType = "java.lang.Void", required = true)}) |
|
|
|
|
@PostMapping({"/api/invoice/v1/addInvoiceBatch", "/api/invoice/v1/addInvoiceBatch/{identity}", "/invoice/addInvoiceBatch"}) |
|
|
|
|
public Object addInvoiceBatch(HttpServletRequest request, String identity) throws Exception { |
|
|
|
|
|
|
|
|
|
// TODO: 2023/11/2 批量开票接口
|
|
|
|
|
|
|
|
|
|
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, "add"); |
|
|
|
|
|
|
|
|
|
// 报文处理
|
|
|
|
|
BillInfo billInfo = decryptResult.toJavaObject(BillInfo.class); |
|
|
|
|
if (billInfo == null) { |
|
|
|
|
throw new JianshuiParamErrorException(ErrorCode.ERROR_PARAMS, companyservice, "invoice"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
billInfo.setSource("2"); |
|
|
|
|
// 获得请求实例,并且进行扣费
|
|
|
|
|
String serviceKey = serviceManageService.getCompanyServiceSupplier("invoice", companyservice.getCompanyid()); |
|
|
|
|
serviceManageService.companyConsume("invoice", companyservice.getCompanyid()); |
|
|
|
|
billInfo.setServiceSupplierKey(serviceKey); |
|
|
|
|
IInvoiceApiService invoiceService = invoiceServiceFactory.getService(serviceKey); |
|
|
|
|
HXResponse result = invoiceService.addInvoice(billInfo, companyservice); |
|
|
|
|
|
|
|
|
|
// HXResponse result = preHandleDecryptResult(decryptResult, "add", companyservice);
|
|
|
|
|
|
|
|
|
|
String responseAdapterKey = serviceManageService.getResponseAdapterKey("invoice", companyservice.getCompanyid()); |
|
|
|
|
IInvoiceResponseService invoiceResponseService = invoiceResponseFactory.getService(responseAdapterKey); |
|
|
|
|
|
|
|
|
|
return invoiceResponseService.response(result, companyservice, "add"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|