Browse Source

【会员系统】DMG 购买结算界面商品价格串接

zenghong 1 week ago
parent
commit
cc31ad5a11

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

@@ -128,14 +128,14 @@ class AppDelegate: NSObject, NSApplicationDelegate, iRateDelegate{
                         KMMemberInfo.shared.isLogin = false
                     }
 #if VERSION_DMG
-            let model = KMProductModel()
-            model.getDMGProductDatas()
+                    let model = KMProductModel.shared
+                    model.getDMGProductDatas()
 #endif
                 }
             }
         } else {
 #if VERSION_DMG
-            let model = KMProductModel()
+            let model = KMProductModel.shared
             model.getDMGProductDatas()
 #endif
         }

+ 240 - 43
PDF Office/PDF Master/Class/Purchase/DMG/KMPurchaseEmbeddedWindowController.swift

@@ -238,6 +238,8 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
     private var license1 = ""
     private var licenseAI1 = ""
     private var isApplyCoupon: Bool = false
+    
+    private var isWindowDidLoad: Bool = false
 
     @objc static func currentWC(_ productInfo: KMListingProductsModel) -> KMPurchaseEmbeddedWindowController {
         if currentWindowController != nil {
@@ -280,8 +282,59 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
         confirmPayment(isConfirm: false)
         self.window?.delegate = self;
         
+        isWindowDidLoad = true
+    }
+    
+    override func close() {
+        super.close()
+        
+        self.clearEventData()
+    }
+    
+    // MARK: DMG Action
+    func isMoreCountViewShouldHidden(_ productinfo: KMListingProductsModel) -> Bool {
+        //买断版本才能一次购买多个,并且购买多个时,不会自动绑定,需要在后台给自己绑定才能有会员权益
+        if productinfo.paymentModel == 2 {
+            return false
+        }
+        return true
+    }
+    
+    func updateKMDMGProductType(_ productinfo: KMListingProductsModel) -> Void {
+        switch productinfo.code {
+        case "advanced-annual-subscription-trail":
+            _dmgProductType = .advanced_annual_subscription_trail
+            break
+        case "standard-annual-subscription":
+            _dmgProductType = .standard_annual_subscription
+            break
+        case "advanced-annual-subscription":
+            _dmgProductType = .advanced_annual_subscription
+            break
+        case "advanced-permanent":
+            _dmgProductType = .advanced_permanent
+            break
+        case "ai-subscription-month":
+            _dmgProductType = .ai_subscription_month
+            break
+        case "ai-subscription-year-trail":
+            _dmgProductType = .ai_subscription_year_trail
+            break
+        case "advanced-permanent-blackFive":
+            _dmgProductType = .advanced_permanent_blackFive
+            break
+        case "advanced-annual-subscription-blackFive":
+            _dmgProductType = .advanced_annual_subscription_blackFive
+            break
+        default:
+            _dmgProductType = .advanced_annual_subscription_trail
+            break
+        }
+    }
+    
+    func updateProduct_Info() -> Void {
         if KMMemberInfo.shared.isLogin {
-            let model = KMProductModel()
+            let model = KMProductModel.shared
             model.getDMGProductPriceInfosForMember(productId: product_Info.id, isEducation: 0) { [weak self] success, result in
                 if success {
                     guard let productResults : KMMemberProductResult = result else {
@@ -304,21 +357,6 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
         }
     }
     
-    override func close() {
-        super.close()
-        
-        self.clearEventData()
-    }
-    
-    // MARK: DMG Action
-    func isMoreCountViewShouldHidden(_ productinfo: KMListingProductsModel) -> Bool {
-        //买断版本才能一次购买多个,并且购买多个时,不会自动绑定,需要在后台给自己绑定才能有会员权益
-        if productinfo.paymentModel == 2 {
-            return false
-        }
-        return true
-    }
-    
     // MARK: UI
     
     private func xibInitialization() -> Void {
@@ -365,6 +403,55 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
             let productName = product_Info.productName
             pdfReaderProLabel.stringValue = productName
         }
+        if _dmgProductType == .standard_annual_subscription {
+            aiAddOnView.isHidden = true
+            extendedView.isHidden = true
+            
+            let productName = product_Info.productName
+            pdfReaderProLabel.stringValue = productName
+        }
+        if _dmgProductType == .advanced_annual_subscription {
+            aiAddOnView.isHidden = true
+            extendedView.isHidden = true
+            
+            let productName = product_Info.productName
+            pdfReaderProLabel.stringValue = productName
+        }
+        if _dmgProductType == .advanced_permanent {
+            aiAddOnView.isHidden = true
+            extendedView.isHidden = true
+            
+            let productName = product_Info.productName
+            pdfReaderProLabel.stringValue = productName
+        }
+        if _dmgProductType == .ai_subscription_month {
+            aiAddOnView.isHidden = true
+            extendedView.isHidden = true
+            
+            let productName = product_Info.productName
+            pdfReaderProLabel.stringValue = productName
+        }
+        if _dmgProductType == .ai_subscription_year_trail {
+            aiAddOnView.isHidden = true
+            extendedView.isHidden = true
+            
+            let productName = product_Info.productName
+            pdfReaderProLabel.stringValue = productName
+        }
+        if _dmgProductType == .advanced_permanent_blackFive {
+            aiAddOnView.isHidden = true
+            extendedView.isHidden = true
+            
+            let productName = product_Info.productName
+            pdfReaderProLabel.stringValue = productName
+        }
+        if _dmgProductType == .advanced_annual_subscription_blackFive {
+            aiAddOnView.isHidden = true
+            extendedView.isHidden = true
+            
+            let productName = product_Info.productName
+            pdfReaderProLabel.stringValue = productName
+        }
         
         
 //        if productType == .ipaConvert || productType == .ipaAI {
@@ -610,47 +697,150 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
     }
     
     private func priceRefresh(productsModel: KMListingProductsModel) -> Void {
-        if _dmgProductType == .advanced_annual_subscription_trail {
+        var listPrice: Float = 0.0
+        var discount: Float = 0.0
+        var paySum: Float = 0.0
+        var discount1: Float = 0.0
+        var original1: Float = 0.0
+        var abbreviation = "USD"
+        if NSLocalizedString("USD", comment: "") == "CNY" {
+            abbreviation = "CNY"
+        }
+        
+        if _dmgProductType == .advanced_annual_subscription_trail       ||
+           _dmgProductType == .advanced_annual_subscription_blackFive   ||
+           _dmgProductType == .advanced_permanent_blackFive   ||
+           _dmgProductType == .ai_subscription_year_trail {
+            // 全平台高级版年订阅             99.9 美金,带免费试用
+            // 全平台高级版年订阅             99.9 美金,黑五订单
+            // Mac & Win 双平台高级永久      119.99 美金,黑五订单
+            // AI 年订阅                    125.99 美金,带免费试用
             aiAddOnView.isHidden = true
             extendedView.isHidden = true
             
-            let tipsString = NSLocalizedString("%.2@/year, auto-renewal", comment: "")
+            var tipsString = NSLocalizedString("%.2@/year, auto-renewal", comment: "")
+            if product_Info.cycle == 4 {
+                tipsString = NSLocalizedString("%.2@/year, auto-renewal", comment: "")
+            }
+            if product_Info.cycle == 3 {
+                tipsString = NSLocalizedString("%.2@/half a year, auto-renewal", comment: "")
+            }
+            if product_Info.cycle == 2 {
+                tipsString = NSLocalizedString("%.2@/quarter, auto-renewal", comment: "")
+            }
+            if product_Info.cycle == 1 {
+                tipsString = NSLocalizedString("%.2@/monthly, auto-renewal", comment: "")
+            }
+            if product_Info.cycle == 0 {
+                tipsString = NSLocalizedString("%.2@, One time purchase.", comment: "")
+            }
             var fullString = String(format: tipsString, product_Info.price)
             let preferredLanguage = Locale.preferredLanguages.first ?? "en"
             if preferredLanguage.hasPrefix("zh-Hans") || preferredLanguage.hasPrefix("zh-Hant") {
                 fullString = String(format: tipsString, product_Info.cnyPrice)
             }
-            var abbreviation = "USD"
-            if NSLocalizedString("USD", comment: "") == "CNY" {
-                abbreviation = "CNY"
-            }
             
             prmiumLabel.stringValue = String(format: "%@ %@", abbreviation, fullString)
             
-            var listPrice: Float = 0.0
-            var discount: Float = 0.0
-            var paySum: Float = 0.0
-            var discount1: Float = product_Info.displayPrice.floatValue
-            var original1: Float = product_Info.price.floatValue
+            discount1 = product_Info.displayPrice.floatValue
+            original1 = product_Info.price.floatValue
             if preferredLanguage.hasPrefix("zh-Hans") || preferredLanguage.hasPrefix("zh-Hant") {
                 discount1 = product_Info.displayCnyPrice.floatValue
                 original1 = product_Info.cnyPrice.floatValue
             }
+            
             listPrice = original1 * Float(amountTextField1.stringValue)!
             paySum = discount1 * Float(amountTextField1.stringValue)!
             discount = listPrice - paySum
+        }
+        
+        if _dmgProductType == .advanced_annual_subscription  ||
+           _dmgProductType == .standard_annual_subscription  ||
+           _dmgProductType == .advanced_permanent  ||
+           _dmgProductType == .ai_subscription_month {
+            // 全平台高级版年订阅             99.9 美金,无试用
+            // 全平台标准版年订阅             79.9 美金
+            // Mac & Win 双平台高级永久      119.99 美金
+            // AI 月订阅                    14.99 美金
+            aiAddOnView.isHidden = true
+            extendedView.isHidden = true
             
-            originalPriceLabel1.stringValue = String(format: "%@ %@", abbreviation, String(format: "%.2f", discount1))
-            if String(format: "%.2f", original1) == String(format: "%.2f", discount1) {
-                discountPriceLabel1.isHidden = true
+            var tipsString = NSLocalizedString("%.2@/year, auto-renewal", comment: "")
+            if product_Info.cycle == 4 {
+                tipsString = NSLocalizedString("%.2@/year, auto-renewal", comment: "")
+            }
+            if product_Info.cycle == 3 {
+                tipsString = NSLocalizedString("%.2@/half a year, auto-renewal", comment: "")
+            }
+            if product_Info.cycle == 2 {
+                tipsString = NSLocalizedString("%.2@/quarter, auto-renewal", comment: "")
+            }
+            if product_Info.cycle == 1 {
+                tipsString = NSLocalizedString("%.2@/monthly, auto-renewal", comment: "")
+            }
+            if product_Info.cycle == 0 {
+                tipsString = NSLocalizedString("%.2@, One time purchase.", comment: "")
+            }
+            var fullString = String(format: tipsString, product_Info.price)
+            let preferredLanguage = Locale.preferredLanguages.first ?? "en"
+            if preferredLanguage.hasPrefix("zh-Hans") || preferredLanguage.hasPrefix("zh-Hant") {
+                fullString = String(format: tipsString, product_Info.cnyPrice)
+            }
+            
+            prmiumLabel.stringValue = String(format: "%@ %@", abbreviation, fullString)
+            
+            discount1 = product_Info.price.floatValue //优惠价格拿原价
+            original1 = product_Info.price.floatValue
+            if preferredLanguage.hasPrefix("zh-Hans") || preferredLanguage.hasPrefix("zh-Hant") {
+                discount1 = product_Info.cnyPrice.floatValue  //优惠价格拿原价
+                original1 = product_Info.cnyPrice.floatValue
+            }
+            
+            listPrice = original1 * Float(amountTextField1.stringValue)!
+            paySum = discount1 * Float(amountTextField1.stringValue)!
+            discount = listPrice - paySum
+        }
+        
+        originalPriceLabel1.stringValue = String(format: "%@ %@", abbreviation, String(format: "%.2f", discount1))
+        if String(format: "%.2f", original1) == String(format: "%.2f", discount1) {
+            discountPriceLabel1.isHidden = true
+        } else {
+            discountPriceLabel1.isHidden = false
+            let attributedString = NSMutableAttributedString(string: String(format: "%@ %@", abbreviation, String(format: "%.2f", original1)))
+            attributedString.addAttribute(.strikethroughStyle, value: NSNumber(value: NSUnderlineStyle.single.rawValue), range: NSMakeRange(0, attributedString.length))
+            attributedString.addAttribute(.strikethroughColor, value: NSColor(named: "KMPurchaseDiscountColor") as Any, range: NSMakeRange(0, attributedString.length))
+            discountPriceLabel1.attributedStringValue = attributedString
+        }
+        
+        if self.discountScale != "" || self.discountAmount != "" {
+            if self.discountScale != "" {
+                paySum = paySum * Float(self.discountScale)!
+                discount = listPrice - paySum
             } else {
-                discountPriceLabel1.isHidden = false
-                let attributedString = NSMutableAttributedString(string: String(format: "%.2f", original1))
-                attributedString.addAttribute(.strikethroughStyle, value: NSNumber(value: NSUnderlineStyle.single.rawValue), range: NSMakeRange(0, attributedString.length))
-                attributedString.addAttribute(.strikethroughColor, value: NSColor(named: "KMPurchaseDiscountColor") as Any, range: NSMakeRange(0, attributedString.length))
-                discountPriceLabel1.attributedStringValue = attributedString
+                var discountAmountF = Float(self.discountAmount)
+                if NSLocalizedString("USD", comment: "") == "CNY" {
+                    discountAmountF = discountAmountF! * 6.5
+                }
+                paySum = paySum - discountAmountF!
+                discount = listPrice - paySum
+            }
+        }
+        lastPriceLabel1.stringValue = String(format: "%@ %@", abbreviation, String(format: "%.2f", listPrice))
+        discountLabel1.stringValue = String(format: "%@ %@", abbreviation, String(format: "%.2f", discount))
+        paySumLabel1.stringValue = String(format: "%@ %@", abbreviation, String(format: "%.2f", paySum))
+        
+        if discount == 0 {
+            discountView.isHidden = true
+            couponView.isHidden = false
+        } else {
+            discountView.isHidden = false
+            if self.discountScale == "" && self.discountAmount == "" {
+                couponView.isHidden = true
+            } else {
+                couponView.isHidden = false
             }
         }
+        discountLayoutConstraint.constant = discountView.isHidden ? -CGRectGetHeight(discountView.bounds) : 8
     }
     
     private func priceRefresh() -> Void {
@@ -1311,10 +1501,14 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
         }
         set {
             _product_Info = newValue
-            xibInitialization()
-            priceRefresh(productsModel: _product_Info)
-            
-            confirmPayment(isConfirm: false)
+            updateKMDMGProductType(_product_Info)
+            if isWindowDidLoad {
+                
+                xibInitialization()
+                priceRefresh(productsModel: _product_Info)
+                
+                confirmPayment(isConfirm: false)
+            }
         }
     }
     
@@ -1324,10 +1518,13 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
         }
         set {
             _dmgProductType = newValue
-            xibInitialization()
-            priceRefresh()
-            
-            confirmPayment(isConfirm: false)
+            if isWindowDidLoad {
+                
+                xibInitialization()
+                priceRefresh(productsModel: _product_Info)
+                
+                confirmPayment(isConfirm: false)
+            }
         }
     }
     

+ 26 - 26
PDF Office/PDF Master/MemberCenter/Model/KMMemberCenterManager.swift

@@ -874,7 +874,7 @@ class KMMemberCenterManager: NSObject {
                     }
                     dic = (info as? NSDictionary) ?? [:]
                 }
-                let code: Int = dic["code"] as? Int ?? 0
+                let requestCode: Int = dic["code"] as? Int ?? 0
                 let result_Array: [NSDictionary] = dic["result"] as? [NSDictionary] ?? [[:]]
                 let message: String = dic["msg"] as? String ?? ""
                 
@@ -919,8 +919,8 @@ class KMMemberCenterManager: NSObject {
                     results.append(products)
                 }
 
-                let result = KMMemberProductResult(code: code, msg: message, listingProducts: results)
-                if code == 200 {
+                let result = KMMemberProductResult(code: requestCode, msg: message, listingProducts: results)
+                if requestCode == 200 {
                     complete(true, result)
                 } else {
                     complete(false, result)
@@ -960,7 +960,7 @@ class KMMemberCenterManager: NSObject {
                     }
                     dic = (info as? NSDictionary) ?? [:]
                 }
-                let code: Int = dic["code"] as? Int ?? 0
+                let requestCode: Int = dic["code"] as? Int ?? 0
                 let result_Array: [NSDictionary] = [dic["result"]] as? [NSDictionary] ?? [[:]]
                 let message: String = dic["msg"] as? String ?? ""
                 
@@ -1004,8 +1004,8 @@ class KMMemberCenterManager: NSObject {
                     results.append(products)
                 }
 
-                let result = KMMemberProductResult(code: code, msg: message, listingProducts: results)
-                if code == 200 {
+                let result = KMMemberProductResult(code: requestCode, msg: message, listingProducts: results)
+                if requestCode == 200 {
                     complete(true, result)
                 } else {
                     complete(false, result)
@@ -1045,7 +1045,7 @@ class KMMemberCenterManager: NSObject {
                     }
                     dic = (info as? NSDictionary) ?? [:]
                 }
-                let code: Int = dic["code"] as? Int ?? 0
+                let requestCode: Int = dic["code"] as? Int ?? 0
                 let result: NSDictionary = dic["result"] as? NSDictionary ?? [:]
                 let message: String = dic["msg"] as? String ?? ""
                 
@@ -1065,8 +1065,8 @@ class KMMemberCenterManager: NSObject {
                 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)
-                if code == 200 {
+                let result1 = KMMemberProductResult(code: requestCode, msg: message, batchProductPrice: products)
+                if requestCode == 200 {
                     complete(true, result1)
                 } else {
                     complete(false, result1)
@@ -1187,7 +1187,7 @@ class KMMemberCenterManager: NSObject {
                     }
                     dic = (info as? NSDictionary) ?? [:]
                 }
-                let code: Int = dic["code"] as? Int ?? 0
+                let requestCode: Int = dic["code"] as? Int ?? 0
                 let result: NSDictionary = dic["result"] as? NSDictionary ?? [:]
                 let message: String = dic["msg"] as? String ?? ""
                 
@@ -1207,8 +1207,8 @@ class KMMemberCenterManager: NSObject {
                 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)
-                if code == 200 {
+                let result1 = KMMemberProductResult(code: requestCode, msg: message, batchProductPrice: products)
+                if requestCode == 200 {
                     complete(true, result1)
                 } else {
                     complete(false, result1)
@@ -1253,8 +1253,8 @@ class KMMemberCenterManager: NSObject {
                     }
                     dic = (info as? NSDictionary) ?? [:]
                 }
-                let code: Int = dic["code"] as? Int ?? 0
-                if code == 200 {
+                let requestCode: Int = dic["code"] as? Int ?? 0
+                if requestCode == 200 {
                     complete(true, dic)
                 } else {
                     complete(false, dic)
@@ -1304,22 +1304,22 @@ class KMMemberCenterManager: NSObject {
                 }
                 dic = (info as? NSDictionary) ?? [:]
             }
-            let code: Int = dic["code"] as? Int ?? 0
+            let requestCode: 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 requestCode == 200 {
                 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)
+                let result1 = KMMemberProductResult(code: requestCode, msg: message, createOrder: products)
                 complete(true, result1)
             } else {
-                let result1 = KMMemberProductResult(code: code, msg: message, createOrder: KMCreateOrderModel(thirdOrderNo: thirdOrderNo, orderId: orderId, payHref: payHref))
+                let result1 = KMMemberProductResult(code: requestCode, msg: message, createOrder: KMCreateOrderModel(thirdOrderNo: thirdOrderNo, orderId: orderId, payHref: payHref))
                 complete(false, result1)
             }
         }
@@ -1363,22 +1363,22 @@ class KMMemberCenterManager: NSObject {
                 }
                 dic = (info as? NSDictionary) ?? [:]
             }
-            let code: Int = dic["code"] as? Int ?? 0
+            let requestCode: 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 requestCode == 200 {
                 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)
+                let result1 = KMMemberProductResult(code: requestCode, msg: message, createOrder: products)
                 complete(true, result1)
             } else {
-                let result1 = KMMemberProductResult(code: code, msg: message, createOrder: KMCreateOrderModel(thirdOrderNo: thirdOrderNo, orderId: orderId, payHref: payHref))
+                let result1 = KMMemberProductResult(code: requestCode, msg: message, createOrder: KMCreateOrderModel(thirdOrderNo: thirdOrderNo, orderId: orderId, payHref: payHref))
                 complete(false, result1)
             }
         }
@@ -1413,8 +1413,8 @@ class KMMemberCenterManager: NSObject {
                     }
                     dic = (info as? NSDictionary) ?? [:]
                 }
-                let code: Int = dic["code"] as? Int ?? 0
-                if code == 200 {
+                let requestCode: Int = dic["code"] as? Int ?? 0
+                if requestCode == 200 {
                     complete(true, dic)
                 } else {
                     complete(false, dic)
@@ -1468,9 +1468,9 @@ class KMMemberCenterManager: NSObject {
                     }
                     dic = (info as? NSDictionary) ?? [:]
                 }
-                let code: Int = dic["code"] as? Int ?? 0
+                let requestCode: Int = dic["code"] as? Int ?? 0
 
-                if code == 200 {
+                if requestCode == 200 {
                     complete(true, dic)
                 } else {
                     complete(false, dic)

+ 5 - 0
PDF Office/PDF Master/MemberCenter/Model/KMMemberProductResult.swift

@@ -112,6 +112,11 @@ class KMListingProductsModel: NSObject {
         self.cnyPrice = cnyPrice
         self.displayCnyPrice = displayCnyPrice
         self.upgradePrice = upgradePrice
+        self.code = code
+    }
+    
+    override init() {
+        
     }
 }
 

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

@@ -52,6 +52,7 @@ typealias AppstorePurchaseComplete = (_ success: Bool,_ msg: String) -> Void
 
 @objcMembers
 class KMProductModel: ObservableObject {
+    static let shared = KMProductModel()
     /**
      比较表类型
      */

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

@@ -129,7 +129,7 @@ class KMProductCompareWC: NSWindowController {
     @IBOutlet @objc weak var platformsView4: NSView!
 
     
-    private var model = KMProductModel()
+    private var model = KMProductModel.shared
     private var cancellables = Set<AnyCancellable>()
     
     var orientation: Bool = false // 是否定向跳转
@@ -1029,7 +1029,30 @@ class KMProductCompareWC: NSWindowController {
     
     @IBAction func appstorePurchaseAction(_ sender: NSButton) {
 #if VERSION_DMG
-        let embeddedWC = KMPurchaseEmbeddedWindowController.currentFirstTrialWC("com.brother.pdfreaderpro.mac.product_2")
+        let model = KMProductModel.shared
+        
+        var product : KMListingProductsModel?
+        let productsWithMember : [KMListingProductsModel] = model.dmgLastGetProductPriceInfos?.listingProducts ?? []
+        let products : [KMListingProductsModel] = model.dmgProductDatas?.listingProducts ?? []
+        if KMMemberInfo.shared.isLogin {
+            if productsWithMember.count > 0{
+                product = productsWithMember.first
+            } else {
+                if products.count > 0{
+                    product = products[3]
+                } else {
+                    product = KMListingProductsModel()
+                }
+            }
+        } else {
+            if products.count > 0{
+                product = products.first
+            } else {
+                product = KMListingProductsModel()
+            }
+        }
+        
+        let embeddedWC = KMPurchaseEmbeddedWindowController.currentWC(product ?? KMListingProductsModel())
         embeddedWC.showWindow(nil)
         embeddedWC.window?.center()
 #else