Commit adb4585a authored by shiyu's avatar shiyu

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

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