|
...
|
...
|
@@ -12,8 +12,10 @@ import 'package:one_key/net/http_url.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 '../models/notebook.dart';
|
|
|
|
import '../models/reserve_deposit_model.dart';
|
|
|
|
import '../models/reserve_recheck_model.dart';
|
|
|
|
|
|
...
|
...
|
@@ -270,27 +272,60 @@ class NotebookDetailModel extends ChangeNotifier { |
|
|
|
//安排在线预订
|
|
|
|
Future<bool> setReserveStatus(
|
|
|
|
BuildContext context, Map<String, String> params,
|
|
|
|
{ifPush = true, showLoading = false}) async {
|
|
|
|
BaseResp<Map<String, dynamic>> baseResp = await DioUtil()
|
|
|
|
.request<Map<String, dynamic>>(
|
|
|
|
context, Method.get, 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);
|
|
|
|
{ifPush = true, showLoading = false, Notebook notebook}) async {
|
|
|
|
////到店 2 离店 3
|
|
|
|
///
|
|
|
|
///
|
|
|
|
bool can = true;
|
|
|
|
if (params['status'] == '2') {
|
|
|
|
//到店操作,限制在就餐前一小时之后
|
|
|
|
// 订单就餐时间
|
|
|
|
DateTime dateTime =
|
|
|
|
DateTime.fromMillisecondsSinceEpoch(int.parse(notebook.ddate) * 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);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
Utils.showToast("订单已被处理");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (can) {
|
|
|
|
BaseResp<Map<String, dynamic>> baseResp = await DioUtil()
|
|
|
|
.request<Map<String, dynamic>>(
|
|
|
|
context, Method.get, 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
//设置消息状态
|
...
|
...
|
|