v6工具类调整

beta-enc
kane 2 years ago
parent 6416dafe9d
commit 5f91a7b1bc
  1. 2
      jianshui-admin/src/main/java/com/jianshui/api/controller/http/invoice/v1/InvoiceController.java
  2. 33
      jianshui-invoice/src/main/java/com/jianshui/invoice/utils/elephant/ElephantUtils.java

@ -4,8 +4,6 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import com.dxhy.order.protocol.invoke.DxhyInterfaceResponse;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.jianshui.common.core.domain.AjaxResult;
import com.jianshui.common.core.domain.entity.Companyservice;

@ -1,19 +1,15 @@
package com.jianshui.invoice.utils.elephant;
import cn.hutool.core.codec.Base64Decoder;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.ContentType;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSON;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.dxhy.order.InvokeDxhyApi;
import com.dxhy.order.ReceiveDxhyApi;
import com.dxhy.order.protocol.invoke.DxhyInterfaceRequest;
import com.dxhy.order.protocol.invoke.DxhyInterfaceResponse;
import com.jianshui.common.core.domain.AjaxResult;
@ -23,19 +19,16 @@ import com.jianshui.common.exception.jianshui.JianshuiParamErrorException;
import com.jianshui.common.exception.jianshui.JianshuiServiceConfigErrorException;
import com.jianshui.common.exception.jianshui.JianshuiServiceException;
import com.jianshui.common.utils.StringUtils;
import com.jianshui.common.utils.TimeUtil;
import com.jianshui.common.utils.http.HttpUtils;
import com.jianshui.common.utils.jianshui.CommonUtils;
import com.jianshui.common.utils.spring.SpringUtils;
import com.jianshui.invoice.constant.elephant.ElephantConstants;
import com.jianshui.invoice.domain.dto.HXResponse;
import com.jianshui.system.domain.CompanyserviceProp;
import com.jianshui.system.service.ICompanyservicePropService;
import com.jianshui.system.service.ISysConfigService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.RequestEntity;
import org.apache.commons.httpclient.methods.StringRequestEntity;
@ -346,41 +339,53 @@ 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();
BASE64Encoder encoder = new BASE64Encoder();
// 调用v6请求内容(content字段)
String str = JSONUtil.toJsonStr(data);
byte[] contentByte = str.getBytes();
// byte[] contentByte = "{\"DDPCXX\":{\"DDQQPCH\":\"5767e3e0907c4e3c848c3f459b68394b\",\"NSRSBH\":\"110101MYJ2GPQQ4\",\"FPLXDM\":\"004\"},\"DDZXX\":[{\"DDTXX\":{\"DDQQLSH\":\"4767e3e0907c4e3c848c3f459b68394b\",\"NSRSBH\":\"110101MYJ2GPQQ4\",\"NSRMC\":\"测试 localhost\",\"KPLX\":\"0\",\"XHFSBH\":\"110101MYJ2GPQQ4\",\"XHFMC\":\"测试 localhost\",\"XHFDZ\":\"山东省济南市济微路141号中铁物流园1楼\",\"XHFDH\":\"1\",\"XHFYH\":\"齐鲁银行济南王官庄支行 1170 8140 0000 0016 252\",\"XHFZH\":\"1170814000000016252\",\"GMFSBH\":\"91320700774687205M\",\"GMFMC\":\"连云港天邦科技开发有限公司\",\"GMFDZ\":\"江苏省连云港市海州开发区新浦工业园振兴路\",\"GMFDH\":\"0518-85287867\",\"GMFYH\":\"江苏银行连云港浦中支行 \",\"GMFZH\":\"70300101314068535\",\"GMFLX\":\"01\",\"KPR\":\"test1\",\"QDBZ\":\"0\",\"JSHJ\":\"7475.76\",\"HJJE\":\"6615.72\",\"HJSE\":\"860.04\",\"DDH\":\"4767e3e0907c4e3c848c3f459b68394b\",\"DDSJ\":\"2022-05-17 10:09:33\"},\"DDMXXX\":[{\"XH\":\"1\",\"FPHXZ\":\"0\",\"SPBM\":\"108020799\",\"YHZCBS\":\"0\",\"XMMC\":\"圆钢\",\"GGXH\":\"60\",\"DW\":\"吨\",\"SPSL\":1.014,\"DJ\":\"4991.15\",\"JE\":\"5061.03\",\"HSBZ\":\"0\",\"SL\":\"0.13\",\"SE\":\"657.93\",\"BYZD1\":\"\",\"BYZD2\":\"\",\"BYZD3\":\"\"},{\"XH\":\"2\",\"FPHXZ\":\"0\",\"SPBM\":\"108020799\",\"YHZCBS\":\"0\",\"XMMC\":\"圆钢\",\"GGXH\":\"55\",\"DW\":\"吨\",\"SPSL\":0.23,\"DJ\":\"4902.65\",\"JE\":\"1127.61\",\"HSBZ\":\"0\",\"SL\":\"0.13\",\"SE\":\"146.59\",\"BYZD1\":\"\",\"BYZD2\":\"\",\"BYZD3\":\"\"},{\"XH\":\"3\",\"FPHXZ\":\"0\",\"SPBM\":\"108020799\",\"YHZCBS\":\"0\",\"XMMC\":\"圆钢\",\"GGXH\":\"10\",\"DW\":\"吨\",\"SPSL\":0.076,\"DJ\":\"5619.47\",\"JE\":\"427.08\",\"HSBZ\":\"0\",\"SL\":\"0.13\",\"SE\":\"55.52\",\"BYZD1\":\"\",\"BYZD2\":\"\",\"BYZD3\":\"\"}]}]}".getBytes();
// String byteContent = encoder.encode(contentByte);
boolean isDevMode = CommonUtils.isDevMode();
// 主机名(京东云地址)
String host = ElephantConstants.PROD_HOST_LOCAL;
if (isDevMode) {
host = ElephantConstants.DEV_HOST_LOCAL;
}
//kk TODO : 2023/9/5 大象接口迁京东云
//https://js.ele12.com/
host = "https://js.ele12.com/order-api";
// 最终接口地址
String url = host + uri;
// 封装大象v6调用类
// TODO 注意调整这里
DxhyInterfaceRequest dxhyInterfaceRequest = new DxhyInterfaceRequest();
// 地址
dxhyInterfaceRequest.setRequestUrl(url);
// 请求方式
dxhyInterfaceRequest.setRequestType("POST");
// 超时时间(毫秒值)
dxhyInterfaceRequest.setHttpTimeOut("100000");
// 流水号(拷贝的接口文档的)
dxhyInterfaceRequest.setDataExchangeId("1617954341800234234234552");
// appid
dxhyInterfaceRequest.setSecretId(secretId);
// appkey
dxhyInterfaceRequest.setSecretKey(sercretKey);
// 内容字段(content请求体)
dxhyInterfaceRequest.setContent(str);
// 不打包
dxhyInterfaceRequest.setZipCode("0");
// 不加密
dxhyInterfaceRequest.setEncryptCode("0");
// 大象v6调用方法(获取结果处理)
DxhyInterfaceResponse dxhyInterfaceResponse = InvokeDxhyApi.dxhyInterfaceInvoke(dxhyInterfaceRequest);
log.info("请求成功,结果{}",JSONUtil.toJsonStr(dxhyInterfaceResponse));
return dxhyInterfaceResponse;
@ -417,7 +422,7 @@ public class ElephantUtils {
}
//kk TODO : 2023/9/5 大象接口迁京东云
//https://js.ele12.com/
host = "https://js.ele12.com/order-api";
// host = "https://js.ele12.com/order-api";
String url = host + uri;
// String token = getToken();

Loading…
Cancel
Save