From 654ddc0b4a72334ab1ef31808114256d31151d6d Mon Sep 17 00:00:00 2001 From: "aditya.siregar" Date: Wed, 28 Aug 2024 00:32:19 +0700 Subject: [PATCH] Update Transaction --- internal/entity/transaction.go | 2 ++ internal/handlers/http/transaction/transaction.go | 2 ++ internal/handlers/response/transaction.go | 2 ++ internal/repository/transaction/transaction.go | 2 +- internal/services/service.go | 2 +- 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/entity/transaction.go b/internal/entity/transaction.go index 7e28546..998349e 100644 --- a/internal/entity/transaction.go +++ b/internal/entity/transaction.go @@ -52,6 +52,8 @@ type TransactionList struct { SiteName string PartnerName string Amount int64 + Total int64 + Fee int64 } type TransactionApproval struct { diff --git a/internal/handlers/http/transaction/transaction.go b/internal/handlers/http/transaction/transaction.go index e41e3d6..5b70f4f 100644 --- a/internal/handlers/http/transaction/transaction.go +++ b/internal/handlers/http/transaction/transaction.go @@ -105,6 +105,8 @@ func (h *TransactionHandler) ToTransactionListResponse(transactions []*entity.Tr SiteName: transaction.SiteName, Amount: transaction.Amount, PartnerName: transaction.PartnerName, + Total: transaction.Total, + Fee: transaction.Fee, } } diff --git a/internal/handlers/response/transaction.go b/internal/handlers/response/transaction.go index 5cdbb96..c6d67c5 100644 --- a/internal/handlers/response/transaction.go +++ b/internal/handlers/response/transaction.go @@ -10,6 +10,8 @@ type TransactionListItem struct { SiteName string `json:"site_name"` Amount int64 `json:"amount"` PartnerName string `json:"partner_name"` + Total int64 `json:"total"` + Fee int64 `json:"fee"` } type TransactionListResponse struct { diff --git a/internal/repository/transaction/transaction.go b/internal/repository/transaction/transaction.go index 3c70f7d..2d7a26c 100644 --- a/internal/repository/transaction/transaction.go +++ b/internal/repository/transaction/transaction.go @@ -135,7 +135,7 @@ func (r *TransactionRepository) GetTransactionList(ctx mycontext.Context, req en var total int64 query := r.db.Table("transactions t"). - Select("t.id, t.transaction_type, t.status, t.created_at, s.name as site_name, p.name as partner_name, t.amount"). + Select("t.id, t.transaction_type, t.status, t.created_at, s.name as site_name, p.name as partner_name, t.amount, t.fee, t.total"). Joins("left join sites s on t.site_id = s.id"). Joins("left join partners p on t.partner_id = p.id") diff --git a/internal/services/service.go b/internal/services/service.go index dfda9ee..3bf017b 100644 --- a/internal/services/service.go +++ b/internal/services/service.go @@ -50,7 +50,7 @@ func NewServiceManagerImpl(cfg *config.Config, repo *repository.RepoManagerImpl) BranchSvc: branch.NewBranchService(repo.Branch), StudioSvc: studio.NewStudioService(repo.Studio), ProductSvc: product.NewProductService(repo.Product), - OrderSvc: order.NewOrderService(repo.Order, repo.Product, repo.Crypto, repo.Midtrans, repo.Payment, repo.Trx, repo.Wallet, &cfg.Order, repo.Transactiont add), + OrderSvc: order.NewOrderService(repo.Order, repo.Product, repo.Crypto, repo.Midtrans, repo.Payment, repo.Trx, repo.Wallet, &cfg.Order, repo.Transaction), OSSSvc: oss.NewOSSService(repo.OSS), PartnerSvc: partner.NewPartnerService( repo.Partner, users.NewUserService(repo.User, repo.Branch), repo.Trx, repo.Wallet, repo.User),