feat: add TenantLedger model and query generation
- 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.
This commit is contained in:
@@ -17,18 +17,18 @@ const TableNameContentPrice = "content_prices"
|
||||
|
||||
// ContentPrice mapped from table <content_prices>
|
||||
type ContentPrice struct {
|
||||
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
|
||||
TenantID int64 `gorm:"column:tenant_id;type:bigint;not null" json:"tenant_id"`
|
||||
UserID int64 `gorm:"column:user_id;type:bigint;not null" json:"user_id"`
|
||||
ContentID int64 `gorm:"column:content_id;type:bigint;not null" json:"content_id"`
|
||||
Currency consts.Currency `gorm:"column:currency;type:character varying(16);not null;default:CNY" json:"currency"`
|
||||
PriceAmount int64 `gorm:"column:price_amount;type:bigint;not null" json:"price_amount"`
|
||||
DiscountType consts.DiscountType `gorm:"column:discount_type;type:character varying(16);not null;default:none" json:"discount_type"`
|
||||
DiscountValue int64 `gorm:"column:discount_value;type:bigint;not null" json:"discount_value"`
|
||||
DiscountStartAt time.Time `gorm:"column:discount_start_at;type:timestamp with time zone" json:"discount_start_at"`
|
||||
DiscountEndAt time.Time `gorm:"column:discount_end_at;type:timestamp with time zone" json:"discount_end_at"`
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:timestamp with time zone;not null;default:now()" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp with time zone;not null;default:now()" json:"updated_at"`
|
||||
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true;comment:主键ID:自增" json:"id"` // 主键ID:自增
|
||||
TenantID int64 `gorm:"column:tenant_id;type:bigint;not null;comment:租户ID:多租户隔离;与内容归属一致" json:"tenant_id"` // 租户ID:多租户隔离;与内容归属一致
|
||||
UserID int64 `gorm:"column:user_id;type:bigint;not null;comment:用户ID:设置/更新价格的操作人(通常为 tenant_admin);用于审计" json:"user_id"` // 用户ID:设置/更新价格的操作人(通常为 tenant_admin);用于审计
|
||||
ContentID int64 `gorm:"column:content_id;type:bigint;not null;comment:内容ID:唯一约束 (tenant_id, content_id);一个内容在一个租户内仅一份定价" json:"content_id"` // 内容ID:唯一约束 (tenant_id, content_id);一个内容在一个租户内仅一份定价
|
||||
Currency consts.Currency `gorm:"column:currency;type:character varying(16);not null;default:CNY;comment:币种:当前固定 CNY;金额单位为分" json:"currency"` // 币种:当前固定 CNY;金额单位为分
|
||||
PriceAmount int64 `gorm:"column:price_amount;type:bigint;not null;comment:基础价格:分;0 表示免费(可直接访问正片资源)" json:"price_amount"` // 基础价格:分;0 表示免费(可直接访问正片资源)
|
||||
DiscountType consts.DiscountType `gorm:"column:discount_type;type:character varying(16);not null;default:none;comment:折扣类型:none/percent/amount;仅影响下单时成交价,需写入订单快照" json:"discount_type"` // 折扣类型:none/percent/amount;仅影响下单时成交价,需写入订单快照
|
||||
DiscountValue int64 `gorm:"column:discount_value;type:bigint;not null;comment:折扣值:percent=0-100(按业务校验);amount=分;none 时忽略" json:"discount_value"` // 折扣值:percent=0-100(按业务校验);amount=分;none 时忽略
|
||||
DiscountStartAt time.Time `gorm:"column:discount_start_at;type:timestamp with time zone;comment:折扣开始时间:可为空;为空表示立即生效(由业务逻辑解释)" json:"discount_start_at"` // 折扣开始时间:可为空;为空表示立即生效(由业务逻辑解释)
|
||||
DiscountEndAt time.Time `gorm:"column:discount_end_at;type:timestamp with time zone;comment:折扣结束时间:可为空;为空表示长期有效(由业务逻辑解释)" json:"discount_end_at"` // 折扣结束时间:可为空;为空表示长期有效(由业务逻辑解释)
|
||||
CreatedAt time.Time `gorm:"column:created_at;type:timestamp with time zone;not null;default:now();comment:创建时间:默认 now();用于审计" json:"created_at"` // 创建时间:默认 now();用于审计
|
||||
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp with time zone;not null;default:now();comment:更新时间:默认 now();更新价格/折扣时写入" json:"updated_at"` // 更新时间:默认 now();更新价格/折扣时写入
|
||||
}
|
||||
|
||||
// Quick operations without importing query package
|
||||
|
||||
Reference in New Issue
Block a user