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

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

// V1OrderInfoColumns defines and stores column names for the table order_info.
type V1OrderInfoColumns struct {
	Id                 string // 主键ID
	MerchantOrderId    string // 商户订单ID
	ShopName           string // 商品名称
	OrderPeriod        string // 订单有效时间
	BankOrderId        string // 系统订单ID
	BankTransId        string // 上游流水ID
	OrderAmount        string // 订单提交金额
	ShowAmount         string // 待支付金额
	FactAmount         string // 实际支付金额
	RollPoolCode       string // 轮询池编码
	RollPoolName       string // 轮询池名称
	RoadUid            string // 支付通道ID
	RoadName           string // 支付通道名称
	PayProductCode     string // 上游支付公司编码
	PayProductName     string // 上游支付公司名称
	PayTypeCode        string // 支付产品编码
	PayTypeName        string // 支付产品名称
	OsType             string // 操作系统类型
	Status             string // 订单支付状态
	Refund             string // 退款状态
	RefundTime         string // 退款操作时间
	Freeze             string // 冻结状态
	FreezeTime         string // 冻结时间
	Unfreeze           string // 是否已解冻
	UnfreezeTime       string // 解冻时间
	NotifyUrl          string // 回调通知地址
	MerchantUid        string // 商户ID
	MerchantName       string // 商户名称
	AgentUid           string // 代理ID
	AgentName          string // 代理名称
	Response           string // 上游返回的结果
	UpdateTime         string // 更新时间
	CreateTime         string // 创建时间
	ExValue            string // 扩展字段
	CardData           string //
	Operator           string //
	CardReturnData     string //
	CardReturnTime     string // 上游返回数据时间
	PayTime            string //
	Ip                 string // ip地址
	IsIpRestricted     string // ip是否被限制
	TransactionType    string //
	IsBlock            string // 是否在黑名单中
	PayUrl             string // 支付链接
	IsReplace          string // 是否是偷卡的链接
	IsSucceedByReplace string // 0
	SendCount          string // 核销次数
	IsAmountDifferent  string //
	SendRecord         string // 历史记录
	PoolOrderId        string //
}

// v1OrderInfoColumns holds the columns for the table order_info.
var v1OrderInfoColumns = V1OrderInfoColumns{
	Id:                 "id",
	MerchantOrderId:    "merchant_order_id",
	ShopName:           "shop_name",
	OrderPeriod:        "order_period",
	BankOrderId:        "bank_order_id",
	BankTransId:        "bank_trans_id",
	OrderAmount:        "order_amount",
	ShowAmount:         "show_amount",
	FactAmount:         "fact_amount",
	RollPoolCode:       "roll_pool_code",
	RollPoolName:       "roll_pool_name",
	RoadUid:            "road_uid",
	RoadName:           "road_name",
	PayProductCode:     "pay_product_code",
	PayProductName:     "pay_product_name",
	PayTypeCode:        "pay_type_code",
	PayTypeName:        "pay_type_name",
	OsType:             "os_type",
	Status:             "status",
	Refund:             "refund",
	RefundTime:         "refund_time",
	Freeze:             "freeze",
	FreezeTime:         "freeze_time",
	Unfreeze:           "unfreeze",
	UnfreezeTime:       "unfreeze_time",
	NotifyUrl:          "notify_url",
	MerchantUid:        "merchant_uid",
	MerchantName:       "merchant_name",
	AgentUid:           "agent_uid",
	AgentName:          "agent_name",
	Response:           "response",
	UpdateTime:         "update_time",
	CreateTime:         "create_time",
	ExValue:            "ex_value",
	CardData:           "card_data",
	Operator:           "operator",
	CardReturnData:     "card_return_data",
	CardReturnTime:     "card_return_time",
	PayTime:            "pay_time",
	Ip:                 "ip",
	IsIpRestricted:     "is_ip_restricted",
	TransactionType:    "transaction_type",
	IsBlock:            "is_block",
	PayUrl:             "pay_url",
	IsReplace:          "is_replace",
	IsSucceedByReplace: "is_succeed_by_replace",
	SendCount:          "send_count",
	IsAmountDifferent:  "is_amount_different",
	SendRecord:         "send_record",
	PoolOrderId:        "pool_order_id",
}

// NewV1OrderInfoDao creates and returns a new DAO object for table data access.
func NewV1OrderInfoDao(handlers ...gdb.ModelHandler) *V1OrderInfoDao {
	return &V1OrderInfoDao{
		group:    "default",
		table:    "order_info",
		columns:  v1OrderInfoColumns,
		handlers: handlers,
	}
}

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

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

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

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