order

package
v1.15.19 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2026 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DailyBreakdown added in v1.15.16

type DailyBreakdown struct {
	// Name is the plan name or the payment platform, depending on the group.
	Name string
	// Id is the grouped plan id; zero for a payment-method group and for
	// orders that carry no plan, such as balance top-ups.
	Id     int64
	Orders int64
	Amount int64
}

DailyBreakdown is one row of a settled-order breakdown, grouped by plan or by payment method for the daily report.

type DailyReport added in v1.15.16

type DailyReport struct {
	Date     time.Time
	Orders   int64
	Amount   int64
	ByPlan   []DailyBreakdown
	ByMethod []DailyBreakdown
}

DailyReport totals the orders settled on one day, alongside the plan and payment-method breakdowns.

type Details

type Details struct {
	Id              int64                `gorm:"primaryKey"`
	ParentId        int64                `gorm:"type:bigint;default:null;comment:Parent Order Id"`
	SubOrders       []*Order             `gorm:"foreignKey:ParentId;references:Id"`
	UserId          int64                `gorm:"type:bigint;not null;default:0;comment:User Id"`
	OrderNo         string               `gorm:"type:varchar(255);not null;default:'';unique;comment:Order No"`
	Type            uint8                `gorm:"type:tinyint(1);not null;default:1;comment:Order Type: 1: Subscribe, 2: Renewal, 3: ResetTraffic, 4: Recharge"`
	Quantity        int64                `gorm:"type:bigint;not null;default:1;comment:Quantity"`
	Price           int64                `gorm:"type:int;not null;default:0;comment:Original price"`
	Amount          int64                `gorm:"type:int;not null;default:0;comment:Order Amount"`
	Discount        int64                `gorm:"type:int;not null;default:0;comment:Order Discount"`
	Coupon          string               `gorm:"type:varchar(255);default:null;comment:Coupon"`
	CouponDiscount  int64                `gorm:"type:int;not null;default:0;comment:Coupon Discount"`
	PaymentId       int64                `gorm:"type:bigint;not null;default:0;comment:Payment Id"`
	Payment         *payment.Payment     `gorm:"foreignKey:PaymentId;references:Id"`
	Method          string               `gorm:"type:varchar(255);not null;default:'';comment:Payment Method"`
	FeeAmount       int64                `gorm:"type:int;not null;default:0;comment:Fee Amount"`
	PaymentAmount   int64                `gorm:"type:bigint;not null;default:0;comment:Amount requested by payment gateway in minor units"`
	PaymentCurrency string               `gorm:"type:varchar(16);not null;default:'';comment:Payment gateway currency"`
	TradeNo         string               `gorm:"type:varchar(255);default:null;comment:Trade No"`
	GiftAmount      int64                `gorm:"type:int;not null;default:0;comment:User Gift Amount"`
	Commission      int64                `gorm:"type:int;not null;default:0;comment:Order Commission"`
	Status          uint8                `gorm:"type:tinyint(1);not null;default:1;comment:Order Status: 1: Pending, 2: Paid, 3: Failed"`
	SubscribeId     int64                `gorm:"type:bigint;not null;default:0;comment:Subscribe Id"`
	SubscribeToken  string               `gorm:"type:varchar(255);default:null;comment:Renewal Subscribe Token"`
	Subscribe       *subscribe.Subscribe `gorm:"foreignKey:SubscribeId;references:Id"`
	IsNew           bool                 `gorm:"type:tinyint(1);not null;default:0;comment:Is New Order"`
	CreatedAt       time.Time            `gorm:"<-:create;comment:Create Time"`
	UpdatedAt       time.Time            `gorm:"comment:Update Time"`
}

type Event

type Event struct {
	ID          int64      `gorm:"primaryKey;autoIncrement"`
	OrderID     int64      `gorm:"type:bigint;not null;index:idx_order_event_order_id_id,priority:1"`
	OrderNo     string     `gorm:"type:varchar(255);not null;index:idx_order_event_order_no_id,priority:1"`
	EventType   string     `gorm:"type:varchar(64);not null"`
	Payload     string     `gorm:"type:text;not null"`
	CreatedAt   time.Time  `gorm:"<-:create"`
	PublishedAt *time.Time `gorm:"index:idx_order_event_published_at_id,priority:1"`
}

Event is the durable order event outbox. Redis only distributes these records with low latency; reconnecting clients always recover from this table.

func (Event) TableName

func (Event) TableName() string

type Order

type Order struct {
	Id                     int64     `gorm:"primaryKey"`
	ParentId               int64     `gorm:"type:bigint;default:null;comment:Parent Order Id"`
	UserId                 int64     `gorm:"type:bigint;not null;default:0;comment:User Id"`
	OrderNo                string    `gorm:"type:varchar(255);not null;default:'';unique;comment:Order No"`
	Type                   uint8     `gorm:"type:tinyint(1);not null;default:1;comment:Order Type: 1: Subscribe, 2: Renewal, 3: ResetTraffic, 4: Recharge"`
	Quantity               int64     `gorm:"type:bigint;not null;default:1;comment:Quantity"`
	Price                  int64     `gorm:"type:int;not null;default:0;comment:Original price"`
	Amount                 int64     `gorm:"type:int;not null;default:0;comment:Order Amount"`
	GiftAmount             int64     `gorm:"type:int;not null;default:0;comment:User Gift Amount"`
	Discount               int64     `gorm:"type:int;not null;default:0;comment:Discount Amount"`
	Coupon                 string    `gorm:"type:varchar(255);default:null;comment:Coupon"`
	CouponDiscount         int64     `gorm:"type:int;not null;default:0;comment:Coupon Discount Amount"`
	CouponReserved         bool      `gorm:"type:tinyint(1);not null;default:0;comment:Coupon usage reserved while order is pending"`
	Commission             int64     `gorm:"type:int;not null;default:0;comment:Order Commission"`
	PaymentId              int64     `gorm:"type:bigint;not null;default:0;comment:Payment Method Id"`
	Method                 string    `gorm:"type:varchar(255);not null;default:'';comment:Payment Method"`
	FeeAmount              int64     `gorm:"type:int;not null;default:0;comment:Fee Amount"`
	PaymentAmount          int64     `gorm:"type:bigint;not null;default:0;comment:Amount requested by payment gateway in minor units"`
	PaymentCurrency        string    `gorm:"type:varchar(16);not null;default:'';comment:Payment gateway currency"`
	TradeNo                string    `gorm:"type:varchar(255);default:null;comment:Trade No"`
	Status                 uint8     `gorm:"type:tinyint(1);not null;default:1;comment:Order Status: 1: Pending, 2: Paid, 3:Close, 4: Failed, 5:Finished;"`
	SubscribeId            int64     `gorm:"type:bigint;not null;default:0;comment:Subscribe Id"`
	SubscribeToken         string    `gorm:"type:varchar(255);default:null;comment:Renewal Subscribe Token"`
	GuestAuthType          string    `gorm:"type:varchar(255);not null;default:'';comment:Guest auth type before account activation"`
	GuestIdentifier        string    `gorm:"type:varchar(255);not null;default:'';comment:Guest auth identifier before account activation"`
	GuestPasswordHash      string    `gorm:"type:varchar(255);not null;default:'';comment:Guest password hash before account activation"`
	GuestInviteCode        string    `gorm:"type:varchar(255);not null;default:'';comment:Guest invite code before account activation"`
	GuestCheckoutTokenHash string    `gorm:"type:char(64);not null;default:'';comment:Hash of guest checkout capability"`
	StateVersion           int64     `gorm:"type:bigint;not null;default:0;comment:Monotonic version for order state transitions"`
	IdempotencyKey         string    `gorm:"type:varchar(128);uniqueIndex;default:null;comment:V2 create idempotency key"`
	IdempotencyHash        string    `gorm:"type:char(64);default:null;comment:Stable hash of the V2 create request"`
	IsNew                  bool      `gorm:"type:tinyint(1);not null;default:0;comment:Is New Order"`
	CreatedAt              time.Time `gorm:"<-:create;comment:Create Time"`
	UpdatedAt              time.Time `gorm:"comment:Update Time"`
}

func (Order) TableName

func (Order) TableName() string

type OrdersTotal

type OrdersTotal struct {
	AmountTotal        int64
	NewOrderAmount     int64
	RenewalOrderAmount int64
}

type OrdersTotalWithDate

type OrdersTotalWithDate struct {
	Date               string
	AmountTotal        int64
	NewOrderAmount     int64
	RenewalOrderAmount int64
}

type UserCounts

type UserCounts struct {
	NewUsers     int64 `gorm:"column:new_users"`
	RenewalUsers int64 `gorm:"column:renewal_users"`
}

UserCounts User counts for new and renewal users

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL