|
|
@@ -2,6 +2,9 @@ package com.ruoyi.logistics.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.fasterxml.jackson.databind.type.TypeFactory;
|
|
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
|
import com.ruoyi.common.redis.service.RedisIdGenerator;
|
|
|
import com.ruoyi.logistics.config.SFExpressConfig;
|
|
|
@@ -59,9 +62,9 @@ public class SFLogisticsService implements LogisticsService {
|
|
|
1 顺丰特快
|
|
|
2 顺丰标快
|
|
|
6 顺丰即日*/
|
|
|
- msgData.put("expressTypeId", 1);
|
|
|
+ msgData.put("expressTypeId", bizWaybillOrder.getProductCode());
|
|
|
//包裹数 未定义 非必填
|
|
|
- msgData.put("parcelQty", 1);
|
|
|
+ msgData.put("parcelQty", bizWaybillOrder.getGoodsQty());
|
|
|
//收寄方地址参数
|
|
|
List<Map<String, Object>> contactInfoList = new ArrayList<>();
|
|
|
Map<String, Object> Consignor = new HashMap<>();
|
|
|
@@ -103,7 +106,7 @@ public class SFLogisticsService implements LogisticsService {
|
|
|
* @date 2026-02-02
|
|
|
*/
|
|
|
@Override
|
|
|
- public JSONObject createOrder(BizWaybillOrder bizWaybillOrder) {
|
|
|
+ public JSONObject createOrder(BizWaybillOrder bizWaybillOrder) throws JsonProcessingException {
|
|
|
IServiceCodeStandard standardService = ExpressServiceCodeEnum.EXP_RECE_CREATE_ORDER; //下订单
|
|
|
CallExpressServiceTools tools=CallExpressServiceTools.getInstance();
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
@@ -113,8 +116,10 @@ public class SFLogisticsService implements LogisticsService {
|
|
|
//预下单 已返回订单id
|
|
|
orderData.put("orderId",bizWaybillOrder.getWaybillNo());
|
|
|
orderData.put("monthlyCard",sfExpressConfig.getMonthlyCord());//月结账户
|
|
|
- //包裹数目前字段没有
|
|
|
- orderData.put("parcelQty",1);
|
|
|
+ //包裹数
|
|
|
+ orderData.put("parcelQty",bizWaybillOrder.getGoodsQty());
|
|
|
+ //产品类别
|
|
|
+ orderData.put("expressTypeId",bizWaybillOrder.getProductCode());
|
|
|
//商品信息
|
|
|
List<Map<String,Object>> cargoDetails = new ArrayList<>();
|
|
|
Map cargo=new HashMap<>();
|
|
|
@@ -123,13 +128,8 @@ public class SFLogisticsService implements LogisticsService {
|
|
|
cargo.put("weight",bizWaybillOrder.getGoodsWeight());
|
|
|
cargoDetails.add(cargo);
|
|
|
orderData.put("cargoDetails",cargoDetails);
|
|
|
-
|
|
|
- //增值服务信息 serviceList":[{"name":"INSURE","value":"500"}]
|
|
|
- List<Map<String,Object>> serviceList = new ArrayList<>();
|
|
|
- Map service=new HashMap<>();
|
|
|
- service.put("name","INSURE");
|
|
|
- service.put("value","500");
|
|
|
- serviceList.add(service);
|
|
|
+ //将增值服务字符串转换完增值服务参数
|
|
|
+ List<Map<String,Object>> serviceList=getAddedProducts(bizWaybillOrder.getAddedService());
|
|
|
orderData.put("serviceList",serviceList);
|
|
|
//收寄双方信息
|
|
|
List<Map<String,Object>> contactInfoList = new ArrayList<>();
|
|
|
@@ -163,7 +163,8 @@ public class SFLogisticsService implements LogisticsService {
|
|
|
JSONObject jsonObject = JSON.parseObject(result).getJSONObject("apiResultData");
|
|
|
JSONObject resultInfo = new JSONObject();
|
|
|
if (jsonObject != null && jsonObject.containsKey("success") && jsonObject.getBooleanValue("success")) {
|
|
|
- resultInfo.put("success", true);
|
|
|
+ resultInfo.put("success", true); //.getJSONObject("waybillNoInfoList")
|
|
|
+ resultInfo.put("data", jsonObject.getJSONObject("msgData").getJSONArray("waybillNoInfoList"));
|
|
|
resultInfo.put("msg", "下单成功!");
|
|
|
return resultInfo;
|
|
|
} else {
|
|
|
@@ -179,6 +180,39 @@ public class SFLogisticsService implements LogisticsService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private List<Map<String, Object>> getAddedProducts(String addedService) throws JsonProcessingException {
|
|
|
+ List<Map<String, Object>> serviceList = new ArrayList<>();
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ TypeFactory typeFactory = objectMapper.getTypeFactory();
|
|
|
+ Map<String, String> serviceMap = objectMapper.readValue(addedService, typeFactory.constructType(Map.class));
|
|
|
+
|
|
|
+ // 遍历Map的key
|
|
|
+ Set<String> keys = serviceMap.keySet();
|
|
|
+ for (String key : keys) {
|
|
|
+ switch (key) {
|
|
|
+ case "isPack":
|
|
|
+ break;
|
|
|
+ case "guaranteeMoney": //顺丰基础包
|
|
|
+ Map INSURE = new HashMap<>();
|
|
|
+ INSURE.put("name", "INSURE");
|
|
|
+ INSURE.put("value", serviceMap.get(key));
|
|
|
+ serviceList.add(INSURE);
|
|
|
+ case "isOverLongWeight": //超长超重
|
|
|
+ break;
|
|
|
+
|
|
|
+ case "isReceiptCollect": //签单返回
|
|
|
+ break;
|
|
|
+ case "isWoodenCrate": //打木架
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ log.info("收到未定义的增值服务代码: {}", key);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return serviceList;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 顺丰物流取消订单接口
|