3 Commity d66451c9b4 ... 013330b320

Autor SHA1 Wiadomość Data
  zenghong 013330b320 Merge branch 'develop_PDFReaderPro_V4.7.0' of git.kdan.cc:Mac_PDF/PDF_Office into develop_PDFReaderPro_V4.7.0 1 tydzień temu
  zenghong cc31ad5a11 【会员系统】DMG 购买结算界面商品价格串接 1 tydzień temu
  zenghong 404bcbc750 【会员系统】DMG 购买结算界面商品展示串接 1 tydzień temu

+ 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
         }

+ 291 - 29
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 {
@@ -275,10 +277,12 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
         
         xibInitialization()
         paymentMethod = .paypal
-        priceRefresh()
+        priceRefresh(productsModel: product_Info)
         
         confirmPayment(isConfirm: false)
         self.window?.delegate = self;
+        
+        isWindowDidLoad = true
     }
     
     override func close() {
@@ -296,6 +300,63 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
         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.shared
+            model.getDMGProductPriceInfosForMember(productId: product_Info.id, isEducation: 0) { [weak self] success, result in
+                if success {
+                    guard let productResults : KMMemberProductResult = result else {
+                        return
+                    }
+                    guard let products : [KMListingProductsModel] = productResults.listingProducts else {
+                        return
+                    }
+                    guard let product : KMListingProductsModel = products.first else {
+                        return
+                    }
+                    self?.product_Info = product;
+                    for tProduct in products {
+                        if tProduct.id == self?.product_Info.id {
+                            self?.product_Info = tProduct;
+                        }
+                    }
+                }
+            }
+        }
+    }
+    
     // MARK: UI
     
     private func xibInitialization() -> Void {
@@ -316,33 +377,80 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
         refreshLicenseCodeView(isReveal: false)
         usualAddCountView.isHidden = isMoreCountViewShouldHidden(product_Info)
         
+        oneLicenseLabel.stringValue = NSLocalizedString("and more offline. It's one time purchase.", comment: "")
+        oneLicenseLabel.isHidden = true
+        
+        licenseCodeLabel.stringValue = NSLocalizedString("License Code", comment: "")
+        licenseCodeLabel.textColor = NSColor(named: "KMPurchaseTitleColor1")
+        licenseCodeLabel.font = NSFont.SFProTextRegularFont(14.0)
+        licenseCodeTextField.placeholderString = NSLocalizedString("Input license code previously activated the app", comment: "")
+        licenseCodeTextField.delegate = self
+        licenseCodeBox.borderColor = NSColor(named: "KMPurchase_DADBDE")!
+        licenseCodeBox.fillColor = NSColor(named: "KMPurchase_FFFFFF")!
+        notFoundButton.title = NSLocalizedString("Not Found?", comment: "")
+        notFoundButton.setTitleColor(color: NSColor(named: "KMPurchaseCouponColor")!, font: NSFont(name: "body-s-regular", size: 14))
+        licenseCodeTextField.stringValue = VerificationManager.default().originLicenseCode ?? ""
+        refreshLicenseCodeView(isReveal: true)
+        licenseCodeErrorLabel.stringValue = NSLocalizedString("Please enter right license code. How to Retrieve License.", comment: "")
+        licenseCodeErrorLabel.textColor = NSColor(named: "KMPurchaseErrorColor")
+        licenseCodeErrorLabel.font = NSFont.SFProTextRegularFont(11.0)
+        refreshLicenseCodeErrorView(isReveal: false)
+        
         if _dmgProductType == .advanced_annual_subscription_trail {
             aiAddOnView.isHidden = true
             extendedView.isHidden = true
             
-            pdfReaderProLabel.stringValue = NSLocalizedString("PDF Reader Pro Standard - Annual Plan", comment: "")
+            let productName = product_Info.productName
+            pdfReaderProLabel.stringValue = productName
+        }
+        if _dmgProductType == .standard_annual_subscription {
+            aiAddOnView.isHidden = true
+            extendedView.isHidden = true
             
-            let tipsString = NSLocalizedString("%.2@/year, auto-renewal", comment: "")
-            let fullString = String(format: tipsString, product_Info.price)
-            prmiumLabel.stringValue = fullString
+            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
             
-//            oneLicenseLabel.stringValue = NSLocalizedString("and more offline. It's one time purchase.", comment: "")
-            licenseCodeLabel.stringValue = NSLocalizedString("License Code", comment: "")
-            licenseCodeLabel.textColor = NSColor(named: "KMPurchaseTitleColor1")
-            licenseCodeLabel.font = NSFont.SFProTextRegularFont(14.0)
-            licenseCodeTextField.placeholderString = NSLocalizedString("Input license code previously activated the app", comment: "")
-            licenseCodeTextField.delegate = self
-            licenseCodeBox.borderColor = NSColor(named: "KMPurchase_DADBDE")!
-            licenseCodeBox.fillColor = NSColor(named: "KMPurchase_FFFFFF")!
-            notFoundButton.title = NSLocalizedString("Not Found?", comment: "")
-            notFoundButton.setTitleColor(color: NSColor(named: "KMPurchaseCouponColor")!, font: NSFont(name: "body-s-regular", size: 14))
-            licenseCodeTextField.stringValue = VerificationManager.default().originLicenseCode ?? ""
-            refreshLicenseCodeView(isReveal: true)
-            licenseCodeErrorLabel.stringValue = NSLocalizedString("Please enter right license code. How to Retrieve License.", comment: "")
-            licenseCodeErrorLabel.textColor = NSColor(named: "KMPurchaseErrorColor")
-            licenseCodeErrorLabel.font = NSFont.SFProTextRegularFont(11.0)
-            refreshLicenseCodeErrorView(isReveal: false)
+            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
         }
         
         
@@ -588,6 +696,153 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
         emailErrorLabel(isReveal: false)
     }
     
+    private func priceRefresh(productsModel: KMListingProductsModel) -> Void {
+        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
+            
+            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.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
+            
+            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 {
+                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 {
         if KMDMGProductsManager.shareInstance.productDatas == nil {
             let alert = NSAlert()
@@ -1246,10 +1501,14 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
         }
         set {
             _product_Info = newValue
-            xibInitialization()
-            priceRefresh()
-            
-            confirmPayment(isConfirm: false)
+            updateKMDMGProductType(_product_Info)
+            if isWindowDidLoad {
+                
+                xibInitialization()
+                priceRefresh(productsModel: _product_Info)
+                
+                confirmPayment(isConfirm: false)
+            }
         }
     }
     
@@ -1259,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