AccountRightModel.swift 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. convenience init(dict: [String : Any]) {
  75. self.init()
  76. self.isVip = dict["isVip"] as? Int ?? 0
  77. self.hasAiPermissions = dict["hasAiPermissions"] as? Int ?? 0
  78. self.aiBuyUrl = dict["aiBuyUrl"] as? String ?? ""
  79. if let info = dict["trialData"] as? [String : Any] {
  80. self.trialData = AccountTrialModel(dict: info)
  81. }
  82. if let array = dict["rightsInterestsData"] as? [Any] {
  83. var datas: [AccountRightInfoModel] = []
  84. for data in array {
  85. guard let dict = data as? [String : Any] else {
  86. continue
  87. }
  88. let model = AccountRightInfoModel(dict: dict)
  89. datas.append(model)
  90. }
  91. self.rightsInterestsData = datas
  92. }
  93. if let array = dict["expiredBenefits"] as? [Any] {
  94. var datas: [AccountRightInfoModel] = []
  95. for data in array {
  96. guard let dict = data as? [String : Any] else {
  97. continue
  98. }
  99. let model = AccountRightInfoModel(dict: dict)
  100. datas.append(model)
  101. }
  102. self.expiredBenefits = datas
  103. }
  104. if let array = dict["moreBenefits"] as? [Any] {
  105. var datas: [ProductListModel] = []
  106. for data in array {
  107. guard let dict = data as? [String : Any] else {
  108. continue
  109. }
  110. let model = ProductListModel(dict: dict)
  111. datas.append(model)
  112. }
  113. self.moreBenefits = datas
  114. }
  115. }
  116. }