Ver código fonte

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

wangshuai 1 semana atrás
pai
commit
1f5ff004f5

+ 31 - 0
PDF Office/PDF Master/MemberCenter/ViewModel/KMProductModel.swift

@@ -67,7 +67,17 @@ class KMProductModel: ObservableObject {
      */
     var dmgProductDatas: KMMemberProductResult?
     
+    /**
+     DMG 版本 已经登录用户 最后一次价格价格获取
+     */
+    var dmgLastGetProductPriceInfos: KMMemberProductResult?
+    
     // MARK: DMG Public Method
+    
+    /**
+     @abstract 获取服务器架上所有商品 (得到的价格是原始价格)
+     @param
+     */
     func getDMGProductDatas() -> Void {
         if KMMemberCenterManager.manager.isConnectionAvailable() == false {
             let alert = NSAlert()
@@ -86,6 +96,27 @@ class KMProductModel: ObservableObject {
         
     }
     
+    /**
+     @abstract 获取登录用户价格(建立订单时需要用到)
+     @param
+     */
+    func getDMGProductPriceInfosForMember(productId: String, isEducation: Int, _ complete: @escaping KMMemberProductComplete) {
+        if KMMemberCenterManager.manager.isConnectionAvailable() == false {
+            let alert = NSAlert()
+            alert.alertStyle = .critical
+            alert.messageText = NSLocalizedString("Error Information", comment: "")
+            alert.informativeText = NSLocalizedString("Please make sure your internet connection is available.", comment: "")
+            alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
+            alert.runModal()
+            return
+        }
+        //暂时无教育优惠,先固定传 0
+        KMMemberCenterManager.manager.getProductPriceForBuy(productId: productId, isEducation: 0, userId:KMMemberInfo.shared.userID) { [weak self] success, result in
+            guard let productsArrays : KMMemberProductResult = result else { return }
+            self?.dmgLastGetProductPriceInfos = productsArrays
+        }
+    }
+    
     // MARK: Public Method
     
     /**