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