Files
olons_admin/server/internal/dao/internal/trade_order.go
T
2026-10-10 20:56:17 +08:00

130 lines
4.6 KiB
Go

// ==========================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================
package internal
import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
// TradeOrderDao is the data access object for the table hg_trade_order.
type TradeOrderDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns TradeOrderColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// TradeOrderColumns defines and stores column names for the table hg_trade_order.
type TradeOrderColumns struct {
Id string // 主键
TenantId string // 租户ID
OrderNo string // 订单号
MemberId string // 会员ID
TaskId string // 任务ID
ProductId string // 商品ID
ProductName string // 商品名称快照
OrderType string // 订单类型
Quantity string // 数量
UnitPriceAmount string // 单价(分)
TotalAmount string // 订单金额(分)
CommissionAmount string // 佣金(分)
Currency string // 币种
MemberLevelId string // 下单等级ID
RuleSnapshot string // 规则快照
Message string // 订单消息
OrderStatus string // 订单状态
FreezeStatus string // 冻结状态
ApprovalRequestId string // 人工处理审批ID
MatchedAt string // 匹配时间
CompletedAt string // 完成时间
UnfrozenAt string // 解冻时间
CreatedBy string // 创建者
UpdatedBy string // 更新者
CreatedAt string // 下单时间
UpdatedAt string // 更新时间
}
// tradeOrderColumns holds the columns for the table hg_trade_order.
var tradeOrderColumns = TradeOrderColumns{
Id: "id",
TenantId: "tenant_id",
OrderNo: "order_no",
MemberId: "member_id",
TaskId: "task_id",
ProductId: "product_id",
ProductName: "product_name",
OrderType: "order_type",
Quantity: "quantity",
UnitPriceAmount: "unit_price_amount",
TotalAmount: "total_amount",
CommissionAmount: "commission_amount",
Currency: "currency",
MemberLevelId: "member_level_id",
RuleSnapshot: "rule_snapshot",
Message: "message",
OrderStatus: "order_status",
FreezeStatus: "freeze_status",
ApprovalRequestId: "approval_request_id",
MatchedAt: "matched_at",
CompletedAt: "completed_at",
UnfrozenAt: "unfrozen_at",
CreatedBy: "created_by",
UpdatedBy: "updated_by",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
}
// NewTradeOrderDao creates and returns a new DAO object for table data access.
func NewTradeOrderDao(handlers ...gdb.ModelHandler) *TradeOrderDao {
return &TradeOrderDao{
group: "default",
table: "hg_trade_order",
columns: tradeOrderColumns,
handlers: handlers,
}
}
// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *TradeOrderDao) DB() gdb.DB {
return g.DB(dao.group)
}
// Table returns the table name of the current DAO.
func (dao *TradeOrderDao) Table() string {
return dao.table
}
// Columns returns all column names of the current DAO.
func (dao *TradeOrderDao) Columns() TradeOrderColumns {
return dao.columns
}
// Group returns the database configuration group name of the current DAO.
func (dao *TradeOrderDao) Group() string {
return dao.group
}
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *TradeOrderDao) Ctx(ctx context.Context) *gdb.Model {
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.
// It rolls back the transaction and returns the error if function f returns a non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note: Do not commit or roll back the transaction in function f,
// as it is automatically handled by this function.
func (dao *TradeOrderDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
return dao.Ctx(ctx).Transaction(ctx, f)
}