ms_schedule.ts
1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import * as infodb from '../table'
import moment = require('moment');
import { cache,redis as client, redis, task_lock } from '../../../cache';
//ms_schedule
async function getMsSchedulesByLottery({lotteryId}:any) {
let key = `${config.CachePrefix}match:match_ms_schedule:v1_${moment().add(-10,'day').format('YYYY-MM-DD')}_${lotteryId}`
let reply = await client.get(key);
if (reply) {
return JSON.parse(reply)
}
let result = await infodb.ms_schedule.findAll({
where:{
core_lottery_id:lotteryId,
core_match_time:{$gt:moment().add(-10,'day').format('YYYY-MM-DD')},
},
limit:1000,
attributes: ['core_match_id', 'sportsdt_match_id', 'sportsdt_host_team_id'
, 'sportsdt_guest_team_id', 'sportsdt_competition_id', 'sportsdt_type', 'sportsdt_degree'
, 'sportsdt_num', 'sportsdt_starttime', 'sportsdt_isah'],
})
await client.set(key,JSON.stringify(result))
await client.expire(key, 60*10)
return result
}
async function getMsSchedulesByCoreIds({CoreIds}:any) {
return cache(async ({CoreIds}:any)=>{
let result = (await infodb.ms_schedule.findAll({
where:{
core_match_id:{$in:CoreIds},
core_match_time:{$gt:moment().add(-120,'day').format('YYYY-MM-DD')},
},
limit:1000,
attributes: ['core_match_id', 'sportsdt_match_id', 'sportsdt_host_team_id'
, 'sportsdt_guest_team_id', 'sportsdt_competition_id', 'sportsdt_type', 'sportsdt_degree'
, 'sportsdt_num', 'sportsdt_starttime', 'sportsdt_isah', 'sportsdt_n'
, 'yiqiu_match_id', 'sporttery_match_id', 'w500_match_id', 'info_match_id'],
})).map((o:any)=>o.dataValues)
return result
},{CoreIds},10,"getMsSchedulesByCoreIds:v1",60,100)
}
export {getMsSchedulesByLottery,getMsSchedulesByCoreIds}