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 {