Browse Source

Merge branch 'develop_PDFReaderPro_V4.7.0' of git.kdan.cc:Mac_PDF/PDF_Office into develop_PDFReaderPro_V4.7.0

tangchao 4 days ago
parent
commit
560c475822

+ 43 - 8
PDF Office/PDF Master/Class/Purchase/DMG/KMPurchaseEmbeddedWindowController.swift

@@ -720,7 +720,8 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
                 self?.product_Info.displayPriceString = nil
                 self?.product_Info.displayCnyPriceString = nil
                 self?.product_Info.individualPriceString = batchProductPrice.price
-                
+                self?.product_Info.individualCnyPriceString = batchProductPrice.cnyPrice
+
                 self?.priceRefresh(productsModel: self?.product_Info ?? KMListingProductsModel())
             }
         } else {
@@ -762,8 +763,29 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
         
         KMMemberCenterManager.manager.checkCoupon(productId: product_Info.id, userId: KMMemberInfo.shared.userID, code: coupomTextField.stringValue) {[weak self] success, result in
             if(success == true) {
-//                self?.product_Info.price =
-//                self?.priceRefresh(productsModel: product_Info)
+                
+                guard let productResult : KMMemberProductResult = result else {
+                    return
+                }
+                guard let couponModel : KMCheckCouponModel = productResult.checkCoupon else {
+                    return
+                }
+
+                let priceString = couponModel.priceString
+                self?.product_Info.priceString = priceString
+                
+                let cnyPriceString = couponModel.cnyPriceString
+                self?.product_Info.cnyPriceString = cnyPriceString //批量时将总价赋给priceString,只显示priceString价格了,其他的置空
+                
+                self?.product_Info.upgradePriceString = couponModel.upgradePriceString
+                self?.product_Info.displayPriceString = couponModel.displayPriceString
+                self?.product_Info.displayCnyPriceString = couponModel.displayCnyPriceString
+                
+                self?.product_Info.individualPriceString = couponModel.priceString
+                self?.product_Info.individualCnyPriceString = couponModel.cnyPriceString
+                self?.product_Info.verifyofferCode = self?.coupomTextField.stringValue ?? ""
+
+                self?.priceRefresh(productsModel: self?._product_Info ?? KMListingProductsModel())
             }else {
                 let alert = NSAlert()
                 alert.alertStyle = .critical
@@ -834,8 +856,8 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
         }
 
         var couponCode = ""
-        if coupomErrorLabel.isHidden {
-            couponCode = coupomTextField.stringValue
+        if product_Info.verifyofferCode.isEmpty == false  {
+            couponCode = product_Info.verifyofferCode
         }
         
         let model = KMProductModel.shared
@@ -902,7 +924,7 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
             model.createSubscriber(productId: _product_Info.id,
                                    paymentMethod: getPurchasePaymentMethod(),
                                    price: priceString,
-                                   discountFlag: getPurchaseDiscountFlag(),
+                                   discountFlag: getOneTimePurchaseDiscountFlag(),
                                    couponCode: couponCode,
                                    num: pdfCount) { success, result in
                 if success {
@@ -964,8 +986,8 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
             return 4
         } else {
             var couponCode = ""
-            if coupomErrorLabel.isHidden {
-                couponCode = coupomTextField.stringValue
+            if _product_Info.verifyofferCode.isEmpty == false {
+                couponCode = _product_Info.verifyofferCode
             }
             
             if(couponCode.isEmpty == false) {//判断是否有使用优惠卷
@@ -1187,6 +1209,19 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
 
         return priceString
     }
+    
+    func showsinglePriceString()->String { //单价
+        let preferredLanguage = Locale.preferredLanguages.first ?? "en"
+        var priceString = product_Info.priceString ?? ""
+        if preferredLanguage.hasPrefix("zh-Hans") || preferredLanguage.hasPrefix("zh-Hant") {
+            priceString = product_Info.individualPriceString ?? ""
+        } else {
+            priceString = product_Info.individualCnyPriceString ?? ""
+        }
+
+        return priceString
+    }
+
 
     
     func showPayPriceString()->String { //实际支付的价格

+ 2 - 0
PDF Office/PDF Master/MemberCenter/Model/KMMemberCenterManager.swift

@@ -1007,6 +1007,7 @@ class KMMemberCenterManager: NSObject {
 
                     let products = KMListingProductsModel(id: id, productName: productName, price: priceString, maxDeviceNum: maxDeviceNum, displayPrice: displayPriceString, levels: levels, platforms: platforms, productLineId: productLineId, paymentModel: paymentModel, cycle: cycle, cnyPrice: cnyPriceString, displayCnyPrice: displayCnyPriceString, upgradePrice: upgradePriceString, code: code)
                     products.individualPriceString = priceString
+                    products.individualCnyPriceString = cnyPriceString
                     results.append(products)
                 }
 
@@ -1118,6 +1119,7 @@ class KMMemberCenterManager: NSObject {
 
                     let products = KMListingProductsModel(id: id, productName: productName, price: priceString, maxDeviceNum: maxDeviceNum, displayPrice: displayPriceString, levels: levels, platforms: platforms, productLineId: productLineId, paymentModel: paymentModel, cycle: cycle, cnyPrice: cnyPriceString, displayCnyPrice: displayCnyPriceString, upgradePrice: upgradePriceString, code: code)
                     products.individualPriceString = priceString
+                    products.individualCnyPriceString = cnyPriceString
                     results.append(products)
                 }
 

+ 3 - 0
PDF Office/PDF Master/MemberCenter/Model/KMMemberProductResult.swift

@@ -99,10 +99,12 @@ class KMListingProductsModel: NSObject {
     var upgradePriceString    : String? // 【可选】买断升级订阅价格
     
     var individualPriceString    : String? // 每个单价
+    var individualCnyPriceString    : String? // 每个单价
 
     var totalPrice      : String = "" // 【可选】批量购买总价
     var cnyTotalPrice   : String = "" // 【可选】批量购买优惠总价人民币总价
 
+    var verifyofferCode   : String = "" // 优惠码
 
     init(id: String, productName: String, price: String?, maxDeviceNum: Int, displayPrice: String?, levels: String, platforms: String, productLineId: Int, paymentModel: Int, cycle: Int, cnyPrice: String?, displayCnyPrice: String?, upgradePrice: String?, code: String) {
         self.id = id
@@ -165,6 +167,7 @@ class KMCheckCouponModel: NSObject {
     var displayCnyPriceString : String? // 【可选】人民币优惠价格
     var displayPriceString    : String? // 【可选】教育优惠价格
     var upgradePriceString    : String? // 【可选】买断升级订阅价格
+    var verifyofferCode   : String = "" // 优惠码
     
     init(id: String, productName: String, price: String?, maxDeviceNum: Int, displayPrice: String?, levels: String, platforms: String, productLineId: Int, paymentModel: Int, cycle: Int, cnyPrice: String?, displayCnyPrice:  String?, upgradePrice:  String?, code: String) {
         self.id = id