|
|
|
@ -1,6 +1,8 @@ |
|
|
|
|
package com.jianshui.invoice.utils.elephant; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
|
import cn.hutool.core.lang.Snowflake; |
|
|
|
|
import cn.hutool.core.util.IdUtil; |
|
|
|
|
import cn.hutool.core.util.RandomUtil; |
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
import cn.hutool.http.ContentType; |
|
|
|
@ -331,6 +333,7 @@ public class ElephantUtils { |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 大象请求 大象部署版 v6 无token |
|
|
|
|
* Post请求 |
|
|
|
|
* |
|
|
|
|
* @param uri 请求uri |
|
|
|
|
* @param methodName 文档里的"接口方法" |
|
|
|
@ -339,33 +342,34 @@ public class ElephantUtils { |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public static DxhyInterfaceResponse sendRequestWithoutTokenV6(String uri, String methodName, JSON data, Companyservice companyservice) throws UnsupportedEncodingException, NoSuchAlgorithmException, InvalidKeyException { |
|
|
|
|
// v4的考过来的 没变
|
|
|
|
|
|
|
|
|
|
ICompanyservicePropService companyserviceProp = SpringUtils.getBean(ICompanyservicePropService.class); |
|
|
|
|
CompanyserviceProp secretIdProp = companyserviceProp.selectPropByKey(companyservice.getCompanyid(), "elephant_secret_id"); |
|
|
|
|
if (secretIdProp == null) { |
|
|
|
|
throw new JianshuiServiceException("企业未配置属性,请联系管理员!"); |
|
|
|
|
} |
|
|
|
|
// appid
|
|
|
|
|
|
|
|
|
|
String secretId = secretIdProp.getValue(); |
|
|
|
|
CompanyserviceProp sercretKeyProp = companyserviceProp.selectPropByKey(companyservice.getCompanyid(), "elephant_secret_key"); |
|
|
|
|
if (sercretKeyProp == null) { |
|
|
|
|
throw new JianshuiServiceException("企业未配置属性,请联系管理员!"); |
|
|
|
|
} |
|
|
|
|
// appkey
|
|
|
|
|
|
|
|
|
|
String sercretKey = sercretKeyProp.getValue(); |
|
|
|
|
// 调用v6请求内容(content字段)
|
|
|
|
|
String str = JSONUtil.toJsonStr(data); |
|
|
|
|
boolean isDevMode = CommonUtils.isDevMode(); |
|
|
|
|
// 主机名(京东云地址)
|
|
|
|
|
String host = ElephantConstants.PROD_HOST_LOCAL; |
|
|
|
|
String host = ElephantConstants.PROD_HOST_LOCAL_V6_JingDongYun; |
|
|
|
|
if (isDevMode) { |
|
|
|
|
host = ElephantConstants.DEV_HOST_LOCAL; |
|
|
|
|
host = ElephantConstants.DEV_HOST_LOCAL_V6_JingDongYun; |
|
|
|
|
} |
|
|
|
|
host = "https://js.ele12.com/order-api"; |
|
|
|
|
// 最终接口地址
|
|
|
|
|
String url = host + uri; |
|
|
|
|
|
|
|
|
|
DxhyInterfaceResponse dxhyInterfaceResponse = null; |
|
|
|
|
|
|
|
|
|
// 封装大象v6调用类
|
|
|
|
|
// TODO 注意调整这里
|
|
|
|
|
DxhyInterfaceRequest dxhyInterfaceRequest = new DxhyInterfaceRequest(); |
|
|
|
|
// 地址
|
|
|
|
|
dxhyInterfaceRequest.setRequestUrl(url); |
|
|
|
@ -374,7 +378,13 @@ public class ElephantUtils { |
|
|
|
|
// 超时时间(毫秒值)
|
|
|
|
|
dxhyInterfaceRequest.setHttpTimeOut("100000"); |
|
|
|
|
// 流水号(拷贝的接口文档的)
|
|
|
|
|
dxhyInterfaceRequest.setDataExchangeId("1617954341800234234234552"); |
|
|
|
|
// dxhyInterfaceRequest.setDataExchangeId("1617954341800234234234552");
|
|
|
|
|
// 生成流水号
|
|
|
|
|
Snowflake snowflake = IdUtil.createSnowflake(1, 1); |
|
|
|
|
long snowflakeId = snowflake.nextId(); |
|
|
|
|
String snowflakeIdStr = String.valueOf(snowflakeId); |
|
|
|
|
dxhyInterfaceRequest.setDataExchangeId(snowflakeIdStr); |
|
|
|
|
|
|
|
|
|
// appid
|
|
|
|
|
dxhyInterfaceRequest.setSecretId(secretId); |
|
|
|
|
// appkey
|
|
|
|
@ -385,15 +395,22 @@ public class ElephantUtils { |
|
|
|
|
dxhyInterfaceRequest.setZipCode("0"); |
|
|
|
|
// 不加密
|
|
|
|
|
dxhyInterfaceRequest.setEncryptCode("0"); |
|
|
|
|
// 大象v6调用方法(获取结果处理)
|
|
|
|
|
DxhyInterfaceResponse dxhyInterfaceResponse = InvokeDxhyApi.dxhyInterfaceInvoke(dxhyInterfaceRequest); |
|
|
|
|
log.info("请求成功,结果{}",JSONUtil.toJsonStr(dxhyInterfaceResponse)); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
// 大象v6调用方法(获取结果处理)
|
|
|
|
|
log.info("【销项】【大象工具类】调用V6接口,入参{}",JSONUtil.toJsonStr(dxhyInterfaceRequest)); |
|
|
|
|
dxhyInterfaceResponse = InvokeDxhyApi.dxhyInterfaceInvoke(dxhyInterfaceRequest); |
|
|
|
|
log.info("【销项】【大象工具类】请求成功,结果{}",JSONUtil.toJsonStr(dxhyInterfaceResponse)); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("【销项】【大象接口】调用HttpsUtilV6.Exception, url=" + url + ",request=" + JSONUtil.toJsonStr(dxhyInterfaceRequest), e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return dxhyInterfaceResponse; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 大象请求 大象部署版 1.2.4 无token |
|
|
|
|
* |
|
|
|
|