86 lines
3.9 KiB
Go
86 lines
3.9 KiB
Go
// Package paymenthistory exposes a read-only, branch-scoped audit view over
|
|
// every visa/master/sber payout attempt (visa_master_order_payments) - the
|
|
// full trail visamasterpay.PaymentResultDTO deliberately keeps per-order
|
|
// (see its doc comment), denormalized here with order/branch/operator info
|
|
// so an admin/operator can browse and filter payment history across orders
|
|
// without N+1 calls.
|
|
package paymenthistory
|
|
|
|
import (
|
|
"encoding/json"
|
|
"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"`
|
|
OrderNumber string `json:"orderNumber"`
|
|
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"`
|
|
// FormUrl/SuccessUrl are only set while the attempt is still pending
|
|
// (awaiting the customer to finish paying on GBÜS's hosted page) - once
|
|
// an attempt is finalized (success/failed), gateway_response no longer
|
|
// holds a formUrl, so there's nothing left to resume.
|
|
FormUrl *string `json:"formUrl,omitempty"`
|
|
SuccessUrl *string `json:"successUrl,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
|
|
// rbac.BindBranchIDs and takes priority over BranchId when set (see
|
|
// rbac.AppendBranchIDs), the same way visamaster.ListFilter works.
|
|
type ListFilter struct {
|
|
OrderId *int64
|
|
BranchId *int64
|
|
BranchIds []int64
|
|
UserId *int64
|
|
Status *string // gateway_status: pending/success/failed
|
|
Search string // matches order passport name/surname or unique id
|
|
Page int
|
|
Limit int
|
|
}
|
|
|
|
type ListPaymentHistoryDTO struct {
|
|
Count int64 `json:"count"`
|
|
Items []PaymentHistoryItemDTO `json:"items"`
|
|
}
|
|
|
|
// PaymentLogDTO is one step-by-step entry from visa_master_payment_logs -
|
|
// the granular audit trail recorded while processing an order's payout
|
|
// (see visamasterpay's logStep), independent of and more detailed than
|
|
// the summary rows in visa_master_order_payments.
|
|
type PaymentLogDTO struct {
|
|
Id int64 `json:"id"`
|
|
OrderId int64 `json:"orderId"`
|
|
Step string `json:"step"`
|
|
Detail json.RawMessage `json:"detail,omitempty"`
|
|
CreatedById *int64 `json:"createdById,omitempty"`
|
|
CreatedByName string `json:"createdByName,omitempty"`
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
}
|