|
|
|
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';
|
|
...
|
...
|
@@ -472,7 +473,7 @@ class NotebookDetailChangeModel with ChangeNotifier { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///录入顾客订座相关信息,同时更新商家桌位状态
|
|
|
|
///录入更改内部预订
|
|
|
|
Future<SunReserveInfoModel> setReserveInfo(BuildContext context) async {
|
|
|
|
UserModel userModel = Provider.of<UserModel>(context, listen: false);
|
|
|
|
String pnum = '6';
|
|
...
|
...
|
@@ -503,6 +504,7 @@ class NotebookDetailChangeModel with ChangeNotifier { |
|
|
|
String timeStr = ymyStr + ' ' + ddateStr + ':00';
|
|
|
|
// int start = DateUtil.getDateMsByTimeStr(timeStr);
|
|
|
|
|
|
|
|
LogUtil.v(timeStr);
|
|
|
|
// String tempDdate = ymyStr + ' ' + ddateStr + ':00';
|
|
|
|
int ddate = DateUtil.getDateMsByTimeStr(timeStr);
|
|
|
|
String tableSelectInfo = '';
|
|
...
|
...
|
@@ -534,17 +536,18 @@ class NotebookDetailChangeModel with ChangeNotifier { |
|
|
|
keys = 'night';
|
|
|
|
}
|
|
|
|
if (keys != '') {
|
|
|
|
String start = '${ddate}'.substring(0, 10);
|
|
|
|
List temp = dailyMap[keys];
|
|
|
|
String timeStrStart = ymyStr + ' ' + temp.first['title'] + ':00';
|
|
|
|
String timeStrEnd = ymyStr + ' ' + temp.last['title'] + ':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 = {
|
|
|
|
'is_set_ddate': isSetDate,
|
|
|
|
"sid": userModel.user.sellerid, //商家ID
|
|
|
|
"tid": tableSelectInfo, //桌子ID: 格式 2,3,4
|
|
|
|
"pnum": pnum, //预定用餐人数
|
|
...
|
...
|
@@ -552,9 +555,10 @@ class NotebookDetailChangeModel with ChangeNotifier { |
|
|
|
"sex": sex, //预订人姓名:1:男 2:女
|
|
|
|
"phone": phoneController.text, //预订人电话
|
|
|
|
"cusdem": customController.text, //预订人需求:25汉字
|
|
|
|
'note_name':userModel.user.account,
|
|
|
|
'type':"0",//内部预订
|
|
|
|
"rdate": rdate, //预定用餐时间范围:时间戳 开始时间戳(time)-结束时间戳(time)
|
|
|
|
"ddate": '${ddate}'.substring(0, 10), //到店时间
|
|
|
|
"ddate_solt": ddateSolt
|
|
|
|
};
|
|
|
|
if(detailEntity.id.isNotEmpty&&detailEntity.id!="-1"){
|
|
|
|
params['rid']=detailEntity.id;
|
|
...
|
...
|
@@ -578,7 +582,119 @@ class NotebookDetailChangeModel with ChangeNotifier { |
|
|
|
baseResp.responseData['data']['row'] != null) {
|
|
|
|
itemModel = ReserveInfoModel.fromJson(baseResp.responseData).data;
|
|
|
|
} else {
|
|
|
|
Utils.showToast(baseResp.msg ?? detailEntity.id=="-1"?"变更预订订单失败,请重试!":"变更预订订单失败,请重试!");
|
|
|
|
Utils.showToast(baseResp.msg ?? detailEntity.id=="-1"?"录入预订订单失败,请重试!":"变更预订订单失败,请重试!");
|
|
|
|
}
|
|
|
|
return itemModel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//更改在线预订
|
|
|
|
Future<SunReserveInfoModel> updateOnlineReserveInfo(BuildContext context) async {
|
|
|
|
UserModel userModel = Provider.of<UserModel>(context, listen: false);
|
|
|
|
String pnum = '6';
|
|
|
|
for (var item in personNumList) {
|
|
|
|
if (item['isSelect']) {
|
|
|
|
pnum = item['dateText'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (pnum == '') {
|
|
|
|
pnum = '6';
|
|
|
|
}
|
|
|
|
String sex = '1';
|
|
|
|
for (var item in sexList) {
|
|
|
|
if (item['select']) {
|
|
|
|
sex = item['code'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//当前选中 月 日string
|
|
|
|
String mdStr = '';
|
|
|
|
//今天 明天 其他天
|
|
|
|
for (var item in dateList) {
|
|
|
|
if (item['select'] == true) {
|
|
|
|
mdStr = item['title'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String timeNowYear = DateUtil.formatDate(DateTime.now(), format: 'yyyy');
|
|
|
|
String ymyStr = timeNowYear + '-' + mdStr; //年月日
|
|
|
|
String timeStr = ymyStr + ' ' + ddateStr + ':00';
|
|
|
|
// int start = DateUtil.getDateMsByTimeStr(timeStr);
|
|
|
|
|
|
|
|
// String tempDdate = ymyStr + ' ' + ddateStr + ':00';
|
|
|
|
int ddate = DateUtil.getDateMsByTimeStr(timeStr);
|
|
|
|
String tableSelectInfo = '';
|
|
|
|
for (TableList item in tableList) {
|
|
|
|
// if (item.selected) {
|
|
|
|
tableSelectInfo += ',${item.id}';
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
print(tableSelectInfo);
|
|
|
|
if (tableSelectInfo.startsWith(',')) {
|
|
|
|
tableSelectInfo = tableSelectInfo.substring(1);
|
|
|
|
}
|
|
|
|
print(tableSelectInfo);
|
|
|
|
String rdate = '';
|
|
|
|
String ddateSolt = '';
|
|
|
|
print(sunDateList);
|
|
|
|
for (var item in sunDateList) {
|
|
|
|
if (item['isSelect'] == true) {
|
|
|
|
String keys = '';
|
|
|
|
ddateSolt = '${item['ddateSolt']}';
|
|
|
|
if (item['ddateSolt'] == 1) {
|
|
|
|
//早市
|
|
|
|
keys = 'morning';
|
|
|
|
} else if (item['ddateSolt'] == 2) {
|
|
|
|
//午市
|
|
|
|
keys = 'noon';
|
|
|
|
} else if (item['ddateSolt'] == 3) {
|
|
|
|
//晚市
|
|
|
|
keys = 'night';
|
|
|
|
}
|
|
|
|
if (keys != '') {
|
|
|
|
List temp = dailyMap[keys];
|
|
|
|
String timeStrStart = ymyStr + ' ' + temp.first['title'] + ':00';
|
|
|
|
String timeStrEnd = ymyStr + ' ' + temp.last['title'] + ':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 = {
|
|
|
|
'is_set_ddate': isSetDate,
|
|
|
|
"sid": userModel.user.sellerid, //商家ID
|
|
|
|
"tid": tableSelectInfo, //桌子ID: 格式 2,3,4
|
|
|
|
"pnum": pnum, //预定用餐人数
|
|
|
|
"rname": nameController.text, //预订人姓名
|
|
|
|
"sex": sex, //预订人姓名:1:男 2:女
|
|
|
|
"phone": phoneController.text, //预订人电话
|
|
|
|
"cusdem": customController.text, //预订人需求:25汉字
|
|
|
|
'type':"1",//在线预订
|
|
|
|
"rdate": rdate, //预定用餐时间范围:时间戳 开始时间戳(time)-结束时间戳(time)
|
|
|
|
"ddate": '${ddate}'.substring(0, 10), //到店时间
|
|
|
|
"ddate_solt": ddateSolt
|
|
|
|
};
|
|
|
|
print(params);
|
|
|
|
BaseResp<Map<String, dynamic>> baseResp = await DioUtil()
|
|
|
|
.request<Map<String, dynamic>>(
|
|
|
|
context, Method.get, HttpUrl.set_customer_info,
|
|
|
|
data: params)
|
|
|
|
.catchError((error) {
|
|
|
|
print(error.toString());
|
|
|
|
});
|
|
|
|
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).data;
|
|
|
|
} else {
|
|
|
|
Utils.showToast(baseResp.msg ?? "变更预订订单失败,请重试!");
|
|
|
|
}
|
|
|
|
return itemModel;
|
|
|
|
}
|
...
|
...
|
|