1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909 |
- //
- // KMProductModel.swift
- // PDF Reader Pro
- //
- // Created by wanjun on 2024/11/6.
- //
- import Foundation
- import Combine
- #if !VERSION_DMG
- import StoreKit
- #endif
- @objc enum KMCompareTableType : Int {
- case trial = 0 // 试用比较表
- case dmg_Base // DMG 购买比较表
- case dmg_Upgrades1 // DMG 升级比较表 39.99
- case dmg_Upgrades2 // DMG 升级比较表 49.99
- case lite_Base // Lite 基础版
- case lite_MacWindows // Lite Mac&Windows双平台高级版永久
- case pro_Base // Pro 基础版
- case pro_Advanced // Pro Mac单平台高级版永久
- }
- @objc enum KMCompareProductType : Int {
- case free = 0 // 免费
- case freeTrial // 试用
- case allPlatformStandard // 全平台标准版年订阅
- case dualPlatformAdvanced // Mac&Windows双平台高级版永久
- case allPlatformAdvanced_6 // 全平台高级版6个月订阅
- case allPlatformAdvanced_12 // 全平台高级版12个月订阅
- case macPlatformAdvanced // MAC单平台高级版永久
- }
- @objc enum KMPurchasedProductType : Int {
- case fourDevicesAllAccessPackNew6months_lite = 0 // 4_devices_all_access_pack_new_6months(订阅)
- case fourDevicesAllAccessPackNew12months_lite // 4_devices_all_access_pack_12months(订阅)
- // case allAccessPackNew6months_lite // all_access_pack_new_6months(订阅)
- // case allAccessPack12months_lite // all_access_pack_12months(订阅)
- // case allAccessPack6months_lite // all_access_pack_6months(订阅)
- case aiAllAccessPack1month_lite // ai_all_access_pack_1month(订阅)
- case aiAllAccessPack12month_lite // ai_all_access_pack_12month(订阅)
- case allAccessPackPermanent_lite // all_access_pack_permanent(永久)
- case advancedAddDevicesAllAccessPack12months_lite // advanced_add_devices_all_access_pack_12months(订阅)单平台升级到全平台
- case advancedAdd2DevicesAllAccessPack12months_lite // advanced_add_2_devices_all_access_pack_12months(订阅)双平台升级到全平台
- case aiAllAccessPack1month_pro // ai_all_access_pack_1month(订阅)
- case aiAllAccessPack12month_pro // ai_all_access_pack_1month(订阅)
- case pdfToOfficePackPermanent_pro // pdf_to_office_pack_permanent(永久)
- case fourDevicesAllAccessPack12months_pro // 4_devices_all_access_pack_12months(全平台高级年订阅)
- case standardAddDevicesAllAccessPack12months_pro // standard_add_devices_all_access_pack_12months(订阅)
- case advancedAddDevicesAllAccessPack12months_pro // advanced_add_devices_all_access_pack_12months(订阅)
- case advancedAdd2DevicesAllAccessPack12months_pro // advanced_add_2_devices_all_access_pack_12months(订阅)
-
- case pdfReaderProStandard_dmg // 全平台标准版年订阅
- case pdfReaderProAdvanced_dmg // 全平台高级版年订阅
- case pdfReaderProPermanent_dmg // Mac&Windows双平台高级版永久
- case pdfReaderProAIAnnual_dmg // AI 年订阅
- case pdfReaderProAIMonthly_dmg // AI 月订阅
- case pdfToOffice_dmg // 转档包 永久
- case add2Device_dmg // 多设备全平台
- case add3Device_dmg // 单平台升级高级版
- }
- @objc enum KMPaymentModeType : Int {
- case null = 0
- case freeTrial
- case payAsYouGo
- case payUpFront
- case discount
- }
- typealias AppstorePurchaseComplete = (_ success: Bool,_ msg: String) -> Void
- @objcMembers
- class KMProductModel: ObservableObject {
- static let shared = KMProductModel()
- /**
- 比较表类型
- */
- @Published var state: KMCompareTableType = .trial
- /**
- 高级版半年 或 年订阅,true为年订阅,false为半年订阅,默认true为年订阅
- */
- @Published var isPurchaseSwitch: Bool = true
-
- // MARK: DMG Public Property
- /**
- DMG 版本所有已经上架产品记录(暂时无教育优惠)
- */
- var dmgProductDatas: KMMemberProductResult?
-
- /**
- DMG 版本 已经登录用户 最后一次价格获取
- */
- var dmgLastGetProductPriceInfos: KMMemberProductResult?
-
- /**
- DMG 版本 已经登录用户 最后一次批量价格获取
- */
- var dmgLastGetBatchProductPriceInfos: KMMemberProductResult?
-
- /**
- DMG 版本 已经登录用户 最后一次验证商品优惠券价格获取
- */
- var dmgLastCheckCouponProductPriceInfos: KMMemberProductResult?
-
- /**
- DMG 版本 已经登录用户 最后一次创建的买断订单返回信息
- */
- var dmgLastCreatOrderProductInfos: KMMemberProductResult?
-
- /**
- DMG 版本 已经登录用户 最后一次创建的买断订单返回信息
- */
- var dmgLastCreatSubscriberProductInfos: KMMemberProductResult?
-
- // MARK: DMG Public Method
-
- func checkConnectionAvailable() -> Void {
- if KMMemberCenterManager.manager.isConnectionAvailable() == false {
- let alert = NSAlert()
- alert.alertStyle = .critical
- alert.messageText = NSLocalizedString("Error Information", comment: "")
- alert.informativeText = NSLocalizedString("Please make sure your internet connection is available.", comment: "")
- alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
- alert.runModal()
- return
- }
- }
-
- /**
- @abstract 获取DMG服务器架上所有商品 (得到的价格是原始价格)
- @param
- */
- func getDMGProductDatas(discountCode: String, _ complete: @escaping KMMemberProductComplete) -> Void {
- checkConnectionAvailable()
- KMMemberCenterManager.manager.getListingProducts(isEducation: 0, discountCode: discountCode) { [weak self] success, result in
- guard let productsArrays : KMMemberProductResult = result else { return }
- self?.dmgProductDatas = productsArrays
- complete(success, result)
- }
-
- if KMMemberInfo.shared.isLogin {
- // getDMGProductPriceInfosForMember(productId: "SP2024102300004", isEducation: 0) { [weak self] success, result in
- //
- //
- // }
-
- // getDMGBatchProductPriceInfosForMember(productId: "SP2024102300004", num: 10) { [weak self] success, result in
- //
- //
- // }
-
- // getDMGProductListInfosForMember(orderStatus: 0) { [weak self] success, result in
- //
- // }
-
- //创建买断订单
- // creatOrder(productId: "SP2024102300004", paymentMethod: 0, price: "119.99", discountFlag: 0, couponCode: "", num: 1) { [weak self] success, result in
- //
- // }
-
- //创建订阅订单(创建买断订单后会报错已经是购买用户,不能重复购买)
- // createSubscriber(productId: "SP2024102300003", paymentMethod: 0, price: "99.99", discountFlag: 0, couponCode: "", num: 1) { [weak self] success, result in
- //
- // }
-
- // getDMGProductOrderIdInfosForMember(orderId: "94b10d5f1ca193948e005503bff0df11") { [weak self] success, result in
- //
- // }
-
- }
-
- }
-
-
- /**
- @abstract 获取DMG产品价格(美元)
- */
- func getDMGPrice(productCode: String) -> String {
- guard let productModels = dmgProductDatas?.listingProducts else { return "" }
- for model in productModels {
- if model.code == productCode {
- if model.upgradePriceString?.isEmpty == false {
- return String(format: "%.2f", Float(model.upgradePriceString ?? "0") ?? 0)
- } else if model.displayPriceString?.isEmpty == false {
- if model.displayPriceString == "0.00" {
- return String(format: "%.2f", Float(model.priceString ?? "0") ?? 0)
- } else {
- return String(format: "%.2f", Float(model.displayPriceString ?? "0") ?? 0)
- }
- } else {
- return String(format: "%.2f", Float(model.priceString ?? "0") ?? 0)
- }
- }
- }
- return ""
- }
- /**
- @abstract 获取DMG产品价格(人民币)
- */
- func getDMGCNYPrice(productCode: String) -> String {
- guard let productModels = dmgProductDatas?.listingProducts else { return "" }
- for model in productModels {
- if model.code == productCode {
- if model.cnyUpgradePriceString?.isEmpty == false {
- return String(format: "%.2f", Float(model.cnyUpgradePriceString ?? "0") ?? 0)
- } else if model.displayCnyPriceString?.isEmpty == false {
- if model.displayCnyPriceString == "0.00" {
- return String(format: "%.2f", Float(model.cnyPriceString ?? "0") ?? 0)
- } else {
- return String(format: "%.2f", Float(model.displayCnyPriceString ?? "0") ?? 0)
- }
- } else {
- return String(format: "%.2f", Float(model.cnyPriceString ?? "0") ?? 0)
- }
- }
- }
- return ""
- }
- /**
- @abstract 获取DMG产品折扣价格(美元)
- */
- func getDMGDisplayPrice(productCode: String) -> String {
- guard let productModels = dmgProductDatas?.listingProducts else { return "" }
- for model in productModels {
- if model.code == productCode {
- return String(format: "%.2f", Float(model.displayPriceString ?? "0") ?? 0)
- }
- }
- return ""
- }
- /**
- @abstract 获取DMG产品折扣价格(人民币)
- */
- func getDMGDisplayCNYPrice(productCode: String) -> String {
- guard let productModels = dmgProductDatas?.listingProducts else { return "" }
- for model in productModels {
- if model.code == productCode {
- return String(format: "%.2f", Float(model.displayCnyPriceString ?? "0") ?? 0)
- }
- }
- return ""
- }
-
- /** 获取DMG产品原价(美元)*/
- func getDMGOriginalPrice(productCode: String) -> String {
- guard let productModels = dmgProductDatas?.listingProducts else { return "" }
- for model in productModels {
- if model.code == productCode {
- return String(format: "%.2f", Float(model.priceString ?? "0") ?? 0)
- }
- }
- return ""
- }
-
- /** 获取DMG产品原价(人民币)*/
- func getDMGOriginalCNYPrice(productCode: String) -> String {
- guard let productModels = dmgProductDatas?.listingProducts else { return "" }
- for model in productModels {
- if model.code == productCode {
- return String(format: "%.2f", Float(model.cnyPriceString ?? "0") ?? 0)
- }
- }
- return ""
- }
-
- /** 获取DMG产品优惠卷价格(美元)*/
- func getDMGDisplayAmountPrice(productCode: String, pointNum: Int) -> String {
- guard let productModels = dmgProductDatas?.listingProducts else { return "" }
- for model in productModels {
- if model.code == productCode {
- let formatStr = "%.\(pointNum)f"
- return String(format: formatStr, Float(model.displayAmount ?? "0") ?? 0)
- }
- }
- return ""
- }
-
- /** 获取DMG产品优惠卷价格(人民币)*/
- func getDMGDisplayAmountCNYPrice(productCode: String, pointNum: Int) -> String {
- guard let productModels = dmgProductDatas?.listingProducts else { return "" }
- for model in productModels {
- if model.code == productCode {
- let formatStr = "%.\(pointNum)f"
- return String(format: formatStr, Float(model.cnyDisplayAmount ?? "0") ?? 0)
- }
- }
- return ""
- }
-
- /**
- @abstract 获取登录用户价格(建立订单时需要用到)
- @param productId 购买的产品id
- @param isEducation 是否教育优惠
- @param complete 回调
- */
- func getDMGProductPriceInfosForMember(productId: String, isEducation: Int, _ complete: @escaping KMMemberProductComplete) {
- checkConnectionAvailable()
- //暂时无教育优惠,先固定传 0
- KMMemberCenterManager.manager.getProductPriceForBuy(productId: productId, isEducation: 0, userId:KMMemberInfo.shared.userID) { [weak self] success, result in
- if success {
- guard let productsArrays : KMMemberProductResult = result else {
- complete(false, result)
- return
- }
- self?.dmgLastGetProductPriceInfos = productsArrays
- complete(true, productsArrays)
- } else {
- complete(false, result)
- }
- }
- }
-
- /**
- @abstract 获取批量阶段购买价格(建立订单时需要用到)
- @param productId 购买的产品id
- @param num 批量个数
- @param complete 回调
- */
- func getDMGBatchProductPriceInfosForMember(productId: String, num: Int, _ complete: @escaping KMMemberProductComplete) {
- checkConnectionAvailable()
- KMMemberCenterManager.manager.getBatchProductPrice(productId: productId, num: num) { [weak self] success, result in
- if success {
- guard let productsArrays : KMMemberProductResult = result else {
- complete(false, result)
- return
- }
- self?.dmgLastGetBatchProductPriceInfos = productsArrays
- complete(true, productsArrays)
- } else {
- complete(false, result)
- }
- }
- }
-
- /**
- @abstract 验证商品优惠券(建立订单时需要用到)
- @param productId 购买的产品id
- @param code 优惠券
- @param complete 回调
- */
- func getDMGCheckCouponProductPriceInfosForMember(productId: String, code: String, _ complete: @escaping KMMemberProductComplete) {
- checkConnectionAvailable()
- KMMemberCenterManager.manager.checkCoupon(productId: productId, userId: KMMemberInfo.shared.userID, code: code) { [weak self] success, result in
- if success {
- guard let productsArrays : KMMemberProductResult = result else {
- complete(false, result)
- return
- }
- self?.dmgLastCheckCouponProductPriceInfos = productsArrays
- complete(true, productsArrays)
- } else {
- complete(false, result)
- }
- }
- }
-
- /**
- @abstract 获取订单列表
- @param orderStatus 0全部1待支付
- @param complete 回调
- */
- func getDMGProductListInfosForMember(orderStatus: Int, _ complete: @escaping KMMemberRequestInfoComplete) {
- checkConnectionAvailable()
- KMMemberCenterManager.manager.getOrderListByStatus(orderStatus: orderStatus) { [weak self] success, result in
- if success {
- guard let productsInfos : NSDictionary = result else {
- complete(false, result)
- return
- }
- complete(true, productsInfos)
- } else {
- complete(false, result)
- }
- }
- }
-
- /**
- @abstract 创建订单(买断)
- @param productId 产品id
- @param paymentMethod 支付方式 PAYPAL(0),ALIPAY(1),WXPAY(2),PADDLE(3)
- @param price 价格
- @param discountFlag 0原价,1优惠券,2升级,3教育优惠,4批量购买,5黑五折扣
- @param couponCode 优惠卷
- @param num 批量购买数量
- @param complete 回调
- */
- func creatOrder(productId: String, paymentMethod: Int, price: String, discountFlag: Int, couponCode: String, num: Int, _ complete: @escaping KMMemberProductComplete) {
- checkConnectionAvailable()
- KMMemberCenterManager.manager.createOrder(productId: productId, paymentMethod: paymentMethod, price: price, discountFlag: discountFlag, couponCode: couponCode, num: num) { [weak self] success, result in
- if success {
- guard let productsArrays : KMMemberProductResult = result else {
- complete(false, result)
- return
- }
- self?.dmgLastCreatOrderProductInfos = productsArrays
- complete(true, productsArrays)
- } else {
- complete(false, result)
- }
- }
- }
-
- /**
- @abstract 创建订单(订阅)
- @param productId 产品id
- @param paymentMethod 支付方式 PAYPAL(0),ALIPAY(1),WXPAY(2),PADDLE(3)
- @param price 价格
- @param discountFlag 0原价,1优惠券,2升级,3教育优惠,4批量购买,5黑五折扣
- @param couponCode 优惠卷
- @param num 批量购买数量
- @param complete 回调
- */
- func createSubscriber(productId: String, paymentMethod: Int, price: String, discountFlag: Int, couponCode: String, num: Int, _ complete: @escaping KMMemberProductComplete) {
- checkConnectionAvailable()
- KMMemberCenterManager.manager.createSubscriber(productId: productId, paymentMethod: paymentMethod, price: price, discountFlag: discountFlag, couponCode: couponCode, num: num) { [weak self] success, result in
- if success {
- guard let productsArrays : KMMemberProductResult = result else {
- complete(false, result)
- return
- }
- self?.dmgLastCreatSubscriberProductInfos = productsArrays
- complete(true, productsArrays)
- } else {
- complete(false, result)
- }
- }
- }
-
- /**
- @abstract 支付后查询订单状态
- @param productId 购买的产品id
- @param complete 回调
- */
- func getDMGProductOrderIdInfosForMember(orderId: String, _ complete: @escaping KMMemberRequestInfoComplete) {
- checkConnectionAvailable()
- KMMemberCenterManager.manager.getStateByOrderId(orderId: orderId) { [weak self] success, result in
- if success {
- guard let productsInfos : NSDictionary = result else {
- complete(false, result)
- return
- }
- complete(true, productsInfos)
- } else {
- complete(false, result)
- }
- }
- }
-
-
- // MARK: Public Method
-
- /**
- @abstract 根据当前权益获取比较表类型
- @param
- */
- func getCurrentComparisonTableType() -> Void {
- let userScenarioType = KMMemberInfo.shared.userScenarioType
- let platforms = KMMemberInfo.shared.vip_platforms
- let platformsArray = platforms
- .components(separatedBy: ",")
- .map { $0.trimmingCharacters(in: .whitespaces) }
- if userScenarioType == .lite_type1 ||
- userScenarioType == .lite_type3 ||
- userScenarioType == .lite_type11 ||
- userScenarioType == .lite_type4 ||
- userScenarioType == .lite_type5 ||
- userScenarioType == .lite_type9 ||
- userScenarioType == .lite_type13 ||
- userScenarioType == .lite_type7 ||
- userScenarioType == .lite_type8 {
- if userScenarioType == .lite_type1 {
- state = .trial
- } else if userScenarioType == .lite_type3 || userScenarioType == .lite_type11 {
- state = .lite_Base
- } else if userScenarioType == .lite_type4 || userScenarioType == .lite_type5 || userScenarioType == .lite_type9 || userScenarioType == .lite_type13 {
- state = .lite_MacWindows
- } else if userScenarioType == .lite_type7 || userScenarioType == .lite_type8 {
- if KMMemberInfo.shared.vip_paymentModel == "1" && KMMemberInfo.shared.vip_cycle == 4 && platformsArray.count == 4 {
- state = .lite_MacWindows
- } else {
- state = .lite_Base
- }
- }
- } else if userScenarioType == .pro_type1 ||
- userScenarioType == .pro_type3 ||
- userScenarioType == .pro_type4 {
- if userScenarioType == .pro_type1 ||
- userScenarioType == .pro_type4 {
- state = .pro_Advanced
- } else if userScenarioType == .pro_type3 {
- state = .pro_Base
- }
- } else if userScenarioType == .dmg_type4 ||
- userScenarioType == .dmg_type5 ||
- userScenarioType == .dmg_type6 ||
- userScenarioType == .dmg_type7 ||
- userScenarioType == .dmg_type8 ||
- userScenarioType == .dmg_type9 ||
- userScenarioType == .dmg_type10 ||
- userScenarioType == .dmg_type11 ||
- userScenarioType == .dmg_type12 ||
- userScenarioType == .dmg_type13 ||
- userScenarioType == .dmg_type14 ||
- userScenarioType == .dmg_type15 ||
- userScenarioType == .dmg_type16 ||
- userScenarioType == .dmg_type17 ||
- userScenarioType == .dmg_type18 ||
- userScenarioType == .dmg_type19 ||
- userScenarioType == .dmg_type20 ||
- userScenarioType == .dmg_type21 ||
- userScenarioType == .dmg_type22 ||
- userScenarioType == .dmg_type23 ||
- userScenarioType == .dmg_type24 ||
- userScenarioType == .dmg_type25 ||
- userScenarioType == .dmg_type26 ||
- userScenarioType == .dmg_type27 ||
- userScenarioType == .dmg_type28 ||
- userScenarioType == .dmg_type29 ||
- userScenarioType == .dmg_type30 ||
- userScenarioType == .dmg_type31 ||
- userScenarioType == .dmg_type32 ||
- userScenarioType == .dmg_type33 ||
- userScenarioType == .dmg_type34 ||
- userScenarioType == .dmg_type35 ||
- userScenarioType == .dmg_type36 ||
- userScenarioType == .dmg_type37 ||
- userScenarioType == .dmg_type38 ||
- userScenarioType == .dmg_type39 ||
- userScenarioType == .dmg_type40 ||
- userScenarioType == .dmg_type41 ||
- userScenarioType == .dmg_type42 ||
- userScenarioType == .dmg_type43 ||
- userScenarioType == .dmg_type44 ||
- userScenarioType == .dmg_type45 ||
- userScenarioType == .dmg_type46 ||
- userScenarioType == .dmg_type47 ||
- userScenarioType == .dmg_type48 {
- if userScenarioType == .dmg_type4 ||
- userScenarioType == .dmg_type19 ||
- userScenarioType == .dmg_type34 {
- state = .trial
- } else if userScenarioType == .dmg_type5 ||
- userScenarioType == .dmg_type28 ||
- userScenarioType == .dmg_type43 {
- state = .dmg_Upgrades1
- } else if userScenarioType == .dmg_type6 ||
- userScenarioType == .dmg_type7 ||
- userScenarioType == .dmg_type29 ||
- userScenarioType == .dmg_type30 ||
- userScenarioType == .dmg_type44 ||
- userScenarioType == .dmg_type45 {
- state = .dmg_Upgrades2
- } else if userScenarioType == .dmg_type11 ||
- userScenarioType == .dmg_type18 ||
- userScenarioType == .dmg_type22 ||
- userScenarioType == .dmg_type33 ||
- userScenarioType == .dmg_type37 ||
- userScenarioType == .dmg_type48 {
- state = .dmg_Base
- }
- }
- }
-
- /**
- 对应商品价格
- */
- func getProductPrice(_ type: KMPurchasedProductType) -> String {
- #if VERSION_FREE
- #if VERSION_DMG
- // DMG
- if type == .pdfReaderProStandard_dmg {
- if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
- return String(format: "USD $%@", getDMGPrice(productCode: KMStandardAnnualSubscriptionCodeKey_DMG))
- } else {
- return String(format: "CNY ¥%@", getDMGCNYPrice(productCode: KMStandardAnnualSubscriptionCodeKey_DMG))
- }
- } else if type == .pdfReaderProAdvanced_dmg {
- if state == .dmg_Base {
- if isBlackFive {
- if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
- return String(format: "USD $%@", getDMGPrice(productCode: KMAdvancedAnnualSubscriptionBlackFiveCodeKey_DMG))
- } else {
- return String(format: "CNY ¥%@", getDMGCNYPrice(productCode: KMAdvancedAnnualSubscriptionBlackFiveCodeKey_DMG))
- }
- } else {
- if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
- return String(format: "USD $%@", getDMGPrice(productCode: KMAdvancedAnnualSubscriptionCodeKey_DMG))
- } else {
- return String(format: "CNY ¥%@", getDMGCNYPrice(productCode: KMAdvancedAnnualSubscriptionCodeKey_DMG))
- }
- }
- } else {
- if KMMemberInfo.shared.canTrail && state == .trial {
- if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
- return String(format: "USD $%@", getDMGPrice(productCode: KMAdvancedAnnualSubscriptionTrailCodeKey_DMG))
- } else {
- return String(format: "CNY ¥%@", getDMGCNYPrice(productCode: KMAdvancedAnnualSubscriptionTrailCodeKey_DMG))
- }
- } else {
- if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
- return String(format: "USD $%@", getDMGPrice(productCode: KMAdvancedAnnualSubscriptionCodeKey_DMG))
- } else {
- return String(format: "CNY ¥%@", getDMGCNYPrice(productCode: KMAdvancedAnnualSubscriptionCodeKey_DMG))
- }
- }
- }
- } else if type == .pdfReaderProPermanent_dmg {
- if state == .dmg_Base {
- if isBlackFive {
- if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
- return String(format: "USD $%@", getDMGPrice(productCode: KMAdvancedPermanentBlackFiveCodeKey_DMG))
- } else {
- return String(format: "CNY ¥%@", getDMGCNYPrice(productCode: KMAdvancedPermanentBlackFiveCodeKey_DMG))
- }
- } else {
- if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
- return String(format: "USD $%@", getDMGPrice(productCode: KMAdvancedPermanentCodeKey_DMG))
- } else {
- return String(format: "CNY ¥%@", getDMGCNYPrice(productCode: KMAdvancedPermanentCodeKey_DMG))
- }
- }
- } else {
-
- }
- } else if type == .pdfReaderProAIAnnual_dmg {
- if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
- return String(format: "USD $%@", getDMGPrice(productCode: KMAISubscriptionYearTrailCodeKey_DMG))
- } else {
- return String(format: "CNY ¥%@", getDMGCNYPrice(productCode: KMAISubscriptionYearTrailCodeKey_DMG))
- }
- } else if type == .pdfReaderProAIMonthly_dmg {
- if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
- return String(format: "USD $%@", getDMGPrice(productCode: KMAISubscriptionMonthCodeKey_DMG))
- } else {
- return String(format: "CNY ¥%@", getDMGCNYPrice(productCode: KMAISubscriptionMonthCodeKey_DMG))
- }
- } else if type == .pdfToOffice_dmg {
-
- } else if type == .add2Device_dmg {
- } else if type == .add3Device_dmg {
- }
- #else
- // AppStore 免费版本
- if type == .fourDevicesAllAccessPackNew6months_lite {
- if let product = IAPProductsManager.default().fourDevicesAllAccessPackNew6Months_lite, product.isOffers {
- return product.offersPrice()
- } else {
- return IAPProductsManager.default().fourDevicesAllAccessPackNew6Months_lite.price()
- }
- } else if type == .fourDevicesAllAccessPackNew12months_lite {
- if let product = IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite, product.isOffers {
- return product.offersPrice()
- } else {
- return IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite.price()
- }
- } else if type == .aiAllAccessPack1month_lite {
- if let product = IAPProductsManager.default().aiAllAccessPack1month_lite, product.isOffers {
- return product.offersPrice()
- } else {
- return IAPProductsManager.default().aiAllAccessPack1month_lite.price()
- }
- } else if type == .aiAllAccessPack12month_lite {
- if let product = IAPProductsManager.default().aiAllAccessPack12month_lite, product.isOffers {
- return product.offersPrice()
- } else {
- return IAPProductsManager.default().aiAllAccessPack12month_lite.price()
- }
- } else if type == .allAccessPackPermanent_lite {
- if let product = IAPProductsManager.default().allAccessPackPermanent_lite, product.isOffers {
- return product.offersPrice()
- } else {
- return IAPProductsManager.default().allAccessPackPermanent_lite.price()
- }
- } else if type == .advancedAddDevicesAllAccessPack12months_lite {
- if let product = IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_lite, product.isOffers {
- return product.offersPrice()
- } else {
- return IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_lite.price()
- }
- } else if type == .advancedAdd2DevicesAllAccessPack12months_lite {
- if let product = IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_lite, product.isOffers {
- return product.offersPrice()
- } else {
- return IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_lite.price()
- }
- }
- #endif
- #else
- // AppStore 付费版
- if type == .aiAllAccessPack1month_pro {
- if let product = IAPProductsManager.default().aiAllAccessPack1month_pro, product.isOffers {
- return product.offersPrice()
- } else {
- return IAPProductsManager.default().aiAllAccessPack1month_pro.price()
- }
- } else if type == .aiAllAccessPack12month_pro {
- if let product = IAPProductsManager.default().aiAllAccessPack12month_pro, product.isOffers {
- return product.offersPrice()
- } else {
- return IAPProductsManager.default().aiAllAccessPack12month_pro.price()
- }
- } else if type == .pdfToOfficePackPermanent_pro {
- if let product = IAPProductsManager.default().pdfToOfficePackPermanent_pro, product.isOffers {
- return product.offersPrice()
- } else {
- return IAPProductsManager.default().pdfToOfficePackPermanent_pro.price()
- }
- } else if type == .fourDevicesAllAccessPack12months_pro {
- if let product = IAPProductsManager.default().fourDevicesAllAccessPack12months_pro, product.isOffers {
- return product.offersPrice()
- } else {
- return IAPProductsManager.default().fourDevicesAllAccessPack12months_pro.price()
- }
- } else if type == .standardAddDevicesAllAccessPack12months_pro {
- if let product = IAPProductsManager.default().standardAddDevicesAllAccessPack12months_pro, product.isOffers {
- return product.offersPrice()
- } else {
- return IAPProductsManager.default().standardAddDevicesAllAccessPack12months_pro.price()
- }
- } else if type == .advancedAddDevicesAllAccessPack12months_pro {
- if let product = IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_pro, product.isOffers {
- return product.offersPrice()
- } else {
- return IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_pro.price()
- }
- } else if type == .advancedAdd2DevicesAllAccessPack12months_pro {
- if let product = IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_pro, product.isOffers {
- return product.offersPrice()
- } else {
- return IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_pro.price()
- }
- }
- #endif
- return ""
- }
-
- /**
- 优惠价格
- */
- func getDisplayPrice(_ type: KMPurchasedProductType) -> String {
- #if VERSION_FREE
- #if VERSION_DMG
- // DMG
- if type == .pdfReaderProStandard_dmg {
- if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
- return String(format: "USD $%@", getDMGDisplayPrice(productCode: KMStandardAnnualSubscriptionCodeKey_DMG))
- } else {
- return String(format: "CNY ¥%@", getDMGDisplayCNYPrice(productCode: KMStandardAnnualSubscriptionCodeKey_DMG))
- }
- } else if type == .pdfReaderProAdvanced_dmg {
- if state == .dmg_Base {
- if isBlackFive {
- if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
- return String(format: "USD $%@", getDMGDisplayPrice(productCode: KMAdvancedAnnualSubscriptionBlackFiveCodeKey_DMG))
- } else {
- return String(format: "CNY ¥%@", getDMGDisplayCNYPrice(productCode: KMAdvancedAnnualSubscriptionBlackFiveCodeKey_DMG))
- }
- } else {
- if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
- return String(format: "USD $%@", getDMGDisplayPrice(productCode: KMAdvancedAnnualSubscriptionCodeKey_DMG))
- } else {
- return String(format: "CNY ¥%@", getDMGDisplayCNYPrice(productCode: KMAdvancedAnnualSubscriptionCodeKey_DMG))
- }
- }
- } else {
- if KMMemberInfo.shared.canTrail && state == .trial {
- if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
- return String(format: "USD $%@", getDMGDisplayPrice(productCode: KMAdvancedAnnualSubscriptionTrailCodeKey_DMG))
- } else {
- return String(format: "CNY ¥%@", getDMGDisplayCNYPrice(productCode: KMAdvancedAnnualSubscriptionTrailCodeKey_DMG))
- }
- } else {
- if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
- return String(format: "USD $%@", getDMGDisplayPrice(productCode: KMAdvancedAnnualSubscriptionCodeKey_DMG))
- } else {
- return String(format: "CNY ¥%@", getDMGDisplayCNYPrice(productCode: KMAdvancedAnnualSubscriptionCodeKey_DMG))
- }
- }
- }
- } else if type == .pdfReaderProPermanent_dmg {
- if state == .dmg_Base {
- if isBlackFive {
- if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
- return String(format: "USD $%@", getDMGDisplayPrice(productCode: KMAdvancedPermanentBlackFiveCodeKey_DMG))
- } else {
- return String(format: "CNY ¥%@", getDMGDisplayCNYPrice(productCode: KMAdvancedPermanentBlackFiveCodeKey_DMG))
- }
- } else {
- if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
- return String(format: "USD $%@", getDMGDisplayPrice(productCode: KMAdvancedPermanentCodeKey_DMG))
- } else {
- return String(format: "CNY ¥%@", getDMGDisplayCNYPrice(productCode: KMAdvancedPermanentCodeKey_DMG))
- }
- }
- } else {
-
- }
- } else if type == .pdfReaderProAIAnnual_dmg {
- if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
- return String(format: "USD $%@", getDMGDisplayPrice(productCode: KMAISubscriptionYearTrailCodeKey_DMG))
- } else {
- return String(format: "CNY ¥%@", getDMGDisplayCNYPrice(productCode: KMAISubscriptionYearTrailCodeKey_DMG))
- }
- } else if type == .pdfReaderProAIMonthly_dmg {
- if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
- return String(format: "USD $%@", getDMGDisplayPrice(productCode: KMAISubscriptionMonthCodeKey_DMG))
- } else {
- return String(format: "CNY ¥%@", getDMGDisplayCNYPrice(productCode: KMAISubscriptionMonthCodeKey_DMG))
- }
- } else if type == .pdfToOffice_dmg {
-
- } else if type == .add2Device_dmg {
- } else if type == .add3Device_dmg {
- }
- #else
- // AppStore 免费版本
- // if type == .fourDevicesAllAccessPackNew6months_lite {
- // if let product = IAPProductsManager.default().fourDevicesAllAccessPackNew6Months_lite, product.isOffers {
- // return product.offersPrice()
- // } else {
- // return IAPProductsManager.default().fourDevicesAllAccessPackNew6Months_lite.price()
- // }
- // } else if type == .fourDevicesAllAccessPackNew12months_lite {
- // if let product = IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite, product.isOffers {
- // return product.offersPrice()
- // } else {
- // return IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite.price()
- // }
- // } else if type == .aiAllAccessPack1month_lite {
- // if let product = IAPProductsManager.default().aiAllAccessPack1month_lite, product.isOffers {
- // return product.offersPrice()
- // } else {
- // return IAPProductsManager.default().aiAllAccessPack1month_lite.price()
- // }
- // } else if type == .aiAllAccessPack12month_lite {
- // if let product = IAPProductsManager.default().aiAllAccessPack12month_lite, product.isOffers {
- // return product.offersPrice()
- // } else {
- // return IAPProductsManager.default().aiAllAccessPack12month_lite.price()
- // }
- // } else if type == .allAccessPackPermanent_lite {
- // if let product = IAPProductsManager.default().allAccessPackPermanent_lite, product.isOffers {
- // return product.offersPrice()
- // } else {
- // return IAPProductsManager.default().allAccessPackPermanent_lite.price()
- // }
- // } else if type == .advancedAddDevicesAllAccessPack12months_lite {
- // if let product = IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_lite, product.isOffers {
- // return product.offersPrice()
- // } else {
- // return IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_lite.price()
- // }
- // } else if type == .advancedAdd2DevicesAllAccessPack12months_lite {
- // if let product = IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_lite, product.isOffers {
- // return product.offersPrice()
- // } else {
- // return IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_lite.price()
- // }
- // }
- #endif
- #else
- // AppStore 付费版
- // if type == .aiAllAccessPack1month_pro {
- // if let product = IAPProductsManager.default().aiAllAccessPack1month_pro, product.isOffers {
- // return product.offersPrice()
- // } else {
- // return IAPProductsManager.default().aiAllAccessPack1month_pro.price()
- // }
- // } else if type == .aiAllAccessPack12month_pro {
- // if let product = IAPProductsManager.default().aiAllAccessPack12month_pro, product.isOffers {
- // return product.offersPrice()
- // } else {
- // return IAPProductsManager.default().aiAllAccessPack12month_pro.price()
- // }
- // } else if type == .pdfToOfficePackPermanent_pro {
- // if let product = IAPProductsManager.default().pdfToOfficePackPermanent_pro, product.isOffers {
- // return product.offersPrice()
- // } else {
- // return IAPProductsManager.default().pdfToOfficePackPermanent_pro.price()
- // }
- // } else if type == .fourDevicesAllAccessPack12months_pro {
- // if let product = IAPProductsManager.default().fourDevicesAllAccessPack12months_pro, product.isOffers {
- // return product.offersPrice()
- // } else {
- // return IAPProductsManager.default().fourDevicesAllAccessPack12months_pro.price()
- // }
- // } else if type == .standardAddDevicesAllAccessPack12months_pro {
- // if let product = IAPProductsManager.default().standardAddDevicesAllAccessPack12months_pro, product.isOffers {
- // return product.offersPrice()
- // } else {
- // return IAPProductsManager.default().standardAddDevicesAllAccessPack12months_pro.price()
- // }
- // } else if type == .advancedAddDevicesAllAccessPack12months_pro {
- // if let product = IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_pro, product.isOffers {
- // return product.offersPrice()
- // } else {
- // return IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_pro.price()
- // }
- // } else if type == .advancedAdd2DevicesAllAccessPack12months_pro {
- // if let product = IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_pro, product.isOffers {
- // return product.offersPrice()
- // } else {
- // return IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_pro.price()
- // }
- // }
- #endif
- return ""
- }
-
- /** 原价 */
- func getOriginalPrice(_ type: KMPurchasedProductType) -> String {
- #if VERSION_FREE
- #if VERSION_DMG
- if type == .pdfReaderProStandard_dmg {
- if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
- return String(format: "USD $%@", getDMGOriginalPrice(productCode: KMStandardAnnualSubscriptionCodeKey_DMG))
- } else {
- return String(format: "CNY ¥%@", getDMGOriginalCNYPrice(productCode: KMStandardAnnualSubscriptionCodeKey_DMG))
- }
- } else if type == .pdfReaderProAdvanced_dmg {
- if state == .dmg_Base {
- if isBlackFive {
- if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
- return String(format: "USD $%@", getDMGOriginalPrice(productCode: KMAdvancedAnnualSubscriptionBlackFiveCodeKey_DMG))
- } else {
- return String(format: "CNY ¥%@", getDMGOriginalCNYPrice(productCode: KMAdvancedAnnualSubscriptionBlackFiveCodeKey_DMG))
- }
- } else {
- if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
- return String(format: "USD $%@", getDMGOriginalPrice(productCode: KMAdvancedAnnualSubscriptionCodeKey_DMG))
- } else {
- return String(format: "CNY ¥%@", getDMGOriginalCNYPrice(productCode: KMAdvancedAnnualSubscriptionCodeKey_DMG))
- }
- }
- } else {
- if KMMemberInfo.shared.canTrail && state == .trial {
- if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
- return String(format: "USD $%@", getDMGOriginalPrice(productCode: KMAdvancedAnnualSubscriptionTrailCodeKey_DMG))
- } else {
- return String(format: "CNY ¥%@", getDMGOriginalCNYPrice(productCode: KMAdvancedAnnualSubscriptionTrailCodeKey_DMG))
- }
- } else {
- if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
- return String(format: "USD $%@", getDMGOriginalPrice(productCode: KMAdvancedAnnualSubscriptionCodeKey_DMG))
- } else {
- return String(format: "CNY ¥%@", getDMGOriginalCNYPrice(productCode: KMAdvancedAnnualSubscriptionCodeKey_DMG))
- }
- }
- }
- } else if type == .pdfReaderProPermanent_dmg {
- if state == .dmg_Base {
- if isBlackFive {
- if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
- return String(format: "USD $%@", getDMGOriginalPrice(productCode: KMAdvancedPermanentBlackFiveCodeKey_DMG))
- } else {
- return String(format: "CNY ¥%@", getDMGOriginalCNYPrice(productCode: KMAdvancedPermanentBlackFiveCodeKey_DMG))
- }
- } else {
- if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
- return String(format: "USD $%@", getDMGOriginalPrice(productCode: KMAdvancedPermanentCodeKey_DMG))
- } else {
- return String(format: "CNY ¥%@", getDMGOriginalCNYPrice(productCode: KMAdvancedPermanentCodeKey_DMG))
- }
- }
- } else {
-
- }
- } else if type == .pdfReaderProAIAnnual_dmg {
- if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
- return String(format: "USD $%@", getDMGOriginalPrice(productCode: KMAISubscriptionYearTrailCodeKey_DMG))
- } else {
- return String(format: "CNY ¥%@", getDMGOriginalCNYPrice(productCode: KMAISubscriptionYearTrailCodeKey_DMG))
- }
- } else if type == .pdfReaderProAIMonthly_dmg {
- if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
- return String(format: "USD $%@", getDMGOriginalPrice(productCode: KMAISubscriptionMonthCodeKey_DMG))
- } else {
- return String(format: "CNY ¥%@", getDMGOriginalCNYPrice(productCode: KMAISubscriptionMonthCodeKey_DMG))
- }
- } else if type == .pdfToOffice_dmg {
-
- } else if type == .add2Device_dmg {
- } else if type == .add3Device_dmg {
- }
- #else
- // AppStore 免费版本
- // if type == .fourDevicesAllAccessPackNew6months_lite {
- // if let product = IAPProductsManager.default().fourDevicesAllAccessPackNew6Months_lite, product.isOffers {
- // return product.offersPrice()
- // } else {
- // return IAPProductsManager.default().fourDevicesAllAccessPackNew6Months_lite.price()
- // }
- // } else if type == .fourDevicesAllAccessPackNew12months_lite {
- // if let product = IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite, product.isOffers {
- // return product.offersPrice()
- // } else {
- // return IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite.price()
- // }
- // } else if type == .aiAllAccessPack1month_lite {
- // if let product = IAPProductsManager.default().aiAllAccessPack1month_lite, product.isOffers {
- // return product.offersPrice()
- // } else {
- // return IAPProductsManager.default().aiAllAccessPack1month_lite.price()
- // }
- // } else if type == .aiAllAccessPack12month_lite {
- // if let product = IAPProductsManager.default().aiAllAccessPack12month_lite, product.isOffers {
- // return product.offersPrice()
- // } else {
- // return IAPProductsManager.default().aiAllAccessPack12month_lite.price()
- // }
- // } else if type == .allAccessPackPermanent_lite {
- // if let product = IAPProductsManager.default().allAccessPackPermanent_lite, product.isOffers {
- // return product.offersPrice()
- // } else {
- // return IAPProductsManager.default().allAccessPackPermanent_lite.price()
- // }
- // } else if type == .advancedAddDevicesAllAccessPack12months_lite {
- // if let product = IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_lite, product.isOffers {
- // return product.offersPrice()
- // } else {
- // return IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_lite.price()
- // }
- // } else if type == .advancedAdd2DevicesAllAccessPack12months_lite {
- // if let product = IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_lite, product.isOffers {
- // return product.offersPrice()
- // } else {
- // return IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_lite.price()
- // }
- // }
- #endif
- #else
- // AppStore 付费版
- // if type == .aiAllAccessPack1month_pro {
- // if let product = IAPProductsManager.default().aiAllAccessPack1month_pro, product.isOffers {
- // return product.offersPrice()
- // } else {
- // return IAPProductsManager.default().aiAllAccessPack1month_pro.price()
- // }
- // } else if type == .aiAllAccessPack12month_pro {
- // if let product = IAPProductsManager.default().aiAllAccessPack12month_pro, product.isOffers {
- // return product.offersPrice()
- // } else {
- // return IAPProductsManager.default().aiAllAccessPack12month_pro.price()
- // }
- // } else if type == .pdfToOfficePackPermanent_pro {
- // if let product = IAPProductsManager.default().pdfToOfficePackPermanent_pro, product.isOffers {
- // return product.offersPrice()
- // } else {
- // return IAPProductsManager.default().pdfToOfficePackPermanent_pro.price()
- // }
- // } else if type == .fourDevicesAllAccessPack12months_pro {
- // if let product = IAPProductsManager.default().fourDevicesAllAccessPack12months_pro, product.isOffers {
- // return product.offersPrice()
- // } else {
- // return IAPProductsManager.default().fourDevicesAllAccessPack12months_pro.price()
- // }
- // } else if type == .standardAddDevicesAllAccessPack12months_pro {
- // if let product = IAPProductsManager.default().standardAddDevicesAllAccessPack12months_pro, product.isOffers {
- // return product.offersPrice()
- // } else {
- // return IAPProductsManager.default().standardAddDevicesAllAccessPack12months_pro.price()
- // }
- // } else if type == .advancedAddDevicesAllAccessPack12months_pro {
- // if let product = IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_pro, product.isOffers {
- // return product.offersPrice()
- // } else {
- // return IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_pro.price()
- // }
- // } else if type == .advancedAdd2DevicesAllAccessPack12months_pro {
- // if let product = IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_pro, product.isOffers {
- // return product.offersPrice()
- // } else {
- // return IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_pro.price()
- // }
- // }
- #endif
- return ""
- }
-
- /** 优惠卷价格 */
- func getDMGDisplayAmountPrice(_ type: KMPurchasedProductType, pointNum: Int, hasPrefix: Bool) -> String {
- #if VERSION_FREE
- #if VERSION_DMG
- var prefixStr = _isUSD() ? "USD" : "CNY"
- prefixStr = hasPrefix ? prefixStr : ""
- if type == .pdfReaderProStandard_dmg {
- let productCode = KMStandardAnnualSubscriptionCodeKey_DMG
- if _isUSD() {
- return String(format: "%@ $%@", prefixStr, getDMGDisplayAmountPrice(productCode: productCode, pointNum: pointNum))
- } else {
- return String(format: "%@ ¥%@", prefixStr, getDMGDisplayAmountCNYPrice(productCode: productCode, pointNum: pointNum))
- }
- } else if type == .pdfReaderProAdvanced_dmg {
- if state == .dmg_Base {
- if isBlackFive {
- let productCode = KMAdvancedAnnualSubscriptionBlackFiveCodeKey_DMG
- if _isUSD() {
- return String(format: "%@ $%@", prefixStr,getDMGDisplayAmountPrice(productCode: productCode, pointNum: pointNum))
- } else {
- return String(format: "%@ ¥%@", prefixStr, getDMGDisplayAmountCNYPrice(productCode: productCode, pointNum: pointNum))
- }
- } else {
- let productCode = KMAdvancedAnnualSubscriptionCodeKey_DMG
- if _isUSD() {
- return String(format: "%@ $%@", prefixStr, getDMGDisplayAmountPrice(productCode: productCode, pointNum: pointNum))
- } else {
- return String(format: "%@ ¥%@",prefixStr, getDMGDisplayAmountCNYPrice(productCode: productCode, pointNum: pointNum))
- }
- }
- } else {
- if KMMemberInfo.shared.canTrail && state == .trial {
- let productCode = KMAdvancedAnnualSubscriptionTrailCodeKey_DMG
- if _isUSD() {
- return String(format: "%@ $%@", prefixStr, getDMGDisplayAmountPrice(productCode: productCode, pointNum: pointNum))
- } else {
- return String(format: "%@ ¥%@", prefixStr, getDMGDisplayAmountCNYPrice(productCode: productCode, pointNum: pointNum))
- }
- } else {
- let productCode = KMAdvancedAnnualSubscriptionCodeKey_DMG
- if _isUSD() {
- return String(format: "%@ $%@", prefixStr, getDMGDisplayAmountPrice(productCode: productCode, pointNum: pointNum))
- } else {
- return String(format: "%@ ¥%@", prefixStr, getDMGDisplayAmountCNYPrice(productCode: productCode, pointNum: pointNum))
- }
- }
- }
- } else if type == .pdfReaderProPermanent_dmg {
- if state == .dmg_Base {
- if isBlackFive {
- let productCode = KMAdvancedPermanentBlackFiveCodeKey_DMG
- if _isUSD() {
- return String(format: "%@ $%@", prefixStr, getDMGDisplayAmountPrice(productCode:productCode , pointNum: pointNum))
- } else {
- return String(format: "%@ ¥%@", prefixStr, getDMGDisplayAmountCNYPrice(productCode: productCode, pointNum: pointNum))
- }
- } else {
- let productCode = KMAdvancedPermanentCodeKey_DMG
- if _isUSD() {
- return String(format: "%@ $%@", prefixStr, getDMGDisplayAmountPrice(productCode: productCode, pointNum: pointNum))
- } else {
- return String(format: "%@ ¥%@", prefixStr, getDMGDisplayAmountCNYPrice(productCode: productCode, pointNum: pointNum))
- }
- }
- } else {
-
- }
- } else if type == .pdfReaderProAIAnnual_dmg {
- let productCode = KMAISubscriptionYearTrailCodeKey_DMG
- if _isUSD() {
- return String(format: "%@ $%@", prefixStr, getDMGDisplayAmountPrice(productCode:productCode , pointNum: pointNum))
- } else {
- return String(format: "%@ ¥%@", prefixStr, getDMGDisplayAmountCNYPrice(productCode: productCode, pointNum: pointNum))
- }
- } else if type == .pdfReaderProAIMonthly_dmg {
- let productCode = KMAISubscriptionMonthCodeKey_DMG
- if _isUSD() {
- return String(format: "%@ $%@", prefixStr, getDMGDisplayAmountPrice(productCode: productCode, pointNum: pointNum))
- } else {
- return String(format: "%@ ¥%@", prefixStr, getDMGDisplayAmountCNYPrice(productCode: productCode, pointNum: pointNum))
- }
- } else if type == .pdfToOffice_dmg {
-
- } else if type == .add2Device_dmg {
- } else if type == .add3Device_dmg {
- }
- #else
- // AppStore 免费版本
- #endif
- #else
- // AppStore 付费版
- #endif
- return ""
- }
-
- func appstorePurchaseAction(_ tag: Int, discountType: KMDiscountType, _ complete: @escaping AppstorePurchaseComplete) -> Void {
- if state == .dmg_Base {
- var code = ""
- if tag == 1 {
- code = KMStandardAnnualSubscriptionCodeKey_DMG
- } else if tag == 3 {
- if isBlackFive {
- code = KMAdvancedPermanentBlackFiveCodeKey_DMG
- } else {
- code = KMAdvancedPermanentCodeKey_DMG
- }
- } else {
- if isBlackFive {
- code = KMAdvancedAnnualSubscriptionBlackFiveCodeKey_DMG
- } else {
- code = KMAdvancedAnnualSubscriptionCodeKey_DMG
- }
- }
- #if VERSION_DMG
- let embeddedWC = KMPurchaseEmbeddedWindowController.currentCode(code)
- if discountType == .newUserGift {
- embeddedWC.discountCodeId = kKMNewUserGiftDiscountCodeId
- } else if discountType == .advancedYearSubscribeTrialingCancel {
- embeddedWC.discountCodeId = kKMAdvancedYearSubscribeDiscountCodeId
-
- embeddedWC.kEventName = KMProductCompareWC.shared.kEventName
- embeddedWC.kEventParams = KMProductCompareWC.shared.kEventParams
- } else {
- embeddedWC.discountCodeId = nil
- }
- embeddedWC.openWindow(discountType: discountType)
-
- embeddedWC.window?.center()
- #endif
- } else if state == .dmg_Upgrades1 {
- #if VERSION_DMG
- let embeddedWC = KMPurchaseEmbeddedWindowController.currentCode(KMAdvancedAnnualSubscriptionCodeKey_DMG)
- embeddedWC.showWindow(nil)
- embeddedWC.window?.center()
- #endif
- } else if state == .dmg_Upgrades2 {
- #if VERSION_DMG
- let embeddedWC = KMPurchaseEmbeddedWindowController.currentCode(KMAdvancedAnnualSubscriptionCodeKey_DMG)
- embeddedWC.showWindow(nil)
- embeddedWC.window?.center()
- #endif
- } else if state == .lite_Base {
- if tag == 0 {
- if isPurchaseSwitch {
- if discountType == .advancedYearSubscribeTrialingCancel {
- membershipPurchase(.fourDevicesAllAccessPackNew12months_lite, discountCode: "4_devices_all_access_pack_12months_20250102")
- } else {
- membershipPurchase(.fourDevicesAllAccessPackNew12months_lite, discountCode: nil)
- }
- } else {
- if discountType == .advancedYearSubscribeTrialingCancel {
- membershipPurchase(.fourDevicesAllAccessPackNew6months_lite, discountCode: "4_devices_all_access_pack_new_6month_20250102")
- } else {
- membershipPurchase(.fourDevicesAllAccessPackNew6months_lite, discountCode: nil)
- }
- }
- } else if tag == 3 {
- membershipPurchase(.allAccessPackPermanent_lite, discountCode: nil)
- } else {
- membershipPurchase(.fourDevicesAllAccessPackNew12months_lite, discountCode: nil)
- }
- } else if state == .lite_MacWindows {
- if tag == 2 {
- let platforms = KMMemberInfo.shared.vip_platforms
- let platformsArray = platforms
- .components(separatedBy: ",")
- .map { $0.trimmingCharacters(in: .whitespaces) }
- if KMMemberInfo.shared.userScenarioType == .lite_type5 {
- if platformsArray.count == 1 {
- membershipPurchase(.advancedAddDevicesAllAccessPack12months_lite, discountCode: nil)
- } else if platformsArray.count == 2 {
- membershipPurchase(.advancedAdd2DevicesAllAccessPack12months_lite, discountCode: nil)
- }
- } else {
- if platformsArray.count == 1 {
- membershipPurchase(.advancedAddDevicesAllAccessPack12months_lite, discountCode: nil)
- } else if platformsArray.count == 2 {
- membershipPurchase(.advancedAdd2DevicesAllAccessPack12months_lite, discountCode: nil)
- } else {
- membershipPurchase(.advancedAdd2DevicesAllAccessPack12months_lite, discountCode: nil)
- }
- }
- }
- } else if state == .pro_Base {
- if KMMemberInfo.shared.userScenarioType == .pro_type3 {
- if tag == 2 {
- membershipPurchase(.standardAddDevicesAllAccessPack12months_pro, discountCode: nil)
- } else if tag == 3 {
- membershipPurchase(.pdfToOfficePackPermanent_pro, discountCode: nil)
- }
- }
- } else if state == .pro_Advanced {
- let platforms = KMMemberInfo.shared.vip_platforms
- let platformsArray = platforms
- .components(separatedBy: ",")
- .map { $0.trimmingCharacters(in: .whitespaces) }
- if KMMemberInfo.shared.userScenarioType == .pro_type1 {
- if platformsArray.count == 1 {
- membershipPurchase(.advancedAddDevicesAllAccessPack12months_pro, discountCode: nil)
- } else if platformsArray.count == 2 {
- membershipPurchase(.advancedAdd2DevicesAllAccessPack12months_pro, discountCode: nil)
- } else if KMMemberInfo.shared.vip_levels == "1" {
- membershipPurchase(.advancedAddDevicesAllAccessPack12months_pro, discountCode: nil)
- } else {
- membershipPurchase(.advancedAdd2DevicesAllAccessPack12months_pro, discountCode: nil)
- }
- } else if KMMemberInfo.shared.userScenarioType == .pro_type4 {
- if platformsArray.count == 1 {
- membershipPurchase(.advancedAddDevicesAllAccessPack12months_pro, discountCode: nil)
- } else if platformsArray.count == 2 {
- membershipPurchase(.advancedAdd2DevicesAllAccessPack12months_pro, discountCode: nil)
- } else {
- membershipPurchase(.advancedAdd2DevicesAllAccessPack12months_pro, discountCode: nil)
- }
- }
- } else {
- #if VERSION_FREE
- #if VERSION_DMG
- // DMG
- var code = ""
- if state == .dmg_Base {
- if isBlackFive {
- code = KMAdvancedAnnualSubscriptionBlackFiveCodeKey_DMG
- } else {
- code = KMAdvancedAnnualSubscriptionCodeKey_DMG
- }
- } else {
- if KMMemberInfo.shared.canTrail && state == .trial {
- code = KMAdvancedAnnualSubscriptionTrailCodeKey_DMG
- } else {
- code = KMAdvancedAnnualSubscriptionCodeKey_DMG
- }
- }
- let embeddedWC = KMPurchaseEmbeddedWindowController.currentCode(code)
- if code == KMAdvancedAnnualSubscriptionTrailCodeKey_DMG && discountType == .freeTrail {
- embeddedWC.openWindow(discountType: discountType)
- } else {
- embeddedWC.showWindow(nil)
- }
- embeddedWC.window?.center()
- #else
- // AppStore 免费版本
- if tag == 2 {
- membershipPurchase(.fourDevicesAllAccessPackNew12months_lite, discountCode: nil)
- }
- #endif
- #else
- // AppStore 付费版
- #endif
- }
- }
-
- func appStoreEquityVerification(_ notification: Notification,_ complete: @escaping KMMemberProductComplete) -> Void {
- #if VERSION_FREE
- #if VERSION_DMG
- // DMG
- #else
- // AppStore 免费版本
- var transactionId: String = ""
- var productId: String = ""
- if let userInfo = notification.object as? SKPaymentTransaction {
- transactionId = userInfo.transactionIdentifier ?? ""
- productId = userInfo.payment.productIdentifier
- } else if let userInfo = notification.object as? KMIAPTransaction {
- transactionId = userInfo.transactionIdentifier ?? ""
- productId = userInfo.productIdentifier ?? ""
- } else if let info = notification.userInfo as? [String : Any] {
- transactionId = info["tid"] as? String ?? ""
- productId = info["pid"] as? String ?? ""
- }
-
- if transactionId.isEmpty == false && productId.isEmpty == false {
- KMPrint("Transaction ID: \(transactionId)")
- KMPrint("product ID: \(productId)")
-
- var productCode = ""
- var isSubscribed = false
- if productId == "com.pdfreaderpro.mac_free.member.all_access_pack_advanced_6months.001" {
- productCode = "advanced-annual-subscription-six-month"
- if IAPProductsManager.default().fourDevicesAllAccessPackNew6Months_lite.isSubscribed {
- isSubscribed = true
- }
- } 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 == true {
- productCode = "advanced-annual-subscription-trail"
- } else {
- productCode = "advanced-annual-subscription"
- }
- KMPrint("productCode: \(productCode)")
- if IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite.isSubscribed {
- isSubscribed = true
- }
- } else if productId == "com.pdfreaderpro.mac_free.member.all_access_pack_new_6months.001" {
- productCode = "advanced-annual-subscription-six-month"
- if IAPProductsManager.default().allAccessPackNew6months_lite.isSubscribed {
- isSubscribed = true
- }
- } else if productId == "com.pdfreaderpro.mac_free.member.all_access_pack_12months.001" {
- productCode = "advanced-annual-subscription"
- if IAPProductsManager.default().allAccessPack12months_lite.isSubscribed {
- isSubscribed = true
- }
- } else if productId == "com.pdfreaderpro.mac_free.member.all_access_pack_6months.001" {
- productCode = "advanced-annual-subscription-six-month"
- if IAPProductsManager.default().allAccessPack6months_lite.isSubscribed {
- isSubscribed = true
- }
- } else if productId == "com.pdfreaderpro.mac_free.member.ai_pack_1_month" {
- productCode = "ai-subscription-month"
- if IAPProductsManager.default().aiAllAccessPack1month_lite.isSubscribed {
- isSubscribed = true
- }
- } else if productId == "com.pdfreaderpro.mac_free.member.ai_pack_12_month" {
- productCode = "ai-subscription-year-trail"
- if IAPProductsManager.default().aiAllAccessPack12month_lite.isSubscribed {
- isSubscribed = true
- }
- } else if productId == "com.pdfreaderpro.mac_free.member.all_access_pack_advanced_permanent_license.001" {
- productCode = "advanced-permanent"
- if IAPProductsManager.default().allAccessPackPermanent_lite.isSubscribed {
- isSubscribed = true
- }
- } else if productId == "com.pdfreaderpro.mac_free.member.advanced_add_devices_all_access_pack_advanced_annual.001" {
- productCode = "advanced-annual-subscription-single-upgrade"
- if IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_lite.isSubscribed {
- isSubscribed = true
- }
- } else if productId == "com.pdfreaderpro.mac_free.member.advanced_add_2_devices_all_access_pack_advanced_annual.001" {
- productCode = "advanced-annual-subscription-multi-upgrade"
- if IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_lite.isSubscribed {
- isSubscribed = true
- }
- }
- if isSubscribed {
- KMMemberCenterManager.manager.appStoreEquityVerification(applePayProductId: productId, transactionId: transactionId, productCode: productCode) { success, result in
- DispatchQueue.main.async {
- if success {
- complete(true, result)
- } else {
- complete(false, result)
- }
- }
- }
- }
- } else {
- print(NSLocalizedString("Order does not exist.", tableName: "MemberCenterLocalizable", comment: ""))
- }
- #endif
- #else
- // AppStore 付费版
- if let userInfo = notification.object as? SKPaymentTransaction,
- let transactionId = userInfo.transactionIdentifier as? String,
- let productId = userInfo.payment.productIdentifier as? String {
- print("Transaction ID: \(transactionId)")
- print("product ID: \(productId)")
-
- var productCode = ""
- var isSubscribed = false
- if productId == "com.pdfreaderpro.mac.ai_pack_1_month" {
- productCode = "ai-subscription-month"
- if IAPProductsManager.default().aiAllAccessPack1month_pro.isSubscribed {
- isSubscribed = true
- }
- } else if productId == "com.pdfreaderpro.mac.ai_pack_12_month" {
- productCode = "ai-subscription-year-trail"
- if IAPProductsManager.default().aiAllAccessPack12month_pro.isSubscribed {
- isSubscribed = true
- }
- } else if productId == "com.pdfreaderpro.mac.pdf_to_office_pack_permanent_license.001" {
- productCode = "advanced-permanent-mac-upgrade"
- if IAPProductsManager.default().pdfToOfficePackPermanent_pro.isSubscribed {
- isSubscribed = true
- }
- } else if productId == "com.pdfreaderpro.mac.all_access_pack_advanced_annual.001" {
- productCode = "advanced-permanent-mac-upgrade"
- if IAPProductsManager.default().fourDevicesAllAccessPack12months_pro.isSubscribed {
- isSubscribed = true
- }
- } else if productId == "com.pdfreaderpro.mac.standard_add_devices_all_access_pack_advanced_annual.001" {
- productCode = "advanced-annual-subscription-standard-upgrade"
- if IAPProductsManager.default().standardAddDevicesAllAccessPack12months_pro.isSubscribed {
- isSubscribed = true
- }
- } else if productId == "com.pdfreaderpro.mac.advanced_add_devices_all_access_pack_advanced_annual.001" {
- productCode = "advanced-annual-subscription-single-upgrade"
- if IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_pro.isSubscribed {
- isSubscribed = true
- }
- } else if productId == "com.pdfreaderpro.mac.advanced_add_2_devices_all_access_pack_advanced_annual.001" {
- productCode = "advanced-annual-subscription-multi-upgrade"
- if IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_pro.isSubscribed {
- isSubscribed = true
- }
- }
- if isSubscribed {
- KMMemberCenterManager.manager.appStoreEquityVerification(applePayProductId: productId, transactionId: transactionId, productCode: productCode) { success, result in
- if success {
- complete(true, result)
- } else {
- complete(false, result)
- }
-
- }
- }
- } else {
- print(NSLocalizedString("Order does not exist.", tableName: "MemberCenterLocalizable", comment: ""))
- }
- #endif
- }
-
- var isCancelAutoRenew: Bool {
- return IAPProductsManager.default().isCancelAutoRenew()
- }
-
- var isShowSale: Bool {
- if #available(macOS 10.14.4, *), isCancelAutoRenew {
- #if VERSION_FREE
- #if VERSION_DMG
- // DMG
- if let info = KMAdvertisementManager.manager.info.StoreUserRecovery?.content?.first, !(info.show! as NSString).boolValue {
- return false
- }
- #else
- // AppStore 免费版本
- let manager = IAPProductsManager.default()
- let isSubscribed_newlyMonth = manager?.fourDevicesAllAccessPackNew6Months_lite.isSubscribed ?? false
- let isSubscribed_year = manager?.fourDevicesAllAccessPackNew12months_lite.isSubscribed ?? false
- if isSubscribed_newlyMonth || isSubscribed_year {
- return false
- }
- if let info = KMAdvertisementManager.manager.info.StoreUserRecovery?.content?.first, !(info.show! as NSString).boolValue {
- return false
- }
- if let discounts = manager?.fourDevicesAllAccessPackNew12months_lite.product?.discounts, discounts.count <= 0 {
- return false
- }
- #endif
- #else
- // AppStore 付费版
- if let info = KMAdvertisementManager.manager.info.StoreUserRecovery?.content?.first, !(info.show! as NSString).boolValue {
- return false
- }
- #endif
- return true
- }
- return false
- }
-
- #if !VERSION_DMG
- func checkSubscriptionOffer(for product: SKProduct?) -> KMPaymentModeType {
- guard let theProduct = product else {
- return .null
- }
- if let introductoryPrice = theProduct.introductoryPrice {
- switch introductoryPrice.paymentMode {
- case .freeTrial:
- return .freeTrial
- case .payAsYouGo:
- return .payAsYouGo
- case .payUpFront:
- return .payUpFront
- @unknown default:
- print("Unknown introductory offer type.")
- }
- }
- if #available(iOS 12.2, *), !theProduct.discounts.isEmpty {
- return .discount
- }
- return .null
- }
- #endif
- // MARK: Private Method
-
- /**
- 会员购买
- */
- private func membershipPurchase(_ type: KMPurchasedProductType, discountCode: String?) -> Void {
- #if !VERSION_DMG
- if type == .fourDevicesAllAccessPackNew6months_lite || type == .fourDevicesAllAccessPackNew12months_lite {
- if isPurchaseSwitch {
- if let data = discountCode, data.isEmpty == false {
- IAPProductsManager.default().buySubProduct(IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite, discountCode: data)
- } else {
- IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite, discount: isCancelAutoRenew)
- }
- } else {
- if let data = discountCode, data.isEmpty == false {
- IAPProductsManager.default().buySubProduct(IAPProductsManager.default().fourDevicesAllAccessPackNew6Months_lite, discountCode: data)
- } else {
- IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().fourDevicesAllAccessPackNew6Months_lite, discount: isCancelAutoRenew)
- }
- }
- } else if type == .aiAllAccessPack1month_lite {
- IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().aiAllAccessPack1month_lite, discount: isCancelAutoRenew)
- } else if type == .aiAllAccessPack12month_lite {
- IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().aiAllAccessPack12month_lite, discount: isCancelAutoRenew)
- } else if type == .allAccessPackPermanent_lite {
- IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().allAccessPackPermanent_lite, discount: isCancelAutoRenew)
- } else if type == .advancedAddDevicesAllAccessPack12months_lite {
- IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_lite, discount: isCancelAutoRenew)
- } else if type == .advancedAdd2DevicesAllAccessPack12months_lite {
- IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_lite, discount: isCancelAutoRenew)
- } else if type == .aiAllAccessPack1month_pro {
- IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().aiAllAccessPack1month_pro, discount: isCancelAutoRenew)
- } else if type == .aiAllAccessPack12month_pro {
- IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().aiAllAccessPack12month_pro, discount: isCancelAutoRenew)
- } else if type == .pdfToOfficePackPermanent_pro {
- IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().pdfToOfficePackPermanent_pro, discount: isCancelAutoRenew)
- } else if type == .fourDevicesAllAccessPack12months_pro {
- IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().fourDevicesAllAccessPack12months_pro, discount: isCancelAutoRenew)
- } else if type == .standardAddDevicesAllAccessPack12months_pro {
- IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().standardAddDevicesAllAccessPack12months_pro, discount: isCancelAutoRenew)
- } else if type == .advancedAddDevicesAllAccessPack12months_pro {
- IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_pro, discount: isCancelAutoRenew)
- } else if type == .advancedAdd2DevicesAllAccessPack12months_pro {
- IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_pro, discount: isCancelAutoRenew)
- }
- #endif
- }
-
- private func _isUSD() -> Bool {
- return NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD"
- }
- // MARK: Action Method
-
- /**
- 恢复购买
- */
- func productRestore() -> Void {
- IAPProductsManager.default().restoreSubscriptions()
- }
-
- func privacyPolicyAction() -> Void {
- NSWorkspace.shared.open(URL(string: "https://www.pdfreaderpro.com/privacy-policy")!)
- }
-
- func termOfSerAction() -> Void {
- NSWorkspace.shared.open(URL(string: "https://www.pdfreaderpro.com/terms_of_service")!)
- }
-
- // MARK: Get & Set
-
- /**
- 当前比较表产品列表内容
- */
- var products: [KMCompareProductType] {
- if state == .trial {
- return [.free, .freeTrial]
- } else if state == .dmg_Base {
- return [.free, .allPlatformStandard, .allPlatformAdvanced_12, .dualPlatformAdvanced]
- } else if state == .dmg_Upgrades1 {
- return [.allPlatformAdvanced_12]
- } else if state == .dmg_Upgrades1 {
- return [.allPlatformAdvanced_12]
- } else if state == .lite_Base {
- return [.free, .allPlatformAdvanced_6, .allPlatformAdvanced_12, .dualPlatformAdvanced]
- } else if state == .lite_MacWindows {
- return [.allPlatformAdvanced_12]
- } else if state == .pro_Base {
- return [.allPlatformAdvanced_12, .macPlatformAdvanced]
- } else if state == .pro_Advanced {
- return [.allPlatformAdvanced_12]
- }
- return []
- }
-
- /**
- 比较表数据源
- */
- var dataSource: [Any] {
- if isPurchaseSwitch {
- // 试用 全平台标准版年订阅 全平台高级版6/12个月订阅 Mac&Windows双平台高级版永久 MAC单平台高级版永久
- //MAC单平台标准版永久
- if KMMemberInfo.shared.vip_levels == "1" && KMMemberInfo.shared.vip_status != 2 {
- var aiYear = NSLocalizedString("Free for the 1st year, then auto-renew at $125.99/year", tableName: "MemberCenterLocalizable", comment: "")
- #if VERSION_FREE
- #if VERSION_DMG
- // DMG
- if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
- let priceStr = "USD $\(getDMGPrice(productCode: KMAISubscriptionYearTrailCodeKey_DMG))"
- aiYear = String(format: NSLocalizedString("Free for the 1st year, then auto-renew at %@/year", tableName: "MemberCenterLocalizable", comment: ""), priceStr)
- } else {
- let priceStr = "CNY ¥\(getDMGCNYPrice(productCode: KMAISubscriptionYearTrailCodeKey_DMG))"
- aiYear = String(format: NSLocalizedString("Free for the 1st year, then auto-renew at %@/year", tableName: "MemberCenterLocalizable", comment: ""), priceStr)
- }
- #else
- // AppStore 免费版本
- aiYear = String(format: NSLocalizedString("Free for the 1st year, then auto-renew at %@/year", tableName: "MemberCenterLocalizable", comment: ""), IAPProductsManager.default().aiAllAccessPack12month_lite.price())
- #endif
- #else
- // AppStore 付费版
- aiYear = String(format: NSLocalizedString("Free for the 1st year, then auto-renew at %@/year", tableName: "MemberCenterLocalizable", comment: ""), IAPProductsManager.default().aiAllAccessPack12month_pro.price())
- #endif
- return [
- "Membership Benefits",
- ["Supported platforms", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows", "mac"],
- ["Maximum number of accessible devices", "4 devices", "4 devices", "4 devices", "1 device", "1 device"],
- ["1-year AI free use", "X", "X", aiYear, "X", "X"],
- "PDF to Office",
- ["Convert PDFs to Word, HTML, TXT, JPEG or PNG files", "X", "Standard", "Advanced", "Advanced", "Advanced"],
- ["Turn PDF to PPT, Excel, RTF, CSV, and more", "X", "X", "✓", "✓", "✓"],
- ["Convert PDF to TIFF, BMP, GIF or TGA files", "X", "X", "✓", "✓", "✓"],
- "Edit PDF",
- ["Add and edit text in PDF", "X", "✓", "✓", "✓", "✓"],
- ["Edit, crop, replace image in PDF", "X", "✓", "✓", "✓", "✓"],
- "OCR",
- ["Extract texts from image-based or scanned PDF", "X", "✓", "✓", "✓", "✓"],
- "Organize Pages",
- ["Extract, rotate, rearrange, replace, add, delete pages", "X", "✓", "✓", "✓", "✓"],
- ["Split PDFs into multiple files", "X", "✓", "✓", "✓", "✓"],
- "Advanced Editing Tools",
- ["Merge multiple documents into a new PDF", "Up to 2 files or 20 MB", "✓", "✓", "✓", "✓", "✓"],
- ["Add & edit watermark", "X", "✓", "✓", "✓", "✓"],
- ["Add header, footer, page numbers", "X", "✓", "✓", "✓", "✓"],
- ["Add Bates Number", "X", "✓", "✓", "✓", "✓"],
- ["Insert PDF page background by color or image", "X", "✓", "✓", "✓", "✓"],
- ["Create fattened copies", "X", "✓", "✓", "✓", "✓"],
- ["Extract Images", "X", "✓", "✓", "✓", "✓"],
- ["Extract tables", "X", "X", "✓", "✓", "✓"],
- ["Measuring Tools", "X", "✓", "✓", "✓", "✓"],
- "Fill & Sign",
- ["Create digital signature", "X", "✓", "✓", "✓", "✓"],
- ["Create & Edit & Fill Adobe Fillable PDF Forms", "X", "✓", "✓", "✓", "✓"],
- "Security",
- ["Batch encrypting PDF documents", "X", "✓", "✓", "✓", "✓"],
- ["PDF Password Remover", "X", "✓", "✓", "✓", "✓"],
- ["Redact sensitive information", "X", "✓", "✓", "✓", "✓"],
- "Create PDF",
- ["Convert JPEG, JPG, PNG, TIFF, BMP or PSD files to PDFs", "1 file", "✓", "✓", "✓", "✓"],
- ["Create PDFs from a scanner and iOS devices", "X", "✓", "✓", "✓", "✓"],
- "Annotations",
- ["Customize PDF stamps", "X", "✓", "✓", "✓", "✓"],
- ["Hyperlink", "Page Number", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email"],
- ["Signature", "Standard", "Advanced", "Advanced", "Advanced", "Advanced"],
- ["Table", "X", "✓", "✓", "✓", "✓"],
- "View PDF",
- ["Multi-tab viewer", "X", "✓", "✓", "✓", "✓"],
- ["Various printing types: poster, booklet, multi-page printing", "X", "✓", "✓", "✓", "✓"],
- ["Customize theme colors: Light Mode, Dark Mode, Sepia Mode and more", "X", "✓", "✓", "✓", "✓"],
- ["Split View to compare files", "X", "✓", "✓", "✓", "✓"],
- "Subscription Based Solution",
- ["Access all premium features in app", "X", "12 months", "12 months", "∞", "∞"],
- ["Priority customer support", "X", "✓", "✓", "✓", "✓"],
- ["Ad-free", "X", "✓", "✓", "✓", "✓"]
- ]
- } else {
- return [
- "Membership Benefits",
- ["Supported platforms", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows", "mac"],
- ["Maximum number of accessible devices", "4 devices", "4 devices", "4 devices", "1 device", "1 device"],
- ["1-year AI free use", "X", "X", "X", "X", "X"],
- "PDF to Office",
- ["Convert PDFs to Word, HTML, TXT, JPEG or PNG files", "X", "Standard", "Advanced", "Advanced", "Advanced"],
- ["Turn PDF to PPT, Excel, RTF, CSV, and more", "X", "X", "✓", "✓", "✓"],
- ["Convert PDF to TIFF, BMP, GIF or TGA files", "X", "X", "✓", "✓", "✓"],
- "Edit PDF",
- ["Add and edit text in PDF", "X", "✓", "✓", "✓", "✓"],
- ["Edit, crop, replace image in PDF", "X", "✓", "✓", "✓", "✓"],
- "OCR",
- ["Extract texts from image-based or scanned PDF", "X", "✓", "✓", "✓", "✓"],
- "Organize Pages",
- ["Extract, rotate, rearrange, replace, add, delete pages", "X", "✓", "✓", "✓", "✓"],
- ["Split PDFs into multiple files", "X", "✓", "✓", "✓", "✓"],
- "Advanced Editing Tools",
- ["Merge multiple documents into a new PDF", "Up to 2 files or 20 MB", "✓", "✓", "✓", "✓", "✓"],
- ["Add & edit watermark", "X", "✓", "✓", "✓", "✓"],
- ["Add header, footer, page numbers", "X", "✓", "✓", "✓", "✓"],
- ["Add Bates Number", "X", "✓", "✓", "✓", "✓"],
- ["Insert PDF page background by color or image", "X", "✓", "✓", "✓", "✓"],
- ["Create fattened copies", "X", "✓", "✓", "✓", "✓"],
- ["Extract Images", "X", "✓", "✓", "✓", "✓"],
- ["Extract tables", "X", "X", "✓", "✓", "✓"],
- ["Measuring Tools", "X", "✓", "✓", "✓", "✓"],
- "Fill & Sign",
- ["Create digital signature", "X", "✓", "✓", "✓", "✓"],
- ["Create & Edit & Fill Adobe Fillable PDF Forms", "X", "✓", "✓", "✓", "✓"],
- "Security",
- ["Batch encrypting PDF documents", "X", "✓", "✓", "✓", "✓"],
- ["PDF Password Remover", "X", "✓", "✓", "✓", "✓"],
- ["Redact sensitive information", "X", "✓", "✓", "✓", "✓"],
- "Create PDF",
- ["Convert JPEG, JPG, PNG, TIFF, BMP or PSD files to PDFs", "1 file", "✓", "✓", "✓", "✓"],
- ["Create PDFs from a scanner and iOS devices", "X", "✓", "✓", "✓", "✓"],
- "Annotations",
- ["Customize PDF stamps", "X", "✓", "✓", "✓", "✓"],
- ["Hyperlink", "Page Number", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email"],
- ["Signature", "Standard", "Advanced", "Advanced", "Advanced", "Advanced"],
- ["Table", "X", "✓", "✓", "✓", "✓"],
- "View PDF",
- ["Multi-tab viewer", "X", "✓", "✓", "✓", "✓"],
- ["Various printing types: poster, booklet, multi-page printing", "X", "✓", "✓", "✓", "✓"],
- ["Customize theme colors: Light Mode, Dark Mode, Sepia Mode and more", "X", "✓", "✓", "✓", "✓"],
- ["Split View to compare files", "X", "✓", "✓", "✓", "✓"],
- "Subscription Based Solution",
- ["Access all premium features in app", "X", "12 months", "12 months", "∞", "∞"],
- ["Priority customer support", "X", "✓", "✓", "✓", "✓"],
- ["Ad-free", "X", "✓", "✓", "✓", "✓"]
- ]
- }
- } else {
- if KMMemberInfo.shared.vip_levels == "1" && KMMemberInfo.shared.vip_status != 2 {
- return [
- "Membership Benefits",
- ["Supported platforms", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows", "mac"],
- ["Maximum number of accessible devices", "4 devices", "4 devices", "4 devices", "1 device", "1 device"],
- ["1-year AI free use", "X", "X", "X", "X", "X"],
- "PDF to Office",
- ["Convert PDFs to Word, HTML, TXT, JPEG or PNG files", "X", "Standard", "Advanced", "Advanced", "Advanced"],
- ["Turn PDF to PPT, Excel, RTF, CSV, and more", "X", "X", "✓", "✓", "✓"],
- ["Convert PDF to TIFF, BMP, GIF or TGA files", "X", "X", "✓", "✓", "✓"],
- "Edit PDF",
- ["Add and edit text in PDF", "X", "✓", "✓", "✓", "✓"],
- ["Edit, crop, replace image in PDF", "X", "✓", "✓", "✓", "✓"],
- "OCR",
- ["Extract texts from image-based or scanned PDF", "X", "✓", "✓", "✓", "✓"],
- "Organize Pages",
- ["Extract, rotate, rearrange, replace, add, delete pages", "X", "✓", "✓", "✓", "✓"],
- ["Split PDFs into multiple files", "X", "✓", "✓", "✓", "✓"],
- "Advanced Editing Tools",
- ["Merge multiple documents into a new PDF", "Up to 2 files or 20 MB", "✓", "✓", "✓", "✓", "✓"],
- ["Add & edit watermark", "X", "✓", "✓", "✓", "✓"],
- ["Add header, footer, page numbers", "X", "✓", "✓", "✓", "✓"],
- ["Add Bates Number", "X", "✓", "✓", "✓", "✓"],
- ["Insert PDF page background by color or image", "X", "✓", "✓", "✓", "✓"],
- ["Create fattened copies", "X", "✓", "✓", "✓", "✓"],
- ["Extract Images", "X", "✓", "✓", "✓", "✓"],
- ["Extract tables", "X", "X", "✓", "✓", "✓"],
- ["Measuring Tools", "X", "✓", "✓", "✓", "✓"],
- "Fill & Sign",
- ["Create digital signature", "X", "✓", "✓", "✓", "✓"],
- ["Create & Edit & Fill Adobe Fillable PDF Forms", "X", "✓", "✓", "✓", "✓"],
- "Security",
- ["Batch encrypting PDF documents", "X", "✓", "✓", "✓", "✓"],
- ["PDF Password Remover", "X", "✓", "✓", "✓", "✓"],
- ["Redact sensitive information", "X", "✓", "✓", "✓", "✓"],
- "Create PDF",
- ["Convert JPEG, JPG, PNG, TIFF, BMP or PSD files to PDFs", "1 file", "✓", "✓", "✓", "✓"],
- ["Create PDFs from a scanner and iOS devices", "X", "✓", "✓", "✓", "✓"],
- "Annotations",
- ["Customize PDF stamps", "X", "✓", "✓", "✓", "✓"],
- ["Hyperlink", "Page Number", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email"],
- ["Signature", "Standard", "Advanced", "Advanced", "Advanced", "Advanced"],
- ["Table", "X", "✓", "✓", "✓", "✓"],
- "View PDF",
- ["Multi-tab viewer", "X", "✓", "✓", "✓", "✓"],
- ["Various printing types: poster, booklet, multi-page printing", "X", "✓", "✓", "✓", "✓"],
- ["Customize theme colors: Light Mode, Dark Mode, Sepia Mode and more", "X", "✓", "✓", "✓", "✓"],
- ["Split View to compare files", "X", "✓", "✓", "✓", "✓"],
- "Subscription Based Solution",
- ["Access all premium features in app", "X", "6 months", "6 months", "∞", "∞"],
- ["Priority customer support", "X", "✓", "✓", "✓", "✓"],
- ["Ad-free", "X", "✓", "✓", "✓", "✓"]
- ]
- } else {
- return [
- "Membership Benefits",
- ["Supported platforms", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows", "mac"],
- ["Maximum number of accessible devices", "4 devices", "4 devices", "4 devices", "1 device", "1 device"],
- ["1-year AI free use", "X", "X", "X", "X", "X"],
- "PDF to Office",
- ["Convert PDFs to Word, HTML, TXT, JPEG or PNG files", "X", "Standard", "Advanced", "Advanced", "Advanced"],
- ["Turn PDF to PPT, Excel, RTF, CSV, and more", "X", "X", "✓", "✓", "✓"],
- ["Convert PDF to TIFF, BMP, GIF or TGA files", "X", "X", "✓", "✓", "✓"],
- "Edit PDF",
- ["Add and edit text in PDF", "X", "✓", "✓", "✓", "✓"],
- ["Edit, crop, replace image in PDF", "X", "✓", "✓", "✓", "✓"],
- "OCR",
- ["Extract texts from image-based or scanned PDF", "X", "✓", "✓", "✓", "✓"],
- "Organize Pages",
- ["Extract, rotate, rearrange, replace, add, delete pages", "X", "✓", "✓", "✓", "✓"],
- ["Split PDFs into multiple files", "X", "✓", "✓", "✓", "✓"],
- "Advanced Editing Tools",
- ["Merge multiple documents into a new PDF", "Up to 2 files or 20 MB", "✓", "✓", "✓", "✓", "✓"],
- ["Add & edit watermark", "X", "✓", "✓", "✓", "✓"],
- ["Add header, footer, page numbers", "X", "✓", "✓", "✓", "✓"],
- ["Add Bates Number", "X", "✓", "✓", "✓", "✓"],
- ["Insert PDF page background by color or image", "X", "✓", "✓", "✓", "✓"],
- ["Create fattened copies", "X", "✓", "✓", "✓", "✓"],
- ["Extract Images", "X", "✓", "✓", "✓", "✓"],
- ["Extract tables", "X", "X", "✓", "✓", "✓"],
- ["Measuring Tools", "X", "✓", "✓", "✓", "✓"],
- "Fill & Sign",
- ["Create digital signature", "X", "✓", "✓", "✓", "✓"],
- ["Create & Edit & Fill Adobe Fillable PDF Forms", "X", "✓", "✓", "✓", "✓"],
- "Security",
- ["Batch encrypting PDF documents", "X", "✓", "✓", "✓", "✓"],
- ["PDF Password Remover", "X", "✓", "✓", "✓", "✓"],
- ["Redact sensitive information", "X", "✓", "✓", "✓", "✓"],
- "Create PDF",
- ["Convert JPEG, JPG, PNG, TIFF, BMP or PSD files to PDFs", "1 file", "✓", "✓", "✓", "✓"],
- ["Create PDFs from a scanner and iOS devices", "X", "✓", "✓", "✓", "✓"],
- "Annotations",
- ["Customize PDF stamps", "X", "✓", "✓", "✓", "✓"],
- ["Hyperlink", "Page Number", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email"],
- ["Signature", "Standard", "Advanced", "Advanced", "Advanced", "Advanced"],
- ["Table", "X", "✓", "✓", "✓", "✓"],
- "View PDF",
- ["Multi-tab viewer", "X", "✓", "✓", "✓", "✓"],
- ["Various printing types: poster, booklet, multi-page printing", "X", "✓", "✓", "✓", "✓"],
- ["Customize theme colors: Light Mode, Dark Mode, Sepia Mode and more", "X", "✓", "✓", "✓", "✓"],
- ["Split View to compare files", "X", "✓", "✓", "✓", "✓"],
- "Subscription Based Solution",
- ["Access all premium features in app", "X", "6 months", "6 months", "∞", "∞"],
- ["Priority customer support", "X", "✓", "✓", "✓", "✓"],
- ["Ad-free", "X", "✓", "✓", "✓", "✓"]
- ]
- }
- }
- }
-
- /**
- 是否黑五活动期
- */
- var isBlackFive: Bool {
- #if DEBUG
- return false
- #endif
- if let loginContent = KMAdvertisementManager.manager.info.topRightInfoContent {
- if loginContent.content?.isEmpty == false {
- return true
- }
- }
- return false
- }
- }
|