fix: change history model

This commit is contained in:
skeris 2024-03-09 22:39:05 +03:00
parent 98432999b6
commit be0eee473b
7 changed files with 13 additions and 11 deletions

@ -42,7 +42,7 @@ func (receiver *Controller) InsertHistory(ctx context.Context, in *customer.Hist
UserID: in.UserID,
Comment: in.Comment,
Key: in.Key,
RawDetails: in.RawDetails,
// RawDetails: in.RawDetails,
}); err != nil {
receiver.logger.Error("failed to insert history on <InsertHistory> of <HistoryController>", zap.Error(err))
return nil, errors.GRPC("failed to insert history", err)

@ -418,7 +418,10 @@ func (api *API2) PayCart(ctx echo.Context) error {
Key: models.CustomerHistoryKeyPayCart,
UserID: account.UserID,
Comment: "Успешная оплата корзины",
RawDetails: tariffs,
RawDetails: models.RawDetails{
Tariffs: tariffs,
Price: int64(discountResponse.Price),
},
}); err != nil {
return api.errorOld(ctx, err)
}

@ -7,7 +7,7 @@ type History struct {
UserID string `json:"userId" bson:"userId"`
Comment string `json:"comment" bson:"comment"`
Key string `json:"key" bson:"key"`
RawDetails any `json:"rawDetails" bson:"rawDetails"`
RawDetails RawDetails `json:"rawDetails" bson:"rawDetails"`
Deleted bool `json:"isDeleted" bson:"isDeleted"`
CreatedAt time.Time `json:"createdAt" bson:"createdAt"`
UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"`

@ -2,7 +2,6 @@ package callback
import (
"context"
"fmt"
"log"
"go.uber.org/zap"
@ -88,7 +87,7 @@ func (receiver *PaymentCallbackService) SuccessEvent(ctx context.Context, event
UserID: account.UserID,
Comment: event.Message,
Key: event.Key,
RawDetails: fmt.Sprintf("%d%s", event.Amount, event.Currency),
// RawDetails: fmt.Sprintf("%d%s", event.Amount, event.Currency),
}); err != nil {
receiver.logger.Error("failed to create history on <SuccessEvent> of <PaymentCallbackService>", zap.Error(err))
}
@ -102,7 +101,7 @@ func (receiver *PaymentCallbackService) FailureEvent(ctx context.Context, event
UserID: event.UserID,
Comment: event.Message,
Key: event.Key,
RawDetails: fmt.Sprintf("%d%s", event.Amount, event.Currency),
// RawDetails: fmt.Sprintf("%d%s", event.Amount, event.Currency),
}); err != nil {
receiver.logger.Error("failed to create history on <FailureEvent> of <PaymentCallbackService>", zap.Error(err))
return err

@ -206,9 +206,9 @@ func (receiver *Service) Pay(ctx context.Context, accessToken string, userID str
Key: models.CustomerHistoryKeyPayCart,
UserID: account.UserID,
Comment: "Успешная оплата корзины",
RawDetails: map[string]any{
"tariffs": tariffs,
"price": discountResponse.Price,
RawDetails: models.RawDetails{
Tariffs: tariffs,
Price: int64(discountResponse.Price),
},
}); historyErr != nil {
receiver.logger.Error("failed to insert history on <Pay> of <CartService>", zap.Error(historyErr))

@ -139,7 +139,7 @@ func (receiver *Service) ReplenishAccountWallet(ctx context.Context, request *mo
Key: models.CustomerHistoryKeyReplenish,
UserID: request.Account.UserID,
Comment: "Успешное пополнение средств (Без конвертации валюты)",
RawDetails: fmt.Sprintf("%d%s", cash, models.InternalCurrencyKey),
// RawDetails: fmt.Sprintf("%d%s", cash, models.InternalCurrencyKey),
}); historyErr != nil {
receiver.logger.Error("failed to insert history on <ReplenishAccountWallet> of <WalletService>", zap.Error(historyErr))
}
@ -183,7 +183,7 @@ func (receiver *Service) ReplenishAccountWallet(ctx context.Context, request *mo
Key: models.CustomerHistoryKeyReplenish,
UserID: request.Account.UserID,
Comment: "Успешное пополнение средств (C конвертацией валюты)",
RawDetails: fmt.Sprintf("%d%s", cash, request.Currency),
//RawDetails: fmt.Sprintf("%d%s", cash, request.Currency),
}); historyErr != nil {
receiver.logger.Error("failed to insert history on <ReplenishAccountWallet> of <WalletService>", zap.Error(historyErr))
}

BIN
main Executable file

Binary file not shown.