From febd190d6e51f0c8d9ea20439763abb2ba9b5e0f Mon Sep 17 00:00:00 2001 From: GuwandykA Date: Mon, 21 Sep 2026 18:31:31 +0500 Subject: [PATCH] fixed error --- docs/docs.go | 2 +- docs/swagger.json | 2 +- docs/swagger.yaml | 2 +- .../payment/paymenthistory/db/postgresql.go | 8 ++- internal/payment/paymenthistory/dto.go | 56 ++++++++++--------- 5 files changed, 39 insertions(+), 31 deletions(-) diff --git a/docs/docs.go b/docs/docs.go index 044bcc1..aedba66 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -9399,7 +9399,7 @@ const docTemplate = `{ "type": "integer" }, "branchName": { - "type": "string" + "$ref": "#/definitions/shared.LocalizedText" }, "createdAt": { "type": "string" diff --git a/docs/swagger.json b/docs/swagger.json index 1727b30..db965e4 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -9393,7 +9393,7 @@ "type": "integer" }, "branchName": { - "type": "string" + "$ref": "#/definitions/shared.LocalizedText" }, "createdAt": { "type": "string" diff --git a/docs/swagger.yaml b/docs/swagger.yaml index f378baa..39623cd 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1313,7 +1313,7 @@ definitions: branchId: type: integer branchName: - type: string + $ref: '#/definitions/shared.LocalizedText' createdAt: type: string createdById: diff --git a/internal/payment/paymenthistory/db/postgresql.go b/internal/payment/paymenthistory/db/postgresql.go index d1d6e46..7c78faa 100644 --- a/internal/payment/paymenthistory/db/postgresql.go +++ b/internal/payment/paymenthistory/db/postgresql.go @@ -29,7 +29,7 @@ LEFT JOIN branches b ON b.id = o.branch_id LEFT JOIN users u ON u.id = p.created_by` const historySelectColumns = `p.id, p.order_id, COALESCE(o.unique_id, ''), COALESCE(o.type, ''), - o.branch_id, COALESCE(b.name, ''), COALESCE(o.passport_name, ''), COALESCE(o.passport_surname, ''), p.user_id, + o.branch_id, b.name, COALESCE(o.passport_name, ''), COALESCE(o.passport_surname, ''), p.user_id, p.amount_tmt, p.bank_fee_tmt, p.gbus_fee_tmt, p.tveb_fee_usd, p.tveb_fee_tmt, p.total_amount_tmt, p.exchange_rate_usd, p.exchange_rate_rub, p.payment_period, p.gateway_status, p.gateway_reference, p.created_by, ` + shared.UserDisplaySQL + `, @@ -112,9 +112,10 @@ func buildListQuery(filter paymenthistory.ListFilter) (whereClause string, args func scanHistoryItem(row pgx.Row) (paymenthistory.PaymentHistoryItemDTO, error) { var item paymenthistory.PaymentHistoryItemDTO var gatewayStatus string + var branchNameJSON []byte if err := row.Scan( &item.Id, &item.OrderId, &item.OrderUniqueId, &item.Type, - &item.BranchId, &item.BranchName, &item.PassportName, &item.PassportSurname, &item.UserId, + &item.BranchId, &branchNameJSON, &item.PassportName, &item.PassportSurname, &item.UserId, &item.AmountTmt, &item.BankFeeTmt, &item.GbusFeeTmt, &item.TvebFeeUsd, &item.TvebFeeTmt, &item.TotalAmountTmt, &item.ExchangeRateUsd, &item.ExchangeRateRub, &item.PaymentPeriod, &gatewayStatus, &item.GatewayReference, &item.CreatedById, &item.CreatedByName, @@ -122,6 +123,9 @@ func scanHistoryItem(row pgx.Row) (paymenthistory.PaymentHistoryItemDTO, error) ); err != nil { return paymenthistory.PaymentHistoryItemDTO{}, err } + if err := shared.UnmarshalLocalized(branchNameJSON, &item.BranchName); err != nil { + return paymenthistory.PaymentHistoryItemDTO{}, err + } item.GatewayStatus = gatewayStatus item.Paid = gatewayStatus == "success" return item, nil diff --git a/internal/payment/paymenthistory/dto.go b/internal/payment/paymenthistory/dto.go index c980fc9..466a0fe 100644 --- a/internal/payment/paymenthistory/dto.go +++ b/internal/payment/paymenthistory/dto.go @@ -6,37 +6,41 @@ // without N+1 calls. package paymenthistory -import "time" +import ( + "time" + + "online-back/internal/shared" +) // PaymentHistoryItemDTO is one payout attempt (paid, failed, or still // pending) enriched with the order/branch/client/operator context needed to // display it in a history list, without requiring a separate lookup per row. type PaymentHistoryItemDTO struct { - Id int64 `json:"id"` - OrderId int64 `json:"orderId"` - OrderUniqueId string `json:"orderUniqueId"` - Type string `json:"type"` - BranchId int64 `json:"branchId"` - BranchName string `json:"branchName"` - PassportName string `json:"passportName"` - PassportSurname string `json:"passportSurname"` - UserId int64 `json:"userId"` - Paid bool `json:"paid"` - AmountTmt float64 `json:"amountTmt"` - BankFeeTmt float64 `json:"bankFeeTmt"` - GbusFeeTmt *float64 `json:"gbusFeeTmt,omitempty"` - TvebFeeUsd *float64 `json:"tvebFeeUsd,omitempty"` - TvebFeeTmt *float64 `json:"tvebFeeTmt,omitempty"` - TotalAmountTmt float64 `json:"totalAmountTmt"` - ExchangeRateUsd float64 `json:"exchangeRateUsd"` - ExchangeRateRub *float64 `json:"exchangeRateRub,omitempty"` - PaymentPeriod time.Time `json:"paymentPeriod"` - GatewayStatus string `json:"gatewayStatus"` - GatewayReference *string `json:"gatewayReference,omitempty"` - CreatedById *int64 `json:"createdById,omitempty"` - CreatedByName string `json:"createdByName,omitempty"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` + Id int64 `json:"id"` + OrderId int64 `json:"orderId"` + OrderUniqueId string `json:"orderUniqueId"` + Type string `json:"type"` + BranchId int64 `json:"branchId"` + BranchName shared.LocalizedText `json:"branchName"` + PassportName string `json:"passportName"` + PassportSurname string `json:"passportSurname"` + UserId int64 `json:"userId"` + Paid bool `json:"paid"` + AmountTmt float64 `json:"amountTmt"` + BankFeeTmt float64 `json:"bankFeeTmt"` + GbusFeeTmt *float64 `json:"gbusFeeTmt,omitempty"` + TvebFeeUsd *float64 `json:"tvebFeeUsd,omitempty"` + TvebFeeTmt *float64 `json:"tvebFeeTmt,omitempty"` + TotalAmountTmt float64 `json:"totalAmountTmt"` + ExchangeRateUsd float64 `json:"exchangeRateUsd"` + ExchangeRateRub *float64 `json:"exchangeRateRub,omitempty"` + PaymentPeriod time.Time `json:"paymentPeriod"` + GatewayStatus string `json:"gatewayStatus"` + GatewayReference *string `json:"gatewayReference,omitempty"` + CreatedById *int64 `json:"createdById,omitempty"` + CreatedByName string `json:"createdByName,omitempty"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` } // ListFilter narrows the history list. BranchIds is populated by