AccountRightModel.swift 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. // 有效权益记录
  64. var rightsInterestsData: [AccountRightInfoModel] = []
  65. // 过期权益记录
  66. var expiredBenefits: [AccountRightInfoModel] = []
  67. // 更多权益产品购买数据
  68. var moreBenefits: [ProductListModel] = []
  69. var trialData: AccountTrialModel?
  70. convenience init(dict: [String : Any]) {
  71. self.init()
  72. self.isVip = dict["isVip"] as? Int ?? 0
  73. if let info = dict["trialData"] as? [String : Any] {
  74. self.trialData = AccountTrialModel(dict: info)
  75. }
  76. if let array = dict["rightsInterestsData"] as? [Any] {
  77. var datas: [AccountRightInfoModel] = []
  78. for data in array {
  79. guard let dict = data as? [String : Any] else {
  80. continue
  81. }
  82. let model = AccountRightInfoModel(dict: dict)
  83. datas.append(model)
  84. }
  85. self.rightsInterestsData = datas
  86. }
  87. if let array = dict["expiredBenefits"] as? [Any] {
  88. var datas: [AccountRightInfoModel] = []
  89. for data in array {
  90. guard let dict = data as? [String : Any] else {
  91. continue
  92. }
  93. let model = AccountRightInfoModel(dict: dict)
  94. datas.append(model)
  95. }
  96. self.expiredBenefits = datas
  97. }
  98. if let array = dict["moreBenefits"] as? [Any] {
  99. var datas: [ProductListModel] = []
  100. for data in array {
  101. guard let dict = data as? [String : Any] else {
  102. continue
  103. }
  104. let model = ProductListModel(dict: dict)
  105. datas.append(model)
  106. }
  107. self.moreBenefits = datas
  108. }
  109. }
  110. }