소스 검색

【会员系统】DMG 所有可购买商品解析数据结构修改&Crash兼容

zenghong 1 주 전
부모
커밋
38b6211c24

+ 17 - 17
PDF Office/PDF Master/MemberCenter/Model/KMMemberCenterManager.swift

@@ -858,7 +858,7 @@ class KMMemberCenterManager: NSObject {
             for dict1 in result_Array {
                 var id = ""
                 var productName = ""
-                var price = ""
+                var price = NSNumber(value: 0.0)
                 var maxDeviceNum = 0
                 var levels = ""
                 var platforms = ""
@@ -866,18 +866,18 @@ class KMMemberCenterManager: NSObject {
                 var paymentModel = 0
                 var cycle = 0
                 var code = ""
-                var cnyPrice = ""
-                if let token = dict1["id"] { id = token as! String }
-                if let token = dict1["productName"] { productName = token as! String }
-                if let token = dict1["price"] { price = token as! String }
-                if let token = dict1["maxDeviceNum"] { maxDeviceNum = token as! Int }
-                if let token = dict1["levels"] { levels = token as! String }
-                if let token = dict1["platforms"] { platforms = token as! String }
-                if let token = dict1["productLineId"] { productLineId = token as! Int }
-                if let token = dict1["paymentModel"] { paymentModel = token as! Int }
-                if let token = dict1["cycle"] { cycle = token as! Int }
-                if let token = dict1["code"] { code = token as! String }
-                if let token = dict1["cnyPrice"] { cnyPrice = token as! String }
+                var cnyPrice = NSNumber(value: 0.0)
+                if let token = dict1["id"] { id = token as? String ?? id }
+                if let token = dict1["productName"] { productName = token as? String ?? productName }
+                if let token = dict1["price"] { price = token as? NSNumber ?? price }
+                if let token = dict1["maxDeviceNum"] { maxDeviceNum = token as? Int ?? maxDeviceNum }
+                if let token = dict1["levels"] { levels = token as? String ?? levels }
+                if let token = dict1["platforms"] { platforms = token as? String ?? platforms }
+                if let token = dict1["productLineId"] { productLineId = token as? Int ?? productLineId }
+                if let token = dict1["paymentModel"] { paymentModel = token as? Int ?? paymentModel }
+                if let token = dict1["cycle"] { cycle = token as? Int ?? cycle }
+                if let token = dict1["code"] { code = token as? String ?? code  }
+                if let token = dict1["cnyPrice"] { cnyPrice = token as? NSNumber ?? cnyPrice }
                 let products = KMListingProductsModel(id: id, productName: productName, price: price, maxDeviceNum: maxDeviceNum, levels: levels, platforms: platforms, productLineId: productLineId, paymentModel: paymentModel, cycle: cycle, code: code, cnyPrice: cnyPrice)
                 results.append(products)
             }
@@ -926,7 +926,7 @@ class KMMemberCenterManager: NSObject {
             for dict1 in result_Array {
                 var id = ""
                 var productName = ""
-                var price = ""
+                var price = NSNumber(value: 0.0)
                 var maxDeviceNum = 0
                 var levels = ""
                 var platforms = ""
@@ -934,10 +934,10 @@ class KMMemberCenterManager: NSObject {
                 var paymentModel = 0
                 var cycle = 0
                 var code = ""
-                var cnyPrice = ""
+                var cnyPrice = NSNumber(value: 0.0)
                 if let token = dict1["id"] { id = token as! String }
                 if let token = dict1["productName"] { productName = token as! String }
-                if let token = dict1["price"] { price = token as! String }
+                if let token = dict1["price"] { price = token as! NSNumber }
                 if let token = dict1["maxDeviceNum"] { maxDeviceNum = token as! Int }
                 if let token = dict1["levels"] { levels = token as! String }
                 if let token = dict1["platforms"] { platforms = token as! String }
@@ -945,7 +945,7 @@ class KMMemberCenterManager: NSObject {
                 if let token = dict1["paymentModel"] { paymentModel = token as! Int }
                 if let token = dict1["cycle"] { cycle = token as! Int }
                 if let token = dict1["code"] { code = token as! String }
-                if let token = dict1["cnyPrice"] { cnyPrice = token as! String }
+                if let token = dict1["cnyPrice"] { cnyPrice = token as! NSNumber }
                 let products = KMListingProductsModel(id: id, productName: productName, price: price, maxDeviceNum: maxDeviceNum, levels: levels, platforms: platforms, productLineId: productLineId, paymentModel: paymentModel, cycle: cycle, code: code, cnyPrice: cnyPrice)
                 results.append(products)
             }

+ 3 - 3
PDF Office/PDF Master/MemberCenter/Model/KMMemberProductResult.swift

@@ -84,7 +84,7 @@ class KMMemberProductResult: NSObject {
 class KMListingProductsModel: NSObject {
     var id              : String = "" // 【可选】id
     var productName     : String = "" // 【可选】名称
-    var price           : String = "" // 【可选】价格
+    var price           : NSNumber = NSNumber(value: 0.0) // 【可选】价格
     var maxDeviceNum    : Int = 0 // 【可选】最大可登录设备数
     var levels          : String = "" // 【可选】3高级2标准1免费
     var platforms       : String = "" // 【可选】产品支持平台
@@ -92,11 +92,11 @@ class KMListingProductsModel: NSObject {
     var paymentModel    : Int = 0 // 【可选】付费模式(1自动续订 2单次付费)
     var cycle           : Int = 0 // 【可选】订阅周期:1、月(30天);2、季(90天);3、半年(183天);4、年(365天)
     var code            : String = "" // 【可选】产品code
-    var cnyPrice        : String = "" // 【可选】人民币价格
+    var cnyPrice        : NSNumber = NSNumber(value: 0.0) // 【可选】人民币价格
 //    var displayCnyPrice        : NSNull // 【可选】人民币优惠价格
 //    var displayPrice        : NSNull // 【可选】教育优惠价格
 //    var upgradePrice        : NSNull // 【可选】买断升级订阅价格
-    init(id: String, productName: String, price: String, maxDeviceNum: Int, levels: String, platforms: String, productLineId: Int, paymentModel: Int, cycle: Int, code: String, cnyPrice: String) {
+    init(id: String, productName: String, price: NSNumber, maxDeviceNum: Int, levels: String, platforms: String, productLineId: Int, paymentModel: Int, cycle: Int, code: String, cnyPrice: NSNumber) {
         self.id = id
         self.productName = productName
         self.price = price