|
@@ -1,5 +1,6 @@
|
|
|
package com.ruoyi.logistics.service.impl;
|
|
package com.ruoyi.logistics.service.impl;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.lop.open.api.sdk.DefaultDomainApiClient;
|
|
import com.lop.open.api.sdk.DefaultDomainApiClient;
|
|
|
import com.lop.open.api.sdk.LopException;
|
|
import com.lop.open.api.sdk.LopException;
|
|
@@ -19,7 +20,9 @@ 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.EcapV1OrdersModifyLopResponse;
|
|
|
import com.lop.open.api.sdk.response.ECAP.EcapV1OrdersPrecheckLopResponse;
|
|
import com.lop.open.api.sdk.response.ECAP.EcapV1OrdersPrecheckLopResponse;
|
|
|
import com.ruoyi.common.core.utils.DateUtils;
|
|
import com.ruoyi.common.core.utils.DateUtils;
|
|
|
|
|
+import com.ruoyi.common.core.utils.StringUtils;
|
|
|
import com.ruoyi.logistics.config.JDExpressConfig;
|
|
import com.ruoyi.logistics.config.JDExpressConfig;
|
|
|
|
|
+import com.ruoyi.logistics.constant.JDDictConstants;
|
|
|
import com.ruoyi.logistics.constant.SysConfigConstants;
|
|
import com.ruoyi.logistics.constant.SysConfigConstants;
|
|
|
import com.ruoyi.logistics.domain.BizWaybillOrder;
|
|
import com.ruoyi.logistics.domain.BizWaybillOrder;
|
|
|
import com.ruoyi.logistics.service.LogisticsService;
|
|
import com.ruoyi.logistics.service.LogisticsService;
|
|
@@ -29,7 +32,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
@Service
|
|
@Service
|
|
@@ -116,7 +121,7 @@ public class JDLogisticsService implements LogisticsService {
|
|
|
//订单信息
|
|
//订单信息
|
|
|
com.lop.open.api.sdk.domain.ECAP.CommonCreateOrderApi.commonCreateOrderV1.CommonCreateOrderRequest requestDTO = new com.lop.open.api.sdk.domain.ECAP.CommonCreateOrderApi.commonCreateOrderV1.CommonCreateOrderRequest();
|
|
com.lop.open.api.sdk.domain.ECAP.CommonCreateOrderApi.commonCreateOrderV1.CommonCreateOrderRequest requestDTO = new com.lop.open.api.sdk.domain.ECAP.CommonCreateOrderApi.commonCreateOrderV1.CommonCreateOrderRequest();
|
|
|
requestDTO.setOrderId(bizWaybillOrder.getWaybillNo());
|
|
requestDTO.setOrderId(bizWaybillOrder.getWaybillNo());
|
|
|
- requestDTO.setOrderOrigin(1);
|
|
|
|
|
|
|
+ requestDTO.setOrderOrigin(getOrderOrigin(bizWaybillOrder.getProductCode()));
|
|
|
requestDTO.setCustomerCode(sysConfigService.selectConfigByKey(SysConfigConstants.JD_LOGISTICS_CUSTOMERCODE));
|
|
requestDTO.setCustomerCode(sysConfigService.selectConfigByKey(SysConfigConstants.JD_LOGISTICS_CUSTOMERCODE));
|
|
|
requestDTO.setSettleType(3);
|
|
requestDTO.setSettleType(3);
|
|
|
requestDTO.setPickupStartTime(bizWaybillOrder.getPickupTime().getTime());
|
|
requestDTO.setPickupStartTime(bizWaybillOrder.getPickupTime().getTime());
|
|
@@ -127,6 +132,24 @@ public class JDLogisticsService implements LogisticsService {
|
|
|
com.lop.open.api.sdk.domain.ECAP.CommonCreateOrderApi.commonCreateOrderV1.CommonProductInfo productInfo = new com.lop.open.api.sdk.domain.ECAP.CommonCreateOrderApi.commonCreateOrderV1.CommonProductInfo();
|
|
com.lop.open.api.sdk.domain.ECAP.CommonCreateOrderApi.commonCreateOrderV1.CommonProductInfo productInfo = new com.lop.open.api.sdk.domain.ECAP.CommonCreateOrderApi.commonCreateOrderV1.CommonProductInfo();
|
|
|
productInfo.setProductCode(bizWaybillOrder.getProductCode());
|
|
productInfo.setProductCode(bizWaybillOrder.getProductCode());
|
|
|
|
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(bizWaybillOrder.getAddedService())) {
|
|
|
|
|
+ JSONObject addedJson = JSON.parseObject(bizWaybillOrder.getAddedService());
|
|
|
|
|
+ List<com.lop.open.api.sdk.domain.ECAP.CommonCreateOrderApi.commonCreateOrderV1.CommonProductInfo> addedProducts = new ArrayList<>();
|
|
|
|
|
+ if (!addedJson.isEmpty()) {
|
|
|
|
|
+ addedJson.keySet().forEach(key -> {
|
|
|
|
|
+ com.lop.open.api.sdk.domain.ECAP.CommonCreateOrderApi.commonCreateOrderV1.CommonProductInfo addedProduct = new com.lop.open.api.sdk.domain.ECAP.CommonCreateOrderApi.commonCreateOrderV1.CommonProductInfo();
|
|
|
|
|
+ addedProduct.setProductCode(key);
|
|
|
|
|
+
|
|
|
|
|
+ addedProduct.setProductAttrs(getProductAttrs(requestDTO.getOrderOrigin(), key, addedJson.getString(key)));
|
|
|
|
|
+
|
|
|
|
|
+ addedProducts.add(addedProduct);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ productInfo.setAddedProducts(addedProducts);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
//货物信息
|
|
//货物信息
|
|
|
List<CommonCargoInfo> cargoes = new ArrayList<>();
|
|
List<CommonCargoInfo> cargoes = new ArrayList<>();
|
|
|
CommonCargoInfo cargoInfo = new CommonCargoInfo();
|
|
CommonCargoInfo cargoInfo = new CommonCargoInfo();
|
|
@@ -261,4 +284,51 @@ public class JDLogisticsService implements LogisticsService {
|
|
|
}
|
|
}
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ private Integer getOrderOrigin(String productCode) {
|
|
|
|
|
+ int orderOrigin = 1;
|
|
|
|
|
+ if (productCode.equals(JDDictConstants.PRODUCT_CODE_ED_M_0001) || productCode.equals(JDDictConstants.PRODUCT_CODE_ED_M_0002)) {
|
|
|
|
|
+ orderOrigin = 1;
|
|
|
|
|
+ } else if (productCode.equals(JDDictConstants.PRODUCT_CODE_FR_M_0004)) {
|
|
|
|
|
+ orderOrigin = 4;
|
|
|
|
|
+ }
|
|
|
|
|
+ return orderOrigin;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 封装增值服务参数
|
|
|
|
|
+ * @param addedProductCode
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ private Map<String, String> getProductAttrs(Integer orderOrigin, String addedProductCode, String value) {
|
|
|
|
|
+ if (StringUtils.isBlank(addedProductCode)) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ Map<String, String> productAttrs = new HashMap<>();
|
|
|
|
|
+ if (orderOrigin == 1) {
|
|
|
|
|
+ if (addedProductCode.equals("ed-a-0002")) {
|
|
|
|
|
+ productAttrs.put("guaranteeMoney", value);
|
|
|
|
|
+ return productAttrs;
|
|
|
|
|
+ } else if (addedProductCode.equals("ed-a-0010")) {
|
|
|
|
|
+ productAttrs.put("reReceiveMode", "[\"electronic\"]");
|
|
|
|
|
+ productAttrs.put("reReceiveType", "[\"electronicStubForm\"]");
|
|
|
|
|
+ return productAttrs;
|
|
|
|
|
+ } else if (addedProductCode.equals("ed-a-0011")) {
|
|
|
|
|
+ productAttrs.put("packagingType", value);
|
|
|
|
|
+ return productAttrs;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (orderOrigin == 4) {
|
|
|
|
|
+ if (addedProductCode.equals("fr-a-0002")) {
|
|
|
|
|
+ productAttrs.put("guaranteeMoney", value);
|
|
|
|
|
+ return productAttrs;
|
|
|
|
|
+ } else if (addedProductCode.equals("fr-a-0007")) {
|
|
|
|
|
+ productAttrs.put("reReceiveMode", value);
|
|
|
|
|
+ return productAttrs;
|
|
|
|
|
+ } else if (addedProductCode.equals("fr-a-0005")) {
|
|
|
|
|
+ productAttrs.put("packagingType", value);
|
|
|
|
|
+ return productAttrs;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|