From f974f5c39b14e499932dd9205da08da5953d18e6 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Mon, 21 Oct 2024 16:47:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=90=8C=E6=AD=A5=E9=85=92=E5=BA=97ID,?= =?UTF-8?q?=20=E6=8C=89=E9=A1=B5=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/jobs/syncHeytripJobs.js | 4 ++-- server/services/heytripService.js | 15 ++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/server/jobs/syncHeytripJobs.js b/server/jobs/syncHeytripJobs.js index df3f651..53038c0 100644 --- a/server/jobs/syncHeytripJobs.js +++ b/server/jobs/syncHeytripJobs.js @@ -65,11 +65,11 @@ const AidsState = () => { /** * 获取新增的酒店详情 * ID同步结束后启动, ID每10W 条大约需要半小时 - * 每天03:05:00启动 + * * 每天 */ const newHotelDetails = () => { // return false; - const dailyJob1 = scheduleJob('0 5 3 * * *', async function () { + const dailyJob1 = scheduleJob('0 5 8 * * *', async function () { // const dailyJob1 = scheduleJob('0 5 12 * * *', async function () { const job1 = scheduleJob('*/5 * * * * *', async function () { console.log('-------------------------syncing heytrip[newHotelDetails], get accommodation details.-------------------------'); diff --git a/server/services/heytripService.js b/server/services/heytripService.js index 030d2ff..c9a8a79 100644 --- a/server/services/heytripService.js +++ b/server/services/heytripService.js @@ -160,14 +160,15 @@ class Heytrip { const today = new Date(); today.setHours(0, 0, 0, 0); // set the time to 00:00:00.000 - let lastPageIndex; let pageIndex; - lastPageIndex = await this.getFirstPageIndex({ last_modify_time: { [Op.lt]: today }, page_index: { [Op.lt]: 9999 } }); - pageIndex = lastPageIndex; + let lastPageIndex; + let pageIndex; + // lastPageIndex = await this.getFirstPageIndex({ last_modify_time: { [Op.lt]: today }, page_index: { [Op.lt]: 9999 } }); + // pageIndex = lastPageIndex; if (isEmpty(lastPageIndex)) { - lastPageIndex = await this.getLastPageIndex({ last_modify_time: { [Op.gt]: today }, page_index: { [Op.lt]: 9999 } }); + lastPageIndex = await this.getLastPageIndex({ last_modify_time: { [Op.gt]: today }, page_index: { [Op.gt]: 0 } }); // console.log('syncAidState', 'lastPageIndex', lastPageIndex); - pageIndex = lastPageIndex + 1; + pageIndex = (lastPageIndex || 0) + 1; } console.log('syncAidState', lastPageIndex, pageIndex); @@ -180,7 +181,7 @@ class Heytrip { raw: true, logging: false, where: { update_flag: 99, - page_index: { [Op.gt]: 9999 }, + page_index: { [Op.lt]: 0 }, last_modify_time: { [Op.gt]: today }, }, attributes: ['hotel_id'], @@ -220,7 +221,7 @@ class Heytrip { // 页码滚动 const oldToNext = savedPageIds.filter((item) => !validIds.includes((item.hotel_id))).map((item) => item.hotel_id); if (!isEmpty(oldToNext)) { - await HeytripIds.update({ page_index: Number(pageIndex)+9999, update_flag: 99 }, { where: { hotel_id: oldToNext },logging: false, }); + await HeytripIds.update({ page_index: -Number(pageIndex), update_flag: 99 }, { where: { hotel_id: oldToNext },logging: false, }); } return {