提交 57f14fea authored 作者: 000516's avatar 000516

物流回单添加京东TC单据,回写签收时间,回单状态统一重置为未回单(无回单图片)

...@@ -4,7 +4,7 @@ import cn.hutool.core.date.DateUtil; ...@@ -4,7 +4,7 @@ import cn.hutool.core.date.DateUtil;
import com.sfa.common.core.web.controller.BaseController; import com.sfa.common.core.web.controller.BaseController;
import com.sfa.job.pojo.response.FinanceOrderDetailUpdateDto; import com.sfa.job.pojo.response.FinanceOrderDetailUpdateDto;
import com.sfa.job.pojo.response.SyncOrderDetailDto; import com.sfa.job.pojo.response.SyncOrderDetailDto;
import com.sfa.job.service.order.FinanceOrderSyncService; import com.sfa.job.service.order.IFinanceOrderSyncService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -23,7 +23,7 @@ import java.util.Date; ...@@ -23,7 +23,7 @@ import java.util.Date;
@RequestMapping("/finance/order") @RequestMapping("/finance/order")
public class FinanceOrderDetailSyncController extends BaseController { public class FinanceOrderDetailSyncController extends BaseController {
@Autowired @Autowired
private FinanceOrderSyncService syncService; private IFinanceOrderSyncService syncService;
@GetMapping("/syncWdtOrderDetail") @GetMapping("/syncWdtOrderDetail")
public SyncOrderDetailDto syncWangdiantongOrderDetail(Date startTime, Date endTime) { public SyncOrderDetailDto syncWangdiantongOrderDetail(Date startTime, Date endTime) {
......
package com.sfa.job.controller.order; package com.sfa.job.controller.order;
import com.sfa.job.pojo.response.SyncOrderDetailDto; import com.sfa.job.pojo.response.SyncOrderDetailDto;
import com.sfa.job.service.order.WdtQimenOrderSyncService; import com.sfa.job.service.order.IWdtQimenOrderSyncService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -22,7 +22,7 @@ import java.util.Date; ...@@ -22,7 +22,7 @@ import java.util.Date;
public class WdtQimenOrderController { public class WdtQimenOrderController {
@Autowired @Autowired
private WdtQimenOrderSyncService orderQimenSyncService; private IWdtQimenOrderSyncService orderQimenSyncService;
@GetMapping("/sync") @GetMapping("/sync")
......
...@@ -7,7 +7,7 @@ import lombok.Getter; ...@@ -7,7 +7,7 @@ import lombok.Getter;
* @date : 2025-08-13 10 * @date : 2025-08-13 10
* @describe : * @describe :
*/ */
public interface KyeEnum { public interface SentReceiptEnum {
/** /**
* 回单状态类型 * 回单状态类型
...@@ -56,4 +56,21 @@ public interface KyeEnum { ...@@ -56,4 +56,21 @@ public interface KyeEnum {
return "10".equals(type) || "30".equals(type); return "10".equals(type) || "30".equals(type);
} }
} }
/**
* 回单通用类型
*/
@Getter
enum ReceiptEnum {
/**
* 已签收未回单
*/
NO("未回单");
private String desc;
ReceiptEnum(String desc) {
this.desc = desc;
}
}
} }
...@@ -2,6 +2,7 @@ package com.sfa.job.pojo.response; ...@@ -2,6 +2,7 @@ package com.sfa.job.pojo.response;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
...@@ -10,6 +11,7 @@ import java.util.List; ...@@ -10,6 +11,7 @@ import java.util.List;
/** /**
* T100出货单中的物流单据 * T100出货单中的物流单据
*/ */
@Accessors(chain = true)
@Data @Data
public class OrdersSentDto implements Serializable { public class OrdersSentDto implements Serializable {
/** /**
......
...@@ -6,7 +6,7 @@ import com.sfa.job.pojo.response.SyncOrderDetailDto; ...@@ -6,7 +6,7 @@ import com.sfa.job.pojo.response.SyncOrderDetailDto;
import java.util.Date; import java.util.Date;
public interface FinanceOrderSyncService { public interface IFinanceOrderSyncService {
SyncOrderDetailDto syncWdtOrder(Date startTime, Date endTime, Integer syncType); SyncOrderDetailDto syncWdtOrder(Date startTime, Date endTime, Integer syncType);
SyncOrderDetailDto syncWdtRefundOrder(Date startTime, Date endTime, Integer syncType); SyncOrderDetailDto syncWdtRefundOrder(Date startTime, Date endTime, Integer syncType);
......
...@@ -5,6 +5,6 @@ import com.sfa.job.pojo.response.SyncOrderDetailDto; ...@@ -5,6 +5,6 @@ import com.sfa.job.pojo.response.SyncOrderDetailDto;
import java.util.Date; import java.util.Date;
public interface WdtQimenOrderSyncService { public interface IWdtQimenOrderSyncService {
SyncOrderDetailDto syncWdtQimenOrder(Date startTime, Date endTime, Integer syncType, Long pageSize); SyncOrderDetailDto syncWdtQimenOrder(Date startTime, Date endTime, Integer syncType, Long pageSize);
} }
...@@ -15,7 +15,7 @@ import com.sfa.job.domain.order.wq.FinanceOrderCostWq; ...@@ -15,7 +15,7 @@ import com.sfa.job.domain.order.wq.FinanceOrderCostWq;
import com.sfa.job.pojo.request.WdtOrderQueryVO; import com.sfa.job.pojo.request.WdtOrderQueryVO;
import com.sfa.job.pojo.request.WdtRefundQueryVO; import com.sfa.job.pojo.request.WdtRefundQueryVO;
import com.sfa.job.pojo.response.*; import com.sfa.job.pojo.response.*;
import com.sfa.job.service.order.FinanceOrderSyncService; import com.sfa.job.service.order.IFinanceOrderSyncService;
import com.sfa.job.util.WangdiantongUtil; import com.sfa.job.util.WangdiantongUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
...@@ -36,7 +36,7 @@ import java.util.stream.Collectors; ...@@ -36,7 +36,7 @@ import java.util.stream.Collectors;
@DS("bi") @DS("bi")
@Slf4j @Slf4j
@Service @Service
public class FinanceOrderSyncServiceImpl implements FinanceOrderSyncService { public class FinanceOrderSyncServiceImpl implements IFinanceOrderSyncService {
@Autowired @Autowired
WangdiantongUtil wangdiantongUtil; WangdiantongUtil wangdiantongUtil;
......
...@@ -6,9 +6,10 @@ import com.sfa.common.core.enums.ECode; ...@@ -6,9 +6,10 @@ import com.sfa.common.core.enums.ECode;
import com.sfa.common.core.exception.ServiceException; import com.sfa.common.core.exception.ServiceException;
import com.sfa.common.core.utils.DateUtils; import com.sfa.common.core.utils.DateUtils;
import com.sfa.job.domain.order.dao.IOrdersSentDao; import com.sfa.job.domain.order.dao.IOrdersSentDao;
import com.sfa.job.enums.KyeEnum; import com.sfa.job.enums.SentReceiptEnum;
import com.sfa.job.pojo.response.OrdersSentDto; import com.sfa.job.pojo.response.OrdersSentDto;
import com.sfa.job.service.order.IOrdersSentQueryService; import com.sfa.job.service.order.IOrdersSentQueryService;
import com.sfa.job.util.JdtcUtil;
import com.sfa.job.util.KyeUtil; import com.sfa.job.util.KyeUtil;
import com.sfa.job.util.QinCeUtils; import com.sfa.job.util.QinCeUtils;
import com.sfa.job.util.aliyun.OssUtil; import com.sfa.job.util.aliyun.OssUtil;
...@@ -17,10 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -17,10 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.util.ArrayList; import java.util.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -40,6 +38,8 @@ public class OrdersSentQueryServiceImpl implements IOrdersSentQueryService { ...@@ -40,6 +38,8 @@ public class OrdersSentQueryServiceImpl implements IOrdersSentQueryService {
private KyeUtil kyeUtil; private KyeUtil kyeUtil;
@Autowired @Autowired
private OssUtil ossUtil; private OssUtil ossUtil;
@Autowired
private JdtcUtil jdtcUtil;
@Override @Override
public void ordersSentToQince() { public void ordersSentToQince() {
...@@ -68,8 +68,59 @@ public class OrdersSentQueryServiceImpl implements IOrdersSentQueryService { ...@@ -68,8 +68,59 @@ public class OrdersSentQueryServiceImpl implements IOrdersSentQueryService {
// 按物流公司分类 // 按物流公司分类
Map<String, List<OrdersSentDto>> transportMap = sents.stream().collect(Collectors.groupingBy(OrdersSentDto::getTransport)); Map<String, List<OrdersSentDto>> transportMap = sents.stream().collect(Collectors.groupingBy(OrdersSentDto::getTransport));
getOrderSentReceiptBy109(transportMap.get("109")); getOrderSentReceiptBy109(transportMap.get("109"));
getOrderSentReceiptBy134(transportMap.get("134"));
}
/**
* 134-京东TC回单
*/
private void getOrderSentReceiptBy134(List<OrdersSentDto> ordersSentDtos) {
if (CollectionUtils.isEmpty(ordersSentDtos)) {
log.info("[134-京东TC]暂无,需回单单据");
return;
}
// 填写Object完整路径(不包含Bucket名称),例:[path]/[文件名.扩展名]
// String ossON = "wuliu/" + DateUtils.getYearMonth() + "/京东TC/";
List<List<OrdersSentDto>> split = ordersSentDtos.stream().collect(Collectors.groupingBy(it -> ordersSentDtos.indexOf(it) / 20)).values().stream().collect(Collectors.toList());
log.info("[134-京东TC]需回单{}张,分{}组", ordersSentDtos.size(), split.size());
for (List<OrdersSentDto> dtos : split) {
try {
List<String> exNos = dtos.stream().map(it -> it.getExpressNo()).collect(Collectors.toList());
JSONArray waybills = jdtcUtil.orderQuery(exNos);
if (CollectionUtils.isEmpty(waybills)) {
log.info("[134-京东TC]以上批次,未查询到物流信息");
continue;
}
log.info("[134-京东TC]以上批次,查询到{}条物流信息", waybills.size());
for (Object waybill : waybills) {
disReceiptBy134((JSONObject) waybill, null);
}
} catch (Exception e) {
log.error("[134-京东TC]忽略异常:{}",e.getMessage());
}
}
}
private void disReceiptBy134(JSONObject jdInfo, String ossON) {
String orderStatus = jdInfo.getString("orderStatus");
if (!"妥投".equals(orderStatus)){
return;
}
OrdersSentDto ordersSentDto = new OrdersSentDto()
.setExpressNo(jdInfo.getString("waybillCode"))
.setOperateEndDatetime(jdInfo.getDate("orderTime"))
.setReceiptFlag(SentReceiptEnum.ReceiptEnum.NO.getDesc());
/**
* 京东回单照片暂无获取API
*/
ordersSentDao.updateByExpressNo(ordersSentDto);
} }
/**
* 109-跨越回单
*/
private void getOrderSentReceiptBy109(List<OrdersSentDto> ordersSentDtos) { private void getOrderSentReceiptBy109(List<OrdersSentDto> ordersSentDtos) {
if (CollectionUtils.isEmpty(ordersSentDtos)) { if (CollectionUtils.isEmpty(ordersSentDtos)) {
log.info("[109-跨越]暂无,需回单单据"); log.info("[109-跨越]暂无,需回单单据");
...@@ -82,24 +133,27 @@ public class OrdersSentQueryServiceImpl implements IOrdersSentQueryService { ...@@ -82,24 +133,27 @@ public class OrdersSentQueryServiceImpl implements IOrdersSentQueryService {
log.info("[109-跨越]需回单{}张,分{}组",ordersSentDtos.size(),split.size()); log.info("[109-跨越]需回单{}张,分{}组",ordersSentDtos.size(),split.size());
for (List<OrdersSentDto> os : split) { for (List<OrdersSentDto> os : split) {
List<String> exNos = os.stream().map(it -> it.getExpressNo()).collect(Collectors.toList()); try {
log.info("[109-跨越]开始处理:{}",JSONObject.toJSONString(exNos)); List<String> exNos = os.stream().map(it -> it.getExpressNo()).collect(Collectors.toList());
log.info("[109-跨越]开始处理:{}",JSONObject.toJSONString(exNos));
JSONArray waybillBaseInfo = kyeUtil.getWaybillBaseInfo(exNos);
if (CollectionUtils.isEmpty(waybillBaseInfo)){ JSONArray waybillBaseInfo = kyeUtil.getWaybillBaseInfo(exNos);
log.info("[109-跨越]以上批次,未查询到物流信息"); if (CollectionUtils.isEmpty(waybillBaseInfo)){
continue; log.info("[109-跨越]以上批次,未查询到物流信息");
} continue;
}
log.info("[109-跨越]以上批次,查询到{}条物流信息",waybillBaseInfo.size()); log.info("[109-跨越]以上批次,查询到{}条物流信息",waybillBaseInfo.size());
for (Object o : waybillBaseInfo) { for (Object o : waybillBaseInfo) {
disReceipt((JSONObject) o,ossON); disReceiptBy109((JSONObject) o,ossON);
}
}catch (Exception e) {
log.error("[109-跨越]忽略异常:{}",e.getMessage());
} }
} }
} }
private void disReceipt(JSONObject infoJson,String ossON){ private void disReceiptBy109(JSONObject infoJson,String ossON) throws Exception {
// 判断物流单是否已签收,未签收数据不处理 // 判断物流单是否已签收,未签收数据不处理
Date operateEndTime = infoJson.getDate("operateEndTime"); Date operateEndTime = infoJson.getDate("operateEndTime");
if (operateEndTime == null){ if (operateEndTime == null){
...@@ -107,33 +161,31 @@ public class OrdersSentQueryServiceImpl implements IOrdersSentQueryService { ...@@ -107,33 +161,31 @@ public class OrdersSentQueryServiceImpl implements IOrdersSentQueryService {
} }
String expressNo = infoJson.getString("waybillNumber"); String expressNo = infoJson.getString("waybillNumber");
String receiptFlag = infoJson.getString("receiptFlag"); String receiptFlag = infoJson.getString("receiptFlag");
OrdersSentDto ordersSentDto = new OrdersSentDto(); OrdersSentDto ordersSentDto = new OrdersSentDto()
ordersSentDto.setExpressNo(expressNo); .setExpressNo(expressNo)
ordersSentDto.setOperateEndDatetime(operateEndTime); .setOperateEndDatetime(operateEndTime)
ordersSentDto.setReceiptFlag(KyeEnum.KyeReceiptEnum.getDesc(receiptFlag)); .setReceiptFlag(SentReceiptEnum.KyeReceiptEnum.getDesc(receiptFlag));
/** /**
* 回单类型为回单原件、回单照片时查询照片,否则跳过 * 回单类型为回单原件、回单照片时查询照片,否则跳过
*/ */
if (!KyeEnum.KyeReceiptEnum.hasPhoto(receiptFlag)){ if (!SentReceiptEnum.KyeReceiptEnum.hasPhoto(receiptFlag)){
ordersSentDao.updateByExpressNo(ordersSentDto); ordersSentDao.updateByExpressNo(ordersSentDto);
return; return;
} }
JSONArray objects = kyeUtil.queryWaybillPicture(expressNo); JSONArray objects = kyeUtil.queryWaybillPicture(expressNo);
if (CollectionUtils.isEmpty(objects)){ if (!CollectionUtils.isEmpty(objects)){
ordersSentDao.updateByExpressNo(ordersSentDto); List<String> urls = new ArrayList<>();
return; for (Object object : objects) {
} JSONObject jsonObject = (JSONObject) object;
List<String> urls = new ArrayList<>(); String url = jsonObject.getString("url");
for (Object object : objects) { String originalName = jsonObject.getString("originalName");
JSONObject jsonObject = (JSONObject) object; String ossUrl = ossUtil.uploadPhotoByte(url, ossON + originalName);
String url = jsonObject.getString("url"); urls.add(ossUrl);
String originalName = jsonObject.getString("originalName"); }
String ossUrl = ossUtil.uploadPhotoByte(url, ossON + originalName); ordersSentDto.setReceiptPhoto(JSONObject.toJSONString(urls));
urls.add(ossUrl);
} }
ordersSentDto.setReceiptPhoto(JSONObject.toJSONString(urls));
ordersSentDao.updateByExpressNo(ordersSentDto); ordersSentDao.updateByExpressNo(ordersSentDto);
} }
......
...@@ -19,7 +19,7 @@ import com.sfa.job.pojo.order.response.WdtQimenResponseDto; ...@@ -19,7 +19,7 @@ import com.sfa.job.pojo.order.response.WdtQimenResponseDto;
import com.sfa.job.pojo.order.response.WdtSalesTradeQueryQueryWithDetailDto; import com.sfa.job.pojo.order.response.WdtSalesTradeQueryQueryWithDetailDto;
import com.sfa.job.pojo.response.CollectOrderLogDto; import com.sfa.job.pojo.response.CollectOrderLogDto;
import com.sfa.job.pojo.response.SyncOrderDetailDto; import com.sfa.job.pojo.response.SyncOrderDetailDto;
import com.sfa.job.service.order.WdtQimenOrderSyncService; import com.sfa.job.service.order.IWdtQimenOrderSyncService;
import com.sfa.job.util.WdtQimenUtil; import com.sfa.job.util.WdtQimenUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
...@@ -39,7 +39,7 @@ import java.util.*; ...@@ -39,7 +39,7 @@ import java.util.*;
@DS("bi") @DS("bi")
@Slf4j @Slf4j
@Service @Service
public class WdtQimenOrderSyncServiceImpl implements WdtQimenOrderSyncService { public class WdtQimenOrderSyncServiceImpl implements IWdtQimenOrderSyncService {
@Autowired @Autowired
WdtQimenOrderDetailDao orderDetailDao; WdtQimenOrderDetailDao orderDetailDao;
@Autowired @Autowired
......
package com.sfa.job.util; package com.sfa.job.util;
import cn.hutool.core.date.DatePattern;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
...@@ -18,11 +19,7 @@ import java.security.GeneralSecurityException; ...@@ -18,11 +19,7 @@ import java.security.GeneralSecurityException;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.OffsetTime; import java.time.OffsetTime;
import java.time.format.DateTimeFormatter; import java.util.*;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/** /**
* @author : liqiulin * @author : liqiulin
...@@ -36,64 +33,35 @@ public class JdtcUtil { ...@@ -36,64 +33,35 @@ public class JdtcUtil {
* =================== JDTC API - config =================== * =================== JDTC API - config ===================
*/ */
@Value("${jdtc.url}") @Value("${jdtc.url}")
private String JDTC_URL; private String jdTCUrl;
@Value("${jdtc.accesstoken}") @Value("${jdtc.accesstoken}")
private String TOKEN; private String jdTCToken;
@Value("${jdtc.wl_appkey}") @Value("${jdtc.wl_appkey}")
private String WL_APPKEY; private String wlAppkey;
@Value("${jdtc.wl_appsecret}") @Value("${jdtc.wl_appsecret}")
private String WL_APPSECRET; private String wlAppSecret;
@Value("${jdtc.pin}") @Value("${jdtc.pin}")
private String PIN; private String pin;
@Value("${jdtc.customer_code}")
private String customerCode;
/** /**
* =================== JDTC API - path =================== * =================== JDTC API - path ===================
*/ */
private final String ORDER_TRACE_QUERY_PATH = "/TransferCenterService/order/trace/query/v1"; private final String ORDER_TRACE_QUERY_PATH = "/TransferCenterService/order/trace/query/v1";
private final String ORDER_QUERY_PATH = "/TransferCenterService/order/query/v1";
private final String DOMAIN = "TransferCenterService"; private final String DOMAIN = "TransferCenterService";
private final String HEX_CHARACTERS = "0123456789ABCDEF"; private final String HEX_CHARACTERS = "0123456789ABCDEF";
private final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); private final String ALGORITHM = "md5-salt";
public JSONArray getOrderTrace(String orderNo) { public JSONArray getOrderTrace(String orderNo) {
try { try {
String baseUri = JDTC_URL; String body = "[{\"pin\":\""+pin+"\",\"purchaseOrderNo\":\""+orderNo+"\"}]";
String appKey = WL_APPKEY; Map<String, String> urlParams = getUrlParams(ORDER_TRACE_QUERY_PATH, body);
String appSecret = WL_APPSECRET; String req = HttpUtil.createPost(jdTCUrl + ORDER_TRACE_QUERY_PATH + "?" + httpBuildQuery(urlParams)).addHeaders(getHeaders()).body(body).execute().body();
String accessToken = TOKEN;
String algorithm = "md5-salt";
String body = "[{\"pin\":\""+PIN+"\",\"purchaseOrderNo\":\""+orderNo+"\"}]";
String timestamp = DATE_TIME_FORMATTER.format(LocalDateTime.now());
String content = String.join("", new String[]{
appSecret,
"access_token", accessToken,
"app_key", appKey,
"method", ORDER_TRACE_QUERY_PATH,
"param_json", body,
"timestamp", timestamp,
"v", "2.0",
appSecret
});
Map<String, String> urlParams = new HashMap<>();
urlParams.put("LOP-DN", DOMAIN);
urlParams.put("access_token", accessToken);
urlParams.put("app_key", appKey);
urlParams.put("timestamp", timestamp);
urlParams.put("v", "2.0");
urlParams.put("sign", sign(algorithm, content.getBytes(StandardCharsets.UTF_8), appSecret.getBytes(StandardCharsets.UTF_8)));
urlParams.put("algorithm", algorithm);
Map<String, String> headers = new HashMap<>();
// lop-tz代表时区,为接口调用当地的时区;删去后默认为东八区
headers.put("lop-tz", String.valueOf(OffsetTime.now().getOffset().getTotalSeconds() / 3600));
// 用于开放平台识别客户调用API方式,客户无需修改
headers.put("User-Agent", "lop-http/java");
headers.put("content-type", "application/json;charset=utf-8");
String req = HttpUtil.createPost(baseUri + ORDER_TRACE_QUERY_PATH + "?" + httpBuildQuery(urlParams)).addHeaders(headers).body(body).execute().body();
JSONObject reqJson = JSONObject.parseObject(req); JSONObject reqJson = JSONObject.parseObject(req);
if (!reqJson.getString("code").equals("1000")){ if (!reqJson.getString("code").equals("1000")){
log.error("请求京东TC物流轨迹接口返回异常:{}",reqJson); log.error("请求京东TC 物流轨迹 接口返回异常:{}",reqJson);
throw new ServiceException(ECode.JINGDONG_TC_ORDER_TRACE_API_ERROR); throw new ServiceException(ECode.JINGDONG_TC_ORDER_TRACE_API_ERROR);
} }
JSONObject data = reqJson.getJSONObject("data"); JSONObject data = reqJson.getJSONObject("data");
...@@ -102,6 +70,28 @@ public class JdtcUtil { ...@@ -102,6 +70,28 @@ public class JdtcUtil {
throw new ServiceException(ECode.JINGDONG_TC_ORDER_TRACE_QUERY_ERROR); throw new ServiceException(ECode.JINGDONG_TC_ORDER_TRACE_QUERY_ERROR);
} }
} }
public JSONArray orderQuery(List<String> waybillCodes) throws Exception{
try {
Map<String,Object> params = new HashMap<>();
params.put("customerCode", customerCode);
params.put("pin", pin);
params.put("waybillCodes", waybillCodes);
String body = JSONObject.toJSONString(Arrays.asList(params));
Map<String, String> urlParams = getUrlParams(ORDER_QUERY_PATH, body);
String req = HttpUtil.createPost(jdTCUrl + ORDER_QUERY_PATH + "?" + httpBuildQuery(urlParams)).addHeaders(getHeaders()).body(body).execute().body();
JSONObject reqJson = JSONObject.parseObject(req);
if (!reqJson.getString("code").equals("1000")){
log.error("请求京东TC 到仓订单查询 接口返回异常:{}",reqJson);
throw new ServiceException(ECode.JINGDONG_TC_ORDER_QUERY_API_ERROR);
}
JSONObject data = reqJson.getJSONObject("data");
return data.containsKey("details") ? data.getJSONArray("details") : new JSONArray();
} catch (GeneralSecurityException | UnsupportedEncodingException e) {
throw new ServiceException(ECode.JINGDONG_TC_ORDER_QUERY_API_ERROR);
}
}
private String sign(String algorithm, byte[] data, byte[] secret) throws GeneralSecurityException { private String sign(String algorithm, byte[] data, byte[] secret) throws GeneralSecurityException {
if (Objects.equals(algorithm, "md5-salt")) { if (Objects.equals(algorithm, "md5-salt")) {
...@@ -148,4 +138,37 @@ public class JdtcUtil { ...@@ -148,4 +138,37 @@ public class JdtcUtil {
} }
return stringBuilder.toString(); return stringBuilder.toString();
} }
private Map<String, String> getUrlParams(String method,String body) throws GeneralSecurityException{
String timestamp = DatePattern.NORM_DATETIME_FORMATTER.format(LocalDateTime.now());
String content = String.join("", new String[]{
wlAppSecret,
"access_token", jdTCToken,
"app_key", wlAppkey,
"method", method,
"param_json", body,
"timestamp", timestamp,
"v", "2.0",
wlAppSecret
});
Map<String, String> urlParams = new HashMap<>();
urlParams.put("LOP-DN", DOMAIN);
urlParams.put("access_token", jdTCToken);
urlParams.put("app_key", wlAppkey);
urlParams.put("timestamp", timestamp);
urlParams.put("v", "2.0");
urlParams.put("sign", sign(ALGORITHM, content.getBytes(StandardCharsets.UTF_8), wlAppSecret.getBytes(StandardCharsets.UTF_8)));
urlParams.put("algorithm", ALGORITHM);
return urlParams;
}
private Map<String, String> getHeaders(){
Map<String, String> headers = new HashMap<>();
// lop-tz代表时区,为接口调用当地的时区;删去后默认为东八区
headers.put("lop-tz", String.valueOf(OffsetTime.now().getOffset().getTotalSeconds() / 3600));
// 用于开放平台识别客户调用API方式,客户无需修改
headers.put("User-Agent", "lop-http/java");
headers.put("content-type", "application/json;charset=utf-8");
return headers;
}
} }
...@@ -72,7 +72,7 @@ public class KyeUtil { ...@@ -72,7 +72,7 @@ public class KyeUtil {
/** /**
* 根据单号获取运单信息 * 根据单号获取运单信息
*/ */
public JSONArray getWaybillBaseInfo(List<String> waybillNumbers) { public JSONArray getWaybillBaseInfo(List<String> waybillNumbers) throws Exception {
try { try {
Boolean isSandbox = IS_SANDBOX; Boolean isSandbox = IS_SANDBOX;
String appKey = APP_KEY; String appKey = APP_KEY;
...@@ -95,7 +95,7 @@ public class KyeUtil { ...@@ -95,7 +95,7 @@ public class KyeUtil {
} }
} }
public JSONArray queryWaybillPicture(String expressNo) { public JSONArray queryWaybillPicture(String expressNo) throws Exception {
try { try {
Boolean isSandbox = IS_SANDBOX; Boolean isSandbox = IS_SANDBOX;
String appKey = APP_KEY; String appKey = APP_KEY;
......
...@@ -6,7 +6,7 @@ import cn.hutool.http.HttpStatus; ...@@ -6,7 +6,7 @@ import cn.hutool.http.HttpStatus;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.sfa.job.pojo.response.FinanceOrderDetailUpdateDto; import com.sfa.job.pojo.response.FinanceOrderDetailUpdateDto;
import com.sfa.job.pojo.response.SyncOrderDetailDto; import com.sfa.job.pojo.response.SyncOrderDetailDto;
import com.sfa.job.service.order.FinanceOrderSyncService; import com.sfa.job.service.order.IFinanceOrderSyncService;
import com.xxl.job.core.context.XxlJobContext; import com.xxl.job.core.context.XxlJobContext;
import com.xxl.job.core.context.XxlJobHelper; import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob; import com.xxl.job.core.handler.annotation.XxlJob;
...@@ -26,7 +26,7 @@ import java.util.Date; ...@@ -26,7 +26,7 @@ import java.util.Date;
public class FinanceOrderTask { public class FinanceOrderTask {
@Autowired @Autowired
FinanceOrderSyncService financeOrderSyncService; IFinanceOrderSyncService IFinanceOrderSyncService;
/** /**
* 同步财务订单数据 * 同步财务订单数据
...@@ -45,7 +45,7 @@ public class FinanceOrderTask { ...@@ -45,7 +45,7 @@ public class FinanceOrderTask {
XxlJobHelper.log("xxl-job开始同步-旺店通订单明细api接口数据"); XxlJobHelper.log("xxl-job开始同步-旺店通订单明细api接口数据");
// 定时任务不设定开始时间和结束时间 // 定时任务不设定开始时间和结束时间
SyncOrderDetailDto detailDto = financeOrderSyncService.syncWdtOrder(null, null,0); SyncOrderDetailDto detailDto = IFinanceOrderSyncService.syncWdtOrder(null, null,0);
XxlJobHelper.log("xxl-job结束同步-旺店通订单明细api接口数据, 共同步订单{}条数据,订单明细{}条,订单批次号:{},订单的开始时间{}和结束时间{}", XxlJobHelper.log("xxl-job结束同步-旺店通订单明细api接口数据, 共同步订单{}条数据,订单明细{}条,订单批次号:{},订单的开始时间{}和结束时间{}",
detailDto.getOrderCount(),detailDto.getOrderDetailCount(),detailDto.getBatchNo(), detailDto.getOrderCount(),detailDto.getOrderDetailCount(),detailDto.getBatchNo(),
DateUtil.formatDateTime(detailDto.getStartTime()),DateUtil.formatDateTime(detailDto.getEndTime()) ); DateUtil.formatDateTime(detailDto.getStartTime()),DateUtil.formatDateTime(detailDto.getEndTime()) );
...@@ -73,7 +73,7 @@ public class FinanceOrderTask { ...@@ -73,7 +73,7 @@ public class FinanceOrderTask {
XxlJobHelper.log("xxl-job开始同步-旺店通订单明细api接口数据"); XxlJobHelper.log("xxl-job开始同步-旺店通订单明细api接口数据");
// 定时任务不设定开始时间和结束时间 // 定时任务不设定开始时间和结束时间
SyncOrderDetailDto detailDto = financeOrderSyncService.syncWdtRefundOrder(null, null,0); SyncOrderDetailDto detailDto = IFinanceOrderSyncService.syncWdtRefundOrder(null, null,0);
Long endTime = System.currentTimeMillis(); Long endTime = System.currentTimeMillis();
XxlJobHelper.log("xxl-job结束同步-旺店通订单明细api接口数据, 共同步订单{}条数据,订单明细{}条,订单批次号:{},订单的开始时间{}和结束时间{},时长:{}", XxlJobHelper.log("xxl-job结束同步-旺店通订单明细api接口数据, 共同步订单{}条数据,订单明细{}条,订单批次号:{},订单的开始时间{}和结束时间{},时长:{}",
detailDto.getOrderCount(),detailDto.getOrderDetailCount(),detailDto.getBatchNo(), detailDto.getOrderCount(),detailDto.getOrderDetailCount(),detailDto.getBatchNo(),
...@@ -106,7 +106,7 @@ public class FinanceOrderTask { ...@@ -106,7 +106,7 @@ public class FinanceOrderTask {
// 定时任务不设定开始时间和结束时间 // 定时任务不设定开始时间和结束时间
Date startTime = DateUtil.beginOfDay(DateUtil.offsetDay(new Date(),-1)); Date startTime = DateUtil.beginOfDay(DateUtil.offsetDay(new Date(),-1));
Date endTime = DateUtil.endOfDay(DateUtil.offsetDay(new Date(),-1)); Date endTime = DateUtil.endOfDay(DateUtil.offsetDay(new Date(),-1));
FinanceOrderDetailUpdateDto detailDto = financeOrderSyncService.updateCost(startTime,endTime); FinanceOrderDetailUpdateDto detailDto = IFinanceOrderSyncService.updateCost(startTime,endTime);
XxlJobHelper.log("修改旺店通订单明细结束-旺店通订单明细api接口数据, 共修改订单数{}条数据", detailDto.getTotalCount()); XxlJobHelper.log("修改旺店通订单明细结束-旺店通订单明细api接口数据, 共修改订单数{}条数据", detailDto.getTotalCount());
XxlJobHelper.handleSuccess(JSONObject.toJSONString(detailDto)); XxlJobHelper.handleSuccess(JSONObject.toJSONString(detailDto));
......
...@@ -6,7 +6,7 @@ import cn.hutool.http.HttpStatus; ...@@ -6,7 +6,7 @@ import cn.hutool.http.HttpStatus;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.sfa.job.pojo.response.SyncOrderDetailDto; import com.sfa.job.pojo.response.SyncOrderDetailDto;
import com.sfa.job.service.order.WdtQimenOrderSyncService; import com.sfa.job.service.order.IWdtQimenOrderSyncService;
import com.xxl.job.core.context.XxlJobContext; import com.xxl.job.core.context.XxlJobContext;
import com.xxl.job.core.context.XxlJobHelper; import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob; import com.xxl.job.core.handler.annotation.XxlJob;
...@@ -26,7 +26,7 @@ import java.util.Date; ...@@ -26,7 +26,7 @@ import java.util.Date;
public class WdtQimenOrderTask { public class WdtQimenOrderTask {
@Autowired @Autowired
WdtQimenOrderSyncService qimenSyncService; IWdtQimenOrderSyncService qimenSyncService;
/** /**
* 同步财务订单数据 * 同步财务订单数据
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
<select id="getNotReceiptSent" resultMap="ordersSentResultMap"> <select id="getNotReceiptSent" resultMap="ordersSentResultMap">
select send_id, transport, transport_name, express_no, dd_no select send_id, transport, transport_name, express_no, dd_no
from orders_sent from orders_sent
where transport = 109 where transport in (109,134)
and receipt_flag = '无' and receipt_flag = '无'
and post_data &gt;= date_sub(CURDATE(), INTERVAL 45 DAY) and post_data &gt;= date_sub(CURDATE(), INTERVAL 45 DAY)
</select> </select>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论