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

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

// V1RechargeTMallShopColumns defines and stores column names for the table recharge_t_mall_shop.
type V1RechargeTMallShopColumns struct {
	Id           string //
	OrderNo      string // 订单号
	Account      string // 充值账号
	TMallOrderNo string // 淘宝订单号
	BuyerNick    string // 买家昵称
	BuyerRate    string // 买家是否评价
	Status       string // 交易状态
	Payment      string // 实付金额
	TotalFee     string // 商品金额
	PayTime      string // 付款时间
	TradeStatus  string // 天猫返回状态
	BuyerMemo    string // 买家备注
	AlipayNo     string // 支付宝交易号
	BuyerMessage string // 买家留言
	CreateTime   string // 交易创建时间
	EndTime      string // 交易结束时间
	CreatedAt    string //
	UpdatedAt    string //
	DeletedAt    string //
}

// v1RechargeTMallShopColumns holds the columns for the table recharge_t_mall_shop.
var v1RechargeTMallShopColumns = V1RechargeTMallShopColumns{
	Id:           "id",
	OrderNo:      "order_no",
	Account:      "account",
	TMallOrderNo: "t_mall_order_no",
	BuyerNick:    "buyer_nick",
	BuyerRate:    "buyer_rate",
	Status:       "status",
	Payment:      "payment",
	TotalFee:     "total_fee",
	PayTime:      "pay_time",
	TradeStatus:  "trade_status",
	BuyerMemo:    "buyer_memo",
	AlipayNo:     "alipay_no",
	BuyerMessage: "buyer_message",
	CreateTime:   "create_time",
	EndTime:      "end_time",
	CreatedAt:    "created_at",
	UpdatedAt:    "updated_at",
	DeletedAt:    "deleted_at",
}

// NewV1RechargeTMallShopDao creates and returns a new DAO object for table data access.
func NewV1RechargeTMallShopDao(handlers ...gdb.ModelHandler) *V1RechargeTMallShopDao {
	return &V1RechargeTMallShopDao{
		group:    "default",
		table:    "recharge_t_mall_shop",
		columns:  v1RechargeTMallShopColumns,
		handlers: handlers,
	}
}

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

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

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

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