notebook_detail_model.dart
28 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
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
import 'package:one_key/constant/constant.dart';
import 'package:one_key/constant/error.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/manager.dart';
import 'package:one_key/models/notebook_detail.dart';
import 'package:one_key/models/user_history_entity.dart';
import 'package:one_key/net/base_resp.dart';
import 'package:one_key/net/dio_util.dart';
import 'package:one_key/net/http_url.dart';
import 'package:one_key/provider/customer_provider.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/route/navigator_util.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/widgets/loading.dart';
import 'package:provider/provider.dart';
import '../app.dart';
import '../models/GetDzSellerConfModel.dart';
import '../models/base_info_model.dart';
import '../models/detail_model_all_model.dart';
import '../models/get_reserve_type_field_model.dart';
import '../models/note_book_only_model.dart';
import '../models/notebook.dart';
import '../models/remark.dart';
import '../models/reserveA_action_log_modol.dart';
import '../models/reserve_deposit_model.dart';
import '../models/reserve_img_text.dart';
import '../models/reserve_recheck_model.dart';
import '../models/seller_user_account_type.dart';
import '../models/seller_version_model.dart';
import '../models/user.dart';
import 'dart:convert' as convert;
class NotebookDetailModel extends ChangeNotifier {
PageState pageState = PageState.Loading;
PageState pageStateChange = PageState.Loading;
PageState pageStateSim = PageState.Loading;
String selectNum;
int selectIndex;
TextEditingController numController = TextEditingController();
String strTF;
String prestrTF;
TextEditingController phoneController = TextEditingController();
TextEditingController nameController = TextEditingController();
List sexList;
List<UserHistoryEntity> userHistorys = []; //历史录入
List<ReserveDepositSunModel> reserveDepositList = []; //订单订金数据
List<ReserveRecheckSunModel> reserveRecheckList = []; //核餐记录数据
List<GetReserveTypeFieldsSunModel> reserveTypes = []; //用餐类型
List<ReserveActionLogSunModol> reserveActionLogData = []; // 获取预订操作记录
String depositId; //订金id
DetailModelAllSunModel detailModelAllSunModel; //订座详情页
List<Remark> remarks = []; //所有备注
List<Remark> ofenRemarks = []; //常用备注
List<SellerVersionSunModel> sellerVersionList = [];
bool sellerCoupon = false; //优惠券营销
bool sellerRecharge = false; //储值营销
bool sellerWine = false; //存酒
bool sellerOrderCustomer = false; //用户提前点餐
bool sellerOrderManager = false; //经理排菜
bool sellerFeast = false; //宴会
bool sellerPreserve = false; //客情维护
bool sellerMarketing = false; //客情营销
bool sellerNormal = false; //超能或者标准或高级
bool sellerSimple = false; //极速版
bool sellerNormalSpecial = false; //标准版客情和极速版一样
String sellerNormalEdate = '';
String smsInfo = '';
String price = '';
String priceID = '';
String depositPrice = '';
String reserveTotal = '';
List<SellerUserAccountTypeSunModel> serverList = []; //服务人员
BaseInfoSunModel baseInfoSunModel; //客户经理基础信息
GetDzSellerConfSunModel dzSellerConfModel;
bool phoneSwich = true;
bool nameSwich = true;
String reserveImgText;
String smsContent = '';
String isShowNoticeDeposit;
NotebookDetailModel() {
initSexList();
}
///称谓
initSexList() {
String sexStr = '1';
sexList = [
{
'title': '先生',
'select': sexStr == '1' ? true : false,
'code': '1',
'hasLeftBorder': true
},
{
'title': '女士',
'select': sexStr == '2' ? true : false,
'code': '2',
'hasLeftBorder': false
},
{
'title': '公司',
'select': sexStr == '3' ? true : false,
'code': '3',
'hasLeftBorder': false
}
];
}
/// 获取预订详情所需数据集合
getReserveDetailDataSet(BuildContext context, Map<String, String> params,
{isShowLoading = true, bool showCircle = false}) async {
if (isShowLoading) {
pageState = PageState.Loading;
notifyListeners();
}
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(
context, Method.post, HttpUrl.get_reserve_detail_data_set,
data: params, showLoading: isShowLoading ? false : showCircle)
.catchError((error) {
print(error.toString());
if (error is MyError) {
switch (error.type) {
case 1:
pageState = PageState.ConnectivityError;
break;
case 2:
pageState = PageState.ConnectivityTimeOut;
break;
default:
pageState = PageState.ConnectivityError;
break;
}
}
notifyListeners();
});
if (baseResp.code == Constant.status_success) {
//详情原来接口
if (baseResp.data.isEmpty) {
pageState = PageState.Empty;
} else {
pageState = PageState.Success;
}
detailModelAllSunModel =
DetailModelAllModel.fromJson(baseResp.responseData).data;
//
notifyListeners();
} else {
pageState = PageState.ConnectivityError;
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
}
notifyListeners();
}
//获取历史录入
getUserHistorys(BuildContext context, Map<String, String> params) async {
BaseResp<List> baseResp = await DioUtil()
.request<List>(context, Method.post, HttpUrl.get_reserve_user,
data: params, showLoading: false)
.catchError((error) {
print(error.toString());
});
if (baseResp != null && baseResp.code == Constant.status_success) {
userHistorys = baseResp.data.map<UserHistoryEntity>((value) {
return UserHistoryEntity.fromJson(value);
}).toList();
notifyListeners();
}
}
/// 获取预订详情所需其他附属信息
getReserveDetailRelationData(BuildContext context, Map<String, String> params,
{bool showCircle = false}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(
context, Method.post, HttpUrl.get_reserve_detail_relation_data,
data: params, showLoading: showCircle)
.catchError((error) {
print(error.toString());
return null;
});
if (baseResp.code == Constant.status_success) {
if (baseResp.data is Map) {
remarks = (baseResp.data['user_remark']).map<Remark>((value) {
return Remark.fromJson(value);
}).toList();
ofenRemarks = [];
for (Remark item in remarks) {
if (item.oftenUse != '') {
ofenRemarks.add(item);
}
}
//user_baseinfo
if (baseResp.data['user_baseinfo'] != null) {
baseInfoSunModel =
BaseInfoSunModel.fromJson(baseResp.data['user_baseinfo']);
}
if (baseResp.data['template_param'] != null) {
smsContent = baseResp.data["template_param"];
}
if (baseResp.data['is_show_ranme_phone'] != null &&
baseResp.data['is_show_ranme_phone'] != '') {
List isShowRnamePhone = [];
convert.json
.decode(baseResp.data['is_show_ranme_phone'])
.forEach((v) {
isShowRnamePhone.add(v);
});
if (isShowRnamePhone.length > 0) {
String uid =
Provider.of<UserModel>(context, listen: false).user.openid;
isShowRnamePhone.forEach((element) {
List subdata = element.split('-');
if (subdata[0] == uid) {
//设置过
phoneSwich = subdata[1] == '1' ? true : false;
nameSwich = subdata[2] == '1' ? true : false;
}
});
}
}
if (baseResp.data['is_show_notice_deposit'] != null) {
isShowNoticeDeposit = baseResp.data['is_show_notice_deposit'];
}
if (baseResp.data['deposit_price'] != null) {
depositPrice = baseResp.data['deposit_price'];
}
if (baseResp.data['reserve_deposit'] != null) {
price = baseResp.data['reserve_deposit']['price'];
priceID = baseResp.data['reserve_deposit']['id'];
}
if (baseResp.data['SmsInfo'] != null) {
smsInfo = baseResp.data['SmsInfo'].toString();
}
if (baseResp.data['reserve_type_field'] != null) {
reserveTypes = <GetReserveTypeFieldsSunModel>[];
reserveTypes = <GetReserveTypeFieldsSunModel>[];
baseResp.data['reserve_type_field'].forEach((v) {
GetReserveTypeFieldsSunModel temp =
GetReserveTypeFieldsSunModel(name: v, select: false);
reserveTypes.add(temp);
});
}
if (baseResp.data['reserve_image_text'] != null) {
reserveImgText = baseResp.data['reserve_image_text'] ?? '';
}
//服务人员
if (baseResp.data['accountType'] != null) {
baseResp.data['accountType'].forEach((v) {
serverList.add(SellerUserAccountTypeSunModel.fromJson(v));
});
}
//版本
if (baseResp.data['seller_versions'] != null) {
sellerOrderCustomer =
baseResp.data['seller_versions']['order'].toString() == '1'
? true
: false;
sellerOrderManager =
baseResp.data['seller_versions']['cook'].toString() == '1'
? true
: false;
sellerPreserve =
baseResp.data['seller_versions']['guest'].toString() == '1'
? true
: false;
}
} else {
Utils.showToast("获取失败");
}
} else {
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
}
notifyListeners();
return null;
}
/// 获取预订操作记录
Future<List<ReserveActionLogSunModol>> getReserveActionLog(
BuildContext context, Map<String, String> params,
{bool showCircle = false}) async {
BaseResp<List> baseResp = await DioUtil()
.request<List>(context, Method.post, HttpUrl.get_reserve_action_log,
data: params, showLoading: showCircle)
.catchError((error) {
print(error.toString());
return null;
});
if (baseResp.code == Constant.status_success) {
reserveActionLogData =
ReserveActionLogModol.fromJson(baseResp.responseData).data;
return reserveActionLogData;
} else {
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
}
notifyListeners();
return null;
}
/// 通过预订ID查收订金详情
Future<List<ReserveDepositSunModel>> getReserveDepositByRid(
BuildContext context, Map<String, String> params) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(
context, Method.post, HttpUrl.get_reserve_deposit_by_rid,
data: params, showLoading: false)
.catchError((error) {
print(error.toString());
return null;
});
if (baseResp.code == Constant.status_success) {
reserveDepositList =
ReserveDepositModel.fromJson(baseResp.responseData).data;
return reserveDepositList;
} else {
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
}
notifyListeners();
return null;
}
/// 获取核餐记录
Future<List<ReserveRecheckSunModel>> getReserveRecheckByRid(
BuildContext context, Map<String, String> params) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(
context, Method.post, HttpUrl.get_reserve_recheck_by_rid,
data: params, showLoading: false)
.catchError((error) {
print(error.toString());
});
if (baseResp.code == Constant.status_success) {
reserveRecheckList =
ReserveRecheckModel.fromJson(baseResp.responseData).data;
return reserveRecheckList;
} else {
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
}
notifyListeners();
}
///获取用餐类型
Future<List<GetReserveTypeFieldsSunModel>> getReserveTypeField(
BuildContext context,
{isShowLoading = true,
bool showCircle = false}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.post, HttpUrl.get_reserve_type_field,
showLoading: isShowLoading ? false : showCircle)
.catchError((error) {
print(error.toString());
if (error is MyError) {
// switch (error.type) {
// case 1:
// pageState = PageState.ConnectivityError;
// break;
// case 2:
// pageState = PageState.ConnectivityTimeOut;
// break;
// default:
// pageState = PageState.ConnectivityError;
// break;
// }
}
notifyListeners();
return null;
});
if (baseResp.code == Constant.status_success) {
reserveTypes =
GetReserveTypeFieldModel.fromJson(baseResp.responseData).data;
return reserveTypes;
} else {
pageState = PageState.ConnectivityError;
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
}
return null;
}
///获取已预订订单
Future<NotebookDetail> getReserveDetailSim(
BuildContext context, Map<String, String> params,
{isShowLoading = true, bool showCircle = false}) async {
if (isShowLoading) {
pageStateSim = PageState.Loading;
notifyListeners();
}
BaseResp<Map<String, dynamic>> baseResp = await DioUtil()
.request<Map<String, dynamic>>(
context, Method.post, HttpUrl.reserve_detail,
data: params, showLoading: isShowLoading ? false : showCircle)
.catchError((error) {
print(error.toString());
if (error is MyError) {
switch (error.type) {
case 1:
pageStateSim = PageState.ConnectivityError;
break;
case 2:
pageStateSim = PageState.ConnectivityTimeOut;
break;
default:
pageStateSim = PageState.ConnectivityError;
break;
}
}
notifyListeners();
});
if (baseResp.code == Constant.status_success) {
if (baseResp.data.isEmpty) {
pageStateSim = PageState.Empty;
} else {
pageStateSim = PageState.Success;
}
notifyListeners();
return NotebookDetail.fromJson(baseResp.data);
} else {
pageStateSim = PageState.ConnectivityError;
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
}
}
///获取已预订订单
Future<NotebookDetail> getReserveDetail(
BuildContext context, Map<String, String> params,
{isShowLoading = true, bool showCircle = false}) async {
if (isShowLoading) {
pageStateChange = PageState.Loading;
notifyListeners();
}
BaseResp<Map<String, dynamic>> baseResp = await DioUtil()
.request<Map<String, dynamic>>(
context, Method.post, HttpUrl.reserve_detail,
data: params, showLoading: isShowLoading ? false : showCircle)
.catchError((error) {
print(error.toString());
if (error is MyError) {
switch (error.type) {
case 1:
pageStateChange = PageState.ConnectivityError;
break;
case 2:
pageStateChange = PageState.ConnectivityTimeOut;
break;
default:
pageStateChange = PageState.ConnectivityError;
break;
}
}
notifyListeners();
});
if (baseResp.code == Constant.status_success) {
if (baseResp.data.isEmpty) {
pageStateChange = PageState.Empty;
} else {
pageStateChange = PageState.Success;
}
notifyListeners();
return NotebookDetail.fromJson(baseResp.data);
} else {
pageStateChange = PageState.ConnectivityError;
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
}
}
///获取商家信息
Future<List<Manager>> getManagers(BuildContext context) async {
UserModel userModel = Provider.of<UserModel>(context, listen: false);
Map<String, String> params = {
"seller_id": userModel.user.sellerid,
"seller_openid": userModel.user.openid
};
BaseResp<Map<String, dynamic>> baseResp = await DioUtil()
.request<Map<String, dynamic>>(context, Method.post, HttpUrl.sellerinfo,
data: params, showLoading: false)
.catchError((error) {
print(error.toString());
});
if (baseResp?.code == Constant.status_success) {
return (baseResp.data["manager"] as List)
.map((value) => Manager.fromJson(value as Map<String, dynamic>))
.toList();
}
}
///设置客户经理
setReserveCusmnan(BuildContext context, Map<String, String> params) async {
BaseResp<String> baseResp = await DioUtil()
.request<String>(context, Method.post, HttpUrl.set_reserve_cusman,
data: params)
.catchError((error) {
print(error.toString());
});
if (baseResp.code == Constant.status_success) {
} else {
Utils.showToast(baseResp.msg ?? "");
}
}
///创建收订金
createReserveDeposit(BuildContext context, Map<String, String> params) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.post, HttpUrl.create_reserve_deposit,
data: params)
.catchError((error) {
print(error.toString());
return false;
});
if (baseResp.code == Constant.status_success) {
if (baseResp.data is Map) {
depositId = baseResp.data['id'];
}
return true;
} else {
Utils.showToast(baseResp.msg ?? "");
return false;
}
}
///创建核餐
createReserveRecheck(BuildContext context, Map<String, String> params) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.post, HttpUrl.create_reserve_recheck,
data: params)
.catchError((error) {
print(error.toString());
return false;
});
if (baseResp.code == Constant.status_success) {
return true;
} else {
Utils.showToast(baseResp.msg ?? "");
return false;
}
}
//删除预订订金
delReserveDepositByid(
BuildContext context, Map<String, String> params) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(
context, Method.post, HttpUrl.del_reserve_deposit_by_id,
data: params)
.catchError((error) {
print(error.toString());
return false;
});
if (baseResp.code == Constant.status_success) {
return true;
} else {
Utils.showToast(baseResp.msg ?? "");
return false;
}
}
//取消预订发送短信
wxSendCancelSms(BuildContext context, Map<String, String> params) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.post, HttpUrl.wx_send_cancel_sms,
data: params, showLoading: false)
.catchError((error) {
print(error.toString());
});
if (baseResp.code == Constant.status_success) {
if (baseResp.data is Map) {
if (baseResp.data['Message'] == 'OK') {
Utils.showToast('取消预订短信已发送给客户');
} else {
Utils.showToast('取消预订短信发送失败');
}
} else {
Utils.showToast('取消预订短信发送失败');
}
} else {
Utils.showToast(baseResp.msg ?? '取消预订短信发送失败');
}
}
//安排在线预订
Future<bool> setReserveStatusOnly(
BuildContext context, Map<String, String> params,
{ifPush = true,
showLoading = false,
NoteBookOnlySunModel notebook}) async {
////到店 2 离店 3
///
///
bool can = true;
if (params['status'] == '2') {
//到店操作,限制在就餐前一小时之后
// 订单就餐时间
DateTime dateTime =
DateTime.fromMillisecondsSinceEpoch(int.parse(notebook.rdate) * 1000);
// // 现在的时间
// DateTime
DateTime now = DateTime.now();
// DateTime now = DateTime.fromMillisecondsSinceEpoch(1703905139 * 1000);
var difference = dateTime.difference(now);
print(difference.inMinutes > 60);
if (difference.inMinutes > 60) {
Utils.showToast('当前预订不能点击到店,因为还没到临餐时间!');
can = false;
Loading.hideLoading(context);
}
} else if (params['status'] == '3') {
//离店操作,需要订单已经是到店状态
if (notebook.status != '2') {
Utils.showToast('当前订单不能点击离店,需要先做到店确认!');
can = false;
Loading.hideLoading(context);
}
}
if (can) {
BaseResp<Map<String, dynamic>> baseResp = await DioUtil()
.request<Map<String, dynamic>>(
context, Method.post, HttpUrl.set_reserve_status,
data: params, showLoading: showLoading)
.catchError((error) {
print(error.toString());
});
if (baseResp == null) return false;
if (baseResp.code == Constant.status_success && baseResp.data != null) {
if (ifPush) {
UserModel userModel = Provider.of<UserModel>(context, listen: false);
NavigatorUtil.goNotebookDetailPage(
context, params["rid"], userModel.user.openid,
replace: true);
}
return true;
} else {
Utils.showToast("订单已被处理");
return false;
}
}
return false;
}
//安排在线预订
Future<bool> setReserveStatus(
BuildContext context, Map<String, String> params,
{ifPush = true, showLoading = false, Notebook notebook}) async {
////到店 2 离店 3
///
///
bool can = true;
if (params['status'] == '2') {
//到店操作,限制在就餐前一小时之后
// 订单就餐时间
DateTime dateTime =
DateTime.fromMillisecondsSinceEpoch(int.parse(notebook.rdate) * 1000);
// // 现在的时间
// DateTime
DateTime now = DateTime.now();
// DateTime now = DateTime.fromMillisecondsSinceEpoch(1703905139 * 1000);
var difference = dateTime.difference(now);
print(difference.inMinutes > 60);
if (difference.inMinutes > 60) {
Utils.showToast('当前预订不能点击到店,因为还没到临餐时间!');
can = false;
Loading.hideLoading(context);
}
} else if (params['status'] == '3') {
//离店操作,需要订单已经是到店状态
if (notebook.status != '2') {
Utils.showToast('当前订单不能点击离店,需要先做到店确认!');
can = false;
Loading.hideLoading(context);
}
}
if (can) {
BaseResp<Map<String, dynamic>> baseResp = await DioUtil()
.request<Map<String, dynamic>>(
context, Method.post, HttpUrl.set_reserve_status,
data: params, showLoading: showLoading)
.catchError((error) {
print(error.toString());
});
if (baseResp == null) return false;
if (baseResp.code == Constant.status_success && baseResp.data != null) {
if (ifPush) {
UserModel userModel = Provider.of<UserModel>(context, listen: false);
NavigatorUtil.goNotebookDetailPage(
context, params["rid"], userModel.user.openid,
replace: true);
}
return true;
} else {
Utils.showToast("订单已被处理");
return false;
}
}
return false;
}
// 取消订单设置订金走向
setReserveDeposit(BuildContext context, Map<String, String> params) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.post, HttpUrl.set_reserve_deposit,
data: params, showLoading: false)
.catchError((error) {
print(error.toString());
});
if (baseResp.code == Constant.status_success) {
} else {
Utils.showToast(baseResp.msg);
}
}
//设置消息状态
setMessageStatus(BuildContext context, Map<String, String> params) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.post, HttpUrl.set_message_status,
data: params, showLoading: false)
.catchError((error) {
print(error.toString());
});
if (baseResp.code == Constant.status_success) {
} else {
Utils.showToast(baseResp.msg);
}
}
// 设置订单服务经理
setServeUidByRid(BuildContext context, Map<String, String> params) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.post, HttpUrl.set_serve_uid_by_rid,
data: params, showLoading: false)
.catchError((error) {
print(error.toString());
return false;
});
if (baseResp.code == Constant.status_success) {
return true;
} else {
Utils.showToast(baseResp.msg);
}
return false;
}
// 编辑订单附加信息
Future<bool> upReserveInfo(BuildContext context, String rid,
{String actualPum,
String conAmount,
String dateStr,
String cusdem,
String sex,
String name,
String phone,
String ymd,
String reserveType,
bool showLoading = false,
bool needToast = true,
String photoNote}) async {
if (phone != null && phone != '') {
//判断是否可以输入自己的手机号
CustomerProvider customerProvider =
Provider.of<CustomerProvider>(context, listen: false);
await customerProvider.getSellerGuest(context);
if (customerProvider.isselfphone) {
//录入客户电话时不能用自己手机号(管店)
User user = Provider.of<UserModel>(context, listen: false).user;
if (user.userphone == phone || user.userphoneMyPage == phone) {
Utils.showToast('录入客户电话时不能用自己手机号!');
return false;
}
}
}
Map<String, dynamic> params = {
"rid": rid,
'note_name': Provider.of<UserModel>(context, listen: false).user.account
};
if (photoNote != null) {
params['photo_note'] = photoNote;
}
if (actualPum != null) {
params['actual_pum'] = actualPum;
}
if (conAmount != null) {
params['con_amount'] = conAmount;
}
if (dateStr != null) {
String timeStr = ymd + ' ' + dateStr + ':00';
int ddate = DateUtil.getDateMsByTimeStr(timeStr);
params['ddate'] = '${ddate}'.substring(0, 10); //到店时间
}
if (cusdem != null) {
params['cusdem'] = cusdem;
}
if (sex != null) {
params['sex'] = sex;
}
if (name != null) {
params['rname'] = name;
}
if (phone != null && phone != '') {
params['phone'] = phone;
}
if (reserveType != null && reserveType != '') {
params['reserve_type'] = reserveType;
}
bool sucess = await _upReserveInfo(context, params,
showLoading: showLoading, needToast: needToast);
if (sucess) {
if (!showLoading && needToast) {
Utils.showToast("修改成功!");
}
return true;
}
return false;
}
Future<bool> _upReserveInfo(BuildContext context, Map<String, dynamic> params,
{ifPush = true, showLoading = false, bool needToast = true}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.post, HttpUrl.up_reserve_info,
data: params, showLoading: showLoading)
.catchError((error) {
print(error.toString());
});
if (baseResp == null) return false;
if (baseResp.code == Constant.status_success && baseResp.data != null) {
return true;
} else {
if (needToast) {
Utils.showToast(baseResp.msg);
}
return false;
}
}
}