Переглянути джерело

【会员系统】DMG 订单相关API完善

zenghong 1 тиждень тому
батько
коміт
b99c454bf1

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

@@ -112,10 +112,10 @@ class KMProductModel: ObservableObject {
      */
     func getDMGProductDatas() -> Void {
         checkConnectionAvailable()
-//        KMMemberCenterManager.manager.getListingProducts(isEducation: 0) { [weak self] success, result in
-//            guard let productsArrays : KMMemberProductResult = result else { return }
-//            self?.dmgProductDatas = productsArrays
-//        }
+        KMMemberCenterManager.manager.getListingProducts(isEducation: 0) { [weak self] success, result in
+            guard let productsArrays : KMMemberProductResult = result else { return }
+            self?.dmgProductDatas = productsArrays
+        }
         
         if KMMemberInfo.shared.isLogin {
 //            getDMGProductPriceInfosForMember(productId: "SP2024102300004", isEducation: 0) { [weak self] success, result in
@@ -132,12 +132,18 @@ class KMProductModel: ObservableObject {
 //                
 //            }
             
+            //创建买断订单
 //            creatOrder(productId: "SP2024102300004", paymentMethod: 0, price: NSNumber(value: 119.99), discountFlag: 0, couponCode: "", num: 1) { [weak self] success, result in
 //
 //            }
             
-//            createSubscriber(productId: "SP2024102300003", paymentMethod: 0, price: NSNumber(value: 119.99), discountFlag: 0, couponCode: "", num: 1) { [weak self] success, result in
+            //创建订阅订单(创建买断订单后会报错已经是购买用户,不能重复购买)
+//            createSubscriber(productId: "SP2024103100003", paymentMethod: 0, price: NSNumber(value: 99.99), discountFlag: 0, couponCode: "", num: 1) { [weak self] success, result in
 //
+//            }
+            
+//            getDMGProductOrderIdInfosForMember(orderId: "94b10d5f1ca193948e005503bff0df11") { [weak self] success, result in
+//                
 //            }
             
         }
@@ -283,6 +289,26 @@ class KMProductModel: ObservableObject {
         }
     }
     
+    /**
+     @abstract 支付后查询订单状态
+     @param productId 购买的产品id
+     @param complete 回调
+     */
+    func getDMGProductOrderIdInfosForMember(orderId: String, _ complete: @escaping KMMemberRequestInfoComplete) {
+        checkConnectionAvailable()
+        KMMemberCenterManager.manager.getStateByOrderId(orderId: orderId) { [weak self] success, result in
+            if success {
+                guard let productsInfos : NSDictionary = result else {
+                    complete(false, result)
+                    return
+                }
+                complete(true, productsInfos)
+            } else {
+                complete(false, result)
+            }
+        }
+    }
+    
     
     // MARK: Public Method