|
...
|
...
|
@@ -12,6 +12,7 @@ import 'package:one_key/models/area_model.dart'; |
|
|
|
import 'package:one_key/models/guest_info_model.dart';
|
|
|
|
import 'package:one_key/models/notebook.dart';
|
|
|
|
import 'package:one_key/models/reserve_info_model.dart';
|
|
|
|
import 'package:one_key/models/seller_hide_conf_model.dart';
|
|
|
|
import 'package:one_key/models/tableOuter.dart';
|
|
|
|
import 'package:one_key/models/table_list.dart';
|
|
|
|
import 'package:one_key/net/base_resp.dart';
|
|
...
|
...
|
@@ -87,6 +88,8 @@ class TableManagerModelOrReserve with ChangeNotifier { |
|
|
|
|
|
|
|
List<TableListReserve> selectTablesOrReserve = []; //选择的桌位
|
|
|
|
|
|
|
|
List<SellerHideConfiSunModel>? sellerHideConfiData = [];
|
|
|
|
|
|
|
|
TableManagerModelOrReserve() {
|
|
|
|
// print('fdsfs');
|
|
|
|
|
|
...
|
...
|
@@ -148,6 +151,25 @@ class TableManagerModelOrReserve with ChangeNotifier { |
|
|
|
return '1';
|
|
|
|
}
|
|
|
|
|
|
|
|
//获取商家隐藏订单日期配置列表
|
|
|
|
Future<List<SellerHideConfiSunModel>?> getSellerHideConf(
|
|
|
|
BuildContext context) async {
|
|
|
|
try {
|
|
|
|
BaseResp<dynamic> baseResp = await DioUtil().request<dynamic>(
|
|
|
|
context, Method.get, HttpUrl.get_seller_hide_conf,
|
|
|
|
showLoading: false);
|
|
|
|
if (baseResp != null && baseResp.code == Constant.status_success) {
|
|
|
|
sellerHideConfiData = SellerHideConfiModel.fromJson(
|
|
|
|
baseResp.responseData as Map<String, dynamic>)
|
|
|
|
.data ??
|
|
|
|
[];
|
|
|
|
}
|
|
|
|
return sellerHideConfiData;
|
|
|
|
} catch (error) {
|
|
|
|
print(error.toString());
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 获取商家桌位列表及对应预订数据
|
|
|
|
|
|
|
|
Future<bool> getTableListOrReserve(
|
|
...
|
...
|
@@ -164,6 +186,12 @@ class TableManagerModelOrReserve with ChangeNotifier { |
|
|
|
// showLoading = true;
|
|
|
|
// }
|
|
|
|
|
|
|
|
if (Utils.isBeforeToday(datetime)) {
|
|
|
|
await getSellerHideConf(
|
|
|
|
context,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Map<String, String?> params = {
|
|
|
|
'sid': Provider.of<UserModel>(context, listen: false).user!.sellerid,
|
|
|
|
'x': '1',
|
|
...
|
...
|
@@ -185,6 +213,66 @@ class TableManagerModelOrReserve with ChangeNotifier { |
|
|
|
tablesOrReserveDataShow = TableListReseveModel.fromJson(
|
|
|
|
baseResp.responseData as Map<String, dynamic>)
|
|
|
|
.data;
|
|
|
|
//
|
|
|
|
// 处理
|
|
|
|
print(sellerHideConfiData);
|
|
|
|
int limitNum = -1;
|
|
|
|
if (sellerHideConfiData!.length > 0) {
|
|
|
|
int index = sellerHideConfiData!
|
|
|
|
.indexWhere((element) => element.sid == params['sid']);
|
|
|
|
if (index != -1) {
|
|
|
|
//存在配置
|
|
|
|
|
|
|
|
// "str": "3-2"
|
|
|
|
// 判断请求的日期是周一到周四还是其他
|
|
|
|
|
|
|
|
String str = sellerHideConfiData![index].str ?? '';
|
|
|
|
|
|
|
|
List<String> config = str.split('-');
|
|
|
|
|
|
|
|
if (datetime.weekday == 1 ||
|
|
|
|
datetime.weekday == 2 ||
|
|
|
|
datetime.weekday == 3 ||
|
|
|
|
datetime.weekday == 4) {
|
|
|
|
//周一到周四
|
|
|
|
|
|
|
|
limitNum = int.parse(config[0]);
|
|
|
|
} else {
|
|
|
|
limitNum = int.parse(config[1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (limitNum != -1) {
|
|
|
|
//存在配置
|
|
|
|
|
|
|
|
int sum = 0;
|
|
|
|
tablesOrReserveData?.forEach((element) {
|
|
|
|
element.tableList?.forEach((subelement) {
|
|
|
|
if (subelement.reserveList != null) {
|
|
|
|
sum++;
|
|
|
|
}
|
|
|
|
if (sum > limitNum) {
|
|
|
|
subelement.reserveList = null;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
int sumShow = 0;
|
|
|
|
tablesOrReserveDataShow?.forEach((element) {
|
|
|
|
element.tableList?.forEach((subelement) {
|
|
|
|
if (subelement.reserveList != null) {
|
|
|
|
sumShow++;
|
|
|
|
}
|
|
|
|
if (sumShow > limitNum) {
|
|
|
|
subelement.reserveList = null;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
if (tablesOrReserveData!.length == 0) {
|
|
|
|
pageStateOrReserve = PageState.Empty;
|
|
|
|
} else {
|
|
...
|
...
|
@@ -1771,8 +1859,7 @@ class TableManagerModelOrReserve with ChangeNotifier { |
|
|
|
}
|
|
|
|
|
|
|
|
//获取区域数据
|
|
|
|
Future<List<AreaSunModel>?> getRegionBySellerid(
|
|
|
|
BuildContext context) async {
|
|
|
|
Future<List<AreaSunModel>?> getRegionBySellerid(BuildContext context) async {
|
|
|
|
Map<String, String?> params = {
|
|
|
|
"sellerid": Provider.of<UserModel>(context, listen: false).user!.sellerid
|
|
|
|
};
|
...
|
...
|
|