Commit adb4585a authored by shiyu's avatar shiyu

顺丰查询物流轨迹需要带用户手机后4位号码

parent b9b5efe4
...@@ -97,6 +97,7 @@ public class RefreshLogisticsJob { ...@@ -97,6 +97,7 @@ public class RefreshLogisticsJob {
LogisticsRequestDto logisticsRequestDto = new LogisticsRequestDto(); LogisticsRequestDto logisticsRequestDto = new LogisticsRequestDto();
logisticsRequestDto.setLogisticsCode(distributionOrder.getLogisticsCode()); logisticsRequestDto.setLogisticsCode(distributionOrder.getLogisticsCode());
logisticsRequestDto.setWaybill(distributionOrder.getWaybill()); logisticsRequestDto.setWaybill(distributionOrder.getWaybill());
logisticsRequestDto.setReceiverPhone(distributionOrder.getReceiverPhone());
Result result = logisticsApi.findTrails(logisticsRequestDto); Result result = logisticsApi.findTrails(logisticsRequestDto);
if (!result.getSuccess()) { if (!result.getSuccess()) {
logger.error("订单号:{} 查询物流轨迹失败", orderId); logger.error("订单号:{} 查询物流轨迹失败", orderId);
......
package com.wwdz.ch.core.api; package com.wwdz.ch.core.api;
import com.wwdz.ch.core.consts.CommConsts;
import com.wwdz.ch.core.consts.CommonEnum; import com.wwdz.ch.core.consts.CommonEnum;
import com.wwdz.ch.core.consts.LogisticsEnum; import com.wwdz.ch.core.consts.LogisticsEnum;
import com.wwdz.ch.core.entity.LogisticsInfo; import com.wwdz.ch.core.entity.LogisticsInfo;
...@@ -7,9 +8,13 @@ import com.wwdz.ch.core.entity.LogisticsRequestDto; ...@@ -7,9 +8,13 @@ import com.wwdz.ch.core.entity.LogisticsRequestDto;
import com.wwdz.ch.core.entity.TrailInfo; import com.wwdz.ch.core.entity.TrailInfo;
import com.wwdz.ch.core.type.Result; import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.core.util.Base64; import com.wwdz.ch.core.util.Base64;
import com.wwdz.ch.db.dao.distribution.DistributionOrderDao;
import com.wwdz.ch.db.domain.distribution.DistributionOrder;
import com.xxdxxs.utils.JsonUtils; import com.xxdxxs.utils.JsonUtils;
import com.xxdxxs.utils.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.io.*; import java.io.*;
...@@ -30,6 +35,9 @@ public class LogisticsApi { ...@@ -30,6 +35,9 @@ public class LogisticsApi {
@Value("${dts.wx.apikey}") @Value("${dts.wx.apikey}")
private String APIKEY; private String APIKEY;
@Autowired
DistributionOrderDao distributionOrderDao;
private final static String GET_TRAIL_URL = "https://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx"; private final static String GET_TRAIL_URL = "https://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx";
...@@ -38,21 +46,22 @@ public class LogisticsApi { ...@@ -38,21 +46,22 @@ public class LogisticsApi {
*/ */
public Result findTrails(LogisticsRequestDto dto){ public Result findTrails(LogisticsRequestDto dto){
try { try {
String RequestData = "{" + Map<String, String> paramMap = new HashMap<>();
"'ShipperCode': '" paramMap.put("ShipperCode", dto.getLogisticsCode());
+ dto.getLogisticsCode() paramMap.put("LogisticCode", dto.getWaybill());
+ "'," if (LogisticsEnum.SF.getCode().equals(dto.getLogisticsCode())) {
+ if (StringUtils.hasLength(dto.getReceiverPhone())) {
"'LogisticCode': '" paramMap.put("CustomerName", dto.getReceiverPhone().substring( dto.getReceiverPhone().length() - 4));
+ dto.getWaybill() + "'," }
+ }
"}"; String requestData = JsonUtils.from(paramMap);
// 组装系统级参数 // 组装系统级参数
Map<String, String> params = new HashMap<String, String>(); Map<String, String> params = new HashMap<String, String>();
params.put("RequestData", urlEncoder(RequestData, "UTF-8")); params.put("RequestData", urlEncoder(requestData, "UTF-8"));
params.put("EBusinessID", KUAIDINIAO_ID); params.put("EBusinessID", KUAIDINIAO_ID);
params.put("RequestType", "8001"); params.put("RequestType", "8001");
String dataSign = encrypt(RequestData, APIKEY, "UTF-8"); String dataSign = encrypt(requestData, APIKEY, "UTF-8");
params.put("DataSign", urlEncoder(dataSign, "UTF-8")); params.put("DataSign", urlEncoder(dataSign, "UTF-8"));
params.put("DataType", "2"); params.put("DataType", "2");
String result = sendPost(GET_TRAIL_URL, params); String result = sendPost(GET_TRAIL_URL, params);
......
...@@ -12,6 +12,8 @@ public class LogisticsRequestDto implements Entity { ...@@ -12,6 +12,8 @@ public class LogisticsRequestDto implements Entity {
private String waybill; private String waybill;
private String receiverPhone;
/** /**
* 物流单号类型 * 物流单号类型
*/ */
......
...@@ -132,7 +132,7 @@ ...@@ -132,7 +132,7 @@
@project https://github.com/itfsw/mybatis-generator-plugin @project https://github.com/itfsw/mybatis-generator-plugin
--> -->
select select
'true' as QUERYID,
<if test="example.distinct"> <if test="example.distinct">
distinct distinct
</if> </if>
......
...@@ -45,6 +45,7 @@ public class LogisticsServiceImpl implements LogisticsService { ...@@ -45,6 +45,7 @@ public class LogisticsServiceImpl implements LogisticsService {
LogisticsRequestDto logisticsRequestDto = new LogisticsRequestDto(); LogisticsRequestDto logisticsRequestDto = new LogisticsRequestDto();
logisticsRequestDto.setLogisticsCode(distributionOrder.getLogisticsCode()); logisticsRequestDto.setLogisticsCode(distributionOrder.getLogisticsCode());
logisticsRequestDto.setWaybill(distributionOrder.getWaybill()); logisticsRequestDto.setWaybill(distributionOrder.getWaybill());
logisticsRequestDto.setReceiverPhone(distributionOrder.getReceiverPhone());
Result result = logisticsApi.findTrails(logisticsRequestDto); Result result = logisticsApi.findTrails(logisticsRequestDto);
if (result.getSuccess()) { if (result.getSuccess()) {
LogisticsInfo logisticsInfo = (LogisticsInfo) result.getData(); LogisticsInfo logisticsInfo = (LogisticsInfo) result.getData();
...@@ -74,6 +75,7 @@ public class LogisticsServiceImpl implements LogisticsService { ...@@ -74,6 +75,7 @@ public class LogisticsServiceImpl implements LogisticsService {
String logisticsCode = null; String logisticsCode = null;
String waybill = null; String waybill = null;
String receiverInfo = null; String receiverInfo = null;
LogisticsRequestDto logisticsRequestDto = new LogisticsRequestDto();
if (type == CommonEnum.LogisticsTypeEnum.FROM.getCode()) { if (type == CommonEnum.LogisticsTypeEnum.FROM.getCode()) {
IdentifyOrder identifyOrder = identifyOrderDao.findByDistributionOrderId(dto.getDistributionOrderId()); IdentifyOrder identifyOrder = identifyOrderDao.findByDistributionOrderId(dto.getDistributionOrderId());
logisticsCode = identifyOrder.getFromLogisticsCode(); logisticsCode = identifyOrder.getFromLogisticsCode();
...@@ -86,20 +88,23 @@ public class LogisticsServiceImpl implements LogisticsService { ...@@ -86,20 +88,23 @@ public class LogisticsServiceImpl implements LogisticsService {
} else { } else {
receiverInfo = CommConsts.SYSTEM_DEFAULT_ADDRESS; receiverInfo = CommConsts.SYSTEM_DEFAULT_ADDRESS;
} }
logisticsRequestDto.setReceiverPhone(distributionOrder.getReceiverPhone());
} else if (type == CommonEnum.LogisticsTypeEnum.DELIVERY.getCode()) { } else if (type == CommonEnum.LogisticsTypeEnum.DELIVERY.getCode()) {
DistributionOrder distributionOrder = distributionOrderDao.findById(dto.getDistributionOrderId()); DistributionOrder distributionOrder = distributionOrderDao.findById(dto.getDistributionOrderId());
logisticsCode = distributionOrder.getLogisticsCode(); logisticsCode = distributionOrder.getLogisticsCode();
waybill = distributionOrder.getWaybill(); waybill = distributionOrder.getWaybill();
receiverInfo = distributionOrder.getReceiverName() + "," + distributionOrder.getReceiverPhone() + "," + distributionOrder.getReceiverAddress(); receiverInfo = distributionOrder.getReceiverName() + "," + distributionOrder.getReceiverPhone() + "," + distributionOrder.getReceiverAddress();
logisticsRequestDto.setReceiverPhone(distributionOrder.getReceiverPhone());
} else if (type == CommonEnum.LogisticsTypeEnum.SEND_BACK.getCode()) { } else if (type == CommonEnum.LogisticsTypeEnum.SEND_BACK.getCode()) {
IdentifyOrder identifyOrder = identifyOrderDao.findByDistributionOrderId(dto.getDistributionOrderId()); IdentifyOrder identifyOrder = identifyOrderDao.findByDistributionOrderId(dto.getDistributionOrderId());
logisticsCode = identifyOrder.getOutLogisticsCode(); logisticsCode = identifyOrder.getOutLogisticsCode();
waybill = identifyOrder.getOutWaybill(); waybill = identifyOrder.getOutWaybill();
receiverInfo = identifyOrder.getReturnName() + "," + identifyOrder.getReturnPhone() + "," + identifyOrder.getReturnAddress(); receiverInfo = identifyOrder.getReturnName() + "," + identifyOrder.getReturnPhone() + "," + identifyOrder.getReturnAddress();
logisticsRequestDto.setReceiverPhone(identifyOrder.getReturnPhone());
} }
LogisticsRequestDto logisticsRequestDto = new LogisticsRequestDto();
logisticsRequestDto.setLogisticsCode(logisticsCode); logisticsRequestDto.setLogisticsCode(logisticsCode);
logisticsRequestDto.setWaybill(waybill); logisticsRequestDto.setWaybill(waybill);
Result result = logisticsApi.findTrails(logisticsRequestDto); Result result = logisticsApi.findTrails(logisticsRequestDto);
if (result.getSuccess()) { if (result.getSuccess()) {
LogisticsInfo logisticsInfo = (LogisticsInfo) result.getData(); LogisticsInfo logisticsInfo = (LogisticsInfo) result.getData();
......
...@@ -48,7 +48,7 @@ public class SendMsgFromExcelJob { ...@@ -48,7 +48,7 @@ public class SendMsgFromExcelJob {
private String env; private String env;
// 每年8月14日晚上19点执行一次 // 每年8月14日晚上19点执行一次
@Scheduled(cron = "0 20 19 14 8 ?") // @Scheduled(cron = "0 20 19 14 8 ?")
public void executeTask() { public void executeTask() {
if ("dev".equals(env)) { if ("dev".equals(env)) {
logger.info(">>>>>>>>>>>>>>>>>>>>>>> dev环境, 不执行给指定类目用户发送通知任务<<<<<<<<<<<<<<<<<<<<<"); logger.info(">>>>>>>>>>>>>>>>>>>>>>> dev环境, 不执行给指定类目用户发送通知任务<<<<<<<<<<<<<<<<<<<<<");
...@@ -93,7 +93,7 @@ public class SendMsgFromExcelJob { ...@@ -93,7 +93,7 @@ public class SendMsgFromExcelJob {
msg = "如是画苑·中美协画家专场开始啦,请前往"+ url + "查看"; msg = "如是画苑·中美协画家专场开始啦,请前往"+ url + "查看";
} }
if (StringUtils.hasLength(msg)) { if (StringUtils.hasLength(msg)) {
aliSmsSender.sendSms(phone, msg); // aliSmsSender.sendSms(phone, msg);
logger.info("手机号: {}, msg: {}, 发送短信成功", phone, msg); logger.info("手机号: {}, msg: {}, 发送短信成功", phone, msg);
} }
} }
......
...@@ -29,8 +29,9 @@ public class LogisticsApiTest { ...@@ -29,8 +29,9 @@ public class LogisticsApiTest {
@Test @Test
public void findTrails() { public void findTrails() {
LogisticsRequestDto dto = new LogisticsRequestDto(); LogisticsRequestDto dto = new LogisticsRequestDto();
dto.setLogisticsCode("EMS"); dto.setLogisticsCode("SF");
dto.setWaybill("9858779957787"); dto.setWaybill("SF1440039031603");
dto.setReceiverPhone("13817817481");
Result result = logisticsApi.findTrails(dto); Result result = logisticsApi.findTrails(dto);
logger.info("物流轨迹: {}" + result); logger.info("物流轨迹: {}" + result);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment