@pisell/pisellos 0.0.141 → 0.0.143

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/modules/Cart/index.d.ts +14 -0
  2. package/dist/modules/Cart/index.js +36 -0
  3. package/dist/modules/Cart/utils/changePrice.d.ts +3 -0
  4. package/dist/modules/Cart/utils/changePrice.js +100 -0
  5. package/dist/modules/Date/index.js +57 -6
  6. package/dist/modules/ProductList/index.d.ts +7 -0
  7. package/dist/modules/ProductList/index.js +102 -39
  8. package/dist/modules/Schedule/index.d.ts +9 -1
  9. package/dist/modules/Schedule/index.js +121 -1
  10. package/dist/modules/Schedule/types.d.ts +13 -0
  11. package/dist/solution/BookingByStep/index.d.ts +120 -30
  12. package/dist/solution/BookingByStep/index.js +735 -1094
  13. package/dist/solution/BookingByStep/utils/capacity.d.ts +47 -0
  14. package/dist/solution/BookingByStep/utils/capacity.js +132 -0
  15. package/dist/solution/BookingByStep/utils/resources.d.ts +21 -29
  16. package/dist/solution/BookingByStep/utils/resources.js +39 -95
  17. package/dist/solution/BookingByStep/utils/timeslots.d.ts +11 -0
  18. package/dist/solution/BookingByStep/utils/timeslots.js +15 -0
  19. package/lib/modules/Cart/index.d.ts +14 -0
  20. package/lib/modules/Cart/index.js +32 -0
  21. package/lib/modules/Cart/utils/changePrice.d.ts +3 -0
  22. package/lib/modules/Cart/utils/changePrice.js +64 -0
  23. package/lib/modules/Date/index.js +62 -10
  24. package/lib/modules/ProductList/index.d.ts +7 -0
  25. package/lib/modules/ProductList/index.js +45 -0
  26. package/lib/modules/Schedule/index.d.ts +9 -1
  27. package/lib/modules/Schedule/index.js +78 -0
  28. package/lib/modules/Schedule/types.d.ts +13 -0
  29. package/lib/solution/BookingByStep/index.d.ts +120 -30
  30. package/lib/solution/BookingByStep/index.js +360 -580
  31. package/lib/solution/BookingByStep/utils/capacity.d.ts +47 -0
  32. package/lib/solution/BookingByStep/utils/capacity.js +106 -0
  33. package/lib/solution/BookingByStep/utils/resources.d.ts +21 -29
  34. package/lib/solution/BookingByStep/utils/resources.js +21 -58
  35. package/lib/solution/BookingByStep/utils/timeslots.d.ts +11 -0
  36. package/lib/solution/BookingByStep/utils/timeslots.js +7 -0
  37. package/package.json +1 -1
@@ -27,7 +27,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
27
27
  import { BaseModule } from "../../modules/BaseModule";
28
28
  import { BookingByStepHooks, createModule } from "./types";
29
29
  import { getAvailableProductResources } from "./utils/products";
30
- import { getResourcesByProduct, getTimeSlicesByResource, getTimeSlicesByResources, getIsUsableByTimeItem, getOthersSelectedResources, formatDefaultCapacitys, getSumCapacity, checkSubResourcesCapacity, getOthersCartSelectedResources, filterScheduleByDateRange, checkSessionProductLeadTime, getResourcesIdsByProduct, sortCombinedResources } from "./utils/resources";
30
+ import { getResourcesByProduct, getTimeSlicesByResource, getTimeSlicesByResources, getIsUsableByTimeItem, getOthersSelectedResources, getOthersCartSelectedResources, filterScheduleByDateRange, checkSessionProductLeadTime, getResourcesIdsByProduct, sortCombinedResources, filterResourcesByFormItem, checkTwoResourcesIntersection } from "./utils/resources";
31
31
  import dayjs from 'dayjs';
32
32
  import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
33
33
  import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
@@ -36,9 +36,11 @@ dayjs.extend(isSameOrAfter);
36
36
  import { getResourcesMap } from "../../modules/Resource/utils";
37
37
  import { cloneDeep } from 'lodash-es';
38
38
  import { calcCalendarDataByScheduleResult, calcMinTimeMaxTimeBySchedules, getAllSortedDateRanges } from "../../modules/Schedule/utils";
39
- import { disableAllDates, disableDatesBeforeOneDay, generateMonthDates, handleAvailableDateByResource } from "../../modules/Date/utils";
39
+ import { handleAvailableDateByResource } from "../../modules/Date/utils";
40
40
  import { areAllNormalProducts, isNormalProduct } from "../../modules/Product/utils";
41
- import { calculateResourceAvailableTime, findFastestAvailableResource } from "./utils/timeslots";
41
+ import { calculateResourceAvailableTime, filterConditionTimeSlots, findFastestAvailableResource } from "./utils/timeslots";
42
+ import { updateAllCartItemPrice } from "../../modules/Cart/utils/changePrice";
43
+ import { getCapacityInfoByCartItem, checkSubResourcesCapacity, checkResourceCanUseByCapacity } from "./utils/capacity";
42
44
  export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
43
45
  _inherits(BookingByStepImpl, _BaseModule);
44
46
  var _super = _createSuper(BookingByStepImpl);
@@ -124,7 +126,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
124
126
  throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
125
127
  }
126
128
  });
127
- this.loadAllSchedule();
129
+ this.store.schedule.loadAllSchedule();
128
130
  this.core.effects.emit(BookingByStepHooks.onInited, {});
129
131
  case 18:
130
132
  case "end":
@@ -205,65 +207,40 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
205
207
  this.store.step.updateStep(key, step);
206
208
  }
207
209
 
208
- // 获取购物车里 temp.xxx的方法
209
- // async getStoreCart(key?: string) {
210
- // return this.store.cart.getTemp(key);
211
- // }
212
-
213
- // 加载商品,然后导到商品列表里去
210
+ /**
211
+ *
212
+ * 加载商品,然后导到商品列表里去
213
+ * @param {({
214
+ * category_ids?: number[];
215
+ * product_ids?: number[];
216
+ * collection?: number | string[];
217
+ * schedule_date?: string;
218
+ * })} {
219
+ * category_ids = [],
220
+ * product_ids = [],
221
+ * collection = [],
222
+ * schedule_date,
223
+ * }
224
+ * @return {*}
225
+ * @memberof BookingByStepImpl
226
+ */
214
227
  }, {
215
228
  key: "loadProducts",
216
- value: function () {
229
+ value: (function () {
217
230
  var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
218
- var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, schedule_date, userPlugin, customer_id, _userPlugin$get, productsData;
231
+ var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, schedule_date;
219
232
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
220
233
  while (1) switch (_context2.prev = _context2.next) {
221
234
  case 0:
222
235
  _ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection, schedule_date = _ref.schedule_date;
223
- // // 如果 schedule_ids 为空,则需要尝试从 schedule 模块里获取
224
- // if (!schedule_ids?.length) {
225
- // const schedule_ids_data = this.store.schedule
226
- // .getScheduleListByIds(schedule_ids)
227
- // .map((n) => n.id);
228
- // if (schedule_ids_data.length) {
229
- // schedule_ids = schedule_ids_data;
230
- // } else if (schedule_date) {
231
- // // 后端说如果 schedule_ids 如果为空,需要给[0]
232
- // schedule_ids = [0];
233
- // }
234
- // }
235
- userPlugin = this.core.getPlugin('user');
236
- customer_id = undefined;
237
- try {
238
- customer_id = userPlugin === null || userPlugin === void 0 || (_userPlugin$get = userPlugin.get()) === null || _userPlugin$get === void 0 ? void 0 : _userPlugin$get.id;
239
- } catch (error) {
240
- console.error(error);
241
- }
242
- // 如果没传schedule_date,则从
243
- _context2.next = 6;
244
- return this.request.post("/product/query", {
245
- open_quotation: 1,
246
- open_bundle: 0,
247
- exclude_extension_type: ['product_party', 'product_event', 'product_series_event', 'product_package_ticket', 'ticket', 'event_item'],
248
- with: ['category', 'collection', 'resourceRelation'],
249
- status: 'published',
250
- num: 500,
251
- skip: 1,
252
- customer_id: customer_id,
236
+ return _context2.abrupt("return", this.store.products.loadProducts({
253
237
  category_ids: category_ids,
254
- ids: product_ids,
238
+ product_ids: product_ids,
255
239
  collection: collection,
256
- front_end_cache_id: this.cacheId,
257
- // client_schedule_ids: schedule_ids,
258
- schedule_date: schedule_date
259
- }, {
260
- useCache: true
261
- });
262
- case 6:
263
- productsData = _context2.sent;
264
- this.store.products.addProduct(productsData.data.list);
265
- return _context2.abrupt("return", productsData.data.list);
266
- case 9:
240
+ schedule_date: schedule_date,
241
+ cacheId: this.cacheId
242
+ }));
243
+ case 2:
267
244
  case "end":
268
245
  return _context2.stop();
269
246
  }
@@ -274,9 +251,25 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
274
251
  }
275
252
  return loadProducts;
276
253
  }()
254
+ /**
255
+ * 通过 schedule 来读取商品,适用于 session 类商品
256
+ *
257
+ * @param {{
258
+ * date: string;
259
+ * product_ids?: number[];
260
+ * category_ids?: number[];
261
+ * }} {
262
+ * date,
263
+ * product_ids = [],
264
+ * category_ids = [],
265
+ * }
266
+ * @return {*}
267
+ * @memberof BookingByStepImpl
268
+ */
269
+ )
277
270
  }, {
278
271
  key: "loadProductByScheduleDate",
279
- value: function () {
272
+ value: (function () {
280
273
  var _loadProductByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref2) {
281
274
  var _schedule$product_ids;
282
275
  var date, _ref2$product_ids, product_ids, _ref2$category_ids, category_ids, scheduleList, schedule, otherProductsIds, allProductIds;
@@ -296,18 +289,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
296
289
  week: '',
297
290
  weekNum: 0
298
291
  }]);
299
- // const scheduleIds = scheduleList
300
- // .filter((n) => n.date === date)
301
- // .flatMap((n) => n.schedule_id)
302
- // .filter((n) => n !== null && n !== undefined);
303
-
304
- // 如果外面没传 product_ids,尝试从对应 schedule 里拿 product_ids
305
- // if (!product_ids?.length) {
306
- // const schedule = scheduleList.find((n) => n.date === date);
307
- // if (schedule && schedule.product_ids?.length) {
308
- // product_ids = schedule.product_ids;
309
- // }
310
- // }
311
292
  // V2接口修改后,只能从schedule 接口里拿数据,不可以从外面拿,外面给的是装修数据
312
293
  schedule = scheduleList.find(function (n) {
313
294
  return n.date === date;
@@ -322,7 +303,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
322
303
  });
323
304
  _context3.next = 9;
324
305
  return this.loadProducts({
325
- // schedule_ids: scheduleIds,
326
306
  product_ids: allProductIds,
327
307
  category_ids: category_ids,
328
308
  schedule_date: date
@@ -340,29 +320,35 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
340
320
  }
341
321
  return loadProductByScheduleDate;
342
322
  }()
323
+ /**
324
+ * 更新完商品数据、切换日期、或者在较后的流程里登录了,检测当前购物车里是否有商品,如果有,则需要更新购物车里的商品价格
325
+ *
326
+ * @param {string} date
327
+ * @memberof BookingByStepImpl
328
+ */
329
+ )
343
330
  }, {
344
331
  key: "updateQuotationPriceAndCart",
345
- value: function () {
332
+ value: (function () {
346
333
  var _updateQuotationPriceAndCart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(date) {
347
334
  var _this3 = this;
348
- var cartItems, userPlugin, customer_id, _userPlugin$get2, res, _iterator, _step, _loop;
349
- return _regeneratorRuntime().wrap(function _callee4$(_context5) {
350
- while (1) switch (_context5.prev = _context5.next) {
335
+ var cartItems, userPlugin, customer_id, _userPlugin$get, res;
336
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
337
+ while (1) switch (_context4.prev = _context4.next) {
351
338
  case 0:
352
- // 更新完商品数据以后,检测当前购物车里是否有商品,如果有,则需要更新购物车里的商品价格
353
339
  cartItems = this.store.cart.getItems();
354
340
  if (!cartItems.length) {
355
- _context5.next = 25;
341
+ _context4.next = 11;
356
342
  break;
357
343
  }
358
344
  userPlugin = this.core.getPlugin('user');
359
345
  customer_id = undefined;
360
346
  try {
361
- customer_id = userPlugin === null || userPlugin === void 0 || (_userPlugin$get2 = userPlugin.get()) === null || _userPlugin$get2 === void 0 ? void 0 : _userPlugin$get2.id;
347
+ customer_id = userPlugin === null || userPlugin === void 0 || (_userPlugin$get = userPlugin.get()) === null || _userPlugin$get === void 0 ? void 0 : _userPlugin$get.id;
362
348
  } catch (error) {
363
349
  console.error(error);
364
350
  }
365
- _context5.next = 7;
351
+ _context4.next = 7;
366
352
  return this.store.products.loadProductsPrice({
367
353
  ids: cartItems.map(function (n) {
368
354
  return n.id;
@@ -371,286 +357,104 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
371
357
  customer_id: customer_id
372
358
  });
373
359
  case 7:
374
- res = _context5.sent;
375
- _iterator = _createForOfIteratorHelper(cartItems);
376
- _context5.prev = 9;
377
- _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
378
- var _bundle;
379
- var item, targetProduct, cartProduct, productInfo, bundle;
380
- return _regeneratorRuntime().wrap(function _loop$(_context4) {
381
- while (1) switch (_context4.prev = _context4.next) {
382
- case 0:
383
- item = _step.value;
384
- targetProduct = res.find(function (n) {
385
- return n.id === item.id;
386
- });
387
- _context4.next = 4;
388
- return _this3.store.products.getProduct(item.id);
389
- case 4:
390
- cartProduct = _context4.sent;
391
- productInfo = cartProduct === null || cartProduct === void 0 ? void 0 : cartProduct.getData();
392
- bundle = item._bundleOrigin;
393
- productInfo.price = targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.price;
394
- productInfo.base_price = targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.base_price;
395
- bundle = (_bundle = bundle) === null || _bundle === void 0 ? void 0 : _bundle.map(function (n) {
396
- var _targetProduct$bundle;
397
- // 更新 bundle 的价格
398
- var targetBundle = targetProduct === null || targetProduct === void 0 || (_targetProduct$bundle = targetProduct.bundle_group) === null || _targetProduct$bundle === void 0 ? void 0 : _targetProduct$bundle.find(function (m) {
399
- return m.id === n.group_id;
400
- });
401
- if (targetBundle) {
402
- var targetBundleItem = targetBundle.bundle_item.find(function (m) {
403
- return m.id === n.id;
404
- });
405
- if (targetBundleItem) {
406
- return _objectSpread(_objectSpread({}, n), {}, {
407
- price: targetBundleItem.price,
408
- base_price: targetBundleItem.base_price
409
- });
410
- }
411
- }
412
- return n;
413
- });
414
- _this3.store.cart.updateItem({
415
- _id: item._id,
416
- product: productInfo,
417
- bundle: bundle
418
- });
419
- case 11:
420
- case "end":
421
- return _context4.stop();
422
- }
423
- }, _loop);
360
+ res = _context4.sent;
361
+ _context4.next = 10;
362
+ return updateAllCartItemPrice(cartItems, res, function (id) {
363
+ return _this3.store.products.getProduct(id);
364
+ }, function (params) {
365
+ return _this3.store.cart.updateItem(params);
424
366
  });
425
- _iterator.s();
426
- case 12:
427
- if ((_step = _iterator.n()).done) {
428
- _context5.next = 16;
429
- break;
430
- }
431
- return _context5.delegateYield(_loop(), "t0", 14);
432
- case 14:
433
- _context5.next = 12;
434
- break;
435
- case 16:
436
- _context5.next = 21;
437
- break;
438
- case 18:
439
- _context5.prev = 18;
440
- _context5.t1 = _context5["catch"](9);
441
- _iterator.e(_context5.t1);
442
- case 21:
443
- _context5.prev = 21;
444
- _iterator.f();
445
- return _context5.finish(21);
446
- case 24:
367
+ case 10:
447
368
  this.core.effects.emit("".concat(this.store.cart.name, ":onUpdateQuotationPrice"), {});
448
- case 25:
369
+ case 11:
449
370
  case "end":
450
- return _context5.stop();
371
+ return _context4.stop();
451
372
  }
452
- }, _callee4, this, [[9, 18, 21, 24]]);
373
+ }, _callee4, this);
453
374
  }));
454
375
  function updateQuotationPriceAndCart(_x5) {
455
376
  return _updateQuotationPriceAndCart.apply(this, arguments);
456
377
  }
457
378
  return updateQuotationPriceAndCart;
458
- }() // 加载当前店铺下所有 schedule
459
- }, {
460
- key: "loadAllSchedule",
461
- value: function () {
462
- var _loadAllSchedule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
463
- var _scheduleList$data;
464
- var scheduleList;
465
- return _regeneratorRuntime().wrap(function _callee5$(_context6) {
466
- while (1) switch (_context6.prev = _context6.next) {
467
- case 0:
468
- _context6.next = 2;
469
- return this.request.get("/schedule", {
470
- num: 999
471
- }, {
472
- useCache: true
473
- });
474
- case 2:
475
- scheduleList = _context6.sent;
476
- this.store.schedule.setScheduleList(((_scheduleList$data = scheduleList.data) === null || _scheduleList$data === void 0 ? void 0 : _scheduleList$data.list) || []);
477
- case 4:
478
- case "end":
479
- return _context6.stop();
480
- }
481
- }, _callee5, this);
482
- }));
483
- function loadAllSchedule() {
484
- return _loadAllSchedule.apply(this, arguments);
485
- }
486
- return loadAllSchedule;
487
- }() // ui 层提供日期的起始范围,返回一个起始范围内日期的可用情况
379
+ }()
380
+ /**
381
+ * ui 层提供日期的起始范围,返回一个起始范围内日期的可用情况
382
+ * 适用于先选日期的流程,确定日期是否可用
383
+ * 已知问题:如果挂接的商品的资源不可用,后端是不会计算的
384
+ *
385
+ * @param {LoadScheduleAvailableDateParams} {
386
+ * startDate,
387
+ * endDate,
388
+ * custom_page_id,
389
+ * channel,
390
+ * }
391
+ * @memberof BookingByStepImpl
392
+ */
393
+ )
488
394
  }, {
489
395
  key: "loadScheduleAvailableDate",
490
- value: function () {
491
- var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref3) {
492
- var _res$data$date_list, _res$data$other_produ, _res$data$other_produ2;
493
- var startDate, endDate, custom_page_id, channel, dates, res;
494
- return _regeneratorRuntime().wrap(function _callee6$(_context7) {
495
- while (1) switch (_context7.prev = _context7.next) {
396
+ value: (function () {
397
+ var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref3) {
398
+ var startDate, endDate, custom_page_id, channel;
399
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
400
+ while (1) switch (_context5.prev = _context5.next) {
496
401
  case 0:
497
402
  startDate = _ref3.startDate, endDate = _ref3.endDate, custom_page_id = _ref3.custom_page_id, channel = _ref3.channel;
498
- // 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天,需要把 startDate 置为今天
499
- if (dayjs(startDate).isBefore(dayjs(), 'day')) {
500
- startDate = dayjs().format('YYYY-MM-DD');
501
- }
502
- // 1.生成当前月份的所有日期,默认都不可用
503
- dates = generateMonthDates(startDate, endDate);
504
- dates = disableAllDates(dates);
505
- // 如果 endDate 在今天之前,则不用查接口,直接返回 dates
506
- if (!dayjs(endDate).isBefore(dayjs(), 'day')) {
507
- _context7.next = 6;
508
- break;
509
- }
510
- return _context7.abrupt("return", dates);
511
- case 6:
512
- _context7.next = 8;
513
- return this.request.get("/schedule/product/availability/v2", {
514
- start_date: startDate,
515
- end_date: endDate,
403
+ _context5.next = 3;
404
+ return this.store.schedule.loadScheduleAvailableDate({
405
+ startDate: startDate,
406
+ endDate: endDate,
516
407
  custom_page_id: custom_page_id,
517
408
  channel: channel
518
409
  });
519
- case 8:
520
- res = _context7.sent;
521
- this.store.schedule.setAvailabilityScheduleDateList(res.data.date_list);
522
- this.store.schedule.setOtherProductsIds(res.data.other_product_ids || []);
523
- // 如果没有schedule或者结束日期在今天之前,则所有日期均不可用
524
- if (!(!((_res$data$date_list = res.data.date_list) !== null && _res$data$date_list !== void 0 && _res$data$date_list.length) && !((_res$data$other_produ = res.data.other_product_ids) !== null && _res$data$other_produ !== void 0 && _res$data$other_produ.length) || dayjs(endDate).isBefore(dayjs(), 'day'))) {
525
- _context7.next = 13;
526
- break;
527
- }
528
- return _context7.abrupt("return", dates);
529
- case 13:
530
- if ((_res$data$other_produ2 = res.data.other_product_ids) !== null && _res$data$other_produ2 !== void 0 && _res$data$other_produ2.length) {
531
- // 如果后端有返回 other_product_ids ,意味着有 duration 商品,则今天以及今天以后的日期均可用
532
- dates.forEach(function (n) {
533
- n.status = 'available';
534
- });
535
- } else {
536
- res.data.date_list.forEach(function (n) {
537
- var index = dates.findIndex(function (m) {
538
- return m.date === n.date;
539
- });
540
- if (index !== -1) {
541
- dates[index].status = 'available';
542
- }
543
- });
544
- }
545
- dates = disableDatesBeforeOneDay(dates);
546
- return _context7.abrupt("return", dates);
547
- case 16:
410
+ case 3:
411
+ return _context5.abrupt("return", _context5.sent);
412
+ case 4:
548
413
  case "end":
549
- return _context7.stop();
414
+ return _context5.stop();
550
415
  }
551
- }, _callee6, this);
416
+ }, _callee5, this);
552
417
  }));
553
418
  function loadScheduleAvailableDate(_x6) {
554
419
  return _loadScheduleAvailableDate.apply(this, arguments);
555
420
  }
556
421
  return loadScheduleAvailableDate;
557
- }()
558
- }, {
559
- key: "storeProduct",
560
- value: function () {
561
- var _storeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(productData) {
562
- var activeAccount, _ref4, bundle, options, origin, product_variant_id, _ref4$quantity, quantity, rowKey, cartItems, currentAccount, targetCartItem, targetAccount, isSameAccount, product, addCartItem;
563
- return _regeneratorRuntime().wrap(function _callee7$(_context8) {
564
- while (1) switch (_context8.prev = _context8.next) {
565
- case 0:
566
- // 往购物车加商品数据的时候,默认用当前 activeAccount 填充到 product 的 account 里面
567
- activeAccount = this.getActiveAccount();
568
- _ref4 = productData || {}, bundle = _ref4.bundle, options = _ref4.options, origin = _ref4.origin, product_variant_id = _ref4.product_variant_id, _ref4$quantity = _ref4.quantity, quantity = _ref4$quantity === void 0 ? 1 : _ref4$quantity, rowKey = _ref4.rowKey; // 检查购物车里是否已经存在 rowKey相同的数据,如果是则更新数量
569
- // 还需要判断账号是否一致
570
- cartItems = this.store.cart.getItems();
571
- if (!rowKey) {
572
- _context8.next = 12;
573
- break;
574
- }
575
- currentAccount = this.store.accountList.getActiveAccount();
576
- targetCartItem = cartItems.find(function (n) {
577
- var _n$_productOrigin;
578
- return ((_n$_productOrigin = n._productOrigin) === null || _n$_productOrigin === void 0 ? void 0 : _n$_productOrigin.rowKey) === rowKey && n.holder_id === (currentAccount === null || currentAccount === void 0 ? void 0 : currentAccount.getId());
579
- });
580
- targetAccount = targetCartItem === null || targetCartItem === void 0 ? void 0 : targetCartItem.holder_id;
581
- isSameAccount = (currentAccount === null || currentAccount === void 0 ? void 0 : currentAccount.getId()) === targetAccount;
582
- if (!(targetCartItem && isNormalProduct(targetCartItem._productOrigin) && isSameAccount)) {
583
- _context8.next = 12;
584
- break;
585
- }
586
- this.store.cart.updateItem({
587
- _id: targetCartItem._id,
588
- product: _objectSpread({}, targetCartItem._productOrigin),
589
- quantity: (targetCartItem.num || 1) + quantity
590
- });
591
- // 这里需要单独触发一个,购物车商品数量发生改变的 hook
592
- this.core.effects.emit("".concat(this.store.cart.name, ":onUpdateCartItemNums"), {});
593
- return _context8.abrupt("return");
594
- case 12:
595
- product = _objectSpread(_objectSpread({}, origin), {}, {
596
- product_variant_id: product_variant_id,
597
- rowKey: rowKey
598
- });
599
- addCartItem = {
600
- product: product,
601
- bundle: bundle,
602
- options: options,
603
- quantity: quantity
604
- };
605
- if (activeAccount) {
606
- addCartItem.account = activeAccount;
607
- }
608
- this.store.cart.addItem(addCartItem);
609
- case 16:
610
- case "end":
611
- return _context8.stop();
612
- }
613
- }, _callee7, this);
614
- }));
615
- function storeProduct(_x7) {
616
- return _storeProduct.apply(this, arguments);
617
- }
618
- return storeProduct;
619
422
  }() // 添加单个账户或者 guest
423
+ )
620
424
  }, {
621
425
  key: "addAccount",
622
426
  value: function () {
623
- var _addAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(account, extra) {
427
+ var _addAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(account, extra) {
624
428
  var accountModules, newAccount;
625
- return _regeneratorRuntime().wrap(function _callee8$(_context9) {
626
- while (1) switch (_context9.prev = _context9.next) {
429
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
430
+ while (1) switch (_context6.prev = _context6.next) {
627
431
  case 0:
628
432
  if (!((extra === null || extra === void 0 ? void 0 : extra.type) === 'holder')) {
629
- _context9.next = 5;
433
+ _context6.next = 5;
630
434
  break;
631
435
  }
632
- _context9.next = 3;
436
+ _context6.next = 3;
633
437
  return this.store.accountList.addHolderAccounts({
634
438
  holders: [account],
635
439
  customerId: extra.customerId,
636
440
  type: 'unshift'
637
441
  });
638
442
  case 3:
639
- accountModules = _context9.sent;
640
- return _context9.abrupt("return", accountModules[0].getAccount());
443
+ accountModules = _context6.sent;
444
+ return _context6.abrupt("return", accountModules[0].getAccount());
641
445
  case 5:
642
- _context9.next = 7;
446
+ _context6.next = 7;
643
447
  return this.store.accountList.addAccount(account);
644
448
  case 7:
645
- newAccount = _context9.sent;
646
- return _context9.abrupt("return", newAccount.getAccount());
449
+ newAccount = _context6.sent;
450
+ return _context6.abrupt("return", newAccount.getAccount());
647
451
  case 9:
648
452
  case "end":
649
- return _context9.stop();
453
+ return _context6.stop();
650
454
  }
651
- }, _callee8, this);
455
+ }, _callee6, this);
652
456
  }));
653
- function addAccount(_x8, _x9) {
457
+ function addAccount(_x7, _x8) {
654
458
  return _addAccount.apply(this, arguments);
655
459
  }
656
460
  return addAccount;
@@ -658,13 +462,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
658
462
  }, {
659
463
  key: "addAccounts",
660
464
  value: function () {
661
- var _addAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(accounts, extra) {
662
- var res, _iterator2, _step2, account, accountModule, accountData;
663
- return _regeneratorRuntime().wrap(function _callee9$(_context10) {
664
- while (1) switch (_context10.prev = _context10.next) {
465
+ var _addAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(accounts, extra) {
466
+ var res, _iterator, _step, account, accountModule, accountData;
467
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
468
+ while (1) switch (_context7.prev = _context7.next) {
665
469
  case 0:
666
470
  if (!((extra === null || extra === void 0 ? void 0 : extra.type) === 'holder')) {
667
- _context10.next = 3;
471
+ _context7.next = 3;
668
472
  break;
669
473
  }
670
474
  this.store.accountList.addHolderAccounts({
@@ -672,49 +476,49 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
672
476
  customerId: extra.customerId,
673
477
  type: 'unshift'
674
478
  });
675
- return _context10.abrupt("return");
479
+ return _context7.abrupt("return");
676
480
  case 3:
677
481
  res = [];
678
- _iterator2 = _createForOfIteratorHelper(accounts);
679
- _context10.prev = 5;
680
- _iterator2.s();
482
+ _iterator = _createForOfIteratorHelper(accounts);
483
+ _context7.prev = 5;
484
+ _iterator.s();
681
485
  case 7:
682
- if ((_step2 = _iterator2.n()).done) {
683
- _context10.next = 16;
486
+ if ((_step = _iterator.n()).done) {
487
+ _context7.next = 16;
684
488
  break;
685
489
  }
686
- account = _step2.value;
687
- _context10.next = 11;
490
+ account = _step.value;
491
+ _context7.next = 11;
688
492
  return this.store.accountList.addAccount(account);
689
493
  case 11:
690
- accountModule = _context10.sent;
494
+ accountModule = _context7.sent;
691
495
  accountData = accountModule.getAccount();
692
496
  if (accountData) {
693
497
  res.push(accountData);
694
498
  }
695
499
  case 14:
696
- _context10.next = 7;
500
+ _context7.next = 7;
697
501
  break;
698
502
  case 16:
699
- _context10.next = 21;
503
+ _context7.next = 21;
700
504
  break;
701
505
  case 18:
702
- _context10.prev = 18;
703
- _context10.t0 = _context10["catch"](5);
704
- _iterator2.e(_context10.t0);
506
+ _context7.prev = 18;
507
+ _context7.t0 = _context7["catch"](5);
508
+ _iterator.e(_context7.t0);
705
509
  case 21:
706
- _context10.prev = 21;
707
- _iterator2.f();
708
- return _context10.finish(21);
510
+ _context7.prev = 21;
511
+ _iterator.f();
512
+ return _context7.finish(21);
709
513
  case 24:
710
- return _context10.abrupt("return", res);
514
+ return _context7.abrupt("return", res);
711
515
  case 25:
712
516
  case "end":
713
- return _context10.stop();
517
+ return _context7.stop();
714
518
  }
715
- }, _callee9, this, [[5, 18, 21, 24]]);
519
+ }, _callee7, this, [[5, 18, 21, 24]]);
716
520
  }));
717
- function addAccounts(_x10, _x11) {
521
+ function addAccounts(_x9, _x10) {
718
522
  return _addAccounts.apply(this, arguments);
719
523
  }
720
524
  return addAccounts;
@@ -722,20 +526,20 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
722
526
  }, {
723
527
  key: "getAccounts",
724
528
  value: function () {
725
- var _getAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
529
+ var _getAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
726
530
  var accounts;
727
- return _regeneratorRuntime().wrap(function _callee10$(_context11) {
728
- while (1) switch (_context11.prev = _context11.next) {
531
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
532
+ while (1) switch (_context8.prev = _context8.next) {
729
533
  case 0:
730
534
  accounts = this.store.accountList.getAccounts();
731
- return _context11.abrupt("return", accounts.map(function (account) {
535
+ return _context8.abrupt("return", accounts.map(function (account) {
732
536
  return account.getAccount();
733
537
  }));
734
538
  case 2:
735
539
  case "end":
736
- return _context11.stop();
540
+ return _context8.stop();
737
541
  }
738
- }, _callee10, this);
542
+ }, _callee8, this);
739
543
  }));
740
544
  function getAccounts() {
741
545
  return _getAccounts.apply(this, arguments);
@@ -759,7 +563,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
759
563
  key: "getActiveAccount",
760
564
  value: function getActiveAccount() {
761
565
  var activeAccount = this.store.accountList.getActiveAccount();
762
- return activeAccount ? activeAccount.getAccount() : null;
566
+ var account = activeAccount === null || activeAccount === void 0 ? void 0 : activeAccount.getAccount();
567
+ return account === null ? undefined : account;
763
568
  }
764
569
  }, {
765
570
  key: "removeAccount",
@@ -776,10 +581,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
776
581
  }, {
777
582
  key: "fetchHolderAccountsAsync",
778
583
  value: (function () {
779
- var _fetchHolderAccountsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(params) {
584
+ var _fetchHolderAccountsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
780
585
  var cartItems, _this$store$date$getD, date, normalProductCartItem;
781
- return _regeneratorRuntime().wrap(function _callee11$(_context12) {
782
- while (1) switch (_context12.prev = _context12.next) {
586
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
587
+ while (1) switch (_context9.prev = _context9.next) {
783
588
  case 0:
784
589
  cartItems = this.store.cart.getItems();
785
590
  if (cartItems.length) {
@@ -794,14 +599,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
794
599
  }
795
600
  this.updateQuotationPriceAndCart(date);
796
601
  }
797
- return _context12.abrupt("return", this.store.accountList.fetchHolderAccounts(params));
602
+ return _context9.abrupt("return", this.store.accountList.fetchHolderAccounts(params));
798
603
  case 3:
799
604
  case "end":
800
- return _context12.stop();
605
+ return _context9.stop();
801
606
  }
802
- }, _callee11, this);
607
+ }, _callee9, this);
803
608
  }));
804
- function fetchHolderAccountsAsync(_x12) {
609
+ function fetchHolderAccountsAsync(_x11) {
805
610
  return _fetchHolderAccountsAsync.apply(this, arguments);
806
611
  }
807
612
  return fetchHolderAccountsAsync;
@@ -810,9 +615,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
810
615
  }, {
811
616
  key: "setDateRange",
812
617
  value: function () {
813
- var _setDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(dateRange) {
814
- return _regeneratorRuntime().wrap(function _callee12$(_context13) {
815
- while (1) switch (_context13.prev = _context13.next) {
618
+ var _setDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(dateRange) {
619
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
620
+ while (1) switch (_context10.prev = _context10.next) {
816
621
  case 0:
817
622
  this.store.date.setDateRange(dateRange);
818
623
  // 日期数据变更后,如果购物车里有数据,需要更新购物车里的报价单的价格
@@ -821,11 +626,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
821
626
  }
822
627
  case 2:
823
628
  case "end":
824
- return _context13.stop();
629
+ return _context10.stop();
825
630
  }
826
- }, _callee12, this);
631
+ }, _callee10, this);
827
632
  }));
828
- function setDateRange(_x13) {
633
+ function setDateRange(_x12) {
829
634
  return _setDateRange.apply(this, arguments);
830
635
  }
831
636
  return setDateRange;
@@ -840,16 +645,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
840
645
  }, {
841
646
  key: "getDateRange",
842
647
  value: function () {
843
- var _getDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
844
- return _regeneratorRuntime().wrap(function _callee13$(_context14) {
845
- while (1) switch (_context14.prev = _context14.next) {
648
+ var _getDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
649
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
650
+ while (1) switch (_context11.prev = _context11.next) {
846
651
  case 0:
847
- return _context14.abrupt("return", this.store.date.getDateRange());
652
+ return _context11.abrupt("return", this.store.date.getDateRange());
848
653
  case 1:
849
654
  case "end":
850
- return _context14.stop();
655
+ return _context11.stop();
851
656
  }
852
- }, _callee13, this);
657
+ }, _callee11, this);
853
658
  }));
854
659
  function getDateRange() {
855
660
  return _getDateRange.apply(this, arguments);
@@ -866,7 +671,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
866
671
  }, {
867
672
  key: "getAvailableDate",
868
673
  value: function () {
869
- var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
674
+ var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
870
675
  var _this4 = this,
871
676
  _dateRange$,
872
677
  _dateRange$2,
@@ -880,16 +685,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
880
685
  dateRange,
881
686
  tempStartDate,
882
687
  tempEndDate,
883
- _ref5,
688
+ _ref4,
884
689
  resourceIds,
885
690
  rules,
886
691
  resourcesMap,
887
692
  res,
888
- _args15 = arguments;
889
- return _regeneratorRuntime().wrap(function _callee14$(_context15) {
890
- while (1) switch (_context15.prev = _context15.next) {
693
+ _args12 = arguments;
694
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
695
+ while (1) switch (_context12.prev = _context12.next) {
891
696
  case 0:
892
- params = _args15.length > 0 && _args15[0] !== undefined ? _args15[0] : {};
697
+ params = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : {};
893
698
  // 开始日期如果小于今天,直接以今天当做开始日期
894
699
  products = params.products, startDate = params.startDate, endDate = params.endDate, type = params.type; // 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天 且 endDate 小于或等于今天,需要把 startDate 置为今天
895
700
  if (dayjs(startDate).isBefore(dayjs(), 'day') && (dayjs(endDate).isAfter(dayjs(), 'day') || dayjs(endDate).isSame(dayjs(), 'day'))) {
@@ -916,15 +721,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
916
721
  tempStartDate = startDate || (dateRange === null || dateRange === void 0 || (_dateRange$ = dateRange[0]) === null || _dateRange$ === void 0 ? void 0 : _dateRange$.date);
917
722
  tempEndDate = endDate || (dateRange === null || dateRange === void 0 || (_dateRange$2 = dateRange[1]) === null || _dateRange$2 === void 0 ? void 0 : _dateRange$2.date) || (dateRange === null || dateRange === void 0 || (_dateRange$3 = dateRange[0]) === null || _dateRange$3 === void 0 ? void 0 : _dateRange$3.date);
918
723
  if (tempProducts.length) {
919
- _context15.next = 11;
724
+ _context12.next = 11;
920
725
  break;
921
726
  }
922
- return _context15.abrupt("return", []);
727
+ return _context12.abrupt("return", []);
923
728
  case 11:
924
729
  // 在这里需要把能收集到的数据都收集上来,拼装好给 date 模块去查询
925
- _ref5 = getAvailableProductResources(tempProducts) || {}, resourceIds = _ref5.resourceIds, rules = _ref5.rules, resourcesMap = _ref5.resourcesMap;
730
+ _ref4 = getAvailableProductResources(tempProducts) || {}, resourceIds = _ref4.resourceIds, rules = _ref4.rules, resourcesMap = _ref4.resourcesMap;
926
731
  this.otherParams.currentResourcesMap = resourcesMap;
927
- _context15.next = 15;
732
+ _context12.next = 15;
928
733
  return this.store.date.getResourceDates({
929
734
  url: params.url,
930
735
  query: {
@@ -936,13 +741,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
936
741
  type: type
937
742
  });
938
743
  case 15:
939
- res = _context15.sent;
940
- return _context15.abrupt("return", res);
744
+ res = _context12.sent;
745
+ return _context12.abrupt("return", res);
941
746
  case 17:
942
747
  case "end":
943
- return _context15.stop();
748
+ return _context12.stop();
944
749
  }
945
- }, _callee14, this);
750
+ }, _callee12, this);
946
751
  }));
947
752
  function getAvailableDate() {
948
753
  return _getAvailableDate.apply(this, arguments);
@@ -955,22 +760,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
955
760
  }, {
956
761
  key: "getSummary",
957
762
  value: (function () {
958
- var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
763
+ var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
959
764
  var cartItems, summary;
960
- return _regeneratorRuntime().wrap(function _callee15$(_context16) {
961
- while (1) switch (_context16.prev = _context16.next) {
765
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
766
+ while (1) switch (_context13.prev = _context13.next) {
962
767
  case 0:
963
768
  cartItems = this.store.cart.getItems();
964
- _context16.next = 3;
769
+ _context13.next = 3;
965
770
  return this.store.summary.getSummary(cartItems);
966
771
  case 3:
967
- summary = _context16.sent;
968
- return _context16.abrupt("return", summary);
772
+ summary = _context13.sent;
773
+ return _context13.abrupt("return", summary);
969
774
  case 5:
970
775
  case "end":
971
- return _context16.stop();
776
+ return _context13.stop();
972
777
  }
973
- }, _callee15, this);
778
+ }, _callee13, this);
974
779
  }));
975
780
  function getSummary() {
976
781
  return _getSummary.apply(this, arguments);
@@ -984,18 +789,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
984
789
  }, {
985
790
  key: "getProtocol",
986
791
  value: (function () {
987
- var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(protocolId) {
988
- return _regeneratorRuntime().wrap(function _callee16$(_context17) {
989
- while (1) switch (_context17.prev = _context17.next) {
792
+ var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(protocolId) {
793
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
794
+ while (1) switch (_context14.prev = _context14.next) {
990
795
  case 0:
991
- return _context17.abrupt("return", this.store.summary.getProtocol(protocolId));
796
+ return _context14.abrupt("return", this.store.summary.getProtocol(protocolId));
992
797
  case 1:
993
798
  case "end":
994
- return _context17.stop();
799
+ return _context14.stop();
995
800
  }
996
- }, _callee16, this);
801
+ }, _callee14, this);
997
802
  }));
998
- function getProtocol(_x14) {
803
+ function getProtocol(_x13) {
999
804
  return _getProtocol.apply(this, arguments);
1000
805
  }
1001
806
  return getProtocol;
@@ -1004,16 +809,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1004
809
  }, {
1005
810
  key: "getProducts",
1006
811
  value: function () {
1007
- var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1008
- return _regeneratorRuntime().wrap(function _callee17$(_context18) {
1009
- while (1) switch (_context18.prev = _context18.next) {
812
+ var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
813
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
814
+ while (1) switch (_context15.prev = _context15.next) {
1010
815
  case 0:
1011
- return _context18.abrupt("return", this.store.products.getProducts());
816
+ return _context15.abrupt("return", this.store.products.getProducts());
1012
817
  case 1:
1013
818
  case "end":
1014
- return _context18.stop();
819
+ return _context15.stop();
1015
820
  }
1016
- }, _callee17, this);
821
+ }, _callee15, this);
1017
822
  }));
1018
823
  function getProducts() {
1019
824
  return _getProducts.apply(this, arguments);
@@ -1023,15 +828,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1023
828
  }, {
1024
829
  key: "setLoginAccount",
1025
830
  value: function () {
1026
- var _setLoginAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(accountId, accountInfo) {
831
+ var _setLoginAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(accountId, accountInfo) {
1027
832
  var _this5 = this;
1028
833
  var account, stateAccountId, cartItems, _this$store$date$getD2, date, normalProductCartItem;
1029
- return _regeneratorRuntime().wrap(function _callee18$(_context19) {
1030
- while (1) switch (_context19.prev = _context19.next) {
834
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
835
+ while (1) switch (_context16.prev = _context16.next) {
1031
836
  case 0:
1032
837
  account = this.store.accountList.getAccount(accountId);
1033
838
  if (!account) {
1034
- _context19.next = 11;
839
+ _context16.next = 11;
1035
840
  break;
1036
841
  }
1037
842
  stateAccountId = account.getId();
@@ -1060,17 +865,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1060
865
  }
1061
866
  this.updateQuotationPriceAndCart(date);
1062
867
  }
1063
- _context19.next = 12;
868
+ _context16.next = 12;
1064
869
  break;
1065
870
  case 11:
1066
871
  throw new Error("\u6CA1\u6709\u627E\u5230".concat(accountId, "\u8D26\u6237"));
1067
872
  case 12:
1068
873
  case "end":
1069
- return _context19.stop();
874
+ return _context16.stop();
1070
875
  }
1071
- }, _callee18, this);
876
+ }, _callee16, this);
1072
877
  }));
1073
- function setLoginAccount(_x15, _x16) {
878
+ function setLoginAccount(_x14, _x15) {
1074
879
  return _setLoginAccount.apply(this, arguments);
1075
880
  }
1076
881
  return setLoginAccount;
@@ -1078,14 +883,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1078
883
  }, {
1079
884
  key: "generateCartData",
1080
885
  value: function () {
1081
- var _generateCartData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
1082
- return _regeneratorRuntime().wrap(function _callee19$(_context20) {
1083
- while (1) switch (_context20.prev = _context20.next) {
886
+ var _generateCartData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
887
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
888
+ while (1) switch (_context17.prev = _context17.next) {
1084
889
  case 0:
1085
890
  case "end":
1086
- return _context20.stop();
891
+ return _context17.stop();
1087
892
  }
1088
- }, _callee19);
893
+ }, _callee17);
1089
894
  }));
1090
895
  function generateCartData() {
1091
896
  return _generateCartData.apply(this, arguments);
@@ -1095,23 +900,23 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1095
900
  }, {
1096
901
  key: "getFreeProduct",
1097
902
  value: function () {
1098
- var _getFreeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(id) {
903
+ var _getFreeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(id) {
1099
904
  var res;
1100
- return _regeneratorRuntime().wrap(function _callee20$(_context21) {
1101
- while (1) switch (_context21.prev = _context21.next) {
905
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
906
+ while (1) switch (_context18.prev = _context18.next) {
1102
907
  case 0:
1103
- _context21.next = 2;
908
+ _context18.next = 2;
1104
909
  return this.request.post("/pay/order/free-pay/".concat(id));
1105
910
  case 2:
1106
- res = _context21.sent;
1107
- return _context21.abrupt("return", res);
911
+ res = _context18.sent;
912
+ return _context18.abrupt("return", res);
1108
913
  case 4:
1109
914
  case "end":
1110
- return _context21.stop();
915
+ return _context18.stop();
1111
916
  }
1112
- }, _callee20, this);
917
+ }, _callee18, this);
1113
918
  }));
1114
- function getFreeProduct(_x17) {
919
+ function getFreeProduct(_x16) {
1115
920
  return _getFreeProduct.apply(this, arguments);
1116
921
  }
1117
922
  return getFreeProduct;
@@ -1134,16 +939,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1134
939
  }, {
1135
940
  key: "submitOrder",
1136
941
  value: function () {
1137
- var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
942
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
1138
943
  var cartItems, newCartItems, type;
1139
- return _regeneratorRuntime().wrap(function _callee21$(_context22) {
1140
- while (1) switch (_context22.prev = _context22.next) {
944
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
945
+ while (1) switch (_context19.prev = _context19.next) {
1141
946
  case 0:
1142
947
  cartItems = this.store.cart.getItems();
1143
948
  newCartItems = cloneDeep(cartItems); // 先整个临时的逻辑,把购物车里所有商品的资源给他格式化一下
1144
949
  newCartItems.forEach(function (item) {
1145
950
  if (item._origin.resources && item._origin.resources.length) {
1146
- var _item$_productOrigin, _item$_origin;
951
+ var _item$_origin;
1147
952
  item._origin.resources = item._origin.resources.map(function (n) {
1148
953
  var newResourcesItem = cloneDeep(n);
1149
954
  delete newResourcesItem.id;
@@ -1151,13 +956,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1151
956
  delete newResourcesItem.resourceType;
1152
957
  return _objectSpread({}, newResourcesItem);
1153
958
  });
1154
- var formatCapacity = formatDefaultCapacitys({
1155
- capacity: (_item$_productOrigin = item._productOrigin) === null || _item$_productOrigin === void 0 ? void 0 : _item$_productOrigin.capacity,
1156
- product_bundle: item._origin.product.product_bundle
1157
- });
1158
- var currentCapacity = getSumCapacity({
1159
- capacity: formatCapacity
1160
- });
959
+ var _getCapacityInfoByCar = getCapacityInfoByCartItem(item),
960
+ currentCapacity = _getCapacityInfoByCar.currentCapacity,
961
+ formatCapacity = _getCapacityInfoByCar.formatCapacity;
1161
962
  if (!((_item$_origin = item._origin) !== null && _item$_origin !== void 0 && _item$_origin.metadata)) {
1162
963
  item._origin.metadata = {};
1163
964
  }
@@ -1171,7 +972,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1171
972
  }))) {
1172
973
  type = 'virtual';
1173
974
  }
1174
- return _context22.abrupt("return", this.store.order.submitOrder({
975
+ return _context19.abrupt("return", this.store.order.submitOrder({
1175
976
  query: {
1176
977
  cartItems: newCartItems,
1177
978
  type: type
@@ -1179,9 +980,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1179
980
  }));
1180
981
  case 6:
1181
982
  case "end":
1182
- return _context22.stop();
983
+ return _context19.stop();
1183
984
  }
1184
- }, _callee21, this);
985
+ }, _callee19, this);
1185
986
  }));
1186
987
  function submitOrder() {
1187
988
  return _submitOrder.apply(this, arguments);
@@ -1191,14 +992,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1191
992
  }, {
1192
993
  key: "pay",
1193
994
  value: function () {
1194
- var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
1195
- return _regeneratorRuntime().wrap(function _callee22$(_context23) {
1196
- while (1) switch (_context23.prev = _context23.next) {
995
+ var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
996
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
997
+ while (1) switch (_context20.prev = _context20.next) {
1197
998
  case 0:
1198
999
  case "end":
1199
- return _context23.stop();
1000
+ return _context20.stop();
1200
1001
  }
1201
- }, _callee22);
1002
+ }, _callee20);
1202
1003
  }));
1203
1004
  function pay() {
1204
1005
  return _pay.apply(this, arguments);
@@ -1208,14 +1009,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1208
1009
  }, {
1209
1010
  key: "getPayInfo",
1210
1011
  value: function () {
1211
- var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
1212
- return _regeneratorRuntime().wrap(function _callee23$(_context24) {
1213
- while (1) switch (_context24.prev = _context24.next) {
1012
+ var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
1013
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1014
+ while (1) switch (_context21.prev = _context21.next) {
1214
1015
  case 0:
1215
1016
  case "end":
1216
- return _context24.stop();
1017
+ return _context21.stop();
1217
1018
  }
1218
- }, _callee23);
1019
+ }, _callee21);
1219
1020
  }));
1220
1021
  function getPayInfo() {
1221
1022
  return _getPayInfo.apply(this, arguments);
@@ -1225,15 +1026,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1225
1026
  }, {
1226
1027
  key: "setOtherParams",
1227
1028
  value: function () {
1228
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
1229
- var _ref6,
1230
- _ref6$cover,
1029
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
1030
+ var _ref5,
1031
+ _ref5$cover,
1231
1032
  cover,
1232
- _args25 = arguments;
1233
- return _regeneratorRuntime().wrap(function _callee24$(_context25) {
1234
- while (1) switch (_context25.prev = _context25.next) {
1033
+ _args22 = arguments;
1034
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1035
+ while (1) switch (_context22.prev = _context22.next) {
1235
1036
  case 0:
1236
- _ref6 = _args25.length > 1 && _args25[1] !== undefined ? _args25[1] : {}, _ref6$cover = _ref6.cover, cover = _ref6$cover === void 0 ? false : _ref6$cover;
1037
+ _ref5 = _args22.length > 1 && _args22[1] !== undefined ? _args22[1] : {}, _ref5$cover = _ref5.cover, cover = _ref5$cover === void 0 ? false : _ref5$cover;
1237
1038
  if (cover) {
1238
1039
  this.otherParams = params;
1239
1040
  } else {
@@ -1241,11 +1042,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1241
1042
  }
1242
1043
  case 2:
1243
1044
  case "end":
1244
- return _context25.stop();
1045
+ return _context22.stop();
1245
1046
  }
1246
- }, _callee24, this);
1047
+ }, _callee22, this);
1247
1048
  }));
1248
- function setOtherParams(_x18) {
1049
+ function setOtherParams(_x17) {
1249
1050
  return _setOtherParams.apply(this, arguments);
1250
1051
  }
1251
1052
  return setOtherParams;
@@ -1253,51 +1054,193 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1253
1054
  }, {
1254
1055
  key: "getOtherParams",
1255
1056
  value: function () {
1256
- var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
1257
- return _regeneratorRuntime().wrap(function _callee25$(_context26) {
1258
- while (1) switch (_context26.prev = _context26.next) {
1057
+ var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
1058
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1059
+ while (1) switch (_context23.prev = _context23.next) {
1259
1060
  case 0:
1260
- return _context26.abrupt("return", this.otherParams);
1061
+ return _context23.abrupt("return", this.otherParams);
1261
1062
  case 1:
1262
1063
  case "end":
1263
- return _context26.stop();
1064
+ return _context23.stop();
1264
1065
  }
1265
- }, _callee25, this);
1066
+ }, _callee23, this);
1266
1067
  }));
1267
1068
  function getOtherParams() {
1268
1069
  return _getOtherParams.apply(this, arguments);
1269
1070
  }
1270
1071
  return getOtherParams;
1271
- }() // 更新购物车
1072
+ }()
1073
+ /**
1074
+ * 往购物车加商品数据(duration 类、普通商品)
1075
+ * 老接口,先不删,怕 UI 有问题,直接桥接到新接口addProductToCart上
1076
+ *
1077
+ * @param {ProductData} productData
1078
+ * @memberof BookingByStepImpl
1079
+ */
1272
1080
  }, {
1273
- key: "updateCart",
1274
- value: function updateCart(params) {
1275
- var _this6 = this;
1276
- var targetCartItem = this.store.cart.getItem(params._id);
1277
- if (!targetCartItem) {
1278
- throw new Error("\u6CA1\u6709\u627E\u5230".concat(params._id, "\u8D2D\u7269\u8F66\u5546\u54C1"));
1081
+ key: "storeProduct",
1082
+ value: (function () {
1083
+ var _storeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(productData) {
1084
+ var activeAccount;
1085
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1086
+ while (1) switch (_context24.prev = _context24.next) {
1087
+ case 0:
1088
+ // 往购物车加商品数据的时候,默认用当前 activeAccount 填充到 product 的 account 里面
1089
+ activeAccount = this.getActiveAccount(); // 直接调用 addProductToCart,不传递 date 参数以避免日期检查逻辑
1090
+ this.addProductToCart({
1091
+ product: productData,
1092
+ account: activeAccount
1093
+ });
1094
+ case 2:
1095
+ case "end":
1096
+ return _context24.stop();
1097
+ }
1098
+ }, _callee24, this);
1099
+ }));
1100
+ function storeProduct(_x18) {
1101
+ return _storeProduct.apply(this, arguments);
1279
1102
  }
1280
- var currentResourcesCapacityMap = {};
1281
- if (params.resources) {
1282
- var _targetCartItem$_prod;
1283
- var formatCapacity = formatDefaultCapacitys({
1284
- capacity: (_targetCartItem$_prod = targetCartItem._productOrigin) === null || _targetCartItem$_prod === void 0 ? void 0 : _targetCartItem$_prod.capacity,
1285
- product_bundle: targetCartItem._origin.product.product_bundle
1103
+ return storeProduct;
1104
+ }()
1105
+ /**
1106
+ * 往购物车加商品数据
1107
+ *
1108
+ * @param {({
1109
+ * product: ProductData;
1110
+ * date?: { startTime: string; endTime: string } | null;
1111
+ * account?: Account | null;
1112
+ * })} {
1113
+ * product,
1114
+ * date,
1115
+ * account,
1116
+ * }
1117
+ * @return {*}
1118
+ * @memberof BookingByStepImpl
1119
+ */
1120
+ )
1121
+ }, {
1122
+ key: "addProductToCart",
1123
+ value: function addProductToCart(_ref6) {
1124
+ var product = _ref6.product,
1125
+ date = _ref6.date,
1126
+ account = _ref6.account;
1127
+ var _ref7 = product || {},
1128
+ bundle = _ref7.bundle,
1129
+ options = _ref7.options,
1130
+ origin = _ref7.origin,
1131
+ product_variant_id = _ref7.product_variant_id,
1132
+ rowKey = _ref7.rowKey,
1133
+ _ref7$quantity = _ref7.quantity,
1134
+ quantity = _ref7$quantity === void 0 ? 1 : _ref7$quantity;
1135
+ var productData = _objectSpread(_objectSpread({}, origin), {}, {
1136
+ product_variant_id: product_variant_id
1137
+ });
1138
+ if (!account) {
1139
+ var activeAccount = this.getActiveAccount();
1140
+ if (activeAccount) {
1141
+ account = activeAccount;
1142
+ }
1143
+ }
1144
+ var flag = this.store.cart.mergeCartItemByRowKey({
1145
+ rowKey: rowKey,
1146
+ quantity: quantity,
1147
+ account: account || undefined
1148
+ });
1149
+ if (flag) {
1150
+ return;
1151
+ }
1152
+ var addItemParams = {
1153
+ product: productData,
1154
+ bundle: bundle,
1155
+ options: options,
1156
+ quantity: quantity
1157
+ };
1158
+ if (date) {
1159
+ addItemParams.date = date;
1160
+ }
1161
+ if (account) {
1162
+ addItemParams.account = account;
1163
+ }
1164
+ this.addProductCheck({
1165
+ date: date
1166
+ });
1167
+ this.store.cart.addItem(addItemParams);
1168
+ }
1169
+
1170
+ /**
1171
+ * 添加完购物车以后做的一些检测,比如日期是否在同一天
1172
+ *
1173
+ * @param {({ date?: { startTime: string; endTime: string } | null })} { date }
1174
+ * @memberof BookingByStepImpl
1175
+ */
1176
+ }, {
1177
+ key: "addProductCheck",
1178
+ value: function addProductCheck(_ref8) {
1179
+ var _this6 = this;
1180
+ var date = _ref8.date;
1181
+ // 检测,有传递 date,检查购物车里其他商品的 date 是否在同一天,如果不在,清空那些不在同一天的商品
1182
+ if (date) {
1183
+ var cartItems = this.store.cart.getItems().filter(function (n) {
1184
+ return !isNormalProduct(n._productOrigin);
1286
1185
  });
1287
- var currentCapacity = getSumCapacity({
1288
- capacity: formatCapacity
1186
+ var cartItemsByDate = cartItems.filter(function (n) {
1187
+ return !dayjs(n.start_date).isSame(dayjs(date.startTime), 'day');
1289
1188
  });
1189
+ if (cartItemsByDate.length) {
1190
+ cartItemsByDate.forEach(function (n) {
1191
+ _this6.store.cart.removeItem(n._id);
1192
+ });
1193
+ }
1194
+ }
1195
+ }
1196
+ }, {
1197
+ key: "beforeUpdateCart",
1198
+ value: function beforeUpdateCart(params, targetCartItem) {
1199
+ if (params.resources) {
1200
+ var _getCapacityInfoByCar2 = getCapacityInfoByCartItem(targetCartItem),
1201
+ currentCapacity = _getCapacityInfoByCar2.currentCapacity;
1290
1202
  params.resources = params.resources.map(function (n) {
1291
1203
  n.capacity = currentCapacity || 1;
1292
- currentResourcesCapacityMap[n.id] = currentCapacity;
1293
1204
  checkSubResourcesCapacity(n);
1294
1205
  return n;
1295
1206
  });
1296
1207
  }
1208
+ }
1209
+
1210
+ // 更新购物车
1211
+ }, {
1212
+ key: "updateCart",
1213
+ value: function updateCart(params) {
1214
+ var targetCartItem = this.store.cart.getItem(params._id);
1215
+ if (!targetCartItem) {
1216
+ throw new Error("\u6CA1\u6709\u627E\u5230".concat(params._id, "\u8D2D\u7269\u8F66\u5546\u54C1"));
1217
+ }
1218
+ this.beforeUpdateCart(params, targetCartItem);
1297
1219
  this.store.cart.updateItem(params);
1220
+ this.updateCartCheck(params, targetCartItem);
1221
+ }
1222
+
1223
+ /**
1224
+ * 更新购物车以后的一些操作,比如检测资源是否重复,检测资源容量是否足够
1225
+ *
1226
+ * @param {IUpdateItemParams} params
1227
+ * @param {CartItem} targetCartItem
1228
+ * @return {*}
1229
+ * @memberof BookingByStepImpl
1230
+ */
1231
+ }, {
1232
+ key: "updateCartCheck",
1233
+ value: function updateCartCheck(params, targetCartItem) {
1234
+ var _params$resources,
1235
+ _this7 = this;
1236
+ // 零售模板不需要检测
1298
1237
  if (this.otherParams.isRetailTemplate) {
1299
1238
  return;
1300
1239
  }
1240
+ var currentResourcesCapacityMap = {};
1241
+ (_params$resources = params.resources) === null || _params$resources === void 0 || _params$resources.forEach(function (n) {
1242
+ currentResourcesCapacityMap[n.id] = n.capacity;
1243
+ });
1301
1244
  var allOriginResources = [];
1302
1245
  var dateRange = this.store.date.getDateRange();
1303
1246
  if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
@@ -1319,48 +1262,27 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1319
1262
  cartItems.forEach(function (item) {
1320
1263
  if (item._id !== targetCartItem._id) {
1321
1264
  var _item$_origin$resourc;
1265
+ var _getCapacityInfoByCar3 = getCapacityInfoByCartItem(item),
1266
+ currentCapacity = _getCapacityInfoByCar3.currentCapacity;
1322
1267
  var resources = (_item$_origin$resourc = item._origin.resources) === null || _item$_origin$resourc === void 0 ? void 0 : _item$_origin$resourc.filter(function (m) {
1323
1268
  // 检查当前资源是否与目标资源的任何资源匹配
1324
1269
  // 目标资源,应该只取跟当前 m.form_id 相同的资源
1325
- var sameFormIdResources = targetCartItem._origin.resources.filter(function (n) {
1326
- return n.form_id === m.form_id;
1327
- });
1270
+ var sameFormIdResources = filterResourcesByFormItem(targetCartItem._origin.resources, m.form_id);
1328
1271
  if (!(sameFormIdResources !== null && sameFormIdResources !== void 0 && sameFormIdResources.length)) {
1329
1272
  return true;
1330
1273
  }
1331
1274
  return !sameFormIdResources.some(function (targetRes) {
1332
1275
  // 如果新更新进来的资源不是单个预约,其实就不需要检测了资源重叠了,但是需要检测资源 capacity 是否足够
1333
1276
  if (targetRes.resourceType !== 'single') {
1334
- var _item$_productOrigin2;
1335
- var _formatCapacity = formatDefaultCapacitys({
1336
- capacity: (_item$_productOrigin2 = item._productOrigin) === null || _item$_productOrigin2 === void 0 ? void 0 : _item$_productOrigin2.capacity,
1337
- product_bundle: item._origin.product.product_bundle
1338
- });
1339
- var _currentCapacity = getSumCapacity({
1340
- capacity: _formatCapacity
1341
- });
1342
1277
  var originResource = allOriginResources.find(function (n) {
1343
1278
  return n.id === targetRes.id;
1344
1279
  });
1345
- if (currentResourcesCapacityMap[m.id] + _currentCapacity > (originResource === null || originResource === void 0 ? void 0 : originResource.capacity)) {
1346
- return true;
1347
- }
1348
- currentResourcesCapacityMap[m.id] += _currentCapacity;
1349
- return false;
1280
+ var canUse = checkResourceCanUseByCapacity(currentResourcesCapacityMap[m.id], currentCapacity, originResource === null || originResource === void 0 ? void 0 : originResource.capacity);
1281
+ if (canUse) currentResourcesCapacityMap[m.id] += currentCapacity;
1282
+ return !canUse;
1350
1283
  }
1351
1284
  if (item.holder_id !== (targetCartItem === null || targetCartItem === void 0 ? void 0 : targetCartItem.holder_id)) {
1352
- var _targetRes$metadata$c, _m$metadata$combined_;
1353
- // 检查主资源ID是否匹配
1354
- if (targetRes.id === m.id) return true;
1355
- // 检查组合资源的情况
1356
- if (((_targetRes$metadata$c = targetRes.metadata.combined_resource) === null || _targetRes$metadata$c === void 0 ? void 0 : _targetRes$metadata$c.status) === 1 && (
1357
- // 如果现在选择的是组合资源,需要判断
1358
- // 1、当前其他购物车里是否选了当前组合资源的子资源
1359
- // 2、如果其他购物车里的商品也是组合资源,出了组合资源本身的 id 需要判断,还需要判断子资源的 id 是否有交集
1360
- targetRes.metadata.combined_resource.resource_ids.includes(m.id) || targetRes.metadata.combined_resource.resource_ids.some(function (n) {
1361
- return m.metadata.combined_resource.resource_ids.includes(n);
1362
- }))) return true;
1363
- if (((_m$metadata$combined_ = m.metadata.combined_resource) === null || _m$metadata$combined_ === void 0 ? void 0 : _m$metadata$combined_.status) === 1 && m.metadata.combined_resource.resource_ids.includes(targetRes.id)) return true;
1285
+ return checkTwoResourcesIntersection(targetRes, m);
1364
1286
  }
1365
1287
  return false;
1366
1288
  });
@@ -1371,7 +1293,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1371
1293
  var end_time = item.end_time;
1372
1294
  var start_date = item.start_date;
1373
1295
  var end_date = item.end_date;
1374
- _this6.store.cart.updateItem({
1296
+ _this7.store.cart.updateItem({
1375
1297
  _id: item._id,
1376
1298
  resources: resources,
1377
1299
  date: {
@@ -1380,7 +1302,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1380
1302
  }
1381
1303
  });
1382
1304
  } else {
1383
- _this6.store.cart.updateItem({
1305
+ _this7.store.cart.updateItem({
1384
1306
  _id: item._id,
1385
1307
  resources: resources
1386
1308
  });
@@ -1417,208 +1339,75 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1417
1339
  }, {
1418
1340
  key: "batchUpdateCart",
1419
1341
  value: function batchUpdateCart(paramsList) {
1420
- var _this7 = this;
1342
+ var _this8 = this;
1421
1343
  var cartItems = [];
1422
1344
  paramsList.forEach(function (params) {
1423
- var cartItem = _this7.store.cart.formatCartItem(params);
1345
+ var cartItem = _this8.store.cart.formatCartItem(params);
1424
1346
  cartItems.push(cartItem);
1425
1347
  });
1426
1348
  this.store.cart.batchSetItems(cartItems);
1427
1349
  }
1428
1350
 
1429
- /**
1430
- * 从购物车中按类别删除信息
1431
- */
1432
- }, {
1433
- key: "deleteCartItemInfo",
1434
- value: function deleteCartItemInfo(type, _id) {
1435
- this.store.cart.deleteCartItemInfo(type, _id);
1436
- }
1437
- }, {
1438
- key: "checkCartItemByType",
1439
- value: function checkCartItemByType(cartItem, type) {
1440
- return this.store.cart.checkCartItemByType(cartItem, type);
1441
- }
1442
-
1443
- /**
1444
- * 检查购物车商品是否符合条件
1445
- * @param type 类型
1446
- * @returns 不符合条件的购物车商品ID列表
1447
- */
1448
- }, {
1449
- key: "checkCartItems",
1450
- value: function checkCartItems(type) {
1451
- var _this8 = this;
1452
- // 预约流程中普通商品无需检测这些东西
1453
- var cartItems = this.store.cart.getItems().filter(function (n) {
1454
- return !isNormalProduct(n._productOrigin);
1455
- });
1456
- var errorCartItemIds = [];
1457
- cartItems.forEach(function (cartItem) {
1458
- var result = _this8.store.cart.checkCartItemByType(cartItem, type);
1459
- if (!result) {
1460
- errorCartItemIds.push(cartItem._id);
1461
- }
1462
- });
1463
- return errorCartItemIds;
1464
- }
1465
- }, {
1466
- key: "destroy",
1467
- value: function destroy() {
1468
- var _this$store$cart, _this$store$step, _this$store$products, _this$store$guests, _this$store$date, _this$store$accountLi;
1469
- (_this$store$cart = this.store.cart) === null || _this$store$cart === void 0 || _this$store$cart.destroy();
1470
- (_this$store$step = this.store.step) === null || _this$store$step === void 0 || _this$store$step.destroy();
1471
- (_this$store$products = this.store.products) === null || _this$store$products === void 0 || _this$store$products.destroy();
1472
- (_this$store$guests = this.store.guests) === null || _this$store$guests === void 0 || _this$store$guests.destroy();
1473
- (_this$store$date = this.store.date) === null || _this$store$date === void 0 || _this$store$date.destroy();
1474
- (_this$store$accountLi = this.store.accountList) === null || _this$store$accountLi === void 0 || _this$store$accountLi.destroy();
1475
- this.core.effects.offByModuleDestroy(this.name);
1476
- this.core.unregisterModule(this);
1477
- }
1478
-
1479
- // 获取当前购物车内所有关联的资源列表,拼装数据格式
1480
- }, {
1481
- key: "getResourcesList",
1482
- value: function getResourcesList() {
1483
- var _this9 = this;
1484
- var dateRange = this.store.date.getDateRange();
1485
- var resources = [];
1486
- if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
1487
- dateRange.forEach(function (n) {
1488
- if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
1489
- });
1490
- }
1491
- // 如果此时 resources 为空,视作购物车里已经有了 dateRange 数据,此时 dateList 里明确就是那一天的数据
1492
- if (!resources.length) {
1493
- var dateList = this.store.date.getDateList();
1494
- dateList.forEach(function (n) {
1495
- if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
1496
- });
1497
- }
1498
- var resourcesMap = getResourcesMap(cloneDeep(resources));
1499
- var cartItems = this.store.cart.getItems().filter(function (n) {
1500
- return !isNormalProduct(n._productOrigin);
1501
- });
1502
- var arr = [];
1503
- cartItems.forEach(function (cartItem) {
1504
- var _cartItem$_productOri, _cartItem$_productOri2;
1505
- var selectedResources = [];
1506
- var formatCapacity = formatDefaultCapacitys({
1507
- capacity: (_cartItem$_productOri = cartItem._productOrigin) === null || _cartItem$_productOri === void 0 ? void 0 : _cartItem$_productOri.capacity,
1508
- product_bundle: cartItem._origin.product.product_bundle
1509
- });
1510
- cartItem._origin.metadata.capacity = formatCapacity;
1511
- var currentCapacity = getSumCapacity({
1512
- capacity: formatCapacity
1513
- });
1514
- if (cartItem.holder_id) {
1515
- selectedResources = getOthersSelectedResources(cartItems, cartItem.holder_id, resourcesMap);
1516
- } else {
1517
- selectedResources = getOthersCartSelectedResources(cartItems, cartItem._id, resourcesMap);
1518
- }
1519
- var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri2 = cartItem._productOrigin) === null || _cartItem$_productOri2 === void 0 || (_cartItem$_productOri2 = _cartItem$_productOri2.product_resource) === null || _cartItem$_productOri2 === void 0 ? void 0 : _cartItem$_productOri2.resources) || [], selectedResources, currentCapacity);
1520
- // 如果购物车里已经有了时间片,则需要按照时间片过滤
1521
- if (cartItem._origin.start_time) {
1522
- var startTime = dayjs("".concat(cartItem._origin.start_date, " ").concat(cartItem._origin.start_time));
1523
- var endTime = dayjs("".concat(cartItem._origin.end_date, " ").concat(cartItem._origin.end_time));
1524
- var resourcesUseableMap = {};
1525
- productResources.forEach(function (n) {
1526
- // 资源排下序,把单个资源靠前,组合资源排在后面
1527
- n.renderList = n.renderList.sort(function (a, b) {
1528
- var _a$metadata, _b$metadata;
1529
- var aIsCombined = ((_a$metadata = a.metadata) === null || _a$metadata === void 0 || (_a$metadata = _a$metadata.combined_resource) === null || _a$metadata === void 0 ? void 0 : _a$metadata.status) === 1;
1530
- var bIsCombined = ((_b$metadata = b.metadata) === null || _b$metadata === void 0 || (_b$metadata = _b$metadata.combined_resource) === null || _b$metadata === void 0 ? void 0 : _b$metadata.status) === 1;
1531
- if (aIsCombined && !bIsCombined) return 1;
1532
- if (!aIsCombined && bIsCombined) return -1;
1533
- return 0;
1534
- });
1535
- n.renderList = n.renderList.filter(function (m) {
1536
- // m.times 需要做个过滤,假设 timeSlice.start_at 是 09:30 timeSlice.end_at 是 11:30
1537
- // time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
1538
- // 需要判断 time 的开始结束时间 是否包含timeSlice的开始结束时间
1539
- var mTimes = m.times.filter(function (n) {
1540
- return !dayjs(n.start_at).isAfter(dayjs(startTime)) && !dayjs(n.end_at).isBefore(dayjs(endTime));
1541
- });
1542
- // 如果在这个区间的时间一个都没有,可以直接认为这个资源不可用
1543
- if (mTimes.length === 0) {
1544
- return false;
1545
- }
1546
- var canUseArr = mTimes.map(function (item) {
1547
- var _cartItem$_productOri3;
1548
- var res = getIsUsableByTimeItem({
1549
- timeSlice: {
1550
- start_time: startTime.format('HH:mm'),
1551
- end_time: endTime.format('HH:mm'),
1552
- start_at: startTime,
1553
- end_at: endTime
1554
- },
1555
- time: item,
1556
- resource: m,
1557
- currentCount: currentCapacity || 0,
1558
- resourcesUseableMap: resourcesUseableMap,
1559
- cut_off_time: (_cartItem$_productOri3 = cartItem._productOrigin) === null || _cartItem$_productOri3 === void 0 ? void 0 : _cartItem$_productOri3.cut_off_time
1560
- });
1561
- // 如果仅仅是因为子资源容量不够,不应该标记子资源是被占用的情况
1562
- if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
1563
- resourcesUseableMap[m.id] = res.usable;
1564
- }
1565
- return res.usable;
1566
- });
1567
- if (m.onlyComputed) return false;
1568
- // 在已经选定时间的情况下,只要canUseTime 里有一个 false,那就代表不可用
1569
- return !canUseArr.some(function (n) {
1570
- return n === false;
1571
- });
1572
- });
1573
- });
1574
- } else {
1575
- var _cartItem$_productOri4, _this9$shopStore$get;
1576
- var hasFlexibleDuration = ((_cartItem$_productOri4 = cartItem._productOrigin) === null || _cartItem$_productOri4 === void 0 || (_cartItem$_productOri4 = _cartItem$_productOri4.duration) === null || _cartItem$_productOri4 === void 0 ? void 0 : _cartItem$_productOri4.type) === 'flexible';
1577
- var operating_day_boundary = (_this9$shopStore$get = _this9.shopStore.get('core')) === null || _this9$shopStore$get === void 0 || (_this9$shopStore$get = _this9$shopStore$get.core) === null || _this9$shopStore$get === void 0 ? void 0 : _this9$shopStore$get.operating_day_boundary;
1578
- productResources.forEach(function (item) {
1579
- // 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
1580
- // 同时,在这一步尝试去拉一下时间片,基于商品的时长,看每个资源是否还有空余时间能对这个商品做服务,如果没有则过滤
1581
- item.renderList = item.renderList.filter(function (n) {
1582
- var _cartItem$_productOri5, _cartItem$_productOri6;
1583
- var recordCount = n.capacity || 0;
1584
- if (n.onlyComputed) return false;
1585
- // 查一下这个资源基于商品的可用时间片
1586
- var timeSlots = getTimeSlicesByResource({
1587
- resource: n,
1588
- duration: ((_cartItem$_productOri5 = cartItem._productOrigin) === null || _cartItem$_productOri5 === void 0 || (_cartItem$_productOri5 = _cartItem$_productOri5.duration) === null || _cartItem$_productOri5 === void 0 ? void 0 : _cartItem$_productOri5.value) || 10,
1589
- split: 10,
1590
- currentDate: dateRange[0].date,
1591
- hasFlexibleDuration: hasFlexibleDuration,
1592
- cut_off_time: (_cartItem$_productOri6 = cartItem._productOrigin) === null || _cartItem$_productOri6 === void 0 ? void 0 : _cartItem$_productOri6.cut_off_time,
1593
- operating_day_boundary: operating_day_boundary
1594
- });
1595
- return recordCount >= currentCapacity && timeSlots.length > 0;
1596
- });
1597
- });
1351
+ /**
1352
+ * 从购物车中按类别删除信息
1353
+ */
1354
+ }, {
1355
+ key: "deleteCartItemInfo",
1356
+ value: function deleteCartItemInfo(type, _id) {
1357
+ this.store.cart.deleteCartItemInfo(type, _id);
1358
+ }
1359
+ }, {
1360
+ key: "checkCartItemByType",
1361
+ value: function checkCartItemByType(cartItem, type) {
1362
+ return this.store.cart.checkCartItemByType(cartItem, type);
1363
+ }
1364
+
1365
+ /**
1366
+ * 检查购物车商品是否符合条件
1367
+ * @param type 类型
1368
+ * @returns 不符合条件的购物车商品ID列表
1369
+ */
1370
+ }, {
1371
+ key: "checkCartItems",
1372
+ value: function checkCartItems(type) {
1373
+ var _this9 = this;
1374
+ // 预约流程中普通商品无需检测这些东西
1375
+ var cartItems = this.store.cart.getItems().filter(function (n) {
1376
+ return !isNormalProduct(n._productOrigin);
1377
+ });
1378
+ var errorCartItemIds = [];
1379
+ cartItems.forEach(function (cartItem) {
1380
+ var result = _this9.store.cart.checkCartItemByType(cartItem, type);
1381
+ if (!result) {
1382
+ errorCartItemIds.push(cartItem._id);
1598
1383
  }
1599
- arr.push({
1600
- id: cartItem.id,
1601
- // 这里返回的是购物车 id ,后面提交的时候要用的,用这个 id 绑定资源和时间
1602
- _id: cartItem._id,
1603
- // 这里返回的是购物车 id ,后面提交的时候要用的,用这个 id 绑定资源和时间
1604
- product: cartItem._productOrigin,
1605
- resources: productResources,
1606
- holder_id: cartItem.holder_id,
1607
- holder_name: cartItem.holder_title
1608
- });
1609
1384
  });
1610
- return arr;
1385
+ return errorCartItemIds;
1386
+ }
1387
+ }, {
1388
+ key: "destroy",
1389
+ value: function destroy() {
1390
+ var _this$store$cart, _this$store$step, _this$store$products, _this$store$guests, _this$store$date, _this$store$accountLi;
1391
+ (_this$store$cart = this.store.cart) === null || _this$store$cart === void 0 || _this$store$cart.destroy();
1392
+ (_this$store$step = this.store.step) === null || _this$store$step === void 0 || _this$store$step.destroy();
1393
+ (_this$store$products = this.store.products) === null || _this$store$products === void 0 || _this$store$products.destroy();
1394
+ (_this$store$guests = this.store.guests) === null || _this$store$guests === void 0 || _this$store$guests.destroy();
1395
+ (_this$store$date = this.store.date) === null || _this$store$date === void 0 || _this$store$date.destroy();
1396
+ (_this$store$accountLi = this.store.accountList) === null || _this$store$accountLi === void 0 || _this$store$accountLi.destroy();
1397
+ this.core.effects.offByModuleDestroy(this.name);
1398
+ this.core.unregisterModule(this);
1611
1399
  }
1612
1400
 
1613
- // 在日期那边点击下一步的时候,检查这一天购物车里的商品是不是都有资源可以用
1401
+ // 获取当前购物车内所有关联的资源列表,拼装数据格式
1614
1402
  }, {
1615
- key: "checkResourceListForDate",
1616
- value: function checkResourceListForDate() {
1403
+ key: "getResourcesList",
1404
+ value: function getResourcesList() {
1405
+ var _this10 = this;
1617
1406
  var dateRange = this.store.date.getDateRange();
1618
1407
  var resources = [];
1619
1408
  if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
1620
1409
  dateRange.forEach(function (n) {
1621
- if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
1410
+ resources.push.apply(resources, _toConsumableArray(_this10.store.date.getResourcesListByDate(n.date) || []));
1622
1411
  });
1623
1412
  }
1624
1413
  // 如果此时 resources 为空,视作购物车里已经有了 dateRange 数据,此时 dateList 里明确就是那一天的数据
@@ -1634,22 +1423,19 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1634
1423
  });
1635
1424
  var arr = [];
1636
1425
  cartItems.forEach(function (cartItem) {
1637
- var _cartItem$_productOri7, _cartItem$_productOri8;
1426
+ var _cartItem$_productOri;
1638
1427
  var selectedResources = [];
1639
- var formatCapacity = formatDefaultCapacitys({
1640
- capacity: (_cartItem$_productOri7 = cartItem._productOrigin) === null || _cartItem$_productOri7 === void 0 ? void 0 : _cartItem$_productOri7.capacity,
1641
- product_bundle: cartItem._origin.product.product_bundle
1642
- });
1428
+ var _getCapacityInfoByCar4 = getCapacityInfoByCartItem(cartItem),
1429
+ currentCapacity = _getCapacityInfoByCar4.currentCapacity,
1430
+ formatCapacity = _getCapacityInfoByCar4.formatCapacity;
1643
1431
  cartItem._origin.metadata.capacity = formatCapacity;
1644
- var currentCapacity = getSumCapacity({
1645
- capacity: formatCapacity
1646
- });
1647
1432
  if (cartItem.holder_id) {
1648
1433
  selectedResources = getOthersSelectedResources(cartItems, cartItem.holder_id, resourcesMap);
1649
1434
  } else {
1650
1435
  selectedResources = getOthersCartSelectedResources(cartItems, cartItem._id, resourcesMap);
1651
1436
  }
1652
- var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri8 = cartItem._productOrigin) === null || _cartItem$_productOri8 === void 0 || (_cartItem$_productOri8 = _cartItem$_productOri8.product_resource) === null || _cartItem$_productOri8 === void 0 ? void 0 : _cartItem$_productOri8.resources) || [], selectedResources, currentCapacity);
1437
+ // TODO:下面这一坨要放到 resources 模块去
1438
+ var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri = cartItem._productOrigin) === null || _cartItem$_productOri === void 0 || (_cartItem$_productOri = _cartItem$_productOri.product_resource) === null || _cartItem$_productOri === void 0 ? void 0 : _cartItem$_productOri.resources) || [], selectedResources, currentCapacity);
1653
1439
  // 如果购物车里已经有了时间片,则需要按照时间片过滤
1654
1440
  if (cartItem._origin.start_time) {
1655
1441
  var startTime = dayjs("".concat(cartItem._origin.start_date, " ").concat(cartItem._origin.start_time));
@@ -1657,27 +1443,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1657
1443
  var resourcesUseableMap = {};
1658
1444
  productResources.forEach(function (n) {
1659
1445
  // 资源排下序,把单个资源靠前,组合资源排在后面
1660
- n.renderList = n.renderList.sort(function (a, b) {
1661
- var _a$metadata2, _b$metadata2;
1662
- var aIsCombined = ((_a$metadata2 = a.metadata) === null || _a$metadata2 === void 0 || (_a$metadata2 = _a$metadata2.combined_resource) === null || _a$metadata2 === void 0 ? void 0 : _a$metadata2.status) === 1;
1663
- var bIsCombined = ((_b$metadata2 = b.metadata) === null || _b$metadata2 === void 0 || (_b$metadata2 = _b$metadata2.combined_resource) === null || _b$metadata2 === void 0 ? void 0 : _b$metadata2.status) === 1;
1664
- if (aIsCombined && !bIsCombined) return 1;
1665
- if (!aIsCombined && bIsCombined) return -1;
1666
- return 0;
1667
- });
1446
+ n.renderList = sortCombinedResources(n.renderList);
1668
1447
  n.renderList = n.renderList.filter(function (m) {
1669
1448
  // m.times 需要做个过滤,假设 timeSlice.start_at 是 09:30 timeSlice.end_at 是 11:30
1670
1449
  // time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
1671
1450
  // 需要判断 time 的开始结束时间 是否包含timeSlice的开始结束时间
1672
- var mTimes = m.times.filter(function (n) {
1673
- return !dayjs(n.start_at).isAfter(dayjs(startTime)) && !dayjs(n.end_at).isBefore(dayjs(endTime));
1674
- });
1451
+ var mTimes = filterConditionTimeSlots(m.times, startTime, endTime);
1675
1452
  // 如果在这个区间的时间一个都没有,可以直接认为这个资源不可用
1676
1453
  if (mTimes.length === 0) {
1677
1454
  return false;
1678
1455
  }
1679
1456
  var canUseArr = mTimes.map(function (item) {
1680
- var _cartItem$_productOri9;
1457
+ var _cartItem$_productOri2;
1681
1458
  var res = getIsUsableByTimeItem({
1682
1459
  timeSlice: {
1683
1460
  start_time: startTime.format('HH:mm'),
@@ -1689,9 +1466,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1689
1466
  resource: m,
1690
1467
  currentCount: currentCapacity || 0,
1691
1468
  resourcesUseableMap: resourcesUseableMap,
1692
- cut_off_time: (_cartItem$_productOri9 = cartItem._productOrigin) === null || _cartItem$_productOri9 === void 0 ? void 0 : _cartItem$_productOri9.cut_off_time
1469
+ cut_off_time: (_cartItem$_productOri2 = cartItem._productOrigin) === null || _cartItem$_productOri2 === void 0 ? void 0 : _cartItem$_productOri2.cut_off_time
1693
1470
  });
1694
- // 如果仅仅是因为子资源容量不够,不应该标记子资源是被占用的情况
1471
+ // 如果仅仅是因为子资源容量不够,不应该标记子资源是被占用的情况(因为组合资源还需要判断子资源够不够)
1695
1472
  if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
1696
1473
  resourcesUseableMap[m.id] = res.usable;
1697
1474
  }
@@ -1705,19 +1482,25 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1705
1482
  });
1706
1483
  });
1707
1484
  } else {
1485
+ var _cartItem$_productOri3, _this10$shopStore$get;
1486
+ var hasFlexibleDuration = ((_cartItem$_productOri3 = cartItem._productOrigin) === null || _cartItem$_productOri3 === void 0 || (_cartItem$_productOri3 = _cartItem$_productOri3.duration) === null || _cartItem$_productOri3 === void 0 ? void 0 : _cartItem$_productOri3.type) === 'flexible';
1487
+ var operating_day_boundary = (_this10$shopStore$get = _this10.shopStore.get('core')) === null || _this10$shopStore$get === void 0 || (_this10$shopStore$get = _this10$shopStore$get.core) === null || _this10$shopStore$get === void 0 ? void 0 : _this10$shopStore$get.operating_day_boundary;
1708
1488
  productResources.forEach(function (item) {
1709
1489
  // 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
1710
1490
  // 同时,在这一步尝试去拉一下时间片,基于商品的时长,看每个资源是否还有空余时间能对这个商品做服务,如果没有则过滤
1711
1491
  item.renderList = item.renderList.filter(function (n) {
1712
- var _cartItem$_productOri10;
1492
+ var _cartItem$_productOri4, _cartItem$_productOri5;
1713
1493
  var recordCount = n.capacity || 0;
1714
1494
  if (n.onlyComputed) return false;
1715
1495
  // 查一下这个资源基于商品的可用时间片
1716
1496
  var timeSlots = getTimeSlicesByResource({
1717
1497
  resource: n,
1718
- duration: ((_cartItem$_productOri10 = cartItem._productOrigin) === null || _cartItem$_productOri10 === void 0 || (_cartItem$_productOri10 = _cartItem$_productOri10.duration) === null || _cartItem$_productOri10 === void 0 ? void 0 : _cartItem$_productOri10.value) || 10,
1498
+ duration: ((_cartItem$_productOri4 = cartItem._productOrigin) === null || _cartItem$_productOri4 === void 0 || (_cartItem$_productOri4 = _cartItem$_productOri4.duration) === null || _cartItem$_productOri4 === void 0 ? void 0 : _cartItem$_productOri4.value) || 10,
1719
1499
  split: 10,
1720
- currentDate: dateRange[0].date
1500
+ currentDate: dateRange[0].date,
1501
+ hasFlexibleDuration: hasFlexibleDuration,
1502
+ cut_off_time: (_cartItem$_productOri5 = cartItem._productOrigin) === null || _cartItem$_productOri5 === void 0 ? void 0 : _cartItem$_productOri5.cut_off_time,
1503
+ operating_day_boundary: operating_day_boundary
1721
1504
  });
1722
1505
  return recordCount >= currentCapacity && timeSlots.length > 0;
1723
1506
  });
@@ -1728,23 +1511,46 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1728
1511
  // 这里返回的是购物车 id ,后面提交的时候要用的,用这个 id 绑定资源和时间
1729
1512
  _id: cartItem._id,
1730
1513
  // 这里返回的是购物车 id ,后面提交的时候要用的,用这个 id 绑定资源和时间
1731
- productResources: productResources
1514
+ product: cartItem._productOrigin,
1515
+ resources: productResources,
1516
+ holder_id: cartItem.holder_id,
1517
+ holder_name: cartItem.holder_title
1732
1518
  });
1733
1519
  });
1734
- // 检查 productResources里是不是每一项资源的 renderList 里都有数据
1735
- var hasResource = arr.every(function (n) {
1736
- return n.productResources.every(function (m) {
1737
- return m.renderList.length > 0;
1520
+ return arr;
1521
+ }
1522
+
1523
+ /**
1524
+ * 在日期那边点击下一步的时候,检查这一天购物车里的商品是不是都有资源可以用
1525
+ *
1526
+ * @return {*}
1527
+ * @memberof BookingByStepImpl
1528
+ */
1529
+ }, {
1530
+ key: "checkResourceListForDate",
1531
+ value: function checkResourceListForDate() {
1532
+ var resourcesList = this.getResourcesList();
1533
+
1534
+ // 检查每一项资源的 renderList 里是否都有数据
1535
+ var hasResource = resourcesList.every(function (item) {
1536
+ return item.resources.every(function (resource) {
1537
+ return resource.renderList.length > 0;
1738
1538
  });
1739
1539
  });
1740
1540
  return hasResource;
1741
1541
  }
1742
1542
 
1743
- // 给单个购物车里的商品获取资源列表
1543
+ /**
1544
+ * 给单个购物车里的商品获取资源列表,给 UI 用的
1545
+ *
1546
+ * @param {(string | number)} id
1547
+ * @return {*}
1548
+ * @memberof BookingByStepImpl
1549
+ */
1744
1550
  }, {
1745
1551
  key: "getResourcesListByCartItem",
1746
1552
  value: function getResourcesListByCartItem(id) {
1747
- var _targetCartItem$_prod2, _targetCartItem$_prod3;
1553
+ var _targetCartItem$_prod;
1748
1554
  var cartItems = this.store.cart.getItems().filter(function (n) {
1749
1555
  return !isNormalProduct(n._productOrigin);
1750
1556
  });
@@ -1762,19 +1568,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1762
1568
  throw new Error("\u6CA1\u6709\u627E\u5230".concat(id, "\u8D2D\u7269\u8F66\u5546\u54C1"));
1763
1569
  }
1764
1570
  var selectedResources = [];
1765
- var formatCapacity = formatDefaultCapacitys({
1766
- capacity: (_targetCartItem$_prod2 = targetCartItem._productOrigin) === null || _targetCartItem$_prod2 === void 0 ? void 0 : _targetCartItem$_prod2.capacity,
1767
- product_bundle: targetCartItem._origin.product.product_bundle
1768
- });
1769
- var currentCapacity = getSumCapacity({
1770
- capacity: formatCapacity
1771
- });
1571
+ var _getCapacityInfoByCar5 = getCapacityInfoByCartItem(targetCartItem),
1572
+ currentCapacity = _getCapacityInfoByCar5.currentCapacity;
1772
1573
  if (targetCartItem.holder_id) {
1773
1574
  selectedResources = getOthersSelectedResources(cartItems, targetCartItem.holder_id, resourcesMap);
1774
1575
  } else {
1775
1576
  selectedResources = getOthersCartSelectedResources(cartItems, targetCartItem._id, resourcesMap);
1776
1577
  }
1777
- var productResources = getResourcesByProduct(resourcesMap, ((_targetCartItem$_prod3 = targetCartItem._productOrigin) === null || _targetCartItem$_prod3 === void 0 || (_targetCartItem$_prod3 = _targetCartItem$_prod3.product_resource) === null || _targetCartItem$_prod3 === void 0 ? void 0 : _targetCartItem$_prod3.resources) || [], selectedResources, currentCapacity);
1578
+ var productResources = getResourcesByProduct(resourcesMap, ((_targetCartItem$_prod = targetCartItem._productOrigin) === null || _targetCartItem$_prod === void 0 || (_targetCartItem$_prod = _targetCartItem$_prod.product_resource) === null || _targetCartItem$_prod === void 0 ? void 0 : _targetCartItem$_prod.resources) || [], selectedResources, currentCapacity);
1778
1579
  productResources.forEach(function (item) {
1779
1580
  item.renderList = item.renderList.filter(function (n) {
1780
1581
  var recordCount = n.capacity || 0;
@@ -1796,36 +1597,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1796
1597
  }
1797
1598
  }
1798
1599
 
1799
- // 通过资源列表和指定的资源 id,获取指定资源的时间切片
1800
- }, {
1801
- key: "getResourceTimeSlot",
1802
- value: function getResourceTimeSlot(_ref7) {
1803
- var product = _ref7.product,
1804
- resources = _ref7.resources,
1805
- currentResourceId = _ref7.currentResourceId;
1806
- var dateRange = this.store.date.getDateRange();
1807
- var timeSlots = getTimeSlicesByResource({
1808
- resource: resources.find(function (n) {
1809
- return n.id === currentResourceId;
1810
- }),
1811
- duration: product.duration.value,
1812
- split: 10,
1813
- currentDate: dateRange[0].date
1814
- });
1815
- return timeSlots;
1816
- }
1817
-
1818
1600
  // 自动分派可用资源-pro 版,ui 传递某个账号,自动给某个账号下所有商品分配第一种资源
1819
1601
  }, {
1820
1602
  key: "autoSelectAccountResources",
1821
- value: function autoSelectAccountResources(_ref8) {
1822
- var _cartItem$_productOri11, _allProductResources$;
1823
- var cartItem = _ref8.cartItem,
1824
- holder_id = _ref8.holder_id,
1825
- resources_code = _ref8.resources_code,
1826
- timeSlots = _ref8.timeSlots,
1827
- countMap = _ref8.countMap,
1828
- capacity = _ref8.capacity;
1603
+ value: function autoSelectAccountResources(_ref9) {
1604
+ var _cartItem$_productOri6, _allProductResources$;
1605
+ var cartItem = _ref9.cartItem,
1606
+ holder_id = _ref9.holder_id,
1607
+ resources_code = _ref9.resources_code,
1608
+ timeSlots = _ref9.timeSlots,
1609
+ countMap = _ref9.countMap,
1610
+ capacity = _ref9.capacity;
1829
1611
  if (isNormalProduct(cartItem._productOrigin)) {
1830
1612
  return {};
1831
1613
  }
@@ -1839,10 +1621,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1839
1621
  if (!accountCartItems.length) {
1840
1622
  accountCartItems = cartItems;
1841
1623
  }
1842
- // duration=所有商品时间的集合
1624
+ // duration=所有商品时间的集合,如果是灵活时长,当做占用 10 分钟处理
1843
1625
  var duration = accountCartItems.reduce(function (acc, n) {
1844
- var _n$_productOrigin2;
1845
- return acc + (((_n$_productOrigin2 = n._productOrigin) === null || _n$_productOrigin2 === void 0 || (_n$_productOrigin2 = _n$_productOrigin2.duration) === null || _n$_productOrigin2 === void 0 ? void 0 : _n$_productOrigin2.value) || 10);
1626
+ var _n$_productOrigin;
1627
+ return acc + (((_n$_productOrigin = n._productOrigin) === null || _n$_productOrigin === void 0 || (_n$_productOrigin = _n$_productOrigin.duration) === null || _n$_productOrigin === void 0 ? void 0 : _n$_productOrigin.value) || 10);
1846
1628
  }, 0);
1847
1629
  var AllResources = [];
1848
1630
  if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
@@ -1860,15 +1642,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1860
1642
  var resourcesMap = getResourcesMap(cloneDeep(AllResources));
1861
1643
  var allCartItems = cloneDeep(this.store.cart.getItems());
1862
1644
  var selectedResources = getOthersSelectedResources(allCartItems, holder_id, resourcesMap);
1863
- var allProductResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri11 = cartItem._productOrigin) === null || _cartItem$_productOri11 === void 0 || (_cartItem$_productOri11 = _cartItem$_productOri11.product_resource) === null || _cartItem$_productOri11 === void 0 ? void 0 : _cartItem$_productOri11.resources) || [], selectedResources, 1);
1645
+ var allProductResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri6 = cartItem._productOrigin) === null || _cartItem$_productOri6 === void 0 || (_cartItem$_productOri6 = _cartItem$_productOri6.product_resource) === null || _cartItem$_productOri6 === void 0 ? void 0 : _cartItem$_productOri6.resources) || [], selectedResources, 1);
1864
1646
  var resources = ((_allProductResources$ = allProductResources.find(function (n) {
1865
1647
  return n.code === resources_code;
1866
1648
  })) === null || _allProductResources$ === void 0 ? void 0 : _allProductResources$.renderList) || [];
1867
1649
  // 资源排下序,把单个资源靠前,组合资源排在后面
1868
1650
  resources.sort(function (a, b) {
1869
- var _a$metadata3, _b$metadata3;
1870
- var aIsCombined = ((_a$metadata3 = a.metadata) === null || _a$metadata3 === void 0 || (_a$metadata3 = _a$metadata3.combined_resource) === null || _a$metadata3 === void 0 ? void 0 : _a$metadata3.status) === 1;
1871
- var bIsCombined = ((_b$metadata3 = b.metadata) === null || _b$metadata3 === void 0 || (_b$metadata3 = _b$metadata3.combined_resource) === null || _b$metadata3 === void 0 ? void 0 : _b$metadata3.status) === 1;
1651
+ var _a$metadata, _b$metadata;
1652
+ var aIsCombined = ((_a$metadata = a.metadata) === null || _a$metadata === void 0 || (_a$metadata = _a$metadata.combined_resource) === null || _a$metadata === void 0 ? void 0 : _a$metadata.status) === 1;
1653
+ var bIsCombined = ((_b$metadata = b.metadata) === null || _b$metadata === void 0 || (_b$metadata = _b$metadata.combined_resource) === null || _b$metadata === void 0 ? void 0 : _b$metadata.status) === 1;
1872
1654
  if (aIsCombined && !bIsCombined) return 1;
1873
1655
  if (!aIsCombined && bIsCombined) return -1;
1874
1656
  return 0;
@@ -1889,11 +1671,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1889
1671
  // 根据 start_time 和 end_time 去匹配资源
1890
1672
  var targetResource = null;
1891
1673
  var targetResourceTime = 0;
1892
- var _iterator3 = _createForOfIteratorHelper(resources),
1893
- _step3;
1674
+ var _iterator2 = _createForOfIteratorHelper(resources),
1675
+ _step2;
1894
1676
  try {
1895
- var _loop2 = function _loop2() {
1896
- var n = _step3.value;
1677
+ var _loop = function _loop() {
1678
+ var n = _step2.value;
1897
1679
  // 如果资源是独占的,并且 countMap 里选择过这个资源,则直接跳过
1898
1680
  // if (n.resourceType === 'single' && countMap[n.id]) {
1899
1681
  // resourcesUseableMap[n.id] = false;
@@ -1921,14 +1703,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1921
1703
  return 0; // continue
1922
1704
  }
1923
1705
  var canUseTime = mTimes.find(function (item) {
1924
- var _cartItem$_productOri12;
1706
+ var _cartItem$_productOri7;
1925
1707
  var res = getIsUsableByTimeItem({
1926
1708
  timeSlice: timeSlots,
1927
1709
  time: item,
1928
1710
  resource: n,
1929
1711
  currentCount: totalCapacity + (capacity || 0),
1930
1712
  resourcesUseableMap: resourcesUseableMap,
1931
- cut_off_time: (_cartItem$_productOri12 = cartItem._productOrigin) === null || _cartItem$_productOri12 === void 0 ? void 0 : _cartItem$_productOri12.cut_off_time
1713
+ cut_off_time: (_cartItem$_productOri7 = cartItem._productOrigin) === null || _cartItem$_productOri7 === void 0 ? void 0 : _cartItem$_productOri7.cut_off_time
1932
1714
  });
1933
1715
  // 如果只是因为子资源容量不够,而不是子资源被预约导致没时间片,不应该标记子资源为不可用,从而影响组合资源的情况
1934
1716
  if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[n.id]) !== false && res.reason !== 'capacityOnly') {
@@ -1948,15 +1730,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1948
1730
  }
1949
1731
  },
1950
1732
  _ret;
1951
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
1952
- _ret = _loop2();
1733
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
1734
+ _ret = _loop();
1953
1735
  if (_ret === 0) continue;
1954
1736
  if (_ret === 1) break;
1955
1737
  }
1956
1738
  } catch (err) {
1957
- _iterator3.e(err);
1739
+ _iterator2.e(err);
1958
1740
  } finally {
1959
- _iterator3.f();
1741
+ _iterator2.f();
1960
1742
  }
1961
1743
  return {
1962
1744
  selectedResource: targetResource
@@ -1991,7 +1773,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1991
1773
  key: "autoSelectAllProductResources",
1992
1774
  value: function autoSelectAllProductResources(resources_code, timeSlots) {
1993
1775
  var _dateRange$4,
1994
- _this10 = this;
1776
+ _this11 = this;
1995
1777
  var dateRange = this.store.date.getDateRange();
1996
1778
  var resources = [];
1997
1779
  if (dateRange !== null && dateRange !== void 0 && (_dateRange$4 = dateRange[0]) !== null && _dateRange$4 !== void 0 && _dateRange$4.date) {
@@ -1999,10 +1781,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1999
1781
  if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
2000
1782
  });
2001
1783
  }
2002
- // const resourcesMap = getResourcesMap(cloneDeep(resources));
2003
1784
  // 一个账号一个账号处理
2004
1785
  var errorList = [];
1786
+ // 资源使用情况-单个预约
2005
1787
  var selectResourcesMap = {};
1788
+ // 资源使用情况-多个预约
2006
1789
  var selectResourcesWithTimeSlots = {};
2007
1790
  var accountList = this.store.accountList.getAccounts();
2008
1791
  var selectForCartResources = function selectForCartResources(cartItems) {
@@ -2012,18 +1795,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2012
1795
  // 第一个商品分配完以后,第二个商品分配的start_time应该是第一个商品的 end_time ,然后 end_time 应该是 start_time+duration
2013
1796
  // 判断购物车里是否有 flexible 类型的商品,如果有则不累加时间
2014
1797
  var hasFlexibleProduct = cartItems.some(function (item) {
2015
- var _item$_productOrigin3;
2016
- return ((_item$_productOrigin3 = item._productOrigin) === null || _item$_productOrigin3 === void 0 || (_item$_productOrigin3 = _item$_productOrigin3.duration) === null || _item$_productOrigin3 === void 0 ? void 0 : _item$_productOrigin3.type) === 'flexible';
1798
+ var _item$_productOrigin;
1799
+ return ((_item$_productOrigin = item._productOrigin) === null || _item$_productOrigin === void 0 || (_item$_productOrigin = _item$_productOrigin.duration) === null || _item$_productOrigin === void 0 ? void 0 : _item$_productOrigin.type) === 'flexible';
2017
1800
  });
2018
1801
  cartItems.forEach(function (item, index) {
2019
- var _item$_productOrigin4;
2020
- var formatCapacity = formatDefaultCapacitys({
2021
- capacity: (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.capacity,
2022
- product_bundle: item._origin.product.product_bundle
2023
- });
2024
- var currentCapacity = getSumCapacity({
2025
- capacity: formatCapacity
2026
- });
1802
+ var _getCapacityInfoByCar6 = getCapacityInfoByCartItem(item),
1803
+ currentCapacity = _getCapacityInfoByCar6.currentCapacity;
2027
1804
  // 如果商品已经有时间数据了,意味着是通过先选日期再选商品流程进来的,相当于时间切片已经选中了
2028
1805
  if (item._origin.start_time && !(timeSlots !== null && timeSlots !== void 0 && timeSlots.start_time)) {
2029
1806
  recordTimeSlots = {
@@ -2034,18 +1811,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2034
1811
  };
2035
1812
  }
2036
1813
  if (recordTimeSlots) {
2037
- var _item$_productOrigin5, _item$_productOrigin6;
1814
+ var _item$_productOrigin2, _item$_productOrigin3;
2038
1815
  // 同一账号下,如果当前商品不是第一个,则需要根据上一个商品的 end_time 和 duration 计算出当前商品的 start_time 和 end_time
2039
1816
  // 前提:当前资源是单个预约才需要这么做
2040
- var currentResourceConfig = (_item$_productOrigin5 = item._productOrigin) === null || _item$_productOrigin5 === void 0 || (_item$_productOrigin5 = _item$_productOrigin5.product_resource) === null || _item$_productOrigin5 === void 0 || (_item$_productOrigin5 = _item$_productOrigin5.resources) === null || _item$_productOrigin5 === void 0 ? void 0 : _item$_productOrigin5.find(function (n) {
1817
+ var currentResourceConfig = (_item$_productOrigin2 = item._productOrigin) === null || _item$_productOrigin2 === void 0 || (_item$_productOrigin2 = _item$_productOrigin2.product_resource) === null || _item$_productOrigin2 === void 0 || (_item$_productOrigin2 = _item$_productOrigin2.resources) === null || _item$_productOrigin2 === void 0 ? void 0 : _item$_productOrigin2.find(function (n) {
2041
1818
  return n.code === resources_code;
2042
1819
  });
2043
- var resourceBookingType = (currentResourceConfig === null || currentResourceConfig === void 0 ? void 0 : currentResourceConfig.type) || 'single';
2044
- // 只有 duration 类商品需要这个操作
2045
- if (index !== 0 && recordTimeSlots && (currentResourceConfig === null || currentResourceConfig === void 0 ? void 0 : currentResourceConfig.type) === 'single' && (_item$_productOrigin6 = item._productOrigin) !== null && _item$_productOrigin6 !== void 0 && _item$_productOrigin6.duration && !hasFlexibleProduct) {
2046
- var _item$_productOrigin7, _item$_productOrigin8;
2047
- var start_at = dayjs(recordTimeSlots.end_time).add(((_item$_productOrigin7 = item._productOrigin) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.duration) === null || _item$_productOrigin7 === void 0 ? void 0 : _item$_productOrigin7.value) || 10, 'minutes');
2048
- var end_at = start_at.add(((_item$_productOrigin8 = item._productOrigin) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.duration) === null || _item$_productOrigin8 === void 0 ? void 0 : _item$_productOrigin8.value) || 10, 'minutes');
1820
+ // 只有 duration 类商品且不含有灵活时间的商品需要这个操作
1821
+ if (index !== 0 && recordTimeSlots && (currentResourceConfig === null || currentResourceConfig === void 0 ? void 0 : currentResourceConfig.type) === 'single' && (_item$_productOrigin3 = item._productOrigin) !== null && _item$_productOrigin3 !== void 0 && _item$_productOrigin3.duration && !hasFlexibleProduct) {
1822
+ var _item$_productOrigin4, _item$_productOrigin5;
1823
+ var start_at = dayjs(recordTimeSlots.end_time).add(((_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.duration) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.value) || 10, 'minutes');
1824
+ var end_at = start_at.add(((_item$_productOrigin5 = item._productOrigin) === null || _item$_productOrigin5 === void 0 || (_item$_productOrigin5 = _item$_productOrigin5.duration) === null || _item$_productOrigin5 === void 0 ? void 0 : _item$_productOrigin5.value) || 10, 'minutes');
2049
1825
  recordTimeSlots = {
2050
1826
  start_time: start_at.format('HH:mm'),
2051
1827
  end_time: end_at.format('HH:mm'),
@@ -2054,7 +1830,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2054
1830
  };
2055
1831
  }
2056
1832
  // 如果传递了 timeSlots,代表是第二种资源,则直接拿 timeSlots 去匹配
2057
- var res = _this10.autoSelectAccountResources({
1833
+ var res = _this11.autoSelectAccountResources({
2058
1834
  cartItem: item,
2059
1835
  holder_id: item.holder_id,
2060
1836
  resources_code: resources_code,
@@ -2062,10 +1838,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2062
1838
  countMap: selectResourcesWithTimeSlots,
2063
1839
  capacity: currentCapacity
2064
1840
  });
2065
- // // 如果购物车里已经有同类型的 form_id 的资源了,则不处理
2066
- // if (item._origin.resources?.some((n: any) => n.form_id === res?.selectedResource?.form_id)) {
2067
- // return
2068
- // }
2069
1841
  if (res !== null && res !== void 0 && res.selectedResource) {
2070
1842
  if (!selectResourcesWithTimeSlots[res.selectedResource.id]) {
2071
1843
  selectResourcesWithTimeSlots[res.selectedResource.id] = [{
@@ -2080,7 +1852,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2080
1852
  }
2081
1853
  res.selectedResource.capacity = currentCapacity;
2082
1854
  checkSubResourcesCapacity(res.selectedResource);
2083
- _this10.store.cart.updateItem({
1855
+ _this11.store.cart.updateItem({
2084
1856
  _id: item._id,
2085
1857
  // 这里要做去重,避免出现同样类型的资源被塞进同一个商品
2086
1858
  resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
@@ -2093,12 +1865,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2093
1865
  errorList.push(item._id);
2094
1866
  }
2095
1867
  } else {
2096
- var _item$_productOrigin9, _productResources$fin;
1868
+ var _item$_productOrigin6, _productResources$fin;
2097
1869
  // 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
2098
- var allCartItems = cloneDeep(_this10.store.cart.getItems());
1870
+ // 能进到这种逻辑,说明是 duration 类商品或者灵活时长商品,且是第一种资源,还没有确定时间
1871
+ var allCartItems = cloneDeep(_this11.store.cart.getItems());
2099
1872
  // 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
2100
1873
  var selectedResources = [];
2101
- var _resources = cloneDeep(((_item$_productOrigin9 = item._productOrigin) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.product_resource) === null || _item$_productOrigin9 === void 0 ? void 0 : _item$_productOrigin9.resources) || []);
1874
+ var _resources = cloneDeep(((_item$_productOrigin6 = item._productOrigin) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.product_resource) === null || _item$_productOrigin6 === void 0 ? void 0 : _item$_productOrigin6.resources) || []);
2102
1875
  var currentResourcesRenderList = [];
2103
1876
  _resources.forEach(function (n) {
2104
1877
  var _n$renderList;
@@ -2159,7 +1932,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2159
1932
  } else {
2160
1933
  selectResourcesMap[targetResource.id] += currentCapacity;
2161
1934
  }
2162
- _this10.store.cart.updateItem({
1935
+ _this11.store.cart.updateItem({
2163
1936
  _id: item._id,
2164
1937
  resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
2165
1938
  return existingRes.resourceType !== targetRenderList[0].resourceType;
@@ -2179,7 +1952,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2179
1952
  // 如果购物车里没有 holderid数据,证明不按 holder 类流程预约走,给所有购物车一次性分派即可,不做账号下资源互斥逻辑
2180
1953
  if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
2181
1954
  accountList.forEach(function (account) {
2182
- var cartItems = _this10.store.cart.getCartByAccount(account.getId());
1955
+ var cartItems = _this11.store.cart.getCartByAccount(account.getId());
2183
1956
  selectForCartResources(cartItems);
2184
1957
  });
2185
1958
  } else {
@@ -2194,7 +1967,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2194
1967
  key: "getTimeSlotByAllResources",
2195
1968
  value: function getTimeSlotByAllResources(resources_code) {
2196
1969
  var _dateRange,
2197
- _this11 = this,
1970
+ _this12 = this,
2198
1971
  _cartItems$,
2199
1972
  _cartItems$2,
2200
1973
  _this$shopStore$get;
@@ -2213,8 +1986,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2213
1986
  var maxCutOffTime = undefined;
2214
1987
  var maxCutOffTimeValue = dayjs();
2215
1988
  cartItems.forEach(function (item) {
2216
- var _item$_productOrigin10, _item$_productOrigin11, _item$_productOrigin12, _item$_productOrigin13;
2217
- (_item$_productOrigin10 = item._productOrigin) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.product_resource) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.resources) === null || _item$_productOrigin10 === void 0 || _item$_productOrigin10.forEach(function (n) {
1989
+ var _item$_productOrigin7, _item$_productOrigin8, _item$_productOrigin9, _item$_productOrigin10;
1990
+ (_item$_productOrigin7 = item._productOrigin) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.product_resource) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.resources) === null || _item$_productOrigin7 === void 0 || _item$_productOrigin7.forEach(function (n) {
2218
1991
  // TODO: 少了个 status 的判断
2219
1992
  if (n.code === resources_code) {
2220
1993
  resources.push.apply(resources, _toConsumableArray(n.renderList || []));
@@ -2227,10 +2000,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2227
2000
  if (item.resource_id) {
2228
2001
  resourceIds.push(item.resource_id);
2229
2002
  }
2230
- resourcesTypeId = item === null || item === void 0 || (_item$_productOrigin11 = item._productOrigin) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.product_resource) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.resources) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.find(function (n) {
2003
+ resourcesTypeId = item === null || item === void 0 || (_item$_productOrigin8 = item._productOrigin) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.product_resource) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.resources) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.find(function (n) {
2231
2004
  return n.code === resources_code;
2232
- })) === null || _item$_productOrigin11 === void 0 ? void 0 : _item$_productOrigin11.id;
2233
- if ((_item$_productOrigin12 = item._productOrigin) !== null && _item$_productOrigin12 !== void 0 && _item$_productOrigin12.cut_off_time && ((_item$_productOrigin13 = item._productOrigin) === null || _item$_productOrigin13 === void 0 ? void 0 : _item$_productOrigin13.cut_off_time.type) === 'advance') {
2005
+ })) === null || _item$_productOrigin8 === void 0 ? void 0 : _item$_productOrigin8.id;
2006
+ if ((_item$_productOrigin9 = item._productOrigin) !== null && _item$_productOrigin9 !== void 0 && _item$_productOrigin9.cut_off_time && ((_item$_productOrigin10 = item._productOrigin) === null || _item$_productOrigin10 === void 0 ? void 0 : _item$_productOrigin10.cut_off_time.type) === 'advance') {
2234
2007
  var currentCutOffTime = dayjs().add(item._productOrigin.cut_off_time.unit, item._productOrigin.cut_off_time.unit_type);
2235
2008
  if (currentCutOffTime.isAfter(maxCutOffTimeValue, 'minute')) {
2236
2009
  maxCutOffTimeValue = currentCutOffTime;
@@ -2258,13 +2031,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2258
2031
  cartItems.forEach(function (item) {
2259
2032
  // 单个预约累加账号 多个预约取最大值
2260
2033
  if (isSingleResource) {
2261
- var _item$_productOrigin14;
2262
- accountDuration += ((_item$_productOrigin14 = item._productOrigin) === null || _item$_productOrigin14 === void 0 || (_item$_productOrigin14 = _item$_productOrigin14.duration) === null || _item$_productOrigin14 === void 0 ? void 0 : _item$_productOrigin14.value) || 10;
2034
+ var _item$_productOrigin11;
2035
+ accountDuration += ((_item$_productOrigin11 = item._productOrigin) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.duration) === null || _item$_productOrigin11 === void 0 ? void 0 : _item$_productOrigin11.value) || 10;
2263
2036
  } else {
2264
- var _item$_productOrigin15;
2265
- if (accountDuration < (((_item$_productOrigin15 = item._productOrigin) === null || _item$_productOrigin15 === void 0 || (_item$_productOrigin15 = _item$_productOrigin15.duration) === null || _item$_productOrigin15 === void 0 ? void 0 : _item$_productOrigin15.value) || 10)) {
2266
- var _item$_productOrigin16;
2267
- accountDuration = ((_item$_productOrigin16 = item._productOrigin) === null || _item$_productOrigin16 === void 0 || (_item$_productOrigin16 = _item$_productOrigin16.duration) === null || _item$_productOrigin16 === void 0 ? void 0 : _item$_productOrigin16.value) || 10;
2037
+ var _item$_productOrigin12;
2038
+ if (accountDuration < (((_item$_productOrigin12 = item._productOrigin) === null || _item$_productOrigin12 === void 0 || (_item$_productOrigin12 = _item$_productOrigin12.duration) === null || _item$_productOrigin12 === void 0 ? void 0 : _item$_productOrigin12.value) || 10)) {
2039
+ var _item$_productOrigin13;
2040
+ accountDuration = ((_item$_productOrigin13 = item._productOrigin) === null || _item$_productOrigin13 === void 0 || (_item$_productOrigin13 = _item$_productOrigin13.duration) === null || _item$_productOrigin13 === void 0 ? void 0 : _item$_productOrigin13.value) || 10;
2268
2041
  }
2269
2042
  }
2270
2043
  });
@@ -2274,7 +2047,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2274
2047
  };
2275
2048
  if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
2276
2049
  accountList.forEach(function (account) {
2277
- var cartItems = _this11.store.cart.getCartByAccount(account.getId());
2050
+ var cartItems = _this12.store.cart.getCartByAccount(account.getId());
2278
2051
  checkDuration(cartItems);
2279
2052
  });
2280
2053
  } else {
@@ -2301,8 +2074,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2301
2074
  }
2302
2075
  var resourcesUseableMap = {};
2303
2076
  var hasFlexibleDuration = cartItems.some(function (item) {
2304
- var _item$_productOrigin17;
2305
- return ((_item$_productOrigin17 = item._productOrigin) === null || _item$_productOrigin17 === void 0 || (_item$_productOrigin17 = _item$_productOrigin17.duration) === null || _item$_productOrigin17 === void 0 ? void 0 : _item$_productOrigin17.type) === 'flexible';
2077
+ var _item$_productOrigin14;
2078
+ return ((_item$_productOrigin14 = item._productOrigin) === null || _item$_productOrigin14 === void 0 || (_item$_productOrigin14 = _item$_productOrigin14.duration) === null || _item$_productOrigin14 === void 0 ? void 0 : _item$_productOrigin14.type) === 'flexible';
2306
2079
  });
2307
2080
  var operating_day_boundary = (_this$shopStore$get = this.shopStore.get('core')) === null || _this$shopStore$get === void 0 || (_this$shopStore$get = _this$shopStore$get.core) === null || _this$shopStore$get === void 0 ? void 0 : _this$shopStore$get.operating_day_boundary;
2308
2081
  var timeSlots = getTimeSlicesByResources({
@@ -2324,7 +2097,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2324
2097
  key: "submitTimeSlot",
2325
2098
  value: function submitTimeSlot(timeSlots) {
2326
2099
  var _this$shopStore$get2,
2327
- _this12 = this;
2100
+ _this13 = this;
2328
2101
  // 以账号为维度处理数据。购物车里每一项的 startTime应该是前一个商品的 endTime,如果是第一个商品则用 timeSlots.start_at
2329
2102
  var cartItems = this.store.cart.getItems().filter(function (n) {
2330
2103
  return !isNormalProduct(n._productOrigin);
@@ -2353,9 +2126,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2353
2126
  var _newResources$;
2354
2127
  var newResources = cloneDeep(item._origin.resources);
2355
2128
  newResources.forEach(function (resource) {
2356
- var _item$_productOrigin18;
2129
+ var _item$_productOrigin15;
2357
2130
  // 如果商品配置的是灵活时长,开始时间设置为提交的时间,结束时间从资源的可用最晚时间和店铺营业结束时间里取一个最早的
2358
- if (((_item$_productOrigin18 = item._productOrigin) === null || _item$_productOrigin18 === void 0 || (_item$_productOrigin18 = _item$_productOrigin18.duration) === null || _item$_productOrigin18 === void 0 ? void 0 : _item$_productOrigin18.type) === 'flexible') {
2131
+ if (((_item$_productOrigin15 = item._productOrigin) === null || _item$_productOrigin15 === void 0 || (_item$_productOrigin15 = _item$_productOrigin15.duration) === null || _item$_productOrigin15 === void 0 ? void 0 : _item$_productOrigin15.type) === 'flexible') {
2359
2132
  var _allResources$find;
2360
2133
  item.duration = {
2361
2134
  type: 'minutes',
@@ -2372,7 +2145,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2372
2145
 
2373
2146
  // 将 operating_day_boundary 转换为与 resourcesEndTime.end_at 相同日期的完整日期时间
2374
2147
  var resourceDate = dayjs(resourcesEndTime.end_at).format('YYYY-MM-DD');
2375
- var operatingBoundaryDateTime = "".concat(resourceDate, " ").concat(operating_day_boundary.type === 'start_time' ? "23:59" : operating_day_boundary.time);
2148
+ var operatingBoundaryDateTime = "".concat(resourceDate, " ").concat(operating_day_boundary.type === 'start_time' ? '23:59' : operating_day_boundary.time);
2376
2149
  var endTime = dayjs(resourcesEndTime.end_at).isBefore(dayjs(operatingBoundaryDateTime)) ? resourcesEndTime.end_at : operatingBoundaryDateTime;
2377
2150
  // 修复:如果 endTime 只是时间格式(如 "17:00"),需要加上日期
2378
2151
  var formattedEndTime;
@@ -2385,13 +2158,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2385
2158
  }
2386
2159
  resource.endTime = formattedEndTime.format('YYYY-MM-DD HH:mm');
2387
2160
  } else {
2388
- var _item$_productOrigin19;
2161
+ var _item$_productOrigin16;
2389
2162
  resource.startTime = currentStartTime;
2390
- resource.endTime = dayjs(currentStartTime).add(((_item$_productOrigin19 = item._productOrigin) === null || _item$_productOrigin19 === void 0 || (_item$_productOrigin19 = _item$_productOrigin19.duration) === null || _item$_productOrigin19 === void 0 ? void 0 : _item$_productOrigin19.value) || 10, 'minutes').format('YYYY-MM-DD HH:mm');
2163
+ resource.endTime = dayjs(currentStartTime).add(((_item$_productOrigin16 = item._productOrigin) === null || _item$_productOrigin16 === void 0 || (_item$_productOrigin16 = _item$_productOrigin16.duration) === null || _item$_productOrigin16 === void 0 ? void 0 : _item$_productOrigin16.value) || 10, 'minutes').format('YYYY-MM-DD HH:mm');
2391
2164
  }
2392
2165
  // delete resource.times;
2393
2166
  });
2394
- _this12.store.cart.updateItem({
2167
+ _this13.store.cart.updateItem({
2395
2168
  _id: item._id,
2396
2169
  resources: newResources
2397
2170
  });
@@ -2439,26 +2212,59 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2439
2212
  }, {
2440
2213
  key: "openProductDetail",
2441
2214
  value: function () {
2442
- var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(productId) {
2443
- var targetProduct, targetProductData, newScheduleArr;
2444
- return _regeneratorRuntime().wrap(function _callee26$(_context27) {
2445
- while (1) switch (_context27.prev = _context27.next) {
2215
+ var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(productId) {
2216
+ var targetProduct, targetProductData, newScheduleArr, dateRange;
2217
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2218
+ while (1) switch (_context25.prev = _context25.next) {
2446
2219
  case 0:
2447
- _context27.next = 2;
2220
+ _context25.next = 2;
2448
2221
  return this.store.products.getProduct(productId);
2449
2222
  case 2:
2450
- targetProduct = _context27.sent;
2451
- if (targetProduct) {
2452
- targetProductData = targetProduct.getData();
2453
- this.store.currentProduct = targetProduct;
2454
- newScheduleArr = this.getScheduleDataByIds(targetProductData['schedule.ids']);
2455
- targetProduct.setOtherParams('schedule', newScheduleArr);
2223
+ targetProduct = _context25.sent;
2224
+ if (!targetProduct) {
2225
+ _context25.next = 16;
2226
+ break;
2456
2227
  }
2457
- case 4:
2228
+ targetProductData = targetProduct.getData();
2229
+ this.store.currentProduct = targetProduct;
2230
+ // 资源预加载,如果是 duration 类型的商品,且是先选日期的流程,在这里预拉取资源数据
2231
+ if (!targetProductData['schedule.ids']) {
2232
+ _context25.next = 11;
2233
+ break;
2234
+ }
2235
+ newScheduleArr = this.getScheduleDataByIds(targetProductData['schedule.ids']);
2236
+ targetProduct.setOtherParams('schedule', newScheduleArr);
2237
+ _context25.next = 16;
2238
+ break;
2239
+ case 11:
2240
+ if (!targetProductData.duration) {
2241
+ _context25.next = 16;
2242
+ break;
2243
+ }
2244
+ dateRange = this.store.date.getDateRange(); // 如果不是先选日期的流程 duration 商品就啥也不做
2245
+ if (dateRange.length) {
2246
+ _context25.next = 15;
2247
+ break;
2248
+ }
2249
+ return _context25.abrupt("return");
2250
+ case 15:
2251
+ // this.store.date.getResourceDates({
2252
+ // query: {
2253
+ // start_date: dateRange[0].date,
2254
+ // end_date: dateRange[dateRange.length - 1].date,
2255
+ // resource_ids: targetProductData.product_resource?.resources?.map((n: any) => n.id),
2256
+ // },
2257
+ // });
2258
+ this.getAvailableDate({
2259
+ startDate: dateRange[0].date,
2260
+ endDate: dateRange[dateRange.length - 1].date,
2261
+ products: [targetProductData]
2262
+ });
2263
+ case 16:
2458
2264
  case "end":
2459
- return _context27.stop();
2265
+ return _context25.stop();
2460
2266
  }
2461
- }, _callee26, this);
2267
+ }, _callee25, this);
2462
2268
  }));
2463
2269
  function openProductDetail(_x19) {
2464
2270
  return _openProductDetail.apply(this, arguments);
@@ -2474,12 +2280,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2474
2280
  }
2475
2281
  }, {
2476
2282
  key: "getTimeslotBySchedule",
2477
- value: function getTimeslotBySchedule(_ref9) {
2283
+ value: function getTimeslotBySchedule(_ref10) {
2478
2284
  var _this$store$currentPr2, _targetProductData$pr;
2479
- var date = _ref9.date,
2480
- scheduleIds = _ref9.scheduleIds,
2481
- resources = _ref9.resources,
2482
- product = _ref9.product;
2285
+ var date = _ref10.date,
2286
+ scheduleIds = _ref10.scheduleIds,
2287
+ resources = _ref10.resources,
2288
+ product = _ref10.product;
2483
2289
  var targetProduct = this.store.currentProduct;
2484
2290
  // 如果外面传递了product 优先用外面的
2485
2291
  var targetProductData = product || (targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.getData());
@@ -2506,9 +2312,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2506
2312
  });
2507
2313
  // 资源排下序,把单个资源靠前,组合资源排在后面
2508
2314
  allProductResources.sort(function (a, b) {
2509
- var _a$metadata4, _b$metadata4;
2510
- var aIsCombined = ((_a$metadata4 = a.metadata) === null || _a$metadata4 === void 0 || (_a$metadata4 = _a$metadata4.combined_resource) === null || _a$metadata4 === void 0 ? void 0 : _a$metadata4.status) === 1;
2511
- var bIsCombined = ((_b$metadata4 = b.metadata) === null || _b$metadata4 === void 0 || (_b$metadata4 = _b$metadata4.combined_resource) === null || _b$metadata4 === void 0 ? void 0 : _b$metadata4.status) === 1;
2315
+ var _a$metadata2, _b$metadata2;
2316
+ var aIsCombined = ((_a$metadata2 = a.metadata) === null || _a$metadata2 === void 0 || (_a$metadata2 = _a$metadata2.combined_resource) === null || _a$metadata2 === void 0 ? void 0 : _a$metadata2.status) === 1;
2317
+ var bIsCombined = ((_b$metadata2 = b.metadata) === null || _b$metadata2 === void 0 || (_b$metadata2 = _b$metadata2.combined_resource) === null || _b$metadata2 === void 0 ? void 0 : _b$metadata2.status) === 1;
2512
2318
  if (aIsCombined && !bIsCombined) return 1;
2513
2319
  if (!aIsCombined && bIsCombined) return -1;
2514
2320
  return 0;
@@ -2571,9 +2377,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2571
2377
  // 在已经选定时间的情况下,只要canUseTime如果有一个 false 那就不可用
2572
2378
  if (!currentResourcesTimeSlotCanUsedArr.some(function (n) {
2573
2379
  return n === false;
2574
- })
2380
+ }) &&
2575
2381
  // 只统计第一种资源的容量和 left
2576
- && m.form_id === firstEnabledResourceId) {
2382
+ m.form_id === firstEnabledResourceId) {
2577
2383
  if (currentResourcesCount >= count) {
2578
2384
  count = currentResourcesCount;
2579
2385
  }
@@ -2595,75 +2401,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2595
2401
  });
2596
2402
  return formatScheduleTimeSlots;
2597
2403
  }
2598
- }, {
2599
- key: "addProductToCart",
2600
- value: function addProductToCart(_ref10) {
2601
- var _this13 = this;
2602
- var product = _ref10.product,
2603
- date = _ref10.date,
2604
- account = _ref10.account;
2605
- var _ref11 = product || {},
2606
- bundle = _ref11.bundle,
2607
- options = _ref11.options,
2608
- origin = _ref11.origin,
2609
- product_variant_id = _ref11.product_variant_id,
2610
- rowKey = _ref11.rowKey,
2611
- _ref11$quantity = _ref11.quantity,
2612
- quantity = _ref11$quantity === void 0 ? 1 : _ref11$quantity;
2613
- var productData = _objectSpread(_objectSpread({}, origin), {}, {
2614
- product_variant_id: product_variant_id,
2615
- rowKey: rowKey
2616
- });
2617
- if (!account) {
2618
- var activeAccount = this.getActiveAccount();
2619
- if (activeAccount) {
2620
- account = activeAccount;
2621
- }
2622
- }
2623
- if (rowKey) {
2624
- var cartItems = this.store.cart.getItems();
2625
- var targetCartItem = cartItems.find(function (n) {
2626
- var _n$_productOrigin3;
2627
- return ((_n$_productOrigin3 = n._productOrigin) === null || _n$_productOrigin3 === void 0 ? void 0 : _n$_productOrigin3.rowKey) === rowKey;
2628
- });
2629
- if (targetCartItem && isNormalProduct(targetCartItem._productOrigin)) {
2630
- this.store.cart.updateItem({
2631
- _id: targetCartItem._id,
2632
- product: _objectSpread(_objectSpread({}, targetCartItem._productOrigin), {}, {
2633
- quantity: (targetCartItem.num || 1) + quantity
2634
- }),
2635
- bundle: targetCartItem._bundleOrigin,
2636
- options: targetCartItem._optionsOrigin,
2637
- quantity: (targetCartItem.num || 1) + quantity
2638
- });
2639
- // 这里需要单独触发一个,购物车商品数量发生改变的 hook
2640
- this.core.effects.emit("".concat(this.store.cart.name, ":onUpdateCartItemNums"), {});
2641
- return;
2642
- }
2643
- }
2644
- this.store.cart.addItem({
2645
- product: productData,
2646
- date: date,
2647
- account: account,
2648
- bundle: bundle,
2649
- options: options,
2650
- quantity: quantity
2651
- });
2652
- // 检测,有传递 date,检查购物车里其他商品的 date 是否在同一天,如果不在,清空那些不在同一天的商品
2653
- if (date) {
2654
- var _cartItems = this.store.cart.getItems().filter(function (n) {
2655
- return !isNormalProduct(n._productOrigin);
2656
- });
2657
- var cartItemsByDate = _cartItems.filter(function (n) {
2658
- return !dayjs(n.start_date).isSame(dayjs(date.startTime), 'day');
2659
- });
2660
- if (cartItemsByDate.length) {
2661
- cartItemsByDate.forEach(function (n) {
2662
- _this13.store.cart.removeItem(n._id);
2663
- });
2664
- }
2665
- }
2666
- }
2667
2404
  }, {
2668
2405
  key: "setOtherData",
2669
2406
  value: function setOtherData(key, value) {
@@ -2685,27 +2422,27 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2685
2422
  }, {
2686
2423
  key: "getProductTypeById",
2687
2424
  value: function () {
2688
- var _getProductTypeById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(id) {
2425
+ var _getProductTypeById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(id) {
2689
2426
  var product;
2690
- return _regeneratorRuntime().wrap(function _callee27$(_context28) {
2691
- while (1) switch (_context28.prev = _context28.next) {
2427
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2428
+ while (1) switch (_context26.prev = _context26.next) {
2692
2429
  case 0:
2693
- _context28.next = 2;
2430
+ _context26.next = 2;
2694
2431
  return this.store.products.getProduct(id);
2695
2432
  case 2:
2696
- product = _context28.sent;
2433
+ product = _context26.sent;
2697
2434
  if (!product) {
2698
- _context28.next = 5;
2435
+ _context26.next = 5;
2699
2436
  break;
2700
2437
  }
2701
- return _context28.abrupt("return", product.getProductType());
2438
+ return _context26.abrupt("return", product.getProductType());
2702
2439
  case 5:
2703
- return _context28.abrupt("return", 'normal');
2440
+ return _context26.abrupt("return", 'normal');
2704
2441
  case 6:
2705
2442
  case "end":
2706
- return _context28.stop();
2443
+ return _context26.stop();
2707
2444
  }
2708
- }, _callee27, this);
2445
+ }, _callee26, this);
2709
2446
  }));
2710
2447
  function getProductTypeById(_x20) {
2711
2448
  return _getProductTypeById.apply(this, arguments);
@@ -2723,7 +2460,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2723
2460
  }, {
2724
2461
  key: "getResourcesByCartItemAndCode",
2725
2462
  value: function getResourcesByCartItemAndCode(cartItemId, resourceCode) {
2726
- var _cartItem$_productOri13, _cartItem$_productOri14;
2463
+ var _cartItem$_productOri8;
2727
2464
  var dateRange = this.store.date.getDateRange();
2728
2465
  var resources = [];
2729
2466
  if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
@@ -2746,20 +2483,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2746
2483
  });
2747
2484
  if (!cartItem) return [];
2748
2485
  var selectedResources = [];
2749
- var formatCapacity = formatDefaultCapacitys({
2750
- capacity: (_cartItem$_productOri13 = cartItem._productOrigin) === null || _cartItem$_productOri13 === void 0 ? void 0 : _cartItem$_productOri13.capacity,
2751
- product_bundle: cartItem._origin.product.product_bundle
2752
- });
2486
+ var _getCapacityInfoByCar7 = getCapacityInfoByCartItem(cartItem),
2487
+ currentCapacity = _getCapacityInfoByCar7.currentCapacity,
2488
+ formatCapacity = _getCapacityInfoByCar7.formatCapacity;
2753
2489
  cartItem._origin.metadata.capacity = formatCapacity;
2754
- var currentCapacity = getSumCapacity({
2755
- capacity: formatCapacity
2756
- });
2757
2490
  if (cartItem.holder_id) {
2758
2491
  selectedResources = getOthersSelectedResources(cartItems, cartItem.holder_id, resourcesMap);
2759
2492
  } else {
2760
2493
  selectedResources = getOthersCartSelectedResources(cartItems, cartItem._id, resourcesMap);
2761
2494
  }
2762
- var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri14 = cartItem._productOrigin) === null || _cartItem$_productOri14 === void 0 || (_cartItem$_productOri14 = _cartItem$_productOri14.product_resource) === null || _cartItem$_productOri14 === void 0 ? void 0 : _cartItem$_productOri14.resources) || [], selectedResources, currentCapacity);
2495
+ var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri8 = cartItem._productOrigin) === null || _cartItem$_productOri8 === void 0 || (_cartItem$_productOri8 = _cartItem$_productOri8.product_resource) === null || _cartItem$_productOri8 === void 0 ? void 0 : _cartItem$_productOri8.resources) || [], selectedResources, currentCapacity);
2763
2496
  var targetResource = productResources.find(function (resource) {
2764
2497
  return resource.code === resourceCode;
2765
2498
  });
@@ -2769,9 +2502,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2769
2502
  var endTime = dayjs("".concat(cartItem._origin.end_date, " ").concat(cartItem._origin.end_time));
2770
2503
  var resourcesUseableMap = {};
2771
2504
  targetResource.renderList = targetResource.renderList.sort(function (a, b) {
2772
- var _a$metadata5, _b$metadata5;
2773
- var aIsCombined = ((_a$metadata5 = a.metadata) === null || _a$metadata5 === void 0 || (_a$metadata5 = _a$metadata5.combined_resource) === null || _a$metadata5 === void 0 ? void 0 : _a$metadata5.status) === 1;
2774
- var bIsCombined = ((_b$metadata5 = b.metadata) === null || _b$metadata5 === void 0 || (_b$metadata5 = _b$metadata5.combined_resource) === null || _b$metadata5 === void 0 ? void 0 : _b$metadata5.status) === 1;
2505
+ var _a$metadata3, _b$metadata3;
2506
+ var aIsCombined = ((_a$metadata3 = a.metadata) === null || _a$metadata3 === void 0 || (_a$metadata3 = _a$metadata3.combined_resource) === null || _a$metadata3 === void 0 ? void 0 : _a$metadata3.status) === 1;
2507
+ var bIsCombined = ((_b$metadata3 = b.metadata) === null || _b$metadata3 === void 0 || (_b$metadata3 = _b$metadata3.combined_resource) === null || _b$metadata3 === void 0 ? void 0 : _b$metadata3.status) === 1;
2775
2508
  if (aIsCombined && !bIsCombined) return 1;
2776
2509
  if (!aIsCombined && bIsCombined) return -1;
2777
2510
  return 0;
@@ -2782,7 +2515,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2782
2515
  });
2783
2516
  if (mTimes.length === 0) return false;
2784
2517
  var canUseArr = mTimes.map(function (item) {
2785
- var _cartItem$_productOri15;
2518
+ var _cartItem$_productOri9;
2786
2519
  var res = getIsUsableByTimeItem({
2787
2520
  timeSlice: {
2788
2521
  start_time: startTime.format('HH:mm'),
@@ -2794,7 +2527,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2794
2527
  resource: m,
2795
2528
  currentCount: currentCapacity || 0,
2796
2529
  resourcesUseableMap: resourcesUseableMap,
2797
- cut_off_time: (_cartItem$_productOri15 = cartItem._productOrigin) === null || _cartItem$_productOri15 === void 0 ? void 0 : _cartItem$_productOri15.cut_off_time
2530
+ cut_off_time: (_cartItem$_productOri9 = cartItem._productOrigin) === null || _cartItem$_productOri9 === void 0 ? void 0 : _cartItem$_productOri9.cut_off_time
2798
2531
  });
2799
2532
  if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
2800
2533
  resourcesUseableMap[m.id] = res.usable;
@@ -2808,12 +2541,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2808
2541
  });
2809
2542
  } else {
2810
2543
  targetResource.renderList = targetResource.renderList.filter(function (n) {
2811
- var _cartItem$_productOri16;
2544
+ var _cartItem$_productOri10;
2812
2545
  var recordCount = n.capacity || 0;
2813
2546
  if (n.onlyComputed) return false;
2814
2547
  var timeSlots = getTimeSlicesByResource({
2815
2548
  resource: n,
2816
- duration: ((_cartItem$_productOri16 = cartItem._productOrigin) === null || _cartItem$_productOri16 === void 0 || (_cartItem$_productOri16 = _cartItem$_productOri16.duration) === null || _cartItem$_productOri16 === void 0 ? void 0 : _cartItem$_productOri16.value) || 10,
2549
+ duration: ((_cartItem$_productOri10 = cartItem._productOrigin) === null || _cartItem$_productOri10 === void 0 || (_cartItem$_productOri10 = _cartItem$_productOri10.duration) === null || _cartItem$_productOri10 === void 0 ? void 0 : _cartItem$_productOri10.value) || 10,
2817
2550
  split: 10,
2818
2551
  currentDate: dateRange[0].date
2819
2552
  });
@@ -2831,12 +2564,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2831
2564
  }, {
2832
2565
  key: "getTimeslotsScheduleByDateRange",
2833
2566
  value: (function () {
2834
- var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(_ref12) {
2567
+ var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(_ref11) {
2835
2568
  var startDate, endDate, scheduleIds, resources, dates, currentDate, end, results, _i, _dates, date;
2836
- return _regeneratorRuntime().wrap(function _callee28$(_context29) {
2837
- while (1) switch (_context29.prev = _context29.next) {
2569
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2570
+ while (1) switch (_context27.prev = _context27.next) {
2838
2571
  case 0:
2839
- startDate = _ref12.startDate, endDate = _ref12.endDate, scheduleIds = _ref12.scheduleIds, resources = _ref12.resources;
2572
+ startDate = _ref11.startDate, endDate = _ref11.endDate, scheduleIds = _ref11.scheduleIds, resources = _ref11.resources;
2840
2573
  console.log('appoimentBooking-session-date-getTimeslotsScheduleByDateRange', {
2841
2574
  startDate: startDate,
2842
2575
  endDate: endDate,
@@ -2861,138 +2594,46 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2861
2594
  resources: resources
2862
2595
  });
2863
2596
  }
2864
- return _context29.abrupt("return", results);
2597
+ return _context27.abrupt("return", results);
2865
2598
  case 9:
2866
2599
  case "end":
2867
- return _context29.stop();
2600
+ return _context27.stop();
2868
2601
  }
2869
- }, _callee28, this);
2602
+ }, _callee27, this);
2870
2603
  }));
2871
2604
  function getTimeslotsScheduleByDateRange(_x21) {
2872
2605
  return _getTimeslotsScheduleByDateRange.apply(this, arguments);
2873
2606
  }
2874
2607
  return getTimeslotsScheduleByDateRange;
2875
2608
  }())
2876
- }, {
2877
- key: "getAvailableDateForSession",
2878
- value: function () {
2879
- var _getAvailableDateForSession = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
2880
- var params,
2881
- startDate,
2882
- endDate,
2883
- type,
2884
- tempProducts,
2885
- _ref13,
2886
- resourceIds,
2887
- rules,
2888
- resourcesMap,
2889
- res,
2890
- dateListWithTimeSlots,
2891
- firstAvailableDate,
2892
- _args30 = arguments;
2893
- return _regeneratorRuntime().wrap(function _callee29$(_context30) {
2894
- while (1) switch (_context30.prev = _context30.next) {
2895
- case 0:
2896
- params = _args30.length > 0 && _args30[0] !== undefined ? _args30[0] : {};
2897
- // 开始日期如果小于今天,直接以今天当做开始日期
2898
- startDate = params.startDate, endDate = params.endDate, type = params.type; // 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天 且 endDate 小于或等于今天,需要把 startDate 置为今天
2899
- if (dayjs(startDate).isBefore(dayjs(), 'day') && (dayjs(endDate).isAfter(dayjs(), 'day') || dayjs(endDate).isSame(dayjs(), 'day'))) {
2900
- startDate = dayjs().format('YYYY-MM-DD');
2901
- }
2902
- // 不管前端传什么 endDate 默认查一个月的,以今天为开始日期。用于找到一个月内最近可用的日期
2903
- endDate = dayjs().add(1, 'month').format('YYYY-MM-DD');
2904
- tempProducts = []; // 如果当前打开了某个的商品详情弹窗,则应该默认用这个商品
2905
- if (this.store.currentProduct) {
2906
- tempProducts = [_objectSpread(_objectSpread({}, this.store.currentProduct.getData()), {}, {
2907
- _schedule: this.store.currentProduct.getOtherParams()['schedule']
2908
- })];
2909
- }
2910
- // 在这里需要把能收集到的数据都收集上来,拼装好给 date 模块去查询
2911
- _ref13 = getAvailableProductResources(tempProducts) || {}, resourceIds = _ref13.resourceIds, rules = _ref13.rules, resourcesMap = _ref13.resourcesMap;
2912
- this.otherParams.currentResourcesMap = resourcesMap;
2913
- _context30.next = 10;
2914
- return this.store.date.getResourceDates({
2915
- query: {
2916
- start_date: startDate || '',
2917
- end_date: endDate || '',
2918
- resource_ids: resourceIds
2919
- },
2920
- rules: rules,
2921
- type: type
2922
- });
2923
- case 10:
2924
- res = _context30.sent;
2925
- if (!this.store.currentProduct) {
2926
- _context30.next = 16;
2927
- break;
2928
- }
2929
- _context30.next = 14;
2930
- return this.getTimeslotsScheduleByDateRange({
2931
- startDate: startDate || '',
2932
- endDate: endDate || ''
2933
- });
2934
- case 14:
2935
- dateListWithTimeSlots = _context30.sent;
2936
- res.forEach(function (n) {
2937
- if (!dateListWithTimeSlots[n.date]) {
2938
- n.status = 'unavailable';
2939
- } else {
2940
- var allTimeSlotsCanUse = dateListWithTimeSlots[n.date].every(function (d) {
2941
- return d.count;
2942
- });
2943
- if (!allTimeSlotsCanUse) {
2944
- n.status = 'unavailable';
2945
- }
2946
- }
2947
- });
2948
- case 16:
2949
- // 找到第一个可用的日期返回给 UI
2950
- firstAvailableDate = res.find(function (n) {
2951
- return n.status === 'available';
2952
- });
2953
- return _context30.abrupt("return", {
2954
- dateList: res,
2955
- firstAvailableDate: firstAvailableDate
2956
- });
2957
- case 18:
2958
- case "end":
2959
- return _context30.stop();
2960
- }
2961
- }, _callee29, this);
2962
- }));
2963
- function getAvailableDateForSession() {
2964
- return _getAvailableDateForSession.apply(this, arguments);
2965
- }
2966
- return getAvailableDateForSession;
2967
- }()
2968
2609
  }, {
2969
2610
  key: "getAvailableDateForSessionOptimize",
2970
2611
  value: function () {
2971
- var _getAvailableDateForSessionOptimize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
2612
+ var _getAvailableDateForSessionOptimize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
2972
2613
  var _this$store$currentPr3, _this$store$currentPr4, _this$store$currentPr5, _tempProducts, _this$store$currentPr6;
2973
2614
  var params,
2974
2615
  startDate,
2975
2616
  endDate,
2976
2617
  endDateAfterMonth,
2977
2618
  tempEndDate,
2619
+ cache,
2978
2620
  tempProducts,
2979
2621
  schedule,
2980
2622
  filteredSchedule,
2981
2623
  tempResourceIds,
2982
2624
  res,
2983
- cache,
2984
2625
  dates,
2985
2626
  currentDate,
2986
2627
  firstAvailableDate,
2987
2628
  openResources,
2988
2629
  allProductResources,
2989
2630
  targetSchedules,
2990
- _loop3,
2991
- _args32 = arguments;
2992
- return _regeneratorRuntime().wrap(function _callee30$(_context32) {
2993
- while (1) switch (_context32.prev = _context32.next) {
2631
+ _loop2,
2632
+ _args29 = arguments;
2633
+ return _regeneratorRuntime().wrap(function _callee28$(_context29) {
2634
+ while (1) switch (_context29.prev = _context29.next) {
2994
2635
  case 0:
2995
- params = _args32.length > 0 && _args32[0] !== undefined ? _args32[0] : {};
2636
+ params = _args29.length > 0 && _args29[0] !== undefined ? _args29[0] : {};
2996
2637
  // 开始日期如果小于今天,直接以今天当做开始日期
2997
2638
  startDate = params.startDate, endDate = params.endDate; // 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天 且 endDate 小于或等于今天,需要把 startDate 置为今天
2998
2639
  if (dayjs(startDate).isBefore(dayjs(), 'day') && (dayjs(endDate).isAfter(dayjs(), 'day') || dayjs(endDate).isSame(dayjs(), 'day'))) {
@@ -3013,38 +2654,38 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3013
2654
  tempEndDate = endDate || '';
3014
2655
  }
3015
2656
  endDate = tempEndDate;
3016
- // 如果当前打开了某个的商品详情弹窗,则应该默认用这个商品
3017
- tempProducts = (_this$store$currentPr3 = this.store.currentProduct) === null || _this$store$currentPr3 === void 0 ? void 0 : _this$store$currentPr3.getData();
3018
- schedule = (_this$store$currentPr4 = this.store.currentProduct) === null || _this$store$currentPr4 === void 0 ? void 0 : _this$store$currentPr4.getOtherParams()['schedule'];
3019
- filteredSchedule = filterScheduleByDateRange(schedule, startDate || '', endDate || ''); // 1.后端返回的数据,确定资源在每一天的可用和使用情况
3020
- tempResourceIds = getResourcesIdsByProduct(tempProducts);
3021
- _context32.next = 14;
3022
- return this.store.date.fetchResourceDates({
3023
- query: {
3024
- start_date: startDate || '',
3025
- end_date: endDate || '',
3026
- resource_ids: tempResourceIds
3027
- }
3028
- });
3029
- case 14:
3030
- res = _context32.sent;
2657
+
3031
2658
  // 先去读缓存结果,因为正常 UI 调用的是 7 天,而下面我会直接计算 30 天(最少也是 14 天),所以先去读缓存结果,如果缓存结果存在,则直接返回
3032
- // TODO 优化关于为什么要放在接口后,因为在获取时间切片的时候还需要读一次接口数据,其实可以直接从这个结果里拿了,需要优化
3033
- cache = (_this$store$currentPr5 = this.store.currentProduct) === null || _this$store$currentPr5 === void 0 ? void 0 : _this$store$currentPr5.getOtherParams()['timeSlotBySchedule'];
2659
+ cache = (_this$store$currentPr3 = this.store.currentProduct) === null || _this$store$currentPr3 === void 0 ? void 0 : _this$store$currentPr3.getOtherParams()['timeSlotBySchedule'];
3034
2660
  if (!cache) {
3035
- _context32.next = 20;
2661
+ _context29.next = 13;
3036
2662
  break;
3037
2663
  }
3038
2664
  if (!(dayjs(params.startDate).isSameOrAfter(dayjs(cache.startDate), 'day') && dayjs(params.endDate).isSameOrBefore(dayjs(cache.endDate), 'day'))) {
3039
- _context32.next = 20;
2665
+ _context29.next = 13;
3040
2666
  break;
3041
2667
  }
3042
2668
  this.store.date.setDateList(cache.dateList);
3043
- return _context32.abrupt("return", {
2669
+ return _context29.abrupt("return", {
3044
2670
  dateList: cache.dateList,
3045
2671
  firstAvailableDate: cache.firstAvailableDate
3046
2672
  });
3047
- case 20:
2673
+ case 13:
2674
+ // 如果当前打开了某个的商品详情弹窗,则应该默认用这个商品
2675
+ tempProducts = (_this$store$currentPr4 = this.store.currentProduct) === null || _this$store$currentPr4 === void 0 ? void 0 : _this$store$currentPr4.getData();
2676
+ schedule = (_this$store$currentPr5 = this.store.currentProduct) === null || _this$store$currentPr5 === void 0 ? void 0 : _this$store$currentPr5.getOtherParams()['schedule'];
2677
+ filteredSchedule = filterScheduleByDateRange(schedule, startDate || '', endDate || ''); // 1.后端返回的数据,确定资源在每一天的可用和使用情况
2678
+ tempResourceIds = getResourcesIdsByProduct(tempProducts);
2679
+ _context29.next = 19;
2680
+ return this.store.date.fetchResourceDates({
2681
+ query: {
2682
+ start_date: startDate || '',
2683
+ end_date: endDate || '',
2684
+ resource_ids: tempResourceIds
2685
+ }
2686
+ });
2687
+ case 19:
2688
+ res = _context29.sent;
3048
2689
  // 2. 商品 schedule 数据,确定日程在每一天的时间片
3049
2690
  // 3. 把后端返回的和 schedule 的数据进行合并,确定每一天的可用和使用情况
3050
2691
  dates = [];
@@ -3064,10 +2705,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3064
2705
  }
3065
2706
  });
3066
2707
  targetSchedules = this.store.schedule.getScheduleListByIds(tempProducts['schedule.ids']);
3067
- _loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
2708
+ _loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
3068
2709
  var currentDateStr, status, _checkSessionProductL, latestStartDate, earliestEndDate, scheduleByDate, minTimeMaxTime, scheduleTimeSlots, timesSlotCanUse;
3069
- return _regeneratorRuntime().wrap(function _loop3$(_context31) {
3070
- while (1) switch (_context31.prev = _context31.next) {
2710
+ return _regeneratorRuntime().wrap(function _loop2$(_context28) {
2711
+ while (1) switch (_context28.prev = _context28.next) {
3071
2712
  case 0:
3072
2713
  currentDateStr = currentDate.format('YYYY-MM-DD');
3073
2714
  status = 'available'; // 1. 检查商品的提前量等情况是否满足
@@ -3159,32 +2800,32 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3159
2800
 
3160
2801
  // 如果 firstAvailableDate 距离 startDate 大于 14 天了,则后面就不需要再找了,也是一种性能保护
3161
2802
  if (!(firstAvailableDate && dayjs(currentDate).diff(dayjs(startDate), 'day') > 14)) {
3162
- _context31.next = 9;
2803
+ _context28.next = 9;
3163
2804
  break;
3164
2805
  }
3165
- return _context31.abrupt("return", 1);
2806
+ return _context28.abrupt("return", 1);
3166
2807
  case 9:
3167
2808
  currentDate = dayjs(currentDate).add(1, 'day');
3168
2809
  case 10:
3169
2810
  case "end":
3170
- return _context31.stop();
2811
+ return _context28.stop();
3171
2812
  }
3172
- }, _loop3);
2813
+ }, _loop2);
3173
2814
  });
3174
2815
  case 28:
3175
2816
  if (!(dayjs(currentDate).isBefore(dayjs(endDate), 'day') || dayjs(currentDate).isSame(dayjs(endDate), 'day'))) {
3176
- _context32.next = 34;
2817
+ _context29.next = 34;
3177
2818
  break;
3178
2819
  }
3179
- return _context32.delegateYield(_loop3(), "t0", 30);
2820
+ return _context29.delegateYield(_loop2(), "t0", 30);
3180
2821
  case 30:
3181
- if (!_context32.t0) {
3182
- _context32.next = 32;
2822
+ if (!_context29.t0) {
2823
+ _context29.next = 32;
3183
2824
  break;
3184
2825
  }
3185
- return _context32.abrupt("break", 34);
2826
+ return _context29.abrupt("break", 34);
3186
2827
  case 32:
3187
- _context32.next = 28;
2828
+ _context29.next = 28;
3188
2829
  break;
3189
2830
  case 34:
3190
2831
  // 最终把资源数据也加到日期内
@@ -3198,15 +2839,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3198
2839
  startDate: startDate,
3199
2840
  endDate: dayjs(currentDate).format('YYYY-MM-DD')
3200
2841
  });
3201
- return _context32.abrupt("return", {
2842
+ return _context29.abrupt("return", {
3202
2843
  dateList: dates,
3203
2844
  firstAvailableDate: firstAvailableDate
3204
2845
  });
3205
2846
  case 38:
3206
2847
  case "end":
3207
- return _context32.stop();
2848
+ return _context29.stop();
3208
2849
  }
3209
- }, _callee30, this);
2850
+ }, _callee28, this);
3210
2851
  }));
3211
2852
  function getAvailableDateForSessionOptimize() {
3212
2853
  return _getAvailableDateForSessionOptimize.apply(this, arguments);
@@ -3228,8 +2869,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3228
2869
  return !isNormalProduct(n._productOrigin);
3229
2870
  });
3230
2871
  return cartItems.some(function (n) {
3231
- var _n$_productOrigin4;
3232
- return (_n$_productOrigin4 = n._productOrigin) === null || _n$_productOrigin4 === void 0 ? void 0 : _n$_productOrigin4.duration;
2872
+ var _n$_productOrigin2;
2873
+ return (_n$_productOrigin2 = n._productOrigin) === null || _n$_productOrigin2 === void 0 ? void 0 : _n$_productOrigin2.duration;
3233
2874
  });
3234
2875
  }
3235
2876
  }, {