1
This commit is contained in:
@@ -18,7 +18,7 @@ public class ErpGoofishOrderEventLog {
|
|||||||
private String orderNo;
|
private String orderNo;
|
||||||
/** ORDER_SYNC / LOGISTICS_SYNC / SHIP */
|
/** ORDER_SYNC / LOGISTICS_SYNC / SHIP */
|
||||||
private String eventType;
|
private String eventType;
|
||||||
/** NOTIFY、LIST、DETAIL_REFRESH、UPSERT、REDIS_WAYBILL、AUTO_SHIP 等 */
|
/** NOTIFY、LIST、DETAIL_REFRESH、JD_LOGISTICS_PUSH、REDIS_WAYBILL、AUTO_SHIP 等 */
|
||||||
private String source;
|
private String source;
|
||||||
private String message;
|
private String message;
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
|||||||
@@ -42,6 +42,9 @@ public interface IErpGoofishOrderService {
|
|||||||
*/
|
*/
|
||||||
void notifyJdWaybillReady(Long jdOrderId);
|
void notifyJdWaybillReady(Long jdOrderId);
|
||||||
|
|
||||||
|
/** 京东物流服务在写 Redis / 企微货主推送后、触发闲鱼同步前记一笔(source=JD_LOGISTICS_PUSH)。 */
|
||||||
|
void traceJdLogisticsPushForGoofish(Long jdOrderId, String waybillNo, String summary);
|
||||||
|
|
||||||
/** 订单状态 / 物流 / 发货 变更日志(新→旧) */
|
/** 订单状态 / 物流 / 发货 变更日志(新→旧) */
|
||||||
List<ErpGoofishOrderEventLog> listEventLogsByOrderId(Long orderId);
|
List<ErpGoofishOrderEventLog> listEventLogsByOrderId(Long orderId);
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ public class GoofishOrderChangeLogger {
|
|||||||
public static final String TYPE_LOGISTICS = "LOGISTICS_SYNC";
|
public static final String TYPE_LOGISTICS = "LOGISTICS_SYNC";
|
||||||
public static final String TYPE_SHIP = "SHIP";
|
public static final String TYPE_SHIP = "SHIP";
|
||||||
|
|
||||||
|
/** 京东物流扫描服务:Redis + 企微货主推送链路(见 LogisticsServiceImpl),不再二次走 wxSend 闲鱼应用避免重复打扰 */
|
||||||
|
public static final String SOURCE_JD_LOGISTICS_PUSH = "JD_LOGISTICS_PUSH";
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ErpGoofishOrderEventLogMapper erpGoofishOrderEventLogMapper;
|
private ErpGoofishOrderEventLogMapper erpGoofishOrderEventLogMapper;
|
||||||
|
|
||||||
@@ -54,6 +57,9 @@ public class GoofishOrderChangeLogger {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
log.info("[goofish-order-event] orderId={} orderNo={} type={} source={} {}", orderId, orderNo, eventType, source, msg);
|
log.info("[goofish-order-event] orderId={} orderNo={} type={} source={} {}", orderId, orderNo, eventType, source, msg);
|
||||||
|
if (SOURCE_JD_LOGISTICS_PUSH.equals(source)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
wxSendGoofishNotifyClient.notifyGoofishEvent(orderNo, eventType, source, msg);
|
wxSendGoofishNotifyClient.notifyGoofishEvent(orderNo, eventType, source, msg);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import com.ruoyi.jarvis.mapper.ErpGoofishOrderMapper;
|
|||||||
import com.ruoyi.jarvis.service.IErpGoofishOrderService;
|
import com.ruoyi.jarvis.service.IErpGoofishOrderService;
|
||||||
import com.ruoyi.jarvis.service.IErpOpenConfigService;
|
import com.ruoyi.jarvis.service.IErpOpenConfigService;
|
||||||
import com.ruoyi.jarvis.service.goofish.GoofishNotifyAsyncFacade;
|
import com.ruoyi.jarvis.service.goofish.GoofishNotifyAsyncFacade;
|
||||||
|
import com.ruoyi.jarvis.service.goofish.GoofishOrderChangeLogger;
|
||||||
import com.ruoyi.jarvis.service.goofish.GoofishOrderPipeline;
|
import com.ruoyi.jarvis.service.goofish.GoofishOrderPipeline;
|
||||||
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||||
import org.springframework.beans.factory.ObjectProvider;
|
import org.springframework.beans.factory.ObjectProvider;
|
||||||
@@ -47,6 +48,9 @@ public class ErpGoofishOrderServiceImpl implements IErpGoofishOrderService {
|
|||||||
@Resource
|
@Resource
|
||||||
private IErpOpenConfigService erpOpenConfigService;
|
private IErpOpenConfigService erpOpenConfigService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private GoofishOrderChangeLogger goofishOrderChangeLogger;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void publishOrProcessNotify(String appid, Long timestamp, JSONObject body) {
|
public void publishOrProcessNotify(String appid, Long timestamp, JSONObject body) {
|
||||||
RocketMQTemplate mq = rocketMQTemplate.getIfAvailable();
|
RocketMQTemplate mq = rocketMQTemplate.getIfAvailable();
|
||||||
@@ -167,6 +171,32 @@ public class ErpGoofishOrderServiceImpl implements IErpGoofishOrderService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void traceJdLogisticsPushForGoofish(Long jdOrderId, String waybillNo, String summary) {
|
||||||
|
if (jdOrderId == null || goofishOrderChangeLogger == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ErpGoofishOrder query = new ErpGoofishOrder();
|
||||||
|
query.setJdOrderId(jdOrderId);
|
||||||
|
List<ErpGoofishOrder> list = erpGoofishOrderMapper.selectList(query);
|
||||||
|
if (list == null || list.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String wb = waybillNo != null ? waybillNo.trim() : "";
|
||||||
|
String sum = summary != null ? summary : "";
|
||||||
|
String msg = "jdOrderId=" + jdOrderId + " waybill=" + wb + ";" + sum;
|
||||||
|
if (msg.length() > 1000) {
|
||||||
|
msg = msg.substring(0, 999) + "…";
|
||||||
|
}
|
||||||
|
for (ErpGoofishOrder row : list) {
|
||||||
|
if (row.getId() == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
goofishOrderChangeLogger.append(row.getId(), row.getAppKey(), row.getOrderNo(),
|
||||||
|
GoofishOrderChangeLogger.TYPE_LOGISTICS, GoofishOrderChangeLogger.SOURCE_JD_LOGISTICS_PUSH, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ErpGoofishOrderEventLog> listEventLogsByOrderId(Long orderId) {
|
public List<ErpGoofishOrderEventLog> listEventLogsByOrderId(Long orderId) {
|
||||||
if (orderId == null) {
|
if (orderId == null) {
|
||||||
|
|||||||
@@ -219,9 +219,13 @@ public class LogisticsServiceImpl implements ILogisticsService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 京东单已写入 Redis 运单后,联动闲鱼单同步并发货(失败不影响物流主流程) */
|
/**
|
||||||
private void safeNotifyGoofishShip(Long jdOrderId) {
|
* 京东单已写入 Redis 运单后,联动闲鱼单同步并发货(失败不影响物流主流程)。
|
||||||
|
* 若存在关联闲鱼单,会先写入事件来源 JD_LOGISTICS_PUSH,便于与 REDIS_WAYBILL / AUTO_SHIP 对照。
|
||||||
|
*/
|
||||||
|
private void safeNotifyGoofishShip(Long jdOrderId, String waybillNo, String traceSummary) {
|
||||||
try {
|
try {
|
||||||
|
erpGoofishOrderService.traceJdLogisticsPushForGoofish(jdOrderId, waybillNo, traceSummary);
|
||||||
erpGoofishOrderService.notifyJdWaybillReady(jdOrderId);
|
erpGoofishOrderService.notifyJdWaybillReady(jdOrderId);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn("闲鱼发货联动异常 jdOrderId={} err={}", jdOrderId, e.toString());
|
logger.warn("闲鱼发货联动异常 jdOrderId={} err={}", jdOrderId, e.toString());
|
||||||
@@ -388,7 +392,8 @@ public class LogisticsServiceImpl implements ILogisticsService {
|
|||||||
logger.info("订单运单号已存在且一致,说明之前已推送过,跳过重复推送 - 订单ID: {}, waybill_no: {}", orderId, waybillNo);
|
logger.info("订单运单号已存在且一致,说明之前已推送过,跳过重复推送 - 订单ID: {}, waybill_no: {}", orderId, waybillNo);
|
||||||
// 更新过期时间,确保记录不会过期
|
// 更新过期时间,确保记录不会过期
|
||||||
stringRedisTemplate.opsForValue().set(redisKey, waybillNo, 30, TimeUnit.DAYS);
|
stringRedisTemplate.opsForValue().set(redisKey, waybillNo, 30, TimeUnit.DAYS);
|
||||||
safeNotifyGoofishShip(orderId);
|
safeNotifyGoofishShip(orderId, waybillNo,
|
||||||
|
"Redis 运单与本次一致,跳过重复企微推送;已刷新 TTL;随后触发闲鱼同步");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -406,7 +411,8 @@ public class LogisticsServiceImpl implements ILogisticsService {
|
|||||||
logger.info("订单创建时间较早({}),且Redis中无记录但已获取到运单号,视为之前已推送过,直接标记为已处理,跳过推送 - 订单ID: {}, waybill_no: {}",
|
logger.info("订单创建时间较早({}),且Redis中无记录但已获取到运单号,视为之前已推送过,直接标记为已处理,跳过推送 - 订单ID: {}, waybill_no: {}",
|
||||||
order.getCreateTime(), orderId, waybillNo);
|
order.getCreateTime(), orderId, waybillNo);
|
||||||
stringRedisTemplate.opsForValue().set(redisKey, waybillNo, 30, TimeUnit.DAYS);
|
stringRedisTemplate.opsForValue().set(redisKey, waybillNo, 30, TimeUnit.DAYS);
|
||||||
safeNotifyGoofishShip(orderId);
|
safeNotifyGoofishShip(orderId, waybillNo,
|
||||||
|
"老单兜底:直写 Redis,跳过企微;随后触发闲鱼同步");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -433,7 +439,9 @@ public class LogisticsServiceImpl implements ILogisticsService {
|
|||||||
// 更新过期时间,确保记录不会过期
|
// 更新过期时间,确保记录不会过期
|
||||||
stringRedisTemplate.opsForValue().set(redisKey, waybillNo, 30, TimeUnit.DAYS);
|
stringRedisTemplate.opsForValue().set(redisKey, waybillNo, 30, TimeUnit.DAYS);
|
||||||
}
|
}
|
||||||
safeNotifyGoofishShip(orderId);
|
safeNotifyGoofishShip(orderId, waybillNo,
|
||||||
|
"企微货主推送成功;" + (logisticsLinkUpdated ? "物流链接已更新;" : "物流链接未变;")
|
||||||
|
+ "Redis 已写入;随后触发闲鱼同步");
|
||||||
|
|
||||||
// 记录最终处理结果
|
// 记录最终处理结果
|
||||||
if (logisticsLinkUpdated) {
|
if (logisticsLinkUpdated) {
|
||||||
|
|||||||
Reference in New Issue
Block a user