Selaa lähdekoodia

Merge branch 'develop_PDFReaderPro_V4.7.0' of git.kdan.cc:Mac_PDF/PDF_Office into develop_PDFReaderPro_V4.7.0

dinglingui 1 viikko sitten
vanhempi
commit
fc4a519d5c

+ 15 - 6
PDF Office/PDF Master/Class/AIInfo/KMAIRequestServerManager.swift

@@ -317,18 +317,27 @@ class ResultWrapper: NSObject {
             if responseObject != nil {
                 let data: NSDictionary = responseObject as? NSDictionary ?? [:]
                 if data.count > 0 {
-                    let wrapper = ResultWrapper(success: true, resultData: data)
-                    if let value = data["fileKey"] {
-                        wrapper.content = value as! String
+                    let code: Int = data["code"] as? Int ?? 06005
+                    if code == 200 {
+                        let wrapper = ResultWrapper(success: true, resultData: data)
+                        if let value = data["fileKey"] {
+                            wrapper.content = value as! String
+                        }
+                        complete(wrapper)
+                    } else {
+                        let wrapper = ResultWrapper(success: false, resultData: data)
+                        if let value = data["msg"] {
+                            wrapper.content = value as! String
+                        }
+                        complete(wrapper)  
                     }
-                    complete(wrapper)
                 } else {
                     let error = NSError(domain: "unknown error", code: 404)
-                     complete(ResultWrapper(success: false, content: "unknown error"))
+                    complete(ResultWrapper(success: false, content: "unknown error"))
                 }
             } else {
                 let error = NSError(domain: "unknown error", code: 404)
-                 complete(ResultWrapper(success: false, content: "unknown error"))
+                complete(ResultWrapper(success: false, content: "unknown error"))
             }
         }
     }

+ 29 - 8
PDF Office/PDF Master/MemberCenter/ViewModel/KMProductModel.swift

@@ -506,6 +506,11 @@ class KMProductModel: ObservableObject {
     }
     
     func appStoreEquityVerification(_ notification: Notification,_ complete: @escaping KMMemberProductComplete) -> Void {
+#if VERSION_FREE
+#if VERSION_DMG
+        // DMG
+#else
+        // AppStore 免费版本
         if let userInfo = notification.object as? SKPaymentTransaction,
            let transactionId = userInfo.transactionIdentifier as? String,
            let productId = userInfo.payment.productIdentifier as? String {
@@ -514,11 +519,6 @@ class KMProductModel: ObservableObject {
             
             var productCode = ""
             var isSubscribed = false
-#if VERSION_FREE
-#if VERSION_DMG
-    // DMG
-#else
-    // AppStore 免费版本
             if productId == "com.pdfreaderpro.mac_free.member.all_access_pack_advanced_6months.001" {
                 productCode = "advanced-annual-subscription-six-month"
                 if IAPProductsManager.default().fourDevicesAllAccessPackNew6Months_lite.isSubscribed {
@@ -570,9 +570,30 @@ class KMProductModel: ObservableObject {
                     isSubscribed = true
                 }
             }
+            if isSubscribed {
+                KMMemberCenterManager.manager.appStoreEquityVerification(applePayProductId: productId, transactionId: transactionId, productCode: productCode) { success, result in
+                    if success {
+                        complete(true, result)
+                    } else {
+                        complete(false, result)
+                    }
+                    
+                }
+            }
+        } else {
+            print("Transaction ID not found in notification.")
+        }
 #endif
 #else
-    // AppStore 付费版
+        // AppStore 付费版
+        if let userInfo = notification.object as? SKPaymentTransaction,
+           let transactionId = userInfo.transactionIdentifier as? String,
+           let productId = userInfo.payment.productIdentifier as? String {
+            print("Transaction ID: \(transactionId)")
+            print("product ID: \(productId)")
+            
+            var productCode = ""
+            var isSubscribed = false
             if productId == "com.pdfreaderpro.mac.ai_pack_1_month" {
                 productCode = "ai-subscription-month"
                 if IAPProductsManager.default().aiAllAccessPack1month_pro.isSubscribed {
@@ -594,7 +615,6 @@ class KMProductModel: ObservableObject {
                     isSubscribed = true
                 }
             }
-#endif
             if isSubscribed {
                 KMMemberCenterManager.manager.appStoreEquityVerification(applePayProductId: productId, transactionId: transactionId, productCode: productCode) { success, result in
                     if success {
@@ -602,12 +622,13 @@ class KMProductModel: ObservableObject {
                     } else {
                         complete(false, result)
                     }
-
+                    
                 }
             }
         } else {
             print("Transaction ID not found in notification.")
         }
+#endif
     }
     
     var isCancelAutoRenew: Bool {