61 lines
1.3 KiB
SQL
61 lines
1.3 KiB
SQL
-- name: CreateBet :one
|
|
INSERT INTO bets (
|
|
amount,
|
|
total_odds,
|
|
status,
|
|
full_name,
|
|
phone_number,
|
|
branch_id,
|
|
user_id,
|
|
is_shop_bet,
|
|
cashout_id
|
|
)
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
|
|
RETURNING *;
|
|
-- name: CreateBetOutcome :copyfrom
|
|
INSERT INTO bet_outcomes (
|
|
bet_id,
|
|
event_id,
|
|
odd_id,
|
|
home_team_name,
|
|
away_team_name,
|
|
market_id,
|
|
market_name,
|
|
odd,
|
|
odd_name,
|
|
odd_header,
|
|
odd_handicap,
|
|
expires
|
|
)
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12);
|
|
-- name: GetAllBets :many
|
|
SELECT *
|
|
FROM bet_with_outcomes;
|
|
-- name: GetBetByID :one
|
|
SELECT *
|
|
FROM bet_with_outcomes
|
|
WHERE id = $1;
|
|
-- name: GetBetByCashoutID :one
|
|
SELECT *
|
|
FROM bet_with_outcomes
|
|
WHERE cashout_id = $1;
|
|
-- name: GetBetByBranchID :many
|
|
SELECT *
|
|
FROM bet_with_outcomes
|
|
WHERE branch_id = $1;
|
|
-- name: UpdateCashOut :exec
|
|
UPDATE bets
|
|
SET cashed_out = $2,
|
|
updated_at = CURRENT_TIMESTAMP
|
|
WHERE id = $1;
|
|
-- name: UpdateStatus :exec
|
|
UPDATE bets
|
|
SET status = $2,
|
|
updated_at = CURRENT_TIMESTAMP
|
|
WHERE id = $1;
|
|
-- name: DeleteBet :exec
|
|
DELETE FROM bets
|
|
WHERE id = $1;
|
|
-- name: DeleteBetOutcome :exec
|
|
DELETE FROM bet_outcomes
|
|
WHERE bet_id = $1; |