Browse Source

【会员系统】DMG 订单相关API呼叫方式修改

zenghong 1 week ago
parent
commit
01c8734f03

+ 1 - 1
PDF Office/PDF Master/Class/KMLightMember/KMRequestServer/KMRequestServer.swift

@@ -64,7 +64,7 @@ typealias KMHttpRequestServerComplete = (_ task: URLSessionDataTask?, _ response
         sessionManager.requestSerializer = AFJSONRequestSerializer()
         sessionManager.responseSerializer = AFJSONResponseSerializer()
         sessionManager.responseSerializer.acceptableContentTypes = ["application/json","text/html","text/json","text/javascript","text/plain","image/gif"]
-        sessionManager.requestSerializer.timeoutInterval = 10
+        sessionManager.requestSerializer.timeoutInterval = 60
 //        [requestSerializer setValue:@"application/vnd.api+json;version=1" forHTTPHeaderField:@"Accept"];
         if (requestSerializer != nil) {
             requestSerializer!(sessionManager.requestSerializer);

+ 289 - 243
PDF Office/PDF Master/MemberCenter/Model/KMMemberCenterManager.swift

@@ -69,6 +69,22 @@ class KMMemberCenterManager: NSObject {
         return true
     }
     
+    // MARK: 拼接URL(为Get类型)
+    func constructURLString(baseURLString: String, parameters: [String: Any]) -> String? {
+        // Ensure the base URL is valid
+        guard var components = URLComponents(string: baseURLString) else {
+            return nil
+        }
+        
+        // Convert parameters to query items
+        components.queryItems = parameters.map { key, value in
+            URLQueryItem(name: key, value: "\(value)")
+        }
+        
+        // Return the complete URL as a string
+        return components.url?.absoluteString
+    }
+    
     // MARK: 登录模块
     
     /**
@@ -832,7 +848,7 @@ class KMMemberCenterManager: NSObject {
     
 #if VERSION_DMG
     // DMG
-        platformId = "1"
+        platformId = "2"
 #else
     // AppStore 免费版本
 #endif
@@ -840,63 +856,68 @@ class KMMemberCenterManager: NSObject {
     // AppStore 付费版
         platformId = "5"
 #endif
-        let params: [String: Any] = ["isEducation": isEducation,
+        let params: [String: Any] = ["isEducation": NSNumber(value: Int32(isEducation)),
                                      "platformId": platformId]
-        KMRequestServer.requestServer.request(urlString: urlString, method: .get, params: params) { requestSerializer in
-            
-        } 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
+                
+            } 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 result_Array: [NSDictionary] = dic["result"] as? [NSDictionary] ?? [[:]]
-            let message: String = dic["msg"] as? String ?? ""
-            
-            var results: [KMListingProductsModel] = []
-            for dict1 in result_Array {
-                var id = ""
-                var productName = ""
-                var price = NSNumber(value: 0.0)
-                var maxDeviceNum = 0
-                var levels = ""
-                var platforms = ""
-                var productLineId = 0
-                var paymentModel = 0
-                var cycle = 0
-                var code = ""
-                var cnyPrice = NSNumber(value: 0.0)
+                let code: Int = dic["code"] as? Int ?? 0
+                let result_Array: [NSDictionary] = dic["result"] as? [NSDictionary] ?? [[:]]
+                let message: String = dic["msg"] as? String ?? ""
                 
-                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 }
+                var results: [KMListingProductsModel] = []
+                for dict1 in result_Array {
+                    var id = ""
+                    var productName = ""
+                    var price = NSNumber(value: 0.0)
+                    var maxDeviceNum = 0
+                    var levels = ""
+                    var platforms = ""
+                    var productLineId = 0
+                    var paymentModel = 0
+                    var cycle = 0
+                    var code = ""
+                    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)
-            }
+                    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)
+                }
 
-            let result = KMMemberProductResult(code: code, msg: message, listingProducts: results)
-            if code == 200 {
-                complete(true, result)
-            } else {
-                complete(false, result)
+                let result = KMMemberProductResult(code: code, msg: message, listingProducts: results)
+                if code == 200 {
+                    complete(true, result)
+                } else {
+                    complete(false, result)
+                }
             }
+        } else {
+            print("Invalid URL")
+            complete(false, nil)
         }
     }
     
@@ -912,60 +933,66 @@ class KMMemberCenterManager: NSObject {
         let params: [String: Any] = ["productId": productId,
                                      "isEducation": isEducation,
                                      "userId": userId]
-        KMRequestServer.requestServer.request(urlString: urlString, method: .get, params: params) { requestSerializer in
-            
-        } 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
+                
+            } 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) ?? [:]
+                }
+                let code: Int = dic["code"] as? Int ?? 0
+                let result_Array: [NSDictionary] = [dic["result"]] as? [NSDictionary] ?? [[:]]
+                let message: String = dic["msg"] as? String ?? ""
+                
+                var results: [KMListingProductsModel] = []
+                for dict1 in result_Array {
+                    var id = ""
+                    var productName = ""
+                    var price = NSNumber(value: 0.0)
+                    var maxDeviceNum = 0
+                    var levels = ""
+                    var platforms = ""
+                    var productLineId = 0
+                    var paymentModel = 0
+                    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 }
+                    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)
                 }
-                dic = (info as? NSDictionary) ?? [:]
-            }
-            let code: Int = dic["code"] as? Int ?? 0
-            let result_Array: [NSDictionary] = [dic["result"]] as? [NSDictionary] ?? [[:]]
-            let message: String = dic["msg"] as? String ?? ""
-            
-            var results: [KMListingProductsModel] = []
-            for dict1 in result_Array {
-                var id = ""
-                var productName = ""
-                var price = NSNumber(value: 0.0)
-                var maxDeviceNum = 0
-                var levels = ""
-                var platforms = ""
-                var productLineId = 0
-                var paymentModel = 0
-                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 }
-                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)
-            }
 
-            let result = KMMemberProductResult(code: code, msg: message, listingProducts: results)
-            if code == 200 {
-                complete(true, result)
-            } else {
-                complete(false, result)
+                let result = KMMemberProductResult(code: code, msg: message, listingProducts: results)
+                if code == 200 {
+                    complete(true, result)
+                } else {
+                    complete(false, result)
+                }
             }
+        } else {
+            print("Invalid URL")
+            complete(false, nil)
         }
+        
     }
     
     /**
@@ -979,47 +1006,51 @@ class KMMemberCenterManager: NSObject {
         let urlString = configuration.activityBaseURL() + "/pdf-office-website/web/getBatchProductPrice"
         let params: [String: Any] = ["productId": productId,
                                      "num": NSNumber(value: Int32(num))]
-        KMRequestServer.requestServer.request(urlString: urlString, method: .get, params: params) { requestSerializer in
-            
-        } 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
+                
+            } 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 result: NSDictionary = dic["result"] as? NSDictionary ?? [:]
-            let message: String = dic["msg"] as? String ?? ""
-            
-            var productId = ""
-            var totalPrice = ""
-            var price = ""
-            var batchPrice = ""
-            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 }
-            let products = KMBatchProductPriceModel(productId: productId, totalPrice: totalPrice, price: price, batchPrice: batchPrice, cnyPrice: cnyPrice, cnyBatchPrice: cnyBatchPrice, cnyTotalPrice: cnyTotalPrice)
+                let code: Int = dic["code"] as? Int ?? 0
+                let result: NSDictionary = dic["result"] as? NSDictionary ?? [:]
+                let message: String = dic["msg"] as? String ?? ""
+                
+                var productId = ""
+                var totalPrice = ""
+                var price = ""
+                var batchPrice = ""
+                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 }
+                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)
-            if code == 200 {
-                complete(true, result1)
-            } else {
-                complete(false, result1)
+                let result1 = KMMemberProductResult(code: code, msg: message, batchProductPrice: products)
+                if code == 200 {
+                    complete(true, result1)
+                } else {
+                    complete(false, result1)
+                }
             }
+        } else {
+            print("Invalid URL")
         }
     }
     
@@ -1040,111 +1071,120 @@ class KMMemberCenterManager: NSObject {
         let params: [String: Any] = ["productId": productId,
                                      "userId": userId,
                                      "code": code]
-        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
-            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 }
-            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 }
+                let code: 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 }
+                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 }
 
-            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 {
-                complete(true, result1)
-            } else {
-                complete(false, result1)
+                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 {
+                    complete(true, result1)
+                } else {
+                    complete(false, result1)
+                }
             }
+        } else {
+            print("Invalid URL")
+            complete(false, nil)
         }
     }
     
     /**
-     @abstract              获取批量阶段购买价格
-     @param productId 购买的产品id
-     @param isEducation 是否教育优惠
+     @abstract              检查邮箱教育优惠资格
+     @param email 邮箱
      @param complete 回调
      */
     func checkEducation(email: String, _ complete: @escaping KMMemberProductComplete) {
         
         let urlString = configuration.activityBaseURL() + "/pdf-office-website/web/checkEducation"
         let params: [String: Any] = ["email": email]
-        KMRequestServer.requestServer.request(urlString: urlString, method: .get, params: params) { requestSerializer in
-            
-        } 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
+                
+            } 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 result: NSDictionary = dic["result"] as? NSDictionary ?? [:]
-            let message: String = dic["msg"] as? String ?? ""
-            
-            var productId = ""
-            var totalPrice = ""
-            var price = ""
-            var batchPrice = ""
-            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 }
-            let products = KMBatchProductPriceModel(productId: productId, totalPrice: totalPrice, price: price, batchPrice: batchPrice, cnyPrice: cnyPrice, cnyBatchPrice: cnyBatchPrice, cnyTotalPrice: cnyTotalPrice)
+                let code: Int = dic["code"] as? Int ?? 0
+                let result: NSDictionary = dic["result"] as? NSDictionary ?? [:]
+                let message: String = dic["msg"] as? String ?? ""
+                
+                var productId = ""
+                var totalPrice = ""
+                var price = ""
+                var batchPrice = ""
+                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 }
+                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)
-            if code == 200 {
-                complete(true, result1)
-            } else {
-                complete(false, result1)
+                let result1 = KMMemberProductResult(code: code, msg: message, batchProductPrice: products)
+                if code == 200 {
+                    complete(true, result1)
+                } else {
+                    complete(false, result1)
+                }
             }
+        } else {
+            print("Invalid URL")
+            complete(false, nil)
         }
     }
     
@@ -1164,27 +1204,33 @@ class KMMemberCenterManager: NSObject {
             return
         }
         let urlString = configuration.activityBaseURL() + "/pdf-office-website/order/getStateByOrderId"
-        KMRequestServer.requestServer.request(urlString: urlString, 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
+        let params: [String: Any] = ["orderId": orderId]
+        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) ?? [:]
+                }
+                let code: Int = dic["code"] as? Int ?? 0
+                if code == 200 {
+                    complete(true, dic)
+                } else {
+                    complete(false, dic)
                 }
-                dic = (info as? NSDictionary) ?? [:]
-            }
-            let code: Int = dic["code"] as? Int ?? 0
-            if code == 200 {
-                complete(true, dic)
-            } else {
-                complete(false, dic)
             }
+        } else {
+            print("Invalid URL")
+            complete(false, nil)
         }
     }
     
@@ -1263,7 +1309,7 @@ class KMMemberCenterManager: NSObject {
             complete(false, nil)
             return
         }
-        let urlString = configuration.activityBaseURL() + "/pdf-office-website/order/createOrder"
+        let urlString = configuration.activityBaseURL() + "/pdf-office-website/order/createSubscription"
         let params: [String: Any] = ["productId": productId,
                                      "paymentMethod": paymentMethod,
                                      "price": price,

+ 1 - 0
PDF Office/PDF Master/MemberCenter/Model/KMMemberInfo.swift

@@ -360,6 +360,7 @@ import Cocoa
             if KMMemberInfo.shared.isLogin {
                 
             }
+            return false
 #else
     // AppStore 免费版本
             if KMMemberInfo.shared.isLogin {

+ 1 - 1
PDF Office/PDF Master/MemberCenter/ViewModel/KMProductModel.swift

@@ -118,7 +118,7 @@ class KMProductModel: ObservableObject {
         }
         
         if KMMemberInfo.shared.isLogin {
-//            getDMGProductPriceInfosForMember(productId: "SP2024102100002", isEducation: 0) { [weak self] success, result in
+//            getDMGProductPriceInfosForMember(productId: "SP2024102300004", isEducation: 0) { [weak self] success, result in
 //                
 //                
 //            }