KMProductModel.swift 119 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909
  1. //
  2. // KMProductModel.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by wanjun on 2024/11/6.
  6. //
  7. import Foundation
  8. import Combine
  9. #if !VERSION_DMG
  10. import StoreKit
  11. #endif
  12. @objc enum KMCompareTableType : Int {
  13. case trial = 0 // 试用比较表
  14. case dmg_Base // DMG 购买比较表
  15. case dmg_Upgrades1 // DMG 升级比较表 39.99
  16. case dmg_Upgrades2 // DMG 升级比较表 49.99
  17. case lite_Base // Lite 基础版
  18. case lite_MacWindows // Lite Mac&Windows双平台高级版永久
  19. case pro_Base // Pro 基础版
  20. case pro_Advanced // Pro Mac单平台高级版永久
  21. }
  22. @objc enum KMCompareProductType : Int {
  23. case free = 0 // 免费
  24. case freeTrial // 试用
  25. case allPlatformStandard // 全平台标准版年订阅
  26. case dualPlatformAdvanced // Mac&Windows双平台高级版永久
  27. case allPlatformAdvanced_6 // 全平台高级版6个月订阅
  28. case allPlatformAdvanced_12 // 全平台高级版12个月订阅
  29. case macPlatformAdvanced // MAC单平台高级版永久
  30. }
  31. @objc enum KMPurchasedProductType : Int {
  32. case fourDevicesAllAccessPackNew6months_lite = 0 // 4_devices_all_access_pack_new_6months(订阅)
  33. case fourDevicesAllAccessPackNew12months_lite // 4_devices_all_access_pack_12months(订阅)
  34. // case allAccessPackNew6months_lite // all_access_pack_new_6months(订阅)
  35. // case allAccessPack12months_lite // all_access_pack_12months(订阅)
  36. // case allAccessPack6months_lite // all_access_pack_6months(订阅)
  37. case aiAllAccessPack1month_lite // ai_all_access_pack_1month(订阅)
  38. case aiAllAccessPack12month_lite // ai_all_access_pack_12month(订阅)
  39. case allAccessPackPermanent_lite // all_access_pack_permanent(永久)
  40. case advancedAddDevicesAllAccessPack12months_lite // advanced_add_devices_all_access_pack_12months(订阅)单平台升级到全平台
  41. case advancedAdd2DevicesAllAccessPack12months_lite // advanced_add_2_devices_all_access_pack_12months(订阅)双平台升级到全平台
  42. case aiAllAccessPack1month_pro // ai_all_access_pack_1month(订阅)
  43. case aiAllAccessPack12month_pro // ai_all_access_pack_1month(订阅)
  44. case pdfToOfficePackPermanent_pro // pdf_to_office_pack_permanent(永久)
  45. case fourDevicesAllAccessPack12months_pro // 4_devices_all_access_pack_12months(全平台高级年订阅)
  46. case standardAddDevicesAllAccessPack12months_pro // standard_add_devices_all_access_pack_12months(订阅)
  47. case advancedAddDevicesAllAccessPack12months_pro // advanced_add_devices_all_access_pack_12months(订阅)
  48. case advancedAdd2DevicesAllAccessPack12months_pro // advanced_add_2_devices_all_access_pack_12months(订阅)
  49. case pdfReaderProStandard_dmg // 全平台标准版年订阅
  50. case pdfReaderProAdvanced_dmg // 全平台高级版年订阅
  51. case pdfReaderProPermanent_dmg // Mac&Windows双平台高级版永久
  52. case pdfReaderProAIAnnual_dmg // AI 年订阅
  53. case pdfReaderProAIMonthly_dmg // AI 月订阅
  54. case pdfToOffice_dmg // 转档包 永久
  55. case add2Device_dmg // 多设备全平台
  56. case add3Device_dmg // 单平台升级高级版
  57. }
  58. @objc enum KMPaymentModeType : Int {
  59. case null = 0
  60. case freeTrial
  61. case payAsYouGo
  62. case payUpFront
  63. case discount
  64. }
  65. typealias AppstorePurchaseComplete = (_ success: Bool,_ msg: String) -> Void
  66. @objcMembers
  67. class KMProductModel: ObservableObject {
  68. static let shared = KMProductModel()
  69. /**
  70. 比较表类型
  71. */
  72. @Published var state: KMCompareTableType = .trial
  73. /**
  74. 高级版半年 或 年订阅,true为年订阅,false为半年订阅,默认true为年订阅
  75. */
  76. @Published var isPurchaseSwitch: Bool = true
  77. // MARK: DMG Public Property
  78. /**
  79. DMG 版本所有已经上架产品记录(暂时无教育优惠)
  80. */
  81. var dmgProductDatas: KMMemberProductResult?
  82. /**
  83. DMG 版本 已经登录用户 最后一次价格获取
  84. */
  85. var dmgLastGetProductPriceInfos: KMMemberProductResult?
  86. /**
  87. DMG 版本 已经登录用户 最后一次批量价格获取
  88. */
  89. var dmgLastGetBatchProductPriceInfos: KMMemberProductResult?
  90. /**
  91. DMG 版本 已经登录用户 最后一次验证商品优惠券价格获取
  92. */
  93. var dmgLastCheckCouponProductPriceInfos: KMMemberProductResult?
  94. /**
  95. DMG 版本 已经登录用户 最后一次创建的买断订单返回信息
  96. */
  97. var dmgLastCreatOrderProductInfos: KMMemberProductResult?
  98. /**
  99. DMG 版本 已经登录用户 最后一次创建的买断订单返回信息
  100. */
  101. var dmgLastCreatSubscriberProductInfos: KMMemberProductResult?
  102. // MARK: DMG Public Method
  103. func checkConnectionAvailable() -> Void {
  104. if KMMemberCenterManager.manager.isConnectionAvailable() == false {
  105. let alert = NSAlert()
  106. alert.alertStyle = .critical
  107. alert.messageText = NSLocalizedString("Error Information", comment: "")
  108. alert.informativeText = NSLocalizedString("Please make sure your internet connection is available.", comment: "")
  109. alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
  110. alert.runModal()
  111. return
  112. }
  113. }
  114. /**
  115. @abstract 获取DMG服务器架上所有商品 (得到的价格是原始价格)
  116. @param
  117. */
  118. func getDMGProductDatas(discountCode: String, _ complete: @escaping KMMemberProductComplete) -> Void {
  119. checkConnectionAvailable()
  120. KMMemberCenterManager.manager.getListingProducts(isEducation: 0, discountCode: discountCode) { [weak self] success, result in
  121. guard let productsArrays : KMMemberProductResult = result else { return }
  122. self?.dmgProductDatas = productsArrays
  123. complete(success, result)
  124. }
  125. if KMMemberInfo.shared.isLogin {
  126. // getDMGProductPriceInfosForMember(productId: "SP2024102300004", isEducation: 0) { [weak self] success, result in
  127. //
  128. //
  129. // }
  130. // getDMGBatchProductPriceInfosForMember(productId: "SP2024102300004", num: 10) { [weak self] success, result in
  131. //
  132. //
  133. // }
  134. // getDMGProductListInfosForMember(orderStatus: 0) { [weak self] success, result in
  135. //
  136. // }
  137. //创建买断订单
  138. // creatOrder(productId: "SP2024102300004", paymentMethod: 0, price: "119.99", discountFlag: 0, couponCode: "", num: 1) { [weak self] success, result in
  139. //
  140. // }
  141. //创建订阅订单(创建买断订单后会报错已经是购买用户,不能重复购买)
  142. // createSubscriber(productId: "SP2024102300003", paymentMethod: 0, price: "99.99", discountFlag: 0, couponCode: "", num: 1) { [weak self] success, result in
  143. //
  144. // }
  145. // getDMGProductOrderIdInfosForMember(orderId: "94b10d5f1ca193948e005503bff0df11") { [weak self] success, result in
  146. //
  147. // }
  148. }
  149. }
  150. /**
  151. @abstract 获取DMG产品价格(美元)
  152. */
  153. func getDMGPrice(productCode: String) -> String {
  154. guard let productModels = dmgProductDatas?.listingProducts else { return "" }
  155. for model in productModels {
  156. if model.code == productCode {
  157. if model.upgradePriceString?.isEmpty == false {
  158. return String(format: "%.2f", Float(model.upgradePriceString ?? "0") ?? 0)
  159. } else if model.displayPriceString?.isEmpty == false {
  160. if model.displayPriceString == "0.00" {
  161. return String(format: "%.2f", Float(model.priceString ?? "0") ?? 0)
  162. } else {
  163. return String(format: "%.2f", Float(model.displayPriceString ?? "0") ?? 0)
  164. }
  165. } else {
  166. return String(format: "%.2f", Float(model.priceString ?? "0") ?? 0)
  167. }
  168. }
  169. }
  170. return ""
  171. }
  172. /**
  173. @abstract 获取DMG产品价格(人民币)
  174. */
  175. func getDMGCNYPrice(productCode: String) -> String {
  176. guard let productModels = dmgProductDatas?.listingProducts else { return "" }
  177. for model in productModels {
  178. if model.code == productCode {
  179. if model.cnyUpgradePriceString?.isEmpty == false {
  180. return String(format: "%.2f", Float(model.cnyUpgradePriceString ?? "0") ?? 0)
  181. } else if model.displayCnyPriceString?.isEmpty == false {
  182. if model.displayCnyPriceString == "0.00" {
  183. return String(format: "%.2f", Float(model.cnyPriceString ?? "0") ?? 0)
  184. } else {
  185. return String(format: "%.2f", Float(model.displayCnyPriceString ?? "0") ?? 0)
  186. }
  187. } else {
  188. return String(format: "%.2f", Float(model.cnyPriceString ?? "0") ?? 0)
  189. }
  190. }
  191. }
  192. return ""
  193. }
  194. /**
  195. @abstract 获取DMG产品折扣价格(美元)
  196. */
  197. func getDMGDisplayPrice(productCode: String) -> String {
  198. guard let productModels = dmgProductDatas?.listingProducts else { return "" }
  199. for model in productModels {
  200. if model.code == productCode {
  201. return String(format: "%.2f", Float(model.displayPriceString ?? "0") ?? 0)
  202. }
  203. }
  204. return ""
  205. }
  206. /**
  207. @abstract 获取DMG产品折扣价格(人民币)
  208. */
  209. func getDMGDisplayCNYPrice(productCode: String) -> String {
  210. guard let productModels = dmgProductDatas?.listingProducts else { return "" }
  211. for model in productModels {
  212. if model.code == productCode {
  213. return String(format: "%.2f", Float(model.displayCnyPriceString ?? "0") ?? 0)
  214. }
  215. }
  216. return ""
  217. }
  218. /** 获取DMG产品原价(美元)*/
  219. func getDMGOriginalPrice(productCode: String) -> String {
  220. guard let productModels = dmgProductDatas?.listingProducts else { return "" }
  221. for model in productModels {
  222. if model.code == productCode {
  223. return String(format: "%.2f", Float(model.priceString ?? "0") ?? 0)
  224. }
  225. }
  226. return ""
  227. }
  228. /** 获取DMG产品原价(人民币)*/
  229. func getDMGOriginalCNYPrice(productCode: String) -> String {
  230. guard let productModels = dmgProductDatas?.listingProducts else { return "" }
  231. for model in productModels {
  232. if model.code == productCode {
  233. return String(format: "%.2f", Float(model.cnyPriceString ?? "0") ?? 0)
  234. }
  235. }
  236. return ""
  237. }
  238. /** 获取DMG产品优惠卷价格(美元)*/
  239. func getDMGDisplayAmountPrice(productCode: String, pointNum: Int) -> String {
  240. guard let productModels = dmgProductDatas?.listingProducts else { return "" }
  241. for model in productModels {
  242. if model.code == productCode {
  243. let formatStr = "%.\(pointNum)f"
  244. return String(format: formatStr, Float(model.displayAmount ?? "0") ?? 0)
  245. }
  246. }
  247. return ""
  248. }
  249. /** 获取DMG产品优惠卷价格(人民币)*/
  250. func getDMGDisplayAmountCNYPrice(productCode: String, pointNum: Int) -> String {
  251. guard let productModels = dmgProductDatas?.listingProducts else { return "" }
  252. for model in productModels {
  253. if model.code == productCode {
  254. let formatStr = "%.\(pointNum)f"
  255. return String(format: formatStr, Float(model.cnyDisplayAmount ?? "0") ?? 0)
  256. }
  257. }
  258. return ""
  259. }
  260. /**
  261. @abstract 获取登录用户价格(建立订单时需要用到)
  262. @param productId 购买的产品id
  263. @param isEducation 是否教育优惠
  264. @param complete 回调
  265. */
  266. func getDMGProductPriceInfosForMember(productId: String, isEducation: Int, _ complete: @escaping KMMemberProductComplete) {
  267. checkConnectionAvailable()
  268. //暂时无教育优惠,先固定传 0
  269. KMMemberCenterManager.manager.getProductPriceForBuy(productId: productId, isEducation: 0, userId:KMMemberInfo.shared.userID) { [weak self] success, result in
  270. if success {
  271. guard let productsArrays : KMMemberProductResult = result else {
  272. complete(false, result)
  273. return
  274. }
  275. self?.dmgLastGetProductPriceInfos = productsArrays
  276. complete(true, productsArrays)
  277. } else {
  278. complete(false, result)
  279. }
  280. }
  281. }
  282. /**
  283. @abstract 获取批量阶段购买价格(建立订单时需要用到)
  284. @param productId 购买的产品id
  285. @param num 批量个数
  286. @param complete 回调
  287. */
  288. func getDMGBatchProductPriceInfosForMember(productId: String, num: Int, _ complete: @escaping KMMemberProductComplete) {
  289. checkConnectionAvailable()
  290. KMMemberCenterManager.manager.getBatchProductPrice(productId: productId, num: num) { [weak self] success, result in
  291. if success {
  292. guard let productsArrays : KMMemberProductResult = result else {
  293. complete(false, result)
  294. return
  295. }
  296. self?.dmgLastGetBatchProductPriceInfos = productsArrays
  297. complete(true, productsArrays)
  298. } else {
  299. complete(false, result)
  300. }
  301. }
  302. }
  303. /**
  304. @abstract 验证商品优惠券(建立订单时需要用到)
  305. @param productId 购买的产品id
  306. @param code 优惠券
  307. @param complete 回调
  308. */
  309. func getDMGCheckCouponProductPriceInfosForMember(productId: String, code: String, _ complete: @escaping KMMemberProductComplete) {
  310. checkConnectionAvailable()
  311. KMMemberCenterManager.manager.checkCoupon(productId: productId, userId: KMMemberInfo.shared.userID, code: code) { [weak self] success, result in
  312. if success {
  313. guard let productsArrays : KMMemberProductResult = result else {
  314. complete(false, result)
  315. return
  316. }
  317. self?.dmgLastCheckCouponProductPriceInfos = productsArrays
  318. complete(true, productsArrays)
  319. } else {
  320. complete(false, result)
  321. }
  322. }
  323. }
  324. /**
  325. @abstract 获取订单列表
  326. @param orderStatus 0全部1待支付
  327. @param complete 回调
  328. */
  329. func getDMGProductListInfosForMember(orderStatus: Int, _ complete: @escaping KMMemberRequestInfoComplete) {
  330. checkConnectionAvailable()
  331. KMMemberCenterManager.manager.getOrderListByStatus(orderStatus: orderStatus) { [weak self] success, result in
  332. if success {
  333. guard let productsInfos : NSDictionary = result else {
  334. complete(false, result)
  335. return
  336. }
  337. complete(true, productsInfos)
  338. } else {
  339. complete(false, result)
  340. }
  341. }
  342. }
  343. /**
  344. @abstract 创建订单(买断)
  345. @param productId 产品id
  346. @param paymentMethod 支付方式 PAYPAL(0),ALIPAY(1),WXPAY(2),PADDLE(3)
  347. @param price 价格
  348. @param discountFlag 0原价,1优惠券,2升级,3教育优惠,4批量购买,5黑五折扣
  349. @param couponCode 优惠卷
  350. @param num 批量购买数量
  351. @param complete 回调
  352. */
  353. func creatOrder(productId: String, paymentMethod: Int, price: String, discountFlag: Int, couponCode: String, num: Int, _ complete: @escaping KMMemberProductComplete) {
  354. checkConnectionAvailable()
  355. KMMemberCenterManager.manager.createOrder(productId: productId, paymentMethod: paymentMethod, price: price, discountFlag: discountFlag, couponCode: couponCode, num: num) { [weak self] success, result in
  356. if success {
  357. guard let productsArrays : KMMemberProductResult = result else {
  358. complete(false, result)
  359. return
  360. }
  361. self?.dmgLastCreatOrderProductInfos = productsArrays
  362. complete(true, productsArrays)
  363. } else {
  364. complete(false, result)
  365. }
  366. }
  367. }
  368. /**
  369. @abstract 创建订单(订阅)
  370. @param productId 产品id
  371. @param paymentMethod 支付方式 PAYPAL(0),ALIPAY(1),WXPAY(2),PADDLE(3)
  372. @param price 价格
  373. @param discountFlag 0原价,1优惠券,2升级,3教育优惠,4批量购买,5黑五折扣
  374. @param couponCode 优惠卷
  375. @param num 批量购买数量
  376. @param complete 回调
  377. */
  378. func createSubscriber(productId: String, paymentMethod: Int, price: String, discountFlag: Int, couponCode: String, num: Int, _ complete: @escaping KMMemberProductComplete) {
  379. checkConnectionAvailable()
  380. KMMemberCenterManager.manager.createSubscriber(productId: productId, paymentMethod: paymentMethod, price: price, discountFlag: discountFlag, couponCode: couponCode, num: num) { [weak self] success, result in
  381. if success {
  382. guard let productsArrays : KMMemberProductResult = result else {
  383. complete(false, result)
  384. return
  385. }
  386. self?.dmgLastCreatSubscriberProductInfos = productsArrays
  387. complete(true, productsArrays)
  388. } else {
  389. complete(false, result)
  390. }
  391. }
  392. }
  393. /**
  394. @abstract 支付后查询订单状态
  395. @param productId 购买的产品id
  396. @param complete 回调
  397. */
  398. func getDMGProductOrderIdInfosForMember(orderId: String, _ complete: @escaping KMMemberRequestInfoComplete) {
  399. checkConnectionAvailable()
  400. KMMemberCenterManager.manager.getStateByOrderId(orderId: orderId) { [weak self] success, result in
  401. if success {
  402. guard let productsInfos : NSDictionary = result else {
  403. complete(false, result)
  404. return
  405. }
  406. complete(true, productsInfos)
  407. } else {
  408. complete(false, result)
  409. }
  410. }
  411. }
  412. // MARK: Public Method
  413. /**
  414. @abstract 根据当前权益获取比较表类型
  415. @param
  416. */
  417. func getCurrentComparisonTableType() -> Void {
  418. let userScenarioType = KMMemberInfo.shared.userScenarioType
  419. let platforms = KMMemberInfo.shared.vip_platforms
  420. let platformsArray = platforms
  421. .components(separatedBy: ",")
  422. .map { $0.trimmingCharacters(in: .whitespaces) }
  423. if userScenarioType == .lite_type1 ||
  424. userScenarioType == .lite_type3 ||
  425. userScenarioType == .lite_type11 ||
  426. userScenarioType == .lite_type4 ||
  427. userScenarioType == .lite_type5 ||
  428. userScenarioType == .lite_type9 ||
  429. userScenarioType == .lite_type13 ||
  430. userScenarioType == .lite_type7 ||
  431. userScenarioType == .lite_type8 {
  432. if userScenarioType == .lite_type1 {
  433. state = .trial
  434. } else if userScenarioType == .lite_type3 || userScenarioType == .lite_type11 {
  435. state = .lite_Base
  436. } else if userScenarioType == .lite_type4 || userScenarioType == .lite_type5 || userScenarioType == .lite_type9 || userScenarioType == .lite_type13 {
  437. state = .lite_MacWindows
  438. } else if userScenarioType == .lite_type7 || userScenarioType == .lite_type8 {
  439. if KMMemberInfo.shared.vip_paymentModel == "1" && KMMemberInfo.shared.vip_cycle == 4 && platformsArray.count == 4 {
  440. state = .lite_MacWindows
  441. } else {
  442. state = .lite_Base
  443. }
  444. }
  445. } else if userScenarioType == .pro_type1 ||
  446. userScenarioType == .pro_type3 ||
  447. userScenarioType == .pro_type4 {
  448. if userScenarioType == .pro_type1 ||
  449. userScenarioType == .pro_type4 {
  450. state = .pro_Advanced
  451. } else if userScenarioType == .pro_type3 {
  452. state = .pro_Base
  453. }
  454. } else if userScenarioType == .dmg_type4 ||
  455. userScenarioType == .dmg_type5 ||
  456. userScenarioType == .dmg_type6 ||
  457. userScenarioType == .dmg_type7 ||
  458. userScenarioType == .dmg_type8 ||
  459. userScenarioType == .dmg_type9 ||
  460. userScenarioType == .dmg_type10 ||
  461. userScenarioType == .dmg_type11 ||
  462. userScenarioType == .dmg_type12 ||
  463. userScenarioType == .dmg_type13 ||
  464. userScenarioType == .dmg_type14 ||
  465. userScenarioType == .dmg_type15 ||
  466. userScenarioType == .dmg_type16 ||
  467. userScenarioType == .dmg_type17 ||
  468. userScenarioType == .dmg_type18 ||
  469. userScenarioType == .dmg_type19 ||
  470. userScenarioType == .dmg_type20 ||
  471. userScenarioType == .dmg_type21 ||
  472. userScenarioType == .dmg_type22 ||
  473. userScenarioType == .dmg_type23 ||
  474. userScenarioType == .dmg_type24 ||
  475. userScenarioType == .dmg_type25 ||
  476. userScenarioType == .dmg_type26 ||
  477. userScenarioType == .dmg_type27 ||
  478. userScenarioType == .dmg_type28 ||
  479. userScenarioType == .dmg_type29 ||
  480. userScenarioType == .dmg_type30 ||
  481. userScenarioType == .dmg_type31 ||
  482. userScenarioType == .dmg_type32 ||
  483. userScenarioType == .dmg_type33 ||
  484. userScenarioType == .dmg_type34 ||
  485. userScenarioType == .dmg_type35 ||
  486. userScenarioType == .dmg_type36 ||
  487. userScenarioType == .dmg_type37 ||
  488. userScenarioType == .dmg_type38 ||
  489. userScenarioType == .dmg_type39 ||
  490. userScenarioType == .dmg_type40 ||
  491. userScenarioType == .dmg_type41 ||
  492. userScenarioType == .dmg_type42 ||
  493. userScenarioType == .dmg_type43 ||
  494. userScenarioType == .dmg_type44 ||
  495. userScenarioType == .dmg_type45 ||
  496. userScenarioType == .dmg_type46 ||
  497. userScenarioType == .dmg_type47 ||
  498. userScenarioType == .dmg_type48 {
  499. if userScenarioType == .dmg_type4 ||
  500. userScenarioType == .dmg_type19 ||
  501. userScenarioType == .dmg_type34 {
  502. state = .trial
  503. } else if userScenarioType == .dmg_type5 ||
  504. userScenarioType == .dmg_type28 ||
  505. userScenarioType == .dmg_type43 {
  506. state = .dmg_Upgrades1
  507. } else if userScenarioType == .dmg_type6 ||
  508. userScenarioType == .dmg_type7 ||
  509. userScenarioType == .dmg_type29 ||
  510. userScenarioType == .dmg_type30 ||
  511. userScenarioType == .dmg_type44 ||
  512. userScenarioType == .dmg_type45 {
  513. state = .dmg_Upgrades2
  514. } else if userScenarioType == .dmg_type11 ||
  515. userScenarioType == .dmg_type18 ||
  516. userScenarioType == .dmg_type22 ||
  517. userScenarioType == .dmg_type33 ||
  518. userScenarioType == .dmg_type37 ||
  519. userScenarioType == .dmg_type48 {
  520. state = .dmg_Base
  521. }
  522. }
  523. }
  524. /**
  525. 对应商品价格
  526. */
  527. func getProductPrice(_ type: KMPurchasedProductType) -> String {
  528. #if VERSION_FREE
  529. #if VERSION_DMG
  530. // DMG
  531. if type == .pdfReaderProStandard_dmg {
  532. if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
  533. return String(format: "USD $%@", getDMGPrice(productCode: KMStandardAnnualSubscriptionCodeKey_DMG))
  534. } else {
  535. return String(format: "CNY ¥%@", getDMGCNYPrice(productCode: KMStandardAnnualSubscriptionCodeKey_DMG))
  536. }
  537. } else if type == .pdfReaderProAdvanced_dmg {
  538. if state == .dmg_Base {
  539. if isBlackFive {
  540. if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
  541. return String(format: "USD $%@", getDMGPrice(productCode: KMAdvancedAnnualSubscriptionBlackFiveCodeKey_DMG))
  542. } else {
  543. return String(format: "CNY ¥%@", getDMGCNYPrice(productCode: KMAdvancedAnnualSubscriptionBlackFiveCodeKey_DMG))
  544. }
  545. } else {
  546. if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
  547. return String(format: "USD $%@", getDMGPrice(productCode: KMAdvancedAnnualSubscriptionCodeKey_DMG))
  548. } else {
  549. return String(format: "CNY ¥%@", getDMGCNYPrice(productCode: KMAdvancedAnnualSubscriptionCodeKey_DMG))
  550. }
  551. }
  552. } else {
  553. if KMMemberInfo.shared.canTrail && state == .trial {
  554. if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
  555. return String(format: "USD $%@", getDMGPrice(productCode: KMAdvancedAnnualSubscriptionTrailCodeKey_DMG))
  556. } else {
  557. return String(format: "CNY ¥%@", getDMGCNYPrice(productCode: KMAdvancedAnnualSubscriptionTrailCodeKey_DMG))
  558. }
  559. } else {
  560. if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
  561. return String(format: "USD $%@", getDMGPrice(productCode: KMAdvancedAnnualSubscriptionCodeKey_DMG))
  562. } else {
  563. return String(format: "CNY ¥%@", getDMGCNYPrice(productCode: KMAdvancedAnnualSubscriptionCodeKey_DMG))
  564. }
  565. }
  566. }
  567. } else if type == .pdfReaderProPermanent_dmg {
  568. if state == .dmg_Base {
  569. if isBlackFive {
  570. if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
  571. return String(format: "USD $%@", getDMGPrice(productCode: KMAdvancedPermanentBlackFiveCodeKey_DMG))
  572. } else {
  573. return String(format: "CNY ¥%@", getDMGCNYPrice(productCode: KMAdvancedPermanentBlackFiveCodeKey_DMG))
  574. }
  575. } else {
  576. if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
  577. return String(format: "USD $%@", getDMGPrice(productCode: KMAdvancedPermanentCodeKey_DMG))
  578. } else {
  579. return String(format: "CNY ¥%@", getDMGCNYPrice(productCode: KMAdvancedPermanentCodeKey_DMG))
  580. }
  581. }
  582. } else {
  583. }
  584. } else if type == .pdfReaderProAIAnnual_dmg {
  585. if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
  586. return String(format: "USD $%@", getDMGPrice(productCode: KMAISubscriptionYearTrailCodeKey_DMG))
  587. } else {
  588. return String(format: "CNY ¥%@", getDMGCNYPrice(productCode: KMAISubscriptionYearTrailCodeKey_DMG))
  589. }
  590. } else if type == .pdfReaderProAIMonthly_dmg {
  591. if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
  592. return String(format: "USD $%@", getDMGPrice(productCode: KMAISubscriptionMonthCodeKey_DMG))
  593. } else {
  594. return String(format: "CNY ¥%@", getDMGCNYPrice(productCode: KMAISubscriptionMonthCodeKey_DMG))
  595. }
  596. } else if type == .pdfToOffice_dmg {
  597. } else if type == .add2Device_dmg {
  598. } else if type == .add3Device_dmg {
  599. }
  600. #else
  601. // AppStore 免费版本
  602. if type == .fourDevicesAllAccessPackNew6months_lite {
  603. if let product = IAPProductsManager.default().fourDevicesAllAccessPackNew6Months_lite, product.isOffers {
  604. return product.offersPrice()
  605. } else {
  606. return IAPProductsManager.default().fourDevicesAllAccessPackNew6Months_lite.price()
  607. }
  608. } else if type == .fourDevicesAllAccessPackNew12months_lite {
  609. if let product = IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite, product.isOffers {
  610. return product.offersPrice()
  611. } else {
  612. return IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite.price()
  613. }
  614. } else if type == .aiAllAccessPack1month_lite {
  615. if let product = IAPProductsManager.default().aiAllAccessPack1month_lite, product.isOffers {
  616. return product.offersPrice()
  617. } else {
  618. return IAPProductsManager.default().aiAllAccessPack1month_lite.price()
  619. }
  620. } else if type == .aiAllAccessPack12month_lite {
  621. if let product = IAPProductsManager.default().aiAllAccessPack12month_lite, product.isOffers {
  622. return product.offersPrice()
  623. } else {
  624. return IAPProductsManager.default().aiAllAccessPack12month_lite.price()
  625. }
  626. } else if type == .allAccessPackPermanent_lite {
  627. if let product = IAPProductsManager.default().allAccessPackPermanent_lite, product.isOffers {
  628. return product.offersPrice()
  629. } else {
  630. return IAPProductsManager.default().allAccessPackPermanent_lite.price()
  631. }
  632. } else if type == .advancedAddDevicesAllAccessPack12months_lite {
  633. if let product = IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_lite, product.isOffers {
  634. return product.offersPrice()
  635. } else {
  636. return IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_lite.price()
  637. }
  638. } else if type == .advancedAdd2DevicesAllAccessPack12months_lite {
  639. if let product = IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_lite, product.isOffers {
  640. return product.offersPrice()
  641. } else {
  642. return IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_lite.price()
  643. }
  644. }
  645. #endif
  646. #else
  647. // AppStore 付费版
  648. if type == .aiAllAccessPack1month_pro {
  649. if let product = IAPProductsManager.default().aiAllAccessPack1month_pro, product.isOffers {
  650. return product.offersPrice()
  651. } else {
  652. return IAPProductsManager.default().aiAllAccessPack1month_pro.price()
  653. }
  654. } else if type == .aiAllAccessPack12month_pro {
  655. if let product = IAPProductsManager.default().aiAllAccessPack12month_pro, product.isOffers {
  656. return product.offersPrice()
  657. } else {
  658. return IAPProductsManager.default().aiAllAccessPack12month_pro.price()
  659. }
  660. } else if type == .pdfToOfficePackPermanent_pro {
  661. if let product = IAPProductsManager.default().pdfToOfficePackPermanent_pro, product.isOffers {
  662. return product.offersPrice()
  663. } else {
  664. return IAPProductsManager.default().pdfToOfficePackPermanent_pro.price()
  665. }
  666. } else if type == .fourDevicesAllAccessPack12months_pro {
  667. if let product = IAPProductsManager.default().fourDevicesAllAccessPack12months_pro, product.isOffers {
  668. return product.offersPrice()
  669. } else {
  670. return IAPProductsManager.default().fourDevicesAllAccessPack12months_pro.price()
  671. }
  672. } else if type == .standardAddDevicesAllAccessPack12months_pro {
  673. if let product = IAPProductsManager.default().standardAddDevicesAllAccessPack12months_pro, product.isOffers {
  674. return product.offersPrice()
  675. } else {
  676. return IAPProductsManager.default().standardAddDevicesAllAccessPack12months_pro.price()
  677. }
  678. } else if type == .advancedAddDevicesAllAccessPack12months_pro {
  679. if let product = IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_pro, product.isOffers {
  680. return product.offersPrice()
  681. } else {
  682. return IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_pro.price()
  683. }
  684. } else if type == .advancedAdd2DevicesAllAccessPack12months_pro {
  685. if let product = IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_pro, product.isOffers {
  686. return product.offersPrice()
  687. } else {
  688. return IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_pro.price()
  689. }
  690. }
  691. #endif
  692. return ""
  693. }
  694. /**
  695. 优惠价格
  696. */
  697. func getDisplayPrice(_ type: KMPurchasedProductType) -> String {
  698. #if VERSION_FREE
  699. #if VERSION_DMG
  700. // DMG
  701. if type == .pdfReaderProStandard_dmg {
  702. if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
  703. return String(format: "USD $%@", getDMGDisplayPrice(productCode: KMStandardAnnualSubscriptionCodeKey_DMG))
  704. } else {
  705. return String(format: "CNY ¥%@", getDMGDisplayCNYPrice(productCode: KMStandardAnnualSubscriptionCodeKey_DMG))
  706. }
  707. } else if type == .pdfReaderProAdvanced_dmg {
  708. if state == .dmg_Base {
  709. if isBlackFive {
  710. if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
  711. return String(format: "USD $%@", getDMGDisplayPrice(productCode: KMAdvancedAnnualSubscriptionBlackFiveCodeKey_DMG))
  712. } else {
  713. return String(format: "CNY ¥%@", getDMGDisplayCNYPrice(productCode: KMAdvancedAnnualSubscriptionBlackFiveCodeKey_DMG))
  714. }
  715. } else {
  716. if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
  717. return String(format: "USD $%@", getDMGDisplayPrice(productCode: KMAdvancedAnnualSubscriptionCodeKey_DMG))
  718. } else {
  719. return String(format: "CNY ¥%@", getDMGDisplayCNYPrice(productCode: KMAdvancedAnnualSubscriptionCodeKey_DMG))
  720. }
  721. }
  722. } else {
  723. if KMMemberInfo.shared.canTrail && state == .trial {
  724. if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
  725. return String(format: "USD $%@", getDMGDisplayPrice(productCode: KMAdvancedAnnualSubscriptionTrailCodeKey_DMG))
  726. } else {
  727. return String(format: "CNY ¥%@", getDMGDisplayCNYPrice(productCode: KMAdvancedAnnualSubscriptionTrailCodeKey_DMG))
  728. }
  729. } else {
  730. if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
  731. return String(format: "USD $%@", getDMGDisplayPrice(productCode: KMAdvancedAnnualSubscriptionCodeKey_DMG))
  732. } else {
  733. return String(format: "CNY ¥%@", getDMGDisplayCNYPrice(productCode: KMAdvancedAnnualSubscriptionCodeKey_DMG))
  734. }
  735. }
  736. }
  737. } else if type == .pdfReaderProPermanent_dmg {
  738. if state == .dmg_Base {
  739. if isBlackFive {
  740. if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
  741. return String(format: "USD $%@", getDMGDisplayPrice(productCode: KMAdvancedPermanentBlackFiveCodeKey_DMG))
  742. } else {
  743. return String(format: "CNY ¥%@", getDMGDisplayCNYPrice(productCode: KMAdvancedPermanentBlackFiveCodeKey_DMG))
  744. }
  745. } else {
  746. if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
  747. return String(format: "USD $%@", getDMGDisplayPrice(productCode: KMAdvancedPermanentCodeKey_DMG))
  748. } else {
  749. return String(format: "CNY ¥%@", getDMGDisplayCNYPrice(productCode: KMAdvancedPermanentCodeKey_DMG))
  750. }
  751. }
  752. } else {
  753. }
  754. } else if type == .pdfReaderProAIAnnual_dmg {
  755. if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
  756. return String(format: "USD $%@", getDMGDisplayPrice(productCode: KMAISubscriptionYearTrailCodeKey_DMG))
  757. } else {
  758. return String(format: "CNY ¥%@", getDMGDisplayCNYPrice(productCode: KMAISubscriptionYearTrailCodeKey_DMG))
  759. }
  760. } else if type == .pdfReaderProAIMonthly_dmg {
  761. if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
  762. return String(format: "USD $%@", getDMGDisplayPrice(productCode: KMAISubscriptionMonthCodeKey_DMG))
  763. } else {
  764. return String(format: "CNY ¥%@", getDMGDisplayCNYPrice(productCode: KMAISubscriptionMonthCodeKey_DMG))
  765. }
  766. } else if type == .pdfToOffice_dmg {
  767. } else if type == .add2Device_dmg {
  768. } else if type == .add3Device_dmg {
  769. }
  770. #else
  771. // AppStore 免费版本
  772. // if type == .fourDevicesAllAccessPackNew6months_lite {
  773. // if let product = IAPProductsManager.default().fourDevicesAllAccessPackNew6Months_lite, product.isOffers {
  774. // return product.offersPrice()
  775. // } else {
  776. // return IAPProductsManager.default().fourDevicesAllAccessPackNew6Months_lite.price()
  777. // }
  778. // } else if type == .fourDevicesAllAccessPackNew12months_lite {
  779. // if let product = IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite, product.isOffers {
  780. // return product.offersPrice()
  781. // } else {
  782. // return IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite.price()
  783. // }
  784. // } else if type == .aiAllAccessPack1month_lite {
  785. // if let product = IAPProductsManager.default().aiAllAccessPack1month_lite, product.isOffers {
  786. // return product.offersPrice()
  787. // } else {
  788. // return IAPProductsManager.default().aiAllAccessPack1month_lite.price()
  789. // }
  790. // } else if type == .aiAllAccessPack12month_lite {
  791. // if let product = IAPProductsManager.default().aiAllAccessPack12month_lite, product.isOffers {
  792. // return product.offersPrice()
  793. // } else {
  794. // return IAPProductsManager.default().aiAllAccessPack12month_lite.price()
  795. // }
  796. // } else if type == .allAccessPackPermanent_lite {
  797. // if let product = IAPProductsManager.default().allAccessPackPermanent_lite, product.isOffers {
  798. // return product.offersPrice()
  799. // } else {
  800. // return IAPProductsManager.default().allAccessPackPermanent_lite.price()
  801. // }
  802. // } else if type == .advancedAddDevicesAllAccessPack12months_lite {
  803. // if let product = IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_lite, product.isOffers {
  804. // return product.offersPrice()
  805. // } else {
  806. // return IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_lite.price()
  807. // }
  808. // } else if type == .advancedAdd2DevicesAllAccessPack12months_lite {
  809. // if let product = IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_lite, product.isOffers {
  810. // return product.offersPrice()
  811. // } else {
  812. // return IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_lite.price()
  813. // }
  814. // }
  815. #endif
  816. #else
  817. // AppStore 付费版
  818. // if type == .aiAllAccessPack1month_pro {
  819. // if let product = IAPProductsManager.default().aiAllAccessPack1month_pro, product.isOffers {
  820. // return product.offersPrice()
  821. // } else {
  822. // return IAPProductsManager.default().aiAllAccessPack1month_pro.price()
  823. // }
  824. // } else if type == .aiAllAccessPack12month_pro {
  825. // if let product = IAPProductsManager.default().aiAllAccessPack12month_pro, product.isOffers {
  826. // return product.offersPrice()
  827. // } else {
  828. // return IAPProductsManager.default().aiAllAccessPack12month_pro.price()
  829. // }
  830. // } else if type == .pdfToOfficePackPermanent_pro {
  831. // if let product = IAPProductsManager.default().pdfToOfficePackPermanent_pro, product.isOffers {
  832. // return product.offersPrice()
  833. // } else {
  834. // return IAPProductsManager.default().pdfToOfficePackPermanent_pro.price()
  835. // }
  836. // } else if type == .fourDevicesAllAccessPack12months_pro {
  837. // if let product = IAPProductsManager.default().fourDevicesAllAccessPack12months_pro, product.isOffers {
  838. // return product.offersPrice()
  839. // } else {
  840. // return IAPProductsManager.default().fourDevicesAllAccessPack12months_pro.price()
  841. // }
  842. // } else if type == .standardAddDevicesAllAccessPack12months_pro {
  843. // if let product = IAPProductsManager.default().standardAddDevicesAllAccessPack12months_pro, product.isOffers {
  844. // return product.offersPrice()
  845. // } else {
  846. // return IAPProductsManager.default().standardAddDevicesAllAccessPack12months_pro.price()
  847. // }
  848. // } else if type == .advancedAddDevicesAllAccessPack12months_pro {
  849. // if let product = IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_pro, product.isOffers {
  850. // return product.offersPrice()
  851. // } else {
  852. // return IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_pro.price()
  853. // }
  854. // } else if type == .advancedAdd2DevicesAllAccessPack12months_pro {
  855. // if let product = IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_pro, product.isOffers {
  856. // return product.offersPrice()
  857. // } else {
  858. // return IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_pro.price()
  859. // }
  860. // }
  861. #endif
  862. return ""
  863. }
  864. /** 原价 */
  865. func getOriginalPrice(_ type: KMPurchasedProductType) -> String {
  866. #if VERSION_FREE
  867. #if VERSION_DMG
  868. if type == .pdfReaderProStandard_dmg {
  869. if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
  870. return String(format: "USD $%@", getDMGOriginalPrice(productCode: KMStandardAnnualSubscriptionCodeKey_DMG))
  871. } else {
  872. return String(format: "CNY ¥%@", getDMGOriginalCNYPrice(productCode: KMStandardAnnualSubscriptionCodeKey_DMG))
  873. }
  874. } else if type == .pdfReaderProAdvanced_dmg {
  875. if state == .dmg_Base {
  876. if isBlackFive {
  877. if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
  878. return String(format: "USD $%@", getDMGOriginalPrice(productCode: KMAdvancedAnnualSubscriptionBlackFiveCodeKey_DMG))
  879. } else {
  880. return String(format: "CNY ¥%@", getDMGOriginalCNYPrice(productCode: KMAdvancedAnnualSubscriptionBlackFiveCodeKey_DMG))
  881. }
  882. } else {
  883. if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
  884. return String(format: "USD $%@", getDMGOriginalPrice(productCode: KMAdvancedAnnualSubscriptionCodeKey_DMG))
  885. } else {
  886. return String(format: "CNY ¥%@", getDMGOriginalCNYPrice(productCode: KMAdvancedAnnualSubscriptionCodeKey_DMG))
  887. }
  888. }
  889. } else {
  890. if KMMemberInfo.shared.canTrail && state == .trial {
  891. if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
  892. return String(format: "USD $%@", getDMGOriginalPrice(productCode: KMAdvancedAnnualSubscriptionTrailCodeKey_DMG))
  893. } else {
  894. return String(format: "CNY ¥%@", getDMGOriginalCNYPrice(productCode: KMAdvancedAnnualSubscriptionTrailCodeKey_DMG))
  895. }
  896. } else {
  897. if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
  898. return String(format: "USD $%@", getDMGOriginalPrice(productCode: KMAdvancedAnnualSubscriptionCodeKey_DMG))
  899. } else {
  900. return String(format: "CNY ¥%@", getDMGOriginalCNYPrice(productCode: KMAdvancedAnnualSubscriptionCodeKey_DMG))
  901. }
  902. }
  903. }
  904. } else if type == .pdfReaderProPermanent_dmg {
  905. if state == .dmg_Base {
  906. if isBlackFive {
  907. if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
  908. return String(format: "USD $%@", getDMGOriginalPrice(productCode: KMAdvancedPermanentBlackFiveCodeKey_DMG))
  909. } else {
  910. return String(format: "CNY ¥%@", getDMGOriginalCNYPrice(productCode: KMAdvancedPermanentBlackFiveCodeKey_DMG))
  911. }
  912. } else {
  913. if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
  914. return String(format: "USD $%@", getDMGOriginalPrice(productCode: KMAdvancedPermanentCodeKey_DMG))
  915. } else {
  916. return String(format: "CNY ¥%@", getDMGOriginalCNYPrice(productCode: KMAdvancedPermanentCodeKey_DMG))
  917. }
  918. }
  919. } else {
  920. }
  921. } else if type == .pdfReaderProAIAnnual_dmg {
  922. if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
  923. return String(format: "USD $%@", getDMGOriginalPrice(productCode: KMAISubscriptionYearTrailCodeKey_DMG))
  924. } else {
  925. return String(format: "CNY ¥%@", getDMGOriginalCNYPrice(productCode: KMAISubscriptionYearTrailCodeKey_DMG))
  926. }
  927. } else if type == .pdfReaderProAIMonthly_dmg {
  928. if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
  929. return String(format: "USD $%@", getDMGOriginalPrice(productCode: KMAISubscriptionMonthCodeKey_DMG))
  930. } else {
  931. return String(format: "CNY ¥%@", getDMGOriginalCNYPrice(productCode: KMAISubscriptionMonthCodeKey_DMG))
  932. }
  933. } else if type == .pdfToOffice_dmg {
  934. } else if type == .add2Device_dmg {
  935. } else if type == .add3Device_dmg {
  936. }
  937. #else
  938. // AppStore 免费版本
  939. // if type == .fourDevicesAllAccessPackNew6months_lite {
  940. // if let product = IAPProductsManager.default().fourDevicesAllAccessPackNew6Months_lite, product.isOffers {
  941. // return product.offersPrice()
  942. // } else {
  943. // return IAPProductsManager.default().fourDevicesAllAccessPackNew6Months_lite.price()
  944. // }
  945. // } else if type == .fourDevicesAllAccessPackNew12months_lite {
  946. // if let product = IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite, product.isOffers {
  947. // return product.offersPrice()
  948. // } else {
  949. // return IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite.price()
  950. // }
  951. // } else if type == .aiAllAccessPack1month_lite {
  952. // if let product = IAPProductsManager.default().aiAllAccessPack1month_lite, product.isOffers {
  953. // return product.offersPrice()
  954. // } else {
  955. // return IAPProductsManager.default().aiAllAccessPack1month_lite.price()
  956. // }
  957. // } else if type == .aiAllAccessPack12month_lite {
  958. // if let product = IAPProductsManager.default().aiAllAccessPack12month_lite, product.isOffers {
  959. // return product.offersPrice()
  960. // } else {
  961. // return IAPProductsManager.default().aiAllAccessPack12month_lite.price()
  962. // }
  963. // } else if type == .allAccessPackPermanent_lite {
  964. // if let product = IAPProductsManager.default().allAccessPackPermanent_lite, product.isOffers {
  965. // return product.offersPrice()
  966. // } else {
  967. // return IAPProductsManager.default().allAccessPackPermanent_lite.price()
  968. // }
  969. // } else if type == .advancedAddDevicesAllAccessPack12months_lite {
  970. // if let product = IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_lite, product.isOffers {
  971. // return product.offersPrice()
  972. // } else {
  973. // return IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_lite.price()
  974. // }
  975. // } else if type == .advancedAdd2DevicesAllAccessPack12months_lite {
  976. // if let product = IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_lite, product.isOffers {
  977. // return product.offersPrice()
  978. // } else {
  979. // return IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_lite.price()
  980. // }
  981. // }
  982. #endif
  983. #else
  984. // AppStore 付费版
  985. // if type == .aiAllAccessPack1month_pro {
  986. // if let product = IAPProductsManager.default().aiAllAccessPack1month_pro, product.isOffers {
  987. // return product.offersPrice()
  988. // } else {
  989. // return IAPProductsManager.default().aiAllAccessPack1month_pro.price()
  990. // }
  991. // } else if type == .aiAllAccessPack12month_pro {
  992. // if let product = IAPProductsManager.default().aiAllAccessPack12month_pro, product.isOffers {
  993. // return product.offersPrice()
  994. // } else {
  995. // return IAPProductsManager.default().aiAllAccessPack12month_pro.price()
  996. // }
  997. // } else if type == .pdfToOfficePackPermanent_pro {
  998. // if let product = IAPProductsManager.default().pdfToOfficePackPermanent_pro, product.isOffers {
  999. // return product.offersPrice()
  1000. // } else {
  1001. // return IAPProductsManager.default().pdfToOfficePackPermanent_pro.price()
  1002. // }
  1003. // } else if type == .fourDevicesAllAccessPack12months_pro {
  1004. // if let product = IAPProductsManager.default().fourDevicesAllAccessPack12months_pro, product.isOffers {
  1005. // return product.offersPrice()
  1006. // } else {
  1007. // return IAPProductsManager.default().fourDevicesAllAccessPack12months_pro.price()
  1008. // }
  1009. // } else if type == .standardAddDevicesAllAccessPack12months_pro {
  1010. // if let product = IAPProductsManager.default().standardAddDevicesAllAccessPack12months_pro, product.isOffers {
  1011. // return product.offersPrice()
  1012. // } else {
  1013. // return IAPProductsManager.default().standardAddDevicesAllAccessPack12months_pro.price()
  1014. // }
  1015. // } else if type == .advancedAddDevicesAllAccessPack12months_pro {
  1016. // if let product = IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_pro, product.isOffers {
  1017. // return product.offersPrice()
  1018. // } else {
  1019. // return IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_pro.price()
  1020. // }
  1021. // } else if type == .advancedAdd2DevicesAllAccessPack12months_pro {
  1022. // if let product = IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_pro, product.isOffers {
  1023. // return product.offersPrice()
  1024. // } else {
  1025. // return IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_pro.price()
  1026. // }
  1027. // }
  1028. #endif
  1029. return ""
  1030. }
  1031. /** 优惠卷价格 */
  1032. func getDMGDisplayAmountPrice(_ type: KMPurchasedProductType, pointNum: Int, hasPrefix: Bool) -> String {
  1033. #if VERSION_FREE
  1034. #if VERSION_DMG
  1035. var prefixStr = _isUSD() ? "USD" : "CNY"
  1036. prefixStr = hasPrefix ? prefixStr : ""
  1037. if type == .pdfReaderProStandard_dmg {
  1038. let productCode = KMStandardAnnualSubscriptionCodeKey_DMG
  1039. if _isUSD() {
  1040. return String(format: "%@ $%@", prefixStr, getDMGDisplayAmountPrice(productCode: productCode, pointNum: pointNum))
  1041. } else {
  1042. return String(format: "%@ ¥%@", prefixStr, getDMGDisplayAmountCNYPrice(productCode: productCode, pointNum: pointNum))
  1043. }
  1044. } else if type == .pdfReaderProAdvanced_dmg {
  1045. if state == .dmg_Base {
  1046. if isBlackFive {
  1047. let productCode = KMAdvancedAnnualSubscriptionBlackFiveCodeKey_DMG
  1048. if _isUSD() {
  1049. return String(format: "%@ $%@", prefixStr,getDMGDisplayAmountPrice(productCode: productCode, pointNum: pointNum))
  1050. } else {
  1051. return String(format: "%@ ¥%@", prefixStr, getDMGDisplayAmountCNYPrice(productCode: productCode, pointNum: pointNum))
  1052. }
  1053. } else {
  1054. let productCode = KMAdvancedAnnualSubscriptionCodeKey_DMG
  1055. if _isUSD() {
  1056. return String(format: "%@ $%@", prefixStr, getDMGDisplayAmountPrice(productCode: productCode, pointNum: pointNum))
  1057. } else {
  1058. return String(format: "%@ ¥%@",prefixStr, getDMGDisplayAmountCNYPrice(productCode: productCode, pointNum: pointNum))
  1059. }
  1060. }
  1061. } else {
  1062. if KMMemberInfo.shared.canTrail && state == .trial {
  1063. let productCode = KMAdvancedAnnualSubscriptionTrailCodeKey_DMG
  1064. if _isUSD() {
  1065. return String(format: "%@ $%@", prefixStr, getDMGDisplayAmountPrice(productCode: productCode, pointNum: pointNum))
  1066. } else {
  1067. return String(format: "%@ ¥%@", prefixStr, getDMGDisplayAmountCNYPrice(productCode: productCode, pointNum: pointNum))
  1068. }
  1069. } else {
  1070. let productCode = KMAdvancedAnnualSubscriptionCodeKey_DMG
  1071. if _isUSD() {
  1072. return String(format: "%@ $%@", prefixStr, getDMGDisplayAmountPrice(productCode: productCode, pointNum: pointNum))
  1073. } else {
  1074. return String(format: "%@ ¥%@", prefixStr, getDMGDisplayAmountCNYPrice(productCode: productCode, pointNum: pointNum))
  1075. }
  1076. }
  1077. }
  1078. } else if type == .pdfReaderProPermanent_dmg {
  1079. if state == .dmg_Base {
  1080. if isBlackFive {
  1081. let productCode = KMAdvancedPermanentBlackFiveCodeKey_DMG
  1082. if _isUSD() {
  1083. return String(format: "%@ $%@", prefixStr, getDMGDisplayAmountPrice(productCode:productCode , pointNum: pointNum))
  1084. } else {
  1085. return String(format: "%@ ¥%@", prefixStr, getDMGDisplayAmountCNYPrice(productCode: productCode, pointNum: pointNum))
  1086. }
  1087. } else {
  1088. let productCode = KMAdvancedPermanentCodeKey_DMG
  1089. if _isUSD() {
  1090. return String(format: "%@ $%@", prefixStr, getDMGDisplayAmountPrice(productCode: productCode, pointNum: pointNum))
  1091. } else {
  1092. return String(format: "%@ ¥%@", prefixStr, getDMGDisplayAmountCNYPrice(productCode: productCode, pointNum: pointNum))
  1093. }
  1094. }
  1095. } else {
  1096. }
  1097. } else if type == .pdfReaderProAIAnnual_dmg {
  1098. let productCode = KMAISubscriptionYearTrailCodeKey_DMG
  1099. if _isUSD() {
  1100. return String(format: "%@ $%@", prefixStr, getDMGDisplayAmountPrice(productCode:productCode , pointNum: pointNum))
  1101. } else {
  1102. return String(format: "%@ ¥%@", prefixStr, getDMGDisplayAmountCNYPrice(productCode: productCode, pointNum: pointNum))
  1103. }
  1104. } else if type == .pdfReaderProAIMonthly_dmg {
  1105. let productCode = KMAISubscriptionMonthCodeKey_DMG
  1106. if _isUSD() {
  1107. return String(format: "%@ $%@", prefixStr, getDMGDisplayAmountPrice(productCode: productCode, pointNum: pointNum))
  1108. } else {
  1109. return String(format: "%@ ¥%@", prefixStr, getDMGDisplayAmountCNYPrice(productCode: productCode, pointNum: pointNum))
  1110. }
  1111. } else if type == .pdfToOffice_dmg {
  1112. } else if type == .add2Device_dmg {
  1113. } else if type == .add3Device_dmg {
  1114. }
  1115. #else
  1116. // AppStore 免费版本
  1117. #endif
  1118. #else
  1119. // AppStore 付费版
  1120. #endif
  1121. return ""
  1122. }
  1123. func appstorePurchaseAction(_ tag: Int, discountType: KMDiscountType, _ complete: @escaping AppstorePurchaseComplete) -> Void {
  1124. if state == .dmg_Base {
  1125. var code = ""
  1126. if tag == 1 {
  1127. code = KMStandardAnnualSubscriptionCodeKey_DMG
  1128. } else if tag == 3 {
  1129. if isBlackFive {
  1130. code = KMAdvancedPermanentBlackFiveCodeKey_DMG
  1131. } else {
  1132. code = KMAdvancedPermanentCodeKey_DMG
  1133. }
  1134. } else {
  1135. if isBlackFive {
  1136. code = KMAdvancedAnnualSubscriptionBlackFiveCodeKey_DMG
  1137. } else {
  1138. code = KMAdvancedAnnualSubscriptionCodeKey_DMG
  1139. }
  1140. }
  1141. #if VERSION_DMG
  1142. let embeddedWC = KMPurchaseEmbeddedWindowController.currentCode(code)
  1143. if discountType == .newUserGift {
  1144. embeddedWC.discountCodeId = kKMNewUserGiftDiscountCodeId
  1145. } else if discountType == .advancedYearSubscribeTrialingCancel {
  1146. embeddedWC.discountCodeId = kKMAdvancedYearSubscribeDiscountCodeId
  1147. embeddedWC.kEventName = KMProductCompareWC.shared.kEventName
  1148. embeddedWC.kEventParams = KMProductCompareWC.shared.kEventParams
  1149. } else {
  1150. embeddedWC.discountCodeId = nil
  1151. }
  1152. embeddedWC.openWindow(discountType: discountType)
  1153. embeddedWC.window?.center()
  1154. #endif
  1155. } else if state == .dmg_Upgrades1 {
  1156. #if VERSION_DMG
  1157. let embeddedWC = KMPurchaseEmbeddedWindowController.currentCode(KMAdvancedAnnualSubscriptionCodeKey_DMG)
  1158. embeddedWC.showWindow(nil)
  1159. embeddedWC.window?.center()
  1160. #endif
  1161. } else if state == .dmg_Upgrades2 {
  1162. #if VERSION_DMG
  1163. let embeddedWC = KMPurchaseEmbeddedWindowController.currentCode(KMAdvancedAnnualSubscriptionCodeKey_DMG)
  1164. embeddedWC.showWindow(nil)
  1165. embeddedWC.window?.center()
  1166. #endif
  1167. } else if state == .lite_Base {
  1168. if tag == 0 {
  1169. if isPurchaseSwitch {
  1170. if discountType == .advancedYearSubscribeTrialingCancel {
  1171. membershipPurchase(.fourDevicesAllAccessPackNew12months_lite, discountCode: "4_devices_all_access_pack_12months_20250102")
  1172. } else {
  1173. membershipPurchase(.fourDevicesAllAccessPackNew12months_lite, discountCode: nil)
  1174. }
  1175. } else {
  1176. if discountType == .advancedYearSubscribeTrialingCancel {
  1177. membershipPurchase(.fourDevicesAllAccessPackNew6months_lite, discountCode: "4_devices_all_access_pack_new_6month_20250102")
  1178. } else {
  1179. membershipPurchase(.fourDevicesAllAccessPackNew6months_lite, discountCode: nil)
  1180. }
  1181. }
  1182. } else if tag == 3 {
  1183. membershipPurchase(.allAccessPackPermanent_lite, discountCode: nil)
  1184. } else {
  1185. membershipPurchase(.fourDevicesAllAccessPackNew12months_lite, discountCode: nil)
  1186. }
  1187. } else if state == .lite_MacWindows {
  1188. if tag == 2 {
  1189. let platforms = KMMemberInfo.shared.vip_platforms
  1190. let platformsArray = platforms
  1191. .components(separatedBy: ",")
  1192. .map { $0.trimmingCharacters(in: .whitespaces) }
  1193. if KMMemberInfo.shared.userScenarioType == .lite_type5 {
  1194. if platformsArray.count == 1 {
  1195. membershipPurchase(.advancedAddDevicesAllAccessPack12months_lite, discountCode: nil)
  1196. } else if platformsArray.count == 2 {
  1197. membershipPurchase(.advancedAdd2DevicesAllAccessPack12months_lite, discountCode: nil)
  1198. }
  1199. } else {
  1200. if platformsArray.count == 1 {
  1201. membershipPurchase(.advancedAddDevicesAllAccessPack12months_lite, discountCode: nil)
  1202. } else if platformsArray.count == 2 {
  1203. membershipPurchase(.advancedAdd2DevicesAllAccessPack12months_lite, discountCode: nil)
  1204. } else {
  1205. membershipPurchase(.advancedAdd2DevicesAllAccessPack12months_lite, discountCode: nil)
  1206. }
  1207. }
  1208. }
  1209. } else if state == .pro_Base {
  1210. if KMMemberInfo.shared.userScenarioType == .pro_type3 {
  1211. if tag == 2 {
  1212. membershipPurchase(.standardAddDevicesAllAccessPack12months_pro, discountCode: nil)
  1213. } else if tag == 3 {
  1214. membershipPurchase(.pdfToOfficePackPermanent_pro, discountCode: nil)
  1215. }
  1216. }
  1217. } else if state == .pro_Advanced {
  1218. let platforms = KMMemberInfo.shared.vip_platforms
  1219. let platformsArray = platforms
  1220. .components(separatedBy: ",")
  1221. .map { $0.trimmingCharacters(in: .whitespaces) }
  1222. if KMMemberInfo.shared.userScenarioType == .pro_type1 {
  1223. if platformsArray.count == 1 {
  1224. membershipPurchase(.advancedAddDevicesAllAccessPack12months_pro, discountCode: nil)
  1225. } else if platformsArray.count == 2 {
  1226. membershipPurchase(.advancedAdd2DevicesAllAccessPack12months_pro, discountCode: nil)
  1227. } else if KMMemberInfo.shared.vip_levels == "1" {
  1228. membershipPurchase(.advancedAddDevicesAllAccessPack12months_pro, discountCode: nil)
  1229. } else {
  1230. membershipPurchase(.advancedAdd2DevicesAllAccessPack12months_pro, discountCode: nil)
  1231. }
  1232. } else if KMMemberInfo.shared.userScenarioType == .pro_type4 {
  1233. if platformsArray.count == 1 {
  1234. membershipPurchase(.advancedAddDevicesAllAccessPack12months_pro, discountCode: nil)
  1235. } else if platformsArray.count == 2 {
  1236. membershipPurchase(.advancedAdd2DevicesAllAccessPack12months_pro, discountCode: nil)
  1237. } else {
  1238. membershipPurchase(.advancedAdd2DevicesAllAccessPack12months_pro, discountCode: nil)
  1239. }
  1240. }
  1241. } else {
  1242. #if VERSION_FREE
  1243. #if VERSION_DMG
  1244. // DMG
  1245. var code = ""
  1246. if state == .dmg_Base {
  1247. if isBlackFive {
  1248. code = KMAdvancedAnnualSubscriptionBlackFiveCodeKey_DMG
  1249. } else {
  1250. code = KMAdvancedAnnualSubscriptionCodeKey_DMG
  1251. }
  1252. } else {
  1253. if KMMemberInfo.shared.canTrail && state == .trial {
  1254. code = KMAdvancedAnnualSubscriptionTrailCodeKey_DMG
  1255. } else {
  1256. code = KMAdvancedAnnualSubscriptionCodeKey_DMG
  1257. }
  1258. }
  1259. let embeddedWC = KMPurchaseEmbeddedWindowController.currentCode(code)
  1260. if code == KMAdvancedAnnualSubscriptionTrailCodeKey_DMG && discountType == .freeTrail {
  1261. embeddedWC.openWindow(discountType: discountType)
  1262. } else {
  1263. embeddedWC.showWindow(nil)
  1264. }
  1265. embeddedWC.window?.center()
  1266. #else
  1267. // AppStore 免费版本
  1268. if tag == 2 {
  1269. membershipPurchase(.fourDevicesAllAccessPackNew12months_lite, discountCode: nil)
  1270. }
  1271. #endif
  1272. #else
  1273. // AppStore 付费版
  1274. #endif
  1275. }
  1276. }
  1277. func appStoreEquityVerification(_ notification: Notification,_ complete: @escaping KMMemberProductComplete) -> Void {
  1278. #if VERSION_FREE
  1279. #if VERSION_DMG
  1280. // DMG
  1281. #else
  1282. // AppStore 免费版本
  1283. var transactionId: String = ""
  1284. var productId: String = ""
  1285. if let userInfo = notification.object as? SKPaymentTransaction {
  1286. transactionId = userInfo.transactionIdentifier ?? ""
  1287. productId = userInfo.payment.productIdentifier
  1288. } else if let userInfo = notification.object as? KMIAPTransaction {
  1289. transactionId = userInfo.transactionIdentifier ?? ""
  1290. productId = userInfo.productIdentifier ?? ""
  1291. } else if let info = notification.userInfo as? [String : Any] {
  1292. transactionId = info["tid"] as? String ?? ""
  1293. productId = info["pid"] as? String ?? ""
  1294. }
  1295. if transactionId.isEmpty == false && productId.isEmpty == false {
  1296. KMPrint("Transaction ID: \(transactionId)")
  1297. KMPrint("product ID: \(productId)")
  1298. var productCode = ""
  1299. var isSubscribed = false
  1300. if productId == "com.pdfreaderpro.mac_free.member.all_access_pack_advanced_6months.001" {
  1301. productCode = "advanced-annual-subscription-six-month"
  1302. if IAPProductsManager.default().fourDevicesAllAccessPackNew6Months_lite.isSubscribed {
  1303. isSubscribed = true
  1304. }
  1305. } else if productId == "com.pdfreaderpro.mac_free.member.all_access_pack_advanced_annual.001" {
  1306. let model = IAPReceiptTool.fetchProductLastestReceipts(with: IAPProductsManager.default().receiptModel, withProductId: productId)
  1307. if model?.is_trial_period == true {
  1308. productCode = "advanced-annual-subscription-trail"
  1309. } else {
  1310. productCode = "advanced-annual-subscription"
  1311. }
  1312. KMPrint("productCode: \(productCode)")
  1313. if IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite.isSubscribed {
  1314. isSubscribed = true
  1315. }
  1316. } else if productId == "com.pdfreaderpro.mac_free.member.all_access_pack_new_6months.001" {
  1317. productCode = "advanced-annual-subscription-six-month"
  1318. if IAPProductsManager.default().allAccessPackNew6months_lite.isSubscribed {
  1319. isSubscribed = true
  1320. }
  1321. } else if productId == "com.pdfreaderpro.mac_free.member.all_access_pack_12months.001" {
  1322. productCode = "advanced-annual-subscription"
  1323. if IAPProductsManager.default().allAccessPack12months_lite.isSubscribed {
  1324. isSubscribed = true
  1325. }
  1326. } else if productId == "com.pdfreaderpro.mac_free.member.all_access_pack_6months.001" {
  1327. productCode = "advanced-annual-subscription-six-month"
  1328. if IAPProductsManager.default().allAccessPack6months_lite.isSubscribed {
  1329. isSubscribed = true
  1330. }
  1331. } else if productId == "com.pdfreaderpro.mac_free.member.ai_pack_1_month" {
  1332. productCode = "ai-subscription-month"
  1333. if IAPProductsManager.default().aiAllAccessPack1month_lite.isSubscribed {
  1334. isSubscribed = true
  1335. }
  1336. } else if productId == "com.pdfreaderpro.mac_free.member.ai_pack_12_month" {
  1337. productCode = "ai-subscription-year-trail"
  1338. if IAPProductsManager.default().aiAllAccessPack12month_lite.isSubscribed {
  1339. isSubscribed = true
  1340. }
  1341. } else if productId == "com.pdfreaderpro.mac_free.member.all_access_pack_advanced_permanent_license.001" {
  1342. productCode = "advanced-permanent"
  1343. if IAPProductsManager.default().allAccessPackPermanent_lite.isSubscribed {
  1344. isSubscribed = true
  1345. }
  1346. } else if productId == "com.pdfreaderpro.mac_free.member.advanced_add_devices_all_access_pack_advanced_annual.001" {
  1347. productCode = "advanced-annual-subscription-single-upgrade"
  1348. if IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_lite.isSubscribed {
  1349. isSubscribed = true
  1350. }
  1351. } else if productId == "com.pdfreaderpro.mac_free.member.advanced_add_2_devices_all_access_pack_advanced_annual.001" {
  1352. productCode = "advanced-annual-subscription-multi-upgrade"
  1353. if IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_lite.isSubscribed {
  1354. isSubscribed = true
  1355. }
  1356. }
  1357. if isSubscribed {
  1358. KMMemberCenterManager.manager.appStoreEquityVerification(applePayProductId: productId, transactionId: transactionId, productCode: productCode) { success, result in
  1359. DispatchQueue.main.async {
  1360. if success {
  1361. complete(true, result)
  1362. } else {
  1363. complete(false, result)
  1364. }
  1365. }
  1366. }
  1367. }
  1368. } else {
  1369. print(NSLocalizedString("Order does not exist.", tableName: "MemberCenterLocalizable", comment: ""))
  1370. }
  1371. #endif
  1372. #else
  1373. // AppStore 付费版
  1374. if let userInfo = notification.object as? SKPaymentTransaction,
  1375. let transactionId = userInfo.transactionIdentifier as? String,
  1376. let productId = userInfo.payment.productIdentifier as? String {
  1377. print("Transaction ID: \(transactionId)")
  1378. print("product ID: \(productId)")
  1379. var productCode = ""
  1380. var isSubscribed = false
  1381. if productId == "com.pdfreaderpro.mac.ai_pack_1_month" {
  1382. productCode = "ai-subscription-month"
  1383. if IAPProductsManager.default().aiAllAccessPack1month_pro.isSubscribed {
  1384. isSubscribed = true
  1385. }
  1386. } else if productId == "com.pdfreaderpro.mac.ai_pack_12_month" {
  1387. productCode = "ai-subscription-year-trail"
  1388. if IAPProductsManager.default().aiAllAccessPack12month_pro.isSubscribed {
  1389. isSubscribed = true
  1390. }
  1391. } else if productId == "com.pdfreaderpro.mac.pdf_to_office_pack_permanent_license.001" {
  1392. productCode = "advanced-permanent-mac-upgrade"
  1393. if IAPProductsManager.default().pdfToOfficePackPermanent_pro.isSubscribed {
  1394. isSubscribed = true
  1395. }
  1396. } else if productId == "com.pdfreaderpro.mac.all_access_pack_advanced_annual.001" {
  1397. productCode = "advanced-permanent-mac-upgrade"
  1398. if IAPProductsManager.default().fourDevicesAllAccessPack12months_pro.isSubscribed {
  1399. isSubscribed = true
  1400. }
  1401. } else if productId == "com.pdfreaderpro.mac.standard_add_devices_all_access_pack_advanced_annual.001" {
  1402. productCode = "advanced-annual-subscription-standard-upgrade"
  1403. if IAPProductsManager.default().standardAddDevicesAllAccessPack12months_pro.isSubscribed {
  1404. isSubscribed = true
  1405. }
  1406. } else if productId == "com.pdfreaderpro.mac.advanced_add_devices_all_access_pack_advanced_annual.001" {
  1407. productCode = "advanced-annual-subscription-single-upgrade"
  1408. if IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_pro.isSubscribed {
  1409. isSubscribed = true
  1410. }
  1411. } else if productId == "com.pdfreaderpro.mac.advanced_add_2_devices_all_access_pack_advanced_annual.001" {
  1412. productCode = "advanced-annual-subscription-multi-upgrade"
  1413. if IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_pro.isSubscribed {
  1414. isSubscribed = true
  1415. }
  1416. }
  1417. if isSubscribed {
  1418. KMMemberCenterManager.manager.appStoreEquityVerification(applePayProductId: productId, transactionId: transactionId, productCode: productCode) { success, result in
  1419. if success {
  1420. complete(true, result)
  1421. } else {
  1422. complete(false, result)
  1423. }
  1424. }
  1425. }
  1426. } else {
  1427. print(NSLocalizedString("Order does not exist.", tableName: "MemberCenterLocalizable", comment: ""))
  1428. }
  1429. #endif
  1430. }
  1431. var isCancelAutoRenew: Bool {
  1432. return IAPProductsManager.default().isCancelAutoRenew()
  1433. }
  1434. var isShowSale: Bool {
  1435. if #available(macOS 10.14.4, *), isCancelAutoRenew {
  1436. #if VERSION_FREE
  1437. #if VERSION_DMG
  1438. // DMG
  1439. if let info = KMAdvertisementManager.manager.info.StoreUserRecovery?.content?.first, !(info.show! as NSString).boolValue {
  1440. return false
  1441. }
  1442. #else
  1443. // AppStore 免费版本
  1444. let manager = IAPProductsManager.default()
  1445. let isSubscribed_newlyMonth = manager?.fourDevicesAllAccessPackNew6Months_lite.isSubscribed ?? false
  1446. let isSubscribed_year = manager?.fourDevicesAllAccessPackNew12months_lite.isSubscribed ?? false
  1447. if isSubscribed_newlyMonth || isSubscribed_year {
  1448. return false
  1449. }
  1450. if let info = KMAdvertisementManager.manager.info.StoreUserRecovery?.content?.first, !(info.show! as NSString).boolValue {
  1451. return false
  1452. }
  1453. if let discounts = manager?.fourDevicesAllAccessPackNew12months_lite.product?.discounts, discounts.count <= 0 {
  1454. return false
  1455. }
  1456. #endif
  1457. #else
  1458. // AppStore 付费版
  1459. if let info = KMAdvertisementManager.manager.info.StoreUserRecovery?.content?.first, !(info.show! as NSString).boolValue {
  1460. return false
  1461. }
  1462. #endif
  1463. return true
  1464. }
  1465. return false
  1466. }
  1467. #if !VERSION_DMG
  1468. func checkSubscriptionOffer(for product: SKProduct?) -> KMPaymentModeType {
  1469. guard let theProduct = product else {
  1470. return .null
  1471. }
  1472. if let introductoryPrice = theProduct.introductoryPrice {
  1473. switch introductoryPrice.paymentMode {
  1474. case .freeTrial:
  1475. return .freeTrial
  1476. case .payAsYouGo:
  1477. return .payAsYouGo
  1478. case .payUpFront:
  1479. return .payUpFront
  1480. @unknown default:
  1481. print("Unknown introductory offer type.")
  1482. }
  1483. }
  1484. if #available(iOS 12.2, *), !theProduct.discounts.isEmpty {
  1485. return .discount
  1486. }
  1487. return .null
  1488. }
  1489. #endif
  1490. // MARK: Private Method
  1491. /**
  1492. 会员购买
  1493. */
  1494. private func membershipPurchase(_ type: KMPurchasedProductType, discountCode: String?) -> Void {
  1495. #if !VERSION_DMG
  1496. if type == .fourDevicesAllAccessPackNew6months_lite || type == .fourDevicesAllAccessPackNew12months_lite {
  1497. if isPurchaseSwitch {
  1498. if let data = discountCode, data.isEmpty == false {
  1499. IAPProductsManager.default().buySubProduct(IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite, discountCode: data)
  1500. } else {
  1501. IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite, discount: isCancelAutoRenew)
  1502. }
  1503. } else {
  1504. if let data = discountCode, data.isEmpty == false {
  1505. IAPProductsManager.default().buySubProduct(IAPProductsManager.default().fourDevicesAllAccessPackNew6Months_lite, discountCode: data)
  1506. } else {
  1507. IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().fourDevicesAllAccessPackNew6Months_lite, discount: isCancelAutoRenew)
  1508. }
  1509. }
  1510. } else if type == .aiAllAccessPack1month_lite {
  1511. IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().aiAllAccessPack1month_lite, discount: isCancelAutoRenew)
  1512. } else if type == .aiAllAccessPack12month_lite {
  1513. IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().aiAllAccessPack12month_lite, discount: isCancelAutoRenew)
  1514. } else if type == .allAccessPackPermanent_lite {
  1515. IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().allAccessPackPermanent_lite, discount: isCancelAutoRenew)
  1516. } else if type == .advancedAddDevicesAllAccessPack12months_lite {
  1517. IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_lite, discount: isCancelAutoRenew)
  1518. } else if type == .advancedAdd2DevicesAllAccessPack12months_lite {
  1519. IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_lite, discount: isCancelAutoRenew)
  1520. } else if type == .aiAllAccessPack1month_pro {
  1521. IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().aiAllAccessPack1month_pro, discount: isCancelAutoRenew)
  1522. } else if type == .aiAllAccessPack12month_pro {
  1523. IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().aiAllAccessPack12month_pro, discount: isCancelAutoRenew)
  1524. } else if type == .pdfToOfficePackPermanent_pro {
  1525. IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().pdfToOfficePackPermanent_pro, discount: isCancelAutoRenew)
  1526. } else if type == .fourDevicesAllAccessPack12months_pro {
  1527. IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().fourDevicesAllAccessPack12months_pro, discount: isCancelAutoRenew)
  1528. } else if type == .standardAddDevicesAllAccessPack12months_pro {
  1529. IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().standardAddDevicesAllAccessPack12months_pro, discount: isCancelAutoRenew)
  1530. } else if type == .advancedAddDevicesAllAccessPack12months_pro {
  1531. IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_pro, discount: isCancelAutoRenew)
  1532. } else if type == .advancedAdd2DevicesAllAccessPack12months_pro {
  1533. IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_pro, discount: isCancelAutoRenew)
  1534. }
  1535. #endif
  1536. }
  1537. private func _isUSD() -> Bool {
  1538. return NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD"
  1539. }
  1540. // MARK: Action Method
  1541. /**
  1542. 恢复购买
  1543. */
  1544. func productRestore() -> Void {
  1545. IAPProductsManager.default().restoreSubscriptions()
  1546. }
  1547. func privacyPolicyAction() -> Void {
  1548. NSWorkspace.shared.open(URL(string: "https://www.pdfreaderpro.com/privacy-policy")!)
  1549. }
  1550. func termOfSerAction() -> Void {
  1551. NSWorkspace.shared.open(URL(string: "https://www.pdfreaderpro.com/terms_of_service")!)
  1552. }
  1553. // MARK: Get & Set
  1554. /**
  1555. 当前比较表产品列表内容
  1556. */
  1557. var products: [KMCompareProductType] {
  1558. if state == .trial {
  1559. return [.free, .freeTrial]
  1560. } else if state == .dmg_Base {
  1561. return [.free, .allPlatformStandard, .allPlatformAdvanced_12, .dualPlatformAdvanced]
  1562. } else if state == .dmg_Upgrades1 {
  1563. return [.allPlatformAdvanced_12]
  1564. } else if state == .dmg_Upgrades1 {
  1565. return [.allPlatformAdvanced_12]
  1566. } else if state == .lite_Base {
  1567. return [.free, .allPlatformAdvanced_6, .allPlatformAdvanced_12, .dualPlatformAdvanced]
  1568. } else if state == .lite_MacWindows {
  1569. return [.allPlatformAdvanced_12]
  1570. } else if state == .pro_Base {
  1571. return [.allPlatformAdvanced_12, .macPlatformAdvanced]
  1572. } else if state == .pro_Advanced {
  1573. return [.allPlatformAdvanced_12]
  1574. }
  1575. return []
  1576. }
  1577. /**
  1578. 比较表数据源
  1579. */
  1580. var dataSource: [Any] {
  1581. if isPurchaseSwitch {
  1582. // 试用 全平台标准版年订阅 全平台高级版6/12个月订阅 Mac&Windows双平台高级版永久 MAC单平台高级版永久
  1583. //MAC单平台标准版永久
  1584. if KMMemberInfo.shared.vip_levels == "1" && KMMemberInfo.shared.vip_status != 2 {
  1585. var aiYear = NSLocalizedString("Free for the 1st year, then auto-renew at $125.99/year", tableName: "MemberCenterLocalizable", comment: "")
  1586. #if VERSION_FREE
  1587. #if VERSION_DMG
  1588. // DMG
  1589. if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
  1590. let priceStr = "USD $\(getDMGPrice(productCode: KMAISubscriptionYearTrailCodeKey_DMG))"
  1591. aiYear = String(format: NSLocalizedString("Free for the 1st year, then auto-renew at %@/year", tableName: "MemberCenterLocalizable", comment: ""), priceStr)
  1592. } else {
  1593. let priceStr = "CNY ¥\(getDMGCNYPrice(productCode: KMAISubscriptionYearTrailCodeKey_DMG))"
  1594. aiYear = String(format: NSLocalizedString("Free for the 1st year, then auto-renew at %@/year", tableName: "MemberCenterLocalizable", comment: ""), priceStr)
  1595. }
  1596. #else
  1597. // AppStore 免费版本
  1598. aiYear = String(format: NSLocalizedString("Free for the 1st year, then auto-renew at %@/year", tableName: "MemberCenterLocalizable", comment: ""), IAPProductsManager.default().aiAllAccessPack12month_lite.price())
  1599. #endif
  1600. #else
  1601. // AppStore 付费版
  1602. aiYear = String(format: NSLocalizedString("Free for the 1st year, then auto-renew at %@/year", tableName: "MemberCenterLocalizable", comment: ""), IAPProductsManager.default().aiAllAccessPack12month_pro.price())
  1603. #endif
  1604. return [
  1605. "Membership Benefits",
  1606. ["Supported platforms", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows", "mac"],
  1607. ["Maximum number of accessible devices", "4 devices", "4 devices", "4 devices", "1 device", "1 device"],
  1608. ["1-year AI free use", "X", "X", aiYear, "X", "X"],
  1609. "PDF to Office",
  1610. ["Convert PDFs to Word, HTML, TXT, JPEG or PNG files", "X", "Standard", "Advanced", "Advanced", "Advanced"],
  1611. ["Turn PDF to PPT, Excel, RTF, CSV, and more", "X", "X", "✓", "✓", "✓"],
  1612. ["Convert PDF to TIFF, BMP, GIF or TGA files", "X", "X", "✓", "✓", "✓"],
  1613. "Edit PDF",
  1614. ["Add and edit text in PDF", "X", "✓", "✓", "✓", "✓"],
  1615. ["Edit, crop, replace image in PDF", "X", "✓", "✓", "✓", "✓"],
  1616. "OCR",
  1617. ["Extract texts from image-based or scanned PDF", "X", "✓", "✓", "✓", "✓"],
  1618. "Organize Pages",
  1619. ["Extract, rotate, rearrange, replace, add, delete pages", "X", "✓", "✓", "✓", "✓"],
  1620. ["Split PDFs into multiple files", "X", "✓", "✓", "✓", "✓"],
  1621. "Advanced Editing Tools",
  1622. ["Merge multiple documents into a new PDF", "Up to 2 files or 20 MB", "✓", "✓", "✓", "✓", "✓"],
  1623. ["Add & edit watermark", "X", "✓", "✓", "✓", "✓"],
  1624. ["Add header, footer, page numbers", "X", "✓", "✓", "✓", "✓"],
  1625. ["Add Bates Number", "X", "✓", "✓", "✓", "✓"],
  1626. ["Insert PDF page background by color or image", "X", "✓", "✓", "✓", "✓"],
  1627. ["Create fattened copies", "X", "✓", "✓", "✓", "✓"],
  1628. ["Extract Images", "X", "✓", "✓", "✓", "✓"],
  1629. ["Extract tables", "X", "X", "✓", "✓", "✓"],
  1630. ["Measuring Tools", "X", "✓", "✓", "✓", "✓"],
  1631. "Fill & Sign",
  1632. ["Create digital signature", "X", "✓", "✓", "✓", "✓"],
  1633. ["Create & Edit & Fill Adobe Fillable PDF Forms", "X", "✓", "✓", "✓", "✓"],
  1634. "Security",
  1635. ["Batch encrypting PDF documents", "X", "✓", "✓", "✓", "✓"],
  1636. ["PDF Password Remover", "X", "✓", "✓", "✓", "✓"],
  1637. ["Redact sensitive information", "X", "✓", "✓", "✓", "✓"],
  1638. "Create PDF",
  1639. ["Convert JPEG, JPG, PNG, TIFF, BMP or PSD files to PDFs", "1 file", "✓", "✓", "✓", "✓"],
  1640. ["Create PDFs from a scanner and iOS devices", "X", "✓", "✓", "✓", "✓"],
  1641. "Annotations",
  1642. ["Customize PDF stamps", "X", "✓", "✓", "✓", "✓"],
  1643. ["Hyperlink", "Page Number", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email"],
  1644. ["Signature", "Standard", "Advanced", "Advanced", "Advanced", "Advanced"],
  1645. ["Table", "X", "✓", "✓", "✓", "✓"],
  1646. "View PDF",
  1647. ["Multi-tab viewer", "X", "✓", "✓", "✓", "✓"],
  1648. ["Various printing types: poster, booklet, multi-page printing", "X", "✓", "✓", "✓", "✓"],
  1649. ["Customize theme colors: Light Mode, Dark Mode, Sepia Mode and more", "X", "✓", "✓", "✓", "✓"],
  1650. ["Split View to compare files", "X", "✓", "✓", "✓", "✓"],
  1651. "Subscription Based Solution",
  1652. ["Access all premium features in app", "X", "12 months", "12 months", "∞", "∞"],
  1653. ["Priority customer support", "X", "✓", "✓", "✓", "✓"],
  1654. ["Ad-free", "X", "✓", "✓", "✓", "✓"]
  1655. ]
  1656. } else {
  1657. return [
  1658. "Membership Benefits",
  1659. ["Supported platforms", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows", "mac"],
  1660. ["Maximum number of accessible devices", "4 devices", "4 devices", "4 devices", "1 device", "1 device"],
  1661. ["1-year AI free use", "X", "X", "X", "X", "X"],
  1662. "PDF to Office",
  1663. ["Convert PDFs to Word, HTML, TXT, JPEG or PNG files", "X", "Standard", "Advanced", "Advanced", "Advanced"],
  1664. ["Turn PDF to PPT, Excel, RTF, CSV, and more", "X", "X", "✓", "✓", "✓"],
  1665. ["Convert PDF to TIFF, BMP, GIF or TGA files", "X", "X", "✓", "✓", "✓"],
  1666. "Edit PDF",
  1667. ["Add and edit text in PDF", "X", "✓", "✓", "✓", "✓"],
  1668. ["Edit, crop, replace image in PDF", "X", "✓", "✓", "✓", "✓"],
  1669. "OCR",
  1670. ["Extract texts from image-based or scanned PDF", "X", "✓", "✓", "✓", "✓"],
  1671. "Organize Pages",
  1672. ["Extract, rotate, rearrange, replace, add, delete pages", "X", "✓", "✓", "✓", "✓"],
  1673. ["Split PDFs into multiple files", "X", "✓", "✓", "✓", "✓"],
  1674. "Advanced Editing Tools",
  1675. ["Merge multiple documents into a new PDF", "Up to 2 files or 20 MB", "✓", "✓", "✓", "✓", "✓"],
  1676. ["Add & edit watermark", "X", "✓", "✓", "✓", "✓"],
  1677. ["Add header, footer, page numbers", "X", "✓", "✓", "✓", "✓"],
  1678. ["Add Bates Number", "X", "✓", "✓", "✓", "✓"],
  1679. ["Insert PDF page background by color or image", "X", "✓", "✓", "✓", "✓"],
  1680. ["Create fattened copies", "X", "✓", "✓", "✓", "✓"],
  1681. ["Extract Images", "X", "✓", "✓", "✓", "✓"],
  1682. ["Extract tables", "X", "X", "✓", "✓", "✓"],
  1683. ["Measuring Tools", "X", "✓", "✓", "✓", "✓"],
  1684. "Fill & Sign",
  1685. ["Create digital signature", "X", "✓", "✓", "✓", "✓"],
  1686. ["Create & Edit & Fill Adobe Fillable PDF Forms", "X", "✓", "✓", "✓", "✓"],
  1687. "Security",
  1688. ["Batch encrypting PDF documents", "X", "✓", "✓", "✓", "✓"],
  1689. ["PDF Password Remover", "X", "✓", "✓", "✓", "✓"],
  1690. ["Redact sensitive information", "X", "✓", "✓", "✓", "✓"],
  1691. "Create PDF",
  1692. ["Convert JPEG, JPG, PNG, TIFF, BMP or PSD files to PDFs", "1 file", "✓", "✓", "✓", "✓"],
  1693. ["Create PDFs from a scanner and iOS devices", "X", "✓", "✓", "✓", "✓"],
  1694. "Annotations",
  1695. ["Customize PDF stamps", "X", "✓", "✓", "✓", "✓"],
  1696. ["Hyperlink", "Page Number", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email"],
  1697. ["Signature", "Standard", "Advanced", "Advanced", "Advanced", "Advanced"],
  1698. ["Table", "X", "✓", "✓", "✓", "✓"],
  1699. "View PDF",
  1700. ["Multi-tab viewer", "X", "✓", "✓", "✓", "✓"],
  1701. ["Various printing types: poster, booklet, multi-page printing", "X", "✓", "✓", "✓", "✓"],
  1702. ["Customize theme colors: Light Mode, Dark Mode, Sepia Mode and more", "X", "✓", "✓", "✓", "✓"],
  1703. ["Split View to compare files", "X", "✓", "✓", "✓", "✓"],
  1704. "Subscription Based Solution",
  1705. ["Access all premium features in app", "X", "12 months", "12 months", "∞", "∞"],
  1706. ["Priority customer support", "X", "✓", "✓", "✓", "✓"],
  1707. ["Ad-free", "X", "✓", "✓", "✓", "✓"]
  1708. ]
  1709. }
  1710. } else {
  1711. if KMMemberInfo.shared.vip_levels == "1" && KMMemberInfo.shared.vip_status != 2 {
  1712. return [
  1713. "Membership Benefits",
  1714. ["Supported platforms", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows", "mac"],
  1715. ["Maximum number of accessible devices", "4 devices", "4 devices", "4 devices", "1 device", "1 device"],
  1716. ["1-year AI free use", "X", "X", "X", "X", "X"],
  1717. "PDF to Office",
  1718. ["Convert PDFs to Word, HTML, TXT, JPEG or PNG files", "X", "Standard", "Advanced", "Advanced", "Advanced"],
  1719. ["Turn PDF to PPT, Excel, RTF, CSV, and more", "X", "X", "✓", "✓", "✓"],
  1720. ["Convert PDF to TIFF, BMP, GIF or TGA files", "X", "X", "✓", "✓", "✓"],
  1721. "Edit PDF",
  1722. ["Add and edit text in PDF", "X", "✓", "✓", "✓", "✓"],
  1723. ["Edit, crop, replace image in PDF", "X", "✓", "✓", "✓", "✓"],
  1724. "OCR",
  1725. ["Extract texts from image-based or scanned PDF", "X", "✓", "✓", "✓", "✓"],
  1726. "Organize Pages",
  1727. ["Extract, rotate, rearrange, replace, add, delete pages", "X", "✓", "✓", "✓", "✓"],
  1728. ["Split PDFs into multiple files", "X", "✓", "✓", "✓", "✓"],
  1729. "Advanced Editing Tools",
  1730. ["Merge multiple documents into a new PDF", "Up to 2 files or 20 MB", "✓", "✓", "✓", "✓", "✓"],
  1731. ["Add & edit watermark", "X", "✓", "✓", "✓", "✓"],
  1732. ["Add header, footer, page numbers", "X", "✓", "✓", "✓", "✓"],
  1733. ["Add Bates Number", "X", "✓", "✓", "✓", "✓"],
  1734. ["Insert PDF page background by color or image", "X", "✓", "✓", "✓", "✓"],
  1735. ["Create fattened copies", "X", "✓", "✓", "✓", "✓"],
  1736. ["Extract Images", "X", "✓", "✓", "✓", "✓"],
  1737. ["Extract tables", "X", "X", "✓", "✓", "✓"],
  1738. ["Measuring Tools", "X", "✓", "✓", "✓", "✓"],
  1739. "Fill & Sign",
  1740. ["Create digital signature", "X", "✓", "✓", "✓", "✓"],
  1741. ["Create & Edit & Fill Adobe Fillable PDF Forms", "X", "✓", "✓", "✓", "✓"],
  1742. "Security",
  1743. ["Batch encrypting PDF documents", "X", "✓", "✓", "✓", "✓"],
  1744. ["PDF Password Remover", "X", "✓", "✓", "✓", "✓"],
  1745. ["Redact sensitive information", "X", "✓", "✓", "✓", "✓"],
  1746. "Create PDF",
  1747. ["Convert JPEG, JPG, PNG, TIFF, BMP or PSD files to PDFs", "1 file", "✓", "✓", "✓", "✓"],
  1748. ["Create PDFs from a scanner and iOS devices", "X", "✓", "✓", "✓", "✓"],
  1749. "Annotations",
  1750. ["Customize PDF stamps", "X", "✓", "✓", "✓", "✓"],
  1751. ["Hyperlink", "Page Number", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email"],
  1752. ["Signature", "Standard", "Advanced", "Advanced", "Advanced", "Advanced"],
  1753. ["Table", "X", "✓", "✓", "✓", "✓"],
  1754. "View PDF",
  1755. ["Multi-tab viewer", "X", "✓", "✓", "✓", "✓"],
  1756. ["Various printing types: poster, booklet, multi-page printing", "X", "✓", "✓", "✓", "✓"],
  1757. ["Customize theme colors: Light Mode, Dark Mode, Sepia Mode and more", "X", "✓", "✓", "✓", "✓"],
  1758. ["Split View to compare files", "X", "✓", "✓", "✓", "✓"],
  1759. "Subscription Based Solution",
  1760. ["Access all premium features in app", "X", "6 months", "6 months", "∞", "∞"],
  1761. ["Priority customer support", "X", "✓", "✓", "✓", "✓"],
  1762. ["Ad-free", "X", "✓", "✓", "✓", "✓"]
  1763. ]
  1764. } else {
  1765. return [
  1766. "Membership Benefits",
  1767. ["Supported platforms", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows", "mac"],
  1768. ["Maximum number of accessible devices", "4 devices", "4 devices", "4 devices", "1 device", "1 device"],
  1769. ["1-year AI free use", "X", "X", "X", "X", "X"],
  1770. "PDF to Office",
  1771. ["Convert PDFs to Word, HTML, TXT, JPEG or PNG files", "X", "Standard", "Advanced", "Advanced", "Advanced"],
  1772. ["Turn PDF to PPT, Excel, RTF, CSV, and more", "X", "X", "✓", "✓", "✓"],
  1773. ["Convert PDF to TIFF, BMP, GIF or TGA files", "X", "X", "✓", "✓", "✓"],
  1774. "Edit PDF",
  1775. ["Add and edit text in PDF", "X", "✓", "✓", "✓", "✓"],
  1776. ["Edit, crop, replace image in PDF", "X", "✓", "✓", "✓", "✓"],
  1777. "OCR",
  1778. ["Extract texts from image-based or scanned PDF", "X", "✓", "✓", "✓", "✓"],
  1779. "Organize Pages",
  1780. ["Extract, rotate, rearrange, replace, add, delete pages", "X", "✓", "✓", "✓", "✓"],
  1781. ["Split PDFs into multiple files", "X", "✓", "✓", "✓", "✓"],
  1782. "Advanced Editing Tools",
  1783. ["Merge multiple documents into a new PDF", "Up to 2 files or 20 MB", "✓", "✓", "✓", "✓", "✓"],
  1784. ["Add & edit watermark", "X", "✓", "✓", "✓", "✓"],
  1785. ["Add header, footer, page numbers", "X", "✓", "✓", "✓", "✓"],
  1786. ["Add Bates Number", "X", "✓", "✓", "✓", "✓"],
  1787. ["Insert PDF page background by color or image", "X", "✓", "✓", "✓", "✓"],
  1788. ["Create fattened copies", "X", "✓", "✓", "✓", "✓"],
  1789. ["Extract Images", "X", "✓", "✓", "✓", "✓"],
  1790. ["Extract tables", "X", "X", "✓", "✓", "✓"],
  1791. ["Measuring Tools", "X", "✓", "✓", "✓", "✓"],
  1792. "Fill & Sign",
  1793. ["Create digital signature", "X", "✓", "✓", "✓", "✓"],
  1794. ["Create & Edit & Fill Adobe Fillable PDF Forms", "X", "✓", "✓", "✓", "✓"],
  1795. "Security",
  1796. ["Batch encrypting PDF documents", "X", "✓", "✓", "✓", "✓"],
  1797. ["PDF Password Remover", "X", "✓", "✓", "✓", "✓"],
  1798. ["Redact sensitive information", "X", "✓", "✓", "✓", "✓"],
  1799. "Create PDF",
  1800. ["Convert JPEG, JPG, PNG, TIFF, BMP or PSD files to PDFs", "1 file", "✓", "✓", "✓", "✓"],
  1801. ["Create PDFs from a scanner and iOS devices", "X", "✓", "✓", "✓", "✓"],
  1802. "Annotations",
  1803. ["Customize PDF stamps", "X", "✓", "✓", "✓", "✓"],
  1804. ["Hyperlink", "Page Number", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email"],
  1805. ["Signature", "Standard", "Advanced", "Advanced", "Advanced", "Advanced"],
  1806. ["Table", "X", "✓", "✓", "✓", "✓"],
  1807. "View PDF",
  1808. ["Multi-tab viewer", "X", "✓", "✓", "✓", "✓"],
  1809. ["Various printing types: poster, booklet, multi-page printing", "X", "✓", "✓", "✓", "✓"],
  1810. ["Customize theme colors: Light Mode, Dark Mode, Sepia Mode and more", "X", "✓", "✓", "✓", "✓"],
  1811. ["Split View to compare files", "X", "✓", "✓", "✓", "✓"],
  1812. "Subscription Based Solution",
  1813. ["Access all premium features in app", "X", "6 months", "6 months", "∞", "∞"],
  1814. ["Priority customer support", "X", "✓", "✓", "✓", "✓"],
  1815. ["Ad-free", "X", "✓", "✓", "✓", "✓"]
  1816. ]
  1817. }
  1818. }
  1819. }
  1820. /**
  1821. 是否黑五活动期
  1822. */
  1823. var isBlackFive: Bool {
  1824. #if DEBUG
  1825. return false
  1826. #endif
  1827. if let loginContent = KMAdvertisementManager.manager.info.topRightInfoContent {
  1828. if loginContent.content?.isEmpty == false {
  1829. return true
  1830. }
  1831. }
  1832. return false
  1833. }
  1834. }