|
|
@@ -4,21 +4,18 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.lop.open.api.sdk.DefaultDomainApiClient;
|
|
|
import com.lop.open.api.sdk.LopException;
|
|
|
+import com.lop.open.api.sdk.domain.ECAP.CommonBusinessApi.commonGetQRCodeV1.CommonBusinessGetQRCodeRequest;
|
|
|
import com.lop.open.api.sdk.domain.ECAP.CommonCreateOrderApi.commonCheckPreCreateOrderV1.CommonCreateOrderRequest;
|
|
|
import com.lop.open.api.sdk.domain.ECAP.CommonCreateOrderApi.commonCheckPreCreateOrderV1.CommonProductInfo;
|
|
|
import com.lop.open.api.sdk.domain.ECAP.CommonCreateOrderApi.commonCheckPreCreateOrderV1.Contact;
|
|
|
import com.lop.open.api.sdk.domain.ECAP.CommonCreateOrderApi.commonCreateOrderV1.CommonCargoInfo;
|
|
|
import com.lop.open.api.sdk.domain.ECAP.CommonModifyCancelOrderApi.commonCancelOrderV1.CommonOrderCancelRequest;
|
|
|
+import com.lop.open.api.sdk.domain.ECAP.CommonQueryOrderApi.commonGetOrderByMonthSettleQRV1.CommonMonthSettleQRQueryRequest;
|
|
|
+import com.lop.open.api.sdk.domain.ECAP.CommonQueryOrderApi.commonGetOrderInfoV1.CommonOrderInfoRequest;
|
|
|
import com.lop.open.api.sdk.plugin.LopPlugin;
|
|
|
import com.lop.open.api.sdk.plugin.factory.OAuth2PluginFactory;
|
|
|
-import com.lop.open.api.sdk.request.ECAP.EcapV1OrdersCancelLopRequest;
|
|
|
-import com.lop.open.api.sdk.request.ECAP.EcapV1OrdersCreateLopRequest;
|
|
|
-import com.lop.open.api.sdk.request.ECAP.EcapV1OrdersModifyLopRequest;
|
|
|
-import com.lop.open.api.sdk.request.ECAP.EcapV1OrdersPrecheckLopRequest;
|
|
|
-import com.lop.open.api.sdk.response.ECAP.EcapV1OrdersCancelLopResponse;
|
|
|
-import com.lop.open.api.sdk.response.ECAP.EcapV1OrdersCreateLopResponse;
|
|
|
-import com.lop.open.api.sdk.response.ECAP.EcapV1OrdersModifyLopResponse;
|
|
|
-import com.lop.open.api.sdk.response.ECAP.EcapV1OrdersPrecheckLopResponse;
|
|
|
+import com.lop.open.api.sdk.request.ECAP.*;
|
|
|
+import com.lop.open.api.sdk.response.ECAP.*;
|
|
|
import com.ruoyi.common.core.exception.ServiceException;
|
|
|
import com.ruoyi.common.core.utils.DateUtils;
|
|
|
import com.ruoyi.common.core.utils.StringUtils;
|
|
|
@@ -499,4 +496,143 @@ public class JDLogisticsService implements LogisticsService {
|
|
|
|
|
|
return productAttrs;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public JSONObject getMonthQRCode() {
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ try {
|
|
|
+ //设置接口域名(有的对接方案同时支持生产和沙箱环境,有的仅支持生产,具体以对接方案中的【API文档-请求地址】为准),生产域名:https://api.jdl.com 预发环境域名:https://uat-api.jdl.com
|
|
|
+ //DefaultDomainApiClient对象全局只需要创建一次
|
|
|
+ DefaultDomainApiClient client = new DefaultDomainApiClient(jdExpressConfig.getServerUrl(),500,15000);
|
|
|
+
|
|
|
+ //入参对象
|
|
|
+ EcapV1BusinessQrcodeLopRequest request = new EcapV1BusinessQrcodeLopRequest();
|
|
|
+
|
|
|
+ //取消订单入参对象
|
|
|
+ CommonBusinessGetQRCodeRequest requestDTO = new CommonBusinessGetQRCodeRequest();
|
|
|
+ requestDTO.setCustomerCode(sysConfigService.selectConfigByKey(SysConfigConstants.JD_LOGISTICS_CUSTOMERCODE));
|
|
|
+
|
|
|
+ request.setRequest(requestDTO);
|
|
|
+
|
|
|
+ //设置插件,必须的操作,不同类型的应用入参不同,请看入参注释,公共参数按顺序分别为AppKey、AppSecret、AccessToken
|
|
|
+ //使用开放平台ISV/自研商家应用调用接口
|
|
|
+ LopPlugin lopPlugin = OAuth2PluginFactory.produceLopPlugin(jdExpressConfig.getAppKey(), jdExpressConfig.getAppSecret(), jdExpressConfig.getAccessToken());
|
|
|
+ request.addLopPlugin(lopPlugin);
|
|
|
+
|
|
|
+ log.info("京东开放平台获取商家二维码接口,请求参数:{}", JSON.toJSONString(request));
|
|
|
+ EcapV1BusinessQrcodeLopResponse response = client.execute(request);
|
|
|
+ log.info("京东开放平台获取商家二维码接口,响应结果:{}", JSON.toJSONString(response));
|
|
|
+
|
|
|
+ if (response.getCode().equals("0")) {
|
|
|
+ if (response.getResponse().getCode() == 0) {
|
|
|
+ result.put("success", true);
|
|
|
+ result.put("msg", response.getResponse().getData().getVerifyMessage());
|
|
|
+ } else {
|
|
|
+ result.put("success", false);
|
|
|
+ result.put("msg", "京东开放平台获取商家二维码!失败原因:" + response.getResponse().getMsg());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ result.put("success", false);
|
|
|
+ result.put("msg", "京东开放平台获取商家二维码!失败原因:" + response.getMsg());
|
|
|
+ }
|
|
|
+ } catch (LopException e) {
|
|
|
+ log.error("京东开放平台获取商家二维码接口异常:{}", e);
|
|
|
+ throw new ServiceException("京东开放平台获取商家二维码接口异常");
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public JSONObject queryOrderByQRCode(String qrCode) {
|
|
|
+ log.info("京东开放平台根据二维码查询运单接口,入参:{}", qrCode);
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ try {
|
|
|
+ //设置接口域名(有的对接方案同时支持生产和沙箱环境,有的仅支持生产,具体以对接方案中的【API文档-请求地址】为准),生产域名:https://api.jdl.com 预发环境域名:https://uat-api.jdl.com
|
|
|
+ //DefaultDomainApiClient对象全局只需要创建一次
|
|
|
+ DefaultDomainApiClient client = new DefaultDomainApiClient(jdExpressConfig.getServerUrl(),500,15000);
|
|
|
+
|
|
|
+ //入参对象
|
|
|
+ CommonqueryorderapiCommongetorderbymonthsettleqrv1LopRequest request = new CommonqueryorderapiCommongetorderbymonthsettleqrv1LopRequest();
|
|
|
+
|
|
|
+ CommonMonthSettleQRQueryRequest requestDTO = new CommonMonthSettleQRQueryRequest();
|
|
|
+ requestDTO.setCustomerCode(sysConfigService.selectConfigByKey(SysConfigConstants.JD_LOGISTICS_CUSTOMERCODE));
|
|
|
+ requestDTO.setMonthSettleQR(qrCode);
|
|
|
+ requestDTO.setAppKey(jdExpressConfig.getAppKey());
|
|
|
+
|
|
|
+ request.setRequest(requestDTO);
|
|
|
+
|
|
|
+ //设置插件,必须的操作,不同类型的应用入参不同,请看入参注释,公共参数按顺序分别为AppKey、AppSecret、AccessToken
|
|
|
+ //使用开放平台ISV/自研商家应用调用接口
|
|
|
+ LopPlugin lopPlugin = OAuth2PluginFactory.produceLopPlugin(jdExpressConfig.getAppKey(), jdExpressConfig.getAppSecret(), jdExpressConfig.getAccessToken());
|
|
|
+ request.addLopPlugin(lopPlugin);
|
|
|
+
|
|
|
+ log.info("京东开放平台根据二维码查询运单接口,请求参数:{}", JSON.toJSONString(request));
|
|
|
+ CommonqueryorderapiCommongetorderbymonthsettleqrv1LopResponse response = client.execute(request);
|
|
|
+ log.info("京东开放平台根据二维码查询运单接口,响应结果:{}", JSON.toJSONString(response));
|
|
|
+
|
|
|
+ if (response.getCode().equals("0")) {
|
|
|
+ if (response.getResponse().getCode() == 0) {
|
|
|
+ result.put("success", true);
|
|
|
+ result.put("msg", response.getResponse().getData().getWaybillQRVerifyInfoList());
|
|
|
+ } else {
|
|
|
+ result.put("success", false);
|
|
|
+ result.put("msg", "京东开放平台根据二维码查询运单接口!失败原因:" + response.getResponse().getMsg());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ result.put("success", false);
|
|
|
+ result.put("msg", "京东开放平台根据二维码查询运单接口!失败原因:" + response.getMsg());
|
|
|
+ }
|
|
|
+ } catch (LopException e) {
|
|
|
+ log.error("京东开放平台根据二维码查询运单接口异常:{}", e);
|
|
|
+ throw new ServiceException("京东开放平台根据二维码查询运单接口异常");
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public JSONObject queryOrderDetailByWaybillCode(String waybillCode) {
|
|
|
+ log.info("京东开放平台根据运单号查询运单详情接口,入参:{}", waybillCode);
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ try {
|
|
|
+ //设置接口域名(有的对接方案同时支持生产和沙箱环境,有的仅支持生产,具体以对接方案中的【API文档-请求地址】为准),生产域名:https://api.jdl.com 预发环境域名:https://uat-api.jdl.com
|
|
|
+ //DefaultDomainApiClient对象全局只需要创建一次
|
|
|
+ DefaultDomainApiClient client = new DefaultDomainApiClient(jdExpressConfig.getServerUrl(),500,15000);
|
|
|
+
|
|
|
+ //入参对象
|
|
|
+ EcapV1OrdersDetailsQueryLopRequest request = new EcapV1OrdersDetailsQueryLopRequest();
|
|
|
+
|
|
|
+ CommonOrderInfoRequest requestDTO = new CommonOrderInfoRequest();
|
|
|
+ requestDTO.setCustomerCode(sysConfigService.selectConfigByKey(SysConfigConstants.JD_LOGISTICS_CUSTOMERCODE));
|
|
|
+ requestDTO.setBusinessUnitCode(sysConfigService.selectConfigByKey(SysConfigConstants.JD_LOGISTICS_BUSINESSUNITCODE));
|
|
|
+ requestDTO.setWaybillCode(waybillCode);
|
|
|
+
|
|
|
+ request.setRequest(requestDTO);
|
|
|
+
|
|
|
+ //设置插件,必须的操作,不同类型的应用入参不同,请看入参注释,公共参数按顺序分别为AppKey、AppSecret、AccessToken
|
|
|
+ //使用开放平台ISV/自研商家应用调用接口
|
|
|
+ LopPlugin lopPlugin = OAuth2PluginFactory.produceLopPlugin(jdExpressConfig.getAppKey(), jdExpressConfig.getAppSecret(), jdExpressConfig.getAccessToken());
|
|
|
+ request.addLopPlugin(lopPlugin);
|
|
|
+
|
|
|
+ log.info("京东开放平台根据运单号查询运单详情接口,请求参数:{}", JSON.toJSONString(request));
|
|
|
+ EcapV1OrdersDetailsQueryLopResponse response = client.execute(request);
|
|
|
+ log.info("京东开放平台根据运单号查询运单详情接口,响应结果:{}", JSON.toJSONString(response));
|
|
|
+
|
|
|
+ if (response.getCode().equals("0")) {
|
|
|
+ if (response.getResult().getCode() == 0) {
|
|
|
+ result.put("success", true);
|
|
|
+ result.put("msg", response.getResult().getData());
|
|
|
+ } else {
|
|
|
+ result.put("success", false);
|
|
|
+ result.put("msg", "京东开放平台根据运单号查询运单详情接口!失败原因:" + response.getResult().getMsg());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ result.put("success", false);
|
|
|
+ result.put("msg", "京东开放平台根据运单号查询运单详情接口!失败原因:" + response.getMsg());
|
|
|
+ }
|
|
|
+ } catch (LopException e) {
|
|
|
+ log.error("京东开放平台根据运单号查询运单详情接口:{}", e);
|
|
|
+ throw new ServiceException("京东开放平台获取商家二维码接口异常");
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|