// ==========================================================================
// 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"
)

// V1CamelOilOrderDao is the data access object for the table camel_oil_order.
type V1CamelOilOrderDao 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  V1CamelOilOrderColumns // columns contains all the column names of Table for convenient usage.
	handlers []gdb.ModelHandler     // handlers for customized model modification.
}

// V1CamelOilOrderColumns defines and stores column names for the table camel_oil_order.
type V1CamelOilOrderColumns struct {
	Id              string // 主键ID
	OrderNo         string // 系统订单号
	MerchantOrderId string // 商户订单号
	AccountId       string // 使用的账号ID
	AccountName     string // 账号名称
	PlatformOrderNo string // 骆驼平台订单号
	Amount          string // 订单金额
	AlipayUrl       string // 支付宝支付链接
	CardPassword    string // 卡密
	CardNumber      string // 卡号
	Status          string // 状态：1待支付 2已支付 3支付超时 4下单失败
	PayStatus       string // 支付状态：0未支付 1已支付 2超时
	NotifyStatus    string // 回调状态：0未回调 1已回调 2回调失败
	NotifyCount     string // 回调次数
	LastCheckAt     string // 最后检测支付时间
	PaidAt          string // 支付完成时间
	Attach          string // 附加信息
	FailureReason   string // 失败原因
	CreatedAt       string // 创建时间
	UpdatedAt       string // 更新时间
	DeletedAt       string // 删除时间（软删除）
}

// v1CamelOilOrderColumns holds the columns for the table camel_oil_order.
var v1CamelOilOrderColumns = V1CamelOilOrderColumns{
	Id:              "id",
	OrderNo:         "order_no",
	MerchantOrderId: "merchant_order_id",
	AccountId:       "account_id",
	AccountName:     "account_name",
	PlatformOrderNo: "platform_order_no",
	Amount:          "amount",
	AlipayUrl:       "alipay_url",
	CardPassword:    "card_password",
	CardNumber:      "card_number",
	Status:          "status",
	PayStatus:       "pay_status",
	NotifyStatus:    "notify_status",
	NotifyCount:     "notify_count",
	LastCheckAt:     "last_check_at",
	PaidAt:          "paid_at",
	Attach:          "attach",
	FailureReason:   "failure_reason",
	CreatedAt:       "created_at",
	UpdatedAt:       "updated_at",
	DeletedAt:       "deleted_at",
}

// NewV1CamelOilOrderDao creates and returns a new DAO object for table data access.
func NewV1CamelOilOrderDao(handlers ...gdb.ModelHandler) *V1CamelOilOrderDao {
	return &V1CamelOilOrderDao{
		group:    "default",
		table:    "camel_oil_order",
		columns:  v1CamelOilOrderColumns,
		handlers: handlers,
	}
}

// DB retrieves and returns the underlying raw database management object of the current DAO.
func (dao *V1CamelOilOrderDao) DB() gdb.DB {
	return g.DB(dao.group)
}

// Table returns the table name of the current DAO.
func (dao *V1CamelOilOrderDao) Table() string {
	return dao.table
}

// Columns returns all column names of the current DAO.
func (dao *V1CamelOilOrderDao) Columns() V1CamelOilOrderColumns {
	return dao.columns
}

// Group returns the database configuration group name of the current DAO.
func (dao *V1CamelOilOrderDao) 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 *V1CamelOilOrderDao) 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 *V1CamelOilOrderDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
	return dao.Ctx(ctx).Transaction(ctx, f)
}
