flyzto 3 месяцев назад
Родитель
Сommit
815fe19c66
2 измененных файлов с 14 добавлено и 4 удалено
  1. 12 2
      server/models/GamesPs.js
  2. 2 2
      server/routes/pstery.js

+ 12 - 2
server/models/GamesPs.js

@@ -40,6 +40,7 @@ const GAMES = {
   Baselist: {},
   Relations: {},
   Solutions: {},
+  UpdateTimestamp: {},
 };
 
 const Request = {
@@ -114,7 +115,7 @@ const updateLeaguesList = ({ mk, leagues }) => {
  * 获取筛选过的联赛
  */
 const getFilteredLeagues = async (mk) => {
-  return axios.get(`${BASE_API_URL}/p/getLeagueTast?mk=${mk}`, { proxy: false })
+  return axios.get(`${BASE_API_URL}/p/getLeagueTast?mk=${mk ?? ''}`, { proxy: false })
   .then(res => {
     if (res.data.code == 0) {
       return res.data.data;
@@ -345,12 +346,21 @@ const syncBaseEvents = ({ mk, games, outrights }) => {
   }
 }
 
-const updateGamesEvents = ({ platform, mk, games, outrights }) => {
+const updateGamesEvents = ({ platform, mk, games, outrights, timestamp, tp }) => {
   return new Promise((resolve, reject) => {
     if (!platform || (!games && !outrights)) {
       return reject(new Error('PLATFORM_GAMES_INVALID'));
     }
 
+    const { UpdateTimestamp } = GAMES;
+    if (!UpdateTimestamp[tp] || UpdateTimestamp[tp] < timestamp) {
+      // Logs.out('updateGamesEvents', { tp, timestamp });
+      UpdateTimestamp[tp] = timestamp;
+    }
+    else {
+      return resolve({ update: 0 });
+    }
+
     if (platform == 'ps') {
       const update = syncBaseEvents({ mk, games, outrights });
       return resolve({ update });

+ 2 - 2
server/routes/pstery.js

@@ -17,8 +17,8 @@ router.post('/update_games_list', (req, res) => {
 
 // 更新比赛盘口
 router.post('/update_games_events', (req, res) => {
-  const { platform, mk, games, outrights } = req.body ?? {};
-  Games.updateGamesEvents({ platform, mk, games, outrights })
+  const { platform, mk, games, outrights, timestamp, tp } = req.body ?? {};
+  Games.updateGamesEvents({ platform, mk, games, outrights, timestamp, tp })
   .then(updateCount => {
     res.sendSuccess({ updateCount });
   })