|
@@ -0,0 +1,100 @@
|
|
|
|
|
+package com.ruoyi.logistics.service.impl;
|
|
|
|
|
+
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.ruoyi.common.redis.service.RedisIdGenerator;
|
|
|
|
|
+import com.ruoyi.logistics.config.SFExpressConfig;
|
|
|
|
|
+import com.ruoyi.logistics.domain.LogisticsOrder;
|
|
|
|
|
+import com.ruoyi.logistics.service.LogisticsService;
|
|
|
|
|
+import com.sf.csim.express.service.CallExpressServiceTools;
|
|
|
|
|
+import com.sf.csim.express.service.HttpClientUtil;
|
|
|
|
|
+import com.sf.csim.express.service.IServiceCodeStandard;
|
|
|
|
|
+import com.sf.csim.express.service.code.ExpressServiceCodeEnum;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
+
|
|
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
+
|
|
|
|
|
+@Service
|
|
|
|
|
+public class SFLogisticsService implements LogisticsService {
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private SFExpressConfig sfExpressConfig;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private RedisIdGenerator redisIdGenerator;
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String createOrder(LogisticsOrder logisticsOrder) throws UnsupportedEncodingException {
|
|
|
|
|
+ IServiceCodeStandard standardService = ExpressServiceCodeEnum.EXP_RECE_CREATE_ORDER; //下订单
|
|
|
|
|
+
|
|
|
|
|
+ CallExpressServiceTools tools=CallExpressServiceTools.getInstance();
|
|
|
|
|
+ Map<String, String> params = new HashMap<String, String>();
|
|
|
|
|
+ String timeStamp = String.valueOf(System.currentTimeMillis());
|
|
|
|
|
+ Map<String,Object> orderData= new HashMap<>();
|
|
|
|
|
+ orderData.put("language","zh_CN");
|
|
|
|
|
+ orderData.put("orderId",redisIdGenerator.generateUniqueId("RJSD"));//客户订单号,重复使用订单号时返回第一次下单成功时的运单信息
|
|
|
|
|
+ orderData.put("monthlyCard","7551234567");//月结账户
|
|
|
|
|
+ orderData.put("parcelQty",3);
|
|
|
|
|
+ //商品信息
|
|
|
|
|
+ List<Map<String,Object>> cargoDetails = new ArrayList<>();
|
|
|
|
|
+ Map cargo=new HashMap<>();
|
|
|
|
|
+ cargo.put("name","笔记本");
|
|
|
|
|
+ cargo.put("count",1);
|
|
|
|
|
+ cargo.put("unit","个");
|
|
|
|
|
+ cargo.put("weight",1.012);
|
|
|
|
|
+ cargo.put("amount",4999.189);
|
|
|
|
|
+ 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);
|
|
|
|
|
+ orderData.put("serviceList",serviceList);
|
|
|
|
|
+ //收寄双方信息
|
|
|
|
|
+ List<Map<String,Object>> contactInfoList = new ArrayList<>();
|
|
|
|
|
+ Map contactInfo1=new HashMap<>();
|
|
|
|
|
+ contactInfo1.put("address","河南省洛阳市洛龙区科技园街道和风雅叙");
|
|
|
|
|
+ contactInfo1.put("contact","张三");
|
|
|
|
|
+ contactInfo1.put("contactType",1);
|
|
|
|
|
+ contactInfo1.put("country","CN");
|
|
|
|
|
+ contactInfo1.put("postCode","580058");
|
|
|
|
|
+ contactInfo1.put("tel","15639072145");
|
|
|
|
|
+ contactInfoList.add(contactInfo1);
|
|
|
|
|
+ Map contactInfo=new HashMap<>();
|
|
|
|
|
+ contactInfo.put("address","河南省郑州市惠济区美景麟起城");
|
|
|
|
|
+ contactInfo.put("company","神州");
|
|
|
|
|
+ contactInfo.put("contact","小乔");
|
|
|
|
|
+ contactInfo.put("contactType",2);
|
|
|
|
|
+ contactInfo.put("country","CN");
|
|
|
|
|
+ contactInfo.put("tel","15539739074");
|
|
|
|
|
+ contactInfoList.add(contactInfo1);
|
|
|
|
|
+ contactInfoList.add(contactInfo);
|
|
|
|
|
+ orderData.put("contactInfoList",contactInfoList);
|
|
|
|
|
+
|
|
|
|
|
+ String msgData =tools.packageMsgData(standardService);
|
|
|
|
|
+ msgData= JSON.toJSONString(orderData);
|
|
|
|
|
+ params.put("partnerID", sfExpressConfig.getClientCode()); // 顾客编码 ,对应丰桥上获取的clientCode
|
|
|
|
|
+ params.put("requestID", UUID.randomUUID().toString().replace("-", ""));
|
|
|
|
|
+ params.put("serviceCode",standardService.getCode());// 接口服务码
|
|
|
|
|
+ params.put("timestamp", timeStamp);
|
|
|
|
|
+ params.put("msgData", msgData);
|
|
|
|
|
+ params.put("msgDigest", tools.getMsgDigest(msgData,timeStamp,sfExpressConfig.getCheckWord()));
|
|
|
|
|
+
|
|
|
|
|
+ // System.out.println(params.get("requestID"));
|
|
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ // System.out.println("====调用请求:" + params.get("msgData"));
|
|
|
|
|
+ System.out.println("====调用实际请求:" + params);
|
|
|
|
|
+ String result = HttpClientUtil.post(sfExpressConfig.getCurrentApiUrl(), params);
|
|
|
|
|
+
|
|
|
|
|
+ System.out.println("====调用丰桥的接口服务代码:" + String.valueOf(standardService.getCode()) + " 接口耗时:"+ String.valueOf(System.currentTimeMillis()-startTime)+"====");
|
|
|
|
|
+ System.out.println("===调用地址 ==="+sfExpressConfig.getCurrentApiUrl());
|
|
|
|
|
+ System.out.println("===顾客编码 ==="+sfExpressConfig.getClientCode());
|
|
|
|
|
+ System.out.println("===返回结果:" +result);
|
|
|
|
|
+
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|