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
|
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),
|
||||||
|
@ -11,6 +11,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 +67,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 +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) {
|
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