Browse Source

【fix】【退订】退订后重启app后,退订弹窗选择价格过高, 不会弹出优惠券

tangchao 1 month ago
parent
commit
b8464cd544

+ 5 - 5
PDF Office/PDF Master/AppDelegate.swift

@@ -144,7 +144,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, iRateDelegate {
                     KMNewUserGiftManager.default.loginProgressState = .success
                     let cnt = KMCancelSubscribeSuccessWindowController.shared.couponsShowCount()
                     if cnt == 1 { // 有显示过
-                        if KMCancelSubscribeSuccessWindowController.shared.appLaunchCountOfCoupons() == 3 {
+                        if KMCancelSubscribeSuccessWindowController.shared.appLaunchCountOfCoupons() == 2 {
                             KMMemberCenterManager.judgeTrailCancel { success, resultModel, error in
                                 if success && resultModel?.result == true { // 试用退订
                                     KMCancelSubscribeSuccessWindowController.shared.openCouponsWindow()
@@ -192,10 +192,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, iRateDelegate {
                                                   platform: .Mac)
         //        测试模式,默认false
         KMAdvertisementManager.manager.debug = true
-
-        if KMCancelSubscribeSuccessWindowController.shared.couponsShowCount() == 1 {
-            KMCancelSubscribeSuccessWindowController.shared.recordAppLaunchCountOfCoupons()
-        }
         
         self.initMainMenu()
         /// pro
@@ -267,6 +263,10 @@ class AppDelegate: NSObject, NSApplicationDelegate, iRateDelegate {
     func openWindowsForAppLaunch() {}
     
     func openWindowsForLogin() {
+        if KMCancelSubscribeSuccessWindowController.shared.couponsShowCount() == 1 {
+            KMCancelSubscribeSuccessWindowController.shared.recordAppLaunchCountOfCoupons()
+        }
+        
         if KMWinBackWindowController.shared.needShow() {
             KMWinBackWindowController.shared.openWindow()
         }

+ 33 - 7
PDF Office/PDF Master/Class/Account/CancelSubscribe/Window/KMCancelSubscribeSuccessWindowController.swift

@@ -198,7 +198,7 @@ let kKMAdvancedYearSubscribedOfTrial            = "KMAdvancedYearSubscribedOfTri
             return
         }
         let member = KMMemberInfo.shared
-        if (IAPProductsManager.default().isAvailableAllFunction() || member.userScenarioType == .lite_type8) { // 本地有权益
+        if (IAPProductsManager.default().isAvailableAllFunction() && member.userScenarioType != .lite_type8) { // 本地有权益
             return
         }
         
@@ -254,21 +254,47 @@ let kKMAdvancedYearSubscribedOfTrial            = "KMAdvancedYearSubscribedOfTri
     }
     
     public func recordCouponsShow() {
-        let cnt = KMDataManager.ud_integer(forKey: couponsShowCountKey_)
-        KMDataManager.ud_set(cnt+1, forKey: couponsShowCountKey_)
+        let member = KMMemberInfo.shared
+        if member.isLogin && member.userEmail.isEmpty == false {
+            let key = member.userEmail+couponsShowCountKey_
+            let cnt = KMDataManager.ud_integer(forKey: key)
+            KMDataManager.ud_set(cnt+1, forKey: key)
+        } else {
+            let cnt = KMDataManager.ud_integer(forKey: couponsShowCountKey_)
+            KMDataManager.ud_set(cnt+1, forKey: couponsShowCountKey_)
+        }
     }
     
     public func couponsShowCount() -> Int {
-        return KMDataManager.ud_integer(forKey: couponsShowCountKey_)
+        let member = KMMemberInfo.shared
+        if member.isLogin && member.userEmail.isEmpty == false {
+            let key = member.userEmail+couponsShowCountKey_
+            return KMDataManager.ud_integer(forKey: key)
+        } else {
+            return KMDataManager.ud_integer(forKey: couponsShowCountKey_)
+        }
     }
     
     public func recordAppLaunchCountOfCoupons() {
-        let cnt = KMDataManager.ud_integer(forKey: appLaunchCountOfCouponsKey_)
-        KMDataManager.ud_set(cnt+1, forKey: appLaunchCountOfCouponsKey_)
+        let member = KMMemberInfo.shared
+        if member.isLogin && member.userEmail.isEmpty == false {
+            let key = member.userEmail+appLaunchCountOfCouponsKey_
+            let cnt = KMDataManager.ud_integer(forKey: key)
+            KMDataManager.ud_set(cnt+1, forKey: key)
+        } else {
+            let cnt = KMDataManager.ud_integer(forKey: appLaunchCountOfCouponsKey_)
+            KMDataManager.ud_set(cnt+1, forKey: appLaunchCountOfCouponsKey_)
+        }
     }
     
     public func appLaunchCountOfCoupons() -> Int {
-        return KMDataManager.ud_integer(forKey: appLaunchCountOfCouponsKey_)
+        let member = KMMemberInfo.shared
+        if member.isLogin && member.userEmail.isEmpty == false {
+            let key = member.userEmail+appLaunchCountOfCouponsKey_
+            return KMDataManager.ud_integer(forKey: key)
+        } else {
+            return KMDataManager.ud_integer(forKey: appLaunchCountOfCouponsKey_)
+        }
     }
     
     // MARK: - Actions

+ 15 - 16
PDF Office/PDF Master/MemberCenter/Model/KMMemberInfo.swift

@@ -1021,23 +1021,22 @@ import Cocoa
                     productCompareShow()
                 }
 #else
-                let member = KMMemberInfo.shared
-                let man = KMNewUserGiftManager.default
-                let type = member.userScenarioType
-                if man.needShow() && member.isFreeAccount {
-                    let winC = KMProductCompareWC.shared
-                    winC.orientation = true
-                    winC.orientationType = .lite_Base
-                    winC.openWindow(discountType: .newUserGift)
-                } else if (member.isMemberAllFunction == false || type == .lite_type8) && KMCheckInManager.default.trailCancel {
-                    let winC = KMProductCompareWC.shared
-                    winC.orientation = true
-                    winC.orientationType = .lite_Base
-                    winC.openWindow(discountType: .advancedYearSubscribeTrialingCancel)
-                } else {
+//                let member = KMMemberInfo.shared
+//                let man = KMNewUserGiftManager.default
+//                let type = member.userScenarioType
+//                if man.needShow() && member.isFreeAccount {
+//                    let winC = KMProductCompareWC.shared
+//                    winC.orientation = true
+//                    winC.orientationType = .lite_Base
+//                    winC.openWindow(discountType: .newUserGift)
+//                } else if (member.isMemberAllFunction == false || type == .lite_type8) && KMCheckInManager.default.trailCancel {
+//                    let winC = KMProductCompareWC.shared
+//                    winC.orientation = true
+//                    winC.orientationType = .lite_Base
+//                    winC.openWindow(discountType: .advancedYearSubscribeTrialingCancel)
+//                } else {
                     productCompareShow()
-                }
-                
+//                }
 #endif
 #else
                 productCompareShow()

+ 3 - 2
PDF Office/PDF Master/MemberCenter/ViewModel/KMProductModel.swift

@@ -1347,8 +1347,8 @@ class KMProductModel: ObservableObject {
         }
         
         if transactionId.isEmpty == false && productId.isEmpty == false {
-            print("Transaction ID: \(transactionId)")
-            print("product ID: \(productId)")
+            KMPrint("Transaction ID: \(transactionId)")
+            KMPrint("product ID: \(productId)")
             
             var productCode = ""
             var isSubscribed = false
@@ -1364,6 +1364,7 @@ class KMProductModel: ObservableObject {
                 } else {
                     productCode = "advanced-annual-subscription"
                 }
+                KMPrint("productCode: \(productCode)")
                 if IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite.isSubscribed {
                     isSubscribed = true
                 }

+ 2 - 2
PDF Office/PDF Master/MemberCenter/WindowsController/KMProductCompareWC.swift

@@ -1613,8 +1613,8 @@ import Combine
                     } else {
                         let member = KMMemberInfo.shared
                         if member.is_advanced_year_subscribe() && member.is_trailing() {
-//                            showAlert(message: NSLocalizedString("kkkkkkk", comment: ""))
-//                            return
+                            showAlert(message: NSLocalizedString("You are in a 7-day free trial. Please purchase the product after it expires.", comment: ""))
+                            return false
                         }
                     }
 #endif