|
|
@@ -1266,10 +1266,18 @@ public class DfOrderServiceImpl implements IErpOrderService {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // 检查发货消息是否已发送
|
|
|
- Object sendGoods = redisCache.getCacheObject(sendGoodsKey + orderId);
|
|
|
- if (("0".equals(stateEx) || "1".equals(stateEx) || "2".equals(stateEx)) && !ObjectUtil.isEmpty(sendGoods)) {
|
|
|
- log.info("发货消息已发送过,跳过 - orderId: {}", orderId);
|
|
|
+ // 1. 方法入口日志
|
|
|
+ log.info("AI发送物流消息开始 - orderId: {}, orderCode: {}, 原始deliveryType: {}, 新stateEx: {}",
|
|
|
+ orderId, order.getOrderCode(), order.getDeliveryType(), stateEx);
|
|
|
+
|
|
|
+ // 3. 检查deliveryType是否发生变化
|
|
|
+ boolean isStateChanged = !Objects.equals(order.getDeliveryType(), stateEx);
|
|
|
+ log.info("状态比较结果 - orderId: {}, order.getDeliveryType(): {}, stateEx: {}, 状态是否变化: {}",
|
|
|
+ orderId, order.getDeliveryType(), stateEx, isStateChanged);
|
|
|
+
|
|
|
+
|
|
|
+ // 状态变化了不发,状态未变更才发
|
|
|
+ if(isStateChanged){
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -1397,6 +1405,27 @@ public class DfOrderServiceImpl implements IErpOrderService {
|
|
|
wxWorkService.SendTextMsg(wxWorkSendTextMsgDTO, qwUser.getServerId());
|
|
|
log.info("每日上午9点和下午4点发送物流消息 AI物流消息发送成功 - orderId: {}, sendId: {}", orderId, sendId);
|
|
|
|
|
|
+
|
|
|
+ // 发送成功后设置今天的Redis标识
|
|
|
+ // 计算到今天结束的剩余秒数(设置到明天凌晨2点过期,确保覆盖当天)
|
|
|
+ cn.hutool.core.date.DateTime tomorrow = cn.hutool.core.date.DateUtil.tomorrow();
|
|
|
+ cn.hutool.core.date.DateTime endOfToday = cn.hutool.core.date.DateUtil.endOfDay(cn.hutool.core.date.DateUtil.date());
|
|
|
+ long secondsUntilTomorrow = (endOfToday.getTime() - System.currentTimeMillis()) / 1000 + 7200; // 加2小时缓冲
|
|
|
+
|
|
|
+ String todayDate = cn.hutool.core.date.DateUtil.today();
|
|
|
+ String todayRedisKey = "ai:express:sent:" + orderId + ":" + todayDate;
|
|
|
+ redisCache.setCacheObject(todayRedisKey, "1", (int) secondsUntilTomorrow, java.util.concurrent.TimeUnit.SECONDS);
|
|
|
+ log.info("设置今天Redis发送标识 - orderId: {}, todayRedisKey: {}, 过期时间(秒): {}", orderId, todayRedisKey, secondsUntilTomorrow);
|
|
|
+
|
|
|
+ // 设置已签收的发送标识
|
|
|
+ if ("301".equals(stateEx)){
|
|
|
+ redisCache.sAdd(signedKey, orderId.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置已发货的发送标识
|
|
|
+ if ("0".equals(stateEx) || "1".equals(stateEx) || "2".equals(stateEx)) {
|
|
|
+ redisCache.setCacheObject(sendGoodsKey + orderId, "1",15, TimeUnit.DAYS);
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
log.error("每日上午9点和下午4点发送物流消息 AI物流消息发送失败 - orderId: {}, sendId: {}, 错误信息: {}", orderId, sendId, e.getMessage(), e);
|
|
|
}
|