generated from PenaSide/GolangTemplate
Update cart.go
This commit is contained in:
parent
5d53e04858
commit
c1e0926d2c
@ -148,14 +148,16 @@ 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
|
||||
}
|
||||
|
||||
reciever.logger.Debug("account for buy cart", zap.Any(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
|
||||
}
|
||||
reciever.logger.Debug("tariffs for buy cart", zap.Any(tariffs))
|
||||
|
||||
tariffsAmount := utils.CalculateCartPurchasesAmount(tariffs)
|
||||
reciever.logger.Debug("tariffsAmount for buy cart", zap.Any(tariffsAmount))
|
||||
|
||||
response, err := receiver.discountClient.Apply(ctx, &discount.ApplyDiscountRequest{
|
||||
UserInformation: &discount.UserInformation{
|
||||
@ -171,6 +173,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
|
||||
}
|
||||
reciever.logger.Debug("applyed discounts for buy cart", zap.Any(response))
|
||||
|
||||
if account.Wallet.Money < int64(response.Price) {
|
||||
receiver.logger.Error("insufficient funds on <Pay> of <CartService>")
|
||||
|
Loading…
Reference in New Issue
Block a user