98 lines
5.3 KiB
Go
98 lines
5.3 KiB
Go
package entity
|
|
|
|
import "time"
|
|
|
|
// BillingOrder 充值订单(付款审核确认后到账)。
|
|
type BillingOrder struct {
|
|
ID int64 `gorm:"primaryKey;autoIncrement" json:"id"`
|
|
OrderNo string `gorm:"size:32;uniqueIndex:uk_order_no" json:"order_no"`
|
|
AccountID int64 `gorm:"index:idx_account_time,priority:1" json:"account_id"`
|
|
Amount float64 `gorm:"type:decimal(12,2)" json:"amount"`
|
|
Count int64 `json:"count"`
|
|
PayType string `gorm:"size:16" json:"pay_type"`
|
|
PayStatus int8 `gorm:"index:idx_pay_status;default:0" json:"pay_status"` // 0待1到账2失败
|
|
Operator string `gorm:"size:64" json:"operator"`
|
|
PaidAt *time.Time `json:"paid_at"`
|
|
Remark string `gorm:"size:255" json:"remark"`
|
|
CreatedAt time.Time `gorm:"autoCreateTime;index:idx_account_time,priority:2" json:"created_at"`
|
|
}
|
|
|
|
func (BillingOrder) TableName() string { return "billing_order" }
|
|
|
|
// BillingConsumeLog 消耗日志(按账号/业务/天)——S2 起为结算域消耗事实源
|
|
// (R2 裁决:stats_user_daily 同粒度双空壳废弃,单一事实源归本表);
|
|
// 日汇总 job T+1 凌晨幂等 UPSERT(明细热窗仅 5 天,月结必须走本表)。
|
|
type BillingConsumeLog struct {
|
|
ID int64 `gorm:"primaryKey;autoIncrement" json:"id"`
|
|
AccountID int64 `gorm:"uniqueIndex:uk_account_date,priority:1" json:"account_id"`
|
|
Business string `gorm:"size:16;uniqueIndex:uk_account_date,priority:2;default:sms" json:"business"`
|
|
StatDate time.Time `gorm:"type:date;uniqueIndex:uk_account_date,priority:3" json:"stat_date"`
|
|
SubmitCount int `json:"submit_count"`
|
|
SuccessCount int `json:"success_count"`
|
|
FailCount int `json:"fail_count"`
|
|
UnknownCount int `json:"unknown_count"` // v20:未知(72h 窗后仍 UNKNOWN)——上家 success_unknown 口径依赖
|
|
FeeTotal float64 `gorm:"type:decimal(12,4)" json:"fee_total"` // 单位=条(=Σ明细 fee,片数口径 Day70)
|
|
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
|
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"` // v20:UPSERT 重跑痕迹
|
|
}
|
|
|
|
func (BillingConsumeLog) TableName() string { return "billing_consume_log" }
|
|
|
|
// SettleCustomer 下家(客户)月度结算单——金额=Σ(日成功条数×生效单价),
|
|
// 出账时刻按价格时间线推导(R1 裁决:明细 Fee 保持片数,不在受理侧金额化)。
|
|
type SettleCustomer struct {
|
|
ID int64 `gorm:"primaryKey;autoIncrement" json:"id"`
|
|
SettleNo string `gorm:"size:32" json:"settle_no"`
|
|
AccountID int64 `gorm:"uniqueIndex:uk_account_period,priority:1" json:"account_id"`
|
|
Period string `gorm:"size:7;uniqueIndex:uk_account_period,priority:2;index:idx_period" json:"period"`
|
|
SuccessCount int64 `json:"success_count"`
|
|
Amount float64 `gorm:"type:decimal(12,2)" json:"amount"` // 应收(元)
|
|
Status int8 `gorm:"default:0" json:"status"` // 0草稿 1已确认 2已结账(已结拒重算)
|
|
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
|
}
|
|
|
|
func (SettleCustomer) TableName() string { return "settle_customer" }
|
|
|
|
// SettleUpstream 上家月度结算单。
|
|
type SettleUpstream struct {
|
|
ID int64 `gorm:"primaryKey;autoIncrement" json:"id"`
|
|
SettleNo string `gorm:"size:32" json:"settle_no"`
|
|
UpstreamID int64 `gorm:"uniqueIndex:uk_upstream_period,priority:1" json:"upstream_id"`
|
|
Period string `gorm:"size:7;uniqueIndex:uk_upstream_period,priority:2;index:idx_period" json:"period"`
|
|
SuccessCount int64 `json:"success_count"`
|
|
Amount float64 `gorm:"type:decimal(12,2)" json:"amount"`
|
|
Status int8 `gorm:"default:0" json:"status"`
|
|
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
|
}
|
|
|
|
func (SettleUpstream) TableName() string { return "settle_upstream" }
|
|
|
|
// SettleRecord 结账记录。
|
|
type SettleRecord struct {
|
|
ID int64 `gorm:"primaryKey;autoIncrement" json:"id"`
|
|
SettleNo string `gorm:"size:32;index:idx_settle_no" json:"settle_no"`
|
|
Direction int8 `gorm:"default:1" json:"direction"` // 1下家 2上家
|
|
Amount float64 `gorm:"type:decimal(12,2)" json:"amount"`
|
|
PayType string `gorm:"size:16" json:"pay_type"`
|
|
Operator string `gorm:"size:64" json:"operator"`
|
|
SettledAt time.Time `json:"settled_at"`
|
|
Remark string `gorm:"size:255" json:"remark"`
|
|
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
|
}
|
|
|
|
func (SettleRecord) TableName() string { return "settle_record" }
|
|
|
|
// SettleLadder 阶梯价档位(S2·R5:出账时按月成功总量落档,档内单价覆写
|
|
// 时间线价;tier_from=档位下限(含),0=首档,上一档与下一档的 from 界定区间;
|
|
// owner_type=account(下家应收)/upstream(上家成本)两类锚点各自配档)。
|
|
type SettleLadder struct {
|
|
ID int64 `gorm:"primaryKey;autoIncrement" json:"id"`
|
|
OwnerType string `gorm:"size:8;uniqueIndex:uk_owner_tier,priority:1" json:"owner_type"` // account/upstream
|
|
OwnerID int64 `gorm:"uniqueIndex:uk_owner_tier,priority:2" json:"owner_id"`
|
|
TierFrom int64 `gorm:"uniqueIndex:uk_owner_tier,priority:3" json:"tier_from"` // 档位下限(含,条)
|
|
Price float64 `gorm:"type:decimal(10,4)" json:"price"` // 该档单价(元/条)
|
|
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
|
}
|
|
|
|
func (SettleLadder) TableName() string { return "settle_ladder" }
|