generated from PenaSide/GolangTemplate
Merge branch 'dev' into 'staging'
Update 2 files See merge request pena-services/customer!10
This commit is contained in:
commit
a259368ba5
@ -149,13 +149,18 @@ func (receiver *Service) Pay(ctx context.Context, accessToken string, userID str
|
||||
return err
|
||||
}
|
||||
|
||||
receiver.logger.Debug("account for buy cart", zap.Any("trtr", account))
|
||||
|
||||
tariffs, err := receiver.hubadminClient.GetTariffs(ctx, accessToken, account.Cart)
|
||||
if err != nil {
|
||||
receiver.logger.Error("failed to get tarrifs on <Pay> of <CartService>", zap.Strings("cart", account.Cart), zap.Error(err))
|
||||
return err
|
||||
}
|
||||
|
||||
receiver.logger.Debug("tariffs for buy cart", zap.Any("trtr", tariffs))
|
||||
|
||||
tariffsAmount := utils.CalculateCartPurchasesAmount(tariffs)
|
||||
receiver.logger.Debug("tariffsAmount for buy cart", zap.Any("trtr", tariffsAmount))
|
||||
|
||||
response, err := receiver.discountClient.Apply(ctx, &discount.ApplyDiscountRequest{
|
||||
UserInformation: &discount.UserInformation{
|
||||
@ -172,6 +177,8 @@ func (receiver *Service) Pay(ctx context.Context, accessToken string, userID str
|
||||
return err
|
||||
}
|
||||
|
||||
receiver.logger.Debug("applyed discounts for buy cart", zap.Any("trtr", response))
|
||||
|
||||
if account.Wallet.Money < int64(response.Price) {
|
||||
receiver.logger.Error("insufficient funds on <Pay> of <CartService>")
|
||||
return errors.New(fmt.Errorf("insufficient funds: %d", int64(response.Price)-account.Wallet.Money), errors.ErrInsufficientFunds)
|
||||
|
Loading…
Reference in New Issue
Block a user