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

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

// V1OrderProfitInfoColumns defines and stores column names for the table order_profit_info.
type V1OrderProfitInfoColumns struct {
	Id              string // 主键，自增
	MerchantName    string // 商户名称
	MerchantUid     string // 商户uid
	AgentUid        string // 代理uid，表示该商户是谁的代理
	AgentName       string // 代理名称
	PayProductCode  string // 支付产品编码
	PayProductName  string // 支付产品名称
	PayTypeCode     string // 支付类型编码
	PayTypeName     string // 支付类型名称
	Status          string // 等待支付-wait,支付成功-success, 支付失败-failed
	MerchantOrderId string // 下游商户提交过来的订单id
	BankOrderId     string // 平台自身的订单id
	BankTransId     string // 上游返回的订单id
	OrderAmount     string // 订单提交金额
	ShowAmount      string // 展示在用户面前待支付的金额
	FactAmount      string // 实际支付金额
	UserInAmount    string // 商户入账金额
	AllProfit       string // 总的利润，包括上游，平台，代理
	SupplierRate    string // 上游的汇率
	PlatformRate    string // 平台自己的手续费率
	AgentRate       string // 代理的手续费率
	SupplierProfit  string // 上游的利润
	PlatformProfit  string // 平台利润
	AgentProfit     string // 代理利润
	UpdateTime      string // 更新时间
	CreateTime      string // 创建时间
	PlatformFee     string //
}

// v1OrderProfitInfoColumns holds the columns for the table order_profit_info.
var v1OrderProfitInfoColumns = V1OrderProfitInfoColumns{
	Id:              "id",
	MerchantName:    "merchant_name",
	MerchantUid:     "merchant_uid",
	AgentUid:        "agent_uid",
	AgentName:       "agent_name",
	PayProductCode:  "pay_product_code",
	PayProductName:  "pay_product_name",
	PayTypeCode:     "pay_type_code",
	PayTypeName:     "pay_type_name",
	Status:          "status",
	MerchantOrderId: "merchant_order_id",
	BankOrderId:     "bank_order_id",
	BankTransId:     "bank_trans_id",
	OrderAmount:     "order_amount",
	ShowAmount:      "show_amount",
	FactAmount:      "fact_amount",
	UserInAmount:    "user_in_amount",
	AllProfit:       "all_profit",
	SupplierRate:    "supplier_rate",
	PlatformRate:    "platform_rate",
	AgentRate:       "agent_rate",
	SupplierProfit:  "supplier_profit",
	PlatformProfit:  "platform_profit",
	AgentProfit:     "agent_profit",
	UpdateTime:      "update_time",
	CreateTime:      "create_time",
	PlatformFee:     "platform_fee",
}

// NewV1OrderProfitInfoDao creates and returns a new DAO object for table data access.
func NewV1OrderProfitInfoDao(handlers ...gdb.ModelHandler) *V1OrderProfitInfoDao {
	return &V1OrderProfitInfoDao{
		group:    "default",
		table:    "order_profit_info",
		columns:  v1OrderProfitInfoColumns,
		handlers: handlers,
	}
}

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

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

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

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