Update cart.go

This commit is contained in:
Mikhail 2023-08-18 16:57:12 +00:00
parent 476f54c2f2
commit f39e5a66f0

@ -148,12 +148,15 @@ func (receiver *Service) Pay(ctx context.Context, accessToken string, userID str
receiver.logger.Error("failed to find account on <Pay> of <CartService>", zap.String("userID", userID), zap.Error(err))
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)
@ -173,6 +176,7 @@ func (receiver *Service) Pay(ctx context.Context, accessToken string, userID str
receiver.logger.Error("failed to discount on <Pay> of <CartService>", zap.Error(err))
return err
}
receiver.logger.Debug("applyed discounts for buy cart", zap.Any("trtr",response))
if account.Wallet.Money < int64(response.Price) {