CNLiveShopViewModel.swift
29.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
//
// CNLiveShopViewModel.swift
// metaCode
//
// Created by open on 2023/10/31.
//
import Foundation
import CNLiveRequestBastKit
typealias resultShopBlock = (_ result: Any,_ respStatue :CNLiveMineResponseType) -> Void
class CNLiveShopViewModel: NSObject {
/// 请求获取订单列表数据
/// - Parameters:
/// - state: 0全部 1待发货 2配送中 3代付款 4订单退款
/// - resultShopBlock: 返回
static func requestOrderList(state: String, keyword: String, page: NSInteger, resultBlock: @escaping resultShopBlock) {
if state == "6" {
let param = NSMutableDictionary()
param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "uid")
param.setValue("\(page)", forKey: "page")
let custom_param = NSMutableDictionary()
custom_param.setValue(APPId_wjj, forKey: "appId")
custom_param.setValue(APPKey_wjj, forKey: "appKey")
CNLiveNetworking.setAllowRequestDefaultArgument(true)
CNLiveNetworking.setupShowDataResult(false)
CNLiveNetworking.setupDSRequest(true)
CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
CNLiveNetworking.requestNetwork(with: .GET, urlString: APPBaseWjjBUrl+"/api/v1/refundList", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in
hiddenLoading()
if (error == nil) {
let resp = result as! NSDictionary
let errorCode = "\(resp["code"] ?? "0")"
if (errorCode == "200") {
if resp["data"] is NSNull {
resultBlock(Array<Any>(),.success)
} else {
let array = resp["data"] as! NSArray
let tempArray = NSMutableArray()
for item in array {
let listModel = dictionaryToModel(item as! [String : Any], ShopOrderListModel.self,"") as! ShopOrderListModel
listModel.isRefund = "1"
tempArray.add(listModel)
}
resultBlock(tempArray, .success)
}
} else {
showMessage(message: resp["message"] as! String)
resultBlock(NSNull(),.failed)
}
} else {
if CNLiveNetworking.isNetworking() {
showMessage(message: "获取失败")
resultBlock(NSNull(),.failed)
} else {
showMessage(message: "似乎与网络断开链接")
resultBlock(NSNull(),.noNetwork)
}
}
}
} else {
let param = NSMutableDictionary()
param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "uid")
param.setValue("\(page)", forKey: "page")
param.setValue("", forKey: "delivery")
param.setValue(state, forKey: "state")
param.setValue(keyword, forKey: "keyword")
let custom_param = NSMutableDictionary()
custom_param.setValue(APPId_wjj, forKey: "appId")
custom_param.setValue(APPKey_wjj, forKey: "appKey")
CNLiveNetworking.setAllowRequestDefaultArgument(true)
CNLiveNetworking.setupShowDataResult(false)
CNLiveNetworking.setupDSRequest(true)
CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
CNLiveNetworking.requestNetwork(with: .GET, urlString: APPBaseWjjBUrl+"/api/v1/orders", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in
hiddenLoading()
if (error == nil) {
let resp = result as! NSDictionary
let errorCode = "\(resp["code"] ?? "0")"
if (errorCode == "200") {
if resp["data"] is NSNull {
resultBlock(Array<Any>(),.success)
} else {
let array = resp["data"] as! NSArray
let tempArray = NSMutableArray()
for item in array {
let listModel = dictionaryToModel(item as! [String : Any], ShopOrderListModel.self,"") as! ShopOrderListModel
tempArray.add(listModel)
}
resultBlock(tempArray, .success)
}
} else {
showMessage(message: resp["message"] as! String)
resultBlock(NSNull(),.failed)
}
} else {
if CNLiveNetworking.isNetworking() {
showMessage(message: "获取失败")
resultBlock(NSNull(),.failed)
} else {
showMessage(message: "似乎与网络断开链接")
resultBlock(NSNull(),.noNetwork)
}
}
}
}
}
/// 通知自提
/// - Parameters:
/// - orderId: 订单id
/// - resultBlock: 返回
static func requestNotifyOrder(orderId: String, resultBlock: @escaping resultShopBlock) {
let param = NSMutableDictionary()
param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "uid")
param.setValue(orderId, forKey: "id")
let custom_param = NSMutableDictionary()
custom_param.setValue(APPId_wjj, forKey: "appId")
custom_param.setValue(APPKey_wjj, forKey: "appKey")
CNLiveNetworking.setAllowRequestDefaultArgument(true)
CNLiveNetworking.setupShowDataResult(false)
CNLiveNetworking.setupDSRequest(true)
CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
CNLiveNetworking.requestNetwork(with: .GET, urlString: APPBaseWjjBUrl+"/api/v1/notifyOrder", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in
hiddenLoading()
if (error == nil) {
let resp = result as! NSDictionary
let errorCode = "\(resp["code"] ?? "0")"
if (errorCode == "200") {
resultBlock("",.success)
} else {
showMessage(message: resp["message"] as! String)
resultBlock(NSNull(),.failed)
}
} else {
if CNLiveNetworking.isNetworking() {
showMessage(message: "获取失败")
resultBlock(NSNull(),.failed)
} else {
showMessage(message: "似乎与网络断开链接")
resultBlock(NSNull(),.noNetwork)
}
}
}
}
/// 获取订单详情数据
/// - Parameters:
/// - orderId: 订单id
/// - resultBlock: 返回
static func requestOrderDetail(orderId: String, isOrderDetai: Bool, isRefund: Bool,resultBlock: @escaping resultShopBlock) {
if isOrderDetai {
let param = NSMutableDictionary()
param.setValue(orderId, forKey: "id")
let custom_param = NSMutableDictionary()
custom_param.setValue(APPId_wjj, forKey: "appId")
custom_param.setValue(APPKey_wjj, forKey: "appKey")
CNLiveNetworking.setAllowRequestDefaultArgument(true)
CNLiveNetworking.setupShowDataResult(false)
CNLiveNetworking.setupDSRequest(true)
CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
CNLiveNetworking.requestNetwork(with: .GET, urlString: APPBaseWjjBUrl+"/api/v1/order", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in
hiddenLoading()
if (error == nil) {
let resp = result as! NSDictionary
let errorCode = "\(resp["code"] ?? "0")"
if (errorCode == "200") {
if resp["data"] is NSNull {
resultBlock(NSNull(),.failed)
} else {
let model = dictionaryToModel(resp as! [String : Any], ShopOrderDetailModel.self,"data") as! ShopOrderDetailModel
var is_send_all: Bool = true
for goodsModel in model.order_detail {
if goodsModel.send_num! > 0 {
is_send_all = false
}
}
model.is_send_all = is_send_all
resultBlock(model,.success)
}
} else {
showMessage(message: resp["message"] as! String)
resultBlock(NSNull(),.failed)
}
} else {
if CNLiveNetworking.isNetworking() {
showMessage(message: "获取失败")
resultBlock(NSNull(),.failed)
} else {
showMessage(message: "似乎与网络断开链接")
resultBlock(NSNull(),.noNetwork)
}
}
}
} else {
var url: String = ""
if isRefund {
url = "/api/v1/refundById"
} else {
url = "/api/v1/refund"
}
let param = NSMutableDictionary()
param.setValue(orderId, forKey: "id")
let custom_param = NSMutableDictionary()
custom_param.setValue(APPId_wjj, forKey: "appId")
custom_param.setValue(APPKey_wjj, forKey: "appKey")
CNLiveNetworking.setAllowRequestDefaultArgument(true)
CNLiveNetworking.setupShowDataResult(false)
CNLiveNetworking.setupDSRequest(true)
CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
CNLiveNetworking.requestNetwork(with: .GET, urlString: APPBaseWjjBUrl+url, param: param as! [String : String], cacheType: .networkOnly) { task, result, error in
hiddenLoading()
if (error == nil) {
let resp = result as! NSDictionary
let errorCode = "\(resp["code"] ?? "0")"
if (errorCode == "200") {
if resp["data"] is NSNull {
resultBlock(NSNull(),.failed)
} else {
let model = dictionaryToModel(resp as! [String : Any], ShopOrderRefundModel.self,"data") as! ShopOrderRefundModel
resultBlock(model,.success)
}
} else {
showMessage(message: resp["message"] as! String)
resultBlock(NSNull(),.failed)
}
} else {
if CNLiveNetworking.isNetworking() {
showMessage(message: "获取失败")
resultBlock(NSNull(),.failed)
} else {
showMessage(message: "似乎与网络断开链接")
resultBlock(NSNull(),.noNetwork)
}
}
}
}
}
/// 同意退款和拒绝退款
/// - Parameters:
/// - refundId: 退款id
/// - desc: 拒绝退款描述
/// - isAgree: 是否同意退款
/// - resultBlock: 返回
static func requestRefund(refundId: NSString, desc: NSString,isAgree: Bool,resultBlock: @escaping resultShopBlock) {
var url: String = ""
let param = NSMutableDictionary()
param.setValue(refundId, forKey: "id")
if isAgree {
url = "/api/v1/confirmRefund"
} else {
url = "/api/v1/refuse"
param.setValue(desc, forKey: "desc")
}
let custom_param = NSMutableDictionary()
custom_param.setValue(APPId_wjj, forKey: "appId")
custom_param.setValue(APPKey_wjj, forKey: "appKey")
CNLiveNetworking.setAllowRequestDefaultArgument(true)
CNLiveNetworking.setupShowDataResult(false)
CNLiveNetworking.setupDSRequest(true)
CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
CNLiveNetworking.requestNetwork(with: .GET, urlString: APPBaseWjjBUrl+url, param: param as! [String : String], cacheType: .networkOnly) { task, result, error in
hiddenLoading()
if (error == nil) {
let resp = result as! NSDictionary
let errorCode = "\(resp["code"] ?? "0")"
if (errorCode == "200") {
if resp["data"] is NSNull {
resultBlock(NSNull(),.failed)
} else {
resultBlock(isAgree ? "退款成功" : "拒绝退款成功",.success)
}
} else {
showMessage(message: resp["message"] as! String)
resultBlock(NSNull(),.failed)
}
} else {
if CNLiveNetworking.isNetworking() {
showMessage(message: "请求失败")
resultBlock(NSNull(),.failed)
} else {
showMessage(message: "似乎与网络断开链接")
resultBlock(NSNull(),.noNetwork)
}
}
}
}
/// 获取商家店铺列表
/// - Parameter resultBlock: 返回
static func requestSellerStore(resultBlock: @escaping resultShopBlock) {
let param = NSMutableDictionary()
param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "id")
let custom_param = NSMutableDictionary()
custom_param.setValue(APPId_wjj, forKey: "appId")
custom_param.setValue(APPKey_wjj, forKey: "appKey")
CNLiveNetworking.setAllowRequestDefaultArgument(true)
CNLiveNetworking.setupShowDataResult(false)
CNLiveNetworking.setupDSRequest(true)
CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
CNLiveNetworking.requestNetwork(with: .GET, urlString: APPBaseWjjBUrl+"/api/v1/sellerStore", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in
hiddenLoading()
if (error == nil) {
let resp = result as! NSDictionary
let errorCode = "\(resp["code"] ?? "0")"
if (errorCode == "200") {
if resp["data"] is NSNull {
resultBlock(NSNull(),.failed)
} else {
let resp_dict = resp["data"] as! NSDictionary
let array = resp_dict["data"] as! NSArray
let tempArray = NSMutableArray()
let textArray = NSMutableArray()
for item in array {
let listModel = dictionaryToModel(item as! [String : Any], ShopOrderStoreModel.self,"") as! ShopOrderStoreModel
tempArray.add(listModel)
textArray.add(listModel.title! as String)
}
resultBlock([tempArray,textArray], .success)
}
} else {
showMessage(message: resp["message"] as! String)
resultBlock(NSNull(),.failed)
}
} else {
if CNLiveNetworking.isNetworking() {
showMessage(message: "请求失败")
resultBlock(NSNull(),.failed)
} else {
showMessage(message: "似乎与网络断开链接")
resultBlock(NSNull(),.noNetwork)
}
}
}
}
/// 发快递 && 编辑快递
/// - Parameters:
/// - orderId: 订单号
/// - expressId: 快递id
/// - expressNum: 快递数量
/// - hiddenSop: true为修改快递 false为发快递
/// - expId: 扩展id (hiddenSop为true时必传)
/// - goodsList: 商品列表 (hiddenSop为false时必传)
/// - storeId: 店铺id (hiddenSop为false时必传)
/// - resultBlock: 返回
static func requestExpress(orderId: String, expressId: String, expressNum: String, hiddenSop: Bool, expId: String, goodsList: NSArray, storeId: String, resultBlock: @escaping resultShopBlock) {
if hiddenSop {
let param = NSMutableDictionary()
param.setValue(orderId, forKey: "id")
param.setValue(expId, forKey: "exp_id")
param.setValue(expressId, forKey: "express_id")
param.setValue(expressNum, forKey: "express_num")
let custom_param = NSMutableDictionary()
custom_param.setValue(APPId_wjj, forKey: "appId")
custom_param.setValue(APPKey_wjj, forKey: "appKey")
CNLiveNetworking.setAllowRequestDefaultArgument(true)
CNLiveNetworking.setupShowDataResult(false)
CNLiveNetworking.setupDSRequest(true)
CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseWjjBUrl+"/api/v1/editExpress", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in
hiddenLoading()
if (error == nil) {
let resp = result as! NSDictionary
let errorCode = "\(resp["code"] ?? "0")"
if (errorCode == "200") {
resultBlock("修改成功", .success)
} else {
showMessage(message: resp["message"] as! String)
resultBlock(NSNull(),.failed)
}
} else {
if CNLiveNetworking.isNetworking() {
showMessage(message: "修改快递信息失败")
resultBlock(NSNull(),.failed)
} else {
showMessage(message: "似乎与网络断开链接")
resultBlock(NSNull(),.noNetwork)
}
}
}
} else {
let param = NSMutableDictionary()
param.setValue(orderId, forKey: "id")
param.setValue(storeId, forKey: "store_id")
param.setValue(expressId, forKey: "express_id")
param.setValue(expressNum, forKey: "express_num")
param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "id")
if goodsList.count > 0 {
do {
let jsonData = try JSONSerialization.data(withJSONObject: goodsList, options: .prettyPrinted)
let jsonString = NSString.init(data: jsonData, encoding: NSUTF8StringEncoding)
param.setValue(jsonString, forKey: "goods_arr")
} catch _ {}
}
let custom_param = NSMutableDictionary()
custom_param.setValue(APPId_wjj, forKey: "appId")
custom_param.setValue(APPKey_wjj, forKey: "appKey")
CNLiveNetworking.setAllowRequestDefaultArgument(true)
CNLiveNetworking.setupShowDataResult(false)
CNLiveNetworking.setupDSRequest(true)
CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseWjjBUrl+"/api/v1/express", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in
hiddenLoading()
if (error == nil) {
let resp = result as! NSDictionary
let errorCode = "\(resp["code"] ?? "0")"
if (errorCode == "200") {
resultBlock("发货成功", .success)
} else {
showMessage(message: resp["message"] as! String)
resultBlock(NSNull(),.failed)
}
} else {
if CNLiveNetworking.isNetworking() {
showMessage(message: "发货失败")
resultBlock(NSNull(),.failed)
} else {
showMessage(message: "似乎与网络断开链接")
resultBlock(NSNull(),.noNetwork)
}
}
}
}
}
/// 快递公司列表
/// - resultBlock: 返回
static func requestExpressList(resultBlock: @escaping resultShopBlock) {
let custom_param = NSMutableDictionary()
custom_param.setValue(APPId_wjj, forKey: "appId")
custom_param.setValue(APPKey_wjj, forKey: "appKey")
CNLiveNetworking.setAllowRequestDefaultArgument(true)
CNLiveNetworking.setupShowDataResult(false)
CNLiveNetworking.setupDSRequest(true)
CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
CNLiveNetworking.requestNetwork(with: .GET, urlString: APPBaseWjjBUrl+"/api/v1/expressList", param: [ : ], cacheType: .networkOnly) { task, result, error in
hiddenLoading()
if (error == nil) {
let resp = result as! NSDictionary
let errorCode = "\(resp["code"] ?? "0")"
if (errorCode == "200") {
if resp["data"] is NSNull {
resultBlock(NSNull(),.failed)
} else {
let resp_dict = resp["data"] as! NSDictionary
let array = resp_dict["data"] as! NSArray
let tempArray = NSMutableArray()
for item in array {
let listModel = dictionaryToModel(item as! [String : Any], ShopOrderExpressModel.self,"") as! ShopOrderExpressModel
tempArray.add(listModel)
}
resultBlock(tempArray, .success)
}
} else {
showMessage(message: resp["message"] as! String)
resultBlock(NSNull(),.failed)
}
} else {
if CNLiveNetworking.isNetworking() {
showMessage(message: "请求失败")
resultBlock(NSNull(),.failed)
} else {
showMessage(message: "似乎与网络断开链接")
resultBlock(NSNull(),.noNetwork)
}
}
}
}
/// 获取部分发货物流详情
/// - Parameters:
/// - orderId: 订单id
/// - resultBlock: 返回
static func requestExpressList(orderId: NSString, resultBlock: @escaping resultShopBlock) {
let param = NSMutableDictionary()
param.setValue(orderId, forKey: "id")
let custom_param = NSMutableDictionary()
custom_param.setValue(APPId_wjj, forKey: "appId")
custom_param.setValue(APPKey_wjj, forKey: "appKey")
CNLiveNetworking.setAllowRequestDefaultArgument(true)
CNLiveNetworking.setupShowDataResult(false)
CNLiveNetworking.setupDSRequest(true)
CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
CNLiveNetworking.requestNetwork(with: .GET, urlString: APPBaseWjjBUrl+"/api/v1/orderMoreExp", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in
hiddenLoading()
if (error == nil) {
let resp = result as! NSDictionary
let errorCode = "\(resp["code"] ?? "0")"
if (errorCode == "200") {
if resp["data"] is NSNull {
resultBlock(NSNull(),.failed)
} else {
let array = resp["data"] as! NSArray
let tempArray = NSMutableArray()
for item in array {
let listModel = dictionaryToModel(item as! [String : Any], ShopOrderExpressListModel.self,"") as! ShopOrderExpressListModel
if listModel.id != "0" {
tempArray.add(listModel)
}
}
resultBlock(tempArray, .success)
}
} else {
showMessage(message: resp["message"] as! String)
resultBlock(NSNull(),.failed)
}
} else {
if CNLiveNetworking.isNetworking() {
showMessage(message: "请求失败")
resultBlock(NSNull(),.failed)
} else {
showMessage(message: "似乎与网络断开链接")
resultBlock(NSNull(),.noNetwork)
}
}
}
}
/// 订单详情查快递 && 订单详情查进度 && 查询快递(退款详情)
/// - Parameters:
/// - orderId: 订单id
/// - expId: 物流id
/// - resultBlock: 返回
static func requestExpressDetail(orderId: NSString, expId: NSString, networkType:CNLiveShopOrderExpressDetailShowType, resultBlock: @escaping resultShopBlock) {
let param = NSMutableDictionary()
param.setValue(orderId, forKey: "id")
var url: NSString = ""
if networkType == .orderExpress {
url = "/api/v1/express"
param.setValue(expId, forKey: "exp_id")
}
if networkType == .byYourself {
url = "/api/v1/step"
}
if networkType == .refundExpress {
url = "/api/v1/getRefundExpress"
}
let custom_param = NSMutableDictionary()
custom_param.setValue(APPId_wjj, forKey: "appId")
custom_param.setValue(APPKey_wjj, forKey: "appKey")
CNLiveNetworking.setAllowRequestDefaultArgument(true)
CNLiveNetworking.setupShowDataResult(false)
CNLiveNetworking.setupDSRequest(true)
CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
CNLiveNetworking.requestNetwork(with: .GET, urlString: APPBaseWjjBUrl+(url as String), param: param as! [String : String], cacheType: .networkOnly) { task, result, error in
hiddenLoading()
if (error == nil) {
let resp = result as! NSDictionary
let errorCode = "\(resp["code"] ?? "0")"
if (errorCode == "200") {
if resp["data"] is NSNull {
resultBlock(NSNull(),.failed)
} else {
let item = resp["data"] as! NSDictionary
let listModel = dictionaryToModel(item as! [String : Any], ShopOrderExpressDetailModel.self,"") as! ShopOrderExpressDetailModel
resultBlock(listModel, .success)
}
} else {
showMessage(message: resp["message"] as! String)
resultBlock(NSNull(),.failed)
}
} else {
if CNLiveNetworking.isNetworking() {
showMessage(message: "请求失败")
resultBlock(NSNull(),.failed)
} else {
showMessage(message: "似乎与网络断开链接")
resultBlock(NSNull(),.noNetwork)
}
}
}
}
/// 电商商家流水
/// - Parameters:
/// - date: 时间
/// - type: 0 全部 1 收入 2 支出
/// - resultBlock: 返回
static func requestAccount(date: String, type:CNLiveShopTransListShowType, resultBlock: @escaping resultShopBlock) {
let param = NSMutableDictionary()
param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "uid")
param.setValue(date, forKey: "date")
if type == .all {
param.setValue("0", forKey: "type")
}
if type == .income {
param.setValue("1", forKey: "type")
}
if type == .outcome {
param.setValue("2", forKey: "type")
}
let custom_param = NSMutableDictionary()
custom_param.setValue(APPId_wjj, forKey: "appId")
custom_param.setValue(APPKey_wjj, forKey: "appKey")
CNLiveNetworking.setAllowRequestDefaultArgument(true)
CNLiveNetworking.setupShowDataResult(false)
CNLiveNetworking.setupDSRequest(true)
CNLiveNetworking.setupCustomParam(custom_param as? [String : String])
CNLiveNetworking.requestNetwork(with: .GET, urlString: APPBaseWjjBUrl+"/api/v1/getShopAccount", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in
hiddenLoading()
if (error == nil) {
let resp = result as! NSDictionary
let errorCode = "\(resp["code"] ?? "0")"
if (errorCode == "200") {
if resp["data"] is NSNull {
resultBlock(NSNull(),.failed)
} else {
let model = dictionaryToModel(resp as! [String : Any], ShopOrderTransBaseDataModel.self,"data") as! ShopOrderTransBaseDataModel
resultBlock(model,.success)
}
} else {
showMessage(message: resp["message"] as! String)
resultBlock(NSNull(),.failed)
}
} else {
if CNLiveNetworking.isNetworking() {
showMessage(message: "请求失败")
resultBlock(NSNull(),.failed)
} else {
showMessage(message: "似乎与网络断开链接")
resultBlock(NSNull(),.noNetwork)
}
}
}
}
}