notebook_detail_change_model_only.dart
26.6 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
import 'dart:async';
import 'dart:convert';
import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
import 'package:one_key/app.dart';
import 'package:one_key/constant/constant.dart';
import 'package:one_key/models/notebook_detail.dart';
import 'package:one_key/models/reserve_info_model.dart';
import 'package:one_key/models/seller_info.dart';
import 'package:one_key/models/table_list.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/notebook_detail_model.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/utils/utils.dart';
import 'package:provider/provider.dart';
import 'package:one_key/models/table.dart' as t;
import '../constant/error.dart';
import '../models/detail_model_all_model.dart';
import '../models/is_exist_order_model.dart';
import '../models/tableOuter.dart';
import '../models/table_or_reserve_model.dart';
class NotebookDetailChangeModelOnly with ChangeNotifier {
TextEditingController phoneController = TextEditingController(); //电话
TextEditingController nameController = TextEditingController(); //客户姓名
TextEditingController customController = TextEditingController(); //客户要求
List sexList = []; // 先生、女士、公司
NotebookDetail? detailEntity;
List<TableListReserve>? tableListOrReserve = [];
List<TableList>? recommendList = []; //推荐列表
// bool isRecommend = false; //是否展示推荐
List oldTableList = [];
List<UserHistoryEntity> userHistorys = []; //历史录入
clearData() {
phoneController = TextEditingController(); //电话
nameController = TextEditingController(); //客户姓名
customController = TextEditingController(); //客户要求
sexList = []; // 先生、女士、公司
tableListOrReserve = [];
}
//构造函数,初始化
NotebookDetailChangeModelOnly() {
// clearData();
// print(detailEntity);
// if (detailEntity.phone != '0') {
// phoneController.text = detailEntity.phone;
// }
// if (detailEntity.rnameStr != '') {
// nameController.text = detailEntity.rname;
// }
// if (detailEntity.cusdem != '') {
// customController.text = detailEntity.cusdem;
// }
// _initSexList();
}
// /// 初始化 早市、午市、晚市
// _initSunDateList(morning, noon, night) {
// String ddateSolt = detailEntity.ddate_solt;
// if (morning != '') {
// sunDateList.add({
// 'dateText': '早市',
// 'dayText': '',
// 'ddateSolt': 1,
// 'key': 'morning',
// 'isSelect': ddateSolt == '1' ? true : false
// });
// }
// if (noon != '') {
// sunDateList.add({
// 'dateText': '午市',
// 'dayText': '',
// 'ddateSolt': 2,
// 'key': 'noon',
// 'isSelect': ddateSolt == '2' ? true : false
// });
// }
// if (night != '') {
// sunDateList.add({
// 'dateText': '晚市',
// 'dayText': '',
// 'ddateSolt': 3,
// 'key': 'night',
// 'isSelect': ddateSolt == '3' ? true : false
// });
// }
// // initHourAndMinuteSelect();
// notifyListeners();
// }
///称谓
initSexList() {
String? sexStr = detailEntity!.sex;
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
},
{
'title': '贵宾',
'select': sexStr == '4' ? true : false,
'code': '4',
'hasLeftBorder': false
}
];
}
List<TableListReserve>? getSpTableListOr() {
String? tableList = App.sp!.getString('table_list_or_reserve');
if (tableList == null) {
return [];
}
List<TableListReseveSunModel> temp = [];
List list = json.decode(tableList);
if (list.length > 0) {
list.forEach((element) {
temp.add(TableListReseveSunModel.fromJson2(element));
});
}
print(temp[0].tableList);
return temp[0].tableList;
}
// List<t.Table> getSpTableList() {
// List<t.Table> tables = [];
// String tableList = App.sp.getString('table_list');
// if (tableList != null) {
// List list = json.decode(tableList);
// if (list.length > 0) {
// list.forEach((element) {
// tables.addAll(TableOuter.fromJson2(element).list);
// });
// }
// }
// return tables;
// }
/// 根据时间和分钟组装 格式:11:00
_dealTime(int begin, int mm) {
String sb = '';
if (begin < 10) {
sb = '0$begin';
} else {
sb = '$begin';
}
sb = '$sb:';
if (mm < 10) {
sb = '${sb}0${mm}';
} else {
sb = '${sb}${mm}';
}
return sb;
}
///获取某个商家下所有服务员信息 **** 取得某个商家的早市、午市、晚市营业时间
Future<SunSellerInfoModel?> getManagersInfo(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
};
try {
BaseResp<Map<String, dynamic>?> baseResp = await DioUtil()
.request<Map<String, dynamic>>(
context, Method.post, HttpUrl.sellerinfo,
data: params);
SunSellerInfoModel? itemModel;
if (baseResp == null) return itemModel;
if (baseResp.code == Constant.status_success) {
if (int.parse(baseResp.status!) != Constant.status_success) {
Utils.showToast(baseResp.msg ?? "");
return itemModel;
}
if (baseResp.responseData!['data'] != null) {
itemModel = SellerInfoModel.fromJson(
baseResp.responseData as Map<String, dynamic>)
.data;
} else {
Utils.showToast(baseResp.msg ?? "");
}
return itemModel;
}
} catch (error) {
print(error.toString());
}
}
// Future<bool> getTableItExistOrder(
// BuildContext context, String rdate, String tableids, String ddateSolt,String rid,List oldTableList,
// {showLoading = false, bool selfDismiss = false}) async {
// Map<String, String> params = {
// 'sid': Provider.of<UserModel>(context, listen: false).user.sellerid,
// 'tableid': tableids,
// 'rdate': rdate,
// 'ddate_solt': ddateSolt,
// 'rid':rid
// };
// BaseResp<dynamic> baseResp = await DioUtil()
// .request<dynamic>(context, Method.get, HttpUrl.get_table_it_exist_order,
// data: params, showLoading: showLoading, selfDismiss: selfDismiss)
// !!.catchError((error) {
// print(error.toString());
// if (error is MyError) {}
// return true;
// });
// if (baseResp == null) return false;
// if (baseResp.code == Constant.status_success) {
// List<IsExistOrderSunModel> data =
// IsExistOrderModel.fromJson(baseResp.responseData).data;
// if (data.length > 0) {
// String msg = '';
// String msgDel = '';
// data.forEach((element) {
// //提示并且把桌子从选中的桌子助农筛选出去
// selectTablesOrReserve
// .removeWhere((element1) => element1.id == element.id);
// if (element.isOccupy == '1') {
// //被占用了
// msg += '${element.name},';
// } else if (element.isOccupy == '0') {
// //被删除了
// msgDel += '${element.name},';
// }
// });
// if (msg.endsWith(',')) {
// msg = msg.substring(0, msg.length - 1);
// }
// if (msgDel.endsWith(',')) {
// msgDel = msgDel.substring(0, msgDel.length - 1);
// }
// if (msg != '' && msgDel == '') {
// Utils.showToast('${msg}已被占用啦');
// } else if (msg == '' && msgDel != '') {
// Utils.showToast('${msgDel}已被删除啦');
// } else if (msg != '' && msgDel != '') {
// Utils.showToast('${msg}已被占用啦\n' + '${msgDel}已被删除啦');
// }
// notifyListeners();
// return false;
// } else {
// return true;
// }
// } else {
// Utils.showToast(baseResp.msg ?? "");
// }
// return true;
// }
///根据商家ID 获取桌位信息列表: 1:散座 2:包间 默认:获取所有数据
Future<List<TableListReserve>?> getNewTableList(
BuildContext context,
String ddate,
String? ddate_solt,
String? pnum,
List? oldTableList) async {
DateTime createTime = DateTime.fromMillisecondsSinceEpoch(int.parse(ddate));
String rdate = DateUtil.formatDate(createTime, format: "yyyyMMdd");
UserModel userModel = Provider.of<UserModel>(context, listen: false);
Map<String, String?> params = {
"sid": userModel.user!.sellerid,
"rdate": rdate,
'ddate_solt': ddate_solt,
};
if (pnum != null && pnum != '') {
params['pnum'] = pnum;
}
if (detailEntity!.id!.isNotEmpty && detailEntity!.id != "-1") {
params['rid'] = detailEntity!.id;
}
try {
BaseResp<dynamic> baseResp = await DioUtil().request<dynamic>(
context, Method.post, HttpUrl.get_table_list,
data: params);
List<TableListSunModel>? itemModelList;
if (baseResp == null) return tableListOrReserve;
if (baseResp.code == Constant.status_success) {
if (int.parse(baseResp.status!) != Constant.status_success) {
Utils.showToast(baseResp.msg ?? "");
return tableListOrReserve;
}
if (baseResp.responseData!['data'] != null) {
itemModelList = TableListModel.fromJson(
baseResp.responseData as Map<String, dynamic>)
.data!
.cast<TableListSunModel>();
} else {
Utils.showToast(baseResp.msg ?? "");
}
tableListOrReserve = [];
for (int i = 0; i < itemModelList!.length; i++) {
if (itemModelList[i].name == "推荐") {
recommendList = itemModelList[i].list!.cast<TableList>();
itemModelList.removeAt(i);
}
}
List<String?> tableIds = []; //所有桌位的id
List<String?> tableIdsOld = []; //带过来所有桌位的id
List<TableListReserve> tableS = getSpTableListOr()!; //缓存的所有桌子
for (TableListReserve elementT in tableS) {
tableIds.add(elementT.id);
}
for (var table in oldTableList!) {
tableIdsOld.add(table.id);
}
for (TableListSunModel item in itemModelList) {
if (item.name == "推荐") {
itemModelList.remove(item);
}
for (var item in item.list!) {
for (var table in oldTableList) {
if (item!.id == table.id) {
item.selected = true;
if (!tableListOrReserve!.contains(item)) {
tableListOrReserve!
.add(TableListReserve.fromJson(item.toJson()));
}
}
}
}
}
List<String?> combinedList = [];
for (var old in tableIdsOld) {
if (!tableIds.contains(old)) {
//删除了
combinedList.add(old);
}
}
// tables
// List usedTableList = []; //被占用的包间
// for (var itemOld in oldTableList) {
// if (tableList.length == 0) {
// usedTableList = oldTableList;
// } else {
// for (var item in tableList) {
// if (item.id != itemOld.id) {
// usedTableList.add(item);
// }
// }
// }
// }
List idold = [];
for (var itemOld in oldTableList) {
idold.add(itemOld.id);
}
List idnew = [];
for (var item in tableListOrReserve!) {
idnew.add(item.id);
}
for (var item in idnew) {
idold.remove(item);
}
print(idold); //被占用的桌子的id
if (idold.length > 0) {
print(combinedList);
List delTablesid = []; //删除
List useTablesid = []; //占用
if (combinedList.length > 0) {
//存在删除的桌位
for (String? ids in idold as Iterable<String?>) {
if (combinedList.contains(ids)) {
delTablesid.add(ids);
} else {
useTablesid.add(ids);
}
}
} else {
useTablesid.addAll(idold); //占用
}
String msg = '';
String msgDel = '';
for (var item in oldTableList) {
if (useTablesid.contains(item.id)) {
msg += '${item.name},';
}
if (delTablesid.contains(item.id)) {
msgDel += '${item.name},';
}
}
if (msg.endsWith(',')) {
msg = msg.substring(0, msg.length - 1);
}
if (msgDel.endsWith(',')) {
msgDel = msgDel.substring(0, msgDel.length - 1);
}
if (msg != '' && msgDel == '') {
Utils.showToast('${msg}已被占用啦');
} else if (msg == '' && msgDel != '') {
Utils.showToast('${msgDel}已被删除啦');
} else if (msg != '' && msgDel != '') {
Utils.showToast('${msg}已被占用啦\n' + '${msgDel}已被删除啦');
}
}
// if (usedTableList.length > 0) {
// print(usedTableList);
// String msg = '';
// for (var item in usedTableList) {
// msg += '${item.name},';
// }
// if (msg.endsWith(',')) {
// msg = msg.substring(0, msg.length - 1);
// }
// Utils.showToast('${msg}已被占用啦');
// }
// if(usedTableList.length > 0){
// for (TableList item in usedTableList) {
// item
// }
// }
// if (tableList.length == 0) {
// // Utils.showToast('包间已经被预订');
// isRecommend = true;
// } else {
// isRecommend = false;
// }
print(tableListOrReserve);
notifyListeners();
return tableListOrReserve;
}
} catch (error) {
print(error.toString());
}
}
///录入更改内部预订
Future<SunReserveInfoModel?> setReserveInfoOnly(
BuildContext context,
String? nameStr,
String? uid,
int currTimeIndex,
DateTime dateTime,
String? morning,
String? noon,
String? night) async {
UserModel userModel = Provider.of<UserModel>(context, listen: false);
if (phoneController.text.trim().length > 0) {
//判断是否可以输入自己的手机号
CustomerProvider customerProvider =
Provider.of<CustomerProvider>(context, listen: false);
await customerProvider.getSellerGuest(context);
if (customerProvider.isselfphone) {
//录入客户电话时不能用自己手机号(管店)
if (userModel.user!.userphone == phoneController.text.trim() ||
userModel.user!.userphoneMyPage == phoneController.text.trim()) {
Utils.showToast('录入客户电话时不能用自己手机号!');
return null;
}
}
}
String ddateHm = detailEntity!.ddateHm; //订座详情页面的到店时间
String? ddateSolt = detailEntity!.ddate_solt; //订座详情页面的餐段(1,2,3 早餐、午餐、晚餐)
String tempTime = ddateHm; //默认上个页面到店时间半小时值
if (ddateSolt != currTimeIndex.toString()) {
if (currTimeIndex == 1) {
tempTime = '08:00';
if (userModel.user!.morning != '' && userModel.user!.morning != null) {
List tempDate = userModel.user!.morning!.split("-");
tempTime = tempDate[0];
}
} else if (currTimeIndex == 2) {
tempTime = '12:00';
if (userModel.user!.noon != '' && userModel.user!.noon != null) {
List tempDate = userModel.user!.noon!.split("-");
tempTime = tempDate[0];
}
} else if (currTimeIndex == 3) {
tempTime = '18:00';
if (userModel.user!.night != '' && userModel.user!.night != null) {
List tempDate = userModel.user!.night!.split("-");
tempTime = tempDate[0];
}
}
}
String ymd = DateUtil.formatDate(dateTime, format: DateFormats.y_mo_d);
String timeStr = ymd + ' ' + tempTime + ':00';
LogUtil.v(timeStr);
int? ddate = DateUtil.getDateMsByTimeStr(timeStr);
String tableSelectInfo = '';
for (TableListReserve item in tableListOrReserve!) {
// if (item.selected) {
tableSelectInfo += ',${item.id}';
// }
}
print(tableSelectInfo);
if (tableSelectInfo.startsWith(',')) {
tableSelectInfo = tableSelectInfo.substring(1);
}
print(tableSelectInfo);
String rdate = '';
late String timeStrStart;
late String timeStrEnd;
if (currTimeIndex == 1) {
//早市
List timem = morning!.split('-');
timeStrStart = ymd + ' ' + timem[0] + ':00';
timeStrEnd = ymd + ' ' + timem[1] + ':00';
} else if (currTimeIndex == 2) {
//午市
List timem = noon!.split('-');
timeStrStart = ymd + ' ' + timem[0] + ':00';
timeStrEnd = ymd + ' ' + timem[1] + ':00';
} else if (currTimeIndex == 3) {
//晚市
List timem = night!.split('-');
timeStrStart = ymd + ' ' + timem[0] + ':00';
timeStrEnd = ymd + ' ' + timem[1] + ':00';
}
int? startM = DateUtil.getDateMsByTimeStr(timeStrStart);
int? endM = DateUtil.getDateMsByTimeStr(timeStrEnd);
String start = '${startM}'.substring(0, 10);
String end = '${endM}'.substring(0, 10);
rdate = start + '-' + end;
Map<String, String?> params = {
"sid": userModel.user!.sellerid, //商家ID
"tid": tableSelectInfo, //桌子ID: 格式 2,3,4
'note_name': userModel.user!.account,
'type': "0", //内部预订
"rdate": rdate, //预定用餐时间范围:时间戳 开始时间戳(time)-结束时间戳(time)
// 'is_set_ddate': "1",
"ddate": '${ddate}'.substring(0, 10), //到店时间
"channel": '5',
"uid": uid
};
if (detailEntity!.id!.isNotEmpty && detailEntity!.id != "-1") {
params['rid'] = detailEntity!.id;
}
if (nameStr!.trim().length > 0) {
String? sex = '1';
for (var item in sexList) {
if (item['select']) {
sex = item['code'];
}
}
params['rname'] = nameStr; //预订人姓名
params['sex'] = sex; //预订人性别:1:男 2:女
}
if (phoneController.text.trim().length > 0) {
params['phone'] = phoneController.text.replaceAll(' ', ''); //预订人电话
}
// if (customController.text.trim().length > 0) {
// params['cusdem'] = customController.text; //预订人需求:25汉字
// }
params['cusdem'] = customController.text; //预订人需求:25汉字
print(params);
try {
BaseResp<Map<String, dynamic>?> baseResp = await DioUtil()
.request<Map<String, dynamic>>(
context, Method.post, HttpUrl.set_reserve_info,
data: params);
SunReserveInfoModel? itemModel = SunReserveInfoModel(null, null, null);
if (baseResp == null) return itemModel;
if (baseResp.code == Constant.status_success) {
if (int.parse(baseResp.status!) != Constant.status_success) {
Utils.showToast(baseResp.msg ?? "");
return itemModel;
}
if (baseResp.responseData!['data'] != null &&
baseResp.responseData!['data']['row'] != null) {
itemModel = ReserveInfoModel.fromJson(
baseResp.responseData as Map<String, dynamic>)
.data;
} else {
Utils.showToast(baseResp.msg ?? "变更预订订单失败,请重试!");
}
return itemModel;
}
} catch (error) {
print(error.toString());
}
return null;
}
//更改在线预订
Future<SunReserveInfoModel?> updateOnlineReserveInfoOnly(
BuildContext context,
String? nameStr,
String? uid,
int currTimeIndex,
DateTime dateTime,
String? morning,
String? noon,
String? night) async {
UserModel userModel = Provider.of<UserModel>(context, listen: false);
if (phoneController.text.trim().length > 0) {
//判断是否可以输入自己的手机号
CustomerProvider customerProvider =
Provider.of<CustomerProvider>(context, listen: false);
await customerProvider.getSellerGuest(context);
if (customerProvider.isselfphone) {
//录入客户电话时不能用自己手机号(管店)
if (userModel.user!.userphone == phoneController.text.trim() ||
userModel.user!.userphoneMyPage == phoneController.text.trim()) {
Utils.showToast('录入客户电话时不能用自己手机号!');
return null;
}
}
}
String ddateHm = detailEntity!.ddateHm; //订座详情页面的到店时间
String? ddateSolt = detailEntity!.ddate_solt; //订座详情页面的餐段(1,2,3 早餐、午餐、晚餐)
String tempTime = ddateHm; //默认上个页面到店时间半小时值
if (ddateSolt != currTimeIndex.toString() || tempTime == '') {
if (currTimeIndex == 1) {
tempTime = '08:00';
ddateSolt = '1';
if (userModel.user!.morning != '' && userModel.user!.morning != null) {
List tempDate = userModel.user!.morning!.split("-");
tempTime = tempDate[0];
}
} else if (currTimeIndex == 2) {
tempTime = '12:00';
ddateSolt = '2';
if (userModel.user!.noon != '' && userModel.user!.noon != null) {
List tempDate = userModel.user!.noon!.split("-");
tempTime = tempDate[0];
}
} else if (currTimeIndex == 3) {
tempTime = '18:00';
ddateSolt = '3';
if (userModel.user!.night != '' && userModel.user!.night != null) {
List tempDate = userModel.user!.night!.split("-");
tempTime = tempDate[0];
}
}
}
String ymd = DateUtil.formatDate(dateTime, format: DateFormats.y_mo_d);
String timeStr = ymd + ' ' + tempTime + ':00';
// int start = DateUtil.getDateMsByTimeStr(timeStr);
LogUtil.v(timeStr);
// String tempDdate = ymyStr + ' ' + ddateStr + ':00';
int? ddate = DateUtil.getDateMsByTimeStr(timeStr);
String tableSelectInfo = '';
for (TableListReserve item in tableListOrReserve!) {
// if (item.selected) {
tableSelectInfo += ',${item.id}';
// }
}
print(tableSelectInfo);
if (tableSelectInfo.startsWith(',')) {
tableSelectInfo = tableSelectInfo.substring(1);
}
print(tableSelectInfo);
String rdate = '';
late String timeStrStart;
late String timeStrEnd;
if (currTimeIndex == 1) {
//早市
List timem = morning!.split('-');
timeStrStart = ymd + ' ' + timem[0] + ':00';
timeStrEnd = ymd + ' ' + timem[1] + ':00';
} else if (currTimeIndex == 2) {
//午市
List timem = noon!.split('-');
timeStrStart = ymd + ' ' + timem[0] + ':00';
timeStrEnd = ymd + ' ' + timem[1] + ':00';
} else if (currTimeIndex == 3) {
//晚市
List timem = night!.split('-');
timeStrStart = ymd + ' ' + timem[0] + ':00';
timeStrEnd = ymd + ' ' + timem[1] + ':00';
}
int? startM = DateUtil.getDateMsByTimeStr(timeStrStart);
int? endM = DateUtil.getDateMsByTimeStr(timeStrEnd);
String start = '${startM}'.substring(0, 10);
String end = '${endM}'.substring(0, 10);
rdate = start + '-' + end;
Map<String, String?> params = {
"sid": userModel.user!.sellerid, //商家ID
"tid": tableSelectInfo, //桌子ID: 格式 2,3,4
"type": "0",
"rdate": rdate, //预定用餐时间范围:时间戳 开始时间戳(time)-结束时间戳(time)
"ddate": '${ddate}'.substring(0, 10), //到店时间
"ddate_solt": ddateSolt,
'note_name': userModel.user!.account
};
// gdfgadgfadfgadfgadfg youwenti
if (detailEntity!.id!.isNotEmpty && detailEntity!.id != "-1") {
params['rid'] = detailEntity!.id;
}
if (nameStr!.trim().length > 0) {
String? sex = '1';
for (var item in sexList) {
if (item['select']) {
sex = item['code'];
}
}
params['rname'] = nameStr; //预订人姓名
params['sex'] = sex; //预订人性别:1:男 2:女
}
if (phoneController.text.trim().length > 0) {
params['phone'] = phoneController.text.replaceAll(' ', ''); //预订人电话
}
// if (customController.text.trim().length > 0) {
params['cusdem'] = customController.text; //预订人需求:25汉字
// }
print(params);
try {
BaseResp<Map<String, dynamic>?> baseResp = await DioUtil()
.request<Map<String, dynamic>>(
context, Method.post, HttpUrl.set_customer_info,
data: params);
SunReserveInfoModel? itemModel;
if (baseResp == null) return itemModel;
if (baseResp.code == Constant.status_success) {
if (int.parse(baseResp.status!) != Constant.status_success) {
Utils.showToast(baseResp.msg ?? "");
return itemModel;
}
if (baseResp.responseData!['data'] != null &&
baseResp.responseData!['data']['row'] != null) {
itemModel = ReserveInfoModel.fromJson(
baseResp.responseData as Map<String, dynamic>)
.data;
} else {
Utils.showToast(baseResp.msg ?? "变更预订订单失败,请重试!");
}
return itemModel;
}
} catch (error) {
print(error.toString());
}
return null;
}
//获取历史录入
getUserHistorys(BuildContext context, Map<String, String?> params) async {
try {
BaseResp<List?> baseResp = await DioUtil().request<List>(
context, Method.post, HttpUrl.get_reserve_user,
data: params, showLoading: false);
if (baseResp != null && baseResp.code == Constant.status_success) {
userHistorys = baseResp.data!.map<UserHistoryEntity>((value) {
return UserHistoryEntity.fromJson(value);
}).toList();
notifyListeners();
}
} catch (error) {
print(error.toString());
}
}
}