Procházet zdrojové kódy

【会员系统】DMG购买相关逻辑处理

wanjun před 5 dny
rodič
revize
afd43f8f63

+ 38 - 12
PDF Office/PDF Master/MemberCenter/ViewModel/KMProductModel.swift

@@ -173,7 +173,7 @@ class KMProductModel: ObservableObject {
         guard let productModels = dmgProductDatas?.listingProducts else { return "" }
         for model in productModels {
             if model.code == productCode {
-                return model.price.stringValue
+                return String(format: "%.2f", model.price.doubleValue)
             }
         }
         return ""
@@ -185,7 +185,7 @@ class KMProductModel: ObservableObject {
         guard let productModels = dmgProductDatas?.listingProducts else { return "" }
         for model in productModels {
             if model.code == productCode {
-                return model.cnyPrice.stringValue
+                return String(format: "%.2f", model.cnyPrice.doubleValue)
             }
         }
         return ""
@@ -197,7 +197,7 @@ class KMProductModel: ObservableObject {
         guard let productModels = dmgProductDatas?.listingProducts else { return "" }
         for model in productModels {
             if model.code == productCode {
-                return model.displayPrice.stringValue
+                return String(format: "%.2f", model.displayPrice.doubleValue)
             }
         }
         return ""
@@ -209,7 +209,7 @@ class KMProductModel: ObservableObject {
         guard let productModels = dmgProductDatas?.listingProducts else { return "" }
         for model in productModels {
             if model.code == productCode {
-                return model.displayCnyPrice.stringValue
+                return String(format: "%.2f", model.displayCnyPrice.doubleValue)
             }
         }
         return ""
@@ -431,9 +431,17 @@ class KMProductModel: ObservableObject {
             if type == .pdfReaderProStandard_dmg {
                 return getDMGPrice(productCode: "standard-annual-subscription")
             } else if type == .pdfReaderProAdvanced_dmg {
-                return getDMGPrice(productCode: "advanced-annual-subscription")
+                if isBlackFive {
+                    return getDMGPrice(productCode: "advanced-annual-subscription-blackFive")
+                } else {
+                    return getDMGPrice(productCode: "advanced-annual-subscription")
+                }
             } else if type == .pdfReaderProPermanent_dmg {
-                return getDMGPrice(productCode: "advanced-permanent")
+                if isBlackFive {
+                    return getDMGPrice(productCode: "advanced-permanent-blackFive")
+                } else {
+                    return getDMGPrice(productCode: "advanced-permanent")
+                }
             } else if type == .pdfReaderProAIAnnual_dmg {
                 return getDMGPrice(productCode: "ai-subscription-year-trail")
             } else if type == .pdfReaderProAIMonthly_dmg {
@@ -441,9 +449,7 @@ class KMProductModel: ObservableObject {
             } else if type == .pdfToOffice_dmg {
                 return getDMGPrice(productCode: "PDF to Office")
             } else if type == .add2Device_dmg {
-                return getDMGPrice(productCode: "Add 2-Device · Advanced Annual")
             } else if type == .add3Device_dmg {
-                return getDMGPrice(productCode: "Add 3-Device · Advanced Annual")
             }
 #else
     // AppStore 免费版本
@@ -546,9 +552,17 @@ class KMProductModel: ObservableObject {
             if tag == 1 {
                 code = "standard-annual-subscription"
             } else if tag == 3 {
-                code = "advanced-permanent"
+                if isBlackFive {
+                    code = "advanced-permanent-blackFive"
+                } else {
+                    code = "advanced-permanent"
+                }
             } else {
-                code = "advanced-annual-subscription"
+                if isBlackFive {
+                    code = "advanced-annual-subscription-blackFive"
+                } else {
+                    code = "advanced-annual-subscription"
+                }
             }
             #if VERSION_DMG
             let embeddedWC = KMPurchaseEmbeddedWindowController.currentCode(code)
@@ -557,13 +571,13 @@ class KMProductModel: ObservableObject {
             #endif
         } else if state == .dmg_Upgrades1 {
             #if VERSION_DMG
-            let embeddedWC = KMPurchaseEmbeddedWindowController.currentCode("Add 2-Device · Advanced Annual")
+            let embeddedWC = KMPurchaseEmbeddedWindowController.currentCode("advanced-annual-subscription")
             embeddedWC.showWindow(nil)
             embeddedWC.window?.center()
             #endif
         } else if state == .dmg_Upgrades2 {
             #if VERSION_DMG
-            let embeddedWC = KMPurchaseEmbeddedWindowController.currentCode("Add 3-Device · Advanced Annual")
+            let embeddedWC = KMPurchaseEmbeddedWindowController.currentCode("advanced-annual-subscription")
             embeddedWC.showWindow(nil)
             embeddedWC.window?.center()
             #endif
@@ -986,4 +1000,16 @@ class KMProductModel: ObservableObject {
             ]
         }
     }
+    
+    /**
+     是否黑五活动期
+     */
+    var isBlackFive: Bool {
+        if let loginContent = KMAdvertisementManager.manager.info.topRightInfoContent {
+            if loginContent.content?.isEmpty == false {
+                return true
+            }
+        }
+        return false
+    }
 }

+ 23 - 7
PDF Office/PDF Master/MemberCenter/WindowsController/KMProductCompareWC.swift

@@ -363,10 +363,28 @@ class KMProductCompareWC: NSWindowController {
             standardPlanPurchaseLabel.stringValue = model.getProductPrice(.pdfReaderProStandard_dmg)
             advancedPlanPurchaseLabel.stringValue = model.getProductPrice(.pdfReaderProAdvanced_dmg)
             permanentPurchaseLabel.stringValue = model.getProductPrice(.pdfReaderProPermanent_dmg)
-        } else if model.state == .dmg_Upgrades1 {
-            advancedPlanPurchaseLabel.stringValue = model.getProductPrice(.add2Device_dmg)
-        } else if model.state == .dmg_Upgrades2 {
-            advancedPlanPurchaseLabel.stringValue = model.getProductPrice(.add3Device_dmg)
+        } else if model.state == .dmg_Upgrades1 || model.state == .dmg_Upgrades2 {
+            guard let productModels = model.dmgProductDatas?.listingProducts else { return }
+            for productModel in productModels {
+                if productModel.code == "advanced-annual-subscription" {
+                    model.getDMGProductPriceInfosForMember(productId: productModel.id, isEducation: 0) { [weak self] success, result in
+                        guard let self = self else { return }
+                        guard let results: KMMemberProductResult = result else { return }
+                        guard let productModels2 = results.listingProducts else { return }
+                        for productModel2 in productModels2 {
+                            if self.model.isBlackFive == true {
+                                if productModel2.code == "advanced-annual-subscription-blackFive" {
+                                    self.permanentPurchaseLabel.stringValue = String(format: "%.2f", productModel2.upgradePrice.doubleValue)
+                                }
+                            } else {
+                                if productModel2.code == "advanced-annual-subscription" {
+                                    self.permanentPurchaseLabel.stringValue = String(format: "%.2f", productModel2.upgradePrice.doubleValue)
+                                }
+                            }
+                        }
+                    }
+                }
+            }
         } else {
             advancedPlanPurchaseLabel.stringValue = model.getProductPrice(.pdfReaderProAdvanced_dmg)
         }
@@ -1116,9 +1134,7 @@ class KMProductCompareWC: NSWindowController {
             model.appStoreEquityVerification(notification) { success, msg in
                 KMUserInfoVCModel().refreshUserInfo { success, msg,dic  in
                 }
-                DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
-                    self.window?.close()
-                }
+                self.window?.close()
             }
         }
     }