feat(loyalty): EnakPoint & EnakCoin #32

Merged
aefril merged 36 commits from feature/point-coint into main 2026-09-30 10:03:08 +02:00
Showing only changes of commit 6af97f5696 - Show all commits
+9 -6
View File
@@ -188,17 +188,20 @@ func (r *walletRepository) CreateTransaction(ctx context.Context, walletTx *enti
}
func (r *walletRepository) GetTransactionByIdempotencyKey(ctx context.Context, key string) (*entities.WalletTransaction, error) {
var walletTx entities.WalletTransaction
// Find rather than First: a new key is the normal case, and First would log every
// one of them as a "record not found" error.
var walletTxs []entities.WalletTransaction
err := DBFromContext(ctx, r.db).WithContext(ctx).
Where("idempotency_key = ?", key).
First(&walletTx).Error
Limit(1).
Find(&walletTxs).Error
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil, nil
}
return nil, fmt.Errorf("failed to get wallet transaction by idempotency key: %w", err)
}
return &walletTx, nil
if len(walletTxs) == 0 {
return nil, nil
}
return &walletTxs[0], nil
}
func (r *walletRepository) CreateLot(ctx context.Context, lot *entities.WalletLot) error {