// // WalletModels.swift // Crush // // Created by Leon on 2025/9/10. // import Foundation // MARK: - VIP // 顶层结构 struct MemberDetailOutput: Codable { var userMemberInfo: UserSubscription? var memberPrivList: [MemberPrivDict]? } // 用户会员信息 struct UserSubscription: Codable { var id: Int? /// Need to be "APPLE" var platform: String? var userId: Int? var subscriptionId: String? var productId: String? var memberType: MemberType? var priceType: PriceType? var purchaseToken: String? var refundTimeMs: Int? /// 1758289340000 var purchaseTime: Int? var expTime: Int? var autoRenewStatus: Bool? var status: String? var createTime: Int? var editTime: Int? var ip: String? /// 是否已经提醒过。 var remind: Bool? func getVIPValid() -> Bool{ if let expTimeTimestamp = expTime{ if Date().timeStamp < expTimeTimestamp{ return true } } return false } } // 会员类型 enum MemberType: String, Codable { case vip = "VIP" } // 价格周期 enum PriceType: String, Codable { case month = "SUB_MONTH" case season = "SUB_SEASON" case year = "SUB_YEAR" } // 会员特权 struct MemberPrivDict: Codable { var id: Int? /// 会员特权标题 var title: String? /// 会员特权描述 var desc: String? var img: String? var sort: Int? var isDelete: Int? var createTime: Int? /// 会员特权code , ADD_CRUSH_COIN、ADD_CREATE_AI等~ var code: String? } // MARK: - Charge struct CoinRechargePreOrderResponse: Codable{ var tradeNo: String? } // MARK: - Bill struct BillListRequest: Codable{ var page: RequestPageData? var type: String? var startTime: Int? var endTime: Int? } struct BillListResponse:Codable{ /// 总收入 var incomeTotal: Int? /// 总支出 var outcomeTotal: Int? var pageList: ResponseContentPageData? } /// 流水 struct BillListInfo: Codable{ var tradeNo: String? var desUid: Int? var status: String? var time: Int? var amount: Int? var item: String? var nickname: String? var period: String? var headImg: String? var custId: String? var bizNum: String? var inOrOut: InOrOut? var periodAmount: Int? var id: Int? /// Buff var payment: String? var platform: String? /// 后续可能添加类型, 可能解析失败 var bizType: String? var message: String? var giftId: Int? var toWithdrawableIncomeTime: Int? /// BALANCE. AWAITING_INCOME var buffType: BuffType? /// Jsonstring: like { "aiId":.xxx, "giftId" : 1, "num": 12} var extend: String? func getExtendObj()-> BillListExtentObj?{ if let extentString = extend { return CodableHelper.decode(BillListExtentObj.self, from: extentString) } return nil } /* { "tradeNo" : "12025091718400465000014", "desUid" : null, "status" : "WITHDRAW_SUCCESS", "time" : 1758105605000, "amount" : 7000, "item" : "Create AI Image", "nickname" : null, "period" : null, "headImg" : null, "custId" : null, "bizNum" : "2025091718400464367010", "inOrOut" : "OUT", "periodAmount" : null, "id" : 161, "payment" : "Buff", "platform" : "Balance", "bizType" : "CREATE_AI_IMAGE", "message" : null, "giftId" : null, "toWithdrawableIncomeTime" : null, "buffType" : "BALANCE", "extend" : null } */ } struct BillListExtentObj: Codable{ var aiId: Int? var giftId: Int? var num: Int? } // MARK: - Enums enum BuffClassify: String, Codable { case bCharge = "B_CHARGE" case bPurchase = "B_PURCHASE" case bRefund = "B_REFUND" case bTip = "B_TIP" case bGift = "B_GIFT" case bEpalSubscription = "B_EPAL_SUBSCRIPTION" case bLuckyDraw = "B_LUCKY_DRAW" case bStore = "B_STORE" case bEpalPrize = "B_EPAL_PRIZE" case bOther = "B_OTHER" case iWithdraw = "I_WITHDRAW" case iServiceIncome = "I_SERVICE_INCOME" case iRefund = "I_REFUND" case iTipIncome = "I_TIP_INCOME" case iGiftIncome = "I_GIFT_INCOME" case iSubscriptionIncome = "I_SUBSCRIPTION_INCOME" case iEpalReward = "I_EPAL_REWARD" case iStoreReward = "I_STORE_REWARD" case iOther = "I_OTHER" } enum BizType: String, Codable { case game = "GAME" case charge = "CHARGE" case sub = "SUB" case withdraw = "WITHDRAW" case refund = "REFUND" case frozenBalance = "FROZEN_BALANCE" case unfrozenBalance = "UNFROZEN_BALANCE" case createAIImage = "CREATE_AI_IMAGE" case textModel = "TEXT_MODEL" case chatAssistant = "CHAT_ASSISTANT" case sendVoice = "SEND_VOICE" case voiceCall = "VOICE_CALL" case imageUnlock = "IMAGE_UNLOCK" case heartbeatPurchase = "HEARTBEAT_PURCHASE" case gift = "GIFT" case unlockAdmirers = "UNLOCK_ADMIRERS" case newUserGift = "NEW_USER_GIFT" case vipBuffGift = "VIP_BUFF_GIFT" case subscribeMember = "SUBSCRIBE_MEMBER" case SIGN_IN_GIFT = "SIGN_IN_GIFT" } enum InOrOut: String, Codable { case `in` = "IN" case out = "OUT" } enum BuffType: String, Codable { case balance = "BALANCE" case withdrawableIncome = "WITHDRAWABLE_INCOME" case awaitingIncome = "AWAITING_INCOME" case refund = "REFUND" case frozenIncome = "FROZEN_INCOME" case frozenBalance = "FROZEN_BALANCE" } enum BillStatus: String, Codable { case created = "CREATED" case rollBack = "ROLL_BACK" case settled = "SETTLED" } enum WithdrawStatus: String, Codable { case inReview = "IN_REVIEW" case reviewFail = "REVIEW_FAIL" case withdrawIng = "WITHDRAW_ING" case withdrawFail = "WITHDRAW_FAIL" case withdrawSuccess = "WITHDRAW_SUCCESS" case withdrawFailBack = "WITHDRAW_FAIL_BACK" }