unit test bet outcome
This commit is contained in:
parent
c637ddb321
commit
95eaed18ad
|
|
@ -4177,7 +4177,7 @@ const docTemplate = `{
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Virtual Games"
|
"Veli Games"
|
||||||
],
|
],
|
||||||
"summary": "Veli Games webhook handler",
|
"summary": "Veli Games webhook handler",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
|
|
|
||||||
|
|
@ -4169,7 +4169,7 @@
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Virtual Games"
|
"Veli Games"
|
||||||
],
|
],
|
||||||
"summary": "Veli Games webhook handler",
|
"summary": "Veli Games webhook handler",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
|
|
|
||||||
|
|
@ -4258,7 +4258,7 @@ paths:
|
||||||
type: object
|
type: object
|
||||||
summary: Veli Games webhook handler
|
summary: Veli Games webhook handler
|
||||||
tags:
|
tags:
|
||||||
- Virtual Games
|
- Veli Games
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
Bearer:
|
Bearer:
|
||||||
in: header
|
in: header
|
||||||
|
|
|
||||||
|
|
@ -498,9 +498,9 @@ func evaluateTotalOverUnder(outcome domain.BetOutcome, score struct{ Home, Away
|
||||||
return domain.OUTCOME_STATUS_ERROR, fmt.Errorf("invalid odd header: %s", outcome.OddHeader)
|
return domain.OUTCOME_STATUS_ERROR, fmt.Errorf("invalid odd header: %s", outcome.OddHeader)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Result and Total betting is a type of bet where the bettor predicts
|
// Result and Total betting is a type of bet where the bettor predicts
|
||||||
// the outcome of a match and whether the total number of points scored will be over or under a specified number.
|
// the outcome of a match and whether the total number of points scored will be over or under a specified number.
|
||||||
func evaluateResultAndTotal(outcome domain.BetOutcome, score struct{ Home, Away int }) (domain.OutcomeStatus, error) {
|
func evaluateResultAndTotal(outcome domain.BetOutcome, score struct{ Home, Away int }) (domain.OutcomeStatus, error) {
|
||||||
|
|
||||||
// The handicap will be in the format "U {float}" or "O {float}"
|
// The handicap will be in the format "U {float}" or "O {float}"
|
||||||
// U and O denoting over and under for this case
|
// U and O denoting over and under for this case
|
||||||
|
|
@ -548,11 +548,11 @@ func evaluateResultAndTotal(outcome domain.BetOutcome, score struct{ Home, Away
|
||||||
default:
|
default:
|
||||||
return domain.OUTCOME_STATUS_ERROR, fmt.Errorf("failed to parse over and under: %s", outcome.OddName)
|
return domain.OUTCOME_STATUS_ERROR, fmt.Errorf("failed to parse over and under: %s", outcome.OddName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Team Total betting is a type of bet where the bettor predicts the total number of points scored by a specific team in a match
|
// Team Total betting is a type of bet where the bettor predicts the total number of points scored by a specific team in a match
|
||||||
// is over or under a specified number.
|
// is over or under a specified number.
|
||||||
func evaluateTeamTotal(outcome domain.BetOutcome, score struct{ Home, Away int }) (domain.OutcomeStatus, error) {
|
func evaluateTeamTotal(outcome domain.BetOutcome, score struct{ Home, Away int }) (domain.OutcomeStatus, error) {
|
||||||
|
|
||||||
// The handicap will be in the format "U {float}" or "O {float}"
|
// The handicap will be in the format "U {float}" or "O {float}"
|
||||||
// U and O denoting over and under for this case
|
// U and O denoting over and under for this case
|
||||||
|
|
@ -594,11 +594,11 @@ func evaluateTeamTotal(outcome domain.BetOutcome, score struct{ Home, Away int }
|
||||||
default:
|
default:
|
||||||
return domain.OUTCOME_STATUS_ERROR, fmt.Errorf("failed to parse over and under: %s", outcome.OddName)
|
return domain.OUTCOME_STATUS_ERROR, fmt.Errorf("failed to parse over and under: %s", outcome.OddName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Result and Both Teams To Score X Points is a type of bet where the bettor predicts whether both teams will score a certain number of points
|
// Result and Both Teams To Score X Points is a type of bet where the bettor predicts whether both teams will score a certain number of points
|
||||||
// and also the result fo the match
|
// and also the result fo the match
|
||||||
func evaluateResultAndBTTSX(outcome domain.BetOutcome, score struct{ Home, Away int }) (domain.OutcomeStatus, error) {
|
func evaluateResultAndBTTSX(outcome domain.BetOutcome, score struct{ Home, Away int }) (domain.OutcomeStatus, error) {
|
||||||
|
|
||||||
// The name parameter will hold value "name": "{team_name} and {Yes | No}"
|
// The name parameter will hold value "name": "{team_name} and {Yes | No}"
|
||||||
// The best way to do this is to evaluate backwards since there might be
|
// The best way to do this is to evaluate backwards since there might be
|
||||||
|
|
@ -646,10 +646,10 @@ func evaluateResultAndBTTSX(outcome domain.BetOutcome, score struct{ Home, Away
|
||||||
|
|
||||||
return domain.OUTCOME_STATUS_LOSS, nil
|
return domain.OUTCOME_STATUS_LOSS, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Both Teams To Score X Points is a type of bet where the bettor predicts whether both teams will score a certain number of points.
|
// Both Teams To Score X Points is a type of bet where the bettor predicts whether both teams will score a certain number of points.
|
||||||
func evaluateBTTSX(outcome domain.BetOutcome, score struct{ Home, Away int }) (domain.OutcomeStatus, error) {
|
func evaluateBTTSX(outcome domain.BetOutcome, score struct{ Home, Away int }) (domain.OutcomeStatus, error) {
|
||||||
threshold, err := strconv.ParseInt(outcome.OddName, 10, 64)
|
threshold, err := strconv.ParseInt(outcome.OddName, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return domain.OUTCOME_STATUS_ERROR, fmt.Errorf("invalid threshold: %s", outcome.OddName)
|
return domain.OUTCOME_STATUS_ERROR, fmt.Errorf("invalid threshold: %s", outcome.OddName)
|
||||||
|
|
@ -670,10 +670,10 @@ func evaluateBTTSX(outcome domain.BetOutcome, score struct{ Home, Away int }) (d
|
||||||
}
|
}
|
||||||
|
|
||||||
return domain.OUTCOME_STATUS_LOSS, nil
|
return domain.OUTCOME_STATUS_LOSS, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Money Line 3 Way betting is a type of bet where the bettor predicts the outcome of a match with three possible outcomes: home win, away win, or draw.
|
// Money Line 3 Way betting is a type of bet where the bettor predicts the outcome of a match with three possible outcomes: home win, away win, or draw.
|
||||||
func evaluateMoneyLine3Way(outcome domain.BetOutcome, score struct{ Home, Away int }) (domain.OutcomeStatus, error) {
|
func evaluateMoneyLine3Way(outcome domain.BetOutcome, score struct{ Home, Away int }) (domain.OutcomeStatus, error) {
|
||||||
switch outcome.OddName {
|
switch outcome.OddName {
|
||||||
case "1": // Home win
|
case "1": // Home win
|
||||||
if score.Home > score.Away {
|
if score.Home > score.Away {
|
||||||
|
|
@ -693,10 +693,10 @@ func evaluateMoneyLine3Way(outcome domain.BetOutcome, score struct{ Home, Away i
|
||||||
default:
|
default:
|
||||||
return domain.OUTCOME_STATUS_ERROR, fmt.Errorf("invalid odd name: %s", outcome.OddName)
|
return domain.OUTCOME_STATUS_ERROR, fmt.Errorf("invalid odd name: %s", outcome.OddName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Double Result betting is a type of bet where the bettor predicts the outcome of a match at both half-time and full-time.
|
// Double Result betting is a type of bet where the bettor predicts the outcome of a match at both half-time and full-time.
|
||||||
func evaluateDoubleResult(outcome domain.BetOutcome, firstHalfScore struct{ Home, Away int }, secondHalfScore struct{ Home, Away int }) (domain.OutcomeStatus, error) {
|
func evaluateDoubleResult(outcome domain.BetOutcome, firstHalfScore struct{ Home, Away int }, secondHalfScore struct{ Home, Away int }) (domain.OutcomeStatus, error) {
|
||||||
halfWins := strings.Split(outcome.OddName, "-")
|
halfWins := strings.Split(outcome.OddName, "-")
|
||||||
if len(halfWins) != 2 {
|
if len(halfWins) != 2 {
|
||||||
return domain.OUTCOME_STATUS_ERROR, fmt.Errorf("invalid odd name: %s", outcome.OddName)
|
return domain.OUTCOME_STATUS_ERROR, fmt.Errorf("invalid odd name: %s", outcome.OddName)
|
||||||
|
|
@ -730,10 +730,10 @@ func evaluateDoubleResult(outcome domain.BetOutcome, firstHalfScore struct{ Home
|
||||||
}
|
}
|
||||||
|
|
||||||
return domain.OUTCOME_STATUS_WIN, nil
|
return domain.OUTCOME_STATUS_WIN, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Highest Scoring Half betting is a type of bet where the bettor predicts which half of the match will have the highest total score.
|
// Highest Scoring Half betting is a type of bet where the bettor predicts which half of the match will have the highest total score.
|
||||||
func evaluateHighestScoringHalf(outcome domain.BetOutcome, firstScore struct{ Home, Away int }, secondScore struct{ Home, Away int }) (domain.OutcomeStatus, error) {
|
func evaluateHighestScoringHalf(outcome domain.BetOutcome, firstScore struct{ Home, Away int }, secondScore struct{ Home, Away int }) (domain.OutcomeStatus, error) {
|
||||||
firstHalfTotal := firstScore.Home + firstScore.Away
|
firstHalfTotal := firstScore.Home + firstScore.Away
|
||||||
secondHalfTotal := secondScore.Home + secondScore.Away
|
secondHalfTotal := secondScore.Home + secondScore.Away
|
||||||
switch outcome.OddName {
|
switch outcome.OddName {
|
||||||
|
|
@ -753,10 +753,10 @@ func evaluateHighestScoringHalf(outcome domain.BetOutcome, firstScore struct{ Ho
|
||||||
return domain.OUTCOME_STATUS_ERROR, fmt.Errorf("invalid oddname: %s", outcome.OddName)
|
return domain.OUTCOME_STATUS_ERROR, fmt.Errorf("invalid oddname: %s", outcome.OddName)
|
||||||
}
|
}
|
||||||
return domain.OUTCOME_STATUS_LOSS, nil
|
return domain.OUTCOME_STATUS_LOSS, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Highest Scoring Quarter betting is a type of bet where the bettor predicts which quarter of the match will have the highest score.
|
// Highest Scoring Quarter betting is a type of bet where the bettor predicts which quarter of the match will have the highest score.
|
||||||
func evaluateHighestScoringQuarter(outcome domain.BetOutcome, firstScore struct{ Home, Away int }, secondScore struct{ Home, Away int }, thirdScore struct{ Home, Away int }, fourthScore struct{ Home, Away int }) (domain.OutcomeStatus, error) {
|
func evaluateHighestScoringQuarter(outcome domain.BetOutcome, firstScore struct{ Home, Away int }, secondScore struct{ Home, Away int }, thirdScore struct{ Home, Away int }, fourthScore struct{ Home, Away int }) (domain.OutcomeStatus, error) {
|
||||||
firstQuarterTotal := firstScore.Home + firstScore.Away
|
firstQuarterTotal := firstScore.Home + firstScore.Away
|
||||||
secondQuarterTotal := secondScore.Home + secondScore.Away
|
secondQuarterTotal := secondScore.Home + secondScore.Away
|
||||||
thirdQuarterTotal := thirdScore.Home + thirdScore.Away
|
thirdQuarterTotal := thirdScore.Home + thirdScore.Away
|
||||||
|
|
@ -787,10 +787,10 @@ func evaluateHighestScoringQuarter(outcome domain.BetOutcome, firstScore struct{
|
||||||
return domain.OUTCOME_STATUS_ERROR, fmt.Errorf("invalid oddname: %s", outcome.OddName)
|
return domain.OUTCOME_STATUS_ERROR, fmt.Errorf("invalid oddname: %s", outcome.OddName)
|
||||||
}
|
}
|
||||||
return domain.OUTCOME_STATUS_LOSS, nil
|
return domain.OUTCOME_STATUS_LOSS, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Team With Highest Scoring Quarter betting is a type of bet where the bettor predicts which team will have the highest score in a specific quarter.
|
// Team With Highest Scoring Quarter betting is a type of bet where the bettor predicts which team will have the highest score in a specific quarter.
|
||||||
func evaluateTeamWithHighestScoringQuarter(outcome domain.BetOutcome, firstScore struct{ Home, Away int }, secondScore struct{ Home, Away int }, thirdScore struct{ Home, Away int }, fourthScore struct{ Home, Away int }) (domain.OutcomeStatus, error) {
|
func evaluateTeamWithHighestScoringQuarter(outcome domain.BetOutcome, firstScore struct{ Home, Away int }, secondScore struct{ Home, Away int }, thirdScore struct{ Home, Away int }, fourthScore struct{ Home, Away int }) (domain.OutcomeStatus, error) {
|
||||||
homeTeamHighestQuarter := max(firstScore.Home, secondScore.Home, thirdScore.Home, fourthScore.Home)
|
homeTeamHighestQuarter := max(firstScore.Home, secondScore.Home, thirdScore.Home, fourthScore.Home)
|
||||||
awayTeamHighestQuarter := max(firstScore.Away, secondScore.Away, thirdScore.Away, fourthScore.Away)
|
awayTeamHighestQuarter := max(firstScore.Away, secondScore.Away, thirdScore.Away, fourthScore.Away)
|
||||||
|
|
||||||
|
|
@ -811,11 +811,11 @@ func evaluateTeamWithHighestScoringQuarter(outcome domain.BetOutcome, firstScore
|
||||||
return domain.OUTCOME_STATUS_ERROR, fmt.Errorf("invalid oddname: %s", outcome.OddName)
|
return domain.OUTCOME_STATUS_ERROR, fmt.Errorf("invalid oddname: %s", outcome.OddName)
|
||||||
}
|
}
|
||||||
return domain.OUTCOME_STATUS_LOSS, nil
|
return domain.OUTCOME_STATUS_LOSS, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handicap and Total betting is a combination of spread betting and total points betting
|
// Handicap and Total betting is a combination of spread betting and total points betting
|
||||||
// where the bettor predicts the outcome of a match with a point spread and the total number of points scored is over or under a specified number.
|
// where the bettor predicts the outcome of a match with a point spread and the total number of points scored is over or under a specified number.
|
||||||
func evaluateHandicapAndTotal(outcome domain.BetOutcome, score struct{ Home, Away int }) (domain.OutcomeStatus, error) {
|
func evaluateHandicapAndTotal(outcome domain.BetOutcome, score struct{ Home, Away int }) (domain.OutcomeStatus, error) {
|
||||||
|
|
||||||
nameSplit := strings.Split(outcome.OddName, " ")
|
nameSplit := strings.Split(outcome.OddName, " ")
|
||||||
// Evaluate from bottom to get the threshold and find out if its over or under
|
// Evaluate from bottom to get the threshold and find out if its over or under
|
||||||
|
|
@ -864,10 +864,10 @@ func evaluateHandicapAndTotal(outcome domain.BetOutcome, score struct{ Home, Awa
|
||||||
return domain.OUTCOME_STATUS_ERROR, fmt.Errorf("failed parsing team name: %s", outcome.OddName)
|
return domain.OUTCOME_STATUS_ERROR, fmt.Errorf("failed parsing team name: %s", outcome.OddName)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Winning Margin betting is a type of bet where the bettor predicts the margin of victory in a match.
|
// Winning Margin betting is a type of bet where the bettor predicts the margin of victory in a match.
|
||||||
func evaluateWinningMargin(outcome domain.BetOutcome, score struct{ Home, Away int }) (domain.OutcomeStatus, error) {
|
func evaluateWinningMargin(outcome domain.BetOutcome, score struct{ Home, Away int }) (domain.OutcomeStatus, error) {
|
||||||
|
|
||||||
marginSplit := strings.Split(outcome.OddName, "")
|
marginSplit := strings.Split(outcome.OddName, "")
|
||||||
if len(marginSplit) < 1 {
|
if len(marginSplit) < 1 {
|
||||||
|
|
@ -901,10 +901,10 @@ func evaluateWinningMargin(outcome domain.BetOutcome, score struct{ Home, Away i
|
||||||
}
|
}
|
||||||
|
|
||||||
return domain.OUTCOME_STATUS_ERROR, fmt.Errorf("invalid oddheader: %s", outcome.OddHeader)
|
return domain.OUTCOME_STATUS_ERROR, fmt.Errorf("invalid oddheader: %s", outcome.OddHeader)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Highest Scoring Period betting is a type of bet where the bettor predicts which period of the match will have the highest total score.
|
// Highest Scoring Period betting is a type of bet where the bettor predicts which period of the match will have the highest total score.
|
||||||
func evaluateHighestScoringPeriod(outcome domain.BetOutcome, firstScore struct{ Home, Away int }, secondScore struct{ Home, Away int }, thirdScore struct{ Home, Away int }) (domain.OutcomeStatus, error) {
|
func evaluateHighestScoringPeriod(outcome domain.BetOutcome, firstScore struct{ Home, Away int }, secondScore struct{ Home, Away int }, thirdScore struct{ Home, Away int }) (domain.OutcomeStatus, error) {
|
||||||
firstPeriodTotal := firstScore.Home + firstScore.Away
|
firstPeriodTotal := firstScore.Home + firstScore.Away
|
||||||
secondPeriodTotal := secondScore.Home + secondScore.Away
|
secondPeriodTotal := secondScore.Home + secondScore.Away
|
||||||
thirdPeriodTotal := thirdScore.Home + thirdScore.Away
|
thirdPeriodTotal := thirdScore.Home + thirdScore.Away
|
||||||
|
|
@ -930,10 +930,10 @@ func evaluateHighestScoringPeriod(outcome domain.BetOutcome, firstScore struct{
|
||||||
return domain.OUTCOME_STATUS_ERROR, fmt.Errorf("invalid oddname: %s", outcome.OddName)
|
return domain.OUTCOME_STATUS_ERROR, fmt.Errorf("invalid oddname: %s", outcome.OddName)
|
||||||
}
|
}
|
||||||
return domain.OUTCOME_STATUS_LOSS, nil
|
return domain.OUTCOME_STATUS_LOSS, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tied After Regulation is a type of bet where the bettor predicts whether the match will end in a tie after regulation time.
|
// Tied After Regulation is a type of bet where the bettor predicts whether the match will end in a tie after regulation time.
|
||||||
func evaluateTiedAfterRegulation(outcome domain.BetOutcome, scores []struct{ Home, Away int }) (domain.OutcomeStatus, error) {
|
func evaluateTiedAfterRegulation(outcome domain.BetOutcome, scores []struct{ Home, Away int }) (domain.OutcomeStatus, error) {
|
||||||
totalScore := struct{ Home, Away int }{0, 0}
|
totalScore := struct{ Home, Away int }{0, 0}
|
||||||
for _, score := range scores {
|
for _, score := range scores {
|
||||||
totalScore.Home += score.Home
|
totalScore.Home += score.Home
|
||||||
|
|
@ -953,10 +953,10 @@ func evaluateTiedAfterRegulation(outcome domain.BetOutcome, scores []struct{ Hom
|
||||||
}
|
}
|
||||||
|
|
||||||
return domain.OUTCOME_STATUS_ERROR, fmt.Errorf("invalid oddname: %s", outcome.OddName)
|
return domain.OUTCOME_STATUS_ERROR, fmt.Errorf("invalid oddname: %s", outcome.OddName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// evaluateRugbyOutcome evaluates the outcome of a Rugby bet
|
// evaluateRugbyOutcome evaluates the outcome of a Rugby bet
|
||||||
func evaluateRugbyOutcome(outcome domain.BetOutcome, result *domain.RugbyResultResponse) (domain.OutcomeStatus, error) {
|
func evaluateRugbyOutcome(outcome domain.BetOutcome, result *domain.RugbyResultResponse) (domain.OutcomeStatus, error) {
|
||||||
finalScore := parseSS(result.SS)
|
finalScore := parseSS(result.SS)
|
||||||
|
|
||||||
switch outcome.MarketName {
|
switch outcome.MarketName {
|
||||||
|
|
@ -969,10 +969,10 @@ func evaluateRugbyOutcome(outcome domain.BetOutcome, result *domain.RugbyResultR
|
||||||
default:
|
default:
|
||||||
return domain.OUTCOME_STATUS_PENDING, fmt.Errorf("unsupported rugby market: %s", outcome.MarketName)
|
return domain.OUTCOME_STATUS_PENDING, fmt.Errorf("unsupported rugby market: %s", outcome.MarketName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// evaluateBaseballOutcome evaluates the outcome of a Baseball bet
|
// evaluateBaseballOutcome evaluates the outcome of a Baseball bet
|
||||||
func evaluateBaseballOutcome(outcome domain.BetOutcome, result *domain.BaseballResultResponse) (domain.OutcomeStatus, error) {
|
func evaluateBaseballOutcome(outcome domain.BetOutcome, result *domain.BaseballResultResponse) (domain.OutcomeStatus, error) {
|
||||||
finalScore := parseSS(result.SS)
|
finalScore := parseSS(result.SS)
|
||||||
|
|
||||||
switch outcome.MarketName {
|
switch outcome.MarketName {
|
||||||
|
|
@ -985,4 +985,4 @@ func evaluateBaseballOutcome(outcome domain.BetOutcome, result *domain.BaseballR
|
||||||
default:
|
default:
|
||||||
return domain.OUTCOME_STATUS_PENDING, fmt.Errorf("unsupported baseball market: %s", outcome.MarketName)
|
return domain.OUTCOME_STATUS_PENDING, fmt.Errorf("unsupported baseball market: %s", outcome.MarketName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
49
internal/services/result/service_test.go
Normal file
49
internal/services/result/service_test.go
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
package result
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/SamuelTariku/FortuneBet-Backend/internal/domain"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestEvaluateFootballOutcome(t *testing.T) {
|
||||||
|
service := &Service{} // or your real logger
|
||||||
|
|
||||||
|
// Mock outcome
|
||||||
|
outcome := domain.BetOutcome{
|
||||||
|
ID: 1,
|
||||||
|
BetID: 1,
|
||||||
|
EventID: 1001,
|
||||||
|
OddID: 2001,
|
||||||
|
SportID: 1, // Assuming 1 = Football
|
||||||
|
HomeTeamName: "Manchester",
|
||||||
|
AwayTeamName: "Liverpool",
|
||||||
|
MarketID: int64(domain.FOOTBALL_FULL_TIME_RESULT),
|
||||||
|
MarketName: "Full Time Result",
|
||||||
|
Odd: 1.75,
|
||||||
|
OddName: "2", // Home win
|
||||||
|
OddHeader: "1",
|
||||||
|
OddHandicap: "",
|
||||||
|
Status: domain.OUTCOME_STATUS_PENDING, // Initial status
|
||||||
|
Expires: time.Now().Add(24 * time.Hour),
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parsed result (simulate Bet365 JSON)
|
||||||
|
finalScore := struct{ Home, Away int }{Home: 2, Away: 1}
|
||||||
|
firstHalfScore := struct{ Home, Away int }{Home: 1, Away: 1}
|
||||||
|
secondHalfScore := struct{ Home, Away int }{Home: 1, Away: 0}
|
||||||
|
corners := struct{ Home, Away int }{Home: 5, Away: 3}
|
||||||
|
halfTimeCorners := struct{ Home, Away int }{Home: 2, Away: 2}
|
||||||
|
events := []map[string]string{
|
||||||
|
{"type": "goal", "team": "home", "minute": "23"},
|
||||||
|
{"type": "goal", "team": "away", "minute": "34"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Act
|
||||||
|
status, _ := service.evaluateFootballOutcome(outcome, finalScore, firstHalfScore, secondHalfScore, corners, halfTimeCorners, events)
|
||||||
|
|
||||||
|
fmt.Printf("\n\nBet Outcome: %v\n\n", &status)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -42,7 +42,7 @@ func (h *Handler) LaunchVeliGame(c *fiber.Ctx) error {
|
||||||
// HandleVeliCallback godoc
|
// HandleVeliCallback godoc
|
||||||
// @Summary Veli Games webhook handler
|
// @Summary Veli Games webhook handler
|
||||||
// @Description Processes game round settlements from Veli
|
// @Description Processes game round settlements from Veli
|
||||||
// @Tags Virtual Games
|
// @Tags Veli Games
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param payload body domain.VeliCallback true "Callback payload"
|
// @Param payload body domain.VeliCallback true "Callback payload"
|
||||||
|
|
|
||||||
|
|
@ -194,11 +194,11 @@ func (a *App) initAppRoutes() {
|
||||||
group.Post("/webhooks/alea-play", a.authMiddleware, h.HandleAleaCallback)
|
group.Post("/webhooks/alea-play", a.authMiddleware, h.HandleAleaCallback)
|
||||||
|
|
||||||
//Veli Virtual Game Routes
|
//Veli Virtual Game Routes
|
||||||
group.Get("/veli-games/launch", a.authMiddleware, h.LaunchVeliGame)
|
group.Get("/veli-games/launch", h.LaunchVeliGame)
|
||||||
group.Post("/webhooks/veli-games", a.authMiddleware, h.HandleVeliCallback)
|
group.Post("/webhooks/veli-games", h.HandleVeliCallback)
|
||||||
|
|
||||||
// Recommendation Routes
|
// Recommendation Routes
|
||||||
group.Get("/virtual-games/recommendations/:userID", a.authMiddleware, h.GetRecommendations)
|
group.Get("/virtual-games/recommendations/:userID", h.GetRecommendations)
|
||||||
|
|
||||||
// Transactions /transactions
|
// Transactions /transactions
|
||||||
a.fiber.Post("/transaction", a.authMiddleware, h.CreateTransaction)
|
a.fiber.Post("/transaction", a.authMiddleware, h.CreateTransaction)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user