|
...
|
...
|
@@ -24,9 +24,9 @@ class NotebookDetailChangeModel with ChangeNotifier { |
|
|
|
TextEditingController customController = TextEditingController(); //客户要求
|
|
|
|
List sexList = []; // 先生、女士、公司
|
|
|
|
Map dailyMap = {}; // 早市对应半点钟,午市对应半点钟、晚市对应半点钟
|
|
|
|
List<String> mornings=[];//早市时间段
|
|
|
|
List<String> noons=[];//午市时间段
|
|
|
|
List<String> nights=[];//晚市时间段
|
|
|
|
List<String> mornings = []; //早市时间段
|
|
|
|
List<String> noons = []; //午市时间段
|
|
|
|
List<String> nights = []; //晚市时间段
|
|
|
|
String ddateStr = ''; //16:30
|
|
|
|
NotebookDetail detailEntity;
|
|
|
|
List<TableList> tableList = [];
|
|
...
|
...
|
@@ -233,7 +233,7 @@ class NotebookDetailChangeModel with ChangeNotifier { |
|
|
|
|
|
|
|
/// 早市、午市、晚市对应的半个小时间隔时间段
|
|
|
|
initDateHourMinuteList(BuildContext context) async {
|
|
|
|
UserModel userModel=Provider.of<UserModel>(context);
|
|
|
|
UserModel userModel = Provider.of<UserModel>(context, listen: false);
|
|
|
|
userModel.user.morning == ''
|
|
|
|
? dailyMap.putIfAbsent('morning', () => '')
|
|
|
|
: dailyMap.putIfAbsent(
|
|
...
|
...
|
@@ -247,12 +247,12 @@ class NotebookDetailChangeModel with ChangeNotifier { |
|
|
|
: dailyMap.putIfAbsent(
|
|
|
|
'night', () => _getHourAndMinute(userModel.user.night, 3));
|
|
|
|
|
|
|
|
_initSunDateList(userModel.user.morning, userModel.user.noon, userModel.user.night);
|
|
|
|
_initSunDateList(
|
|
|
|
userModel.user.morning, userModel.user.noon, userModel.user.night);
|
|
|
|
}
|
|
|
|
|
|
|
|
//根据获取时间 11:00-12:30 获取30分钟间隔组装的数组
|
|
|
|
_getHourAndMinute(
|
|
|
|
String hourAndMinuteStr, int mnd) {
|
|
|
|
_getHourAndMinute(String hourAndMinuteStr, int mnd) {
|
|
|
|
List tempDate = hourAndMinuteStr.split("-");
|
|
|
|
String beginDate = tempDate[0];
|
|
|
|
String endDate = tempDate[1];
|
|
...
|
...
|
@@ -267,11 +267,14 @@ class NotebookDetailChangeModel with ChangeNotifier { |
|
|
|
bool tempLimit = true;
|
|
|
|
while (tempLimit) {
|
|
|
|
String temp = _dealTime(beginHour, beginMinute);
|
|
|
|
if(mnd==1){//早市
|
|
|
|
if (mnd == 1) {
|
|
|
|
//早市
|
|
|
|
mornings.add(temp);
|
|
|
|
}else if(mnd==2){//午市
|
|
|
|
} else if (mnd == 2) {
|
|
|
|
//午市
|
|
|
|
noons.add(temp);
|
|
|
|
}else if(mnd==3){//晚市
|
|
|
|
} else if (mnd == 3) {
|
|
|
|
//晚市
|
|
|
|
nights.add(temp);
|
|
|
|
}
|
|
|
|
bool tempSelect = false;
|
|
...
|
...
|
@@ -313,8 +316,8 @@ class NotebookDetailChangeModel with ChangeNotifier { |
|
|
|
}
|
|
|
|
|
|
|
|
//初始化早市午市晚市选中时间
|
|
|
|
initHourAndMinuteSelect(){
|
|
|
|
int timeMillsNow=DateTime.now().millisecondsSinceEpoch;
|
|
|
|
initHourAndMinuteSelect() {
|
|
|
|
int timeMillsNow = DateTime.now().millisecondsSinceEpoch;
|
|
|
|
//当前选中 月 日string
|
|
|
|
String mdStr = '';
|
|
|
|
//今天 明天 其他天
|
|
...
|
...
|
@@ -325,55 +328,70 @@ class NotebookDetailChangeModel with ChangeNotifier { |
|
|
|
}
|
|
|
|
String timeNowYear = DateUtil.formatDate(DateTime.now(), format: 'yyyy');
|
|
|
|
String ymyStr = timeNowYear + '-' + mdStr; //年月日
|
|
|
|
String timeStr = ymyStr+' 00:00:00';
|
|
|
|
String timeStr = ymyStr + ' 00:00:00';
|
|
|
|
LogUtil.v(timeStr);
|
|
|
|
DateTime dateTime=DateUtil.getDateTime(timeStr);//当前年月日
|
|
|
|
for(var sunDate in sunDateList){
|
|
|
|
if(sunDate['isSelect']==false)continue;
|
|
|
|
switch(sunDate['key']){
|
|
|
|
case "morning"://选中早市
|
|
|
|
bool select=false;
|
|
|
|
for(var temp in dailyMap['morning']){//早市选中距离当前时间最近
|
|
|
|
temp['select']=false;
|
|
|
|
if(select)continue;//只选中第一个
|
|
|
|
if(timeMillsNow<=DateUtil.getDateMsByTimeStr(DateUtil.formatDate(dateTime).replaceRange(11,19, "${temp['title']}:00"))){
|
|
|
|
temp['select']=true;
|
|
|
|
select=true;
|
|
|
|
DateTime dateTime = DateUtil.getDateTime(timeStr); //当前年月日
|
|
|
|
for (var sunDate in sunDateList) {
|
|
|
|
if (sunDate['isSelect'] == false) continue;
|
|
|
|
switch (sunDate['key']) {
|
|
|
|
case "morning": //选中早市
|
|
|
|
bool select = false;
|
|
|
|
for (var temp in dailyMap['morning']) {
|
|
|
|
//早市选中距离当前时间最近
|
|
|
|
temp['select'] = false;
|
|
|
|
if (select) continue; //只选中第一个
|
|
|
|
if (timeMillsNow <=
|
|
|
|
DateUtil.getDateMsByTimeStr(DateUtil.formatDate(dateTime)
|
|
|
|
.replaceRange(11, 19, "${temp['title']}:00"))) {
|
|
|
|
temp['select'] = true;
|
|
|
|
select = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case "noon"://选中午市
|
|
|
|
bool select=false;
|
|
|
|
for(var temp in dailyMap['noon']){//午市选中12:30
|
|
|
|
temp['select']=false;
|
|
|
|
if(select)continue;
|
|
|
|
if(noons.contains("12:30")&&timeMillsNow<=DateUtil.getDateMsByTimeStr(DateUtil.formatDate(dateTime).replaceRange(11,19, "12:30:00"))){
|
|
|
|
if(temp['title']=="12:30"){
|
|
|
|
temp['select']=true;
|
|
|
|
select=true;
|
|
|
|
case "noon": //选中午市
|
|
|
|
bool select = false;
|
|
|
|
for (var temp in dailyMap['noon']) {
|
|
|
|
//午市选中12:30
|
|
|
|
temp['select'] = false;
|
|
|
|
if (select) continue;
|
|
|
|
if (noons.contains("12:30") &&
|
|
|
|
timeMillsNow <=
|
|
|
|
DateUtil.getDateMsByTimeStr(DateUtil.formatDate(dateTime)
|
|
|
|
.replaceRange(11, 19, "12:30:00"))) {
|
|
|
|
if (temp['title'] == "12:30") {
|
|
|
|
temp['select'] = true;
|
|
|
|
select = true;
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
if(timeMillsNow<=DateUtil.getDateMsByTimeStr(DateUtil.formatDate(dateTime).replaceRange(11,19, "${temp['title']}:00"))){
|
|
|
|
temp['select']=true;
|
|
|
|
select=true;
|
|
|
|
} else {
|
|
|
|
if (timeMillsNow <=
|
|
|
|
DateUtil.getDateMsByTimeStr(DateUtil.formatDate(dateTime)
|
|
|
|
.replaceRange(11, 19, "${temp['title']}:00"))) {
|
|
|
|
temp['select'] = true;
|
|
|
|
select = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case "night"://选中晚市
|
|
|
|
bool select=false;
|
|
|
|
for(var temp in dailyMap['night']){//晚市选中18:30
|
|
|
|
temp['select']=false;
|
|
|
|
if(select)continue;
|
|
|
|
if(nights.contains("18:30")&&timeMillsNow<=DateUtil.getDateMsByTimeStr(DateUtil.formatDate(dateTime).replaceRange(11,19, "18:30:00"))){
|
|
|
|
if(temp['title']=="18:30"){
|
|
|
|
temp['select']=true;
|
|
|
|
select=true;
|
|
|
|
case "night": //选中晚市
|
|
|
|
bool select = false;
|
|
|
|
for (var temp in dailyMap['night']) {
|
|
|
|
//晚市选中18:30
|
|
|
|
temp['select'] = false;
|
|
|
|
if (select) continue;
|
|
|
|
if (nights.contains("18:30") &&
|
|
|
|
timeMillsNow <=
|
|
|
|
DateUtil.getDateMsByTimeStr(DateUtil.formatDate(dateTime)
|
|
|
|
.replaceRange(11, 19, "18:30:00"))) {
|
|
|
|
if (temp['title'] == "18:30") {
|
|
|
|
temp['select'] = true;
|
|
|
|
select = true;
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
if(timeMillsNow<=DateUtil.getDateMsByTimeStr(DateUtil.formatDate(dateTime).replaceRange(11,19, "${temp['title']}:00"))){
|
|
|
|
temp['select']=true;
|
|
|
|
select=true;
|
|
|
|
} else {
|
|
|
|
if (timeMillsNow <=
|
|
|
|
DateUtil.getDateMsByTimeStr(DateUtil.formatDate(dateTime)
|
|
|
|
.replaceRange(11, 19, "${temp['title']}:00"))) {
|
|
|
|
temp['select'] = true;
|
|
|
|
select = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
...
|
...
|
@@ -444,8 +462,8 @@ class NotebookDetailChangeModel with ChangeNotifier { |
|
|
|
'ddate_solt': ddate_solt,
|
|
|
|
'pnum': pnum
|
|
|
|
};
|
|
|
|
if(detailEntity.id.isNotEmpty&&detailEntity.id!="-1"){
|
|
|
|
params['rid']=detailEntity.id;
|
|
|
|
if (detailEntity.id.isNotEmpty && detailEntity.id != "-1") {
|
|
|
|
params['rid'] = detailEntity.id;
|
|
|
|
}
|
|
|
|
BaseResp<dynamic> baseResp = await DioUtil()
|
|
|
|
.request<dynamic>(context, Method.get, HttpUrl.get_table_list,
|
|
...
|
...
|
@@ -623,7 +641,7 @@ class NotebookDetailChangeModel with ChangeNotifier { |
|
|
|
String timeStrEnd = ymyStr + ' ' + temp.last['title'] + ':00';
|
|
|
|
int startM = DateUtil.getDateMsByTimeStr(timeStrStart);
|
|
|
|
int endM = DateUtil.getDateMsByTimeStr(timeStrEnd);
|
|
|
|
String start='${startM}'.substring(0, 10);
|
|
|
|
String start = '${startM}'.substring(0, 10);
|
|
|
|
String end = '${endM}'.substring(0, 10);
|
|
|
|
rdate = start + '-' + end;
|
|
|
|
}
|
|
...
|
...
|
@@ -637,14 +655,14 @@ class NotebookDetailChangeModel with ChangeNotifier { |
|
|
|
"sex": sex, //预订人姓名:1:男 2:女
|
|
|
|
"phone": phoneController.text, //预订人电话
|
|
|
|
"cusdem": customController.text, //预订人需求:25汉字
|
|
|
|
'note_name':userModel.user.account,
|
|
|
|
'type':"0",//内部预订
|
|
|
|
'note_name': userModel.user.account,
|
|
|
|
'type': "0", //内部预订
|
|
|
|
"rdate": rdate, //预定用餐时间范围:时间戳 开始时间戳(time)-结束时间戳(time)
|
|
|
|
"ddate": '${ddate}'.substring(0, 10), //到店时间
|
|
|
|
'is_set_ddate':"1"
|
|
|
|
'is_set_ddate': "1"
|
|
|
|
};
|
|
|
|
if(detailEntity.id.isNotEmpty&&detailEntity.id!="-1"){
|
|
|
|
params['rid']=detailEntity.id;
|
|
|
|
if (detailEntity.id.isNotEmpty && detailEntity.id != "-1") {
|
|
|
|
params['rid'] = detailEntity.id;
|
|
|
|
}
|
|
|
|
print(params);
|
|
|
|
BaseResp<Map<String, dynamic>> baseResp = await DioUtil()
|
|
...
|
...
|
@@ -665,14 +683,17 @@ 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 {
|
|
|
|
Future<SunReserveInfoModel> updateOnlineReserveInfo(
|
|
|
|
BuildContext context) async {
|
|
|
|
UserModel userModel = Provider.of<UserModel>(context, listen: false);
|
|
|
|
String pnum = '6';
|
|
|
|
for (var item in personNumList) {
|
|
...
|
...
|
@@ -738,14 +759,14 @@ class NotebookDetailChangeModel with ChangeNotifier { |
|
|
|
String timeStrEnd = ymyStr + ' ' + temp.last['title'] + ':00';
|
|
|
|
int startM = DateUtil.getDateMsByTimeStr(timeStrStart);
|
|
|
|
int endM = DateUtil.getDateMsByTimeStr(timeStrEnd);
|
|
|
|
String start='${startM}'.substring(0, 10);
|
|
|
|
String start = '${startM}'.substring(0, 10);
|
|
|
|
String end = '${endM}'.substring(0, 10);
|
|
|
|
rdate = start + '-' + end;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Map<String, String> params = {
|
|
|
|
"rid":detailEntity.id,
|
|
|
|
"rid": detailEntity.id,
|
|
|
|
'is_set_ddate': isSetDate,
|
|
|
|
"sid": userModel.user.sellerid, //商家ID
|
|
|
|
"tid": tableSelectInfo, //桌子ID: 格式 2,3,4
|
|
...
|
...
|
@@ -754,7 +775,7 @@ class NotebookDetailChangeModel with ChangeNotifier { |
|
|
|
"sex": sex, //预订人姓名:1:男 2:女
|
|
|
|
"phone": phoneController.text, //预订人电话
|
|
|
|
"cusdem": customController.text, //预订人需求:25汉字
|
|
|
|
"type":"0",
|
|
|
|
"type": "0",
|
|
|
|
"rdate": rdate, //预定用餐时间范围:时间戳 开始时间戳(time)-结束时间戳(time)
|
|
|
|
"ddate": '${ddate}'.substring(0, 10), //到店时间
|
|
|
|
"ddate_solt": ddateSolt
|
|
...
|
...
|
@@ -762,8 +783,8 @@ class NotebookDetailChangeModel with ChangeNotifier { |
|
|
|
print(params);
|
|
|
|
BaseResp<Map<String, dynamic>> baseResp = await DioUtil()
|
|
|
|
.request<Map<String, dynamic>>(
|
|
|
|
context, Method.get, HttpUrl.set_customer_info,
|
|
|
|
data: params)
|
|
|
|
context, Method.get, HttpUrl.set_customer_info,
|
|
|
|
data: params)
|
|
|
|
.catchError((error) {
|
|
|
|
print(error.toString());
|
|
|
|
});
|
...
|
...
|
|