You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
99 lines
5.9 KiB
99 lines
5.9 KiB
package model
|
|
|
|
import "time"
|
|
|
|
// TrafficOrder 云媒体流量订单
|
|
type TrafficOrder struct {
|
|
ID int64 `gorm:"primaryKey;column:id;type:BIGINT;not null" json:"id"`
|
|
UserID int64 `gorm:"column:user_id;type:BIGINT;not null" json:"userId"`
|
|
PackageID int64 `gorm:"column:package_id;type:BIGINT" json:"packageId"`
|
|
PackageCode string `gorm:"column:package_code;type:VARCHAR(64)" json:"packageCode"`
|
|
AmountGb int `gorm:"column:amount_gb;type:INT;not null" json:"amountGb"`
|
|
AmountBytes int64 `gorm:"column:amount_bytes;type:BIGINT;not null" json:"amountBytes"`
|
|
UnitPrice float64 `gorm:"column:unit_price;type:DECIMAL(6,2)" json:"unitPrice"`
|
|
TotalPrice float64 `gorm:"column:total_price;type:DECIMAL(10,2)" json:"totalPrice"`
|
|
PayStatus string `gorm:"column:pay_status;type:VARCHAR(16);default:unpaid" json:"payStatus"`
|
|
CreditStatus string `gorm:"column:credit_status;type:VARCHAR(16);default:pending" json:"creditStatus"`
|
|
CreditLedgerID int64 `gorm:"column:credit_ledger_id;type:BIGINT" json:"creditLedgerId"`
|
|
PaymentIdempotencyKey string `gorm:"column:payment_idempotency_key;type:VARCHAR(128);uniqueIndex:uk_traffic_order_payment_idem" json:"-"`
|
|
PaidBy int64 `gorm:"column:paid_by;type:BIGINT" json:"paidBy"`
|
|
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"`
|
|
PaidAt *time.Time `gorm:"column:paid_at" json:"paidAt"`
|
|
}
|
|
|
|
func (TrafficOrder) TableName() string {
|
|
return "traffic_order"
|
|
}
|
|
|
|
// TrafficUsageLog 云媒体消费流水(账本,不可变)
|
|
type TrafficUsageLog struct {
|
|
ID int64 `gorm:"primaryKey;column:id;type:BIGINT;not null" json:"id"`
|
|
UserID int64 `gorm:"column:user_id;type:BIGINT;not null" json:"userId"`
|
|
SourceType string `gorm:"column:source_type;type:VARCHAR(16)" json:"sourceType"` // live / replay / download
|
|
SourceID int64 `gorm:"column:source_id;type:BIGINT" json:"sourceId"`
|
|
BytesUsed int64 `gorm:"column:bytes_used;type:BIGINT" json:"bytesUsed"`
|
|
BalanceBefore int64 `gorm:"column:balance_before;type:BIGINT" json:"balanceBefore"`
|
|
BalanceAfter int64 `gorm:"column:balance_after;type:BIGINT" json:"balanceAfter"`
|
|
IdempotencyKey string `gorm:"column:idempotency_key;type:VARCHAR(160);not null;uniqueIndex:uk_traffic_usage_idempotency" json:"-"`
|
|
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"`
|
|
}
|
|
|
|
func (TrafficUsageLog) TableName() string {
|
|
return "traffic_usage_log"
|
|
}
|
|
|
|
// SimCard SIM 卡
|
|
type SimCard struct {
|
|
ID int64 `gorm:"primaryKey;column:id;type:BIGINT;not null" json:"id"`
|
|
UserID int64 `gorm:"column:user_id;type:BIGINT;not null" json:"userId"`
|
|
DockID string `gorm:"column:dock_id;type:VARCHAR(64)" json:"dockId"`
|
|
Carrier string `gorm:"column:carrier;type:VARCHAR(16)" json:"carrier"` // 移动/联通/电信
|
|
Phone string `gorm:"column:phone;type:VARCHAR(16)" json:"phone"`
|
|
Iccid string `gorm:"column:iccid;type:VARCHAR(32)" json:"iccid"` // 权威字段
|
|
PlanGb int `gorm:"column:plan_gb;type:INT" json:"planGb"`
|
|
UsedGb float64 `gorm:"column:used_gb;type:DECIMAL(10,4);default:0" json:"usedGb"`
|
|
ExpiredAt *time.Time `gorm:"column:expired_at;type:DATE" json:"expiredAt"`
|
|
Status string `gorm:"column:status;type:VARCHAR(16);default:active" json:"status"` // active / expired
|
|
CarrierStatus string `gorm:"column:carrier_status;type:VARCHAR(16);default:normal" json:"carrierStatus"` // normal / suspended / arrears / cancelled
|
|
LastSyncAt *time.Time `gorm:"column:last_sync_at" json:"lastSyncAt"`
|
|
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"`
|
|
UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"`
|
|
}
|
|
|
|
func (SimCard) TableName() string {
|
|
return "sim_card"
|
|
}
|
|
|
|
// SimRechargeLog SIM 卡充值记录
|
|
type SimRechargeLog struct {
|
|
ID int64 `gorm:"primaryKey;column:id;type:BIGINT;not null" json:"id"`
|
|
SimCardID int64 `gorm:"column:sim_card_id;type:BIGINT;not null" json:"simCardId"`
|
|
UserID int64 `gorm:"column:user_id;type:BIGINT;not null" json:"userId"`
|
|
AmountGb int `gorm:"column:amount_gb;type:INT;not null" json:"amountGb"`
|
|
UnitPrice float64 `gorm:"column:unit_price;type:DECIMAL(6,2)" json:"unitPrice"`
|
|
TotalPrice float64 `gorm:"column:total_price;type:DECIMAL(10,2)" json:"totalPrice"`
|
|
PayStatus string `gorm:"column:pay_status;type:VARCHAR(16);default:unpaid" json:"payStatus"`
|
|
RechargeStatus string `gorm:"column:recharge_status;type:VARCHAR(16);default:pending" json:"rechargeStatus"` // pending / success / failed
|
|
RechargeMsg string `gorm:"column:recharge_msg;type:VARCHAR(256);default:''" json:"rechargeMsg"`
|
|
IdempotentKey string `gorm:"column:idempotent_key;type:VARCHAR(64);not null;uniqueIndex:uk_recharge_idem" json:"idempotentKey"`
|
|
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"`
|
|
}
|
|
|
|
func (SimRechargeLog) TableName() string {
|
|
return "sim_recharge_log"
|
|
}
|
|
|
|
// SimUsageRecord SIM 卡用量快照
|
|
type SimUsageRecord struct {
|
|
ID int64 `gorm:"primaryKey;column:id;type:BIGINT;not null" json:"id"`
|
|
SimCardID int64 `gorm:"column:sim_card_id;type:BIGINT;not null;index:idx_record_sim" json:"simCardId"`
|
|
PlanGb int `gorm:"column:plan_gb;type:INT" json:"planGb"`
|
|
UsedGb float64 `gorm:"column:used_gb;type:DECIMAL(10,4)" json:"usedGb"`
|
|
RemainGb float64 `gorm:"column:remain_gb;type:DECIMAL(10,4)" json:"remainGb"`
|
|
CarrierStatus string `gorm:"column:carrier_status;type:VARCHAR(16)" json:"carrierStatus"`
|
|
SyncedAt time.Time `gorm:"column:synced_at;index:idx_record_sim" json:"syncedAt"`
|
|
}
|
|
|
|
func (SimUsageRecord) TableName() string {
|
|
return "sim_usage_record"
|
|
}
|
|
|