AccountRightModel.swift 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. //
  2. // KMAccountRightModel.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by User-Tangchao on 2024/10/24.
  6. //
  7. import Cocoa
  8. class AccountTrialModel: NSObject {
  9. // 试用状态 0为试用已过期 1为试用中
  10. var status: Int = 0
  11. // 已试用天数
  12. var triedDay: Int = 0
  13. // 试用产品序列码
  14. var product_code: String?
  15. convenience init(dict: [String : Any]) {
  16. self.init()
  17. self.status = dict["status"] as? Int ?? 0
  18. self.triedDay = dict["triedDay"] as? Int ?? 0
  19. self.product_code = dict["product_code"] as? String
  20. }
  21. }
  22. class AccountRightInfoModel: NSObject {
  23. // 权益产品名称
  24. var name: String?
  25. // 是否订阅:0=非订阅,1=订阅中,2=已取消订阅
  26. var automatically_subscribe: Int = 0
  27. // 失效时间戳 -1为永久有效
  28. var failure_time: Int = 0
  29. // 页面显示失效时间
  30. var failure_time_text: String?
  31. // 产品类型:1='1-Month Plan',2='1-Year Plan',3='Lifetime Plan'
  32. var license_id: Int = 0
  33. // 权益状态:1=有效,2=无效
  34. var status: Int = 0
  35. // sku id
  36. var sku_id: Int = 0
  37. // 总设备数量
  38. var total_num: Int = 0
  39. // 剩余设备数量
  40. var surplus_num: Int = 0
  41. // 购买链接
  42. var buy_url: String?
  43. // 产品序列码
  44. var product_code: String?
  45. convenience init(dict: [String : Any]) {
  46. self.init()
  47. self.name = dict["name"] as? String
  48. self.automatically_subscribe = dict["automatically_subscribe"] as? Int ?? 0
  49. self.failure_time = dict["failure_time"] as? Int ?? 0
  50. self.failure_time_text = dict["failure_time_text"] as? String
  51. self.license_id = dict["license_id"] as? Int ?? 0
  52. self.status = dict["status"] as? Int ?? 0
  53. self.sku_id = dict["sku_id"] as? Int ?? 0
  54. self.total_num = dict["total_num"] as? Int ?? 0
  55. self.surplus_num = dict["surplus_num"] as? Int ?? 0
  56. self.buy_url = dict["buy_url"] as? String
  57. self.product_code = dict["product_code"] as? String
  58. }
  59. }
  60. class AccountRightModel: NSObject {
  61. // 当前设备是否为Vip 0为否 1为是(如果用户只买了win的产品,mac端登录就为0)
  62. var isVip: Int = 0
  63. // 当前是否有AI权益 0为无 1为有
  64. var hasAiPermissions: Int = 0
  65. // AI购买链接
  66. var aiBuyUrl: String = ""
  67. // 有效权益记录
  68. var rightsInterestsData: [AccountRightInfoModel] = []
  69. // 过期权益记录
  70. var expiredBenefits: [AccountRightInfoModel] = []
  71. // 更多权益产品购买数据
  72. var moreBenefits: [ProductListModel] = []
  73. var trialData: AccountTrialModel?
  74. var memberInfo: AccountInfoModel?
  75. convenience init(dict: [String : Any]) {
  76. self.init()
  77. self.isVip = dict["isVip"] as? Int ?? 0
  78. self.hasAiPermissions = dict["hasAiPermissions"] as? Int ?? 0
  79. self.aiBuyUrl = dict["aiBuyUrl"] as? String ?? ""
  80. if let info = dict["trialData"] as? [String : Any] {
  81. self.trialData = AccountTrialModel(dict: info)
  82. }
  83. if let info = dict["memberInfo"] as? [String : Any] {
  84. self.memberInfo = AccountInfoModel(dict: info)
  85. }
  86. if let array = dict["rightsInterestsData"] as? [Any] {
  87. var datas: [AccountRightInfoModel] = []
  88. for data in array {
  89. guard let dict = data as? [String : Any] else {
  90. continue
  91. }
  92. let model = AccountRightInfoModel(dict: dict)
  93. datas.append(model)
  94. }
  95. self.rightsInterestsData = datas
  96. }
  97. if let array = dict["expiredBenefits"] as? [Any] {
  98. var datas: [AccountRightInfoModel] = []
  99. for data in array {
  100. guard let dict = data as? [String : Any] else {
  101. continue
  102. }
  103. let model = AccountRightInfoModel(dict: dict)
  104. datas.append(model)
  105. }
  106. self.expiredBenefits = datas
  107. }
  108. if let array = dict["moreBenefits"] as? [Any] {
  109. var datas: [ProductListModel] = []
  110. for data in array {
  111. guard let dict = data as? [String : Any] else {
  112. continue
  113. }
  114. let model = ProductListModel(dict: dict)
  115. datas.append(model)
  116. }
  117. self.moreBenefits = datas
  118. }
  119. }
  120. }