// Code generated by ent, DO NOT EDIT.

package paymentorder

import (
	"time"

	"entgo.io/ent/dialect/sql"
	"entgo.io/ent/dialect/sql/sqlgraph"
)

const (
	// Label holds the string label denoting the paymentorder type in the database.
	Label = "payment_order"
	// FieldID holds the string denoting the id field in the database.
	FieldID = "id"
	// FieldUserID holds the string denoting the user_id field in the database.
	FieldUserID = "user_id"
	// FieldUserEmail holds the string denoting the user_email field in the database.
	FieldUserEmail = "user_email"
	// FieldUserName holds the string denoting the user_name field in the database.
	FieldUserName = "user_name"
	// FieldUserNotes holds the string denoting the user_notes field in the database.
	FieldUserNotes = "user_notes"
	// FieldAmount holds the string denoting the amount field in the database.
	FieldAmount = "amount"
	// FieldPayAmount holds the string denoting the pay_amount field in the database.
	FieldPayAmount = "pay_amount"
	// FieldFeeRate holds the string denoting the fee_rate field in the database.
	FieldFeeRate = "fee_rate"
	// FieldRechargeCode holds the string denoting the recharge_code field in the database.
	FieldRechargeCode = "recharge_code"
	// FieldOutTradeNo holds the string denoting the out_trade_no field in the database.
	FieldOutTradeNo = "out_trade_no"
	// FieldPaymentType holds the string denoting the payment_type field in the database.
	FieldPaymentType = "payment_type"
	// FieldPaymentTradeNo holds the string denoting the payment_trade_no field in the database.
	FieldPaymentTradeNo = "payment_trade_no"
	// FieldPayURL holds the string denoting the pay_url field in the database.
	FieldPayURL = "pay_url"
	// FieldQrCode holds the string denoting the qr_code field in the database.
	FieldQrCode = "qr_code"
	// FieldQrCodeImg holds the string denoting the qr_code_img field in the database.
	FieldQrCodeImg = "qr_code_img"
	// FieldOrderType holds the string denoting the order_type field in the database.
	FieldOrderType = "order_type"
	// FieldPlanID holds the string denoting the plan_id field in the database.
	FieldPlanID = "plan_id"
	// FieldSubscriptionGroupID holds the string denoting the subscription_group_id field in the database.
	FieldSubscriptionGroupID = "subscription_group_id"
	// FieldSubscriptionDays holds the string denoting the subscription_days field in the database.
	FieldSubscriptionDays = "subscription_days"
	// FieldProviderInstanceID holds the string denoting the provider_instance_id field in the database.
	FieldProviderInstanceID = "provider_instance_id"
	// FieldProviderKey holds the string denoting the provider_key field in the database.
	FieldProviderKey = "provider_key"
	// FieldStatus holds the string denoting the status field in the database.
	FieldStatus = "status"
	// FieldRefundAmount holds the string denoting the refund_amount field in the database.
	FieldRefundAmount = "refund_amount"
	// FieldRefundReason holds the string denoting the refund_reason field in the database.
	FieldRefundReason = "refund_reason"
	// FieldRefundAt holds the string denoting the refund_at field in the database.
	FieldRefundAt = "refund_at"
	// FieldForceRefund holds the string denoting the force_refund field in the database.
	FieldForceRefund = "force_refund"
	// FieldRefundRequestedAt holds the string denoting the refund_requested_at field in the database.
	FieldRefundRequestedAt = "refund_requested_at"
	// FieldRefundRequestReason holds the string denoting the refund_request_reason field in the database.
	FieldRefundRequestReason = "refund_request_reason"
	// FieldRefundRequestedBy holds the string denoting the refund_requested_by field in the database.
	FieldRefundRequestedBy = "refund_requested_by"
	// FieldExpiresAt holds the string denoting the expires_at field in the database.
	FieldExpiresAt = "expires_at"
	// FieldPaidAt holds the string denoting the paid_at field in the database.
	FieldPaidAt = "paid_at"
	// FieldCompletedAt holds the string denoting the completed_at field in the database.
	FieldCompletedAt = "completed_at"
	// FieldFailedAt holds the string denoting the failed_at field in the database.
	FieldFailedAt = "failed_at"
	// FieldFailedReason holds the string denoting the failed_reason field in the database.
	FieldFailedReason = "failed_reason"
	// FieldClientIP holds the string denoting the client_ip field in the database.
	FieldClientIP = "client_ip"
	// FieldSrcHost holds the string denoting the src_host field in the database.
	FieldSrcHost = "src_host"
	// FieldSrcURL holds the string denoting the src_url field in the database.
	FieldSrcURL = "src_url"
	// FieldCreatedAt holds the string denoting the created_at field in the database.
	FieldCreatedAt = "created_at"
	// FieldUpdatedAt holds the string denoting the updated_at field in the database.
	FieldUpdatedAt = "updated_at"
	// EdgeUser holds the string denoting the user edge name in mutations.
	EdgeUser = "user"
	// Table holds the table name of the paymentorder in the database.
	Table = "payment_orders"
	// UserTable is the table that holds the user relation/edge.
	UserTable = "payment_orders"
	// UserInverseTable is the table name for the User entity.
	// It exists in this package in order to avoid circular dependency with the "user" package.
	UserInverseTable = "users"
	// UserColumn is the table column denoting the user relation/edge.
	UserColumn = "user_id"
)

// Columns holds all SQL columns for paymentorder fields.
var Columns = []string{
	FieldID,
	FieldUserID,
	FieldUserEmail,
	FieldUserName,
	FieldUserNotes,
	FieldAmount,
	FieldPayAmount,
	FieldFeeRate,
	FieldRechargeCode,
	FieldOutTradeNo,
	FieldPaymentType,
	FieldPaymentTradeNo,
	FieldPayURL,
	FieldQrCode,
	FieldQrCodeImg,
	FieldOrderType,
	FieldPlanID,
	FieldSubscriptionGroupID,
	FieldSubscriptionDays,
	FieldProviderInstanceID,
	FieldProviderKey,
	FieldStatus,
	FieldRefundAmount,
	FieldRefundReason,
	FieldRefundAt,
	FieldForceRefund,
	FieldRefundRequestedAt,
	FieldRefundRequestReason,
	FieldRefundRequestedBy,
	FieldExpiresAt,
	FieldPaidAt,
	FieldCompletedAt,
	FieldFailedAt,
	FieldFailedReason,
	FieldClientIP,
	FieldSrcHost,
	FieldSrcURL,
	FieldCreatedAt,
	FieldUpdatedAt,
}

// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
	for i := range Columns {
		if column == Columns[i] {
			return true
		}
	}
	return false
}

var (
	// UserEmailValidator is a validator for the "user_email" field. It is called by the builders before save.
	UserEmailValidator func(string) error
	// UserNameValidator is a validator for the "user_name" field. It is called by the builders before save.
	UserNameValidator func(string) error
	// DefaultFeeRate holds the default value on creation for the "fee_rate" field.
	DefaultFeeRate float64
	// RechargeCodeValidator is a validator for the "recharge_code" field. It is called by the builders before save.
	RechargeCodeValidator func(string) error
	// DefaultOutTradeNo holds the default value on creation for the "out_trade_no" field.
	DefaultOutTradeNo string
	// OutTradeNoValidator is a validator for the "out_trade_no" field. It is called by the builders before save.
	OutTradeNoValidator func(string) error
	// PaymentTypeValidator is a validator for the "payment_type" field. It is called by the builders before save.
	PaymentTypeValidator func(string) error
	// PaymentTradeNoValidator is a validator for the "payment_trade_no" field. It is called by the builders before save.
	PaymentTradeNoValidator func(string) error
	// DefaultOrderType holds the default value on creation for the "order_type" field.
	DefaultOrderType string
	// OrderTypeValidator is a validator for the "order_type" field. It is called by the builders before save.
	OrderTypeValidator func(string) error
	// ProviderInstanceIDValidator is a validator for the "provider_instance_id" field. It is called by the builders before save.
	ProviderInstanceIDValidator func(string) error
	// ProviderKeyValidator is a validator for the "provider_key" field. It is called by the builders before save.
	ProviderKeyValidator func(string) error
	// DefaultStatus holds the default value on creation for the "status" field.
	DefaultStatus string
	// StatusValidator is a validator for the "status" field. It is called by the builders before save.
	StatusValidator func(string) error
	// DefaultRefundAmount holds the default value on creation for the "refund_amount" field.
	DefaultRefundAmount float64
	// DefaultForceRefund holds the default value on creation for the "force_refund" field.
	DefaultForceRefund bool
	// RefundRequestedByValidator is a validator for the "refund_requested_by" field. It is called by the builders before save.
	RefundRequestedByValidator func(string) error
	// ClientIPValidator is a validator for the "client_ip" field. It is called by the builders before save.
	ClientIPValidator func(string) error
	// SrcHostValidator is a validator for the "src_host" field. It is called by the builders before save.
	SrcHostValidator func(string) error
	// DefaultCreatedAt holds the default value on creation for the "created_at" field.
	DefaultCreatedAt func() time.Time
	// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
	DefaultUpdatedAt func() time.Time
	// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
	UpdateDefaultUpdatedAt func() time.Time
)

// OrderOption defines the ordering options for the PaymentOrder queries.
type OrderOption func(*sql.Selector)

// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldID, opts...).ToFunc()
}

// ByUserID orders the results by the user_id field.
func ByUserID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldUserID, opts...).ToFunc()
}

// ByUserEmail orders the results by the user_email field.
func ByUserEmail(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldUserEmail, opts...).ToFunc()
}

// ByUserName orders the results by the user_name field.
func ByUserName(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldUserName, opts...).ToFunc()
}

// ByUserNotes orders the results by the user_notes field.
func ByUserNotes(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldUserNotes, opts...).ToFunc()
}

// ByAmount orders the results by the amount field.
func ByAmount(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldAmount, opts...).ToFunc()
}

// ByPayAmount orders the results by the pay_amount field.
func ByPayAmount(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldPayAmount, opts...).ToFunc()
}

// ByFeeRate orders the results by the fee_rate field.
func ByFeeRate(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldFeeRate, opts...).ToFunc()
}

// ByRechargeCode orders the results by the recharge_code field.
func ByRechargeCode(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldRechargeCode, opts...).ToFunc()
}

// ByOutTradeNo orders the results by the out_trade_no field.
func ByOutTradeNo(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldOutTradeNo, opts...).ToFunc()
}

// ByPaymentType orders the results by the payment_type field.
func ByPaymentType(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldPaymentType, opts...).ToFunc()
}

// ByPaymentTradeNo orders the results by the payment_trade_no field.
func ByPaymentTradeNo(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldPaymentTradeNo, opts...).ToFunc()
}

// ByPayURL orders the results by the pay_url field.
func ByPayURL(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldPayURL, opts...).ToFunc()
}

// ByQrCode orders the results by the qr_code field.
func ByQrCode(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldQrCode, opts...).ToFunc()
}

// ByQrCodeImg orders the results by the qr_code_img field.
func ByQrCodeImg(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldQrCodeImg, opts...).ToFunc()
}

// ByOrderType orders the results by the order_type field.
func ByOrderType(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldOrderType, opts...).ToFunc()
}

// ByPlanID orders the results by the plan_id field.
func ByPlanID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldPlanID, opts...).ToFunc()
}

// BySubscriptionGroupID orders the results by the subscription_group_id field.
func BySubscriptionGroupID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldSubscriptionGroupID, opts...).ToFunc()
}

// BySubscriptionDays orders the results by the subscription_days field.
func BySubscriptionDays(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldSubscriptionDays, opts...).ToFunc()
}

// ByProviderInstanceID orders the results by the provider_instance_id field.
func ByProviderInstanceID(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldProviderInstanceID, opts...).ToFunc()
}

// ByProviderKey orders the results by the provider_key field.
func ByProviderKey(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldProviderKey, opts...).ToFunc()
}

// ByStatus orders the results by the status field.
func ByStatus(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldStatus, opts...).ToFunc()
}

// ByRefundAmount orders the results by the refund_amount field.
func ByRefundAmount(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldRefundAmount, opts...).ToFunc()
}

// ByRefundReason orders the results by the refund_reason field.
func ByRefundReason(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldRefundReason, opts...).ToFunc()
}

// ByRefundAt orders the results by the refund_at field.
func ByRefundAt(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldRefundAt, opts...).ToFunc()
}

// ByForceRefund orders the results by the force_refund field.
func ByForceRefund(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldForceRefund, opts...).ToFunc()
}

// ByRefundRequestedAt orders the results by the refund_requested_at field.
func ByRefundRequestedAt(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldRefundRequestedAt, opts...).ToFunc()
}

// ByRefundRequestReason orders the results by the refund_request_reason field.
func ByRefundRequestReason(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldRefundRequestReason, opts...).ToFunc()
}

// ByRefundRequestedBy orders the results by the refund_requested_by field.
func ByRefundRequestedBy(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldRefundRequestedBy, opts...).ToFunc()
}

// ByExpiresAt orders the results by the expires_at field.
func ByExpiresAt(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldExpiresAt, opts...).ToFunc()
}

// ByPaidAt orders the results by the paid_at field.
func ByPaidAt(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldPaidAt, opts...).ToFunc()
}

// ByCompletedAt orders the results by the completed_at field.
func ByCompletedAt(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldCompletedAt, opts...).ToFunc()
}

// ByFailedAt orders the results by the failed_at field.
func ByFailedAt(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldFailedAt, opts...).ToFunc()
}

// ByFailedReason orders the results by the failed_reason field.
func ByFailedReason(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldFailedReason, opts...).ToFunc()
}

// ByClientIP orders the results by the client_ip field.
func ByClientIP(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldClientIP, opts...).ToFunc()
}

// BySrcHost orders the results by the src_host field.
func BySrcHost(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldSrcHost, opts...).ToFunc()
}

// BySrcURL orders the results by the src_url field.
func BySrcURL(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldSrcURL, opts...).ToFunc()
}

// ByCreatedAt orders the results by the created_at field.
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
}

// ByUpdatedAt orders the results by the updated_at field.
func ByUpdatedAt(opts ...sql.OrderTermOption) OrderOption {
	return sql.OrderByField(FieldUpdatedAt, opts...).ToFunc()
}

// ByUserField orders the results by user field.
func ByUserField(field string, opts ...sql.OrderTermOption) OrderOption {
	return func(s *sql.Selector) {
		sqlgraph.OrderByNeighborTerms(s, newUserStep(), sql.OrderByField(field, opts...))
	}
}
func newUserStep() *sqlgraph.Step {
	return sqlgraph.NewStep(
		sqlgraph.From(Table, FieldID),
		sqlgraph.To(UserInverseTable, FieldID),
		sqlgraph.Edge(sqlgraph.M2O, true, UserTable, UserColumn),
	)
}
