Q1Service.go 2.8 KB
Newer Older
M
monomania 已提交
1 2 3 4 5 6 7 8 9 10 11
package service

import (
	"math"
	"strings"
	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"
	"time"
)

M
monomania 已提交
12
type Q1Service struct {
M
monomania 已提交
13 14 15 16 17
	AnalyService
	//最大让球数据
	MaxLetBall float64
}

18
func (this *Q1Service) ModelName() string {
M
monomania 已提交
19 20 21
	return "Q1"
}

M
monomania 已提交
22 23 24 25
func (this *Q1Service) AnalyTest() {
	this.AnalyService.AnalyTest(this)
}

26 27
func (this *Q1Service) Analy(analyAll bool) {
	this.AnalyService.Analy(analyAll,this)
28 29 30
}

func (this *Q1Service) Analy_Near() {
31
	this.AnalyService.Analy_Near(this)
M
monomania 已提交
32 33
}

S
shi.zeyuan 已提交
34 35 36 37 38 39 40
/**
  -1 参数错误
  -2 不符合让球数
  -3 计算分析错误
  0  新增的分析结果
  1  需要更新结果
 */
M
monomania 已提交
41
func (this *Q1Service) analyStub(v *pojo.MatchLast) (int, *entity5.AnalyResult) {
42
	temp_data := this.Find(v.Id, this.ModelName())
M
monomania 已提交
43 44
	matchId := v.Id
	//声明使用变量
45 46
	var e281data *entity3.EuroHis
	var e1129data *entity3.EuroHis
47
	var a18bet *entity3.AsiaHis
48
	eList := this.EuroHisService.FindByMatchIdCompId(matchId, "281", "1129")
M
monomania 已提交
49
	if len(eList) < 2 {
50
		return -1, temp_data
M
monomania 已提交
51 52
	}
	for _, ev := range eList {
M
monomania 已提交
53 54
		if strings.EqualFold(ev.CompId, "281") {
			e281data = ev
M
monomania 已提交
55 56
			continue
		}
M
monomania 已提交
57
		if strings.EqualFold(ev.CompId, "1129") {
M
1.xxx  
monomania 已提交
58
			e1129data = ev
M
monomania 已提交
59 60 61
			continue
		}
	}
M
1.xxx  
monomania 已提交
62
	if e281data == nil || e1129data == nil  {
63
		return -1, temp_data
M
1.xxx  
monomania 已提交
64 65
	}

M
monomania 已提交
66
	//0.没有变化则跳过
M
monomania 已提交
67
	if e281data.Ep3 == e281data.Sp3 || e281data.Ep0 == e281data.Sp0 {
68
		return -3, temp_data
M
monomania 已提交
69
	}
M
monomania 已提交
70 71 72
	//if e1129data.Ep3 == e1129data.Sp3 || e1129data.Ep0 == e1129data.Sp0 {
	//	return -3, nil
	//}
M
monomania 已提交
73 74 75

	//1.有变化,进行以下逻辑
	//亚赔
76
	aList := this.AsiaHisService.FindByMatchIdCompId(matchId, "18Bet")
M
monomania 已提交
77
	if len(aList) < 1 {
78
		return -1, temp_data
M
monomania 已提交
79
	}
80 81 82
	a18bet = aList[0]
	temp_data.LetBall = a18bet.ELetBall
	if math.Abs(a18bet.ELetBall) > this.MaxLetBall {
S
shi.zeyuan 已提交
83
		return -2, temp_data
M
monomania 已提交
84 85 86 87
	}

	//得出结果
	var preResult int
M
monomania 已提交
88 89
	if e1129data.Ep3 > e281data.Ep3 && e1129data.Ep0 < e281data.Ep0 {
		preResult = 0
90
	} else if e1129data.Ep0 > e281data.Ep0 && e1129data.Ep3 < e281data.Ep3 {
M
monomania 已提交
91
		preResult = 3
92
	} else {
93
		return -3, temp_data
M
monomania 已提交
94 95 96 97 98 99
	}

	var data *entity5.AnalyResult
	if len(temp_data.Id) > 0 {
		temp_data.PreResult = preResult
		temp_data.HitCount = temp_data.HitCount + 1
100
		temp_data.LetBall = a18bet.ELetBall
M
monomania 已提交
101 102
		data = temp_data
		//比赛结果
M
monomania 已提交
103
		data.Result = this.IsRight(v, data)
M
monomania 已提交
104 105 106 107 108
		return 1, data
	} else {
		data = new(entity5.AnalyResult)
		data.MatchId = v.Id
		data.MatchDate = v.MatchDate
M
monomania 已提交
109
		data.SLetBall = a18bet.SLetBall
110
		data.LetBall = a18bet.ELetBall
M
monomania 已提交
111
		data.AlFlag = this.ModelName()
M
monomania 已提交
112 113 114
		format := time.Now().Format("0102150405")
		data.AlSeq = format
		data.PreResult = preResult
S
shi.zeyuan 已提交
115
		data.HitCount = 3
116
		data.LetBall = a18bet.ELetBall
M
monomania 已提交
117
		//比赛结果
M
monomania 已提交
118
		data.Result = this.IsRight(v, data)
M
monomania 已提交
119 120 121
		return 0, data
	}
}