guoziyun 9 mēneši atpakaļ
vecāks
revīzija
0bd2095073

+ 5 - 4
oms/services/cron-jobs/index.ts

@@ -18,10 +18,11 @@ const settings: [string, string, CronJobModule][] = [
   // ["message-sender", "*/5 * * * *", require("./message-sender") as CronJobModule], // 每5分钟运行一次, 已经单独剥离出去了(message-seender-service),定时任务这里取消了
   // ["active-user-daily-notify", "30 18 * * *", require("./active-user-daily-notify") as CronJobModule], // 每天下午6点,开始活跃用户新作品消息推送
   // ["fcm-notify", "30 18 * * *", require("./fcm-notify") as CronJobModule], // 每天下午6点,基于原来的active-user-daily-notify,增加schedule推送,AB测试
-  ["daily-notify-at-morning", "0 19 * * *", require("./notify/daily-notify-at-morning") as CronJobModule], // 每天下午7点,对应巴西时间早上8点推送一轮
-  ["daily-notify-at-midday", "0 23 * * *", require("./notify/daily-notify-at-midday") as CronJobModule], // 每天晚上11点,对应巴西时间中午12点推送一轮
-  ["daily-notify-at-evening", "0 3 * * *", require("./notify/daily-notify-at-evening") as CronJobModule], // 每天凌晨3点,对应巴西时间下午4点
-  ["daily-notify-at-afternoon", "0 7 * * *", require("./notify/daily-notify-at-afternoon") as CronJobModule], // 每天上午7点,对应巴西时间晚上8点
+  // ["daily-notify-at-morning", "0 19 * * *", require("./notify/daily-notify-at-morning") as CronJobModule], // 每天下午7点,对应巴西时间早上8点推送一轮
+  // ["daily-notify-at-midday", "0 23 * * *", require("./notify/daily-notify-at-midday") as CronJobModule], // 每天晚上11点,对应巴西时间中午12点推送一轮
+  // ["daily-notify-at-evening", "0 3 * * *", require("./notify/daily-notify-at-evening") as CronJobModule], // 每天凌晨3点,对应巴西时间下午4点
+  // ["daily-notify-at-afternoon", "0 7 * * *", require("./notify/daily-notify-at-afternoon") as CronJobModule], // 每天上午7点,对应巴西时间晚上8点
+  ["local-timezone-notify", "0 18 * * *", require("./notify/local-timezone-notify") as CronJobModule], // 每天下午6点,开始制定当天的推送计划
 ];
 
 /**

+ 19 - 19
oms/services/cron-jobs/notify/local-timezone-notify.ts

@@ -5,7 +5,7 @@ import { MessageStrategy, IMessageStrategy } from "../../../src/models/messageSt
 import { MessageRecord, IMessageRecord } from "../../../src/models/messageRecordModel";
 import Art, { IArt } from "../../../src/models/artModel";
 import { TimezoneService } from "../../../src/services/timezoneService";
-import { connectToDatabase } from "../../../src/database";
+// import { connectToDatabase } from "../../../src/database";
 
 // 确保模型已被注册
 mongoose.model("MessageTemplate", MessageTemplate.schema);
@@ -110,23 +110,23 @@ const recordMessage = async (
   plannedSendAt: Date
 ) => {
   try {
-    // await MessageRecord.create({
-    //   uid: uid,
-    //   cc: cc,
-    //   templateId: template._id,
-    //   templateName: template.templateName,
-    //   strategyId: strategyId,
-    //   strategyName: strategyName,
-    //   title: messageData.title,
-    //   content: messageData.content,
-    //   image: messageData.image,
-    //   bigger: messageData.bigger === "true",
-    //   action: messageData.action,
-    //   param: messageData.param,
-    //   extend: messageData.extend,
-    //   plannedSendAt: plannedSendAt, // 使用计算出的计划时间
-    //   status: 0,
-    // });
+    await MessageRecord.create({
+      uid: uid,
+      cc: cc,
+      templateId: template._id,
+      templateName: template.templateName,
+      strategyId: strategyId,
+      strategyName: strategyName,
+      title: messageData.title,
+      content: messageData.content,
+      image: messageData.image,
+      bigger: messageData.bigger === "true",
+      action: messageData.action,
+      param: messageData.param,
+      extend: messageData.extend,
+      plannedSendAt: plannedSendAt, // 使用计算出的计划时间
+      status: 0,
+    });
 
     console.log(`成功为用户 ${uid} 创建消息记录。计划发送时间: ${plannedSendAt.toISOString()}`);
   } catch (error) {
@@ -141,7 +141,7 @@ const recordMessage = async (
 export async function run(): Promise<void> {
   console.log("脚本开始:创建活跃用户每日通知任务...");
 
-  await connectToDatabase();
+  // await connectToDatabase();
 
   try {
     const sevenDaysAgo = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);