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 7a41169..78ae924 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 @@ -75,54 +75,6 @@ public class InvoiceController { @Autowired private InvoiceAddPService addService; - @GetMapping("/api/v1/test") - public EleNewMessage test() { - Companyservice companyservice = new Companyservice(); - FindRedInfo findRedInfo = new FindRedInfo(); - findRedInfo.setSQBQQPCH("127021937706230911155203"); - findRedInfo.setNSRSBH("91370921MACWQ1520M"); - DxhyInterfaceResponse dxhyInterfaceResponse = null; - try { - dxhyInterfaceResponse = ElephantUtils.sendRequestWithoutTokenV6(ElephantConstants.REDINFO_FIND_LOCALHOST, - ElephantConstants.REDINFO_FIND_METHOD, JSONUtil.parse(findRedInfo), companyservice); - } catch (UnsupportedEncodingException | InvalidKeyException | NoSuchAlgorithmException e) { - log.error("【销项发票】【大象接口】【红字信息表查询】发票请求异常,请求报文{},销方信息{}", - JSONUtil.parse(findRedInfo).toString(), JSONObject.toJSONString(companyservice)); - e.printStackTrace(); - throw new JianshuiServiceException("系统异常!"); - } - String data = dxhyInterfaceResponse.getData(); - cn.hutool.json.JSONObject dataStr = new cn.hutool.json.JSONObject(data); - if ("000000".equals(dataStr.getStr("ZTDM"))) { - Gson gson = new Gson(); - EleOuterMessage eleOuterMessage = gson.fromJson(data, EleOuterMessage.class); - String inMsg = ""; - String inMsgInfo = ""; - List hzsqdxzzxx = eleOuterMessage.getHZSQDXZZXX(); - for (HZSQDMessage hzsqdMessage : hzsqdxzzxx) { - inMsg = hzsqdMessage.getHZSQDXZTXX().getZTDM(); - inMsgInfo = hzsqdMessage.getHZSQDXZTXX().getZTXX(); - hzsqdMessage.getHZSQDXZTXX().setBillNo(findRedInfo.getSQBQQPCH()); - } - EleNewMessage eleNewMessage = new EleNewMessage(); - BeanUtil.copyProperties(eleOuterMessage, eleNewMessage); - eleNewMessage.setStatus(eleOuterMessage.getZTDM().substring(eleOuterMessage.getZTDM().length() - 4)); - if ("060000".equals(inMsg)) { - eleNewMessage.setMessage(inMsgInfo); - eleNewMessage.setData(eleOuterMessage.getHZSQDXZZXX()); - return eleNewMessage; - } else { - eleNewMessage.setMessage(inMsgInfo); - eleNewMessage.setData(eleOuterMessage.getHZSQDXZZXX()); - return eleNewMessage; - } - } else { - EleNewMessage eleNewMessage = new EleNewMessage(); - eleNewMessage.setStatus("9999"); - eleNewMessage.setMessage("接口请求失败"); - return eleNewMessage; - } - } /** * 功能描述: 红字查询接口 @@ -1483,6 +1435,135 @@ public class InvoiceController { } + /** 红字确认单列表查询(数电专用) */ + @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/queryRedConfirmationList/{identity}", "/api/invoice/v1/queryRedConfirmationList"}) + public Object queryRedConfirmationList(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()); + + IInvoiceApiService invoiceService = invoiceServiceFactory.getService(serviceKey); + HXResponse result = invoiceService.queryRedConfirmationList(decryptResult, companyservice); + + String responseAdapterKey = serviceManageService.getResponseAdapterKey("invoice", companyservice.getCompanyid()); + IInvoiceResponseService invoiceResponseService = invoiceResponseFactory.getService(responseAdapterKey); + + return invoiceResponseService.response(result, companyservice, ""); + + } + + /** 红字确认单明细查询(数电专用) */ + @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/queryRedConfirmationItemList/{identity}", "/api/invoice/v1/queryRedConfirmationItemList"}) + public Object queryRedConfirmationItemList(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()); + + IInvoiceApiService invoiceService = invoiceServiceFactory.getService(serviceKey); + HXResponse result = invoiceService.queryRedConfirmationItemList(decryptResult, companyservice); + + String responseAdapterKey = serviceManageService.getResponseAdapterKey("invoice", companyservice.getCompanyid()); + IInvoiceResponseService invoiceResponseService = invoiceResponseFactory.getService(responseAdapterKey); + + return invoiceResponseService.response(result, companyservice, ""); + + } + + +/** 红字确认单申请(数电专用) */ + @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/redConfirmationApply/{identity}", "/api/invoice/v1/redConfirmationApply"}) + public Object RedConfirmationApply(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()); + + IInvoiceApiService invoiceService = invoiceServiceFactory.getService(serviceKey); + HXResponse result = invoiceService.redConfirmationApply(decryptResult, companyservice); + + String responseAdapterKey = serviceManageService.getResponseAdapterKey("invoice", companyservice.getCompanyid()); + IInvoiceResponseService invoiceResponseService = invoiceResponseFactory.getService(responseAdapterKey); + + return invoiceResponseService.response(result, companyservice, ""); + + } + +/** 红字确认单确认(数电专用) */ + @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/redConfirmationConfirm/{identity}", "/api/invoice/v1/redConfirmationConfirm"}) + public Object redConfirmationConfirm(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()); + + IInvoiceApiService invoiceService = invoiceServiceFactory.getService(serviceKey); + HXResponse result = invoiceService.redConfirmationConfirm(decryptResult, companyservice); + + String responseAdapterKey = serviceManageService.getResponseAdapterKey("invoice", companyservice.getCompanyid()); + IInvoiceResponseService invoiceResponseService = invoiceResponseFactory.getService(responseAdapterKey); + + return invoiceResponseService.response(result, companyservice, ""); + + } + diff --git a/jianshui-invoice/src/main/java/com/jianshui/invoice/constant/elephant/ElephantConstantsV6.java b/jianshui-invoice/src/main/java/com/jianshui/invoice/constant/elephant/ElephantConstantsV6.java index 5dfa561..d45cea5 100644 --- a/jianshui-invoice/src/main/java/com/jianshui/invoice/constant/elephant/ElephantConstantsV6.java +++ b/jianshui-invoice/src/main/java/com/jianshui/invoice/constant/elephant/ElephantConstantsV6.java @@ -57,10 +57,30 @@ public class ElephantConstantsV6 { public static String REDINFO_FIND_METHOD = "GetRedInvoiceApplication"; - // 生成动态二维码 + // 数电-生成动态二维码 public static String GEN_DYNAMIC_CODE_LOCALHOST = "/invoice/api/v6/GenerateDynamicCode"; public static String GEN_DYNAMIC_CODE_METHOD = "GenerateDynamicCode"; + // 数电-红字确认单列表查询 + public static String QUERY_RED_CONFIRMATION_LIST_LOCALHOST = "/invoice/api/v6/QueryRedConfirmationList"; + public static String QUERY_RED_CONFIRMATION_LIST_METHOD = "QueryRedConfirmationList"; + + // 数电-红字确认单明细查询 + public static String QUERY_RED_CONFIRMATION_ITEM_LIST_LOCALHOST = "/invoice/api/v6/QueryRedConfirmationItemList"; + public static String QUERY_RED_CONFIRMATION_ITEM_LIST_METHOD = "QueryRedConfirmationItemList"; + + // 数电-红字确认单申请 + public static String RED_CONFIRMATION_LOCALHOST = "/invoice/api/v6/RedConfirmationApply"; + public static String RED_CONFIRMATION_METHOD = "RedConfirmationApply"; + + // 数电-红字确认单确认 + public static String RED_CONFIRMATION_CONFIRM_LOCALHOST = "/invoice/api/v6/RedConfirmationConfirm"; + public static String RED_CONFIRMATION_CONFIRM_METHOD = "RedConfirmationConfirm"; + + + + + // 发票作废 public static String DEPRECATE_INVOICE = "order-api/order-api/V5/DeprecateInvoices"; diff --git a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/IInvoiceApiService.java b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/IInvoiceApiService.java index f78814f..768beff 100644 --- a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/IInvoiceApiService.java +++ b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/IInvoiceApiService.java @@ -58,6 +58,38 @@ public interface IInvoiceApiService { */ public HXResponse scopeQueryInvoices(JSONObject queryJson, Companyservice companyservice); + /** + * 红字确认单列表查询-数电 + * @param decryptResult + * @param companyservice + * @return + */ + HXResponse queryRedConfirmationList(JSONObject decryptResult, Companyservice companyservice); + + /** + * 红字确认单明细查询(数电专用) + * @param decryptResult + * @param companyservice + * @return + */ + HXResponse queryRedConfirmationItemList(JSONObject decryptResult, Companyservice companyservice); + + /** + * 红字确认单申请(数电专用) + * @param decryptResult + * @param companyservice + * @return + */ + HXResponse redConfirmationApply(JSONObject decryptResult, Companyservice companyservice); + + /** + * 红字确认单确认(数电专用) + * @param decryptResult + * @param companyservice + * @return + */ + HXResponse redConfirmationConfirm(JSONObject decryptResult, Companyservice companyservice); + /** * 申请/上传 红字发票 * diff --git a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/AisinoConsoleInvoiceApiServiceImpl.java b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/AisinoConsoleInvoiceApiServiceImpl.java index 53d39e6..78616fd 100644 --- a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/AisinoConsoleInvoiceApiServiceImpl.java +++ b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/AisinoConsoleInvoiceApiServiceImpl.java @@ -513,6 +513,26 @@ public class AisinoConsoleInvoiceApiServiceImpl implements IInvoiceApiService { return null; } + @Override + public HXResponse queryRedConfirmationList(JSONObject decryptResult, Companyservice companyservice) { + return null; + } + + @Override + public HXResponse queryRedConfirmationItemList(JSONObject decryptResult, Companyservice companyservice) { + return null; + } + + @Override + public HXResponse redConfirmationApply(JSONObject decryptResult, Companyservice companyservice) { + return null; + } + + @Override + public HXResponse redConfirmationConfirm(JSONObject decryptResult, Companyservice companyservice) { + return null; + } + /** 红字信息表上传*/ @Override public HXResponse uploadRedInfo(Redinfo redinfo, Companyservice companyservice) { diff --git a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiServiceImpl.java b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiServiceImpl.java index 4b4e8d8..ec30486 100644 --- a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiServiceImpl.java +++ b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiServiceImpl.java @@ -748,6 +748,26 @@ public class ElephantInvoiceApiServiceImpl implements IInvoiceApiService { } + @Override + public HXResponse queryRedConfirmationList(JSONObject decryptResult, Companyservice companyservice) { + return null; + } + + @Override + public HXResponse queryRedConfirmationItemList(JSONObject decryptResult, Companyservice companyservice) { + return null; + } + + @Override + public HXResponse redConfirmationApply(JSONObject decryptResult, Companyservice companyservice) { + return null; + } + + @Override + public HXResponse redConfirmationConfirm(JSONObject decryptResult, Companyservice companyservice) { + return null; + } + /** * 功能描述: 红字信息查询 * diff --git a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiV6ServiceImpl.java b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiV6ServiceImpl.java index 471b22f..ab07884 100644 --- a/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiV6ServiceImpl.java +++ b/jianshui-invoice/src/main/java/com/jianshui/invoice/service/impl/api/ElephantInvoiceApiV6ServiceImpl.java @@ -2,6 +2,7 @@ package com.jianshui.invoice.service.impl.api; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.codec.Base64; +import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSONArray; @@ -10,7 +11,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.dxhy.order.protocol.invoke.DxhyInterfaceResponse; import com.google.gson.Gson; import com.jianshui.common.constant.Constants; -import com.jianshui.common.constant.WebServiceConstant; import com.jianshui.common.core.domain.AjaxResult; import com.jianshui.common.core.domain.entity.Companyservice; import com.jianshui.common.enums.ErrorCode; @@ -21,7 +21,6 @@ import com.jianshui.common.utils.DateUtils; import com.jianshui.common.utils.StringUtils; import com.jianshui.common.utils.TimeUtil; import com.jianshui.common.utils.http.HttpHelper; -import com.jianshui.common.utils.jcsk.ApiHttp; import com.jianshui.common.utils.uuid.IdUtils; import com.jianshui.framework.manager.AsyncManager; import com.jianshui.invoice.constant.elephant.ElephantConstantsV6; @@ -46,7 +45,6 @@ import com.jianshui.queue.utils.RedisQueueUtil; import com.jianshui.storage.domain.StorageUrlDTO; import com.jianshui.storage.factory.StorageFactory; import com.jianshui.storage.service.IStorageService; -import com.jianshui.system.domain.InvoiceAllApiLog; import com.jianshui.system.mapper.CompanyserviceMapper; import com.jianshui.system.service.ISysConfigService; import lombok.extern.slf4j.Slf4j; @@ -98,7 +96,6 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService { * * @param billInfo * @return - * @description TODO 没有处理机动车的情况,需要处理机动车,冲红和蓝票都要处理 */ @Override public HXResponse addInvoice(BillInfo billInfo, Companyservice companyservice) throws IllegalAccessException, InstantiationException { @@ -122,47 +119,13 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService { ddpcxx.setDDQQPCH(billInfo.getSystemOrderno()); ddpcxx.setNSRSBH(billInfo.getSellerTaxnum()); ddpcxx.setKPZD(billInfo.getTerminalNumber()); - // 大象发票类型代码说明 - // 增值税专用发票: 004 1 - // 增值税普通发票: 007 1 - // 增值税电子专用发票:028 1 - // 机动车销售统一发票:005 1 - // 二手车销售统一发票:006 1 - // 增值税普通发票(电子): 026 1 String invioceType = billInfo.getInvoiceType(); String fplxdm = ElephantUtils.transElephantType(invioceType, 1); ddpcxx.setFPLXDM(fplxdm); - // switch (invioceType) { - // case "p": - // ddpcxx.setFPLXDM("026"); - // break; - // case "c": - // ddpcxx.setFPLXDM("007"); - // break; - // case "s": - // ddpcxx.setFPLXDM("004"); - // break; - // case "b": - // ddpcxx.setFPLXDM("028"); - // break; - // case "j": - // ddpcxx.setFPLXDM("005"); - // throw new JianshuiParamErrorException("暂不支持的开票类型,请联系管理员!", companyservice, "invoice"); - // case "u": - // ddpcxx.setFPLXDM("006"); - // throw new JianshuiParamErrorException("暂不支持的开票类型,请联系管理员!", companyservice, "invoice"); - // case "r": - // default: - // throw new JianshuiParamErrorException("暂不支持的开票类型,请联系管理员!", companyservice, "invoice"); - // } //kk TODO : 2023/9/15 V6数电新增 // 标准开具 - Qdtxx qdtxx = BeanUtil.copyProperties(billInfo,Qdtxx.class); - /* if(billInfo.getFjyslist() != null && billInfo.getFjyslist().size()>0){ - List fjysList = BeanUtil.copyToList(billInfo.getFjyslist(),Fjys.class); - qdtxx.setFjyslist(fjysList); - }*/ + Qdtxx qdtxx = BeanUtil.copyProperties(billInfo, Qdtxx.class); qdtxx.setQydm(billInfo.getDqbm()); qdtxx.setFJYSLIST(billInfo.getFjyslist());// 附加要素列表 qdtxx.setHWYSLIST(billInfo.getHwysList()); // 货物运输 @@ -191,11 +154,6 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService { // 全电头信息 elephantInvoiceAddDTO.setQDTXX(qdtxx); - // JSONObject result = JSONObject.parseObject("{\"zipCode\":\"0\",\"entCode\":\"91370102MA3UD2FG21\",\"dataExchangeId\":\"20220328140706911955546286280593\",\"encryptCode\":\"0\",\"returnStateInfo\":{\"returnCode\":\"0000\",\"returnMessage\":\"5aSE55CG5oiQ5YqfIQ==\"},\"content\":\"eyJERFFRUENIIjoiODgyOWNmNWUtNDAyYS00NWZkLWFiYmEtMzlkMjlhOWMzMjMzIiwiWlRETSI6IjAwOTk5OSIsIlpUWFgiOiLkvIHkuJrmnKrphY3nva7nqI7mjqforr7lpIcifQ==\"}"); - // if (!CommonUtils.isDevMode()) { - // result = ElephantUtils.sendRequest(ElephantConstantsV6.ADD_INVOICE, (JSONObject) JSONObject.toJSON(elephantInvoiceAddDTO)); - // } - // AjaxResult queryResult = ElephantUtils.sendRequest(ElephantConstantsV6.ADD_INVOICE, JSONUtil.parse(elephantInvoiceAddDTO)); AjaxResult queryResult = null; try { queryResult = ElephantUtils.sendRequestWithoutTokenV6New(ElephantConstantsV6.ADD_INVOICE_LOCALHOST, ElephantConstantsV6.ADD_INVOICE_METHOD, JSONUtil.parse(elephantInvoiceAddDTO), companyservice); @@ -268,12 +226,6 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService { } } - // // 处理报文保存 - // JSONObject DDJGXX = contentJson.getJSONObject("DDJGXX"); - // if (StringUtils.isNotEmpty(DDJGXX.getString("DDQQLSH"))) { - // billInfo.setFpqqlsh(DDJGXX.getString("DDQQLSH")); - // } - // 定时拉取保存发票, TODO 处理开票中的问题 AsyncManager.me().execute(new QueryInvoiceTask(billInfo, companyservice, this)); @@ -307,11 +259,7 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService { */ @Override public HXResponse queryInvoice(QueryBillInfoDTO billInfo, Companyservice companyservice) { - // String fpqqlsh = billInfo.getFpqqlsh(); - // if (StringUtils.isEmpty(fpqqlsh)) { - // HXResponse response = new HXResponse("9999", "发票请求流水号不能为空!"); - // return response; - // } + // 获得当前时间戳 Long timestamp = System.currentTimeMillis(); String uuid = UUID.randomUUID().toString(); @@ -354,8 +302,6 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService { queryBody.put("BSWJ", "0"); debugLog("断点4", uuid, timestamp); - // AjaxResult queryResult = ElephantUtils.sendRequest(ElephantConstantsV6.QUERY_INVOICE, JSONUtil.parse(queryBody)); - // queryResult = ElephantUtils.sendRequest(ElephantConstantsV6.ADD_INVOICE_RESULT, JSONUtil.parse(queryBody)); AjaxResult queryResult = null; try { queryResult = ElephantUtils.sendRequestWithoutToken(ElephantConstantsV6.QUERY_INVOICE_LOCALHOST, ElephantConstantsV6.QUERY_INVOICE_METHOD, JSONUtil.parse(queryBody), companyservice); @@ -368,19 +314,6 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService { // 判断外层报文是否成功 if (queryResult.isError()) { - // String base64Result = returnStateInfo.getString("returnMessage"); - // String errorMsg = new String(Base64.decodeBase64(base64Result)); - // Invoice tempInvoice = new Invoice(); - // tempInvoice.setInvoiceMsg(errorMsg); - // if (billInfo.getSystemOrderno() != null) { - // tempInvoice.setSystemOrderno(billInfo.getSystemOrderno()); - // } - // if (billInfo.getOutTradeOrderno() != null) { - // tempInvoice.setOutTradeOrderno(billInfo.getOutTradeOrderno()); - // } - // if (billInfo.getFpqqlsh() != null) { - // tempInvoice.setFpqqlsh(billInfo.getFpqqlsh()); - // } throw new JianshuiServiceException(queryResult.getMsg()); } debugLog("断点6", uuid, timestamp); @@ -808,12 +741,11 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService { } - - } /** * 生成动态二维码接口 + * * @param decryptResult * @param companyservice * @return @@ -825,18 +757,137 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService { try { dxhyInterfaceResponse = ElephantUtils.sendRequestWithoutTokenV6(ElephantConstantsV6.GEN_DYNAMIC_CODE_LOCALHOST, ElephantConstantsV6.GEN_DYNAMIC_CODE_METHOD, JSONUtil.parse(decryptResult), companyservice); } catch (UnsupportedEncodingException | InvalidKeyException | NoSuchAlgorithmException e) { - log.error("【销项发票】【大象接口】【生成动态二维码】发票请求异常,请求报文{},销方信息{}", decryptResult, JSONObject.toJSONString(companyservice)); + log.error("【销项发票】【大象接口】【数电】【生成动态二维码】发票请求异常,请求报文{},销方信息{}", decryptResult, JSONObject.toJSONString(companyservice)); e.printStackTrace(); - return new HXResponse("9999","系统异常!"); + return new HXResponse("009999", "系统异常!"); } - Object data = dxhyInterfaceResponse.getData(); - String code = dxhyInterfaceResponse.getCode(); - return new HXResponse(code,data); + return parseResult(dxhyInterfaceResponse); + } + + /** + * 红字确认单列表查询(数电专用) + * + * */ + @Override + public HXResponse queryRedConfirmationList(JSONObject decryptResult, Companyservice companyservice) { + + DxhyInterfaceResponse dxhyInterfaceResponse = null; + try { + dxhyInterfaceResponse = ElephantUtils.sendRequestWithoutTokenV6(ElephantConstantsV6.QUERY_RED_CONFIRMATION_LIST_LOCALHOST, ElephantConstantsV6.QUERY_RED_CONFIRMATION_LIST_METHOD, JSONUtil.parse(decryptResult), companyservice); + } catch (UnsupportedEncodingException | InvalidKeyException | NoSuchAlgorithmException e) { + log.error("【销项发票】【大象接口】【数电】【红字确认单列表查询】发票请求异常,请求报文{},销方信息{}", decryptResult, JSONObject.toJSONString(companyservice)); + e.printStackTrace(); + return new HXResponse("009999", "系统异常!"); + } + return parseResult(dxhyInterfaceResponse); } + /** + * 红字确认单明细查询(数电专用) + * @param decryptResult + * @param companyservice + * @return + */ + @Override + public HXResponse queryRedConfirmationItemList(JSONObject decryptResult, Companyservice companyservice) { + DxhyInterfaceResponse dxhyInterfaceResponse = null; + try { + dxhyInterfaceResponse = ElephantUtils.sendRequestWithoutTokenV6(ElephantConstantsV6.QUERY_RED_CONFIRMATION_ITEM_LIST_LOCALHOST, ElephantConstantsV6.QUERY_RED_CONFIRMATION_ITEM_LIST_METHOD, JSONUtil.parse(decryptResult), companyservice); + } catch (UnsupportedEncodingException | InvalidKeyException | NoSuchAlgorithmException e) { + log.error("【销项发票】【大象接口】【数电】【红字确认单明细查询】发票请求异常,请求报文{},销方信息{}", decryptResult, JSONObject.toJSONString(companyservice)); + e.printStackTrace(); + return new HXResponse("009999", "系统异常!"); + } + + return parseResult(dxhyInterfaceResponse); + } + + /** + * 红字确认单申请(数电专用) + * @param decryptResult + * @param companyservice + * @return + */ + @Override + public HXResponse redConfirmationApply(JSONObject decryptResult, Companyservice companyservice) { + DxhyInterfaceResponse dxhyInterfaceResponse = null; + try { + dxhyInterfaceResponse = ElephantUtils.sendRequestWithoutTokenV6(ElephantConstantsV6.RED_CONFIRMATION_LOCALHOST, ElephantConstantsV6.RED_CONFIRMATION_METHOD, JSONUtil.parse(decryptResult), companyservice); + } catch (UnsupportedEncodingException | InvalidKeyException | NoSuchAlgorithmException e) { + log.error("【销项发票】【大象接口】【数电】【红字确认单申请】发票请求异常,请求报文{},销方信息{}", decryptResult, JSONObject.toJSONString(companyservice)); + e.printStackTrace(); + return new HXResponse("009999", "系统异常!"); + } + + return parseResult(dxhyInterfaceResponse); + } + + + /** + * 红字确认单确认接口 + * @param decryptResult + * @param companyservice + * @return + */ + @Override + public HXResponse redConfirmationConfirm(JSONObject decryptResult, Companyservice companyservice) { + DxhyInterfaceResponse dxhyInterfaceResponse = null; + try { + dxhyInterfaceResponse = ElephantUtils.sendRequestWithoutTokenV6(ElephantConstantsV6.RED_CONFIRMATION_LOCALHOST, ElephantConstantsV6.RED_CONFIRMATION_METHOD, JSONUtil.parse(decryptResult), companyservice); + } catch (UnsupportedEncodingException | InvalidKeyException | NoSuchAlgorithmException e) { + log.error("【销项发票】【大象接口】【数电】【红字确认单确认接口】发票请求异常,请求报文{},销方信息{}", decryptResult, JSONObject.toJSONString(companyservice)); + e.printStackTrace(); + return new HXResponse("009999", "系统异常!"); + } + + return parseResult(dxhyInterfaceResponse); + } + + + /** + * 大象通用返回处理 + * + * @param dxhyInterfaceResponse + * @return + */ + public HXResponse parseResult(DxhyInterfaceResponse dxhyInterfaceResponse) { + + if (BeanUtil.isEmpty(dxhyInterfaceResponse)) { + return new HXResponse("9999", "接口请求失败!返回内容不存在!", "", false); + } + + // 大象通用返回处理,返回简税HXResponse + Object data = dxhyInterfaceResponse.getData() != null ? dxhyInterfaceResponse.getData() : ""; + String code = dxhyInterfaceResponse.getCode() != null ? dxhyInterfaceResponse.getCode() : ""; + + if ("000000".equals(code)) { + if (ObjUtil.isNotEmpty(data)) { + cn.hutool.json.JSONObject dataJson = JSONUtil.parseObj(data); + String ztdm = dataJson.get("ZTDM") != null ? dataJson.get("ZTDM").toString() : ""; + String ztxx = dataJson.get("ZTXX") != null ? dataJson.get("ZTXX").toString() : ""; + String dataTemp = dataJson.get("DATA") != null ? dataJson.get("DATA").toString() : ""; + + if ("000000".equals(ztdm)) { + if(StrUtil.isNotEmpty(dataTemp)){ + return new HXResponse(code, "", dataTemp, true); + }else{ + return new HXResponse(code, "", data, true); + } + + } else { + return new HXResponse(ztdm, ztxx, "", true); + } + } + } else { + return new HXResponse(code, "接口请求失败!", "", false); + } + + return new HXResponse(code, "接口请求失败!", "", false); + } + /** * 申请/上传 红字发票 * 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 027d702..f160d01 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 @@ -359,6 +359,26 @@ public class JcskInvoiceApiServiceImpl implements IInvoiceApiService { return null; } + @Override + public HXResponse queryRedConfirmationList(JSONObject decryptResult, Companyservice companyservice) { + return null; + } + + @Override + public HXResponse queryRedConfirmationItemList(JSONObject decryptResult, Companyservice companyservice) { + return null; + } + + @Override + public HXResponse redConfirmationApply(JSONObject decryptResult, Companyservice companyservice) { + return null; + } + + @Override + public HXResponse redConfirmationConfirm(JSONObject decryptResult, Companyservice companyservice) { + return null; + } + /** * 红字信息表上传 */