|
|
@@ -108,14 +108,17 @@ extension LNOrderManager {
|
|
|
queue: DispatchQueue = .main,
|
|
|
handler: @escaping (Bool) -> Void) {
|
|
|
LNHttpManager.shared.cancelOrder(orderId: orderId) { [weak self] err in
|
|
|
- queue.asyncIfNotGlobal {
|
|
|
- handler(err == nil)
|
|
|
- }
|
|
|
guard let self else { return }
|
|
|
- if err == nil {
|
|
|
- notifyOrderInfoChanged(orderId: orderId)
|
|
|
- } else {
|
|
|
- showToast(err?.errorDescription)
|
|
|
+
|
|
|
+ queue.asyncIfNotGlobal { [weak self] in
|
|
|
+ handler(err == nil)
|
|
|
+
|
|
|
+ guard let self else { return }
|
|
|
+ if err == nil {
|
|
|
+ notifyOrderInfoChanged(orderId: orderId)
|
|
|
+ } else {
|
|
|
+ showToast(err?.errorDescription)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -123,14 +126,16 @@ extension LNOrderManager {
|
|
|
func finishOrder(orderId: String, queue: DispatchQueue = .main,
|
|
|
handler: @escaping (Bool) -> Void) {
|
|
|
LNHttpManager.shared.finishOrder(orderId: orderId) { [weak self] err in
|
|
|
- queue.asyncIfNotGlobal {
|
|
|
- handler(err == nil)
|
|
|
- }
|
|
|
guard let self else { return }
|
|
|
- if err == nil {
|
|
|
- notifyOrderInfoChanged(orderId: orderId)
|
|
|
- } else {
|
|
|
- showToast(err?.errorDescription)
|
|
|
+ queue.asyncIfNotGlobal { [weak self] in
|
|
|
+ handler(err == nil)
|
|
|
+
|
|
|
+ guard let self else { return }
|
|
|
+ if err == nil {
|
|
|
+ notifyOrderInfoChanged(orderId: orderId)
|
|
|
+ } else {
|
|
|
+ showToast(err?.errorDescription)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -140,14 +145,16 @@ extension LNOrderManager {
|
|
|
handler: @escaping (Bool) -> Void) {
|
|
|
LNHttpManager.shared.refundOrder(orderId: orderId, reason: reason, attachments: attachments)
|
|
|
{ [weak self] err in
|
|
|
- queue.asyncIfNotGlobal {
|
|
|
- handler(err == nil)
|
|
|
- }
|
|
|
guard let self else { return }
|
|
|
- if err == nil {
|
|
|
- notifyOrderInfoChanged(orderId: orderId)
|
|
|
- } else {
|
|
|
- showToast(err?.errorDescription)
|
|
|
+ queue.asyncIfNotGlobal { [weak self] in
|
|
|
+ handler(err == nil)
|
|
|
+
|
|
|
+ guard let self else { return }
|
|
|
+ if err == nil {
|
|
|
+ notifyOrderInfoChanged(orderId: orderId)
|
|
|
+ } else {
|
|
|
+ showToast(err?.errorDescription)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -158,14 +165,15 @@ extension LNOrderManager {
|
|
|
LNHttpManager.shared.commentOrder(
|
|
|
orderId: orderId, star: star, comment: comment)
|
|
|
{ [weak self] err in
|
|
|
- queue.asyncIfNotGlobal {
|
|
|
- handler(err == nil)
|
|
|
- }
|
|
|
guard let self else { return }
|
|
|
- if err == nil {
|
|
|
- notifyOrderInfoChanged(orderId: orderId)
|
|
|
- } else {
|
|
|
- showToast(err?.errorDescription)
|
|
|
+ queue.asyncIfNotGlobal { [weak self] in
|
|
|
+ handler(err == nil)
|
|
|
+ guard let self else { return }
|
|
|
+ if err == nil {
|
|
|
+ notifyOrderInfoChanged(orderId: orderId)
|
|
|
+ } else {
|
|
|
+ showToast(err?.errorDescription)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -173,14 +181,16 @@ extension LNOrderManager {
|
|
|
func rejectOrder(orderId: String, queue: DispatchQueue = .main,
|
|
|
handler: @escaping (Bool) -> Void) {
|
|
|
LNHttpManager.shared.rejectOrder(orderId: orderId) { [weak self] err in
|
|
|
- queue.asyncIfNotGlobal {
|
|
|
- handler(err == nil)
|
|
|
- }
|
|
|
guard let self else { return }
|
|
|
- if err == nil {
|
|
|
- notifyOrderInfoChanged(orderId: orderId)
|
|
|
- } else {
|
|
|
- showToast(err?.errorDescription)
|
|
|
+ queue.asyncIfNotGlobal { [weak self] in
|
|
|
+ handler(err == nil)
|
|
|
+
|
|
|
+ guard let self else { return }
|
|
|
+ if err == nil {
|
|
|
+ notifyOrderInfoChanged(orderId: orderId)
|
|
|
+ } else {
|
|
|
+ showToast(err?.errorDescription)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -188,14 +198,15 @@ extension LNOrderManager {
|
|
|
func acceptOrder(orderId: String, queue: DispatchQueue = .main,
|
|
|
handler: @escaping (Bool) -> Void) {
|
|
|
LNHttpManager.shared.acceptOrder(orderId: orderId) { [weak self] err in
|
|
|
- queue.asyncIfNotGlobal {
|
|
|
- handler(err == nil)
|
|
|
- }
|
|
|
guard let self else { return }
|
|
|
- if err == nil {
|
|
|
- notifyOrderInfoChanged(orderId: orderId)
|
|
|
- } else {
|
|
|
- showToast(err?.errorDescription)
|
|
|
+ queue.asyncIfNotGlobal { [weak self] in
|
|
|
+ handler(err == nil)
|
|
|
+ guard let self else { return }
|
|
|
+ if err == nil {
|
|
|
+ notifyOrderInfoChanged(orderId: orderId)
|
|
|
+ } else {
|
|
|
+ showToast(err?.errorDescription)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -203,14 +214,15 @@ extension LNOrderManager {
|
|
|
func startOrderService(orderId: String, queue: DispatchQueue = .main,
|
|
|
handler: @escaping (Bool) -> Void) {
|
|
|
LNHttpManager.shared.startOrderService(orderId: orderId) { [weak self] err in
|
|
|
- queue.asyncIfNotGlobal {
|
|
|
- handler(err == nil)
|
|
|
- }
|
|
|
guard let self else { return }
|
|
|
- if err == nil {
|
|
|
- notifyOrderInfoChanged(orderId: orderId)
|
|
|
- } else {
|
|
|
- showToast(err?.errorDescription)
|
|
|
+ queue.asyncIfNotGlobal { [weak self] in
|
|
|
+ handler(err == nil)
|
|
|
+ guard let self else { return }
|
|
|
+ if err == nil {
|
|
|
+ notifyOrderInfoChanged(orderId: orderId)
|
|
|
+ } else {
|
|
|
+ showToast(err?.errorDescription)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -218,14 +230,15 @@ extension LNOrderManager {
|
|
|
func finishOrderService(orderId: String, queue: DispatchQueue = .main,
|
|
|
handler: @escaping (Bool) -> Void) {
|
|
|
LNHttpManager.shared.finishOrderService(orderId: orderId) { [weak self] err in
|
|
|
- queue.asyncIfNotGlobal {
|
|
|
- handler(err == nil)
|
|
|
- }
|
|
|
guard let self else { return }
|
|
|
- if err == nil {
|
|
|
- notifyOrderInfoChanged(orderId: orderId)
|
|
|
- } else {
|
|
|
- showToast(err?.errorDescription)
|
|
|
+ queue.asyncIfNotGlobal { [weak self] in
|
|
|
+ handler(err == nil)
|
|
|
+ guard let self else { return }
|
|
|
+ if err == nil {
|
|
|
+ notifyOrderInfoChanged(orderId: orderId)
|
|
|
+ } else {
|
|
|
+ showToast(err?.errorDescription)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -236,14 +249,16 @@ extension LNOrderManager {
|
|
|
{
|
|
|
LNHttpManager.shared.protestOrder(orderId: orderId, reason: reason, attachments: attachments)
|
|
|
{ [weak self] err in
|
|
|
- queue.asyncIfNotGlobal {
|
|
|
- handler(err == nil)
|
|
|
- }
|
|
|
guard let self else { return }
|
|
|
- if err == nil {
|
|
|
- notifyOrderInfoChanged(orderId: orderId)
|
|
|
- } else {
|
|
|
- showToast(err?.errorDescription)
|
|
|
+ queue.asyncIfNotGlobal { [weak self] in
|
|
|
+ handler(err == nil)
|
|
|
+
|
|
|
+ guard let self else { return }
|
|
|
+ if err == nil {
|
|
|
+ notifyOrderInfoChanged(orderId: orderId)
|
|
|
+ } else {
|
|
|
+ showToast(err?.errorDescription)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -255,14 +270,41 @@ extension LNOrderManager {
|
|
|
func createOrderQR(skillId: String,
|
|
|
count: Int, type: LNOrderSource,
|
|
|
queue: DispatchQueue = .main,
|
|
|
- completion: @escaping (String?) -> Void) {
|
|
|
+ handler: @escaping (String?) -> Void) {
|
|
|
LNHttpManager.shared.createOrderQR(skillId: skillId, count: count, type: type) { data, err in
|
|
|
queue.asyncIfNotGlobal {
|
|
|
- guard let data, err == nil else {
|
|
|
- completion(nil)
|
|
|
- return
|
|
|
- }
|
|
|
- completion(data.qrCode)
|
|
|
+ handler(data?.qrCode)
|
|
|
+ }
|
|
|
+ if let err {
|
|
|
+ showToast(err.errorDescription)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func getQRDetail(data: String,
|
|
|
+ queue: DispatchQueue = .main,
|
|
|
+ handler: @escaping (LNQRCodeDetailResponse?) -> Void) {
|
|
|
+ LNHttpManager.shared.getQRDetail(data: data) { res, err in
|
|
|
+ queue.asyncIfNotGlobal {
|
|
|
+ handler(res)
|
|
|
+ }
|
|
|
+
|
|
|
+ if let err {
|
|
|
+ showToast(err.errorDescription)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func createQRCodeOrder(data: String, count: Int, extra: String,
|
|
|
+ queue: DispatchQueue = .main,
|
|
|
+ handler: @escaping (String?) -> Void) {
|
|
|
+ LNHttpManager.shared.createQROrder(data: data, count: count, extra: extra) { res, err in
|
|
|
+ queue.asyncIfNotGlobal {
|
|
|
+ handler(res?.orderNo)
|
|
|
+ }
|
|
|
+
|
|
|
+ if let err {
|
|
|
+ showToast(err.errorDescription)
|
|
|
}
|
|
|
}
|
|
|
}
|