大象V6调用SDK

beta-enc
dongxiaoke 2 years ago
parent 77506c2960
commit 43632f1e6a
  1. 9
      jianshui-common/pom.xml
  2. BIN
      jianshui-common/src/main/java/com/jianshui/lib/SIMS-order-sdk-1.2.3-RELEASE.jar
  3. 11
      jianshui-invoice/pom.xml
  4. 2
      jianshui-invoice/src/main/java/com/jianshui/invoice/constant/elephant/ElephantConstants.java
  5. 39
      jianshui-invoice/src/main/java/com/jianshui/invoice/utils/elephant/ElephantUtils.java
  6. 8
      pom.xml

@ -161,6 +161,15 @@
<scope>compile</scope>
</dependency>
<!--大象慧云V6接口SDK-->
<dependency>
<groupId>com.dxhy.order</groupId>
<artifactId>SIMS-order-sdk</artifactId>
<version>1.2.3-RELEASE</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/java/com/jianshui/lib/SIMS-order-sdk-1.2.3-RELEASE.jar</systemPath>
</dependency>
</dependencies>
</project>

@ -16,11 +16,6 @@
</description>
<dependencies>
<dependency>
<groupId>com.dxhy.order</groupId>
<artifactId>SIMS-order-sdk</artifactId>
<version>1.2.3-RELEASE</version>
</dependency>
<!-- 通用工具-->
<dependency>
<groupId>com.jianshui</groupId>
@ -69,6 +64,12 @@
<version>1.6.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

@ -17,6 +17,7 @@ public class ElephantConstants {
public static String DEV_HOST = "https://sandbox.zncspt.com/api/";
public static String DEV_ELECLOUD_HOST = "https://sandbox.ele-cloud.com/api/";
public static String DEV_HOST_LOCAL = "http://140.143.226.17:8087/order-api";
public static String DEV_HOST_LOCAL_V6_JingDongYun = "https://js.ele12.com/order-api";
// 生产的域名
public static String PROD_HOST = "https://openapi.zncspt.com/api/";
@ -24,6 +25,7 @@ public class ElephantConstants {
public static String PROD_ELECLOUD_HOST = "https://openapi.ele-cloud.com/api/";
public static String PROD_HOST_LOCAL = "http://140.143.226.17:8087/order-api";
public static String PROD_HOST_LOCAL_V6_JingDongYun = "https://js.ele12.com/order-api";
// 测试的获取token的域名
public static String DEV_TOKEN_HOST = "https://sandbox.zncspt.com/api/authen/token";

@ -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
*

@ -252,6 +252,8 @@
</dependency>
</dependencies>
</dependencyManagement>
@ -288,8 +290,14 @@
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
<compilerArguments>
<!-- 打包本地jar包 -->
<extdirs>${project.basedir}/lib</extdirs>
</compilerArguments>
</configuration>
</plugin>
</plugins>
</build>

Loading…
Cancel
Save