Files
quyun-v2/backend/database/models/orders.gen.go

82 lines
6.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Code generated by go.ipao.vip/gen. DO NOT EDIT.
// Code generated by go.ipao.vip/gen. DO NOT EDIT.
// Code generated by go.ipao.vip/gen. DO NOT EDIT.
package models
import (
"context"
"time"
"quyun/v2/database/fields"
"quyun/v2/pkg/consts"
"go.ipao.vip/gen"
"go.ipao.vip/gen/types"
)
const TableNameOrder = "orders"
// Order mapped from table <orders>
type Order struct {
ID int64 `gorm:"column:id;type:bigint;primaryKey;autoIncrement:true" json:"id"`
TenantID int64 `gorm:"column:tenant_id;type:bigint;not null" json:"tenant_id"`
UserID int64 `gorm:"column:user_id;type:bigint;not null" json:"user_id"`
Type consts.OrderType `gorm:"column:type;type:character varying(32);default:content_purchase" json:"type"`
Status consts.OrderStatus `gorm:"column:status;type:character varying(32);default:created" json:"status"`
Currency consts.Currency `gorm:"column:currency;type:character varying(16);default:CNY" json:"currency"`
AmountOriginal int64 `gorm:"column:amount_original;type:bigint;not null" json:"amount_original"`
AmountDiscount int64 `gorm:"column:amount_discount;type:bigint;not null" json:"amount_discount"`
AmountPaid int64 `gorm:"column:amount_paid;type:bigint;not null" json:"amount_paid"`
Snapshot types.JSONType[fields.OrdersSnapshot] `gorm:"column:snapshot;type:jsonb;default:{}" json:"snapshot"`
IdempotencyKey string `gorm:"column:idempotency_key;type:character varying(128);not null" json:"idempotency_key"`
PaidAt time.Time `gorm:"column:paid_at;type:timestamp with time zone" json:"paid_at"`
RefundedAt time.Time `gorm:"column:refunded_at;type:timestamp with time zone" json:"refunded_at"`
RefundForced bool `gorm:"column:refund_forced;type:boolean" json:"refund_forced"`
RefundOperatorUserID int64 `gorm:"column:refund_operator_user_id;type:bigint" json:"refund_operator_user_id"`
RefundReason string `gorm:"column:refund_reason;type:character varying(255)" json:"refund_reason"`
CreatedAt time.Time `gorm:"column:created_at;type:timestamp with time zone;default:now()" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;type:timestamp with time zone;default:now()" json:"updated_at"`
CouponID int64 `gorm:"column:coupon_id;type:bigint;comment:使用的优惠券ID (0表示未使用)" json:"coupon_id"` // 使用的优惠券ID (0表示未使用)
IsFlagged bool `gorm:"column:is_flagged;type:boolean;not null;comment:问题订单标记;用途:运营标注需复核订单;默认 false。" json:"is_flagged"` // 问题订单标记;用途:运营标注需复核订单;默认 false。
FlagReason string `gorm:"column:flag_reason;type:character varying(255);not null;comment:问题标记原因;用途:说明问题点与风险;默认空字符串。" json:"flag_reason"` // 问题标记原因;用途:说明问题点与风险;默认空字符串。
FlaggedBy int64 `gorm:"column:flagged_by;type:bigint;not null;comment:问题标记操作者ID用途审计追踪默认 0 表示未标记。" json:"flagged_by"` // 问题标记操作者ID用途审计追踪默认 0 表示未标记。
FlaggedAt time.Time `gorm:"column:flagged_at;type:timestamp with time zone;comment:问题标记时间;用途:记录标记时效;未标记为空。" json:"flagged_at"` // 问题标记时间;用途:记录标记时效;未标记为空。
IsReconciled bool `gorm:"column:is_reconciled;type:boolean;not null;comment:对账状态;用途:标识是否完成人工对账;默认 false。" json:"is_reconciled"` // 对账状态;用途:标识是否完成人工对账;默认 false。
ReconcileNote string `gorm:"column:reconcile_note;type:character varying(255);not null;comment:对账说明;用途:记录对账备注与结论;默认空字符串。" json:"reconcile_note"` // 对账说明;用途:记录对账备注与结论;默认空字符串。
ReconciledBy int64 `gorm:"column:reconciled_by;type:bigint;not null;comment:对账操作者ID用途审计追踪默认 0 表示未对账。" json:"reconciled_by"` // 对账操作者ID用途审计追踪默认 0 表示未对账。
ReconciledAt time.Time `gorm:"column:reconciled_at;type:timestamp with time zone;comment:对账时间;用途:记录完成对账时间;未对账为空。" json:"reconciled_at"` // 对账时间;用途:记录完成对账时间;未对账为空。
}
// Quick operations without importing query package
// Update applies changed fields to the database using the default DB.
func (m *Order) Update(ctx context.Context) (gen.ResultInfo, error) {
return Q.Order.WithContext(ctx).Updates(m)
}
// Save upserts the model using the default DB.
func (m *Order) Save(ctx context.Context) error { return Q.Order.WithContext(ctx).Save(m) }
// Create inserts the model using the default DB.
func (m *Order) Create(ctx context.Context) error { return Q.Order.WithContext(ctx).Create(m) }
// Delete removes the row represented by the model using the default DB.
func (m *Order) Delete(ctx context.Context) (gen.ResultInfo, error) {
return Q.Order.WithContext(ctx).Delete(m)
}
// ForceDelete permanently deletes the row (ignores soft delete) using the default DB.
func (m *Order) ForceDelete(ctx context.Context) (gen.ResultInfo, error) {
return Q.Order.WithContext(ctx).Unscoped().Delete(m)
}
// Reload reloads the model from database by its primary key and overwrites current fields.
func (m *Order) Reload(ctx context.Context) error {
fresh, err := Q.Order.WithContext(ctx).GetByID(m.ID)
if err != nil {
return err
}
*m = *fresh
return nil
}