|
@@ -740,7 +740,7 @@ class KMMemberCenterManager: NSObject {
|
|
|
#endif
|
|
|
let params: [String: Any] = ["isEducation": isEducation,
|
|
|
"platformId": platformId]
|
|
|
- KMRequestServer.requestServer.request(urlString: urlString, method: .get, params: nil) { requestSerializer in
|
|
|
+ KMRequestServer.requestServer.request(urlString: urlString, method: .get, params: params) { requestSerializer in
|
|
|
|
|
|
} completion: { [weak self] (task, responseObject, error) in
|
|
|
var dic: NSDictionary = [:]
|
|
@@ -759,7 +759,7 @@ class KMMemberCenterManager: NSObject {
|
|
|
let result_Array: [NSDictionary] = dic["result"] as? [NSDictionary] ?? [[:]]
|
|
|
let message: String = dic["msg"] as? String ?? ""
|
|
|
|
|
|
- var results: [KMListingProducts] = []
|
|
|
+ var results: [KMListingProductsModel] = []
|
|
|
for dict1 in result_Array {
|
|
|
var id = ""
|
|
|
var productName = ""
|
|
@@ -783,7 +783,7 @@ class KMMemberCenterManager: NSObject {
|
|
|
if let token = dict1["cycle"] { cycle = token as! Int }
|
|
|
if let token = dict1["code"] { code = token as! String }
|
|
|
if let token = dict1["cnyPrice"] { cnyPrice = token as! String }
|
|
|
- let products = KMListingProducts(id: id, productName: productName, price: price, maxDeviceNum: maxDeviceNum, levels: levels, platforms: platforms, productLineId: productLineId, paymentModel: paymentModel, cycle: cycle, code: code, cnyPrice: cnyPrice)
|
|
|
+ let products = KMListingProductsModel(id: id, productName: productName, price: price, maxDeviceNum: maxDeviceNum, levels: levels, platforms: platforms, productLineId: productLineId, paymentModel: paymentModel, cycle: cycle, code: code, cnyPrice: cnyPrice)
|
|
|
results.append(products)
|
|
|
}
|
|
|
|
|
@@ -808,7 +808,7 @@ class KMMemberCenterManager: NSObject {
|
|
|
let params: [String: Any] = ["productId": productId,
|
|
|
"isEducation": isEducation,
|
|
|
"userId": userId]
|
|
|
- KMRequestServer.requestServer.request(urlString: urlString, method: .get, params: nil) { requestSerializer in
|
|
|
+ KMRequestServer.requestServer.request(urlString: urlString, method: .get, params: params) { requestSerializer in
|
|
|
|
|
|
} completion: { [weak self] (task, responseObject, error) in
|
|
|
var dic: NSDictionary = [:]
|
|
@@ -827,7 +827,7 @@ class KMMemberCenterManager: NSObject {
|
|
|
let result_Array: [NSDictionary] = dic["result"] as? [NSDictionary] ?? [[:]]
|
|
|
let message: String = dic["msg"] as? String ?? ""
|
|
|
|
|
|
- var results: [KMListingProducts] = []
|
|
|
+ var results: [KMListingProductsModel] = []
|
|
|
for dict1 in result_Array {
|
|
|
var id = ""
|
|
|
var productName = ""
|
|
@@ -851,7 +851,7 @@ class KMMemberCenterManager: NSObject {
|
|
|
if let token = dict1["cycle"] { cycle = token as! Int }
|
|
|
if let token = dict1["code"] { code = token as! String }
|
|
|
if let token = dict1["cnyPrice"] { cnyPrice = token as! String }
|
|
|
- let products = KMListingProducts(id: id, productName: productName, price: price, maxDeviceNum: maxDeviceNum, levels: levels, platforms: platforms, productLineId: productLineId, paymentModel: paymentModel, cycle: cycle, code: code, cnyPrice: cnyPrice)
|
|
|
+ let products = KMListingProductsModel(id: id, productName: productName, price: price, maxDeviceNum: maxDeviceNum, levels: levels, platforms: platforms, productLineId: productLineId, paymentModel: paymentModel, cycle: cycle, code: code, cnyPrice: cnyPrice)
|
|
|
results.append(products)
|
|
|
}
|
|
|
|
|
@@ -875,7 +875,7 @@ class KMMemberCenterManager: NSObject {
|
|
|
let urlString = configuration.activityBaseURL() + "/pdf-office-website/web/getBatchProductPrice"
|
|
|
let params: [String: Any] = ["productId": productId,
|
|
|
"num": num]
|
|
|
- KMRequestServer.requestServer.request(urlString: urlString, method: .get, params: nil) { requestSerializer in
|
|
|
+ KMRequestServer.requestServer.request(urlString: urlString, method: .get, params: params) { requestSerializer in
|
|
|
|
|
|
} completion: { [weak self] (task, responseObject, error) in
|
|
|
var dic: NSDictionary = [:]
|
|
@@ -908,7 +908,7 @@ class KMMemberCenterManager: NSObject {
|
|
|
if let token = result["cnyPrice"] { cnyPrice = token as! String }
|
|
|
if let token = result["cnyBatchPrice"] { cnyBatchPrice = token as! String }
|
|
|
if let token = result["cnyTotalPrice"] { cnyTotalPrice = token as! String }
|
|
|
- let products = KMBatchProductPrice(productId: productId, totalPrice: totalPrice, price: price, batchPrice: batchPrice, cnyPrice: cnyPrice, cnyBatchPrice: cnyBatchPrice, cnyTotalPrice: cnyTotalPrice)
|
|
|
+ let products = KMBatchProductPriceModel(productId: productId, totalPrice: totalPrice, price: price, batchPrice: batchPrice, cnyPrice: cnyPrice, cnyBatchPrice: cnyBatchPrice, cnyTotalPrice: cnyTotalPrice)
|
|
|
|
|
|
let result1 = KMMemberProductResult(code: code, msg: message, batchProductPrice: products)
|
|
|
if code == 200 {
|
|
@@ -934,7 +934,7 @@ class KMMemberCenterManager: NSObject {
|
|
|
let params: [String: Any] = ["productId": productId,
|
|
|
"userId": userId,
|
|
|
"code": code]
|
|
|
- KMRequestServer.requestServer.request(urlString: urlString, method: .get, params: nil) { requestSerializer in
|
|
|
+ KMRequestServer.requestServer.request(urlString: urlString, method: .get, params: params) { requestSerializer in
|
|
|
requestSerializer.setValue("Bearer " + token, forHTTPHeaderField: "Authorization")
|
|
|
} completion: { [weak self] (task, responseObject, error) in
|
|
|
var dic: NSDictionary = [:]
|
|
@@ -978,7 +978,7 @@ class KMMemberCenterManager: NSObject {
|
|
|
if let token = result["cnyPrice"] { cnyPrice = token as! String }
|
|
|
if let token = result["displayCnyPrice"] { displayCnyPrice = token as! String }
|
|
|
|
|
|
- let products = KMCheckCoupon(id: id, productName: productName, price: price, maxDeviceNum: maxDeviceNum, displayPrice: displayPrice, levels: levels, platforms: platforms, productLineId: productLineId, paymentModel: paymentModel, cycle: cycle, cnyPrice: cnyPrice, displayCnyPrice: displayCnyPrice)
|
|
|
+ let products = KMCheckCouponModel(id: id, productName: productName, price: price, maxDeviceNum: maxDeviceNum, displayPrice: displayPrice, levels: levels, platforms: platforms, productLineId: productLineId, paymentModel: paymentModel, cycle: cycle, cnyPrice: cnyPrice, displayCnyPrice: displayCnyPrice)
|
|
|
let result1 = KMMemberProductResult(code: code, msg: message, checkCoupon: products)
|
|
|
if code == 200 {
|
|
|
complete(true, result1)
|
|
@@ -998,7 +998,7 @@ class KMMemberCenterManager: NSObject {
|
|
|
|
|
|
let urlString = configuration.activityBaseURL() + "/pdf-office-website/web/checkEducation"
|
|
|
let params: [String: Any] = ["email": email]
|
|
|
- KMRequestServer.requestServer.request(urlString: urlString, method: .get, params: nil) { requestSerializer in
|
|
|
+ KMRequestServer.requestServer.request(urlString: urlString, method: .get, params: params) { requestSerializer in
|
|
|
|
|
|
} completion: { [weak self] (task, responseObject, error) in
|
|
|
var dic: NSDictionary = [:]
|
|
@@ -1031,7 +1031,7 @@ class KMMemberCenterManager: NSObject {
|
|
|
if let token = result["cnyPrice"] { cnyPrice = token as! String }
|
|
|
if let token = result["cnyBatchPrice"] { cnyBatchPrice = token as! String }
|
|
|
if let token = result["cnyTotalPrice"] { cnyTotalPrice = token as! String }
|
|
|
- let products = KMBatchProductPrice(productId: productId, totalPrice: totalPrice, price: price, batchPrice: batchPrice, cnyPrice: cnyPrice, cnyBatchPrice: cnyBatchPrice, cnyTotalPrice: cnyTotalPrice)
|
|
|
+ let products = KMBatchProductPriceModel(productId: productId, totalPrice: totalPrice, price: price, batchPrice: batchPrice, cnyPrice: cnyPrice, cnyBatchPrice: cnyBatchPrice, cnyTotalPrice: cnyTotalPrice)
|
|
|
|
|
|
let result1 = KMMemberProductResult(code: code, msg: message, batchProductPrice: products)
|
|
|
if code == 200 {
|
|
@@ -1046,6 +1046,154 @@ class KMMemberCenterManager: NSObject {
|
|
|
|
|
|
// MARK: 订单模块
|
|
|
|
|
|
+ /**
|
|
|
+ @abstract 支付后查询订单状态
|
|
|
+ @param orderId 订单id
|
|
|
+ @param complete 回调
|
|
|
+ */
|
|
|
+ func getStateByOrderId(orderId: String, _ complete: @escaping KMMemberProductComplete) {
|
|
|
+ let token: String = KMMemberInfo.shared.access_token
|
|
|
+ if token == "" {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let urlString = configuration.activityBaseURL() + "/pdf-office-website/order/getStateByOrderId"
|
|
|
+ KMRequestServer.requestServer.request(urlString: urlString, method: .get, params: nil) { requestSerializer in
|
|
|
+ requestSerializer.setValue("Bearer " + token, forHTTPHeaderField: "Authorization")
|
|
|
+ } completion: { [weak self] (task, responseObject, error) in
|
|
|
+ var dic: NSDictionary = [:]
|
|
|
+ if error == nil, let responseObject = responseObject as? NSDictionary {
|
|
|
+ dic = responseObject
|
|
|
+ } else {
|
|
|
+ var info = responseObject
|
|
|
+ if let error = error {
|
|
|
+ if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
|
|
|
+ info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dic = (info as? NSDictionary) ?? [:]
|
|
|
+ }
|
|
|
+ let code: Int = dic["code"] as? Int ?? 0
|
|
|
+ let result: NSDictionary = dic["result"] as? NSDictionary ?? [:]
|
|
|
+ let message: String = dic["msg"] as? String ?? ""
|
|
|
+
|
|
|
+ var status = ""
|
|
|
+ if let token = result["status"] { status = token as! String }
|
|
|
+
|
|
|
+ let result1 = KMMemberProductResult(code: code, msg: message, result: status)
|
|
|
+ if code == 200 {
|
|
|
+ complete(true, result1)
|
|
|
+ } else {
|
|
|
+ complete(false, result1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ @abstract 创建订单(买断、订阅)
|
|
|
+ @param productId 产品id
|
|
|
+ @param paymentMethod 支付方式 PAYPAL(0),ALIPAY(1),WXPAY(2),PADDLE(3)
|
|
|
+ @param price 价格
|
|
|
+ @param discountFlag 0原价,1优惠券,2升级,3教育优惠,4批量购买,5黑五折扣
|
|
|
+ @param couponCode 优惠卷
|
|
|
+ @param num 批量购买数量
|
|
|
+ @param complete 回调
|
|
|
+ */
|
|
|
+ func createOrder(productId: String, paymentMethod: Int, price: String, discountFlag: Int, couponCode: String, num: Int, _ complete: @escaping KMMemberProductComplete) {
|
|
|
+ let token: String = KMMemberInfo.shared.access_token
|
|
|
+ if token == "" {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let urlString = configuration.activityBaseURL() + "/pdf-office-website/order/createOrder"
|
|
|
+ let params: [String: Any] = ["productId": productId,
|
|
|
+ "paymentMethod": paymentMethod,
|
|
|
+ "price": price,
|
|
|
+ "discountFlag": discountFlag,
|
|
|
+ "couponCode": couponCode,
|
|
|
+ "num": num]
|
|
|
+ KMRequestServer.requestServer.request(urlString: urlString, method: .post, params: params) { requestSerializer in
|
|
|
+ requestSerializer.setValue("Bearer " + token, forHTTPHeaderField: "Authorization")
|
|
|
+ } completion: { [weak self] (task, responseObject, error) in
|
|
|
+ var dic: NSDictionary = [:]
|
|
|
+ if error == nil, let responseObject = responseObject as? NSDictionary {
|
|
|
+ dic = responseObject
|
|
|
+ } else {
|
|
|
+ var info = responseObject
|
|
|
+ if let error = error {
|
|
|
+ if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
|
|
|
+ info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dic = (info as? NSDictionary) ?? [:]
|
|
|
+ }
|
|
|
+ let code: Int = dic["code"] as? Int ?? 0
|
|
|
+ let result: NSDictionary = dic["result"] as? NSDictionary ?? [:]
|
|
|
+ let message: String = dic["msg"] as? String ?? ""
|
|
|
+
|
|
|
+ var thirdOrderNo = ""
|
|
|
+ var orderId = ""
|
|
|
+ var payHref = ""
|
|
|
+ if code == 200 {
|
|
|
+ if let token = result["thirdOrderNo"] { thirdOrderNo = token as! String }
|
|
|
+ if let token = result["orderId"] { orderId = token as! String }
|
|
|
+ if let token = result["payHref"] { payHref = token as! String }
|
|
|
+ let products = KMCreateOrderModel(thirdOrderNo: thirdOrderNo, orderId: orderId, payHref: payHref)
|
|
|
+ let result1 = KMMemberProductResult(code: code, msg: message, createOrder: products)
|
|
|
+ complete(true, result1)
|
|
|
+ } else {
|
|
|
+ let result1 = KMMemberProductResult(code: code, msg: message, createOrder: KMCreateOrderModel(thirdOrderNo: thirdOrderNo, orderId: orderId, payHref: payHref))
|
|
|
+ complete(false, result1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ @abstract 获取订单列表
|
|
|
+ @param orderStatus 0全部1待支付
|
|
|
+ @param complete 回调
|
|
|
+ */
|
|
|
+ func getOrderListByStatus(orderStatus: Int, _ complete: @escaping KMMemberProductComplete) {
|
|
|
+ let token: String = KMMemberInfo.shared.access_token
|
|
|
+ if token == "" {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let urlString = configuration.activityBaseURL() + "/pdf-office-website/order/getOrderListByStatus"
|
|
|
+ let params: [String: Any] = ["orderStatus": orderStatus]
|
|
|
+ KMRequestServer.requestServer.request(urlString: urlString, method: .get, params: params) { requestSerializer in
|
|
|
+ requestSerializer.setValue("Bearer " + token, forHTTPHeaderField: "Authorization")
|
|
|
+ } completion: { [weak self] (task, responseObject, error) in
|
|
|
+ var dic: NSDictionary = [:]
|
|
|
+ if error == nil, let responseObject = responseObject as? NSDictionary {
|
|
|
+ dic = responseObject
|
|
|
+ } else {
|
|
|
+ var info = responseObject
|
|
|
+ if let error = error {
|
|
|
+ if let data = error.userInfo["com.alamofire.serialization.response.error.data"] as? Data {
|
|
|
+ info = try? JSONSerialization.jsonObject(with: data, options: .mutableLeaves) as? NSDictionary
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dic = (info as? NSDictionary) ?? [:]
|
|
|
+ }
|
|
|
+ let code: Int = dic["code"] as? Int ?? 0
|
|
|
+ let result: NSDictionary = dic["result"] as? NSDictionary ?? [:]
|
|
|
+ let message: String = dic["msg"] as? String ?? ""
|
|
|
+
|
|
|
+// var thirdOrderNo = ""
|
|
|
+// var orderId = ""
|
|
|
+// var payHref = ""
|
|
|
+// if code == 200 {
|
|
|
+// if let token = result["thirdOrderNo"] { thirdOrderNo = token as! String }
|
|
|
+// if let token = result["orderId"] { orderId = token as! String }
|
|
|
+// if let token = result["payHref"] { payHref = token as! String }
|
|
|
+// let products = KMCreateOrderModel(thirdOrderNo: thirdOrderNo, orderId: orderId, payHref: payHref)
|
|
|
+// let result1 = KMMemberProductResult(code: code, msg: message, createOrder: products)
|
|
|
+// complete(true, result1)
|
|
|
+// } else {
|
|
|
+// let result1 = KMMemberProductResult(code: code, msg: message, createOrder: KMCreateOrderModel(thirdOrderNo: thirdOrderNo, orderId: orderId, payHref: payHref))
|
|
|
+// complete(false, result1)
|
|
|
+// }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
// MARK: 评估模块
|
|
|
|