Quellcode durchsuchen

【会员系统】DMG 订单API 数据模型增加数据解析

zenghong vor 1 Woche
Ursprung
Commit
ecd2b329b2

+ 2 - 2
PDF Office/PDF Master/Class/Purchase/DMG/KMPurchaseEmbeddedWindowController.swift

@@ -151,7 +151,7 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
     @IBOutlet weak var image2BottomLayout: NSLayoutConstraint!
     
     private var _dmgProductType: KMDMGProductType = .advanced_annual_subscription_trail
-    private var _product_Info: KMListingProductsModel = KMListingProductsModel(id: "23", productName: "PDF Reader Pro Advanced - Annual Plan", price: NSNumber(value: 99.99), maxDeviceNum: 4, levels: "3", platforms: "Windows,Android,Mac,iOS", productLineId: 1, paymentModel: 1, cycle: 4, code: "advanced-annual-subscription-trail", cnyPrice: 0)
+    private var _product_Info: KMListingProductsModel = KMListingProductsModel(id: "23", productName: "PDF Reader Pro Advanced - Annual Plan", price: NSNumber(value: 99.99), maxDeviceNum: 4, displayPrice: NSNumber(value: 0.0), levels: "3", platforms: "Windows,Android,Mac,iOS", productLineId: 1, paymentModel: 1, cycle: 4, cnyPrice: NSNumber(value: 0), displayCnyPrice: NSNumber(value: 0.0), upgradePrice: NSNumber(value: 0.0), code: "advanced-annual-subscription-trail")
 
     private var pdfCount: Int = 1
     private var _paymentMethod: KMPaymentType = .paypal
@@ -327,7 +327,7 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
             prmiumLabel.stringValue = fullString
             
             
-            oneLicenseLabel.stringValue = NSLocalizedString("and more offline. It's one time purchase.", comment: "")
+//            oneLicenseLabel.stringValue = NSLocalizedString("and more offline. It's one time purchase.", comment: "")
             licenseCodeLabel.stringValue = NSLocalizedString("License Code", comment: "")
             licenseCodeLabel.textColor = NSColor(named: "KMPurchaseTitleColor1")
             licenseCodeLabel.font = NSFont.SFProTextRegularFont(14.0)

+ 66 - 34
PDF Office/PDF Master/MemberCenter/Model/KMMemberCenterManager.swift

@@ -882,7 +882,6 @@ class KMMemberCenterManager: NSObject {
                 for dict1 in result_Array {
                     var id = ""
                     var productName = ""
-                    var price = NSNumber(value: 0.0)
                     var maxDeviceNum = 0
                     var levels = ""
                     var platforms = ""
@@ -890,11 +889,17 @@ class KMMemberCenterManager: NSObject {
                     var paymentModel = 0
                     var cycle = 0
                     var code = ""
+                    
+                    var price = NSNumber(value: 0.0)
+                    var displayPrice = NSNumber(value: 0.0)
+                    var upgradePrice = NSNumber(value: 0.0)
                     var cnyPrice = NSNumber(value: 0.0)
+                    var displayCnyPrice = 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 }
@@ -902,9 +907,15 @@ class KMMemberCenterManager: NSObject {
                     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["price"] { price = token as? NSNumber ?? price }
+                    if let token = dict1["displayPrice"] { displayPrice = token as? NSNumber ?? displayPrice }
+                    if let token = dict1["upgradePrice"] { upgradePrice = token as? NSNumber ?? upgradePrice }
                     if let token = dict1["cnyPrice"] { cnyPrice = token as? NSNumber ?? cnyPrice }
+                    if let token = dict1["displayCnyPrice"] { displayCnyPrice = token as? NSNumber ?? displayCnyPrice }
 
-                    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)
+                    let products = KMListingProductsModel(id: id, productName: productName, price: price, maxDeviceNum: maxDeviceNum, displayPrice: displayPrice, levels: levels, platforms: platforms, productLineId: productLineId, paymentModel: paymentModel, cycle: cycle, cnyPrice: cnyPrice, displayCnyPrice: displayCnyPrice, upgradePrice: upgradePrice, code: code)
+                    
                     results.append(products)
                 }
 
@@ -957,7 +968,6 @@ class KMMemberCenterManager: NSObject {
                 for dict1 in result_Array {
                     var id = ""
                     var productName = ""
-                    var price = NSNumber(value: 0.0)
                     var maxDeviceNum = 0
                     var levels = ""
                     var platforms = ""
@@ -965,19 +975,32 @@ class KMMemberCenterManager: NSObject {
                     var paymentModel = 0
                     var cycle = 0
                     var code = ""
+                    
+                    var price = NSNumber(value: 0.0)
+                    var displayPrice = NSNumber(value: 0.0)
+                    var upgradePrice = NSNumber(value: 0.0)
                     var cnyPrice = NSNumber(value: 0.0)
+                    var displayCnyPrice = 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["productName"] { productName = token as? String ?? productName }
+                    
+                    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["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)
+                    if let token = dict1["displayPrice"] { displayPrice = token as? NSNumber ?? displayPrice }
+                    if let token = dict1["upgradePrice"] { upgradePrice = token as? NSNumber ?? upgradePrice }
+                    if let token = dict1["cnyPrice"] { cnyPrice = token as? NSNumber ?? cnyPrice }
+                    if let token = dict1["displayCnyPrice"] { displayCnyPrice = token as? NSNumber ?? displayCnyPrice }
+
+                    let products = KMListingProductsModel(id: id, productName: productName, price: price, maxDeviceNum: maxDeviceNum, displayPrice: displayPrice, levels: levels, platforms: platforms, productLineId: productLineId, paymentModel: paymentModel, cycle: cycle, cnyPrice: cnyPrice, displayCnyPrice: displayCnyPrice, upgradePrice: upgradePrice, code: code)
                     results.append(products)
                 }
 
@@ -1087,38 +1110,47 @@ class KMMemberCenterManager: NSObject {
                     }
                     dic = (info as? NSDictionary) ?? [:]
                 }
-                let code: Int = dic["code"] as? Int ?? 0
+                let requestCode: Int = dic["code"] as? Int ?? 0
                 let result: NSDictionary = dic["result"] as? NSDictionary ?? [:]
                 let message: String = dic["msg"] as? String ?? ""
                 
                 var id = ""
                 var productName = ""
-                var price = ""
                 var maxDeviceNum = 0
-                var displayPrice = ""
                 var levels = ""
                 var platforms = ""
                 var productLineId = 0
                 var paymentModel = 0
                 var cycle = 0
-                var cnyPrice = ""
-                var displayCnyPrice = ""
-                if let token = result["id"] { id = token as? String ?? id}
-                if let token = result["productName"] { productName = token as? String ?? productName}
-                if let token = result["price"] { price = token as? String ?? price}
-                if let token = result["maxDeviceNum"] { maxDeviceNum = token as? Int ?? maxDeviceNum}
-                if let token = result["displayPrice"] { displayPrice = token as? String ?? displayPrice}
-                if let token = result["levels"] { levels = token as? String ?? levels}
-                if let token = result["platforms"] { platforms = token as? String ?? platforms}
-                if let token = result["productLineId"] { productLineId = token as? Int ?? productLineId}
-                if let token = result["paymentModel"] { paymentModel = token as? Int ?? paymentModel}
-                if let token = result["cycle"] { cycle = token as? Int ?? cycle}
-                if let token = result["cnyPrice"] { cnyPrice = token as? String ?? cnyPrice}
-                if let token = result["displayCnyPrice"] { displayCnyPrice = token as? String ?? displayCnyPrice}
+                var code = ""
+                
+                var price = NSNumber(value: 0.0)
+                var displayPrice = NSNumber(value: 0.0)
+                var upgradePrice = NSNumber(value: 0.0)
+                var cnyPrice = NSNumber(value: 0.0)
+                var displayCnyPrice = NSNumber(value: 0.0)
+                
+                
+                if let token = dic["id"] { id = token as? String ?? id }
+                if let token = dic["productName"] { productName = token as? String ?? productName }
+                
+                if let token = dic["maxDeviceNum"] { maxDeviceNum = token as? Int ?? maxDeviceNum }
+                if let token = dic["levels"] { levels = token as? String ?? levels }
+                if let token = dic["platforms"] { platforms = token as? String ?? platforms }
+                if let token = dic["productLineId"] { productLineId = token as? Int ?? productLineId }
+                if let token = dic["paymentModel"] { paymentModel = token as? Int ?? paymentModel }
+                if let token = dic["cycle"] { cycle = token as? Int ?? cycle }
+                if let token = dic["code"] { code = token as? String ?? code  }
+                
+                if let token = dic["price"] { price = token as? NSNumber ?? price }
+                if let token = dic["displayPrice"] { displayPrice = token as? NSNumber ?? displayPrice }
+                if let token = dic["upgradePrice"] { upgradePrice = token as? NSNumber ?? upgradePrice }
+                if let token = dic["cnyPrice"] { cnyPrice = token as? NSNumber ?? cnyPrice }
+                if let token = dic["displayCnyPrice"] { displayCnyPrice = token as? NSNumber ?? displayCnyPrice }
 
-                let products = KMCheckCouponModel(id: id, productName: productName, price: price, maxDeviceNum: maxDeviceNum, displayPrice: displayPrice, levels: levels, platforms: platforms, productLineId: productLineId, paymentModel: paymentModel, cycle: cycle, cnyPrice: cnyPrice, displayCnyPrice: displayCnyPrice)
-                let result1 = KMMemberProductResult(code: code, msg: message, checkCoupon: products)
-                if code == 200 {
+                let products = KMCheckCouponModel(id: id, productName: productName, price: price, maxDeviceNum: maxDeviceNum, displayPrice: displayPrice, levels: levels, platforms: platforms, productLineId: productLineId, paymentModel: paymentModel, cycle: cycle, cnyPrice: cnyPrice, displayCnyPrice: displayCnyPrice, upgradePrice: upgradePrice, code: code)
+                let result1 = KMMemberProductResult(code: requestCode, msg: message, checkCoupon: products)
+                if requestCode == 200 {
                     complete(true, result1)
                 } else {
                     complete(false, result1)

+ 20 - 11
PDF Office/PDF Master/MemberCenter/Model/KMMemberProductResult.swift

@@ -84,7 +84,6 @@ class KMMemberProductResult: NSObject {
 class KMListingProductsModel: NSObject {
     var id              : String = "" // 【可选】id
     var productName     : String = "" // 【可选】名称
-    var price           : NSNumber = NSNumber(value: 0.0) // 【可选】价格
     var maxDeviceNum    : Int = 0 // 【可选】最大可登录设备数
     var levels          : String = "" // 【可选】3高级2标准1免费
     var platforms       : String = "" // 【可选】产品支持平台
@@ -92,22 +91,27 @@ 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 price           : NSNumber = NSNumber(value: 0.0) // 【可选】美金价格
     var cnyPrice        : NSNumber = NSNumber(value: 0.0) // 【可选】人民币价格
-//    var displayCnyPrice        : NSNull // 【可选】人民币优惠价格
-//    var displayPrice        : NSNull // 【可选】教育优惠价格
-//    var upgradePrice        : NSNull // 【可选】买断升级订阅价格
-    init(id: String, productName: String, price: NSNumber, maxDeviceNum: Int, levels: String, platforms: String, productLineId: Int, paymentModel: Int, cycle: Int, code: String, cnyPrice: NSNumber) {
+    var displayCnyPrice : NSNumber = NSNumber(value: 0.0) // 【可选】人民币优惠价格
+    var displayPrice    : NSNumber = NSNumber(value: 0.0) // 【可选】教育优惠价格
+    var upgradePrice    : NSNumber = NSNumber(value: 0.0) // 【可选】买断升级订阅价格
+    
+    init(id: String, productName: String, price: NSNumber, maxDeviceNum: Int, displayPrice: NSNumber, levels: String, platforms: String, productLineId: Int, paymentModel: Int, cycle: Int, cnyPrice: NSNumber, displayCnyPrice: NSNumber, upgradePrice: NSNumber, code: String) {
         self.id = id
         self.productName = productName
         self.price = price
         self.maxDeviceNum = maxDeviceNum
+        self.displayPrice = displayPrice
         self.levels = levels
         self.platforms = platforms
         self.productLineId = productLineId
         self.paymentModel = paymentModel
         self.cycle = cycle
-        self.code = code
         self.cnyPrice = cnyPrice
+        self.displayCnyPrice = displayCnyPrice
+        self.upgradePrice = upgradePrice
     }
 }
 
@@ -134,17 +138,21 @@ class KMBatchProductPriceModel: NSObject {
 class KMCheckCouponModel: NSObject {
     var id              : String = ""   // 【必需】id
     var productName     : String = ""   // 【必需】名称
-    var price           : String = ""   // 【必需】价格
     var maxDeviceNum    : Int = 0       // 【必需】最大可登录设备数
-    var displayPrice    : String = ""   // 【必需】优惠后价格
     var levels          : String = ""   // 【必需】3高级2标准1免费
     var platforms       : String = ""   // 【必需】产品支持平台
     var productLineId   : Int = 0       // 【必需】所属业务线id (1pdf产品线2compdfkit产品线)
     var paymentModel    : Int = 0       // 【必需】付费模式(1自动续订 2单次付费)
     var cycle           : Int = 0       // 【必需】订阅周期:1、月(30天);2、季(90天);3、半年(183天);4、年(365天)
-    var cnyPrice        : String = ""   // 【必需】人民币价格
-    var displayCnyPrice : String = ""   // 【必需】人民币优惠价格
-    init(id: String, productName: String, price: String, maxDeviceNum: Int, displayPrice: String, levels: String, platforms: String, productLineId: Int, paymentModel: Int, cycle: Int, cnyPrice: String, displayCnyPrice: String) {
+    var code            : String = "" // 【可选】产品code
+    
+    var price           : NSNumber = NSNumber(value: 0.0)   // 【必需】价格
+    var cnyPrice        : NSNumber = NSNumber(value: 0.0) // 【可选】人民币价格
+    var displayCnyPrice : NSNumber = NSNumber(value: 0.0) // 【可选】人民币优惠价格
+    var displayPrice    : NSNumber = NSNumber(value: 0.0) // 【可选】教育优惠价格
+    var upgradePrice    : NSNumber = NSNumber(value: 0.0) // 【可选】买断升级订阅价格
+    
+    init(id: String, productName: String, price: NSNumber, maxDeviceNum: Int, displayPrice: NSNumber, levels: String, platforms: String, productLineId: Int, paymentModel: Int, cycle: Int, cnyPrice: NSNumber, displayCnyPrice: NSNumber, upgradePrice: NSNumber, code: String) {
         self.id = id
         self.productName = productName
         self.price = price
@@ -157,6 +165,7 @@ class KMCheckCouponModel: NSObject {
         self.cycle = cycle
         self.cnyPrice = cnyPrice
         self.displayCnyPrice = displayCnyPrice
+        self.upgradePrice = upgradePrice
     }
 }