debug: logging pay process

This commit is contained in:
skeris 2023-09-15 22:55:39 +03:00
parent 56a2dd1e36
commit a783f0d804

@ -149,12 +149,16 @@ func (receiver *Service) Pay(ctx context.Context, accessToken string, userID str
return nil, err
}
receiver.logger.Info("account for pay", zap.Any("acc", 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 nil, err
}
receiver.logger.Info("tariffs for pay", zap.Any("acc", tariffs))
tariffsAmount := utils.CalculateCartPurchasesAmount(tariffs)
discountResponse, err := receiver.discountClient.Apply(ctx, &discount.ApplyDiscountRequest{
@ -172,6 +176,8 @@ func (receiver *Service) Pay(ctx context.Context, accessToken string, userID str
return nil, err
}
receiver.logger.Info("discountResponse for pay", zap.Any("acc", discountResponse))
if account.Wallet.Money < int64(discountResponse.Price) {
receiver.logger.Error("insufficient funds on <Pay> of <CartService>")
return nil, errors.New(fmt.Errorf("insufficient funds: %d", int64(discountResponse.Price)-account.Wallet.Money), errors.ErrInsufficientFunds)