Yimaru-BackEnd/gen/db/shop_transactions.sql.go

712 lines
18 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.29.0
// source: shop_transactions.sql
package dbgen
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const CreateShopBet = `-- name: CreateShopBet :one
INSERT INTO shop_bets (
shop_transaction_id,
cashout_id,
bet_id,
number_of_outcomes
)
VALUES ($1, $2, $3, $4)
RETURNING id, shop_transaction_id, cashout_id, cashed_out_by, bet_id, number_of_outcomes, cashed_out, created_at, updated_at
`
type CreateShopBetParams struct {
ShopTransactionID int64 `json:"shop_transaction_id"`
CashoutID string `json:"cashout_id"`
BetID int64 `json:"bet_id"`
NumberOfOutcomes int64 `json:"number_of_outcomes"`
}
func (q *Queries) CreateShopBet(ctx context.Context, arg CreateShopBetParams) (ShopBet, error) {
row := q.db.QueryRow(ctx, CreateShopBet,
arg.ShopTransactionID,
arg.CashoutID,
arg.BetID,
arg.NumberOfOutcomes,
)
var i ShopBet
err := row.Scan(
&i.ID,
&i.ShopTransactionID,
&i.CashoutID,
&i.CashedOutBy,
&i.BetID,
&i.NumberOfOutcomes,
&i.CashedOut,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const CreateShopDeposit = `-- name: CreateShopDeposit :one
INSERT INTO shop_deposits (
shop_transaction_id,
customer_id,
wallet_transfer_id
)
VALUES ($1, $2, $3)
RETURNING id, shop_transaction_id, customer_id, wallet_transfer_id, created_at, updated_at
`
type CreateShopDepositParams struct {
ShopTransactionID int64 `json:"shop_transaction_id"`
CustomerID int64 `json:"customer_id"`
WalletTransferID int64 `json:"wallet_transfer_id"`
}
func (q *Queries) CreateShopDeposit(ctx context.Context, arg CreateShopDepositParams) (ShopDeposit, error) {
row := q.db.QueryRow(ctx, CreateShopDeposit, arg.ShopTransactionID, arg.CustomerID, arg.WalletTransferID)
var i ShopDeposit
err := row.Scan(
&i.ID,
&i.ShopTransactionID,
&i.CustomerID,
&i.WalletTransferID,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const CreateShopTransaction = `-- name: CreateShopTransaction :one
INSERT INTO shop_transactions (
amount,
branch_id,
company_id,
user_id,
type,
full_name,
phone_number,
payment_option,
bank_code,
beneficiary_name,
account_name,
account_number,
reference_number
)
VALUES (
$1,
$2,
$3,
$4,
$5,
$6,
$7,
$8,
$9,
$10,
$11,
$12,
$13
)
RETURNING id, amount, branch_id, company_id, user_id, type, full_name, phone_number, payment_option, bank_code, beneficiary_name, account_name, account_number, reference_number, approved_by, verified, created_at, updated_at
`
type CreateShopTransactionParams struct {
Amount int64 `json:"amount"`
BranchID int64 `json:"branch_id"`
CompanyID int64 `json:"company_id"`
UserID int64 `json:"user_id"`
Type int64 `json:"type"`
FullName string `json:"full_name"`
PhoneNumber string `json:"phone_number"`
PaymentOption int64 `json:"payment_option"`
BankCode pgtype.Text `json:"bank_code"`
BeneficiaryName pgtype.Text `json:"beneficiary_name"`
AccountName pgtype.Text `json:"account_name"`
AccountNumber pgtype.Text `json:"account_number"`
ReferenceNumber pgtype.Text `json:"reference_number"`
}
func (q *Queries) CreateShopTransaction(ctx context.Context, arg CreateShopTransactionParams) (ShopTransaction, error) {
row := q.db.QueryRow(ctx, CreateShopTransaction,
arg.Amount,
arg.BranchID,
arg.CompanyID,
arg.UserID,
arg.Type,
arg.FullName,
arg.PhoneNumber,
arg.PaymentOption,
arg.BankCode,
arg.BeneficiaryName,
arg.AccountName,
arg.AccountNumber,
arg.ReferenceNumber,
)
var i ShopTransaction
err := row.Scan(
&i.ID,
&i.Amount,
&i.BranchID,
&i.CompanyID,
&i.UserID,
&i.Type,
&i.FullName,
&i.PhoneNumber,
&i.PaymentOption,
&i.BankCode,
&i.BeneficiaryName,
&i.AccountName,
&i.AccountNumber,
&i.ReferenceNumber,
&i.ApprovedBy,
&i.Verified,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}
const GetAllShopBets = `-- name: GetAllShopBets :many
SELECT id, shop_transaction_id, cashout_id, cashed_out_by, bet_id, number_of_outcomes, cashed_out, created_at, updated_at, customer_full_name, customer_phone_number, branch_id, company_id, amount, transaction_verified, status, total_odds, outcomes
FROM shop_bet_detail
WHERE (
full_name ILIKE '%' || $1 || '%'
OR phone_number ILIKE '%' || $1 || '%'
OR $1 IS NULL
)
AND (
branch_id = $2
OR $2 IS NULL
)
AND (
company_id = $3
OR $3 IS NULL
)
AND (
created_at > $4
OR $4 IS NULL
)
AND (
created_at < $5
OR $5 IS NULL
)
`
type GetAllShopBetsParams struct {
Query pgtype.Text `json:"query"`
BranchID pgtype.Int8 `json:"branch_id"`
CompanyID pgtype.Int8 `json:"company_id"`
CreatedBefore pgtype.Timestamp `json:"created_before"`
CreatedAfter pgtype.Timestamp `json:"created_after"`
}
func (q *Queries) GetAllShopBets(ctx context.Context, arg GetAllShopBetsParams) ([]ShopBetDetail, error) {
rows, err := q.db.Query(ctx, GetAllShopBets,
arg.Query,
arg.BranchID,
arg.CompanyID,
arg.CreatedBefore,
arg.CreatedAfter,
)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ShopBetDetail
for rows.Next() {
var i ShopBetDetail
if err := rows.Scan(
&i.ID,
&i.ShopTransactionID,
&i.CashoutID,
&i.CashedOutBy,
&i.BetID,
&i.NumberOfOutcomes,
&i.CashedOut,
&i.CreatedAt,
&i.UpdatedAt,
&i.CustomerFullName,
&i.CustomerPhoneNumber,
&i.BranchID,
&i.CompanyID,
&i.Amount,
&i.TransactionVerified,
&i.Status,
&i.TotalOdds,
&i.Outcomes,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const GetAllShopDeposit = `-- name: GetAllShopDeposit :many
SELECT id, shop_transaction_id, customer_id, wallet_transfer_id, created_at, updated_at, full_name, phone_number, branch_id, company_id, amount, transaction_verified
FROM shop_deposit_detail
WHERE (
full_name ILIKE '%' || $1 || '%'
OR phone_number ILIKE '%' || $1 || '%'
OR $1 IS NULL
)
AND (
branch_id = $2
OR $2 IS NULL
)
AND (
company_id = $3
OR $3 IS NULL
)
AND (
created_at > $4
OR $4 IS NULL
)
AND (
created_at < $5
OR $5 IS NULL
)
`
type GetAllShopDepositParams struct {
Query pgtype.Text `json:"query"`
BranchID pgtype.Int8 `json:"branch_id"`
CompanyID pgtype.Int8 `json:"company_id"`
CreatedBefore pgtype.Timestamp `json:"created_before"`
CreatedAfter pgtype.Timestamp `json:"created_after"`
}
func (q *Queries) GetAllShopDeposit(ctx context.Context, arg GetAllShopDepositParams) ([]ShopDepositDetail, error) {
rows, err := q.db.Query(ctx, GetAllShopDeposit,
arg.Query,
arg.BranchID,
arg.CompanyID,
arg.CreatedBefore,
arg.CreatedAfter,
)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ShopDepositDetail
for rows.Next() {
var i ShopDepositDetail
if err := rows.Scan(
&i.ID,
&i.ShopTransactionID,
&i.CustomerID,
&i.WalletTransferID,
&i.CreatedAt,
&i.UpdatedAt,
&i.FullName,
&i.PhoneNumber,
&i.BranchID,
&i.CompanyID,
&i.Amount,
&i.TransactionVerified,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const GetAllShopTransactions = `-- name: GetAllShopTransactions :many
SELECT id, amount, branch_id, company_id, user_id, type, full_name, phone_number, payment_option, bank_code, beneficiary_name, account_name, account_number, reference_number, approved_by, verified, created_at, updated_at, creator_first_name, creator_last_name, creator_phone_number, approver_first_name, approver_last_name, approver_phone_number, branch_name, branch_location
FROM shop_transaction_detail
wHERE (
branch_id = $1
OR $1 IS NULL
)
AND (
company_id = $2
OR $2 IS NULL
)
AND (
user_id = $3
OR $3 IS NULL
)
AND (
full_name ILIKE '%' || $4 || '%'
OR phone_number ILIKE '%' || $4 || '%'
OR $4 IS NULL
)
AND (
created_at > $5
OR $5 IS NULL
)
AND (
created_at < $6
OR $6 IS NULL
)
`
type GetAllShopTransactionsParams struct {
BranchID pgtype.Int8 `json:"branch_id"`
CompanyID pgtype.Int8 `json:"company_id"`
UserID pgtype.Int8 `json:"user_id"`
Query pgtype.Text `json:"query"`
CreatedBefore pgtype.Timestamp `json:"created_before"`
CreatedAfter pgtype.Timestamp `json:"created_after"`
}
func (q *Queries) GetAllShopTransactions(ctx context.Context, arg GetAllShopTransactionsParams) ([]ShopTransactionDetail, error) {
rows, err := q.db.Query(ctx, GetAllShopTransactions,
arg.BranchID,
arg.CompanyID,
arg.UserID,
arg.Query,
arg.CreatedBefore,
arg.CreatedAfter,
)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ShopTransactionDetail
for rows.Next() {
var i ShopTransactionDetail
if err := rows.Scan(
&i.ID,
&i.Amount,
&i.BranchID,
&i.CompanyID,
&i.UserID,
&i.Type,
&i.FullName,
&i.PhoneNumber,
&i.PaymentOption,
&i.BankCode,
&i.BeneficiaryName,
&i.AccountName,
&i.AccountNumber,
&i.ReferenceNumber,
&i.ApprovedBy,
&i.Verified,
&i.CreatedAt,
&i.UpdatedAt,
&i.CreatorFirstName,
&i.CreatorLastName,
&i.CreatorPhoneNumber,
&i.ApproverFirstName,
&i.ApproverLastName,
&i.ApproverPhoneNumber,
&i.BranchName,
&i.BranchLocation,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const GetShopBetByBetID = `-- name: GetShopBetByBetID :one
SELECT id, shop_transaction_id, cashout_id, cashed_out_by, bet_id, number_of_outcomes, cashed_out, created_at, updated_at, customer_full_name, customer_phone_number, branch_id, company_id, amount, transaction_verified, status, total_odds, outcomes
FROM shop_bet_detail
WHERE bet_id = $1
`
func (q *Queries) GetShopBetByBetID(ctx context.Context, betID int64) (ShopBetDetail, error) {
row := q.db.QueryRow(ctx, GetShopBetByBetID, betID)
var i ShopBetDetail
err := row.Scan(
&i.ID,
&i.ShopTransactionID,
&i.CashoutID,
&i.CashedOutBy,
&i.BetID,
&i.NumberOfOutcomes,
&i.CashedOut,
&i.CreatedAt,
&i.UpdatedAt,
&i.CustomerFullName,
&i.CustomerPhoneNumber,
&i.BranchID,
&i.CompanyID,
&i.Amount,
&i.TransactionVerified,
&i.Status,
&i.TotalOdds,
&i.Outcomes,
)
return i, err
}
const GetShopBetByID = `-- name: GetShopBetByID :one
SELECT id, shop_transaction_id, cashout_id, cashed_out_by, bet_id, number_of_outcomes, cashed_out, created_at, updated_at, customer_full_name, customer_phone_number, branch_id, company_id, amount, transaction_verified, status, total_odds, outcomes
FROM shop_bet_detail
WHERE id = $1
`
func (q *Queries) GetShopBetByID(ctx context.Context, id int64) (ShopBetDetail, error) {
row := q.db.QueryRow(ctx, GetShopBetByID, id)
var i ShopBetDetail
err := row.Scan(
&i.ID,
&i.ShopTransactionID,
&i.CashoutID,
&i.CashedOutBy,
&i.BetID,
&i.NumberOfOutcomes,
&i.CashedOut,
&i.CreatedAt,
&i.UpdatedAt,
&i.CustomerFullName,
&i.CustomerPhoneNumber,
&i.BranchID,
&i.CompanyID,
&i.Amount,
&i.TransactionVerified,
&i.Status,
&i.TotalOdds,
&i.Outcomes,
)
return i, err
}
const GetShopBetByShopTransactionID = `-- name: GetShopBetByShopTransactionID :one
SELECT id, shop_transaction_id, cashout_id, cashed_out_by, bet_id, number_of_outcomes, cashed_out, created_at, updated_at, customer_full_name, customer_phone_number, branch_id, company_id, amount, transaction_verified, status, total_odds, outcomes
FROM shop_bet_detail
WHERE shop_transaction_id = $1
`
func (q *Queries) GetShopBetByShopTransactionID(ctx context.Context, shopTransactionID int64) (ShopBetDetail, error) {
row := q.db.QueryRow(ctx, GetShopBetByShopTransactionID, shopTransactionID)
var i ShopBetDetail
err := row.Scan(
&i.ID,
&i.ShopTransactionID,
&i.CashoutID,
&i.CashedOutBy,
&i.BetID,
&i.NumberOfOutcomes,
&i.CashedOut,
&i.CreatedAt,
&i.UpdatedAt,
&i.CustomerFullName,
&i.CustomerPhoneNumber,
&i.BranchID,
&i.CompanyID,
&i.Amount,
&i.TransactionVerified,
&i.Status,
&i.TotalOdds,
&i.Outcomes,
)
return i, err
}
const GetShopDepositByID = `-- name: GetShopDepositByID :one
SELECT id, shop_transaction_id, customer_id, wallet_transfer_id, created_at, updated_at, full_name, phone_number, branch_id, company_id, amount, transaction_verified
FROM shop_deposit_detail
WHERE id = $1
`
func (q *Queries) GetShopDepositByID(ctx context.Context, id int64) (ShopDepositDetail, error) {
row := q.db.QueryRow(ctx, GetShopDepositByID, id)
var i ShopDepositDetail
err := row.Scan(
&i.ID,
&i.ShopTransactionID,
&i.CustomerID,
&i.WalletTransferID,
&i.CreatedAt,
&i.UpdatedAt,
&i.FullName,
&i.PhoneNumber,
&i.BranchID,
&i.CompanyID,
&i.Amount,
&i.TransactionVerified,
)
return i, err
}
const GetShopDepositByShopTransactionID = `-- name: GetShopDepositByShopTransactionID :one
SELECT id, shop_transaction_id, customer_id, wallet_transfer_id, created_at, updated_at, full_name, phone_number, branch_id, company_id, amount, transaction_verified
FROM shop_deposit_detail
WHERE shop_transaction_id = $1
`
func (q *Queries) GetShopDepositByShopTransactionID(ctx context.Context, shopTransactionID int64) (ShopDepositDetail, error) {
row := q.db.QueryRow(ctx, GetShopDepositByShopTransactionID, shopTransactionID)
var i ShopDepositDetail
err := row.Scan(
&i.ID,
&i.ShopTransactionID,
&i.CustomerID,
&i.WalletTransferID,
&i.CreatedAt,
&i.UpdatedAt,
&i.FullName,
&i.PhoneNumber,
&i.BranchID,
&i.CompanyID,
&i.Amount,
&i.TransactionVerified,
)
return i, err
}
const GetShopTransactionByBranch = `-- name: GetShopTransactionByBranch :many
SELECT id, amount, branch_id, company_id, user_id, type, full_name, phone_number, payment_option, bank_code, beneficiary_name, account_name, account_number, reference_number, approved_by, verified, created_at, updated_at, creator_first_name, creator_last_name, creator_phone_number, approver_first_name, approver_last_name, approver_phone_number, branch_name, branch_location
FROM shop_transaction_detail
WHERE branch_id = $1
`
func (q *Queries) GetShopTransactionByBranch(ctx context.Context, branchID int64) ([]ShopTransactionDetail, error) {
rows, err := q.db.Query(ctx, GetShopTransactionByBranch, branchID)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ShopTransactionDetail
for rows.Next() {
var i ShopTransactionDetail
if err := rows.Scan(
&i.ID,
&i.Amount,
&i.BranchID,
&i.CompanyID,
&i.UserID,
&i.Type,
&i.FullName,
&i.PhoneNumber,
&i.PaymentOption,
&i.BankCode,
&i.BeneficiaryName,
&i.AccountName,
&i.AccountNumber,
&i.ReferenceNumber,
&i.ApprovedBy,
&i.Verified,
&i.CreatedAt,
&i.UpdatedAt,
&i.CreatorFirstName,
&i.CreatorLastName,
&i.CreatorPhoneNumber,
&i.ApproverFirstName,
&i.ApproverLastName,
&i.ApproverPhoneNumber,
&i.BranchName,
&i.BranchLocation,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const GetShopTransactionByID = `-- name: GetShopTransactionByID :one
SELECT id, amount, branch_id, company_id, user_id, type, full_name, phone_number, payment_option, bank_code, beneficiary_name, account_name, account_number, reference_number, approved_by, verified, created_at, updated_at, creator_first_name, creator_last_name, creator_phone_number, approver_first_name, approver_last_name, approver_phone_number, branch_name, branch_location
FROM shop_transaction_detail
WHERE id = $1
`
func (q *Queries) GetShopTransactionByID(ctx context.Context, id int64) (ShopTransactionDetail, error) {
row := q.db.QueryRow(ctx, GetShopTransactionByID, id)
var i ShopTransactionDetail
err := row.Scan(
&i.ID,
&i.Amount,
&i.BranchID,
&i.CompanyID,
&i.UserID,
&i.Type,
&i.FullName,
&i.PhoneNumber,
&i.PaymentOption,
&i.BankCode,
&i.BeneficiaryName,
&i.AccountName,
&i.AccountNumber,
&i.ReferenceNumber,
&i.ApprovedBy,
&i.Verified,
&i.CreatedAt,
&i.UpdatedAt,
&i.CreatorFirstName,
&i.CreatorLastName,
&i.CreatorPhoneNumber,
&i.ApproverFirstName,
&i.ApproverLastName,
&i.ApproverPhoneNumber,
&i.BranchName,
&i.BranchLocation,
)
return i, err
}
const UpdateShopBetCashOut = `-- name: UpdateShopBetCashOut :exec
UPDATE shop_bets
SET cashed_out = $2,
updated_at = CURRENT_TIMESTAMP
WHERE id = $1
`
type UpdateShopBetCashOutParams struct {
ID int64 `json:"id"`
CashedOut bool `json:"cashed_out"`
}
func (q *Queries) UpdateShopBetCashOut(ctx context.Context, arg UpdateShopBetCashOutParams) error {
_, err := q.db.Exec(ctx, UpdateShopBetCashOut, arg.ID, arg.CashedOut)
return err
}
const UpdateShopBetCashoutID = `-- name: UpdateShopBetCashoutID :exec
UPDATE shop_bets
SET cashout_id = $2,
updated_at = CURRENT_TIMESTAMP
WHERE id = $1
`
type UpdateShopBetCashoutIDParams struct {
ID int64 `json:"id"`
CashoutID string `json:"cashout_id"`
}
func (q *Queries) UpdateShopBetCashoutID(ctx context.Context, arg UpdateShopBetCashoutIDParams) error {
_, err := q.db.Exec(ctx, UpdateShopBetCashoutID, arg.ID, arg.CashoutID)
return err
}
const UpdateShopTransactionVerified = `-- name: UpdateShopTransactionVerified :exec
UPDATE shop_transactions
SET verified = $2,
approved_by = $3,
updated_at = CURRENT_TIMESTAMP
WHERE id = $1
`
type UpdateShopTransactionVerifiedParams struct {
ID int64 `json:"id"`
Verified bool `json:"verified"`
ApprovedBy pgtype.Int8 `json:"approved_by"`
}
func (q *Queries) UpdateShopTransactionVerified(ctx context.Context, arg UpdateShopTransactionVerifiedParams) error {
_, err := q.db.Exec(ctx, UpdateShopTransactionVerified, arg.ID, arg.Verified, arg.ApprovedBy)
return err
}