1
This commit is contained in:
@@ -9,7 +9,6 @@ import com.ruoyi.jarvis.mapper.WeComShareLinkLogisticsJobMapper;
|
|||||||
import com.ruoyi.jarvis.service.IErpGoofishOrderService;
|
import com.ruoyi.jarvis.service.IErpGoofishOrderService;
|
||||||
import com.ruoyi.jarvis.service.ILogisticsService;
|
import com.ruoyi.jarvis.service.ILogisticsService;
|
||||||
import com.ruoyi.jarvis.service.IJDOrderService;
|
import com.ruoyi.jarvis.service.IJDOrderService;
|
||||||
import com.ruoyi.jarvis.wecom.WxSendGoofishNotifyClient;
|
|
||||||
import com.ruoyi.system.service.ISysConfigService;
|
import com.ruoyi.system.service.ISysConfigService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -87,9 +86,6 @@ public class LogisticsServiceImpl implements ILogisticsService {
|
|||||||
@Resource
|
@Resource
|
||||||
private IErpGoofishOrderService erpGoofishOrderService;
|
private IErpGoofishOrderService erpGoofishOrderService;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private WxSendGoofishNotifyClient wxSendGoofishNotifyClient;
|
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
externalApiUrlTemplate = logisticsBaseUrl + logisticsFetchPath + "?tracking_url=";
|
externalApiUrlTemplate = logisticsBaseUrl + logisticsFetchPath + "?tracking_url=";
|
||||||
@@ -443,9 +439,14 @@ public class LogisticsServiceImpl implements ILogisticsService {
|
|||||||
// 更新过期时间,确保记录不会过期
|
// 更新过期时间,确保记录不会过期
|
||||||
stringRedisTemplate.opsForValue().set(redisKey, waybillNo, 30, TimeUnit.DAYS);
|
stringRedisTemplate.opsForValue().set(redisKey, waybillNo, 30, TimeUnit.DAYS);
|
||||||
}
|
}
|
||||||
safeNotifyGoofishShip(orderId, waybillNo,
|
String mark = order.getDistributionMark();
|
||||||
"企微货主推送成功;" + (logisticsLinkUpdated ? "物流链接已更新;" : "物流链接未变;")
|
boolean skipGoofishJdWexin = erpGoofishOrderService.hasLinkedGoofishOrder(orderId)
|
||||||
+ "Redis 已写入;随后触发闲鱼同步");
|
|| (mark != null && mark.contains("\u95f2\u9c7c"));
|
||||||
|
String traceTail = (logisticsLinkUpdated ? "物流链接已更新;" : "物流链接未变;") + "Redis 已写入;随后触发闲鱼同步";
|
||||||
|
String traceSummary = (skipGoofishJdWexin
|
||||||
|
? "闲鱼单本环节未发京东物流企微,真发货见 SHIP 日志;"
|
||||||
|
: "企微货主推送成功;") + traceTail;
|
||||||
|
safeNotifyGoofishShip(orderId, waybillNo, traceSummary);
|
||||||
|
|
||||||
// 记录最终处理结果
|
// 记录最终处理结果
|
||||||
if (logisticsLinkUpdated) {
|
if (logisticsLinkUpdated) {
|
||||||
@@ -821,67 +822,41 @@ public class LogisticsServiceImpl implements ILogisticsService {
|
|||||||
*/
|
*/
|
||||||
private boolean sendEnterprisePushNotification(JDOrder order, String waybillNo, boolean logisticsLinkUpdated, String oldLogisticsLink, String newLogisticsLink) {
|
private boolean sendEnterprisePushNotification(JDOrder order, String waybillNo, boolean logisticsLinkUpdated, String oldLogisticsLink, String newLogisticsLink) {
|
||||||
try {
|
try {
|
||||||
String distributionMark = order.getDistributionMark() != null ? order.getDistributionMark() : "未知";
|
String distributionMark = order.getDistributionMark() != null ? order.getDistributionMark() : "\u672a\u77e5";
|
||||||
String thirdPartyOrderNo = order.getThirdPartyOrderNo();
|
String thirdPartyOrderNo = order.getThirdPartyOrderNo();
|
||||||
String modelStr = order.getModelNumber() != null ? order.getModelNumber() : "无";
|
String modelStr = order.getModelNumber() != null ? order.getModelNumber() : "\u65e0";
|
||||||
String addressStr = order.getAddress() != null ? order.getAddress() : "无";
|
String addressStr = order.getAddress() != null ? order.getAddress() : "\u65e0";
|
||||||
String goofishOrderNo;
|
|
||||||
|
boolean goofishLinked = erpGoofishOrderService.hasLinkedGoofishOrder(order.getId())
|
||||||
|
|| (distributionMark != null && distributionMark.contains("\u95f2\u9c7c"));
|
||||||
|
|
||||||
|
if (goofishLinked) {
|
||||||
|
// 闲鱼单:不在京东扫到运单环节发企微;仅写 Redis 并 notifyJdWaybillReady / tryAutoShip。
|
||||||
|
// 真发货成功后由 GoofishOrderChangeLogger SHIP 事件发 wx。
|
||||||
|
logger.info("闲鱼关联/分销:跳过本环节企微直推 - 订单ID: {}, 订单号: {}, waybill_no: {}",
|
||||||
|
order.getId(), order.getOrderId(), waybillNo);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 非闲鱼:PDD 企微,完整 JD 物流版式
|
||||||
|
StringBuilder std = new StringBuilder();
|
||||||
|
std.append("JD物流信息推送").append("\n");
|
||||||
|
std.append(distributionMark).append("\n");
|
||||||
if (thirdPartyOrderNo != null && !thirdPartyOrderNo.trim().isEmpty()) {
|
if (thirdPartyOrderNo != null && !thirdPartyOrderNo.trim().isEmpty()) {
|
||||||
goofishOrderNo = thirdPartyOrderNo.trim();
|
std.append("第三方单号:").append(thirdPartyOrderNo.trim()).append("\n");
|
||||||
} else if (order.getOrderId() != null && !order.getOrderId().trim().isEmpty()) {
|
|
||||||
goofishOrderNo = order.getOrderId().trim();
|
|
||||||
} else {
|
|
||||||
goofishOrderNo = "无";
|
|
||||||
}
|
}
|
||||||
|
std.append("型号:").append(modelStr).append("\n");
|
||||||
boolean useGoofishWecom = erpGoofishOrderService.hasLinkedGoofishOrder(order.getId())
|
std.append("收货地址:").append(addressStr).append("\n");
|
||||||
|| (distributionMark != null && distributionMark.contains("闲鱼"));
|
if (logisticsLinkUpdated && newLogisticsLink != null && !newLogisticsLink.trim().isEmpty()) {
|
||||||
|
std.append("【物流链接已更新】").append("\n");
|
||||||
String fullText;
|
std.append("新物流链接:").append(newLogisticsLink.trim()).append("\n");
|
||||||
if (useGoofishWecom) {
|
if (oldLogisticsLink != null && !oldLogisticsLink.trim().isEmpty()) {
|
||||||
// 闲鱼:仅「闲鱼自动发货」块,便于复制到平台
|
std.append("旧物流链接:").append(oldLogisticsLink.trim()).append("\n");
|
||||||
StringBuilder goofish = new StringBuilder();
|
|
||||||
goofish.append("闲鱼自动发货:").append("\n");
|
|
||||||
goofish.append("单号:").append(goofishOrderNo).append("\n");
|
|
||||||
goofish.append("型号:").append(modelStr).append("\n");
|
|
||||||
goofish.append("收货地址:").append(addressStr).append("\n");
|
|
||||||
goofish.append("运单号:").append(waybillNo).append("\n");
|
|
||||||
fullText = goofish.toString();
|
|
||||||
} else {
|
|
||||||
// 非闲鱼:沿用京东物流信息完整版式(与历史 PDD 通道一致),不出现「闲鱼自动发货」
|
|
||||||
StringBuilder std = new StringBuilder();
|
|
||||||
std.append("JD物流信息推送").append("\n");
|
|
||||||
std.append(distributionMark).append("\n");
|
|
||||||
if (thirdPartyOrderNo != null && !thirdPartyOrderNo.trim().isEmpty()) {
|
|
||||||
std.append("第三方单号:").append(thirdPartyOrderNo.trim()).append("\n");
|
|
||||||
}
|
}
|
||||||
std.append("型号:").append(modelStr).append("\n");
|
std.append("\n");
|
||||||
std.append("收货地址:").append(addressStr).append("\n");
|
|
||||||
if (logisticsLinkUpdated && newLogisticsLink != null && !newLogisticsLink.trim().isEmpty()) {
|
|
||||||
std.append("【物流链接已更新】").append("\n");
|
|
||||||
std.append("新物流链接:").append(newLogisticsLink.trim()).append("\n");
|
|
||||||
if (oldLogisticsLink != null && !oldLogisticsLink.trim().isEmpty()) {
|
|
||||||
std.append("旧物流链接:").append(oldLogisticsLink.trim()).append("\n");
|
|
||||||
}
|
|
||||||
std.append("\n");
|
|
||||||
}
|
|
||||||
std.append("运单号:").append("\n").append("\n").append("\n").append("\n").append(waybillNo).append("\n");
|
|
||||||
fullText = std.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (useGoofishWecom) {
|
|
||||||
String touserGoofish = getTouserByDistributionMark(distributionMark);
|
|
||||||
logger.info("闲鱼关联或分销含「闲鱼」:尝试企微闲鱼自建应用 - 订单ID: {}, 分销标识: {}, 接收人: {}",
|
|
||||||
order.getId(), distributionMark,
|
|
||||||
StringUtils.hasText(touserGoofish) ? touserGoofish : "(jarvis.wecom.goofish-notify-touser)");
|
|
||||||
if (wxSendGoofishNotifyClient.pushGoofishAgentText(touserGoofish, "", fullText)) {
|
|
||||||
logger.info("企微闲鱼应用推送成功 - 订单ID: {}, 订单号: {}, waybill_no: {}",
|
|
||||||
order.getId(), order.getOrderId(), waybillNo);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
logger.warn("企微闲鱼应用推送失败或未配置 wxSend,不再走 PDD 通道 - 订单ID: {}", order.getId());
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
std.append("运单号:").append("\n").append("\n").append("\n").append("\n").append(waybillNo).append("\n");
|
||||||
|
String fullText = std.toString();
|
||||||
|
|
||||||
// 调用企业微信推送接口(PDD 自建应用)
|
// 调用企业微信推送接口(PDD 自建应用)
|
||||||
JSONObject pushParam = new JSONObject();
|
JSONObject pushParam = new JSONObject();
|
||||||
|
|||||||
Reference in New Issue
Block a user