Bläddra i källkod

【综合】整理代码

tangchao 2 månader sedan
förälder
incheckning
9370af0232

+ 3 - 3
PDF Office/PDF Master/Class/Purchase/IAPReceiptModel.h

@@ -143,16 +143,16 @@ NS_ASSUME_NONNULL_BEGIN
 + (BOOL)hasIntroOfferWithModel:(IAPReceiptModel * _Nullable)model withGroupIdentifier:(NSString * _Nullable)groupIdentifier;
 
 // 获取订阅群组的所有票据
-+ (NSArray <IAPReceiptInfoModel *> * _Nullable)fetchReceiptsWithModel:(IAPReceiptModel * _Nullable)model withGroupIdentifier:(NSString * _Nullable)groupIdentifier;
++ (NSArray <IAPReceiptInfoModel *> *)fetchReceiptsWithModel:(IAPReceiptModel * _Nullable)model withGroupIdentifier:(NSString * _Nullable)groupIdentifier;
 
 // 获取对应商品的最后的票据
 + (IAPReceiptInfoModel * _Nullable)fetchProductLastestReceiptsWithModel:(IAPReceiptModel * _Nullable)model withProductId:(NSString * _Nullable)productId;
 
 // 获取对应商品的所有票据
-+ (NSArray <IAPReceiptInfoModel *> * _Nullable)fetchProductReceiptsWithModel:(IAPReceiptModel * _Nullable)model withProductId:(NSString * _Nullable)productId;
++ (NSArray <IAPReceiptInfoModel *> *)fetchProductReceiptsWithModel:(IAPReceiptModel * _Nullable)model withProductId:(NSString * _Nullable)productId;
 
 // 获取所有的票据
-+ (NSArray <IAPReceiptInfoModel *> * _Nullable)fetchReceiptsWithModel:(IAPReceiptModel * _Nullable)model;
++ (NSArray <IAPReceiptInfoModel *> *)fetchReceiptsWithModel:(IAPReceiptModel * _Nullable)model;
 
 @end
 

+ 1 - 1
PDF Office/PDF Master/Class/Purchase/IAPReceiptModel.m

@@ -201,7 +201,7 @@
     return flagM;
 }
 
-+ (NSArray<IAPReceiptInfoModel *> *)fetchProductReceiptsWithModel:(IAPReceiptModel *)model withProductId:(nonnull NSString *)productId {
++ (NSArray<IAPReceiptInfoModel *> *)fetchProductReceiptsWithModel:(IAPReceiptModel *)model withProductId:(NSString *)productId {
     NSMutableArray *results = [NSMutableArray arrayWithCapacity:4];
     for (IAPReceiptInfoModel *m in [self fetchReceiptsWithModel:model]) {
         if ([m.product_id isEqualToString:productId] == false) {

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

@@ -1348,7 +1348,7 @@ class KMProductModel: ObservableObject {
                 }
             } else if productId == "com.pdfreaderpro.mac_free.member.all_access_pack_advanced_annual.001" {
                 let model = IAPReceiptTool.fetchProductLastestReceipts(with: IAPProductsManager.default().receiptModel, withProductId: productId)
-                if model.is_trial_period {
+                if model?.is_trial_period == true {
                     productCode = "advanced-annual-subscription-trail"
                 } else {
                     productCode = "advanced-annual-subscription"

+ 103 - 82
PDF Office/PDF Master/MemberCenter/WindowsController/KMProductCompareWC.swift

@@ -1034,120 +1034,141 @@ import Combine
         
         specialImageView.image = image
         specialImageView1.image = image
-        if KMKdanRemoteConfig.remoteConfig.showAPP_AveragePrice() {
-            if model.isShowSale {
-                value1PurchaseSubLabel.stringValue = String(format: "%@/%@", averageMonthPriceDiscount ?? "", NSLocalizedString("mon", comment: ""))
-                value1PurchaseOriPriceLbl.stringValue = String(format: "%@/%@", averageMonthPrice ?? "", NSLocalizedString("mon", comment: ""))
-                value1PurchaseOriPriceLbl.isHidden = false
-                billedTopConst.constant = 16
-            } else {
-                if let data = introAveragePrice, data.isEmpty == false {
-                    value1PurchaseSubLabel.stringValue = String(format: "%@/%@", data , NSLocalizedString("mon", comment: ""))
+        let showAveragePrice = KMKdanRemoteConfig.remoteConfig.showAPP_AveragePrice()
+        // 商品是否有推介优惠
+        let hasIntroPrice = (introPrice != nil && introPrice?.isEmpty == false)
+        if model.isPurchaseSwitch { // 年订阅
+            let iapProduct = fourDevicesAllAccessPackNew12months_lite
+            if model.isShowSale { // 旧订阅优惠
+                if showAveragePrice {
+                    value1PurchaseSubLabel.stringValue = String(format: "%@/%@", averageMonthPriceDiscount ?? "", NSLocalizedString("mon", comment: ""))
                     value1PurchaseOriPriceLbl.stringValue = String(format: "%@/%@", averageMonthPrice ?? "", NSLocalizedString("mon", comment: ""))
-                    value1PurchaseOriPriceLbl.isHidden = false
-                    billedTopConst.constant = 16
                 } else {
-                    value1PurchaseLabel.stringValue = String(format: "%@/%@", averageMonthPrice ?? "", NSLocalizedString("mon", comment: ""))
-                    value1PurchaseOriPriceLbl.isHidden = true
-                    billedTopConst.constant = 0
-                }
-            }
-        } else {
-            let hasIntroPrice = (introPrice != nil && introPrice?.isEmpty == false)
-            if model.isPurchaseSwitch {
-                let iapProduct = fourDevicesAllAccessPackNew12months_lite
-                if model.isShowSale {
                     value1PurchaseLabel.stringValue = String(format: "%@/%@", monthPriceDiscount ?? "", NSLocalizedString("12 months", comment: ""))
                     value1PurchaseOriPriceLbl.stringValue = String(format: "%@/%@", monthPrice ?? "", NSLocalizedString("12 months", comment: ""))
-                    value1PurchaseOriPriceLbl.isHidden = false
-                    billedTopConst.constant = 16
-                } else {
-                    let isNewUser = IAPReceiptTool.isNewUser(with: _fetchReceiptModel(), withGroupIdentifier: iapProduct?.product?.subscriptionGroupIdentifier)
-                    if hasIntroPrice && isNewUser { // 推介优惠
+                }
+                value1PurchaseOriPriceLbl.isHidden = false
+                billedTopConst.constant = 16
+            } else {
+                // 是否为新用户
+                let isNewUser = IAPReceiptTool.isNewUser(with: _fetchReceiptModel(), withGroupIdentifier: iapProduct?.product?.subscriptionGroupIdentifier)
+                if hasIntroPrice && isNewUser { // 推介优惠
+                    if showAveragePrice {
+                        value1PurchaseLabel.stringValue = String(format: "%@/%@", introAveragePrice ?? "" , NSLocalizedString("mon", comment: ""))
+                        value1PurchaseOriPriceLbl.stringValue = String(format: "%@/%@", averageMonthPrice ?? "", NSLocalizedString("mon", comment: ""))
+                    } else {
                         value1PurchaseLabel.stringValue = String(format: "%@/%@", introPrice ?? "", NSLocalizedString("12 months", comment: ""))
                         value1PurchaseOriPriceLbl.stringValue = String(format: "%@/%@", monthPrice ?? "", NSLocalizedString("12 months", comment: ""))
-                        value1PurchaseOriPriceLbl.isHidden = false
-                        billedTopConst.constant = 16
-                        
-                        self.value1PurchaseDiscountBox.isHidden = true
-                    } else {
-                        // 促销优惠
-                        var useDiscountCode: String? = nil
-                        if discountType_ == .advancedYearSubscribeTrialingCancel {
-                            let discountCode = "4_devices_all_access_pack_12months_20250102"
-                            if let priceString = iapProduct?.discountPrice(withDiscountCode: discountCode), priceString.isEmpty == false {
-                                self.value1PurchaseDiscountBox.isHidden = false
-                                self.value1PurchaseDiscountView_.label.stringValue = "-"+priceString
-                                
-                                useDiscountCode = discountCode
-                            } else {
-                                self.value1PurchaseDiscountBox.isHidden = true
-                            }
+                    }
+                    value1PurchaseOriPriceLbl.isHidden = false
+                    billedTopConst.constant = 16
+                    
+                    self.value1PurchaseDiscountBox.isHidden = true
+                } else { // 促销优惠
+                    var useDiscountCode: String? = nil
+                    if discountType_ == .advancedYearSubscribeTrialingCancel {
+                        let discountCode = "4_devices_all_access_pack_12months_20250102"
+                        if let priceString = iapProduct?.discountPrice(withDiscountCode: discountCode), priceString.isEmpty == false {
+                            self.value1PurchaseDiscountBox.isHidden = false
+                            self.value1PurchaseDiscountView_.label.stringValue = "-"+priceString
+                            
+                            useDiscountCode = discountCode
                         } else {
                             self.value1PurchaseDiscountBox.isHidden = true
                         }
-                        
-                        if let data = iapProduct?.productPrice(withDiscountCode: useDiscountCode ?? ""), data.isEmpty == false {
+                    } else {
+                        self.value1PurchaseDiscountBox.isHidden = true
+                    }
+                    
+                    if let data = iapProduct?.productPrice(withDiscountCode: useDiscountCode ?? ""), data.isEmpty == false {
+                        if showAveragePrice {
+                            let priceS = iapProduct?.productAveragePrice(withDiscountCode: useDiscountCode ?? "") ?? ""
+                            value1PurchaseLabel.stringValue = String(format: "%@/%@", priceS , NSLocalizedString("mon", comment: ""))
+                            value1PurchaseOriPriceLbl.stringValue = String(format: "%@/%@", averageMonthPrice ?? "", NSLocalizedString("mon", comment: ""))
+                        } else {
                             value1PurchaseLabel.stringValue = String(format: "%@/%@", data ?? "", NSLocalizedString("12 months", comment: ""))
                             value1PurchaseOriPriceLbl.stringValue = String(format: "%@/%@", monthPrice ?? "", NSLocalizedString("12 months", comment: ""))
-                            value1PurchaseOriPriceLbl.isHidden = false
-                            billedTopConst.constant = 16
+                        }
+                        value1PurchaseOriPriceLbl.isHidden = false
+                        billedTopConst.constant = 16
+                    } else {
+                        if showAveragePrice {
+                            value1PurchaseLabel.stringValue = String(format: "%@/%@", averageMonthPrice ?? "", NSLocalizedString("mon", comment: ""))
                         } else {
                             value1PurchaseLabel.stringValue = String(format: "%@/%@", monthPrice ?? "", NSLocalizedString("12 months", comment: ""))
-                            value1PurchaseOriPriceLbl.isHidden = true
-                            billedTopConst.constant = 0
                         }
+                        value1PurchaseOriPriceLbl.isHidden = true
+                        billedTopConst.constant = 0
                     }
                 }
-            } else {
-                let iapProduct = fourDevicesAllAccessPackNew6Months_lite
-                if model.isShowSale { // [旧订阅][活动][可移除]
+            }
+        } else {
+            let iapProduct = fourDevicesAllAccessPackNew6Months_lite
+            if model.isShowSale { // [旧订阅][活动][可移除]
+                if showAveragePrice {
+                    value1PurchaseLabel.stringValue = String(format: "%@/%@", averageMonthPriceDiscount ?? "", NSLocalizedString("mon", comment: ""))
+                    value1PurchaseOriPriceLbl.stringValue = String(format: "%@/%@", averageMonthPrice ?? "", NSLocalizedString("mon", comment: ""))
+                } else {
                     value1PurchaseLabel.stringValue = String(format: "%@/%@", monthPriceDiscount ?? "", NSLocalizedString("6mon", comment: ""))
                     value1PurchaseOriPriceLbl.stringValue = String(format: "%@/%@", monthPrice ?? "", NSLocalizedString("6mon", comment: ""))
-                    value1PurchaseOriPriceLbl.isHidden = false
-                    billedTopConst.constant = 16
-                } else {
-                    let isNewUser = IAPReceiptTool.isNewUser(with: _fetchReceiptModel(), withGroupIdentifier: iapProduct?.product?.subscriptionGroupIdentifier)
-                    if hasIntroPrice && isNewUser { // 推介优惠
+                }
+                value1PurchaseOriPriceLbl.isHidden = false
+                billedTopConst.constant = 16
+            } else {
+                let isNewUser = IAPReceiptTool.isNewUser(with: _fetchReceiptModel(), withGroupIdentifier: iapProduct?.product?.subscriptionGroupIdentifier)
+                if hasIntroPrice && isNewUser { // 推介优惠
+                    if showAveragePrice {
+                        value1PurchaseLabel.stringValue = String(format: "%@/%@", introAveragePrice ?? "" , NSLocalizedString("mon", comment: ""))
+                        value1PurchaseOriPriceLbl.stringValue = String(format: "%@/%@", averageMonthPrice ?? "", NSLocalizedString("mon", comment: ""))
+                    } else {
                         value1PurchaseLabel.stringValue = String(format: "%@/%@", introPrice ?? "", NSLocalizedString("6mon", comment: ""))
                         value1PurchaseOriPriceLbl.stringValue = String(format: "%@/%@", monthPrice ?? "", NSLocalizedString("6mon", comment: ""))
-                        value1PurchaseOriPriceLbl.isHidden = false
-                        billedTopConst.constant = 16
-                        
-                        if discountType_ == .newUserGift {
+                    }
+                    value1PurchaseOriPriceLbl.isHidden = false
+                    billedTopConst.constant = 16
+                    
+                    if discountType_ == .newUserGift {
+                        self.value1PurchaseDiscountBox.isHidden = false
+                        let priceString = iapProduct?.introDiscountPrice() ?? "$10"
+                        self.value1PurchaseDiscountView_.label.stringValue = "-"+priceString
+                    } else {
+                        self.value1PurchaseDiscountBox.isHidden = true
+                    }
+                } else { // 促销优惠
+                    var useDiscountCode: String? = nil
+                    if discountType_ == .advancedYearSubscribeTrialingCancel {
+                        let discountCode = "4_devices_all_access_pack_new_6month_20250102"
+                        if let priceString = iapProduct?.discountPrice(withDiscountCode: discountCode), priceString.isEmpty == false {
                             self.value1PurchaseDiscountBox.isHidden = false
-                            let priceString = iapProduct?.introDiscountPrice() ?? "$10"
                             self.value1PurchaseDiscountView_.label.stringValue = "-"+priceString
+                            
+                            useDiscountCode = discountCode
                         } else {
                             self.value1PurchaseDiscountBox.isHidden = true
                         }
                     } else {
-                        // 促销优惠
-                        var useDiscountCode: String? = nil
-                        if discountType_ == .advancedYearSubscribeTrialingCancel {
-                            let discountCode = "4_devices_all_access_pack_new_6month_20250102"
-                            if let priceString = iapProduct?.discountPrice(withDiscountCode: discountCode), priceString.isEmpty == false {
-                                self.value1PurchaseDiscountBox.isHidden = false
-                                self.value1PurchaseDiscountView_.label.stringValue = "-"+priceString
-                                
-                                useDiscountCode = discountCode
-                            } else {
-                                self.value1PurchaseDiscountBox.isHidden = true
-                            }
+                        self.value1PurchaseDiscountBox.isHidden = true
+                    }
+                    
+                    if let data = iapProduct?.productPrice(withDiscountCode: useDiscountCode ?? ""), data.isEmpty == false {
+                        if showAveragePrice {
+                            let priceS = iapProduct?.productAveragePrice(withDiscountCode: useDiscountCode ?? "") ?? ""
+                            value1PurchaseLabel.stringValue = String(format: "%@/%@", priceS , NSLocalizedString("mon", comment: ""))
+                            value1PurchaseOriPriceLbl.stringValue = String(format: "%@/%@", averageMonthPrice ?? "", NSLocalizedString("mon", comment: ""))
                         } else {
-                            self.value1PurchaseDiscountBox.isHidden = true
-                        }
-                        
-                        if let data = iapProduct?.productPrice(withDiscountCode: useDiscountCode ?? ""), data.isEmpty == false {
                             value1PurchaseLabel.stringValue = String(format: "%@/%@", data ?? "", NSLocalizedString("6mon", comment: ""))
                             value1PurchaseOriPriceLbl.stringValue = String(format: "%@/%@", monthPrice ?? "", NSLocalizedString("6mon", comment: ""))
-                            value1PurchaseOriPriceLbl.isHidden = false
-                            billedTopConst.constant = 16
+                        }
+                        value1PurchaseOriPriceLbl.isHidden = false
+                        billedTopConst.constant = 16
+                    } else {
+                        if showAveragePrice {
+                            value1PurchaseLabel.stringValue = String(format: "%@/%@", averageMonthPrice ?? "", NSLocalizedString("mon", comment: ""))
                         } else {
                             value1PurchaseLabel.stringValue = String(format: "%@/%@", monthPrice ?? "", NSLocalizedString("6mon", comment: ""))
-                            value1PurchaseOriPriceLbl.isHidden = true
-                            billedTopConst.constant = 0
                         }
+                        value1PurchaseOriPriceLbl.isHidden = true
+                        billedTopConst.constant = 0
                     }
                 }
             }