Procházet zdrojové kódy

【会员系统】二次点击订单界面获取订单价格不对问题

wangshuai před 2 dny
rodič
revize
4cefb0d5d9

+ 51 - 47
PDF Office/PDF Master/Class/Purchase/DMG/KMPurchaseEmbeddedWindowController.swift

@@ -281,21 +281,49 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
     func updateProduct_Info() -> Void { //重新获取产品接口
         if KMMemberInfo.shared.isLogin {
             let model = KMProductModel.shared
-            model.getDMGProductPriceInfosForMember(productId: product_Info.id, isEducation: 0) { [weak self] success, result in
-                if success {
-                    guard let productResults : KMMemberProductResult = result else {
+            if(pdfCount > 1) {
+                model.getDMGBatchProductPriceInfosForMember(productId: _product_Info.id, num: pdfCount) { [weak self] success, result in
+                    guard let pricesArrays : KMMemberProductResult = result else {
                         return
                     }
-                    guard let products : [KMListingProductsModel] = productResults.listingProducts else {
+                    guard let batchProductPrice : KMBatchProductPriceModel = pricesArrays.batchProductPrice else {
                         return
                     }
-                    guard let product : KMListingProductsModel = products.first else {
-                        return
+                    //原价更新
+                    let priceString = batchProductPrice.totalPrice
+                    self?.product_Info.priceString = priceString
+                    
+                    let cnyPriceString = batchProductPrice.cnyTotalPrice
+                    self?.product_Info.cnyPriceString = cnyPriceString //批量时将总价赋给priceString,只显示priceString价格了,其他的置空
+                    
+                    self?.product_Info.upgradePriceString = nil
+                    self?.product_Info.displayPriceString = nil
+                    self?.product_Info.displayCnyPriceString = nil
+                    self?.product_Info.individualPriceString = batchProductPrice.price
+                    self?.product_Info.individualCnyPriceString = batchProductPrice.cnyPrice
+                    
+                    if self?._paymentMethod == .alipay || self?._paymentMethod == .wxpay {
+                        self?.updatePrice()
                     }
-                    self?.product_Info = product;
-                    for tProduct in products {
-                        if tProduct.id == self?.product_Info.id {
-                            self?.product_Info = product;
+                    self?.priceRefresh(productsModel: self?.product_Info ?? KMListingProductsModel())
+                }
+            } else {
+                model.getDMGProductPriceInfosForMember(productId: product_Info.id, isEducation: 0) { [weak self] success, result in
+                    if success {
+                        guard let productResults : KMMemberProductResult = result else {
+                            return
+                        }
+                        guard let products : [KMListingProductsModel] = productResults.listingProducts else {
+                            return
+                        }
+                        guard let product : KMListingProductsModel = products.first else {
+                            return
+                        }
+                        self?.product_Info = product;
+                        for tProduct in products {
+                            if tProduct.id == self?.product_Info.id {
+                                self?.product_Info = product;
+                            }
                         }
                     }
                 }
@@ -344,7 +372,11 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
         refreshLicenseCodeView(isReveal: true)
         refreshLicenseCodeErrorView(isReveal: false)
         
-        removeButton1.isEnabled = false
+        if pdfCount > 1 {
+            removeButton1.isEnabled = true
+        } else {
+            removeButton1.isEnabled = false
+        }
         amountTextField1.delegate = self
 
         couponButton.title = NSLocalizedString("I have a coupon?", comment: "")
@@ -651,11 +683,7 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
                     pdfCount += 1
                 }
             }
-            if pdfCount > 1 {
-                removeButton1.isEnabled = true
-            } else {
-                removeButton1.isEnabled = false
-            }
+            
             if pdfCount > 100 {
                 wechatPayButton2.isHidden = false
                 cardButton.isHidden = true
@@ -686,35 +714,8 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
         let model = KMProductModel.shared
         isBatchProductPriceGetFinsed = false
         
-        if(pdfCount > 1) {
-            model.getDMGBatchProductPriceInfosForMember(productId: _product_Info.id, num: pdfCount) { [weak self] success, result in
-                guard let pricesArrays : KMMemberProductResult = result else {
-                    return
-                }
-                guard let batchProductPrice : KMBatchProductPriceModel = pricesArrays.batchProductPrice else {
-                    return
-                }
-                //原价更新
-                let priceString = batchProductPrice.totalPrice
-                self?.product_Info.priceString = priceString
-                
-                let cnyPriceString = batchProductPrice.cnyTotalPrice
-                self?.product_Info.cnyPriceString = cnyPriceString //批量时将总价赋给priceString,只显示priceString价格了,其他的置空
-                
-                self?.product_Info.upgradePriceString = nil
-                self?.product_Info.displayPriceString = nil
-                self?.product_Info.displayCnyPriceString = nil
-                self?.product_Info.individualPriceString = batchProductPrice.price
-                self?.product_Info.individualCnyPriceString = batchProductPrice.cnyPrice
-                
-                if self?._paymentMethod == .alipay || self?._paymentMethod == .wxpay {
-                    self?.updatePrice()
-                }
-                self?.priceRefresh(productsModel: self?.product_Info ?? KMListingProductsModel())
-            }
-        } else {
-            updateProduct_Info()
-        }
+        updateProduct_Info()
+
     }
     
     @IBAction func payButtonAction(_ sender: NSButton) {
@@ -1079,7 +1080,11 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
                 
                 prodocumentView.isHidden = false
             }
-            
+            if pdfCount > 1 {
+                removeButton1.isEnabled = true
+            } else {
+                removeButton1.isEnabled = false
+            }
             if(newValue == "advanced-annual-subscription-trail" ||
                newValue == "ai-subscription-year-trail") {
                 couponView.isHidden = true
@@ -1091,7 +1096,6 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
                 for product in products {
                     if product.code == _product_code {
                         self.product_Info = product;
-                        //更新价格
                         self.updateProduct_Info()
                         break
                     }