KMProductModel.swift 119 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905
  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. embeddedWC.showWindow(nil)
  1261. embeddedWC.window?.center()
  1262. #else
  1263. // AppStore 免费版本
  1264. if tag == 2 {
  1265. membershipPurchase(.fourDevicesAllAccessPackNew12months_lite, discountCode: nil)
  1266. }
  1267. #endif
  1268. #else
  1269. // AppStore 付费版
  1270. #endif
  1271. }
  1272. }
  1273. func appStoreEquityVerification(_ notification: Notification,_ complete: @escaping KMMemberProductComplete) -> Void {
  1274. #if VERSION_FREE
  1275. #if VERSION_DMG
  1276. // DMG
  1277. #else
  1278. // AppStore 免费版本
  1279. var transactionId: String = ""
  1280. var productId: String = ""
  1281. if let userInfo = notification.object as? SKPaymentTransaction {
  1282. transactionId = userInfo.transactionIdentifier ?? ""
  1283. productId = userInfo.payment.productIdentifier
  1284. } else if let userInfo = notification.object as? KMIAPTransaction {
  1285. transactionId = userInfo.transactionIdentifier ?? ""
  1286. productId = userInfo.productIdentifier ?? ""
  1287. } else if let info = notification.userInfo as? [String : Any] {
  1288. transactionId = info["tid"] as? String ?? ""
  1289. productId = info["pid"] as? String ?? ""
  1290. }
  1291. if transactionId.isEmpty == false && productId.isEmpty == false {
  1292. KMPrint("Transaction ID: \(transactionId)")
  1293. KMPrint("product ID: \(productId)")
  1294. var productCode = ""
  1295. var isSubscribed = false
  1296. if productId == "com.pdfreaderpro.mac_free.member.all_access_pack_advanced_6months.001" {
  1297. productCode = "advanced-annual-subscription-six-month"
  1298. if IAPProductsManager.default().fourDevicesAllAccessPackNew6Months_lite.isSubscribed {
  1299. isSubscribed = true
  1300. }
  1301. } else if productId == "com.pdfreaderpro.mac_free.member.all_access_pack_advanced_annual.001" {
  1302. let model = IAPReceiptTool.fetchProductLastestReceipts(with: IAPProductsManager.default().receiptModel, withProductId: productId)
  1303. if model?.is_trial_period == true {
  1304. productCode = "advanced-annual-subscription-trail"
  1305. } else {
  1306. productCode = "advanced-annual-subscription"
  1307. }
  1308. KMPrint("productCode: \(productCode)")
  1309. if IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite.isSubscribed {
  1310. isSubscribed = true
  1311. }
  1312. } else if productId == "com.pdfreaderpro.mac_free.member.all_access_pack_new_6months.001" {
  1313. productCode = "advanced-annual-subscription-six-month"
  1314. if IAPProductsManager.default().allAccessPackNew6months_lite.isSubscribed {
  1315. isSubscribed = true
  1316. }
  1317. } else if productId == "com.pdfreaderpro.mac_free.member.all_access_pack_12months.001" {
  1318. productCode = "advanced-annual-subscription"
  1319. if IAPProductsManager.default().allAccessPack12months_lite.isSubscribed {
  1320. isSubscribed = true
  1321. }
  1322. } else if productId == "com.pdfreaderpro.mac_free.member.all_access_pack_6months.001" {
  1323. productCode = "advanced-annual-subscription-six-month"
  1324. if IAPProductsManager.default().allAccessPack6months_lite.isSubscribed {
  1325. isSubscribed = true
  1326. }
  1327. } else if productId == "com.pdfreaderpro.mac_free.member.ai_pack_1_month" {
  1328. productCode = "ai-subscription-month"
  1329. if IAPProductsManager.default().aiAllAccessPack1month_lite.isSubscribed {
  1330. isSubscribed = true
  1331. }
  1332. } else if productId == "com.pdfreaderpro.mac_free.member.ai_pack_12_month" {
  1333. productCode = "ai-subscription-year-trail"
  1334. if IAPProductsManager.default().aiAllAccessPack12month_lite.isSubscribed {
  1335. isSubscribed = true
  1336. }
  1337. } else if productId == "com.pdfreaderpro.mac_free.member.all_access_pack_advanced_permanent_license.001" {
  1338. productCode = "advanced-permanent"
  1339. if IAPProductsManager.default().allAccessPackPermanent_lite.isSubscribed {
  1340. isSubscribed = true
  1341. }
  1342. } else if productId == "com.pdfreaderpro.mac_free.member.advanced_add_devices_all_access_pack_advanced_annual.001" {
  1343. productCode = "advanced-annual-subscription-single-upgrade"
  1344. if IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_lite.isSubscribed {
  1345. isSubscribed = true
  1346. }
  1347. } else if productId == "com.pdfreaderpro.mac_free.member.advanced_add_2_devices_all_access_pack_advanced_annual.001" {
  1348. productCode = "advanced-annual-subscription-multi-upgrade"
  1349. if IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_lite.isSubscribed {
  1350. isSubscribed = true
  1351. }
  1352. }
  1353. if isSubscribed {
  1354. KMMemberCenterManager.manager.appStoreEquityVerification(applePayProductId: productId, transactionId: transactionId, productCode: productCode) { success, result in
  1355. DispatchQueue.main.async {
  1356. if success {
  1357. complete(true, result)
  1358. } else {
  1359. complete(false, result)
  1360. }
  1361. }
  1362. }
  1363. }
  1364. } else {
  1365. print(NSLocalizedString("Order does not exist.", tableName: "MemberCenterLocalizable", comment: ""))
  1366. }
  1367. #endif
  1368. #else
  1369. // AppStore 付费版
  1370. if let userInfo = notification.object as? SKPaymentTransaction,
  1371. let transactionId = userInfo.transactionIdentifier as? String,
  1372. let productId = userInfo.payment.productIdentifier as? String {
  1373. print("Transaction ID: \(transactionId)")
  1374. print("product ID: \(productId)")
  1375. var productCode = ""
  1376. var isSubscribed = false
  1377. if productId == "com.pdfreaderpro.mac.ai_pack_1_month" {
  1378. productCode = "ai-subscription-month"
  1379. if IAPProductsManager.default().aiAllAccessPack1month_pro.isSubscribed {
  1380. isSubscribed = true
  1381. }
  1382. } else if productId == "com.pdfreaderpro.mac.ai_pack_12_month" {
  1383. productCode = "ai-subscription-year-trail"
  1384. if IAPProductsManager.default().aiAllAccessPack12month_pro.isSubscribed {
  1385. isSubscribed = true
  1386. }
  1387. } else if productId == "com.pdfreaderpro.mac.pdf_to_office_pack_permanent_license.001" {
  1388. productCode = "advanced-permanent-mac-upgrade"
  1389. if IAPProductsManager.default().pdfToOfficePackPermanent_pro.isSubscribed {
  1390. isSubscribed = true
  1391. }
  1392. } else if productId == "com.pdfreaderpro.mac.all_access_pack_advanced_annual.001" {
  1393. productCode = "advanced-permanent-mac-upgrade"
  1394. if IAPProductsManager.default().fourDevicesAllAccessPack12months_pro.isSubscribed {
  1395. isSubscribed = true
  1396. }
  1397. } else if productId == "com.pdfreaderpro.mac.standard_add_devices_all_access_pack_advanced_annual.001" {
  1398. productCode = "advanced-annual-subscription-standard-upgrade"
  1399. if IAPProductsManager.default().standardAddDevicesAllAccessPack12months_pro.isSubscribed {
  1400. isSubscribed = true
  1401. }
  1402. } else if productId == "com.pdfreaderpro.mac.advanced_add_devices_all_access_pack_advanced_annual.001" {
  1403. productCode = "advanced-annual-subscription-single-upgrade"
  1404. if IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_pro.isSubscribed {
  1405. isSubscribed = true
  1406. }
  1407. } else if productId == "com.pdfreaderpro.mac.advanced_add_2_devices_all_access_pack_advanced_annual.001" {
  1408. productCode = "advanced-annual-subscription-multi-upgrade"
  1409. if IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_pro.isSubscribed {
  1410. isSubscribed = true
  1411. }
  1412. }
  1413. if isSubscribed {
  1414. KMMemberCenterManager.manager.appStoreEquityVerification(applePayProductId: productId, transactionId: transactionId, productCode: productCode) { success, result in
  1415. if success {
  1416. complete(true, result)
  1417. } else {
  1418. complete(false, result)
  1419. }
  1420. }
  1421. }
  1422. } else {
  1423. print(NSLocalizedString("Order does not exist.", tableName: "MemberCenterLocalizable", comment: ""))
  1424. }
  1425. #endif
  1426. }
  1427. var isCancelAutoRenew: Bool {
  1428. return IAPProductsManager.default().isCancelAutoRenew()
  1429. }
  1430. var isShowSale: Bool {
  1431. if #available(macOS 10.14.4, *), isCancelAutoRenew {
  1432. #if VERSION_FREE
  1433. #if VERSION_DMG
  1434. // DMG
  1435. if let info = KMAdvertisementManager.manager.info.StoreUserRecovery?.content?.first, !(info.show! as NSString).boolValue {
  1436. return false
  1437. }
  1438. #else
  1439. // AppStore 免费版本
  1440. let manager = IAPProductsManager.default()
  1441. let isSubscribed_newlyMonth = manager?.fourDevicesAllAccessPackNew6Months_lite.isSubscribed ?? false
  1442. let isSubscribed_year = manager?.fourDevicesAllAccessPackNew12months_lite.isSubscribed ?? false
  1443. if isSubscribed_newlyMonth || isSubscribed_year {
  1444. return false
  1445. }
  1446. if let info = KMAdvertisementManager.manager.info.StoreUserRecovery?.content?.first, !(info.show! as NSString).boolValue {
  1447. return false
  1448. }
  1449. if let discounts = manager?.fourDevicesAllAccessPackNew12months_lite.product?.discounts, discounts.count <= 0 {
  1450. return false
  1451. }
  1452. #endif
  1453. #else
  1454. // AppStore 付费版
  1455. if let info = KMAdvertisementManager.manager.info.StoreUserRecovery?.content?.first, !(info.show! as NSString).boolValue {
  1456. return false
  1457. }
  1458. #endif
  1459. return true
  1460. }
  1461. return false
  1462. }
  1463. #if !VERSION_DMG
  1464. func checkSubscriptionOffer(for product: SKProduct?) -> KMPaymentModeType {
  1465. guard let theProduct = product else {
  1466. return .null
  1467. }
  1468. if let introductoryPrice = theProduct.introductoryPrice {
  1469. switch introductoryPrice.paymentMode {
  1470. case .freeTrial:
  1471. return .freeTrial
  1472. case .payAsYouGo:
  1473. return .payAsYouGo
  1474. case .payUpFront:
  1475. return .payUpFront
  1476. @unknown default:
  1477. print("Unknown introductory offer type.")
  1478. }
  1479. }
  1480. if #available(iOS 12.2, *), !theProduct.discounts.isEmpty {
  1481. return .discount
  1482. }
  1483. return .null
  1484. }
  1485. #endif
  1486. // MARK: Private Method
  1487. /**
  1488. 会员购买
  1489. */
  1490. private func membershipPurchase(_ type: KMPurchasedProductType, discountCode: String?) -> Void {
  1491. #if !VERSION_DMG
  1492. if type == .fourDevicesAllAccessPackNew6months_lite || type == .fourDevicesAllAccessPackNew12months_lite {
  1493. if isPurchaseSwitch {
  1494. if let data = discountCode, data.isEmpty == false {
  1495. IAPProductsManager.default().buySubProduct(IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite, discountCode: data)
  1496. } else {
  1497. IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().fourDevicesAllAccessPackNew12months_lite, discount: isCancelAutoRenew)
  1498. }
  1499. } else {
  1500. if let data = discountCode, data.isEmpty == false {
  1501. IAPProductsManager.default().buySubProduct(IAPProductsManager.default().fourDevicesAllAccessPackNew6Months_lite, discountCode: data)
  1502. } else {
  1503. IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().fourDevicesAllAccessPackNew6Months_lite, discount: isCancelAutoRenew)
  1504. }
  1505. }
  1506. } else if type == .aiAllAccessPack1month_lite {
  1507. IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().aiAllAccessPack1month_lite, discount: isCancelAutoRenew)
  1508. } else if type == .aiAllAccessPack12month_lite {
  1509. IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().aiAllAccessPack12month_lite, discount: isCancelAutoRenew)
  1510. } else if type == .allAccessPackPermanent_lite {
  1511. IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().allAccessPackPermanent_lite, discount: isCancelAutoRenew)
  1512. } else if type == .advancedAddDevicesAllAccessPack12months_lite {
  1513. IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_lite, discount: isCancelAutoRenew)
  1514. } else if type == .advancedAdd2DevicesAllAccessPack12months_lite {
  1515. IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_lite, discount: isCancelAutoRenew)
  1516. } else if type == .aiAllAccessPack1month_pro {
  1517. IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().aiAllAccessPack1month_pro, discount: isCancelAutoRenew)
  1518. } else if type == .aiAllAccessPack12month_pro {
  1519. IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().aiAllAccessPack12month_pro, discount: isCancelAutoRenew)
  1520. } else if type == .pdfToOfficePackPermanent_pro {
  1521. IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().pdfToOfficePackPermanent_pro, discount: isCancelAutoRenew)
  1522. } else if type == .fourDevicesAllAccessPack12months_pro {
  1523. IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().fourDevicesAllAccessPack12months_pro, discount: isCancelAutoRenew)
  1524. } else if type == .standardAddDevicesAllAccessPack12months_pro {
  1525. IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().standardAddDevicesAllAccessPack12months_pro, discount: isCancelAutoRenew)
  1526. } else if type == .advancedAddDevicesAllAccessPack12months_pro {
  1527. IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().advancedAddDevicesAllAccessPack12months_pro, discount: isCancelAutoRenew)
  1528. } else if type == .advancedAdd2DevicesAllAccessPack12months_pro {
  1529. IAPProductsManager.default().makeSubProduct(IAPProductsManager.default().advancedAdd2DevicesAllAccessPack12months_pro, discount: isCancelAutoRenew)
  1530. }
  1531. #endif
  1532. }
  1533. private func _isUSD() -> Bool {
  1534. return NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD"
  1535. }
  1536. // MARK: Action Method
  1537. /**
  1538. 恢复购买
  1539. */
  1540. func productRestore() -> Void {
  1541. IAPProductsManager.default().restoreSubscriptions()
  1542. }
  1543. func privacyPolicyAction() -> Void {
  1544. NSWorkspace.shared.open(URL(string: "https://www.pdfreaderpro.com/privacy-policy")!)
  1545. }
  1546. func termOfSerAction() -> Void {
  1547. NSWorkspace.shared.open(URL(string: "https://www.pdfreaderpro.com/terms_of_service")!)
  1548. }
  1549. // MARK: Get & Set
  1550. /**
  1551. 当前比较表产品列表内容
  1552. */
  1553. var products: [KMCompareProductType] {
  1554. if state == .trial {
  1555. return [.free, .freeTrial]
  1556. } else if state == .dmg_Base {
  1557. return [.free, .allPlatformStandard, .allPlatformAdvanced_12, .dualPlatformAdvanced]
  1558. } else if state == .dmg_Upgrades1 {
  1559. return [.allPlatformAdvanced_12]
  1560. } else if state == .dmg_Upgrades1 {
  1561. return [.allPlatformAdvanced_12]
  1562. } else if state == .lite_Base {
  1563. return [.free, .allPlatformAdvanced_6, .allPlatformAdvanced_12, .dualPlatformAdvanced]
  1564. } else if state == .lite_MacWindows {
  1565. return [.allPlatformAdvanced_12]
  1566. } else if state == .pro_Base {
  1567. return [.allPlatformAdvanced_12, .macPlatformAdvanced]
  1568. } else if state == .pro_Advanced {
  1569. return [.allPlatformAdvanced_12]
  1570. }
  1571. return []
  1572. }
  1573. /**
  1574. 比较表数据源
  1575. */
  1576. var dataSource: [Any] {
  1577. if isPurchaseSwitch {
  1578. // 试用 全平台标准版年订阅 全平台高级版6/12个月订阅 Mac&Windows双平台高级版永久 MAC单平台高级版永久
  1579. //MAC单平台标准版永久
  1580. if KMMemberInfo.shared.vip_levels == "1" && KMMemberInfo.shared.vip_status != 2 {
  1581. var aiYear = NSLocalizedString("Free for the 1st year, then auto-renew at $125.99/year", tableName: "MemberCenterLocalizable", comment: "")
  1582. #if VERSION_FREE
  1583. #if VERSION_DMG
  1584. // DMG
  1585. if NSLocalizedString("USD", tableName: "MemberCenterLocalizable", comment: "") == "USD" {
  1586. let priceStr = "USD $\(getDMGPrice(productCode: KMAISubscriptionYearTrailCodeKey_DMG))"
  1587. aiYear = String(format: NSLocalizedString("Free for the 1st year, then auto-renew at %@/year", tableName: "MemberCenterLocalizable", comment: ""), priceStr)
  1588. } else {
  1589. let priceStr = "CNY ¥\(getDMGCNYPrice(productCode: KMAISubscriptionYearTrailCodeKey_DMG))"
  1590. aiYear = String(format: NSLocalizedString("Free for the 1st year, then auto-renew at %@/year", tableName: "MemberCenterLocalizable", comment: ""), priceStr)
  1591. }
  1592. #else
  1593. // AppStore 免费版本
  1594. aiYear = String(format: NSLocalizedString("Free for the 1st year, then auto-renew at %@/year", tableName: "MemberCenterLocalizable", comment: ""), IAPProductsManager.default().aiAllAccessPack12month_lite.price())
  1595. #endif
  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_pro.price())
  1599. #endif
  1600. return [
  1601. "Membership Benefits",
  1602. ["Supported platforms", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows", "mac"],
  1603. ["Maximum number of accessible devices", "4 devices", "4 devices", "4 devices", "1 device", "1 device"],
  1604. ["1-year AI free use", "X", "X", aiYear, "X", "X"],
  1605. "PDF to Office",
  1606. ["Convert PDFs to Word, HTML, TXT, JPEG or PNG files", "X", "Standard", "Advanced", "Advanced", "Advanced"],
  1607. ["Turn PDF to PPT, Excel, RTF, CSV, and more", "X", "X", "✓", "✓", "✓"],
  1608. ["Convert PDF to TIFF, BMP, GIF or TGA files", "X", "X", "✓", "✓", "✓"],
  1609. "Edit PDF",
  1610. ["Add and edit text in PDF", "X", "✓", "✓", "✓", "✓"],
  1611. ["Edit, crop, replace image in PDF", "X", "✓", "✓", "✓", "✓"],
  1612. "OCR",
  1613. ["Extract texts from image-based or scanned PDF", "X", "✓", "✓", "✓", "✓"],
  1614. "Organize Pages",
  1615. ["Extract, rotate, rearrange, replace, add, delete pages", "X", "✓", "✓", "✓", "✓"],
  1616. ["Split PDFs into multiple files", "X", "✓", "✓", "✓", "✓"],
  1617. "Advanced Editing Tools",
  1618. ["Merge multiple documents into a new PDF", "Up to 2 files or 20 MB", "✓", "✓", "✓", "✓", "✓"],
  1619. ["Add & edit watermark", "X", "✓", "✓", "✓", "✓"],
  1620. ["Add header, footer, page numbers", "X", "✓", "✓", "✓", "✓"],
  1621. ["Add Bates Number", "X", "✓", "✓", "✓", "✓"],
  1622. ["Insert PDF page background by color or image", "X", "✓", "✓", "✓", "✓"],
  1623. ["Create fattened copies", "X", "✓", "✓", "✓", "✓"],
  1624. ["Extract Images", "X", "✓", "✓", "✓", "✓"],
  1625. ["Extract tables", "X", "X", "✓", "✓", "✓"],
  1626. ["Measuring Tools", "X", "✓", "✓", "✓", "✓"],
  1627. "Fill & Sign",
  1628. ["Create digital signature", "X", "✓", "✓", "✓", "✓"],
  1629. ["Create & Edit & Fill Adobe Fillable PDF Forms", "X", "✓", "✓", "✓", "✓"],
  1630. "Security",
  1631. ["Batch encrypting PDF documents", "X", "✓", "✓", "✓", "✓"],
  1632. ["PDF Password Remover", "X", "✓", "✓", "✓", "✓"],
  1633. ["Redact sensitive information", "X", "✓", "✓", "✓", "✓"],
  1634. "Create PDF",
  1635. ["Convert JPEG, JPG, PNG, TIFF, BMP or PSD files to PDFs", "1 file", "✓", "✓", "✓", "✓"],
  1636. ["Create PDFs from a scanner and iOS devices", "X", "✓", "✓", "✓", "✓"],
  1637. "Annotations",
  1638. ["Customize PDF stamps", "X", "✓", "✓", "✓", "✓"],
  1639. ["Hyperlink", "Page Number", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email"],
  1640. ["Signature", "Standard", "Advanced", "Advanced", "Advanced", "Advanced"],
  1641. ["Table", "X", "✓", "✓", "✓", "✓"],
  1642. "View PDF",
  1643. ["Multi-tab viewer", "X", "✓", "✓", "✓", "✓"],
  1644. ["Various printing types: poster, booklet, multi-page printing", "X", "✓", "✓", "✓", "✓"],
  1645. ["Customize theme colors: Light Mode, Dark Mode, Sepia Mode and more", "X", "✓", "✓", "✓", "✓"],
  1646. ["Split View to compare files", "X", "✓", "✓", "✓", "✓"],
  1647. "Subscription Based Solution",
  1648. ["Access all premium features in app", "X", "12 months", "12 months", "∞", "∞"],
  1649. ["Priority customer support", "X", "✓", "✓", "✓", "✓"],
  1650. ["Ad-free", "X", "✓", "✓", "✓", "✓"]
  1651. ]
  1652. } else {
  1653. return [
  1654. "Membership Benefits",
  1655. ["Supported platforms", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows", "mac"],
  1656. ["Maximum number of accessible devices", "4 devices", "4 devices", "4 devices", "1 device", "1 device"],
  1657. ["1-year AI free use", "X", "X", "X", "X", "X"],
  1658. "PDF to Office",
  1659. ["Convert PDFs to Word, HTML, TXT, JPEG or PNG files", "X", "Standard", "Advanced", "Advanced", "Advanced"],
  1660. ["Turn PDF to PPT, Excel, RTF, CSV, and more", "X", "X", "✓", "✓", "✓"],
  1661. ["Convert PDF to TIFF, BMP, GIF or TGA files", "X", "X", "✓", "✓", "✓"],
  1662. "Edit PDF",
  1663. ["Add and edit text in PDF", "X", "✓", "✓", "✓", "✓"],
  1664. ["Edit, crop, replace image in PDF", "X", "✓", "✓", "✓", "✓"],
  1665. "OCR",
  1666. ["Extract texts from image-based or scanned PDF", "X", "✓", "✓", "✓", "✓"],
  1667. "Organize Pages",
  1668. ["Extract, rotate, rearrange, replace, add, delete pages", "X", "✓", "✓", "✓", "✓"],
  1669. ["Split PDFs into multiple files", "X", "✓", "✓", "✓", "✓"],
  1670. "Advanced Editing Tools",
  1671. ["Merge multiple documents into a new PDF", "Up to 2 files or 20 MB", "✓", "✓", "✓", "✓", "✓"],
  1672. ["Add & edit watermark", "X", "✓", "✓", "✓", "✓"],
  1673. ["Add header, footer, page numbers", "X", "✓", "✓", "✓", "✓"],
  1674. ["Add Bates Number", "X", "✓", "✓", "✓", "✓"],
  1675. ["Insert PDF page background by color or image", "X", "✓", "✓", "✓", "✓"],
  1676. ["Create fattened copies", "X", "✓", "✓", "✓", "✓"],
  1677. ["Extract Images", "X", "✓", "✓", "✓", "✓"],
  1678. ["Extract tables", "X", "X", "✓", "✓", "✓"],
  1679. ["Measuring Tools", "X", "✓", "✓", "✓", "✓"],
  1680. "Fill & Sign",
  1681. ["Create digital signature", "X", "✓", "✓", "✓", "✓"],
  1682. ["Create & Edit & Fill Adobe Fillable PDF Forms", "X", "✓", "✓", "✓", "✓"],
  1683. "Security",
  1684. ["Batch encrypting PDF documents", "X", "✓", "✓", "✓", "✓"],
  1685. ["PDF Password Remover", "X", "✓", "✓", "✓", "✓"],
  1686. ["Redact sensitive information", "X", "✓", "✓", "✓", "✓"],
  1687. "Create PDF",
  1688. ["Convert JPEG, JPG, PNG, TIFF, BMP or PSD files to PDFs", "1 file", "✓", "✓", "✓", "✓"],
  1689. ["Create PDFs from a scanner and iOS devices", "X", "✓", "✓", "✓", "✓"],
  1690. "Annotations",
  1691. ["Customize PDF stamps", "X", "✓", "✓", "✓", "✓"],
  1692. ["Hyperlink", "Page Number", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email"],
  1693. ["Signature", "Standard", "Advanced", "Advanced", "Advanced", "Advanced"],
  1694. ["Table", "X", "✓", "✓", "✓", "✓"],
  1695. "View PDF",
  1696. ["Multi-tab viewer", "X", "✓", "✓", "✓", "✓"],
  1697. ["Various printing types: poster, booklet, multi-page printing", "X", "✓", "✓", "✓", "✓"],
  1698. ["Customize theme colors: Light Mode, Dark Mode, Sepia Mode and more", "X", "✓", "✓", "✓", "✓"],
  1699. ["Split View to compare files", "X", "✓", "✓", "✓", "✓"],
  1700. "Subscription Based Solution",
  1701. ["Access all premium features in app", "X", "12 months", "12 months", "∞", "∞"],
  1702. ["Priority customer support", "X", "✓", "✓", "✓", "✓"],
  1703. ["Ad-free", "X", "✓", "✓", "✓", "✓"]
  1704. ]
  1705. }
  1706. } else {
  1707. if KMMemberInfo.shared.vip_levels == "1" && KMMemberInfo.shared.vip_status != 2 {
  1708. return [
  1709. "Membership Benefits",
  1710. ["Supported platforms", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows", "mac"],
  1711. ["Maximum number of accessible devices", "4 devices", "4 devices", "4 devices", "1 device", "1 device"],
  1712. ["1-year AI free use", "X", "X", "X", "X", "X"],
  1713. "PDF to Office",
  1714. ["Convert PDFs to Word, HTML, TXT, JPEG or PNG files", "X", "Standard", "Advanced", "Advanced", "Advanced"],
  1715. ["Turn PDF to PPT, Excel, RTF, CSV, and more", "X", "X", "✓", "✓", "✓"],
  1716. ["Convert PDF to TIFF, BMP, GIF or TGA files", "X", "X", "✓", "✓", "✓"],
  1717. "Edit PDF",
  1718. ["Add and edit text in PDF", "X", "✓", "✓", "✓", "✓"],
  1719. ["Edit, crop, replace image in PDF", "X", "✓", "✓", "✓", "✓"],
  1720. "OCR",
  1721. ["Extract texts from image-based or scanned PDF", "X", "✓", "✓", "✓", "✓"],
  1722. "Organize Pages",
  1723. ["Extract, rotate, rearrange, replace, add, delete pages", "X", "✓", "✓", "✓", "✓"],
  1724. ["Split PDFs into multiple files", "X", "✓", "✓", "✓", "✓"],
  1725. "Advanced Editing Tools",
  1726. ["Merge multiple documents into a new PDF", "Up to 2 files or 20 MB", "✓", "✓", "✓", "✓", "✓"],
  1727. ["Add & edit watermark", "X", "✓", "✓", "✓", "✓"],
  1728. ["Add header, footer, page numbers", "X", "✓", "✓", "✓", "✓"],
  1729. ["Add Bates Number", "X", "✓", "✓", "✓", "✓"],
  1730. ["Insert PDF page background by color or image", "X", "✓", "✓", "✓", "✓"],
  1731. ["Create fattened copies", "X", "✓", "✓", "✓", "✓"],
  1732. ["Extract Images", "X", "✓", "✓", "✓", "✓"],
  1733. ["Extract tables", "X", "X", "✓", "✓", "✓"],
  1734. ["Measuring Tools", "X", "✓", "✓", "✓", "✓"],
  1735. "Fill & Sign",
  1736. ["Create digital signature", "X", "✓", "✓", "✓", "✓"],
  1737. ["Create & Edit & Fill Adobe Fillable PDF Forms", "X", "✓", "✓", "✓", "✓"],
  1738. "Security",
  1739. ["Batch encrypting PDF documents", "X", "✓", "✓", "✓", "✓"],
  1740. ["PDF Password Remover", "X", "✓", "✓", "✓", "✓"],
  1741. ["Redact sensitive information", "X", "✓", "✓", "✓", "✓"],
  1742. "Create PDF",
  1743. ["Convert JPEG, JPG, PNG, TIFF, BMP or PSD files to PDFs", "1 file", "✓", "✓", "✓", "✓"],
  1744. ["Create PDFs from a scanner and iOS devices", "X", "✓", "✓", "✓", "✓"],
  1745. "Annotations",
  1746. ["Customize PDF stamps", "X", "✓", "✓", "✓", "✓"],
  1747. ["Hyperlink", "Page Number", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email"],
  1748. ["Signature", "Standard", "Advanced", "Advanced", "Advanced", "Advanced"],
  1749. ["Table", "X", "✓", "✓", "✓", "✓"],
  1750. "View PDF",
  1751. ["Multi-tab viewer", "X", "✓", "✓", "✓", "✓"],
  1752. ["Various printing types: poster, booklet, multi-page printing", "X", "✓", "✓", "✓", "✓"],
  1753. ["Customize theme colors: Light Mode, Dark Mode, Sepia Mode and more", "X", "✓", "✓", "✓", "✓"],
  1754. ["Split View to compare files", "X", "✓", "✓", "✓", "✓"],
  1755. "Subscription Based Solution",
  1756. ["Access all premium features in app", "X", "6 months", "6 months", "∞", "∞"],
  1757. ["Priority customer support", "X", "✓", "✓", "✓", "✓"],
  1758. ["Ad-free", "X", "✓", "✓", "✓", "✓"]
  1759. ]
  1760. } else {
  1761. return [
  1762. "Membership Benefits",
  1763. ["Supported platforms", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows, ios, android", "mac, windows", "mac"],
  1764. ["Maximum number of accessible devices", "4 devices", "4 devices", "4 devices", "1 device", "1 device"],
  1765. ["1-year AI free use", "X", "X", "X", "X", "X"],
  1766. "PDF to Office",
  1767. ["Convert PDFs to Word, HTML, TXT, JPEG or PNG files", "X", "Standard", "Advanced", "Advanced", "Advanced"],
  1768. ["Turn PDF to PPT, Excel, RTF, CSV, and more", "X", "X", "✓", "✓", "✓"],
  1769. ["Convert PDF to TIFF, BMP, GIF or TGA files", "X", "X", "✓", "✓", "✓"],
  1770. "Edit PDF",
  1771. ["Add and edit text in PDF", "X", "✓", "✓", "✓", "✓"],
  1772. ["Edit, crop, replace image in PDF", "X", "✓", "✓", "✓", "✓"],
  1773. "OCR",
  1774. ["Extract texts from image-based or scanned PDF", "X", "✓", "✓", "✓", "✓"],
  1775. "Organize Pages",
  1776. ["Extract, rotate, rearrange, replace, add, delete pages", "X", "✓", "✓", "✓", "✓"],
  1777. ["Split PDFs into multiple files", "X", "✓", "✓", "✓", "✓"],
  1778. "Advanced Editing Tools",
  1779. ["Merge multiple documents into a new PDF", "Up to 2 files or 20 MB", "✓", "✓", "✓", "✓", "✓"],
  1780. ["Add & edit watermark", "X", "✓", "✓", "✓", "✓"],
  1781. ["Add header, footer, page numbers", "X", "✓", "✓", "✓", "✓"],
  1782. ["Add Bates Number", "X", "✓", "✓", "✓", "✓"],
  1783. ["Insert PDF page background by color or image", "X", "✓", "✓", "✓", "✓"],
  1784. ["Create fattened copies", "X", "✓", "✓", "✓", "✓"],
  1785. ["Extract Images", "X", "✓", "✓", "✓", "✓"],
  1786. ["Extract tables", "X", "X", "✓", "✓", "✓"],
  1787. ["Measuring Tools", "X", "✓", "✓", "✓", "✓"],
  1788. "Fill & Sign",
  1789. ["Create digital signature", "X", "✓", "✓", "✓", "✓"],
  1790. ["Create & Edit & Fill Adobe Fillable PDF Forms", "X", "✓", "✓", "✓", "✓"],
  1791. "Security",
  1792. ["Batch encrypting PDF documents", "X", "✓", "✓", "✓", "✓"],
  1793. ["PDF Password Remover", "X", "✓", "✓", "✓", "✓"],
  1794. ["Redact sensitive information", "X", "✓", "✓", "✓", "✓"],
  1795. "Create PDF",
  1796. ["Convert JPEG, JPG, PNG, TIFF, BMP or PSD files to PDFs", "1 file", "✓", "✓", "✓", "✓"],
  1797. ["Create PDFs from a scanner and iOS devices", "X", "✓", "✓", "✓", "✓"],
  1798. "Annotations",
  1799. ["Customize PDF stamps", "X", "✓", "✓", "✓", "✓"],
  1800. ["Hyperlink", "Page Number", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email", "Page Number, URL, Email"],
  1801. ["Signature", "Standard", "Advanced", "Advanced", "Advanced", "Advanced"],
  1802. ["Table", "X", "✓", "✓", "✓", "✓"],
  1803. "View PDF",
  1804. ["Multi-tab viewer", "X", "✓", "✓", "✓", "✓"],
  1805. ["Various printing types: poster, booklet, multi-page printing", "X", "✓", "✓", "✓", "✓"],
  1806. ["Customize theme colors: Light Mode, Dark Mode, Sepia Mode and more", "X", "✓", "✓", "✓", "✓"],
  1807. ["Split View to compare files", "X", "✓", "✓", "✓", "✓"],
  1808. "Subscription Based Solution",
  1809. ["Access all premium features in app", "X", "6 months", "6 months", "∞", "∞"],
  1810. ["Priority customer support", "X", "✓", "✓", "✓", "✓"],
  1811. ["Ad-free", "X", "✓", "✓", "✓", "✓"]
  1812. ]
  1813. }
  1814. }
  1815. }
  1816. /**
  1817. 是否黑五活动期
  1818. */
  1819. var isBlackFive: Bool {
  1820. #if DEBUG
  1821. return false
  1822. #endif
  1823. if let loginContent = KMAdvertisementManager.manager.info.topRightInfoContent {
  1824. if loginContent.content?.isEmpty == false {
  1825. return true
  1826. }
  1827. }
  1828. return false
  1829. }
  1830. }