From ed90a75cd728d61f4c3b09a1ba8c58a7e528f0a9 Mon Sep 17 00:00:00 2001 From: xingze <13153582609@163.com> Date: Mon, 30 Sep 2024 09:36:47 +0800 Subject: [PATCH] =?UTF-8?q?feature:=20=E7=BA=A2=E5=AD=97=E7=A1=AE=E8=AE=A4?= =?UTF-8?q?=E5=8D=95=E7=94=B3=E8=AF=B7=E6=94=B9=E4=B8=BA=E5=B0=8F=E5=86=99?= =?UTF-8?q?=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/ElephantInvoiceApiV6ServiceImpl.java | 56 ++++++++++++++++++- 1 file changed, 54 insertions(+), 2 deletions(-) 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 6f132c3..831ca37 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 @@ -1611,7 +1611,7 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService { e.printStackTrace(); return new HXResponse("009999", "系统异常!"); } - HXResponse hxResponse = parseResult(dxhyInterfaceResponse); + HXResponse hxResponse = parseResultRedApply(dxhyInterfaceResponse); if ("000000".equals(hxResponse.get("code"))) { cn.hutool.json.JSONObject data = JSONUtil.parseObj(hxResponse.getData()); @@ -1630,7 +1630,7 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService { allApiLogMapper.insertInvoiceAllApiLog(allApiLog); } } - return parseResult(dxhyInterfaceResponse); + return parseResultRedApply(dxhyInterfaceResponse); } @@ -1775,6 +1775,58 @@ public class ElephantInvoiceApiV6ServiceImpl implements IInvoiceApiService { } + /** + * 大象红字确认单申请返回 + * + * @param dxhyInterfaceResponse + * @return + */ + public HXResponse parseResultRedApply(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)) { + cn.hutool.json.JSONObject json = null; + if (StrUtil.isNotEmpty(dataTemp)) { + json = JSONUtil.parseObj(dataTemp); + } else { + json = JSONUtil.parseObj(data); + } + // 键值转小写 + JSONObject lowerCaseJson = new JSONObject(); + json.forEach((key, value) -> { + String lowerCaseKey = key.toLowerCase(); + lowerCaseJson.put(lowerCaseKey, value); + }); + return new HXResponse(code, "", json, true); + } else { + return new HXResponse(ztdm, ztxx, "", true); + } + } + } else { + return new HXResponse(code, "接口请求失败!", "", false); + } + + return new HXResponse(code, "接口请求失败!", "", false); + } + + + + + /** * 申请/上传 红字发票 *