Files
quyun-v2/backend/app/http/tenant/dto/ledger_admin.go
Rogee 5dc0f89ac0 feat: add operator and business reference fields to tenant ledgers
- Added `operator_user_id`, `biz_ref_type`, and `biz_ref_id` fields to the TenantLedger model for enhanced auditing and traceability.
- Updated the tenant ledgers query generation to include new fields.
- Introduced new API endpoint for retrieving tenant ledger records with filtering options based on the new fields.
- Enhanced Swagger documentation to reflect the new endpoint and its parameters.
- Created DTOs for admin ledger filtering and item representation.
- Implemented the admin ledger retrieval logic in the tenant service.
- Added database migration scripts to introduce new fields and indexes for efficient querying.
2025-12-22 21:35:10 +08:00

54 lines
2.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package dto
import (
"time"
"quyun/v2/app/requests"
"quyun/v2/database/models"
"quyun/v2/pkg/consts"
)
// AdminLedgerListFilter 定义“租户后台余额流水”查询条件。
//
// 设计目标:
// - 用于审计/对账可以按操作者operator_user_id检索敏感操作流水
// - 也可以按用户、订单、类型、业务引用快速定位流水集合。
type AdminLedgerListFilter struct {
// Pagination 分页参数page/limit
requests.Pagination `json:",inline" query:",inline"`
// OperatorUserID 按操作者用户ID过滤可选
// 典型场景:后台检索“某个管理员发起的充值/退款”等敏感操作流水。
OperatorUserID *int64 `json:"operator_user_id,omitempty" query:"operator_user_id"`
// UserID 按余额账户归属用户ID过滤可选
// 典型场景:查看某个租户成员的资金变化全链路。
UserID *int64 `json:"user_id,omitempty" query:"user_id"`
// Type 按流水类型过滤(可选)。
Type *consts.TenantLedgerType `json:"type,omitempty" query:"type"`
// OrderID 按关联订单过滤(可选)。
OrderID *int64 `json:"order_id,omitempty" query:"order_id"`
// BizRefType 按业务引用类型过滤(可选)。
// 约定:当前业务写入为 "order";未来可扩展为 refund/topup 等。
BizRefType *string `json:"biz_ref_type,omitempty" query:"biz_ref_type"`
// BizRefID 按业务引用ID过滤可选
BizRefID *int64 `json:"biz_ref_id,omitempty" query:"biz_ref_id"`
// CreatedAtFrom 创建时间起(可选)。
CreatedAtFrom *time.Time `json:"created_at_from,omitempty" query:"created_at_from"`
// CreatedAtTo 创建时间止(可选)。
CreatedAtTo *time.Time `json:"created_at_to,omitempty" query:"created_at_to"`
}
// AdminLedgerItem 返回一条余额流水(租户后台视角),并补充展示字段。
type AdminLedgerItem struct {
// Ledger 流水记录(租户内隔离)。
Ledger *models.TenantLedger `json:"ledger"`
// TypeDescription 流水类型中文说明(用于前端展示)。
TypeDescription string `json:"type_description"`
}