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

1、订单 - 发货单物流查询(限制次数5/h);2、定时向勤策回写轨迹数据

上级 e14d4eb7
......@@ -7,4 +7,5 @@ package com.sfa.job.constants;
*/
public interface RedisKeyJob {
String FEISHU_EVENT_CREATE_DEPT = "job:feishu_event:create_dept_";
String QINCE_ORDER_SENT_INTERNET_COUNT = "job:qc_order_sent:sent_no_";
}
......@@ -3,6 +3,8 @@ package com.sfa.job.controller.order;
import com.alibaba.fastjson2.JSONArray;
import com.sfa.common.core.enums.ECode;
import com.sfa.common.core.exception.ServiceException;
import com.sfa.common.redis.service.RedisService;
import com.sfa.job.constants.RedisKeyJob;
import com.sfa.job.pojo.response.OrdersSentDto;
import com.sfa.job.service.order.IOrdersSentQueryService;
import com.sfa.job.util.JdtcUtil;
......@@ -16,18 +18,32 @@ import org.springframework.web.bind.annotation.RestController;
/**
* @author : liqiulin
* @date : 2025-07-08 13
* @describe : 订单物流查询
* @describe : 订单 - 发货单物流查询
*/
@RestController
@RequestMapping("/order/sent/query")
@RequestMapping("/sent")
public class SentQueryController {
@Autowired
private JdtcUtil jdtcUtil;
@Autowired
private IOrdersSentQueryService orderSentQueryService;
@Autowired
private RedisService redisService;
@GetMapping
@GetMapping("/query_p")
public Object query(String sentNo){
// 限制单号每小时只能查询5次
String rKey = RedisKeyJob.QINCE_ORDER_SENT_INTERNET_COUNT + sentNo;
Object cacheObject = redisService.getCacheObject(rKey);
if (cacheObject != null && Integer.parseInt(cacheObject.toString()) >= 5) {
throw new ServiceException(ECode.SENT_NO_QUERY_COUNT_ERROR);
}
Object sent = queryBySentNode(sentNo);
redisService.setCacheObject(rKey, cacheObject == null ? 1 : Integer.parseInt(cacheObject.toString()) + 1);
return sent;
}
private Object queryBySentNode(String sentNo){
OrdersSentDto sent = orderSentQueryService.getSent(sentNo);
Object sentInfo = null;
switch (sent.getTransport()) {
......
package com.sfa.job.service.order.impl;
import com.alibaba.fastjson.JSONObject;
import com.sfa.job.domain.order.dao.IOrdersSentDao;
import com.sfa.job.pojo.response.OrdersSentDto;
import com.sfa.job.service.order.IOrdersSentQueryService;
import com.sfa.job.util.QinCeUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* @author : liqiulin
* @date : 2025-07-10 16
* @describe :
*/
@Slf4j
@Service
public class OrdersSentQueryServiceImpl implements IOrdersSentQueryService {
@Autowired
private IOrdersSentDao ordersSentDao;
@Autowired
private QinCeUtils qinCeUtils;
@Override
public void ordersSentToQince() {
List<OrdersSentDto> sents = ordersSentDao.findByPushqcStatus();
for (OrdersSentDto sent : sents) {
// 修改勤策物流https地址
pushQc(sent);
break;
}
}
......@@ -32,8 +41,20 @@ public class OrdersSentQueryServiceImpl implements IOrdersSentQueryService {
return ordersSentDao.getSent(sentNo);
}
private void pushQc(OrdersSentDto sent) throws Exception{
String sentUrl = "https://sfa.wxl66.cn/link/order/sent?sendId="+sent+"&sentNo="+sent.getBjSentNo();
private void pushQc(OrdersSentDto sent){
try {
String wlHtmlPath = qinCeUtils.wlHtmlPath;
wlHtmlPath += sent.getAhSentNo();
// 勤策中发货单按安徽匹配
Map<String, Object> params = qinCeUtils.modifySentDefinedValParams(sent.getAhSentNo(), wlHtmlPath);
System.out.println(JSONObject.toJSONString(params));
String url = qinCeUtils.builderUrl(QinCeUtils.MODIFY_SENT_DEFINED_VAL, params);
JSONObject request = qinCeUtils.postQC(url, params);
System.out.println(request);
}catch (Exception e) {
log.error("勤策推送物流地址失败,物流信息:{}", JSONObject.toJSONString(sent));
}
}
}
......@@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
......@@ -31,7 +32,8 @@ public class QinCeUtils {
private String OPEN_ID;
@Value("${qince.app_key}")
private String APP_KEY;
@Value("${wxl.wl.html_path}")
public String wlHtmlPath;
/**
* =================== 勤策API - path ===================
......@@ -40,6 +42,9 @@ public class QinCeUtils {
public static final String MODIFY_DEALER = "/api/dealer/v1/modifyDealer/";
public static final String MODIFY_STORE = "/api/store/v1/modifyStore/";
public static final String QUERY_CUS_VISIT_RECORD = "/api/cusVisit/v1/queryCusVisitRecord/";
// 直营发货单自定义字段更新
public static final String MODIFY_SENT_DEFINED_VAL = "/api/dmssent/v1/modifyUseDefinedVal/";
public String builderUrl(String sidepath, Map<String, Object> params) {
String msgId = UUID.randomUUID().toString();
......@@ -58,6 +63,16 @@ public class QinCeUtils {
return params;
}
public Map<String, Object> modifySentDefinedValParams(String sentNo,String wlHtmlPath){
Map<String,Object> vals = new HashMap<>();
vals.put("ext_key","物流轨迹");
vals.put("ext_value",wlHtmlPath);
Map<String,Object> params = new HashMap<>();
params.put("sent_no",sentNo);
params.put("exts", Arrays.asList(vals));
return params;
}
public JSONObject postQC(String url, Object params) throws Exception {
......@@ -65,7 +80,7 @@ public class QinCeUtils {
JSONObject resultJson = JSONObject.parseObject(requestBody);
String returnCode = resultJson.getString("return_code");
if (!"0".equals(returnCode)) {
throw new RuntimeException("OkHttp.post请求error,详情:" + requestBody);
throw new RuntimeException("OkHttp.post 勤策接口返回值异常,详情:" + requestBody);
}
return resultJson;
}
......
package com.sfa.job.xxljob.order;
import com.sfa.job.service.order.IOrdersSentQueryService;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -15,6 +16,10 @@ public class OrdersSentToQince {
@Autowired
private IOrdersSentQueryService ordersSentService;
@XxlJob("push_qc_order_sent")
public void ordersSentToQince(){
ordersSentService.ordersSentToQince();
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论