fixed error
This commit is contained in:
@@ -9399,7 +9399,7 @@ const docTemplate = `{
|
||||
"type": "integer"
|
||||
},
|
||||
"branchName": {
|
||||
"type": "string"
|
||||
"$ref": "#/definitions/shared.LocalizedText"
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "string"
|
||||
|
||||
@@ -9393,7 +9393,7 @@
|
||||
"type": "integer"
|
||||
},
|
||||
"branchName": {
|
||||
"type": "string"
|
||||
"$ref": "#/definitions/shared.LocalizedText"
|
||||
},
|
||||
"createdAt": {
|
||||
"type": "string"
|
||||
|
||||
@@ -1313,7 +1313,7 @@ definitions:
|
||||
branchId:
|
||||
type: integer
|
||||
branchName:
|
||||
type: string
|
||||
$ref: '#/definitions/shared.LocalizedText'
|
||||
createdAt:
|
||||
type: string
|
||||
createdById:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user