Explorar o código

【会员系统】会员购买权益调整

wanjun hai 1 semana
pai
achega
d0e82ddf65

+ 9 - 7
PDF Office/PDF Master/MemberCenter/Model/KMMemberCenterManager.swift

@@ -1453,21 +1453,23 @@ class KMMemberCenterManager: NSObject {
     
     /**
      @abstract              APPstore 权益校验
-     @param orderStatus               0全部1待支付
+     @param applePayProductId
+     @param transactionId
+     @param productCode
      @param complete 回调
      */
-    func appStoreEquityVerification(orderStatus: Int, _ complete: @escaping KMMemberProductComplete) {
+    func appStoreEquityVerification(applePayProductId: String, transactionId: String, productCode: String, _ complete: @escaping KMMemberProductComplete) {
         let token: String = KMMemberInfo.shared.access_token
         if token == "" {
             complete(false, nil)
             return
         }
         let urlString = configuration.activityBaseURL() + "/member-system-website/applePay/appStoreEquityVerification"
-        let params: [String: Any] = ["userId": "",
-                                     "applePayProductId": "",
-                                     "transactionId": "",
-                                     "productCode": ""]
-        KMRequestServer.requestServer.request(urlString: urlString, method: .get, params: params) { requestSerializer in
+        let params: [String: Any] = ["userId": KMMemberInfo.shared.userID,
+                                     "applePayProductId": applePayProductId,
+                                     "transactionId": transactionId,
+                                     "productCode": productCode]
+        KMRequestServer.requestServer.request(urlString: urlString, method: .post, params: params) { requestSerializer in
             requestSerializer.setValue("Bearer " + token, forHTTPHeaderField: "Authorization")
         } completion: { [weak self] (task, responseObject, error) in
             var dic: NSDictionary = [:]

+ 3 - 2
PDF Office/PDF Master/MemberCenter/Model/KMMemberInfo.swift

@@ -248,11 +248,12 @@ import Cocoa
             }
 #else
     // AppStore 免费版本
-            if IAPProductsManager.default().allAccessPack6months_lite.isSubscribed == true || IAPProductsManager.default().allAccessPackNew6months_lite.isSubscribed == true ||
+            if IAPProductsManager.default().allAccessPack6months_lite.isSubscribed == true || 
+                IAPProductsManager.default().allAccessPackNew6months_lite.isSubscribed == true ||
                 IAPProductsManager.default().allAccessPack12months_lite.isSubscribed == true ||
                 IAPProductsManager.default().allAccessProduct.isSubscribed == true {
                 // 有旧买断
-                if KMMemberInfo.shared.canTrail {
+                if KMMemberInfo.shared.canTrail && KMMemberInfo.shared.vip_levels == "1" {
                     return .lite_type9
                 }
                 if KMMemberInfo.shared.vip_status == 3 {

+ 103 - 0
PDF Office/PDF Master/MemberCenter/ViewModel/KMProductModel.swift

@@ -471,6 +471,109 @@ class KMProductModel: ObservableObject {
         }
     }
     
+    func appStoreEquityVerification(_ notification: Notification,_ complete: @escaping KMMemberProductComplete) -> Void {
+        if let userInfo = notification.userInfo,
+           let transactionId = userInfo["transactionId"] as? String,
+           let productId = userInfo["productId"] as? String {
+            print("Transaction ID: \(transactionId)")
+            print("product ID: \(productId)")
+            
+            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 {
+                    isSubscribed = true
+                }
+            } else if productId == "com.pdfreaderpro.mac_free.member.all_access_pack_advanced_annual.001" {
+                productCode = "advanced-annual-subscription"
+                if IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite.isSubscribed {
+                    isSubscribed = true
+                }
+            } else if productId == "com.pdfreaderpro.mac_free.member.all_access_pack_new_6months.001" {
+                productCode = "advanced-annual-subscription-six-month"
+                if IAPProductsManager.default().allAccessPackNew6months_lite.isSubscribed {
+                    isSubscribed = true
+                }
+            } else if productId == "com.pdfreaderpro.mac_free.member.all_access_pack_12months.001" {
+                productCode = "advanced-annual-subscription"
+                if IAPProductsManager.default().allAccessPack12months_lite.isSubscribed {
+                    isSubscribed = true
+                }
+            } else if productId == "com.pdfreaderpro.mac_free.member.all_access_pack_6months.001" {
+                productCode = "advanced-annual-subscription-six-month"
+                if IAPProductsManager.default().allAccessPack6months_lite.isSubscribed {
+                    isSubscribed = true
+                }
+            } else if productId == "com.pdfreaderpro.mac_free.member.ai_pack_1_month" {
+                productCode = "ai-subscription-month"
+                if IAPProductsManager.default().aiAllAccessPack1month_lite.isSubscribed {
+                    isSubscribed = true
+                }
+            } else if productId == "com.pdfreaderpro.mac_free.member.ai_pack_12_month" {
+                productCode = "ai-subscription-year-trail"
+                if IAPProductsManager.default().aiAllAccessPack12month_lite.isSubscribed {
+                    isSubscribed = true
+                }
+            } else if productId == "com.pdfreaderpro.mac_free.member.all_access_pack_advanced_permanent_license.001" {
+                productCode = "advanced-permanent"
+                if IAPProductsManager.default().allAccessPackPermanent_lite.isSubscribed {
+                    isSubscribed = true
+                }
+            } else if productId == "com.pdfreaderpro.mac_free.member.advanced_add_devices_all_access_pack_advanced_annual.001" {
+                productCode = "advanced-annual-subscription-single-upgrade"
+                if IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_lite.isSubscribed {
+                    isSubscribed = true
+                }
+            } else if productId == "com.pdfreaderpro.mac_free.member.advanced_add_2_devices_all_access_pack_advanced_annual.001" {
+                productCode = "advanced-annual-subscription-multi-upgrade"
+                if IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_lite.isSubscribed {
+                    isSubscribed = true
+                }
+            }
+#endif
+#else
+    // AppStore 付费版
+            if productId == "com.pdfreaderpro.mac.ai_pack_1_month" {
+                productCode = "ai-subscription-month"
+                if IAPProductsManager.default().aiAllAccessPack1month_pro.isSubscribed {
+                    isSubscribed = true
+                }
+            } else if productId == "com.pdfreaderpro.mac.ai_pack_12_month" {
+                productCode = "ai-subscription-year-trail"
+                if IAPProductsManager.default().aiAllAccessPack12month_pro.isSubscribed {
+                    isSubscribed = true
+                }
+            } else if productId == "com.pdfreaderpro.mac.pdf_to_office_pack_permanent_license.001" {
+                productCode = "advanced-permanent-mac-upgrade"
+                if IAPProductsManager.default().pdfToOfficePackPermanent_pro.isSubscribed {
+                    isSubscribed = true
+                }
+            } else if productId == "com.pdfreaderpro.mac.all_access_pack_advanced_annual.001" {
+                productCode = "advanced-permanent-mac-upgrade"
+                if IAPProductsManager.default().fourDevicesAllAccessPack12months_pro.isSubscribed {
+                    isSubscribed = true
+                }
+            }
+#endif
+            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.")
+        }
+    }
+    
     var isCancelAutoRenew: Bool {
         return IAPProductsManager.default().isCancelAutoRenew()
     }

+ 5 - 0
PDF Office/PDF Master/MemberCenter/WindowsController/KMProductCompareWC.swift

@@ -1039,6 +1039,11 @@ class KMProductCompareWC: NSWindowController {
     @objc func IAPProductPurchasedNotification(_ notification: Notification) {
         removeWaitingView(from: window?.contentView ?? NSView())
         reloadData()
+        
+        model.appStoreEquityVerification(notification) { success, msg in
+            KMUserInfoVCModel().refreshUserInfo { success, msg in
+            }
+        }
 
         if IAPProductsManager.default().fourDevicesAllAccessPackNew6Months_lite.isSubscribed {
             if kEventTag == 1 {