C3Service.go 6.1 KB
Newer Older
S
1.xxxxx  
shi.zeyuan 已提交
1 2 3
package service

import (
M
monomania 已提交
4
	"fmt"
S
1.xxxxx  
shi.zeyuan 已提交
5 6 7 8 9 10 11 12 13 14 15 16
	"math"
	"tesou.io/platform/foot-parent/foot-api/common/base"
	entity5 "tesou.io/platform/foot-parent/foot-api/module/analy/pojo"
	"tesou.io/platform/foot-parent/foot-api/module/match/pojo"
	entity3 "tesou.io/platform/foot-parent/foot-api/module/odds/pojo"
	"tesou.io/platform/foot-parent/foot-core/module/analy/constants"
	"tesou.io/platform/foot-parent/foot-core/module/match/service"
	"time"
)

type C3Service struct {
	AnalyService
S
1.xxxx  
shi.zeyuan 已提交
17
	service.BFScoreService
S
1.xxxxx  
shi.zeyuan 已提交
18 19
	service.BFBattleService
	service.BFFutureEventService
S
1.xxxx  
shi.zeyuan 已提交
20
	service.BFJinService
S
1.xxxxx  
shi.zeyuan 已提交
21 22 23 24 25 26 27 28 29

	//最大让球数据
	MaxLetBall float64
}

func (this *C3Service) ModelName() string {
	return "C3"
}

M
monomania 已提交
30 31 32 33
func (this *C3Service) AnalyTest() {
	this.AnalyService.AnalyTest(this)
}

S
1.xxxxx  
shi.zeyuan 已提交
34
func (this *C3Service) Analy(analyAll bool) {
35
	this.AnalyService.Analy(analyAll, this)
S
1.xxxxx  
shi.zeyuan 已提交
36 37 38
}

func (this *C3Service) Analy_Near() {
39
	this.AnalyService.Analy_Near(this)
S
1.xxxxx  
shi.zeyuan 已提交
40 41 42 43 44 45 46 47 48 49
}

/**
  -1 参数错误
  -2 不符合让球数
  -3 计算分析错误
  0  新增的分析结果
  1  需要更新结果
 */
func (this *C3Service) analyStub(v *pojo.MatchLast) (int, *entity5.AnalyResult) {
50
	temp_data := this.Find(v.Id, this.ModelName())
S
1.xxxxx  
shi.zeyuan 已提交
51 52
	matchId := v.Id
	//声明使用变量
M
monomania 已提交
53
	var a18Bet *entity3.AsiaHis
S
1.xxxxx  
shi.zeyuan 已提交
54 55 56
	//亚赔
	aList := this.AsiaHisService.FindByMatchIdCompId(matchId, constants.C1_REFER_ASIA)
	if len(aList) < 1 {
57
		return -1, temp_data
S
1.xxxxx  
shi.zeyuan 已提交
58
	}
M
monomania 已提交
59 60 61
	a18Bet = aList[0]
	temp_data.LetBall = a18Bet.ELetBall
	if math.Abs(a18Bet.ELetBall) > this.MaxLetBall {
S
1.xxxx  
shi.zeyuan 已提交
62
		//temp_data.Result =""
S
1.xxxxx  
shi.zeyuan 已提交
63 64
		return -2, temp_data
	}
S
1.xxxx  
shi.zeyuan 已提交
65 66

	//限制初盘,即时盘让球在0.25以内
M
monomania 已提交
67
	if math.Abs(a18Bet.SLetBall-a18Bet.ELetBall) > 0.25 {
68
		//temp_data.Result =""
M
monomania 已提交
69
		return -2, temp_data
S
1.xxxxx  
shi.zeyuan 已提交
70
	}
S
1.xxxx  
shi.zeyuan 已提交
71 72

	//得出结果
S
1.xxxxx  
shi.zeyuan 已提交
73
	preResult := -1
S
1.xxxx  
shi.zeyuan 已提交
74 75 76
	//------
	bfs_arr := this.BFScoreService.FindByMatchId(matchId)
	if len(bfs_arr) < 1 {
77
		return -1, temp_data
S
1.xxxx  
shi.zeyuan 已提交
78 79 80 81
	}

	var mainZongBfs *pojo.BFScore
	var mainZhuBfs *pojo.BFScore
M
monomania 已提交
82
	var mainZhuJinBfs *pojo.BFScore
S
1.xxxx  
shi.zeyuan 已提交
83 84
	var guestZongBfs *pojo.BFScore
	var guestKeBfs *pojo.BFScore
M
monomania 已提交
85
	var guestKeJinBfs *pojo.BFScore
S
1.xxxx  
shi.zeyuan 已提交
86 87 88 89 90 91 92 93
	for _, e := range bfs_arr { //bfs_arr有多语言版本,条数很多
		if e.TeamId == v.MainTeamId {
			if e.Type == "总" {
				mainZongBfs = e
			}
			if e.Type == "主" {
				mainZhuBfs = e
			}
M
monomania 已提交
94 95 96
			if e.Type == "近" {
				mainZhuJinBfs = e
			}
S
1.xxxx  
shi.zeyuan 已提交
97 98 99 100 101 102 103
		} else if e.TeamId == v.GuestTeamId {
			if e.Type == "总" {
				guestZongBfs = e
			}
			if e.Type == "客" {
				guestKeBfs = e
			}
M
monomania 已提交
104 105 106
			if e.Type == "近" {
				guestKeJinBfs = e
			}
S
1.xxxx  
shi.zeyuan 已提交
107 108
		}
	}
M
monomania 已提交
109
	if mainZongBfs == nil || mainZhuBfs == nil || mainZhuJinBfs == nil || guestZongBfs == nil || guestKeBfs == nil || guestKeJinBfs == nil {
110
		return -1, temp_data
S
1.xxxx  
shi.zeyuan 已提交
111
	}
M
monomania 已提交
112 113 114

	var temp_zong_val_1, temp_zong_val_2 float64 = 0, 0
	var temp_jin_val_1, temp_jin_val_2 float64 = 0, 0
S
1.xxxx  
shi.zeyuan 已提交
115 116
	if mainZongBfs.MatchCount >= 8 && guestZongBfs.MatchCount >= 8 {
		//排名越小越好
M
monomania 已提交
117 118 119 120 121
		temp_zong_val_1 = float64(mainZongBfs.Ranking - guestZongBfs.Ranking)
		temp_zong_val_2 = float64(mainZongBfs.GetGoal - guestZongBfs.GetGoal)

		temp_jin_val_1 = float64(mainZhuJinBfs.Score - guestKeJinBfs.Score)
		temp_jin_val_2 = float64(mainZhuJinBfs.GetGoal - guestKeJinBfs.GetGoal)
S
1.xxxx  
shi.zeyuan 已提交
122
	} else {
M
monomania 已提交
123
		return -1, temp_data
S
1.xxxx  
shi.zeyuan 已提交
124 125
	}

M
monomania 已提交
126 127 128 129
	//保证积分榜上,进球能力有支持
	if (temp_zong_val_1 > 0 && temp_zong_val_2 < 0) || (temp_zong_val_1 < 0 && temp_zong_val_2 > 0) {
		return -2, temp_data
	}
S
1.xxxx  
shi.zeyuan 已提交
130

M
monomania 已提交
131 132 133 134 135 136 137 138 139 140
	//2.0区间段
	var sectionBlock1, sectionBlock2 int = -1, -1

	var sectionValArr = []float64{0.0, 0.25, 0.50, 0.75, 1, 1.25, 1.5, 1.75, 2}
	//总积分的让球值
	tempLetball1 := math.Abs(temp_zong_val_1) / 10
	for i, e := range sectionValArr {
		if tempLetball1 <= e {
			sectionBlock1 = i
			break;
S
1.xxxx  
shi.zeyuan 已提交
141
		}
S
1.xxxxx  
shi.zeyuan 已提交
142
	}
M
monomania 已提交
143

M
monomania 已提交
144 145 146 147 148
	tempLetball2 := math.Abs(temp_zong_val_2) / 10
	for i, e := range sectionValArr {
		if tempLetball2 <= e {
			sectionBlock2 = i
			break;
S
1.xxxx  
shi.zeyuan 已提交
149 150 151
		}
	}

M
monomania 已提交
152 153
	if sectionBlock1 == -1 || sectionBlock2 == -1 {
		return -3, temp_data
S
1.xxxx  
shi.zeyuan 已提交
154 155 156
	}

	//3.0即时盘赔率大于等于初盘赔率
M
monomania 已提交
157 158
	sLetBall := math.Abs(a18Bet.SLetBall)
	eLetBall := math.Abs(a18Bet.ELetBall)
S
1.xxxx  
shi.zeyuan 已提交
159
	endUp := eLetBall >= sLetBall
M
monomania 已提交
160 161 162
	if !endUp {
		return -3, temp_data
	}
S
1.xxxx  
shi.zeyuan 已提交
163

M
monomania 已提交
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183

	if matchId == "1721267" {
		fmt.Println("")
	}

	//
	var bf_begin, bf_end float64
	if sectionBlock1 == sectionBlock2 {
		if sectionBlock1 == 0 {
			return -3, temp_data
		}
		bf_begin = sectionValArr[sectionBlock1] - 0.25
		bf_end = sectionValArr[sectionBlock1] + 0.25
	} else if sectionBlock1-sectionBlock2 == 1 || sectionBlock1-sectionBlock2 == -1 {
		if sectionBlock1 < sectionBlock2 {
			bf_begin = sectionValArr[sectionBlock1] - 0.25
			bf_end = sectionValArr[sectionBlock2] + 0.25
		} else {
			bf_begin = sectionValArr[sectionBlock2] - 0.25
			bf_end = sectionValArr[sectionBlock1] + 0.25
S
1.xxxx  
shi.zeyuan 已提交
184 185 186
		}
	}

M
monomania 已提交
187 188 189 190 191 192 193 194
	//存在合理区间里
	var smallLetBall float64
	if eLetBall-sLetBall >= 0 {
		smallLetBall = sLetBall
	} else {
		smallLetBall = eLetBall
	}
	if bf_end-smallLetBall >= 0.5 {
195
		return -3, temp_data
S
1.xxxx  
shi.zeyuan 已提交
196
	}
M
monomania 已提交
197 198 199 200
	var reasonable = false
	if bf_begin <= eLetBall && eLetBall <= bf_end {
		reasonable = true
	}
S
1.xxxx  
shi.zeyuan 已提交
201

M
monomania 已提交
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
	//1.0判断主队是否是让球方
	mainLetball := this.AnalyService.mainLetball(a18Bet)
	if reasonable {
		if mainLetball {
			preResult = 3
		} else {
			preResult = 0
		}
	} else {

	}

	if preResult == 3 && (temp_jin_val_1 < 0 || temp_jin_val_2 < 0) {
		preResult = -1
	}
	if preResult == 3 && (temp_jin_val_1 > 0 || temp_jin_val_2 > 0) {
		preResult = -1
	}

	if preResult < 0 {
222
		return -3, temp_data
S
1.xxxxx  
shi.zeyuan 已提交
223 224
	}

M
monomania 已提交
225
	base.Log.Info("所属于区间: ", bf_begin, " - ", bf_end, " ,对阵", v.MainTeamId+":"+v.GuestTeamId, ",初盘让球:", a18Bet.SLetBall, ",即时盘让球:", a18Bet.ELetBall)
S
1.xxxxx  
shi.zeyuan 已提交
226 227 228 229
	var data *entity5.AnalyResult
	if len(temp_data.Id) > 0 {
		temp_data.PreResult = preResult
		temp_data.HitCount = temp_data.HitCount + 1
M
monomania 已提交
230
		temp_data.LetBall = a18Bet.ELetBall
S
1.xxxxx  
shi.zeyuan 已提交
231 232 233 234 235 236 237 238
		data = temp_data
		//比赛结果
		data.Result = this.IsRight(v, data)
		return 1, data
	} else {
		data = new(entity5.AnalyResult)
		data.MatchId = v.Id
		data.MatchDate = v.MatchDate
M
monomania 已提交
239
		data.SLetBall = a18Bet.SLetBall
M
monomania 已提交
240
		data.LetBall = a18Bet.ELetBall
S
1.xxxxx  
shi.zeyuan 已提交
241 242 243 244 245 246 247 248 249 250
		data.AlFlag = this.ModelName()
		format := time.Now().Format("0102150405")
		data.AlSeq = format
		data.PreResult = preResult
		data.HitCount = 3
		//比赛结果
		data.Result = this.IsRight(v, data)
		return 0, data
	}
}