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

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

// V1OrderSettleInfoColumns defines and stores column names for the table order_settle_info.
type V1OrderSettleInfoColumns struct {
	Id               string // 主键，自增
	PayProductCode   string // 支付产品编码
	PayProductName   string // 支付产品名称
	PayTypeCode      string // 支付类型编码
	PayTypeName      string // 支付类型名称
	MerchantUid      string // 商户uid，表示订单是哪个商户的
	RoadUid          string // 通道uid
	MerchantName     string // 商户名称
	MerchantOrderId  string // 下游商户提交过来的订单id
	BankOrderId      string // 平台自身的订单id
	SettleAmount     string // 结算金额
	IsAllowSettle    string // 是否允许结算，允许-yes，不允许-no
	IsCompleteSettle string // 该笔订单是否结算完毕，没有结算-no，结算完毕-yes
	UpdateTime       string // 更新时间
	CreateTime       string // 创建时间
}

// v1OrderSettleInfoColumns holds the columns for the table order_settle_info.
var v1OrderSettleInfoColumns = V1OrderSettleInfoColumns{
	Id:               "id",
	PayProductCode:   "pay_product_code",
	PayProductName:   "pay_product_name",
	PayTypeCode:      "pay_type_code",
	PayTypeName:      "pay_type_name",
	MerchantUid:      "merchant_uid",
	RoadUid:          "road_uid",
	MerchantName:     "merchant_name",
	MerchantOrderId:  "merchant_order_id",
	BankOrderId:      "bank_order_id",
	SettleAmount:     "settle_amount",
	IsAllowSettle:    "is_allow_settle",
	IsCompleteSettle: "is_complete_settle",
	UpdateTime:       "update_time",
	CreateTime:       "create_time",
}

// NewV1OrderSettleInfoDao creates and returns a new DAO object for table data access.
func NewV1OrderSettleInfoDao(handlers ...gdb.ModelHandler) *V1OrderSettleInfoDao {
	return &V1OrderSettleInfoDao{
		group:    "default",
		table:    "order_settle_info",
		columns:  v1OrderSettleInfoColumns,
		handlers: handlers,
	}
}

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

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

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

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