generated from PenaSide/GolangTemplate
Merge branch 'dev' into 'staging'
Update 2 files See merge request pena-services/customer!8
This commit is contained in:
commit
f50f272f7a
@ -22,6 +22,8 @@ type accountRepository interface {
|
||||
UpdateName(ctx context.Context, userID string, name *models.Name) (*models.Account, errors.Error)
|
||||
}
|
||||
|
||||
const defaultCurrency = "RUB"
|
||||
|
||||
type authClient interface {
|
||||
GetUser(ctx context.Context, userID string) (*models.User, errors.Error)
|
||||
}
|
||||
@ -175,7 +177,7 @@ func (receiver *Service) CreateAccountByUserID(ctx context.Context, userID strin
|
||||
return nil, err
|
||||
}
|
||||
|
||||
createdAccount, err := receiver.repository.Insert(ctx, &models.Account{UserID: user.ID})
|
||||
createdAccount, err := receiver.repository.Insert(ctx, &models.Account{UserID: user.ID, Wallet: models.Wallet{Currency: defaultCurrency}})
|
||||
if err != nil {
|
||||
receiver.logger.Error("failed to create account on <CreateAccountByUserID> of <AccountService>",
|
||||
zap.Error(err),
|
||||
|
@ -2,7 +2,6 @@ package wallet
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"go.uber.org/zap"
|
||||
@ -11,6 +10,8 @@ import (
|
||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/validate"
|
||||
)
|
||||
|
||||
const defaultCurrency = "RUB"
|
||||
|
||||
type accountRepository interface {
|
||||
ChangeWallet(ctx context.Context, userID string, wallet *models.Wallet) (*models.Account, errors.Error)
|
||||
FindByUserID(ctx context.Context, id string) (*models.Account, errors.Error)
|
||||
@ -65,10 +66,7 @@ func New(deps Deps) *Service {
|
||||
|
||||
func (receiver *Service) ReplenishAccountWallet(ctx context.Context, request *models.ReplenishAccountWallet) (*models.Account, errors.Error) {
|
||||
if validate.IsStringEmpty(request.Account.Wallet.Currency) {
|
||||
return nil, errors.New(
|
||||
fmt.Errorf("currency of account <%s> is empty <ReplenishAccountWallet> of <WalletService>", request.Account.UserID),
|
||||
errors.ErrInternalError,
|
||||
)
|
||||
request.Account.Wallet.Currency = defaultCurrency
|
||||
}
|
||||
|
||||
cash := request.Cash
|
||||
@ -161,10 +159,7 @@ func (receiver *Service) ReplenishAccountWallet(ctx context.Context, request *mo
|
||||
|
||||
func (receiver *Service) WithdrawAccountWalletMoney(ctx context.Context, request *models.WithdrawAccountWallet) (*models.Account, errors.Error) {
|
||||
if validate.IsStringEmpty(request.Account.Wallet.Currency) {
|
||||
return nil, errors.New(
|
||||
fmt.Errorf("currency of account <%s> is empty <WithdrawAccountWalletMoney> of <WalletService>", request.Account.UserID),
|
||||
errors.ErrInternalError,
|
||||
)
|
||||
request.Account.Wallet.Currency = defaultCurrency
|
||||
}
|
||||
|
||||
cash, err := receiver.currencyClient.Translate(ctx, &models.TranslateCurrency{
|
||||
|
Loading…
Reference in New Issue
Block a user