- Introduced TenantLedger model with fields for managing tenant transactions, including ID, TenantID, UserID, OrderID, transaction Type, Amount, and balance details. - Implemented CRUD operations for TenantLedger with methods for Create, Update, Delete, and Reload. - Generated query methods for TenantLedger to facilitate database interactions, including filtering, pagination, and aggregation functions. - Established relationships with Order model for foreign key references.
23 lines
1.1 KiB
Go
23 lines
1.1 KiB
Go
package dto
|
|
|
|
import "quyun/v2/database/models"
|
|
|
|
// PurchaseContentForm defines the request body for purchasing a content using tenant balance.
|
|
type PurchaseContentForm struct {
|
|
// IdempotencyKey is used to ensure the purchase request is processed at most once.
|
|
// 建议由客户端生成并保持稳定:同一笔购买重复请求时返回相同结果,避免重复扣款/重复下单。
|
|
IdempotencyKey string `json:"idempotency_key,omitempty"`
|
|
}
|
|
|
|
// PurchaseContentResponse returns the order and granted access after a purchase.
|
|
type PurchaseContentResponse struct {
|
|
// Order is the created or existing order record (may be nil for owner/free-path without order).
|
|
Order *models.Order `json:"order,omitempty"`
|
|
// Item is the single order item of this purchase (current implementation is 1 order -> 1 content).
|
|
Item *models.OrderItem `json:"item,omitempty"`
|
|
// Access is the content access record after purchase grant.
|
|
Access *models.ContentAccess `json:"access,omitempty"`
|
|
// AmountPaid is the final paid amount in cents (CNY 分).
|
|
AmountPaid int64 `json:"amount_paid,omitempty"`
|
|
}
|