Browse Source

【会员系统】修复订阅产品获取推介促销优惠价格

wanjun 3 months ago
parent
commit
996c9df3a6

+ 26 - 0
PDF Office/PDF Master/Class/Purchase/IAPProductsManager.m

@@ -113,6 +113,16 @@ NSString * const KMMemberInfoChangeNotification = @"KMMemberInfoChangeNotificati
 - (NSString *)price {
     NSString *price = nil;
 #if !VERSION_DMG
+    if ([self.product.productIdentifier isEqualToString:KM4DevicesAllAccessPack12Months_Free]) {
+        SKProductDiscount *introductoryPrice = self.product.introductoryPrice;
+        if ([introductoryPrice paymentMode] == SKProductDiscountPaymentModePayUpFront) {
+            NSNumberFormatter *numberFormatter = [[[NSNumberFormatter alloc] init] autorelease];
+            [numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
+            [numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
+            [numberFormatter setLocale:self.product.priceLocale];
+            return [numberFormatter stringFromNumber:introductoryPrice.price];
+        }
+    }
     if (self.product.price) {
         price = [self formattedPrice:NO];
     } else {
@@ -152,6 +162,22 @@ NSString * const KMMemberInfoChangeNotification = @"KMMemberInfoChangeNotificati
 - (NSString *)averagePrice {
     NSString *price = nil;
 #if !VERSION_DMG
+    if ([self.product.productIdentifier isEqualToString:KM4DevicesAllAccessPack12Months_Free]) {
+        SKProductDiscount *introductoryPrice = self.product.introductoryPrice;
+        if ([introductoryPrice paymentMode] == SKProductDiscountPaymentModePayUpFront) {
+            NSNumberFormatter *numberFormatter = [[[NSNumberFormatter alloc] init] autorelease];
+            [numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
+            [numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
+            [numberFormatter setLocale:self.product.priceLocale];
+            
+            CGFloat mouths = self.mouthNumber;
+            if (mouths <= 0) {
+                mouths = 1.0;
+            }
+            NSNumber *number = [NSNumber numberWithDouble:[introductoryPrice.price doubleValue]/mouths];
+            return [numberFormatter stringFromNumber:number];
+        }
+    }
     if (self.product.price) {
         price = [self formattedPrice:YES];
     } else {

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

@@ -845,9 +845,15 @@ class KMProductCompareWC: NSWindowController {
         if(isSubscribed_year) {
             value1PurchaseBtnLbl.stringValue = NSLocalizedString("Subscribed", comment: "")
         } else {
+            if model.checkSubscriptionOffer(for: IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite.product) == .freeTrial {
+                print("222")
+            } else if model.checkSubscriptionOffer(for: IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite.product) == .payUpFront {
+                print("111")
+            }
             if(model.isPurchaseSwitch == true) {
                 if(!isTrialPeriod_year &&
-                   KMMemberInfo.shared.canTrail) {
+                   KMMemberInfo.shared.canTrail &&
+                   model.checkSubscriptionOffer(for: IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite.product) == .freeTrial) {
                     value1PurchaseBtnLbl.stringValue = NSLocalizedString("Free Trial", comment: "")
                 } else {
                     value1PurchaseBtnLbl.stringValue = NSLocalizedString("Subscribe", comment: "")