3
0

2 Revīzijas d5dfa703b9 ... e9fc6209db

Autors SHA1 Ziņojums Datums
  zenghong e9fc6209db Merge branch 'develop_PDFReaderPro_V4.7.0' of git.kdan.cc:Mac_PDF/PDF_Office into develop_PDFReaderPro_V4.7.0 1 nedēļu atpakaļ
  zenghong a771792a0c 【会员系统】DMG 订单相关API数据解包Crash预防 1 nedēļu atpakaļ

+ 103 - 92
PDF Office/PDF Master/MemberCenter/Model/KMMemberCenterManager.swift

@@ -966,17 +966,17 @@ class KMMemberCenterManager: NSObject {
                     var cycle = 0
                     var code = ""
                     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! 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 }
-                    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! NSNumber }
+                    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)
                 }
@@ -1033,13 +1033,13 @@ class KMMemberCenterManager: NSObject {
                 var cnyPrice = ""
                 var cnyBatchPrice = ""
                 var cnyTotalPrice = ""
-                if let token = result["productId"] { productId = token as! String }
-                if let token = result["totalPrice"] { totalPrice = token as! String }
-                if let token = result["price"] { price = token as! String }
-                if let token = result["batchPrice"] { batchPrice = token as! String }
-                if let token = result["cnyPrice"] { cnyPrice = token as! String }
-                if let token = result["cnyBatchPrice"] { cnyBatchPrice = token as! String }
-                if let token = result["cnyTotalPrice"] { cnyTotalPrice = token as! String }
+                if let token = result["productId"] { productId = token as? String ?? productId}
+                if let token = result["totalPrice"] { totalPrice = token as? String ?? totalPrice}
+                if let token = result["price"] { price = token as? String ?? price}
+                if let token = result["batchPrice"] { batchPrice = token as? String ?? batchPrice}
+                if let token = result["cnyPrice"] { cnyPrice = token as? String ?? cnyPrice}
+                if let token = result["cnyBatchPrice"] { cnyBatchPrice = token as? String ?? cnyBatchPrice}
+                if let token = result["cnyTotalPrice"] { cnyTotalPrice = token as? String ?? cnyTotalPrice}
                 let products = KMBatchProductPriceModel(productId: productId, totalPrice: totalPrice, price: price, batchPrice: batchPrice, cnyPrice: cnyPrice, cnyBatchPrice: cnyBatchPrice, cnyTotalPrice: cnyTotalPrice)
 
                 let result1 = KMMemberProductResult(code: code, msg: message, batchProductPrice: products)
@@ -1103,18 +1103,18 @@ class KMMemberCenterManager: NSObject {
                 var cycle = 0
                 var cnyPrice = ""
                 var displayCnyPrice = ""
-                if let token = result["id"] { id = token as! String }
-                if let token = result["productName"] { productName = token as! String }
-                if let token = result["price"] { price = token as! String }
-                if let token = result["maxDeviceNum"] { maxDeviceNum = token as! Int }
-                if let token = result["displayPrice"] { displayPrice = token as! String }
-                if let token = result["levels"] { levels = token as! String }
-                if let token = result["platforms"] { platforms = token as! String }
-                if let token = result["productLineId"] { productLineId = token as! Int }
-                if let token = result["paymentModel"] { paymentModel = token as! Int }
-                if let token = result["cycle"] { cycle = token as! Int }
-                if let token = result["cnyPrice"] { cnyPrice = token as! String }
-                if let token = result["displayCnyPrice"] { displayCnyPrice = token as! String }
+                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}
 
                 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)
@@ -1166,13 +1166,13 @@ class KMMemberCenterManager: NSObject {
                 var cnyPrice = ""
                 var cnyBatchPrice = ""
                 var cnyTotalPrice = ""
-                if let token = result["productId"] { productId = token as! String }
-                if let token = result["totalPrice"] { totalPrice = token as! String }
-                if let token = result["price"] { price = token as! String }
-                if let token = result["batchPrice"] { batchPrice = token as! String }
-                if let token = result["cnyPrice"] { cnyPrice = token as! String }
-                if let token = result["cnyBatchPrice"] { cnyBatchPrice = token as! String }
-                if let token = result["cnyTotalPrice"] { cnyTotalPrice = token as! String }
+                if let token = result["productId"] { productId = token as? String ?? productId}
+                if let token = result["totalPrice"] { totalPrice = token as? String ?? totalPrice}
+                if let token = result["price"] { price = token as? String ?? price}
+                if let token = result["batchPrice"] { batchPrice = token as? String ?? batchPrice}
+                if let token = result["cnyPrice"] { cnyPrice = token as? String ?? cnyPrice}
+                if let token = result["cnyBatchPrice"] { cnyBatchPrice = token as? String ?? cnyBatchPrice}
+                if let token = result["cnyTotalPrice"] { cnyTotalPrice = token as? String ?? cnyTotalPrice}
                 let products = KMBatchProductPriceModel(productId: productId, totalPrice: totalPrice, price: price, batchPrice: batchPrice, cnyPrice: cnyPrice, cnyBatchPrice: cnyBatchPrice, cnyTotalPrice: cnyTotalPrice)
 
                 let result1 = KMMemberProductResult(code: code, msg: message, batchProductPrice: products)
@@ -1280,9 +1280,9 @@ class KMMemberCenterManager: NSObject {
             var orderId = ""
             var payHref = ""
             if code == 200 {
-                if let token = result["thirdOrderNo"] { thirdOrderNo = token as! String }
-                if let token = result["orderId"] { orderId = token as! String }
-                if let token = result["payHref"] { payHref = token as! String }
+                if let token = result["thirdOrderNo"] { thirdOrderNo = token as? String ?? thirdOrderNo}
+                if let token = result["orderId"] { orderId = token as? String ?? orderId}
+                if let token = result["payHref"] { payHref = token as? String ?? payHref}
                 let products = KMCreateOrderModel(thirdOrderNo: thirdOrderNo, orderId: orderId, payHref: payHref)
                 let result1 = KMMemberProductResult(code: code, msg: message, createOrder: products)
                 complete(true, result1)
@@ -1339,9 +1339,9 @@ class KMMemberCenterManager: NSObject {
             var orderId = ""
             var payHref = ""
             if code == 200 {
-                if let token = result["thirdOrderNo"] { thirdOrderNo = token as! String }
-                if let token = result["orderId"] { orderId = token as! String }
-                if let token = result["payHref"] { payHref = token as! String }
+                if let token = result["thirdOrderNo"] { thirdOrderNo = token as? String ?? thirdOrderNo}
+                if let token = result["orderId"] { orderId = token as? String ?? orderId}
+                if let token = result["payHref"] { payHref = token as? String ?? payHref}
                 let products = KMCreateOrderModel(thirdOrderNo: thirdOrderNo, orderId: orderId, payHref: payHref)
                 let result1 = KMMemberProductResult(code: code, msg: message, createOrder: products)
                 complete(true, result1)
@@ -1357,7 +1357,7 @@ class KMMemberCenterManager: NSObject {
      @param orderStatus               0全部1待支付
      @param complete 回调
      */
-    func getOrderListByStatus(orderStatus: Int, _ complete: @escaping KMMemberProductComplete) {
+    func getOrderListByStatus(orderStatus: Int, _ complete: @escaping KMMemberRequestInfoComplete) {
         let token: String = KMMemberInfo.shared.access_token
         if token == "" {
             complete(false, nil)
@@ -1365,39 +1365,45 @@ class KMMemberCenterManager: NSObject {
         }
         let urlString = configuration.activityBaseURL() + "/pdf-office-website/order/getOrderListByStatus"
         let params: [String: Any] = ["orderStatus": orderStatus]
-        KMRequestServer.requestServer.request(urlString: urlString, method: .get, params: params) { requestSerializer in
-            requestSerializer.setValue("Bearer " + token, forHTTPHeaderField: "Authorization")
-        } completion: { [weak self] (task, responseObject, error) in
-            var dic: NSDictionary = [:]
-            if error == nil, let responseObject = responseObject as? NSDictionary {
-                dic = responseObject
-            } else {
-                var info = responseObject
-                if let error = error {
-                    if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
-                        info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
+        if let urlNewString = constructURLString(baseURLString: urlString, parameters: params) {
+            KMRequestServer.requestServer.request(urlString: urlNewString, method: .get, params: nil) { requestSerializer in
+                requestSerializer.setValue("Bearer " + token, forHTTPHeaderField: "Authorization")
+            } completion: { [weak self] (task, responseObject, error) in
+                var dic: NSDictionary = [:]
+                if error == nil, let responseObject = responseObject as? NSDictionary {
+                    dic = responseObject
+                } else {
+                    var info = responseObject
+                    if let error = error {
+                        if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
+                            info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
+                        }
                     }
+                    dic = (info as? NSDictionary) ?? [:]
                 }
-                dic = (info as? NSDictionary) ?? [:]
+                let code: Int = dic["code"] as? Int ?? 0
+                if code == 200 {
+                    complete(true, dic)
+                } else {
+                    complete(false, dic)
+                }
+    //            var thirdOrderNo = ""
+    //            var orderId = ""
+    //            var payHref = ""
+    //            if code == 200 {
+    //                if let token = result["thirdOrderNo"] { thirdOrderNo = token as! String }
+    //                if let token = result["orderId"] { orderId = token as! String }
+    //                if let token = result["payHref"] { payHref = token as! String }
+    //                let products = KMCreateOrderModel(thirdOrderNo: thirdOrderNo, orderId: orderId, payHref: payHref)
+    //                let result1 = KMMemberProductResult(code: code, msg: message, createOrder: products)
+    //                complete(true, result1)
+    //            } else {
+    //                let result1 = KMMemberProductResult(code: code, msg: message, createOrder: KMCreateOrderModel(thirdOrderNo: thirdOrderNo, orderId: orderId, payHref: payHref))
+    //                complete(false, result1)
+    //            }
             }
-            let code: Int = dic["code"] as? Int ?? 0
-            let result: NSDictionary = dic["result"] as? NSDictionary ?? [:]
-            let message: String = dic["msg"] as? String ?? ""
-            
-//            var thirdOrderNo = ""
-//            var orderId = ""
-//            var payHref = ""
-//            if code == 200 {
-//                if let token = result["thirdOrderNo"] { thirdOrderNo = token as! String }
-//                if let token = result["orderId"] { orderId = token as! String }
-//                if let token = result["payHref"] { payHref = token as! String }
-//                let products = KMCreateOrderModel(thirdOrderNo: thirdOrderNo, orderId: orderId, payHref: payHref)
-//                let result1 = KMMemberProductResult(code: code, msg: message, createOrder: products)
-//                complete(true, result1)
-//            } else {
-//                let result1 = KMMemberProductResult(code: code, msg: message, createOrder: KMCreateOrderModel(thirdOrderNo: thirdOrderNo, orderId: orderId, payHref: payHref))
-//                complete(false, result1)
-//            }
+        } else {
+            complete(false, nil)
         }
     }
     
@@ -1413,28 +1419,33 @@ class KMMemberCenterManager: NSObject {
             return
         }
         let urlString = configuration.activityBaseURL() + "/pdf-office-website/order/closeOrder"
-        KMRequestServer.requestServer.request(urlString: urlString, method: .post, params: nil) { requestSerializer in
-            requestSerializer.setValue("Bearer " + token, forHTTPHeaderField: "Authorization")
-        } completion: { [weak self] (task, responseObject, error) in
-            var dic: NSDictionary = [:]
-            if error == nil, let responseObject = responseObject as? NSDictionary {
-                dic = responseObject
-            } else {
-                var info = responseObject
-                if let error = error {
-                    if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
-                        info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
+        let params: [String: Any] = ["orderId": orderId]
+        if let urlNewString = constructURLString(baseURLString: urlString, parameters: params) {
+            KMRequestServer.requestServer.request(urlString: urlNewString, method: .post, params: nil) { requestSerializer in
+                requestSerializer.setValue("Bearer " + token, forHTTPHeaderField: "Authorization")
+            } completion: { [weak self] (task, responseObject, error) in
+                var dic: NSDictionary = [:]
+                if error == nil, let responseObject = responseObject as? NSDictionary {
+                    dic = responseObject
+                } else {
+                    var info = responseObject
+                    if let error = error {
+                        if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
+                            info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
+                        }
                     }
+                    dic = (info as? NSDictionary) ?? [:]
                 }
-                dic = (info as? NSDictionary) ?? [:]
-            }
-            let code: Int = dic["code"] as? Int ?? 0
+                let code: Int = dic["code"] as? Int ?? 0
 
-            if code == 200 {
-                complete(true, dic)
-            } else {
-                complete(false, dic)
+                if code == 200 {
+                    complete(true, dic)
+                } else {
+                    complete(false, dic)
+                }
             }
+        } else {
+            complete(false, nil)
         }
     }
     

+ 3 - 0
PDF Office/PDF Master/MemberCenter/ViewController/KMUserInfoViewController.swift

@@ -537,10 +537,13 @@ class KMUserInfoViewController: NSViewController {
                 buyNow2ImageView.isHidden = false
                 arrow1ImageView.image = NSImage(named: "BuyNewArrowImage1")
                 arrow2ImageView.image = NSImage(named: "BuyNewArrowImage1")
+#if !VERSION_DMG
                 if IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite.isTrialPeriod == true {
                     buyNow2Box.isHidden = true
                     buyNow1BoxLeftConst.constant = (CGRectGetWidth(view.bounds) - CGRectGetWidth(buyNow1Box.frame))/2
                 }
+#else
+#endif
             } else if KMMemberInfo.shared.userScenarioType == .lite_type3 ||
                         KMMemberInfo.shared.userScenarioType == .lite_type11 ||
                         KMMemberInfo.shared.userScenarioType == .lite_type9 {

+ 14 - 10
PDF Office/PDF Master/MemberCenter/ViewModel/KMProductModel.swift

@@ -107,15 +107,15 @@ class KMProductModel: ObservableObject {
     }
     
     /**
-     @abstract 获取服务器架上所有商品 (得到的价格是原始价格)
+     @abstract 获取DMG服务器架上所有商品 (得到的价格是原始价格)
      @param
      */
     func getDMGProductDatas() -> Void {
         checkConnectionAvailable()
-        KMMemberCenterManager.manager.getListingProducts(isEducation: 0) { [weak self] success, result in
-            guard let productsArrays : KMMemberProductResult = result else { return }
-            self?.dmgProductDatas = productsArrays
-        }
+//        KMMemberCenterManager.manager.getListingProducts(isEducation: 0) { [weak self] success, result in
+//            guard let productsArrays : KMMemberProductResult = result else { return }
+//            self?.dmgProductDatas = productsArrays
+//        }
         
         if KMMemberInfo.shared.isLogin {
 //            getDMGProductPriceInfosForMember(productId: "SP2024102300004", isEducation: 0) { [weak self] success, result in
@@ -123,12 +123,16 @@ class KMProductModel: ObservableObject {
 //                
 //            }
             
-//            getDMGBatchProductPriceInfosForMember(productId: "SP2024102100002", num: 10) { [weak self] success, result in
+//            getDMGBatchProductPriceInfosForMember(productId: "SP2024102300004", num: 10) { [weak self] success, result in
+//                
 //                
+//            }
+            
+//            getDMGProductListInfosForMember(orderStatus: 0) { [weak self] success, result in
 //                
 //            }
             
-//            creatOrder(productId: "SP2024102300003", paymentMethod: 0, price: NSNumber(value: 119.99), discountFlag: 0, couponCode: "", num: 1) { [weak self] success, result in
+//            creatOrder(productId: "SP2024102300004", paymentMethod: 0, price: NSNumber(value: 119.99), discountFlag: 0, couponCode: "", num: 1) { [weak self] success, result in
 //
 //            }
             
@@ -212,15 +216,15 @@ class KMProductModel: ObservableObject {
      @param orderStatus               0全部1待支付
      @param complete 回调
      */
-    func getDMGProductListInfosForMember(orderStatus: Int, _ complete: @escaping KMMemberProductComplete) {
+    func getDMGProductListInfosForMember(orderStatus: Int, _ complete: @escaping KMMemberRequestInfoComplete) {
         checkConnectionAvailable()
         KMMemberCenterManager.manager.getOrderListByStatus(orderStatus: orderStatus) { [weak self] success, result in
             if success {
-                guard let productsArrays : KMMemberProductResult = result else {
+                guard let productsInfos : NSDictionary = result else {
                     complete(false, result)
                     return
                 }
-                complete(true, productsArrays)
+                complete(true, productsInfos)
             } else {
                 complete(false, result)
             }