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)
|
UpdateName(ctx context.Context, userID string, name *models.Name) (*models.Account, errors.Error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const defaultCurrency = "RUB"
|
||||||
|
|
||||||
type authClient interface {
|
type authClient interface {
|
||||||
GetUser(ctx context.Context, userID string) (*models.User, errors.Error)
|
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
|
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 {
|
if err != nil {
|
||||||
receiver.logger.Error("failed to create account on <CreateAccountByUserID> of <AccountService>",
|
receiver.logger.Error("failed to create account on <CreateAccountByUserID> of <AccountService>",
|
||||||
zap.Error(err),
|
zap.Error(err),
|
||||||
|
@ -2,7 +2,6 @@ package wallet
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
@ -11,6 +10,8 @@ import (
|
|||||||
"penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/validate"
|
"penahub.gitlab.yandexcloud.net/pena-services/customer/pkg/validate"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const defaultCurrency = "RUB"
|
||||||
|
|
||||||
type accountRepository interface {
|
type accountRepository interface {
|
||||||
ChangeWallet(ctx context.Context, userID string, wallet *models.Wallet) (*models.Account, errors.Error)
|
ChangeWallet(ctx context.Context, userID string, wallet *models.Wallet) (*models.Account, errors.Error)
|
||||||
FindByUserID(ctx context.Context, id string) (*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) {
|
func (receiver *Service) ReplenishAccountWallet(ctx context.Context, request *models.ReplenishAccountWallet) (*models.Account, errors.Error) {
|
||||||
if validate.IsStringEmpty(request.Account.Wallet.Currency) {
|
if validate.IsStringEmpty(request.Account.Wallet.Currency) {
|
||||||
return nil, errors.New(
|
request.Account.Wallet.Currency = defaultCurrency
|
||||||
fmt.Errorf("currency of account <%s> is empty <ReplenishAccountWallet> of <WalletService>", request.Account.UserID),
|
|
||||||
errors.ErrInternalError,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cash := request.Cash
|
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) {
|
func (receiver *Service) WithdrawAccountWalletMoney(ctx context.Context, request *models.WithdrawAccountWallet) (*models.Account, errors.Error) {
|
||||||
if validate.IsStringEmpty(request.Account.Wallet.Currency) {
|
if validate.IsStringEmpty(request.Account.Wallet.Currency) {
|
||||||
return nil, errors.New(
|
request.Account.Wallet.Currency = defaultCurrency
|
||||||
fmt.Errorf("currency of account <%s> is empty <WithdrawAccountWalletMoney> of <WalletService>", request.Account.UserID),
|
|
||||||
errors.ErrInternalError,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cash, err := receiver.currencyClient.Translate(ctx, &models.TranslateCurrency{
|
cash, err := receiver.currencyClient.Translate(ctx, &models.TranslateCurrency{
|
||||||
|
Loading…
Reference in New Issue
Block a user