135 lines
2.8 KiB
Go
135 lines
2.8 KiB
Go
package resource
|
|
|
|
import (
|
|
"hyapp/services/wallet-service/internal/domain/ledger"
|
|
"strings"
|
|
)
|
|
|
|
type ResourceShopItem struct {
|
|
AppCode string
|
|
ShopItemID int64
|
|
ResourceID int64
|
|
Resource Resource
|
|
Status string
|
|
DurationDays int32
|
|
PriceType string
|
|
CoinPrice int64
|
|
EffectiveFromMS int64
|
|
EffectiveToMS int64
|
|
SortOrder int32
|
|
CreatedByUserID int64
|
|
UpdatedByUserID int64
|
|
CreatedAtMS int64
|
|
UpdatedAtMS int64
|
|
}
|
|
|
|
type ResourceShopPurchaseOrder struct {
|
|
AppCode string
|
|
OrderID string
|
|
CommandID string
|
|
UserID int64
|
|
ShopItemID int64
|
|
ResourceID int64
|
|
Resource Resource
|
|
ResourceSnapshotJSON string
|
|
DurationDays int32
|
|
PriceCoin int64
|
|
Status string
|
|
WalletTransactionID string
|
|
ResourceGrantID string
|
|
EntitlementID string
|
|
CreatedAtMS int64
|
|
UpdatedAtMS int64
|
|
}
|
|
|
|
type ResourceShopItemInput struct {
|
|
ShopItemID int64
|
|
ResourceID int64
|
|
Status string
|
|
DurationDays int32
|
|
EffectiveFromMS int64
|
|
EffectiveToMS int64
|
|
SortOrder int32
|
|
}
|
|
|
|
type ListResourceShopItemsQuery struct {
|
|
AppCode string
|
|
ResourceType string
|
|
Status string
|
|
Keyword string
|
|
Page int32
|
|
PageSize int32
|
|
ActiveOnly bool
|
|
}
|
|
|
|
type ListResourceShopPurchaseOrdersQuery struct {
|
|
AppCode string
|
|
UserID int64
|
|
ResourceType string
|
|
Status string
|
|
Keyword string
|
|
Page int32
|
|
PageSize int32
|
|
}
|
|
|
|
type ResourceShopItemsCommand struct {
|
|
AppCode string
|
|
Items []ResourceShopItemInput
|
|
OperatorUserID int64
|
|
}
|
|
|
|
type ResourceShopItemStatusCommand struct {
|
|
AppCode string
|
|
ShopItemID int64
|
|
Status string
|
|
OperatorUserID int64
|
|
}
|
|
|
|
type ResourceShopPurchaseCommand struct {
|
|
AppCode string
|
|
CommandID string
|
|
UserID int64
|
|
ShopItemID int64
|
|
}
|
|
|
|
type ResourceShopPurchaseReceipt struct {
|
|
OrderID string
|
|
TransactionID string
|
|
ShopItem ResourceShopItem
|
|
Resource UserResourceEntitlement
|
|
Balance ledger.AssetBalance
|
|
CoinSpent int64
|
|
GrantID string
|
|
}
|
|
|
|
func ResourceTypeSellableInShop(value string) bool {
|
|
switch NormalizeResourceType(value) {
|
|
case TypeAvatarFrame, TypeProfileCard, TypeVehicle, TypeChatBubble, TypeBadge, TypeMicSeatIcon, TypeMicSeatAnimation:
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
func ValidShopDurationDays(value int32) bool {
|
|
switch value {
|
|
case ShopDurationOneDay, ShopDurationThreeDays, ShopDurationSevenDays:
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|
|
|
|
func NormalizePriceType(value string) string {
|
|
return strings.ToLower(strings.TrimSpace(value))
|
|
}
|
|
|
|
func ValidPriceType(value string) bool {
|
|
switch NormalizePriceType(value) {
|
|
case PriceTypeCoin, PriceTypeFree:
|
|
return true
|
|
default:
|
|
return false
|
|
}
|
|
}
|