|
@@ -12,8 +12,10 @@ import 'package:one_key/net/http_url.dart'; |
|
@@ -12,8 +12,10 @@ import 'package:one_key/net/http_url.dart'; |
|
12
|
import 'package:one_key/provider/user_model.dart';
|
12
|
import 'package:one_key/provider/user_model.dart';
|
|
13
|
import 'package:one_key/route/navigator_util.dart';
|
13
|
import 'package:one_key/route/navigator_util.dart';
|
|
14
|
import 'package:one_key/utils/utils.dart';
|
14
|
import 'package:one_key/utils/utils.dart';
|
|
|
|
15
|
+import 'package:one_key/widgets/loading.dart';
|
|
15
|
import 'package:provider/provider.dart';
|
16
|
import 'package:provider/provider.dart';
|
|
16
|
|
17
|
|
|
|
|
18
|
+import '../models/notebook.dart';
|
|
17
|
import '../models/reserve_deposit_model.dart';
|
19
|
import '../models/reserve_deposit_model.dart';
|
|
18
|
import '../models/reserve_recheck_model.dart';
|
20
|
import '../models/reserve_recheck_model.dart';
|
|
19
|
|
21
|
|
|
@@ -270,27 +272,60 @@ class NotebookDetailModel extends ChangeNotifier { |
|
@@ -270,27 +272,60 @@ class NotebookDetailModel extends ChangeNotifier { |
|
270
|
//安排在线预订
|
272
|
//安排在线预订
|
|
271
|
Future<bool> setReserveStatus(
|
273
|
Future<bool> setReserveStatus(
|
|
272
|
BuildContext context, Map<String, String> params,
|
274
|
BuildContext context, Map<String, String> params,
|
|
273
|
- {ifPush = true, showLoading = false}) async {
|
|
|
|
274
|
- BaseResp<Map<String, dynamic>> baseResp = await DioUtil()
|
|
|
|
275
|
- .request<Map<String, dynamic>>(
|
|
|
|
276
|
- context, Method.get, HttpUrl.set_reserve_status,
|
|
|
|
277
|
- data: params, showLoading: showLoading)
|
|
|
|
278
|
- .catchError((error) {
|
|
|
|
279
|
- print(error.toString());
|
|
|
|
280
|
- });
|
|
|
|
281
|
- if (baseResp == null) return false;
|
|
|
|
282
|
- if (baseResp.code == Constant.status_success && baseResp.data != null) {
|
|
|
|
283
|
- if (ifPush) {
|
|
|
|
284
|
- UserModel userModel = Provider.of<UserModel>(context, listen: false);
|
|
|
|
285
|
- NavigatorUtil.goNotebookDetailPage(
|
|
|
|
286
|
- context, params["rid"], userModel.user.openid,
|
|
|
|
287
|
- replace: true);
|
275
|
+ {ifPush = true, showLoading = false, Notebook notebook}) async {
|
|
|
|
276
|
+ ////到店 2 离店 3
|
|
|
|
277
|
+ ///
|
|
|
|
278
|
+ ///
|
|
|
|
279
|
+ bool can = true;
|
|
|
|
280
|
+ if (params['status'] == '2') {
|
|
|
|
281
|
+ //到店操作,限制在就餐前一小时之后
|
|
|
|
282
|
+ // 订单就餐时间
|
|
|
|
283
|
+ DateTime dateTime =
|
|
|
|
284
|
+ DateTime.fromMillisecondsSinceEpoch(int.parse(notebook.ddate) * 1000);
|
|
|
|
285
|
+
|
|
|
|
286
|
+ // // 现在的时间
|
|
|
|
287
|
+ // DateTime
|
|
|
|
288
|
+ DateTime now = DateTime.now();
|
|
|
|
289
|
+ // DateTime now = DateTime.fromMillisecondsSinceEpoch(1703905139 * 1000);
|
|
|
|
290
|
+ var difference = dateTime.difference(now);
|
|
|
|
291
|
+
|
|
|
|
292
|
+ print(difference.inMinutes > 60);
|
|
|
|
293
|
+ if (difference.inMinutes > 60) {
|
|
|
|
294
|
+ Utils.showToast('当前预订不能点击到店,因为还没到临餐时间!');
|
|
|
|
295
|
+ can = false;
|
|
|
|
296
|
+ Loading.hideLoading(context);
|
|
|
|
297
|
+ }
|
|
|
|
298
|
+ } else if (params['status'] == '3') {
|
|
|
|
299
|
+ //离店操作,需要订单已经是到店状态
|
|
|
|
300
|
+ if (notebook.status != '2') {
|
|
|
|
301
|
+ Utils.showToast('当前订单不能点击离店,需要先做到店确认!');
|
|
|
|
302
|
+ can = false;
|
|
|
|
303
|
+ Loading.hideLoading(context);
|
|
288
|
}
|
304
|
}
|
|
289
|
- return true;
|
|
|
|
290
|
- } else {
|
|
|
|
291
|
- Utils.showToast("订单已被处理");
|
|
|
|
292
|
- return false;
|
|
|
|
293
|
}
|
305
|
}
|
|
|
|
306
|
+ if (can) {
|
|
|
|
307
|
+ BaseResp<Map<String, dynamic>> baseResp = await DioUtil()
|
|
|
|
308
|
+ .request<Map<String, dynamic>>(
|
|
|
|
309
|
+ context, Method.get, HttpUrl.set_reserve_status,
|
|
|
|
310
|
+ data: params, showLoading: showLoading)
|
|
|
|
311
|
+ .catchError((error) {
|
|
|
|
312
|
+ print(error.toString());
|
|
|
|
313
|
+ });
|
|
|
|
314
|
+ if (baseResp == null) return false;
|
|
|
|
315
|
+ if (baseResp.code == Constant.status_success && baseResp.data != null) {
|
|
|
|
316
|
+ if (ifPush) {
|
|
|
|
317
|
+ UserModel userModel = Provider.of<UserModel>(context, listen: false);
|
|
|
|
318
|
+ NavigatorUtil.goNotebookDetailPage(
|
|
|
|
319
|
+ context, params["rid"], userModel.user.openid,
|
|
|
|
320
|
+ replace: true);
|
|
|
|
321
|
+ }
|
|
|
|
322
|
+ return true;
|
|
|
|
323
|
+ } else {
|
|
|
|
324
|
+ Utils.showToast("订单已被处理");
|
|
|
|
325
|
+ return false;
|
|
|
|
326
|
+ }
|
|
|
|
327
|
+ }
|
|
|
|
328
|
+ return false;
|
|
294
|
}
|
329
|
}
|
|
295
|
|
330
|
|
|
296
|
//设置消息状态
|
331
|
//设置消息状态
|