fix: merge issues
This commit is contained in:
parent
cfced1951c
commit
344923b177
6
.gitignore
vendored
6
.gitignore
vendored
|
|
@ -1,7 +1,7 @@
|
|||
# bin
|
||||
# coverage.out
|
||||
bin
|
||||
coverage.out
|
||||
# coverage
|
||||
# .env
|
||||
# tmp
|
||||
# build
|
||||
# *.log
|
||||
*.log
|
||||
|
|
@ -139,7 +139,7 @@ CREATE TABLE IF NOT EXISTS wallet_transfer (
|
|||
cashier_id BIGINT,
|
||||
verified BOOLEAN DEFAULT false,
|
||||
reference_number VARCHAR(255),
|
||||
status VARCHAR(255),
|
||||
status VARCHAR(255),
|
||||
payment_method VARCHAR(255),
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
|
|
@ -308,7 +308,7 @@ ALTER TABLE bets
|
|||
ADD CONSTRAINT fk_bets_users FOREIGN KEY (user_id) REFERENCES users(id),
|
||||
ADD CONSTRAINT fk_bets_branches FOREIGN KEY (branch_id) REFERENCES branches(id);
|
||||
ALTER TABLE wallets
|
||||
ADD CONSTRAINT fk_wallets_users FOREIGN KEY (user_id) REFERENCES users(id);
|
||||
ADD CONSTRAINT fk_wallets_users FOREIGN KEY (user_id) REFERENCES users(id),
|
||||
ADD COLUMN currency VARCHAR(3) NOT NULL DEFAULT 'ETB';
|
||||
ALTER TABLE customer_wallets
|
||||
ADD CONSTRAINT fk_customer_wallets_customers FOREIGN KEY (customer_id) REFERENCES users(id),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.29.0
|
||||
// sqlc v1.28.0
|
||||
// source: auth.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.29.0
|
||||
// sqlc v1.28.0
|
||||
// source: bet.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.29.0
|
||||
// sqlc v1.28.0
|
||||
// source: branch.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.29.0
|
||||
// sqlc v1.28.0
|
||||
// source: cashier.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.29.0
|
||||
// sqlc v1.28.0
|
||||
// source: company.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.29.0
|
||||
// sqlc v1.28.0
|
||||
// source: copyfrom.go
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.29.0
|
||||
// sqlc v1.28.0
|
||||
|
||||
package dbgen
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.29.0
|
||||
// sqlc v1.28.0
|
||||
// source: events.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.29.0
|
||||
// sqlc v1.28.0
|
||||
// source: leagues.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.29.0
|
||||
// sqlc v1.28.0
|
||||
|
||||
package dbgen
|
||||
|
||||
|
|
@ -204,6 +204,15 @@ type Event struct {
|
|||
Source pgtype.Text `json:"source"`
|
||||
}
|
||||
|
||||
type ExchangeRate struct {
|
||||
ID int32 `json:"id"`
|
||||
FromCurrency string `json:"from_currency"`
|
||||
ToCurrency string `json:"to_currency"`
|
||||
Rate pgtype.Numeric `json:"rate"`
|
||||
ValidUntil pgtype.Timestamp `json:"valid_until"`
|
||||
CreatedAt pgtype.Timestamp `json:"created_at"`
|
||||
}
|
||||
|
||||
type League struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
|
|
@ -470,6 +479,7 @@ type Wallet struct {
|
|||
IsActive bool `json:"is_active"`
|
||||
CreatedAt pgtype.Timestamp `json:"created_at"`
|
||||
UpdatedAt pgtype.Timestamp `json:"updated_at"`
|
||||
Currency string `json:"currency"`
|
||||
BonusBalance pgtype.Numeric `json:"bonus_balance"`
|
||||
CashBalance pgtype.Numeric `json:"cash_balance"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.29.0
|
||||
// sqlc v1.28.0
|
||||
// source: monitor.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.29.0
|
||||
// sqlc v1.28.0
|
||||
// source: notification.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.29.0
|
||||
// sqlc v1.28.0
|
||||
// source: odds.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.29.0
|
||||
// sqlc v1.28.0
|
||||
// source: otp.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.29.0
|
||||
// sqlc v1.28.0
|
||||
// source: referal.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.29.0
|
||||
// sqlc v1.28.0
|
||||
// source: result.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.29.0
|
||||
// sqlc v1.28.0
|
||||
// source: ticket.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.29.0
|
||||
// sqlc v1.28.0
|
||||
// source: transactions.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.29.0
|
||||
// sqlc v1.28.0
|
||||
// source: transfer.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.29.0
|
||||
// sqlc v1.28.0
|
||||
// source: user.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.29.0
|
||||
// sqlc v1.28.0
|
||||
// source: virtual_games.sql
|
||||
|
||||
package dbgen
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.29.0
|
||||
// sqlc v1.28.0
|
||||
// source: wallet.sql
|
||||
|
||||
package dbgen
|
||||
|
|
@ -49,7 +49,7 @@ INSERT INTO wallets (
|
|||
user_id
|
||||
)
|
||||
VALUES ($1, $2, $3, $4)
|
||||
RETURNING id, balance, is_withdraw, is_bettable, is_transferable, user_id, is_active, created_at, updated_at, bonus_balance, cash_balance
|
||||
RETURNING id, balance, is_withdraw, is_bettable, is_transferable, user_id, is_active, created_at, updated_at, currency, bonus_balance, cash_balance
|
||||
`
|
||||
|
||||
type CreateWalletParams struct {
|
||||
|
|
@ -77,6 +77,7 @@ func (q *Queries) CreateWallet(ctx context.Context, arg CreateWalletParams) (Wal
|
|||
&i.IsActive,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.Currency,
|
||||
&i.BonusBalance,
|
||||
&i.CashBalance,
|
||||
)
|
||||
|
|
@ -143,7 +144,7 @@ func (q *Queries) GetAllBranchWallets(ctx context.Context) ([]GetAllBranchWallet
|
|||
}
|
||||
|
||||
const GetAllWallets = `-- name: GetAllWallets :many
|
||||
SELECT id, balance, is_withdraw, is_bettable, is_transferable, user_id, is_active, created_at, updated_at, bonus_balance, cash_balance
|
||||
SELECT id, balance, is_withdraw, is_bettable, is_transferable, user_id, is_active, created_at, updated_at, currency, bonus_balance, cash_balance
|
||||
FROM wallets
|
||||
`
|
||||
|
||||
|
|
@ -166,6 +167,7 @@ func (q *Queries) GetAllWallets(ctx context.Context) ([]Wallet, error) {
|
|||
&i.IsActive,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.Currency,
|
||||
&i.BonusBalance,
|
||||
&i.CashBalance,
|
||||
); err != nil {
|
||||
|
|
@ -225,7 +227,7 @@ func (q *Queries) GetCustomerWallet(ctx context.Context, customerID int64) (GetC
|
|||
}
|
||||
|
||||
const GetWalletByID = `-- name: GetWalletByID :one
|
||||
SELECT id, balance, is_withdraw, is_bettable, is_transferable, user_id, is_active, created_at, updated_at, bonus_balance, cash_balance
|
||||
SELECT id, balance, is_withdraw, is_bettable, is_transferable, user_id, is_active, created_at, updated_at, currency, bonus_balance, cash_balance
|
||||
FROM wallets
|
||||
WHERE id = $1
|
||||
`
|
||||
|
|
@ -243,6 +245,7 @@ func (q *Queries) GetWalletByID(ctx context.Context, id int64) (Wallet, error) {
|
|||
&i.IsActive,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.Currency,
|
||||
&i.BonusBalance,
|
||||
&i.CashBalance,
|
||||
)
|
||||
|
|
@ -250,7 +253,7 @@ func (q *Queries) GetWalletByID(ctx context.Context, id int64) (Wallet, error) {
|
|||
}
|
||||
|
||||
const GetWalletByUserID = `-- name: GetWalletByUserID :many
|
||||
SELECT id, balance, is_withdraw, is_bettable, is_transferable, user_id, is_active, created_at, updated_at, bonus_balance, cash_balance
|
||||
SELECT id, balance, is_withdraw, is_bettable, is_transferable, user_id, is_active, created_at, updated_at, currency, bonus_balance, cash_balance
|
||||
FROM wallets
|
||||
WHERE user_id = $1
|
||||
`
|
||||
|
|
@ -274,6 +277,7 @@ func (q *Queries) GetWalletByUserID(ctx context.Context, userID int64) ([]Wallet
|
|||
&i.IsActive,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.Currency,
|
||||
&i.BonusBalance,
|
||||
&i.CashBalance,
|
||||
); err != nil {
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@ import (
|
|||
func convertDBTransfer(transfer dbgen.WalletTransfer) domain.Transfer {
|
||||
return domain.Transfer{
|
||||
ID: transfer.ID,
|
||||
Amount: domain.Currency(transfer.Amount),
|
||||
Type: domain.TransferType(transfer.Type),
|
||||
Verified: transfer.Verified,
|
||||
Amount: domain.Currency(transfer.Amount.Int64),
|
||||
Type: domain.TransferType(transfer.Type.String),
|
||||
Verified: transfer.Verified.Bool,
|
||||
ReceiverWalletID: domain.ValidInt64{
|
||||
Value: transfer.ReceiverWalletID.Int64,
|
||||
Valid: transfer.ReceiverWalletID.Valid,
|
||||
|
|
@ -22,12 +22,6 @@ func convertDBTransfer(transfer dbgen.WalletTransfer) domain.Transfer {
|
|||
Value: transfer.SenderWalletID.Int64,
|
||||
Valid: transfer.SenderWalletID.Valid,
|
||||
},
|
||||
ID: transfer.ID,
|
||||
Amount: domain.Currency(transfer.Amount.Int64),
|
||||
Type: domain.TransferType(transfer.Type.String),
|
||||
Verified: transfer.Verified.Bool,
|
||||
ReceiverWalletID: transfer.ReceiverWalletID.Int64,
|
||||
SenderWalletID: transfer.SenderWalletID.Int64,
|
||||
CashierID: domain.ValidInt64{
|
||||
Value: transfer.CashierID.Int64,
|
||||
Valid: transfer.CashierID.Valid,
|
||||
|
|
@ -41,8 +35,8 @@ func convertCreateTransfer(transfer domain.CreateTransfer) dbgen.CreateTransferP
|
|||
Amount: pgtype.Int8{Int64: int64(transfer.Amount), Valid: true},
|
||||
Type: pgtype.Text{String: string(transfer.Type), Valid: true},
|
||||
ReceiverWalletID: pgtype.Int8{
|
||||
Int64: transfer.ReceiverWalletID,
|
||||
Valid: true,
|
||||
Int64: transfer.ReceiverWalletID.Value,
|
||||
Valid: transfer.ReceiverWalletID.Valid,
|
||||
},
|
||||
SenderWalletID: pgtype.Int8{
|
||||
Int64: transfer.SenderWalletID.Value,
|
||||
|
|
|
|||
|
|
@ -153,14 +153,16 @@ func (s *Service) InitiateWithdrawal(ctx context.Context, userID int64, req doma
|
|||
reference := uuid.New().String()
|
||||
|
||||
createTransfer := domain.CreateTransfer{
|
||||
Amount: domain.Currency(amount),
|
||||
Type: domain.WITHDRAW,
|
||||
ReceiverWalletID: 1,
|
||||
SenderWalletID: withdrawWallet.ID,
|
||||
Status: string(domain.PaymentStatusPending),
|
||||
Verified: false,
|
||||
ReferenceNumber: reference,
|
||||
PaymentMethod: domain.TRANSFER_CHAPA,
|
||||
Amount: domain.Currency(amount),
|
||||
Type: domain.WITHDRAW,
|
||||
SenderWalletID: domain.ValidInt64{
|
||||
Value: withdrawWallet.ID,
|
||||
Valid: true,
|
||||
},
|
||||
Status: string(domain.PaymentStatusPending),
|
||||
Verified: false,
|
||||
ReferenceNumber: reference,
|
||||
PaymentMethod: domain.TRANSFER_CHAPA,
|
||||
}
|
||||
|
||||
transfer, err := s.transferStore.CreateTransfer(ctx, createTransfer)
|
||||
|
|
@ -279,7 +281,11 @@ func (s *Service) HandleVerifyDepositWebhook(ctx context.Context, transfer domai
|
|||
|
||||
// If payment is completed, credit user's wallet
|
||||
if transfer.Status == string(domain.PaymentStatusCompleted) {
|
||||
if err := s.walletStore.AddToWallet(ctx, payment.SenderWalletID, payment.Amount); err != nil {
|
||||
if _, err := s.walletStore.AddToWallet(ctx, payment.SenderWalletID.Value, payment.Amount, domain.ValidInt64{}, domain.TRANSFER_CHAPA, domain.PaymentDetails{
|
||||
ReferenceNumber: domain.ValidString{
|
||||
Value: transfer.Reference,
|
||||
},
|
||||
}); err != nil {
|
||||
return fmt.Errorf("failed to credit user wallet: %w", err)
|
||||
}
|
||||
}
|
||||
|
|
@ -316,7 +322,7 @@ func (s *Service) HandleVerifyWithdrawWebhook(ctx context.Context, payment domai
|
|||
|
||||
// If payment is completed, credit user's wallet
|
||||
if payment.Status == string(domain.PaymentStatusFailed) {
|
||||
if err := s.walletStore.AddToWallet(ctx, transfer.SenderWalletID, transfer.Amount); err != nil {
|
||||
if _, err := s.walletStore.AddToWallet(ctx, transfer.SenderWalletID.Value, transfer.Amount, domain.ValidInt64{}, domain.TRANSFER_DIRECT, domain.PaymentDetails{}); err != nil {
|
||||
return fmt.Errorf("failed to credit user wallet: %w", err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,11 +42,6 @@ func (s *Service) UpdateTransferStatus(ctx context.Context, id int64, status str
|
|||
return s.transferStore.UpdateTransferStatus(ctx, id, status)
|
||||
}
|
||||
|
||||
func (s *Service) UpdateTransferStatus(ctx context.Context, id int64, status string) error {
|
||||
return s.transferStore.UpdateTransferStatus(ctx, id, status)
|
||||
}
|
||||
|
||||
|
||||
|
||||
func (s *Service) TransferToWallet(ctx context.Context, senderID int64, receiverID int64,
|
||||
amount domain.Currency, paymentMethod domain.PaymentMethod,
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ func (s *Service) UpdateBalance(ctx context.Context, id int64, balance domain.Cu
|
|||
}
|
||||
|
||||
func (s *Service) AddToWallet(
|
||||
ctx context.Context, id int64, amount domain.Currency, cashierID domain.ValidInt64, paymentMethod domain.PaymentMethod, paymentDetails domain.PaymentDetails) (domain.Transfer, error) {
|
||||
ctx context.Context, id int64, amount domain.Currency, cashierID domain.ValidInt64, paymentMethod domain.PaymentMethod, paymentDetails domain. PaymentDetails) (domain.Transfer, error) {
|
||||
wallet, err := s.GetWalletByID(ctx, id)
|
||||
if err != nil {
|
||||
return domain.Transfer{}, err
|
||||
|
|
|
|||
|
|
@ -1,2 +1,3 @@
|
|||
time=2025-06-16T02:21:34.859+03:00 level=INFO msg="Authenticated WebSocket connection" service_info.env=development userID=3
|
||||
time=2025-06-16T02:23:59.721+03:00 level=INFO msg="Starting server" service_info.env=development port=8080
|
||||
time=2025-06-16T22:51:15.242+03:00 level=INFO msg="Starting server" service_info.env=development port=8080
|
||||
|
|
|
|||
39033
logs/failed_markets.log
39033
logs/failed_markets.log
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user