|
@@ -293,12 +293,12 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
}
|
|
|
|
|
|
// MARK: DMG Action
|
|
|
- func isMoreCountViewShouldHidden(_ productinfo: KMListingProductsModel) -> Bool {
|
|
|
+ func isOneTimePurchase(_ productinfo: KMListingProductsModel) -> Bool {
|
|
|
//买断版本才能一次购买多个,并且购买多个时,不会自动绑定,需要在后台给自己绑定才能有会员权益
|
|
|
if productinfo.paymentModel == 2 {
|
|
|
- return false
|
|
|
+ return true
|
|
|
}
|
|
|
- return true
|
|
|
+ return false
|
|
|
}
|
|
|
|
|
|
func updateKMDMGProductType(_ productinfo: KMListingProductsModel) -> Void {
|
|
@@ -376,7 +376,12 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
discountPriceLabel1.textColor = NSColor(named: "KMPurchaseDiscountColor")
|
|
|
discountPriceLabel1.font = NSFont.SFProTextRegularFont(9.0)
|
|
|
refreshLicenseCodeView(isReveal: false)
|
|
|
- usualAddCountView.isHidden = isMoreCountViewShouldHidden(product_Info)
|
|
|
+ if isOneTimePurchase(product_Info) {
|
|
|
+ usualAddCountView.isHidden = false
|
|
|
+ } else {
|
|
|
+ usualAddCountView.isHidden = true
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
oneLicenseLabel.stringValue = NSLocalizedString("and more offline. It's one time purchase.", comment: "")
|
|
|
oneLicenseLabel.isHidden = true
|
|
@@ -805,10 +810,7 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
}
|
|
|
|
|
|
if _dmgProductType == .advanced_permanent {
|
|
|
- // 全平台高级版年订阅 99.9 美金,无试用
|
|
|
- // 全平台标准版年订阅 79.9 美金
|
|
|
// Mac & Win 双平台高级永久 119.99 美金
|
|
|
- // AI 月订阅 14.99 美金
|
|
|
aiAddOnView.isHidden = true
|
|
|
extendedView.isHidden = true
|
|
|
|
|
@@ -1233,6 +1235,11 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
if let cnyBatchPriceDouble = Double(cnyBatchPriceString) {
|
|
|
self?.product_Info.displayCnyPrice = NSNumber(value: cnyBatchPriceDouble)
|
|
|
}
|
|
|
+
|
|
|
+ self?.product_Info.totalPrice = batchProductPrice.totalPrice
|
|
|
+ self?.product_Info.cnyTotalPrice = batchProductPrice.cnyTotalPrice
|
|
|
+
|
|
|
+
|
|
|
self?.isBatchProductPriceGetFinsed = true
|
|
|
self?.priceRefresh(productsModel: self?.product_Info ?? KMListingProductsModel())
|
|
|
}
|
|
@@ -1515,62 +1522,193 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- var licenseCode = ""
|
|
|
- if productID == "com.brother.pdfreaderpro.mac.product_2" {
|
|
|
- if licenseCodeTextField.stringValue.count > 0 {
|
|
|
- licenseCode = licenseCodeTextField.stringValue
|
|
|
- } else {
|
|
|
- let alert = NSAlert()
|
|
|
- alert.alertStyle = .critical
|
|
|
- alert.messageText = NSLocalizedString("Error Information", comment: "")
|
|
|
- alert.informativeText = NSLocalizedString("Input license code previously activated the app", comment: "")
|
|
|
- alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
|
|
|
- alert.runModal()
|
|
|
-
|
|
|
- return
|
|
|
- }
|
|
|
- if let license = VerificationManager.default().originLicenseCode, license.count > 0 {
|
|
|
- licenseCode = license
|
|
|
- }
|
|
|
- }
|
|
|
+// var licenseCode = ""
|
|
|
+// if productID == "com.brother.pdfreaderpro.mac.product_2" {
|
|
|
+// if licenseCodeTextField.stringValue.count > 0 {
|
|
|
+// licenseCode = licenseCodeTextField.stringValue
|
|
|
+// } else {
|
|
|
+// let alert = NSAlert()
|
|
|
+// alert.alertStyle = .critical
|
|
|
+// alert.messageText = NSLocalizedString("Error Information", comment: "")
|
|
|
+// alert.informativeText = NSLocalizedString("Input license code previously activated the app", comment: "")
|
|
|
+// alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
|
|
|
+// alert.runModal()
|
|
|
+//
|
|
|
+// return
|
|
|
+// }
|
|
|
+// if let license = VerificationManager.default().originLicenseCode, license.count > 0 {
|
|
|
+// licenseCode = license
|
|
|
+// }
|
|
|
+// }
|
|
|
var couponCode = ""
|
|
|
if coupomErrorLabel.isHidden {
|
|
|
couponCode = coupomTextField.stringValue
|
|
|
}
|
|
|
- self._buyProduct(productID, count: pdfCount, discountId: couponCode, payment: paymentMethod, license: licenseCode, email: emailTextField.stringValue) { [weak self] info, err in
|
|
|
- guard let self = self else { return }
|
|
|
- if err != nil {
|
|
|
- DispatchQueue.main.async {
|
|
|
- let alert = NSAlert()
|
|
|
- alert.alertStyle = .critical
|
|
|
- alert.messageText = NSLocalizedString("Please check if the information is wrong or the network is error.", comment: "")
|
|
|
- alert.addButton(withTitle: NSLocalizedString("Yes", comment: ""))
|
|
|
- alert.runModal()
|
|
|
+
|
|
|
+ let model = KMProductModel.shared
|
|
|
+ if isOneTimePurchase(_product_Info) {
|
|
|
+ var price = _product_Info.totalPrice
|
|
|
+ if self.paymentMethod == .wxpay {
|
|
|
+ if NSLocalizedString("USD", comment: "") == "CNY" {
|
|
|
+ price = _product_Info.cnyTotalPrice
|
|
|
}
|
|
|
- return
|
|
|
}
|
|
|
- if let dataInfo = info {
|
|
|
- self.orderID = dataInfo["trade_no"] as! String
|
|
|
- let page_pay_url = dataInfo["page_pay_url"] as! String
|
|
|
- if self.paymentMethod == .paddle || self.paymentMethod == .paypal {
|
|
|
- if page_pay_url != "" {
|
|
|
- self.openWebView(page_pay_url)
|
|
|
+ if self.paymentMethod == .alipay {
|
|
|
+ if NSLocalizedString("USD", comment: "") == "CNY" {
|
|
|
+ price = _product_Info.cnyTotalPrice
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ model.creatOrder(productId: _product_Info.id,
|
|
|
+ paymentMethod: getPurchasePaymentMethod(),
|
|
|
+ price: price,
|
|
|
+ discountFlag: getOneTimePurchaseDiscountFlag(),
|
|
|
+ couponCode: couponCode,
|
|
|
+ num: pdfCount) { success, result in
|
|
|
+ //写定时器查询结果
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ var price = _product_Info.price
|
|
|
+ let displayPriceString = String(format: "%.2@", _product_Info.displayPrice)
|
|
|
+ if displayPriceString == "0" {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ price = _product_Info.displayPrice
|
|
|
+ }
|
|
|
+ if self.paymentMethod == .wxpay {
|
|
|
+ if NSLocalizedString("USD", comment: "") == "CNY" {
|
|
|
+ price = _product_Info.cnyPrice
|
|
|
+ let displayCnyPriceString = String(format: "%.2@", _product_Info.displayCnyPrice)
|
|
|
+ if displayCnyPriceString == "0" {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ price = _product_Info.displayCnyPrice
|
|
|
}
|
|
|
- } else if self.paymentMethod == .wxpay || self.paymentMethod == .alipay {
|
|
|
- if page_pay_url != "" {
|
|
|
- self.scanCode(page_pay_url)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if self.paymentMethod == .alipay {
|
|
|
+ if NSLocalizedString("USD", comment: "") == "CNY" {
|
|
|
+ price = _product_Info.cnyPrice
|
|
|
+ let displayCnyPriceString = String(format: "%.2@", _product_Info.displayCnyPrice)
|
|
|
+ if displayCnyPriceString == "0" {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ price = _product_Info.displayCnyPrice
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ let priceString = String(format: "%.2@", price)
|
|
|
+ model.createSubscriber(productId: _product_Info.id,
|
|
|
+ paymentMethod: getPurchasePaymentMethod(),
|
|
|
+ price: priceString,
|
|
|
+ discountFlag: getPurchaseDiscountFlag(),
|
|
|
+ couponCode: couponCode,
|
|
|
+ num: pdfCount) { success, result in
|
|
|
+ //写定时器查询结果
|
|
|
+ }
|
|
|
+ }
|
|
|
+// self._buyProduct(productID, count: pdfCount, discountId: couponCode, payment: paymentMethod, license: licenseCode, email: emailTextField.stringValue) { [weak self] info, err in
|
|
|
+// guard let self = self else { return }
|
|
|
+// if err != nil {
|
|
|
+// DispatchQueue.main.async {
|
|
|
+// let alert = NSAlert()
|
|
|
+// alert.alertStyle = .critical
|
|
|
+// alert.messageText = NSLocalizedString("Please check if the information is wrong or the network is error.", comment: "")
|
|
|
+// alert.addButton(withTitle: NSLocalizedString("Yes", comment: ""))
|
|
|
+// alert.runModal()
|
|
|
+// }
|
|
|
+// return
|
|
|
+// }
|
|
|
+// if let dataInfo = info {
|
|
|
+// self.orderID = dataInfo["trade_no"] as! String
|
|
|
+// let page_pay_url = dataInfo["page_pay_url"] as! String
|
|
|
+// if self.paymentMethod == .paddle || self.paymentMethod == .paypal {
|
|
|
+// if page_pay_url != "" {
|
|
|
+// self.openWebView(page_pay_url)
|
|
|
+// }
|
|
|
+// } else if self.paymentMethod == .wxpay || self.paymentMethod == .alipay {
|
|
|
+// if page_pay_url != "" {
|
|
|
+// self.scanCode(page_pay_url)
|
|
|
+// }
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// // 数据错误
|
|
|
+// DispatchQueue.main.async {
|
|
|
+// let alert = NSAlert()
|
|
|
+// alert.alertStyle = .critical
|
|
|
+// alert.messageText = NSLocalizedString("Please check if the information is wrong or the network is error.", comment: "")
|
|
|
+// alert.addButton(withTitle: NSLocalizedString("Yes", comment: ""))
|
|
|
+// alert.runModal()
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+ }
|
|
|
+
|
|
|
+ func getPurchasePaymentMethod() -> Int {
|
|
|
+ switch self.paymentMethod {
|
|
|
+ case .paypal:
|
|
|
+ return 0;
|
|
|
+ case .alipay:
|
|
|
+ return 1;
|
|
|
+ case .wxpay:
|
|
|
+ return 2;
|
|
|
+ case .paddle:
|
|
|
+ return 3;
|
|
|
+ default:
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func getOneTimePurchaseDiscountFlag() -> Int {
|
|
|
+ if pdfCount > 1 {
|
|
|
+ return 4
|
|
|
+ } else {
|
|
|
+ var couponCode = ""
|
|
|
+ if coupomErrorLabel.isHidden {
|
|
|
+ couponCode = coupomTextField.stringValue
|
|
|
+ }
|
|
|
+ if couponCode == "" {
|
|
|
+ if _dmgProductType == .advanced_annual_subscription_blackFive ||
|
|
|
+ _dmgProductType == .advanced_permanent_blackFive {
|
|
|
+ return 5
|
|
|
+ }
|
|
|
+ if _dmgProductType == .advanced_annual_subscription_trail ||
|
|
|
+ _dmgProductType == .ai_subscription_year_trail {
|
|
|
+ return 5
|
|
|
+ }
|
|
|
+ return 0
|
|
|
} else {
|
|
|
- // 数据错误
|
|
|
- DispatchQueue.main.async {
|
|
|
- let alert = NSAlert()
|
|
|
- alert.alertStyle = .critical
|
|
|
- alert.messageText = NSLocalizedString("Please check if the information is wrong or the network is error.", comment: "")
|
|
|
- alert.addButton(withTitle: NSLocalizedString("Yes", comment: ""))
|
|
|
- alert.runModal()
|
|
|
+ if _dmgProductType == .advanced_annual_subscription_blackFive ||
|
|
|
+ _dmgProductType == .advanced_permanent_blackFive {
|
|
|
+ return 11
|
|
|
}
|
|
|
+ return 1
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func getPurchaseDiscountFlag() -> Int {
|
|
|
+ var couponCode = ""
|
|
|
+ if coupomErrorLabel.isHidden {
|
|
|
+ couponCode = coupomTextField.stringValue
|
|
|
+ }
|
|
|
+ if couponCode == "" {
|
|
|
+ if _dmgProductType == .advanced_annual_subscription_blackFive ||
|
|
|
+ _dmgProductType == .advanced_permanent_blackFive {
|
|
|
+ return 5
|
|
|
+ }
|
|
|
+ if _dmgProductType == .advanced_annual_subscription_trail ||
|
|
|
+ _dmgProductType == .ai_subscription_year_trail {
|
|
|
+ return 5
|
|
|
+ }
|
|
|
+ return 0
|
|
|
+ } else {
|
|
|
+ if _dmgProductType == .advanced_annual_subscription_blackFive ||
|
|
|
+ _dmgProductType == .advanced_permanent_blackFive {
|
|
|
+ return 11
|
|
|
}
|
|
|
+ return 1
|
|
|
}
|
|
|
}
|
|
|
|