generated from PenaSide/GolangTemplate
Update 2 files
- /internal/service/wallet/wallet.go - /internal/service/account/account.go
This commit is contained in:
parent
abd8488a33
commit
8b4275c245
@ -175,7 +175,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),
|
||||
|
@ -11,6 +11,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 +67,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 +160,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