Files
hi-server/internal/model/order/order.go
T
shanshanzhong147 d2f9289338
Build docker and publish / build (20.15.1) (push) Has been cancelled
Build docker and publish / build (20.15.1) (pull_request) Successful in 8m28s
新功能(#76): 促销系统下单流程集成
- 新增促销规则/规格促销价/使用记录模型与幂等迁移
- EvaluatePromo 支持 new_user/inactive_user/campaign 规则判定
- purchase/preCreate 接入促销判定:命中促销时跳过百分比折扣
- activate 激活后按 order_no 幂等写入 promo_usage
- 订单模型和响应结构新增 promo_rule_id、promo_discount 字段

Co-authored-by: multica-agent <github@multica.ai>
2026-05-26 22:18:44 -07:00

45 lines
2.9 KiB
Go

package order
import "time"
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"`
SubscriptionUserId int64 `gorm:"type:bigint;not null;default:0;comment:Target user ID for subscription (0=same as UserId)"`
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"`
PromoRuleId int64 `gorm:"type:bigint unsigned;not null;default:0;comment:Promo Rule ID"`
PromoDiscount int64 `gorm:"type:bigint;not null;default:0;comment:Promo 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"`
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"`
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"`
AppAccountToken string `gorm:"type:varchar(36);default:null;comment:Apple IAP App Account Token (UUID)"`
ActivationContext string `gorm:"type:text;default:null;comment:Activation context JSON (guest/redemption info for DB fallback)"`
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 OrdersTotal struct {
AmountTotal int64
NewOrderAmount int64
RenewalOrderAmount int64
}
func (Order) TableName() string {
return "order"
}