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); + } + + + + + /** * 申请/上传 红字发票 *