This commit is contained in:
van
2026-04-07 21:35:36 +08:00
parent a22d17de73
commit 2d4f933791
6 changed files with 70 additions and 2 deletions

View File

@@ -9,6 +9,7 @@ import com.ruoyi.jarvis.service.ILogisticsService;
import com.ruoyi.jarvis.service.IWeComShareLinkLogisticsJobService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
@@ -70,6 +71,9 @@ public class WeComShareLinkLogisticsJobController extends BaseController {
if (job == null) {
return AjaxResult.error("任务不存在");
}
if ("CANCELLED".equalsIgnoreCase(job.getStatus())) {
return AjaxResult.error("任务已取消扫描,请先恢复或新建任务");
}
if (!StringUtils.hasText(job.getTrackingUrl())) {
return AjaxResult.error("该任务无物流短链");
}
@@ -109,4 +113,49 @@ public class WeComShareLinkLogisticsJobController extends BaseController {
r.put("hint", "为单次弹栈处理条数;每项内部仍可能因未出单重新入队");
return AjaxResult.success(r);
}
/**
* 订单取消等:标记为 CANCELLED不再被定时对账入队队列弹出时也会跳过物流请求与推送。
*/
@PreAuthorize("@ss.hasPermi('jarvis:wecom:shareLinkLog:list')")
@PostMapping("/cancel")
public AjaxResult cancel(@RequestBody Map<String, Object> body) {
if (body == null || body.get("jobKey") == null) {
return AjaxResult.error("jobKey 不能为空");
}
String jobKey = body.get("jobKey").toString().trim();
if (!StringUtils.hasText(jobKey)) {
return AjaxResult.error("jobKey 不能为空");
}
WeComShareLinkLogisticsJob job = weComShareLinkLogisticsJobService.selectByJobKey(jobKey);
if (job == null) {
return AjaxResult.error("任务不存在");
}
if ("CANCELLED".equalsIgnoreCase(job.getStatus())) {
return AjaxResult.success("已是取消状态");
}
String extra = body.get("lastNote") != null ? body.get("lastNote").toString().trim() : "";
String note = "manual_cancel";
if (StringUtils.hasText(extra)) {
note = note + "|" + extra;
}
if (note.length() > 500) {
note = note.substring(0, 500) + "";
}
weComShareLinkLogisticsJobMapper.updateByJobKey(jobKey, "CANCELLED", note, null, null);
return AjaxResult.success();
}
/**
* 物理删除任务行Redis 中已存在的同 jobKey 队列项仍可能被弹出,但会因库中无行而跳过扫描)。
*/
@PreAuthorize("@ss.hasPermi('jarvis:wecom:shareLinkLog:list')")
@DeleteMapping("/{jobKey}")
public AjaxResult remove(@PathVariable("jobKey") String jobKey) {
if (!StringUtils.hasText(jobKey)) {
return AjaxResult.error("jobKey 不能为空");
}
weComShareLinkLogisticsJobMapper.deleteByJobKey(jobKey.trim());
return AjaxResult.success();
}
}