提交 ea2a4751 authored 作者: 000516's avatar 000516

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

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