|
@@ -966,17 +966,17 @@ class KMMemberCenterManager: NSObject {
|
|
|
var cycle = 0
|
|
|
var code = ""
|
|
|
var cnyPrice = NSNumber(value: 0.0)
|
|
|
- if let token = dict1["id"] { id = token as! String }
|
|
|
- if let token = dict1["productName"] { productName = token as! String }
|
|
|
- if let token = dict1["price"] { price = token as! NSNumber }
|
|
|
- if let token = dict1["maxDeviceNum"] { maxDeviceNum = token as! Int }
|
|
|
- if let token = dict1["levels"] { levels = token as! String }
|
|
|
- if let token = dict1["platforms"] { platforms = token as! String }
|
|
|
- if let token = dict1["productLineId"] { productLineId = token as! Int }
|
|
|
- if let token = dict1["paymentModel"] { paymentModel = token as! Int }
|
|
|
- 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! NSNumber }
|
|
|
+ if let token = dict1["id"] { id = token as? String ?? id }
|
|
|
+ if let token = dict1["productName"] { productName = token as? String ?? productName}
|
|
|
+ if let token = dict1["price"] { price = token as? NSNumber ?? price }
|
|
|
+ if let token = dict1["maxDeviceNum"] { maxDeviceNum = token as? Int ?? maxDeviceNum}
|
|
|
+ if let token = dict1["levels"] { levels = token as? String ?? levels}
|
|
|
+ if let token = dict1["platforms"] { platforms = token as? String ?? platforms}
|
|
|
+ if let token = dict1["productLineId"] { productLineId = token as? Int ?? productLineId}
|
|
|
+ if let token = dict1["paymentModel"] { paymentModel = token as? Int ?? paymentModel}
|
|
|
+ if let token = dict1["cycle"] { cycle = token as? Int ?? cycle}
|
|
|
+ if let token = dict1["code"] { code = token as? String ?? code}
|
|
|
+ if let token = dict1["cnyPrice"] { cnyPrice = token as? NSNumber ?? 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)
|
|
|
}
|
|
@@ -1033,13 +1033,13 @@ class KMMemberCenterManager: NSObject {
|
|
|
var cnyPrice = ""
|
|
|
var cnyBatchPrice = ""
|
|
|
var cnyTotalPrice = ""
|
|
|
- if let token = result["productId"] { productId = token as! String }
|
|
|
- if let token = result["totalPrice"] { totalPrice = token as! String }
|
|
|
- if let token = result["price"] { price = token as! String }
|
|
|
- if let token = result["batchPrice"] { batchPrice = token as! String }
|
|
|
- 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 }
|
|
|
+ if let token = result["productId"] { productId = token as? String ?? productId}
|
|
|
+ if let token = result["totalPrice"] { totalPrice = token as? String ?? totalPrice}
|
|
|
+ if let token = result["price"] { price = token as? String ?? price}
|
|
|
+ if let token = result["batchPrice"] { batchPrice = token as? String ?? batchPrice}
|
|
|
+ if let token = result["cnyPrice"] { cnyPrice = token as? String ?? cnyPrice}
|
|
|
+ if let token = result["cnyBatchPrice"] { cnyBatchPrice = token as? String ?? cnyBatchPrice}
|
|
|
+ if let token = result["cnyTotalPrice"] { cnyTotalPrice = token as? String ?? 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)
|
|
@@ -1103,18 +1103,18 @@ class KMMemberCenterManager: NSObject {
|
|
|
var cycle = 0
|
|
|
var cnyPrice = ""
|
|
|
var displayCnyPrice = ""
|
|
|
- if let token = result["id"] { id = token as! String }
|
|
|
- if let token = result["productName"] { productName = token as! String }
|
|
|
- if let token = result["price"] { price = token as! String }
|
|
|
- if let token = result["maxDeviceNum"] { maxDeviceNum = token as! Int }
|
|
|
- if let token = result["displayPrice"] { displayPrice = token as! String }
|
|
|
- if let token = result["levels"] { levels = token as! String }
|
|
|
- if let token = result["platforms"] { platforms = token as! String }
|
|
|
- if let token = result["productLineId"] { productLineId = token as! Int }
|
|
|
- if let token = result["paymentModel"] { paymentModel = token as! Int }
|
|
|
- if let token = result["cycle"] { cycle = token as! Int }
|
|
|
- if let token = result["cnyPrice"] { cnyPrice = token as! String }
|
|
|
- if let token = result["displayCnyPrice"] { displayCnyPrice = token as! String }
|
|
|
+ if let token = result["id"] { id = token as? String ?? id}
|
|
|
+ if let token = result["productName"] { productName = token as? String ?? productName}
|
|
|
+ if let token = result["price"] { price = token as? String ?? price}
|
|
|
+ if let token = result["maxDeviceNum"] { maxDeviceNum = token as? Int ?? maxDeviceNum}
|
|
|
+ if let token = result["displayPrice"] { displayPrice = token as? String ?? displayPrice}
|
|
|
+ if let token = result["levels"] { levels = token as? String ?? levels}
|
|
|
+ if let token = result["platforms"] { platforms = token as? String ?? platforms}
|
|
|
+ if let token = result["productLineId"] { productLineId = token as? Int ?? productLineId}
|
|
|
+ if let token = result["paymentModel"] { paymentModel = token as? Int ?? paymentModel}
|
|
|
+ if let token = result["cycle"] { cycle = token as? Int ?? cycle}
|
|
|
+ if let token = result["cnyPrice"] { cnyPrice = token as? String ?? cnyPrice}
|
|
|
+ if let token = result["displayCnyPrice"] { displayCnyPrice = token as? String ?? 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)
|
|
@@ -1166,13 +1166,13 @@ class KMMemberCenterManager: NSObject {
|
|
|
var cnyPrice = ""
|
|
|
var cnyBatchPrice = ""
|
|
|
var cnyTotalPrice = ""
|
|
|
- if let token = result["productId"] { productId = token as! String }
|
|
|
- if let token = result["totalPrice"] { totalPrice = token as! String }
|
|
|
- if let token = result["price"] { price = token as! String }
|
|
|
- if let token = result["batchPrice"] { batchPrice = token as! String }
|
|
|
- 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 }
|
|
|
+ if let token = result["productId"] { productId = token as? String ?? productId}
|
|
|
+ if let token = result["totalPrice"] { totalPrice = token as? String ?? totalPrice}
|
|
|
+ if let token = result["price"] { price = token as? String ?? price}
|
|
|
+ if let token = result["batchPrice"] { batchPrice = token as? String ?? batchPrice}
|
|
|
+ if let token = result["cnyPrice"] { cnyPrice = token as? String ?? cnyPrice}
|
|
|
+ if let token = result["cnyBatchPrice"] { cnyBatchPrice = token as? String ?? cnyBatchPrice}
|
|
|
+ if let token = result["cnyTotalPrice"] { cnyTotalPrice = token as? String ?? 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)
|
|
@@ -1280,9 +1280,9 @@ class KMMemberCenterManager: NSObject {
|
|
|
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 }
|
|
|
+ if let token = result["thirdOrderNo"] { thirdOrderNo = token as? String ?? thirdOrderNo}
|
|
|
+ if let token = result["orderId"] { orderId = token as? String ?? orderId}
|
|
|
+ if let token = result["payHref"] { payHref = token as? String ?? payHref}
|
|
|
let products = KMCreateOrderModel(thirdOrderNo: thirdOrderNo, orderId: orderId, payHref: payHref)
|
|
|
let result1 = KMMemberProductResult(code: code, msg: message, createOrder: products)
|
|
|
complete(true, result1)
|
|
@@ -1339,9 +1339,9 @@ class KMMemberCenterManager: NSObject {
|
|
|
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 }
|
|
|
+ if let token = result["thirdOrderNo"] { thirdOrderNo = token as? String ?? thirdOrderNo}
|
|
|
+ if let token = result["orderId"] { orderId = token as? String ?? orderId}
|
|
|
+ if let token = result["payHref"] { payHref = token as? String ?? payHref}
|
|
|
let products = KMCreateOrderModel(thirdOrderNo: thirdOrderNo, orderId: orderId, payHref: payHref)
|
|
|
let result1 = KMMemberProductResult(code: code, msg: message, createOrder: products)
|
|
|
complete(true, result1)
|
|
@@ -1357,7 +1357,7 @@ class KMMemberCenterManager: NSObject {
|
|
|
@param orderStatus 0全部1待支付
|
|
|
@param complete 回调
|
|
|
*/
|
|
|
- func getOrderListByStatus(orderStatus: Int, _ complete: @escaping KMMemberProductComplete) {
|
|
|
+ func getOrderListByStatus(orderStatus: Int, _ complete: @escaping KMMemberRequestInfoComplete) {
|
|
|
let token: String = KMMemberInfo.shared.access_token
|
|
|
if token == "" {
|
|
|
complete(false, nil)
|
|
@@ -1365,39 +1365,45 @@ class KMMemberCenterManager: NSObject {
|
|
|
}
|
|
|
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
|
|
|
+ if let urlNewString = constructURLString(baseURLString: urlString, parameters: params) {
|
|
|
+ KMRequestServer.requestServer.request(urlString: urlNewString, 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) ?? [:]
|
|
|
}
|
|
|
- dic = (info as? NSDictionary) ?? [:]
|
|
|
+ let code: Int = dic["code"] as? Int ?? 0
|
|
|
+ if code == 200 {
|
|
|
+ complete(true, dic)
|
|
|
+ } else {
|
|
|
+ complete(false, dic)
|
|
|
+ }
|
|
|
+ // 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)
|
|
|
+ // }
|
|
|
}
|
|
|
- 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)
|
|
|
-// }
|
|
|
+ } else {
|
|
|
+ complete(false, nil)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1413,28 +1419,33 @@ class KMMemberCenterManager: NSObject {
|
|
|
return
|
|
|
}
|
|
|
let urlString = configuration.activityBaseURL() + "/pdf-office-website/order/closeOrder"
|
|
|
- KMRequestServer.requestServer.request(urlString: urlString, method: .post, 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
|
|
|
+ let params: [String: Any] = ["orderId": orderId]
|
|
|
+ if let urlNewString = constructURLString(baseURLString: urlString, parameters: params) {
|
|
|
+ KMRequestServer.requestServer.request(urlString: urlNewString, method: .post, 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) ?? [:]
|
|
|
}
|
|
|
- dic = (info as? NSDictionary) ?? [:]
|
|
|
- }
|
|
|
- let code: Int = dic["code"] as? Int ?? 0
|
|
|
+ let code: Int = dic["code"] as? Int ?? 0
|
|
|
|
|
|
- if code == 200 {
|
|
|
- complete(true, dic)
|
|
|
- } else {
|
|
|
- complete(false, dic)
|
|
|
+ if code == 200 {
|
|
|
+ complete(true, dic)
|
|
|
+ } else {
|
|
|
+ complete(false, dic)
|
|
|
+ }
|
|
|
}
|
|
|
+ } else {
|
|
|
+ complete(false, nil)
|
|
|
}
|
|
|
}
|
|
|
|