2026-05-29 19:56:14 +08:00

913 lines
26 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package ledger
import "strings"
const (
// AssetCoin 是用户送礼消费资产。
AssetCoin = "COIN"
// AssetCoinSellerCoin 是币商专用金币资产,只能通过币商转账兑换成玩家普通 COIN。
AssetCoinSellerCoin = "COIN_SELLER_COIN"
// AssetGiftPoint 是主播礼物积分,不能直接消费或提现。
AssetGiftPoint = "GIFT_POINT"
// AssetDiamond 是后续兑换用资产,当前只在余额模型中保留。
AssetDiamond = "DIAMOND"
// AssetHostPeriodDiamond 是主播工资周期钻石投影,只参与工资等级结算,不进入通用钱包余额。
AssetHostPeriodDiamond = "HOST_PERIOD_DIAMOND"
// AssetUSDBalance 是主播可提现美元余额,单位由后续提现策略固定。
AssetUSDBalance = "USD_BALANCE"
// StockTypeUSDTPurchase 表示币商线下 USDT 进货后发放专用金币库存。
StockTypeUSDTPurchase = "usdt_purchase"
// StockTypeCoinCompensation 表示平台人工补偿币商专用金币库存,不计入进货金额。
StockTypeCoinCompensation = "coin_compensation"
// PaidCurrencyUSDT 是首版币商进货支持的唯一线下付款币种。
PaidCurrencyUSDT = "USDT"
// RechargeProductStatusActive 表示内购商品已上架,可进入 App 充值页。
RechargeProductStatusActive = "active"
// RechargeProductStatusDisabled 表示内购商品未上架,仅后台可见。
RechargeProductStatusDisabled = "disabled"
// RechargeProductPlatformAndroid 表示 Google Play 侧内购商品。
RechargeProductPlatformAndroid = "android"
// RechargeProductPlatformIOS 表示 Apple IAP 侧内购商品。
RechargeProductPlatformIOS = "ios"
// RechargeChannelGoogle 是 android 平台内购渠道标识。
RechargeChannelGoogle = "google"
// RechargeChannelApple 是 iOS 平台内购渠道标识。
RechargeChannelApple = "apple"
// PaymentProviderGooglePlay 是 Google Play 一次性内购支付渠道。
PaymentProviderGooglePlay = "google_play"
// PaymentStatusCredited 表示支付已完成校验并入账。
PaymentStatusCredited = "credited"
// PaymentConsumeStatePending 表示已入账但 Google consume 尚未确认完成。
PaymentConsumeStatePending = "consume_pending"
// PaymentConsumeStateConsumed 表示 Google consume 已确认完成。
PaymentConsumeStateConsumed = "consumed"
// GooglePurchaseStatePurchased 是 Google Play 已支付完成状态。
GooglePurchaseStatePurchased = "PURCHASED"
// WithdrawalStatusPending 表示主播美元余额提现已提交,等待后台人工审核和线下转账。
WithdrawalStatusPending = "pending"
// HostSalarySettlementModeDaily 表示主播工资按日结算等级增量。
HostSalarySettlementModeDaily = "daily"
// HostSalarySettlementModeHalfMonth 表示主播工资按半月周期结算等级增量。
HostSalarySettlementModeHalfMonth = "half_month"
// HostSalarySettlementTypeMonthEnd 表示月底清算等级增量、剩余钻石折美元和周期关闭。
HostSalarySettlementTypeMonthEnd = "month_end"
// HostSalarySettlementTriggerAutomatic 表示由 cron-service 自动扫描结算的政策。
HostSalarySettlementTriggerAutomatic = "automatic"
// HostSalarySettlementTriggerManual 表示只允许后台工资结算页人工触发的政策。
HostSalarySettlementTriggerManual = "manual"
// VipStatusActive 表示 VIP 配置或用户会员状态当前有效。
VipStatusActive = "active"
// VipStatusDisabled 表示 VIP 配置被后台停用。
VipStatusDisabled = "disabled"
// VipGrantSourcePurchase 表示用户主动购买或续费 VIP。
VipGrantSourcePurchase = "vip_purchase"
// VipGrantSourceActivity 表示活动系统赠送 VIP。
VipGrantSourceActivity = "activity_grant"
// VipGrantSourceAdmin 表示后台人工赠送 VIP。
VipGrantSourceAdmin = "admin_grant"
// GameOpDebit 表示游戏平台下注、局内道具等扣金币行为。
GameOpDebit = "debit"
// GameOpCredit 表示游戏平台中奖、派奖等加金币行为。
GameOpCredit = "credit"
// GameOpRefund 表示游戏平台扣款失败或取消后的退款入账。
GameOpRefund = "refund"
// GameOpReverse 表示平台冲正;首版按扣回用户 COIN 处理。
GameOpReverse = "reverse"
// RedPacketTypeNormal 表示发出后立即可抢的普通红包。
RedPacketTypeNormal = "normal"
// RedPacketTypeDelayed 表示发出后按后台秒数延迟打开的红包。
RedPacketTypeDelayed = "delayed"
// RedPacketStatusWaitingOpen 表示延迟红包已扣款但未到打开时间。
RedPacketStatusWaitingOpen = "waiting_open"
// RedPacketStatusActive 表示红包可领取。
RedPacketStatusActive = "active"
// RedPacketStatusFinished 表示红包所有份额已领取。
RedPacketStatusFinished = "finished"
// RedPacketStatusRefunded 表示红包过期未领取金额已退回。
RedPacketStatusRefunded = "refunded"
// RedPacketClaimStatusClaimed 表示红包份额领取成功。
RedPacketClaimStatusClaimed = "claimed"
// RedPacketExpireSeconds 固定房内红包 24 小时过期退款。
RedPacketExpireSeconds int32 = 24 * 60 * 60
)
// DebitGiftCommand 是 room-service 送礼扣费的账务命令。
type DebitGiftCommand struct {
AppCode string
CommandID string
RoomID string
SenderUserID int64
TargetUserID int64
GiftID string
GiftCount int32
PriceVersion string
RegionID int64
// TargetIsHost 只能由 gateway 根据 user-service active host profile 注入,客户端输入不可信。
TargetIsHost bool
// TargetHostRegionID 是主播身份所属区域;工资政策按该区域匹配,不能用房间可见区域替代。
TargetHostRegionID int64
// TargetAgencyOwnerUserID 是送礼瞬间主播上级代理的收款用户快照;结算按快照发放,避免月底组织变化错账。
TargetAgencyOwnerUserID int64
}
// Receipt 是账务命令落账后的稳定回执。
type Receipt struct {
BillingReceiptID string
TransactionID string
CoinSpent int64
ChargeAssetType string
ChargeAmount int64
GiftPointAdded int64
HeatValue int64
GiftTypeCode string
PriceVersion string
BalanceAfter int64
// HostPeriodDiamondAdded 是本次送礼写入主播工资周期账户的钻石数;非主播恒为 0。
HostPeriodDiamondAdded int64
// HostPeriodCycleKey 是工资周期键,当前按 UTC 月生成,后续结算按此键定位周期账户。
HostPeriodCycleKey string
}
// HostSalarySettlementBatchCommand 是 cron 或测试触发结算批处理的最小输入。
type HostSalarySettlementBatchCommand struct {
AppCode string
RunID string
WorkerID string
BatchSize int
SettlementType string
// TriggerMode 决定本次批处理读取自动政策还是手动政策;空值按 automatic 处理,兼容已有定时任务。
TriggerMode string
CycleKey string
NowMs int64
}
// HostSalarySettlementBatchResult 汇总一个结算批次的扫描和入账结果。
type HostSalarySettlementBatchResult struct {
ClaimedCount int
ProcessedCount int
SuccessCount int
FailureCount int
HasMore bool
}
// HostSalaryPolicy 是 wallet-service 结算读取的后台政策运行快照。
type HostSalaryPolicy struct {
PolicyID uint64
Name string
RegionID int64
Status string
SettlementMode string
SettlementTriggerMode string
GiftCoinToDiamondRatio string
ResidualDiamondToUSDRate string
EffectiveFromMs int64
EffectiveToMs int64
Levels []HostSalaryPolicyLevel
}
// HostSalaryPolicyLevel 使用累计值表达工资和奖励,结算时只发放“当前累计 - 已发累计”的差额。
type HostSalaryPolicyLevel struct {
LevelNo int
RequiredDiamonds int64
HostSalaryUSDMinor int64
HostCoinReward int64
AgencySalaryUSDMinor int64
Status string
SortOrder int
}
// CoinSellerTransferCommand 是币商给玩家转普通金币的账务命令。
type CoinSellerTransferCommand struct {
AppCode string
CommandID string
SellerUserID int64
TargetUserID int64
SellerRegionID int64
TargetRegionID int64
Amount int64
Reason string
}
// CoinSellerTransferReceipt 是币商转账完成后的稳定回执。
type CoinSellerTransferReceipt struct {
TransactionID string
SellerBalanceAfter int64
TargetBalanceAfter int64
Amount int64
RechargeSequence int64
RechargeUSDMinor int64
RechargeCurrencyCode string
RechargePolicyID int64
RechargePolicyVersion string
RechargePolicyCoinAmount int64
RechargePolicyUSDMinorUnit int64
}
// CoinSellerStockCreditCommand 是后台给币商专用金币库存入账的最小账务命令。
type CoinSellerStockCreditCommand struct {
AppCode string
CommandID string
SellerUserID int64
StockType string
CoinAmount int64
PaidCurrencyCode string
PaidAmountMicro int64
PaymentRef string
EvidenceRef string
OperatorUserID int64
Reason string
}
// CoinSellerStockCreditReceipt 是币商库存入账成功后的稳定回执。
type CoinSellerStockCreditReceipt struct {
TransactionID string
SellerUserID int64
StockType string
CoinAmount int64
PaidCurrencyCode string
PaidAmountMicro int64
CountsAsSellerRecharge bool
BalanceAfter int64
CreatedAtMS int64
}
// RechargeBill 是充值账单的只读投影;充值事实由 wallet_recharge_records 保存。
type RechargeBill struct {
AppCode string
TransactionID string
CommandID string
RechargeType string
Status string
ExternalRef string
UserID int64
SellerUserID int64
SellerRegionID int64
TargetRegionID int64
PolicyID int64
PolicyVersion string
CurrencyCode string
CoinAmount int64
USDMinorAmount int64
ExchangeCoinAmount int64
ExchangeUSDMinorAmount int64
CreatedAtMS int64
}
// ListRechargeBillsQuery 是后台查询所有充值渠道账单的筛选条件。
type ListRechargeBillsQuery struct {
AppCode string
UserID int64
SellerUserID int64
RegionID int64
RechargeType string
Status string
Keyword string
StartAtMS int64
EndAtMS int64
Page int32
PageSize int32
}
// WalletFeatureFlags 是 App 钱包入口的开关投影;首版由 wallet-service 固定返回,后续可迁移到配置表。
type WalletFeatureFlags struct {
RechargeEnabled bool
DiamondExchangeEnabled bool
WithdrawEnabled bool
}
// WalletOverview 是我的页和钱包首页共同使用的轻量摘要。
type WalletOverview struct {
Balances []AssetBalance
FeatureFlags WalletFeatureFlags
}
// WalletValueSummary 是我的页钱包卡片的最小余额投影。
type WalletValueSummary struct {
CoinAmount int64
UpdatedAtMS int64
}
// GiftWallResource 是礼物墙展示所需的资源快照字段,避免读取接口再依赖资源配置实时状态。
type GiftWallResource struct {
AppCode string
ResourceID int64
ResourceCode string
ResourceType string
Name string
Status string
Grantable bool
GrantStrategy string
WalletAssetType string
WalletAssetAmount int64
UsageScopes []string
AssetURL string
PreviewURL string
AnimationURL string
MetadataJSON string
SortOrder int32
CreatedAtMS int64
UpdatedAtMS int64
}
// GiftWallItem 是当前用户收到礼物的按 gift_id 聚合投影。
type GiftWallItem struct {
GiftID string
GiftName string
ResourceID int64
Resource GiftWallResource
ResourceSnapshotJSON string
GiftTypeCode string
PresentationJSON string
GiftCount int64
TotalValue int64
TotalCoinValue int64
TotalDiamondValue int64
TotalGiftPoint int64
TotalHeatValue int64
ChargeAssetType string
LastPriceVersion string
FirstReceivedAtMS int64
LastReceivedAtMS int64
SortOrder int32
}
// UserGiftWall 汇总礼物墙首屏需要的全量统计和按礼物类型聚合列表。
type UserGiftWall struct {
Items []GiftWallItem
GiftKindCount int64
GiftTotalCount int64
TotalValue int64
TotalCoinValue int64
TotalDiamondValue int64
TotalGiftPoint int64
TotalHeatValue int64
}
// RechargeProduct 是用户充值页读取的充值档位。
type RechargeProduct struct {
AppCode string
ProductID int64
ProductCode string
ProductName string
Description string
Platform string
Channel string
CurrencyCode string
AmountMicro int64
AmountMinor int64
CoinAmount int64
PolicyVersion string
Enabled bool
Status string
SortOrder int32
RegionIDs []int64
ResourceAssetType string
CreatedByUserID int64
UpdatedByUserID int64
CreatedAtMS int64
UpdatedAtMS int64
}
// ListRechargeProductsQuery 是后台内购商品配置列表的筛选条件。
type ListRechargeProductsQuery struct {
AppCode string
Status string
Platform string
RegionID int64
Keyword string
Page int32
PageSize int32
}
// RechargeProductCommand 是后台创建或更新内购商品配置的完整事实输入。
type RechargeProductCommand struct {
AppCode string
ProductID int64
AmountMicro int64
CoinAmount int64
ProductName string
Description string
Platform string
RegionIDs []int64
Enabled bool
OperatorUserID int64
}
// GooglePaymentCommand 是 App 完成 Google Play 支付后提交给后端确认和入账的命令。
type GooglePaymentCommand struct {
AppCode string
CommandID string
UserID int64
RegionID int64
ProductID int64
ProductCode string
PackageName string
PurchaseToken string
OrderID string
PurchaseTimeMS int64
}
// GooglePlayPurchase 是 Google Play Developer API 返回的一次性商品购买状态快照。
type GooglePlayPurchase struct {
PackageName string
ProductID string
OrderID string
PurchaseState string
ConsumptionState string
AcknowledgementState string
PurchaseCompletionTime string
RawJSON string
}
// GooglePaymentReceipt 是 Google 支付确认接口返回给 App 的稳定入账回执。
type GooglePaymentReceipt struct {
PaymentOrderID string
TransactionID string
Status string
ProductID int64
ProductCode string
CoinAmount int64
Balance AssetBalance
IdempotentReplay bool
ConsumeState string
}
// DiamondExchangeRule 是钻石兑换金币或余额的固定规则投影。
type DiamondExchangeRule struct {
ExchangeType string
FromAssetType string
ToAssetType string
FromAmount int64
ToAmount int64
Enabled bool
}
// WalletTransaction 是钱包流水页按用户分录查询的投影。
type WalletTransaction struct {
EntryID int64
TransactionID string
BizType string
AssetType string
AvailableDelta int64
FrozenDelta int64
AvailableAfter int64
FrozenAfter int64
CounterpartyUserID int64
RoomID string
CreatedAtMS int64
}
// ListWalletTransactionsQuery 描述 App 钱包流水分页条件。
type ListWalletTransactionsQuery struct {
AppCode string
UserID int64
AssetType string
Page int32
PageSize int32
}
// WithdrawalCommand 是主播余额提现申请命令。人工审核和线下转账不在 App 主链路完成。
type WithdrawalCommand struct {
AppCode string
CommandID string
UserID int64
Amount int64
PayoutAccount string
Reason string
}
// WithdrawalRequest 是提现申请事实。
type WithdrawalRequest struct {
WithdrawalID string
UserID int64
AssetType string
Amount int64
Status string
PayoutAccount string
Reason string
CreatedAtMS int64
UpdatedAtMS int64
}
// VipRewardItem 是 VIP 资源组权益的轻量展示投影。
type VipRewardItem struct {
ResourceID int64
ResourceCode string
ResourceType string
Name string
Quantity int64
ExpiresAtMS int64
}
// VipLevel 是可购买 VIP 等级配置。
type VipLevel struct {
Level int32
Name string
Status string
PriceCoin int64
DurationMS int64
RewardResourceGroupID int64
RequiredRechargeCoinAmount int64
UserRechargeCoinAmount int64
RechargeGateRequired bool
PurchaseLockedReason string
RewardItems []VipRewardItem
CanPurchase bool
SortOrder int32
CreatedAtMS int64
UpdatedAtMS int64
}
// UserVip 是用户当前会员状态。是否有效以 ExpiresAtMS 和当前时间判断。
type UserVip struct {
UserID int64
Level int32
Name string
Active bool
StartedAtMS int64
ExpiresAtMS int64
UpdatedAtMS int64
}
// PurchaseVipCommand 是 App 购买或升级 VIP 的账务命令。
type PurchaseVipCommand struct {
AppCode string
CommandID string
UserID int64
Level int32
}
// PurchaseVipReceipt 是购买 VIP 成功后的稳定回执。
type PurchaseVipReceipt struct {
OrderID string
TransactionID string
Vip UserVip
CoinSpent int64
CoinBalanceAfter int64
RewardItems []VipRewardItem
}
// GrantVipCommand 是活动或后台发放 VIP 的统一入口命令。
type GrantVipCommand struct {
AppCode string
CommandID string
TargetUserID int64
Level int32
GrantSource string
OperatorUserID int64
Reason string
}
// GrantVipReceipt 是赠送 VIP 成功后的稳定回执。
type GrantVipReceipt struct {
TransactionID string
Vip UserVip
RewardItems []VipRewardItem
}
// AdminVipLevelCommand 是后台保存 VIP 等级配置的完整事实输入。
type AdminVipLevelCommand struct {
Level int32
Name string
Status string
PriceCoin int64
DurationMS int64
RewardResourceGroupID int64
RequiredRechargeCoinAmount int64
SortOrder int32
}
// AssetBalance 是账户当前可用/冻结余额投影。
type AssetBalance struct {
AppCode string
UserID int64
AssetType string
AvailableAmount int64
FrozenAmount int64
Version int64
UpdatedAtMs int64
}
// AdminCreditAssetCommand 是后台手动调账的最小审计命令Amount 为正数入账、负数扣账。
type AdminCreditAssetCommand struct {
AppCode string
CommandID string
TargetUserID int64
AssetType string
Amount int64
OperatorUserID int64
Reason string
EvidenceRef string
}
// TaskRewardCommand 是 activity-service 任务领奖的 COIN 入账命令。
type TaskRewardCommand struct {
AppCode string
CommandID string
TargetUserID int64
Amount int64
TaskType string
TaskID string
CycleKey string
Reason string
}
// TaskRewardReceipt 是任务奖励入账后的稳定回执。
type TaskRewardReceipt struct {
TransactionID string
Balance AssetBalance
Amount int64
GrantedAtMS int64
}
// LuckyGiftRewardCommand 是 activity-service 用抽奖 draw_id 发起的 COIN 入账命令。
type LuckyGiftRewardCommand struct {
AppCode string
CommandID string
TargetUserID int64
Amount int64
DrawID string
RoomID string
GiftID string
PoolID string
Reason string
}
// LuckyGiftRewardReceipt 是幸运礼物返奖入账后的稳定回执。
type LuckyGiftRewardReceipt struct {
TransactionID string
Balance AssetBalance
Amount int64
GrantedAtMS int64
}
// GameCoinChangeCommand 是 game-service 对钱包发起的游戏专用金币改账命令。
type GameCoinChangeCommand struct {
AppCode string
CommandID string
UserID int64
PlatformCode string
GameID string
ProviderOrderID string
ProviderRoundID string
OpType string
CoinAmount int64
RoomID string
RequestHash string
}
// GameCoinChangeReceipt 是游戏改账成功或幂等重放后的稳定回执。
type GameCoinChangeReceipt struct {
TransactionID string
BalanceAfter int64
IdempotentReplay bool
}
// RedPacketConfig 是后台红包配置的服务端事实,发送路径必须由 wallet-service 强校验。
type RedPacketConfig struct {
AppCode string
Enabled bool
CountTiers []int32
AmountTiers []int64
DelayedOpenSeconds int32
ExpireSeconds int32
DailySendLimit int32
UpdatedByAdminID int64
RuleURL string
CreatedAtMS int64
UpdatedAtMS int64
}
// RedPacket 是红包资金池和状态的只读投影。
type RedPacket struct {
AppCode string
PacketID string
CommandID string
SenderUserID int64
RoomID string
RegionID int64
PacketType string
TotalAmount int64
PacketCount int32
RemainingAmount int64
RemainingCount int32
Status string
OpenAtMS int64
ExpiresAtMS int64
CreatedAtMS int64
UpdatedAtMS int64
ClaimedByViewer bool
ViewerClaimAmount int64
Claims []RedPacketClaim
RefundAmount int64
RefundStatus string
RefundedAtMS int64
}
// RedPacketClaim 是单个用户抢红包的到账事实。
type RedPacketClaim struct {
AppCode string
ClaimID string
CommandID string
PacketID string
UserID int64
Amount int64
WalletTransactionID string
Status string
FailureReason string
CreatedAtMS int64
UpdatedAtMS int64
}
type RedPacketCreateCommand struct {
AppCode string
CommandID string
SenderUserID int64
RoomID string
RegionID int64
PacketType string
TotalAmount int64
PacketCount int32
}
type RedPacketCreateReceipt struct {
Packet RedPacket
BalanceAfter int64
}
type RedPacketClaimCommand struct {
AppCode string
CommandID string
PacketID string
UserID int64
}
type RedPacketClaimReceipt struct {
Claim RedPacketClaim
Packet RedPacket
BalanceAfter int64
}
type RedPacketRefundReceipt struct {
Packet RedPacket
RefundedAmount int64
}
type RedPacketQuery struct {
AppCode string
RoomID string
SenderUserID int64
RegionID int64
PacketType string
Status string
ViewerUserID int64
StartAtMS int64
EndAtMS int64
Page int32
PageSize int32
}
type RedPacketExpireResult struct {
ExpiredCount int32
RefundedAmount int64
}
// ValidAssetType 限定账本允许落账的资产类型,避免写入任意字符串资产。
func ValidAssetType(assetType string) bool {
switch assetType {
case AssetCoin, AssetCoinSellerCoin, AssetGiftPoint, AssetDiamond, AssetUSDBalance:
return true
default:
return false
}
}
func NormalizeGiftChargeAssetType(assetType string) string {
switch strings.ToUpper(strings.TrimSpace(assetType)) {
case AssetDiamond:
return AssetDiamond
default:
return AssetCoin
}
}
func NormalizeVipGrantSource(source string) string {
switch strings.ToLower(strings.TrimSpace(source)) {
case VipGrantSourcePurchase:
return VipGrantSourcePurchase
case VipGrantSourceActivity:
return VipGrantSourceActivity
case VipGrantSourceAdmin:
return VipGrantSourceAdmin
default:
return ""
}
}
func ValidGiftChargeAssetType(assetType string) bool {
switch strings.ToUpper(strings.TrimSpace(assetType)) {
case AssetCoin, AssetDiamond:
return true
default:
return false
}
}
func NormalizeCoinSellerStockType(stockType string) string {
switch strings.ToLower(strings.TrimSpace(stockType)) {
case StockTypeUSDTPurchase:
return StockTypeUSDTPurchase
case StockTypeCoinCompensation:
return StockTypeCoinCompensation
default:
return ""
}
}
func NormalizeRechargeProductStatus(status string) string {
switch strings.ToLower(strings.TrimSpace(status)) {
case RechargeProductStatusActive:
return RechargeProductStatusActive
case RechargeProductStatusDisabled:
return RechargeProductStatusDisabled
default:
return ""
}
}
func NormalizeRechargeProductPlatform(platform string) string {
switch strings.ToLower(strings.TrimSpace(platform)) {
case RechargeProductPlatformAndroid:
return RechargeProductPlatformAndroid
case RechargeProductPlatformIOS:
return RechargeProductPlatformIOS
default:
return ""
}
}
func RechargeChannelForPlatform(platform string) string {
switch NormalizeRechargeProductPlatform(platform) {
case RechargeProductPlatformAndroid:
return RechargeChannelGoogle
case RechargeProductPlatformIOS:
return RechargeChannelApple
default:
return ""
}
}
func NormalizeGameOpType(opType string) string {
switch strings.ToLower(strings.TrimSpace(opType)) {
case GameOpDebit:
return GameOpDebit
case GameOpCredit:
return GameOpCredit
case GameOpRefund:
return GameOpRefund
case GameOpReverse:
return GameOpReverse
default:
return ""
}
}
func NormalizeRedPacketType(packetType string) string {
switch strings.ToUpper(strings.TrimSpace(packetType)) {
case "IMMEDIATE":
return RedPacketTypeNormal
case "DELAYED":
return RedPacketTypeDelayed
}
switch strings.ToLower(strings.TrimSpace(packetType)) {
case RedPacketTypeNormal:
return RedPacketTypeNormal
case RedPacketTypeDelayed:
return RedPacketTypeDelayed
default:
return ""
}
}
func NormalizeRedPacketStatus(status string) string {
switch strings.ToLower(strings.TrimSpace(status)) {
case RedPacketStatusWaitingOpen:
return RedPacketStatusWaitingOpen
case RedPacketStatusActive:
return RedPacketStatusActive
case RedPacketStatusFinished:
return RedPacketStatusFinished
case RedPacketStatusRefunded:
return RedPacketStatusRefunded
default:
return ""
}
}