history_same_odds.ts
2.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { db as Info } from '../table'
import _ = require('lodash');
import redis = require('redis');
const config = require("../../../../config");
import moment = require('moment');
import api_hemera = require('../../../api_hemera');
export const historySameOddsTemp= {
"ResultSps": null,
"BetSps": null,
"AllCount": null,
"WinCount": null,
"FlatCount": null,
"LostCount": null,
"WinRate": null,
"FlatRate": null,
"LostRate": null,
"SameOddsList": null,
"LastEndBet": null
}
export async function getHistorySameOdds(winBet:any,flatBet:any,lossBet:any){
//只比较最小的两个,winBet>5.0的时候比较负、平, 浮动0.02
let delta = 0.02
if(isNaN(winBet)||isNaN(winBet)||isNaN(winBet)){
throw "获取历史同赔参数错误"
}
let sql = `select * from ms_soccer_hdaodds_814
where
last_odds_win>=${(parseFloat(winBet)-delta).toFixed(2)} and last_odds_win<=${(parseFloat(winBet)+delta).toFixed(2)}
and last_odds_draw>=${(parseFloat(flatBet)-delta).toFixed(2)} and last_odds_draw<=${(parseFloat(flatBet)+delta).toFixed(2)}`
if(parseFloat(winBet)>3.1){
sql = `select * from ms_soccer_hdaodds_814
where
last_odds_loss>=${(parseFloat(lossBet)-delta).toFixed(2)} and last_odds_loss<=${(parseFloat(lossBet)+delta).toFixed(2)}
and last_odds_draw>=${(parseFloat(flatBet)-delta).toFixed(2)} and last_odds_draw<=${(parseFloat(flatBet)+delta).toFixed(2)}`
}
let list =await Info.db.query(sql)
if(list!=null&&list.length>0){
list=list[0]
let result:any = {
"ResultSps": null,
"BetSps": null,
"AllCount": list.length,
"WinCount": _.filter(list,(item)=>{return item.home_score>item.away_score}).length,
"FlatCount": _.filter(list,(item)=>{return item.home_score==item.away_score}).length,
"LostCount": _.filter(list,(item)=>{return item.home_score<item.away_score}).length,
"WinRate": null,
"FlatRate": null,
"LostRate": null,
"SameOddsList": JSON.stringify(_.map(list,(item)=>{
return {
BeginTime: moment.unix(item.game_date/1000).format('YYYY-MM-DD'),
HostTeamId: item.home_team_id,
HostTeam: item.home_team_name,
GuestTeamId: item.away_team_id,
GuestTeam: item.away_team_name,
HostScore: item.home_score,
GuestScore: item.away_score,
ShortName: item.competition_name,
}
})),
"LastEndBet": null
}
if(result.AllCount>0){
result.WinRate = (result.WinCount/result.AllCount).toFixed(4)
result.FlatRate = (result.FlatCount/result.AllCount).toFixed(4)
result.LostRate = (result.LostCount/result.AllCount).toFixed(4)
}
return result
}
return historySameOddsTemp
}