Showing
6 changed files
with
245 additions
and
12 deletions
lib/models/seller_hide_conf_model.dart
0 → 100644
| 1 | + | ||
| 2 | +class SellerHideConfiModel { | ||
| 3 | + int? ret; | ||
| 4 | + List<SellerHideConfiSunModel>? data; | ||
| 5 | + String? msg; | ||
| 6 | + | ||
| 7 | + SellerHideConfiModel({this.ret, this.data, this.msg}); | ||
| 8 | + | ||
| 9 | + SellerHideConfiModel.fromJson(Map<String, dynamic> json) { | ||
| 10 | + if(json["ret"] is int) { | ||
| 11 | + ret = json["ret"]; | ||
| 12 | + } | ||
| 13 | + if(json["data"] is List) { | ||
| 14 | + data = json["data"] == null ? null : (json["data"] as List).map((e) => SellerHideConfiSunModel.fromJson(e)).toList(); | ||
| 15 | + } | ||
| 16 | + if(json["msg"] is String) { | ||
| 17 | + msg = json["msg"]; | ||
| 18 | + } | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + static List<SellerHideConfiModel> fromList(List<Map<String, dynamic>> list) { | ||
| 22 | + return list.map(SellerHideConfiModel.fromJson).toList(); | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + Map<String, dynamic> toJson() { | ||
| 26 | + final Map<String, dynamic> _data = <String, dynamic>{}; | ||
| 27 | + _data["ret"] = ret; | ||
| 28 | + if(data != null) { | ||
| 29 | + _data["data"] = data?.map((e) => e.toJson()).toList(); | ||
| 30 | + } | ||
| 31 | + _data["msg"] = msg; | ||
| 32 | + return _data; | ||
| 33 | + } | ||
| 34 | +} | ||
| 35 | + | ||
| 36 | +class SellerHideConfiSunModel { | ||
| 37 | + String? id; | ||
| 38 | + String? sid; | ||
| 39 | + String? str; | ||
| 40 | + | ||
| 41 | + SellerHideConfiSunModel({this.id, this.sid, this.str}); | ||
| 42 | + | ||
| 43 | + SellerHideConfiSunModel.fromJson(Map<String, dynamic> json) { | ||
| 44 | + if(json["id"] is String) { | ||
| 45 | + id = json["id"]; | ||
| 46 | + } | ||
| 47 | + if(json["sid"] is String) { | ||
| 48 | + sid = json["sid"]; | ||
| 49 | + } | ||
| 50 | + if(json["str"] is String) { | ||
| 51 | + str = json["str"]; | ||
| 52 | + } | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + static List<SellerHideConfiSunModel> fromList(List<Map<String, dynamic>> list) { | ||
| 56 | + return list.map(SellerHideConfiSunModel.fromJson).toList(); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + Map<String, dynamic> toJson() { | ||
| 60 | + final Map<String, dynamic> _data = <String, dynamic>{}; | ||
| 61 | + _data["id"] = id; | ||
| 62 | + _data["sid"] = sid; | ||
| 63 | + _data["str"] = str; | ||
| 64 | + return _data; | ||
| 65 | + } | ||
| 66 | +} |
| @@ -640,6 +640,12 @@ class HttpUrl { | @@ -640,6 +640,12 @@ class HttpUrl { | ||
| 640 | "?service=App.PayOnline.RechargeRefundApply"; // 新版购买优惠券退款(会员充值退款) | 640 | "?service=App.PayOnline.RechargeRefundApply"; // 新版购买优惠券退款(会员充值退款) |
| 641 | 641 | ||
| 642 | 642 | ||
| 643 | +static const get_seller_hide_conf= | ||
| 644 | + "?service=App.Seller.GetSellerHideConf"; // 获取商家隐藏订单日期配置列表 | ||
| 645 | + | ||
| 646 | + | ||
| 647 | + | ||
| 648 | + | ||
| 643 | 649 | ||
| 644 | 650 | ||
| 645 | 651 |
| @@ -349,6 +349,12 @@ class NoteBookPageState extends State<NoteBookPage> { | @@ -349,6 +349,12 @@ class NoteBookPageState extends State<NoteBookPage> { | ||
| 349 | 349 | ||
| 350 | //获取已预订列表 | 350 | //获取已预订列表 |
| 351 | _getReserveList({bool needLoading = false, bool showLoading = true}) async { | 351 | _getReserveList({bool needLoading = false, bool showLoading = true}) async { |
| 352 | + if (Utils.isBeforeToday(dateTimeNow!)) { | ||
| 353 | + await noteBookModel.getSellerHideConf( | ||
| 354 | + context, | ||
| 355 | + ); | ||
| 356 | + } | ||
| 357 | + | ||
| 352 | Map<String, String?> params = { | 358 | Map<String, String?> params = { |
| 353 | "sid": userModel.user!.sellerid, | 359 | "sid": userModel.user!.sellerid, |
| 354 | "rdate": _getRdate(), | 360 | "rdate": _getRdate(), |
| @@ -362,7 +368,7 @@ class NoteBookPageState extends State<NoteBookPage> { | @@ -362,7 +368,7 @@ class NoteBookPageState extends State<NoteBookPage> { | ||
| 362 | params["account"] = userModel.user!.account; | 368 | params["account"] = userModel.user!.account; |
| 363 | } | 369 | } |
| 364 | 370 | ||
| 365 | - await noteBookModel.getReserveListSort(context, params, | 371 | + await noteBookModel.getReserveListSort(context, params, dateTimeNow!, |
| 366 | needLoading: needLoading, showLoading: showLoading); | 372 | needLoading: needLoading, showLoading: showLoading); |
| 367 | // _simpleState(); | 373 | // _simpleState(); |
| 368 | } | 374 | } |
| @@ -1754,13 +1760,13 @@ class NoteBookPageState extends State<NoteBookPage> { | @@ -1754,13 +1760,13 @@ class NoteBookPageState extends State<NoteBookPage> { | ||
| 1754 | ) { | 1760 | ) { |
| 1755 | if (!Utils.isOneDay(day, dateTimeNow!)) { | 1761 | if (!Utils.isOneDay(day, dateTimeNow!)) { |
| 1756 | //不是一天 | 1762 | //不是一天 |
| 1757 | - day = DateTime( | ||
| 1758 | - day.year, | ||
| 1759 | - day.month, | ||
| 1760 | - day.day, | ||
| 1761 | - DateTime.now().hour, | ||
| 1762 | - DateTime.now().minute, | ||
| 1763 | - DateTime.now().second); | 1763 | + day = DateTime( |
| 1764 | + day.year, | ||
| 1765 | + day.month, | ||
| 1766 | + day.day, | ||
| 1767 | + DateTime.now().hour, | ||
| 1768 | + DateTime.now().minute, | ||
| 1769 | + DateTime.now().second); | ||
| 1764 | dateTimeNow = day; | 1770 | dateTimeNow = day; |
| 1765 | _focusedDay = dateTimeNow; | 1771 | _focusedDay = dateTimeNow; |
| 1766 | clearSel = false; | 1772 | clearSel = false; |
| @@ -5,6 +5,7 @@ import 'package:one_key/constant/constant.dart'; | @@ -5,6 +5,7 @@ import 'package:one_key/constant/constant.dart'; | ||
| 5 | import 'package:one_key/constant/error.dart'; | 5 | import 'package:one_key/constant/error.dart'; |
| 6 | import 'package:one_key/constant/state.dart'; | 6 | import 'package:one_key/constant/state.dart'; |
| 7 | import 'package:one_key/models/notebook.dart'; | 7 | import 'package:one_key/models/notebook.dart'; |
| 8 | +import 'package:one_key/models/seller_hide_conf_model.dart'; | ||
| 8 | import 'package:one_key/net/base_resp.dart'; | 9 | import 'package:one_key/net/base_resp.dart'; |
| 9 | import 'package:one_key/net/dio_util.dart'; | 10 | import 'package:one_key/net/dio_util.dart'; |
| 10 | import 'package:one_key/net/http_url.dart'; | 11 | import 'package:one_key/net/http_url.dart'; |
| @@ -29,6 +30,28 @@ class NoteBookModel extends ChangeNotifier { | @@ -29,6 +30,28 @@ class NoteBookModel extends ChangeNotifier { | ||
| 29 | bool isSimple = true; | 30 | bool isSimple = true; |
| 30 | List<NoteBookOnlySunModel>? notebooksSort = []; | 31 | List<NoteBookOnlySunModel>? notebooksSort = []; |
| 31 | 32 | ||
| 33 | + List<SellerHideConfiSunModel>? sellerHideConfiData = []; | ||
| 34 | + | ||
| 35 | + //获取商家隐藏订单日期配置列表 | ||
| 36 | + Future<List<SellerHideConfiSunModel>?> getSellerHideConf( | ||
| 37 | + BuildContext context) async { | ||
| 38 | + try { | ||
| 39 | + BaseResp<dynamic> baseResp = await DioUtil().request<dynamic>( | ||
| 40 | + context, Method.get, HttpUrl.get_seller_hide_conf, | ||
| 41 | + showLoading: false); | ||
| 42 | + if (baseResp != null && baseResp.code == Constant.status_success) { | ||
| 43 | + sellerHideConfiData = SellerHideConfiModel.fromJson( | ||
| 44 | + baseResp.responseData as Map<String, dynamic>) | ||
| 45 | + .data ?? | ||
| 46 | + []; | ||
| 47 | + } | ||
| 48 | + return sellerHideConfiData; | ||
| 49 | + } catch (error) { | ||
| 50 | + print(error.toString()); | ||
| 51 | + return []; | ||
| 52 | + } | ||
| 53 | + } | ||
| 54 | + | ||
| 32 | //获取已预订订单 | 55 | //获取已预订订单 |
| 33 | getReserveList(BuildContext context, Map<String, String?> params, | 56 | getReserveList(BuildContext context, Map<String, String?> params, |
| 34 | {bool needLoading = false, bool showLoading = true}) async { | 57 | {bool needLoading = false, bool showLoading = true}) async { |
| @@ -92,7 +115,7 @@ class NoteBookModel extends ChangeNotifier { | @@ -92,7 +115,7 @@ class NoteBookModel extends ChangeNotifier { | ||
| 92 | 115 | ||
| 93 | //获取已预订订单 | 116 | //获取已预订订单 |
| 94 | Future<List<NoteBookOnlySunModel>?> getReserveListSort( | 117 | Future<List<NoteBookOnlySunModel>?> getReserveListSort( |
| 95 | - BuildContext context, Map<String, String?> params, | 118 | + BuildContext context, Map<String, String?> params, DateTime now, |
| 96 | {bool needLoading = false, bool showLoading = true}) async { | 119 | {bool needLoading = false, bool showLoading = true}) async { |
| 97 | if (needLoading) { | 120 | if (needLoading) { |
| 98 | pageState = PageState.Loading; | 121 | pageState = PageState.Loading; |
| @@ -106,11 +129,50 @@ class NoteBookModel extends ChangeNotifier { | @@ -106,11 +129,50 @@ class NoteBookModel extends ChangeNotifier { | ||
| 106 | context, Method.get, HttpUrl.get_reserve_list_also_order, | 129 | context, Method.get, HttpUrl.get_reserve_list_also_order, |
| 107 | data: params, showLoading: needLoading ? false : showLoading); | 130 | data: params, showLoading: needLoading ? false : showLoading); |
| 108 | if (baseResp == null) return null; | 131 | if (baseResp == null) return null; |
| 132 | + | ||
| 133 | + List<NoteBookOnlySunModel>? tempSort = []; | ||
| 109 | notebooksSort = []; | 134 | notebooksSort = []; |
| 110 | if (baseResp.code == Constant.status_success) { | 135 | if (baseResp.code == Constant.status_success) { |
| 111 | - notebooksSort = NoteBookOnlyModel.fromJson( | 136 | + print(sellerHideConfiData); |
| 137 | + int limitNum = -1; | ||
| 138 | + if (sellerHideConfiData!.length > 0) { | ||
| 139 | + int index = sellerHideConfiData! | ||
| 140 | + .indexWhere((element) => element.sid == params['sid']); | ||
| 141 | + if (index != -1) { | ||
| 142 | + //存在配置 | ||
| 143 | + | ||
| 144 | + // "str": "3-2" | ||
| 145 | + // 判断请求的日期是周一到周四还是其他 | ||
| 146 | + | ||
| 147 | + String str = sellerHideConfiData![index].str ?? ''; | ||
| 148 | + | ||
| 149 | + List<String> config = str.split('-'); | ||
| 150 | + | ||
| 151 | + if (now.weekday == 1 || | ||
| 152 | + now.weekday == 2 || | ||
| 153 | + now.weekday == 3 || | ||
| 154 | + now.weekday == 4) { | ||
| 155 | + //周一到周四 | ||
| 156 | + | ||
| 157 | + limitNum = int.parse(config[0]); | ||
| 158 | + } else { | ||
| 159 | + limitNum = int.parse(config[1]); | ||
| 160 | + } | ||
| 161 | + } | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + tempSort = NoteBookOnlyModel.fromJson( | ||
| 112 | baseResp.responseData as Map<String, dynamic>) | 165 | baseResp.responseData as Map<String, dynamic>) |
| 113 | .data; | 166 | .data; |
| 167 | + if (limitNum != -1) { | ||
| 168 | + if (tempSort!.length > limitNum) { | ||
| 169 | + notebooksSort = tempSort.sublist(0, limitNum); | ||
| 170 | + } else { | ||
| 171 | + notebooksSort = tempSort; | ||
| 172 | + } | ||
| 173 | + } else { | ||
| 174 | + notebooksSort = tempSort; | ||
| 175 | + } | ||
| 114 | 176 | ||
| 115 | if (notebooksSort!.isEmpty) { | 177 | if (notebooksSort!.isEmpty) { |
| 116 | pageState = PageState.Empty; | 178 | pageState = PageState.Empty; |
| @@ -12,6 +12,7 @@ import 'package:one_key/models/area_model.dart'; | @@ -12,6 +12,7 @@ import 'package:one_key/models/area_model.dart'; | ||
| 12 | import 'package:one_key/models/guest_info_model.dart'; | 12 | import 'package:one_key/models/guest_info_model.dart'; |
| 13 | import 'package:one_key/models/notebook.dart'; | 13 | import 'package:one_key/models/notebook.dart'; |
| 14 | import 'package:one_key/models/reserve_info_model.dart'; | 14 | import 'package:one_key/models/reserve_info_model.dart'; |
| 15 | +import 'package:one_key/models/seller_hide_conf_model.dart'; | ||
| 15 | import 'package:one_key/models/tableOuter.dart'; | 16 | import 'package:one_key/models/tableOuter.dart'; |
| 16 | import 'package:one_key/models/table_list.dart'; | 17 | import 'package:one_key/models/table_list.dart'; |
| 17 | import 'package:one_key/net/base_resp.dart'; | 18 | import 'package:one_key/net/base_resp.dart'; |
| @@ -87,6 +88,8 @@ class TableManagerModelOrReserve with ChangeNotifier { | @@ -87,6 +88,8 @@ class TableManagerModelOrReserve with ChangeNotifier { | ||
| 87 | 88 | ||
| 88 | List<TableListReserve> selectTablesOrReserve = []; //选择的桌位 | 89 | List<TableListReserve> selectTablesOrReserve = []; //选择的桌位 |
| 89 | 90 | ||
| 91 | + List<SellerHideConfiSunModel>? sellerHideConfiData = []; | ||
| 92 | + | ||
| 90 | TableManagerModelOrReserve() { | 93 | TableManagerModelOrReserve() { |
| 91 | // print('fdsfs'); | 94 | // print('fdsfs'); |
| 92 | 95 | ||
| @@ -148,6 +151,25 @@ class TableManagerModelOrReserve with ChangeNotifier { | @@ -148,6 +151,25 @@ class TableManagerModelOrReserve with ChangeNotifier { | ||
| 148 | return '1'; | 151 | return '1'; |
| 149 | } | 152 | } |
| 150 | 153 | ||
| 154 | + //获取商家隐藏订单日期配置列表 | ||
| 155 | + Future<List<SellerHideConfiSunModel>?> getSellerHideConf( | ||
| 156 | + BuildContext context) async { | ||
| 157 | + try { | ||
| 158 | + BaseResp<dynamic> baseResp = await DioUtil().request<dynamic>( | ||
| 159 | + context, Method.get, HttpUrl.get_seller_hide_conf, | ||
| 160 | + showLoading: false); | ||
| 161 | + if (baseResp != null && baseResp.code == Constant.status_success) { | ||
| 162 | + sellerHideConfiData = SellerHideConfiModel.fromJson( | ||
| 163 | + baseResp.responseData as Map<String, dynamic>) | ||
| 164 | + .data ?? | ||
| 165 | + []; | ||
| 166 | + } | ||
| 167 | + return sellerHideConfiData; | ||
| 168 | + } catch (error) { | ||
| 169 | + print(error.toString()); | ||
| 170 | + return []; | ||
| 171 | + } | ||
| 172 | + } | ||
| 151 | // 获取商家桌位列表及对应预订数据 | 173 | // 获取商家桌位列表及对应预订数据 |
| 152 | 174 | ||
| 153 | Future<bool> getTableListOrReserve( | 175 | Future<bool> getTableListOrReserve( |
| @@ -164,6 +186,12 @@ class TableManagerModelOrReserve with ChangeNotifier { | @@ -164,6 +186,12 @@ class TableManagerModelOrReserve with ChangeNotifier { | ||
| 164 | // showLoading = true; | 186 | // showLoading = true; |
| 165 | // } | 187 | // } |
| 166 | 188 | ||
| 189 | + if (Utils.isBeforeToday(datetime)) { | ||
| 190 | + await getSellerHideConf( | ||
| 191 | + context, | ||
| 192 | + ); | ||
| 193 | + } | ||
| 194 | + | ||
| 167 | Map<String, String?> params = { | 195 | Map<String, String?> params = { |
| 168 | 'sid': Provider.of<UserModel>(context, listen: false).user!.sellerid, | 196 | 'sid': Provider.of<UserModel>(context, listen: false).user!.sellerid, |
| 169 | 'x': '1', | 197 | 'x': '1', |
| @@ -185,6 +213,66 @@ class TableManagerModelOrReserve with ChangeNotifier { | @@ -185,6 +213,66 @@ class TableManagerModelOrReserve with ChangeNotifier { | ||
| 185 | tablesOrReserveDataShow = TableListReseveModel.fromJson( | 213 | tablesOrReserveDataShow = TableListReseveModel.fromJson( |
| 186 | baseResp.responseData as Map<String, dynamic>) | 214 | baseResp.responseData as Map<String, dynamic>) |
| 187 | .data; | 215 | .data; |
| 216 | + // | ||
| 217 | + // 处理 | ||
| 218 | + print(sellerHideConfiData); | ||
| 219 | + int limitNum = -1; | ||
| 220 | + if (sellerHideConfiData!.length > 0) { | ||
| 221 | + int index = sellerHideConfiData! | ||
| 222 | + .indexWhere((element) => element.sid == params['sid']); | ||
| 223 | + if (index != -1) { | ||
| 224 | + //存在配置 | ||
| 225 | + | ||
| 226 | + // "str": "3-2" | ||
| 227 | + // 判断请求的日期是周一到周四还是其他 | ||
| 228 | + | ||
| 229 | + String str = sellerHideConfiData![index].str ?? ''; | ||
| 230 | + | ||
| 231 | + List<String> config = str.split('-'); | ||
| 232 | + | ||
| 233 | + if (datetime.weekday == 1 || | ||
| 234 | + datetime.weekday == 2 || | ||
| 235 | + datetime.weekday == 3 || | ||
| 236 | + datetime.weekday == 4) { | ||
| 237 | + //周一到周四 | ||
| 238 | + | ||
| 239 | + limitNum = int.parse(config[0]); | ||
| 240 | + } else { | ||
| 241 | + limitNum = int.parse(config[1]); | ||
| 242 | + } | ||
| 243 | + } | ||
| 244 | + } | ||
| 245 | + | ||
| 246 | + if (limitNum != -1) { | ||
| 247 | + //存在配置 | ||
| 248 | + | ||
| 249 | + int sum = 0; | ||
| 250 | + tablesOrReserveData?.forEach((element) { | ||
| 251 | + element.tableList?.forEach((subelement) { | ||
| 252 | + if (subelement.reserveList != null) { | ||
| 253 | + sum++; | ||
| 254 | + } | ||
| 255 | + if (sum > limitNum) { | ||
| 256 | + subelement.reserveList = null; | ||
| 257 | + } | ||
| 258 | + }); | ||
| 259 | + }); | ||
| 260 | + | ||
| 261 | + int sumShow = 0; | ||
| 262 | + tablesOrReserveDataShow?.forEach((element) { | ||
| 263 | + element.tableList?.forEach((subelement) { | ||
| 264 | + if (subelement.reserveList != null) { | ||
| 265 | + sumShow++; | ||
| 266 | + } | ||
| 267 | + if (sumShow > limitNum) { | ||
| 268 | + subelement.reserveList = null; | ||
| 269 | + } | ||
| 270 | + }); | ||
| 271 | + }); | ||
| 272 | + } | ||
| 273 | + | ||
| 274 | + // | ||
| 275 | + | ||
| 188 | if (tablesOrReserveData!.length == 0) { | 276 | if (tablesOrReserveData!.length == 0) { |
| 189 | pageStateOrReserve = PageState.Empty; | 277 | pageStateOrReserve = PageState.Empty; |
| 190 | } else { | 278 | } else { |
| @@ -1771,8 +1859,7 @@ class TableManagerModelOrReserve with ChangeNotifier { | @@ -1771,8 +1859,7 @@ class TableManagerModelOrReserve with ChangeNotifier { | ||
| 1771 | } | 1859 | } |
| 1772 | 1860 | ||
| 1773 | //获取区域数据 | 1861 | //获取区域数据 |
| 1774 | - Future<List<AreaSunModel>?> getRegionBySellerid( | ||
| 1775 | - BuildContext context) async { | 1862 | + Future<List<AreaSunModel>?> getRegionBySellerid(BuildContext context) async { |
| 1776 | Map<String, String?> params = { | 1863 | Map<String, String?> params = { |
| 1777 | "sellerid": Provider.of<UserModel>(context, listen: false).user!.sellerid | 1864 | "sellerid": Provider.of<UserModel>(context, listen: false).user!.sellerid |
| 1778 | }; | 1865 | }; |
| @@ -56,6 +56,12 @@ import 'dart:typed_data'; | @@ -56,6 +56,12 @@ import 'dart:typed_data'; | ||
| 56 | typedef BookTimeSetCallback = void Function(bool needChange); | 56 | typedef BookTimeSetCallback = void Function(bool needChange); |
| 57 | 57 | ||
| 58 | class Utils { | 58 | class Utils { |
| 59 | + static bool isBeforeToday(DateTime dateToCompare) { | ||
| 60 | + DateTime today = DateTime.now(); | ||
| 61 | + // 只比较年、月、日部分,忽略时间部分 | ||
| 62 | + return dateToCompare.isBefore(DateTime(today.year, today.month, today.day)); | ||
| 63 | + } | ||
| 64 | + | ||
| 59 | static Future<bool> isImageLargerThan120KB(Uint8List? imageBytes) async { | 65 | static Future<bool> isImageLargerThan120KB(Uint8List? imageBytes) async { |
| 60 | if (imageBytes == null) { | 66 | if (imageBytes == null) { |
| 61 | return false; | 67 | return false; |
-
Please register or login to post a comment