66 lines
1.7 KiB
Go
66 lines
1.7 KiB
Go
package ledger
|
|
|
|
const (
|
|
// AssetCoin 是用户送礼消费资产。
|
|
AssetCoin = "COIN"
|
|
// AssetGiftPoint 是主播礼物积分,不能直接消费或提现。
|
|
AssetGiftPoint = "GIFT_POINT"
|
|
// AssetDiamond 是后续兑换用资产,当前只在余额模型中保留。
|
|
AssetDiamond = "DIAMOND"
|
|
// AssetUSDBalance 是主播可提现美元余额,单位由后续提现策略固定。
|
|
AssetUSDBalance = "USD_BALANCE"
|
|
)
|
|
|
|
// DebitGiftCommand 是 room-service 送礼扣费的账务命令。
|
|
type DebitGiftCommand struct {
|
|
CommandID string
|
|
RoomID string
|
|
SenderUserID int64
|
|
TargetUserID int64
|
|
GiftID string
|
|
GiftCount int32
|
|
PriceVersion string
|
|
}
|
|
|
|
// Receipt 是账务命令落账后的稳定回执。
|
|
type Receipt struct {
|
|
BillingReceiptID string
|
|
TransactionID string
|
|
CoinSpent int64
|
|
GiftPointAdded int64
|
|
HeatValue int64
|
|
PriceVersion string
|
|
BalanceAfter int64
|
|
}
|
|
|
|
// AssetBalance 是账户当前可用/冻结余额投影。
|
|
type AssetBalance struct {
|
|
UserID int64
|
|
AssetType string
|
|
AvailableAmount int64
|
|
FrozenAmount int64
|
|
Version int64
|
|
UpdatedAtMs int64
|
|
}
|
|
|
|
// AdminCreditAssetCommand 是后台手动入账的最小审计命令。
|
|
type AdminCreditAssetCommand struct {
|
|
CommandID string
|
|
TargetUserID int64
|
|
AssetType string
|
|
Amount int64
|
|
OperatorUserID int64
|
|
Reason string
|
|
EvidenceRef string
|
|
}
|
|
|
|
// ValidAssetType 限定账本允许落账的资产类型,避免写入任意字符串资产。
|
|
func ValidAssetType(assetType string) bool {
|
|
switch assetType {
|
|
case AssetCoin, AssetGiftPoint, AssetDiamond, AssetUSDBalance:
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|