-- name: CreateWallet :one INSERT INTO wallets ( is_withdraw, is_bettable, is_transferable, user_id, type ) VALUES ($1, $2, $3, $4, $5) RETURNING *; -- name: CreateCustomerWallet :one INSERT INTO customer_wallets ( customer_id, regular_wallet_id, static_wallet_id ) VALUES ($1, $2, $3) RETURNING *; -- name: GetAllWallets :many SELECT * FROM wallets; -- name: GetWalletByID :one SELECT * FROM wallets WHERE id = $1; -- name: GetWalletByUserID :many SELECT * FROM wallets WHERE user_id = $1; -- name: GetAllCustomerWallet :many SELECT * FROM customer_wallet_details; -- name: GetCustomerWallet :one SELECT * FROM customer_wallet_details WHERE customer_id = $1; -- name: GetAllBranchWallets :many SELECT wallets.id, wallets.balance, wallets.is_active, wallets.updated_at, wallets.created_at, branches.name, branches.location, branches.branch_manager_id, branches.company_id, branches.is_self_owned FROM branches JOIN wallets ON branches.wallet_id = wallets.id; -- name: UpdateBalance :exec UPDATE wallets SET balance = $1, updated_at = CURRENT_TIMESTAMP WHERE id = $2; -- name: UpdateWalletActive :exec UPDATE wallets SET is_active = $1, updated_at = CURRENT_TIMESTAMP WHERE id = $2; -- name: GetCompanyByWalletID :one SELECT id, name, admin_id, wallet_id FROM companies WHERE wallet_id = $1 LIMIT 1; -- name: GetBranchByWalletID :one SELECT id, name, location, is_active, wallet_id, branch_manager_id, company_id, is_self_owned, created_at, updated_at FROM branches WHERE wallet_id = $1 LIMIT 1; -- -- name: GetCustomerByWalletID :one -- SELECT id, first_name, last_name, email, phone_number,email_verified,phone_verified,company_id,suspended -- FROM users -- WHERE wallet_id = $1 -- LIMIT 1;