@pisell/pisellos 2.0.19 → 2.0.21

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 (35) hide show
  1. package/dist/modules/Account/index.d.ts +1 -0
  2. package/dist/modules/Account/index.js +6 -0
  3. package/dist/modules/Account/types.d.ts +2 -0
  4. package/dist/modules/AccountList/index.d.ts +1 -0
  5. package/dist/modules/AccountList/index.js +7 -0
  6. package/dist/modules/Date/utils.js +12 -1
  7. package/dist/modules/Product/index.d.ts +1 -0
  8. package/dist/modules/Product/index.js +6 -0
  9. package/dist/modules/ProductList/index.js +21 -9
  10. package/dist/modules/Rules/index.js +4 -2
  11. package/dist/modules/Schedule/utils.js +10 -1
  12. package/dist/plugins/user.d.ts +7 -0
  13. package/dist/plugins/user.js +1 -0
  14. package/dist/solution/BookingByStep/index.d.ts +1 -0
  15. package/dist/solution/BookingByStep/index.js +425 -255
  16. package/dist/solution/BookingByStep/utils/resources.d.ts +5 -0
  17. package/dist/solution/BookingByStep/utils/resources.js +22 -4
  18. package/lib/modules/Account/index.d.ts +1 -0
  19. package/lib/modules/Account/index.js +4 -0
  20. package/lib/modules/Account/types.d.ts +2 -0
  21. package/lib/modules/AccountList/index.d.ts +1 -0
  22. package/lib/modules/AccountList/index.js +3 -0
  23. package/lib/modules/Date/utils.js +7 -0
  24. package/lib/modules/Product/index.d.ts +1 -0
  25. package/lib/modules/Product/index.js +3 -0
  26. package/lib/modules/ProductList/index.js +16 -2
  27. package/lib/modules/Rules/index.js +2 -2
  28. package/lib/modules/Schedule/utils.js +5 -1
  29. package/lib/plugins/user.d.ts +7 -0
  30. package/lib/plugins/user.js +17 -0
  31. package/lib/solution/BookingByStep/index.d.ts +1 -0
  32. package/lib/solution/BookingByStep/index.js +96 -5
  33. package/lib/solution/BookingByStep/utils/resources.d.ts +5 -0
  34. package/lib/solution/BookingByStep/utils/resources.js +17 -4
  35. package/package.json +1 -1
@@ -204,7 +204,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
204
204
  value: function () {
205
205
  var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
206
206
  var _schedule_ids;
207
- var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, _ref$schedule_ids, schedule_ids, schedule_date, schedule_ids_data, productsData;
207
+ var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, _ref$schedule_ids, schedule_ids, schedule_date, schedule_ids_data, userPlugin, customer_id, _userPlugin$get, productsData;
208
208
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
209
209
  while (1) switch (_context2.prev = _context2.next) {
210
210
  case 0:
@@ -216,9 +216,20 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
216
216
  });
217
217
  if (schedule_ids_data.length) {
218
218
  schedule_ids = schedule_ids_data;
219
+ } else if (schedule_date) {
220
+ // 后端说如果 schedule_ids 如果为空,需要给[0]
221
+ schedule_ids = [0];
219
222
  }
220
223
  }
221
- _context2.next = 4;
224
+ userPlugin = this.core.getPlugin('user');
225
+ customer_id = undefined;
226
+ try {
227
+ customer_id = userPlugin === null || userPlugin === void 0 || (_userPlugin$get = userPlugin.get()) === null || _userPlugin$get === void 0 ? void 0 : _userPlugin$get.id;
228
+ } catch (error) {
229
+ console.error(error);
230
+ }
231
+ // 如果没传schedule_date,则从
232
+ _context2.next = 7;
222
233
  return this.request.post("/product/query", {
223
234
  open_quotation: 1,
224
235
  open_bundle: 1,
@@ -227,6 +238,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
227
238
  status: 'published',
228
239
  num: 500,
229
240
  skip: 1,
241
+ customer_id: customer_id,
230
242
  category_ids: category_ids,
231
243
  ids: product_ids,
232
244
  collection: collection,
@@ -236,11 +248,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
236
248
  }, {
237
249
  useCache: true
238
250
  });
239
- case 4:
251
+ case 7:
240
252
  productsData = _context2.sent;
241
253
  this.store.products.addProduct(productsData.data.list);
242
254
  return _context2.abrupt("return", productsData.data.list);
243
- case 7:
255
+ case 10:
244
256
  case "end":
245
257
  return _context2.stop();
246
258
  }
@@ -296,30 +308,148 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
296
308
  return _loadProductByScheduleDate.apply(this, arguments);
297
309
  }
298
310
  return loadProductByScheduleDate;
311
+ }()
312
+ }, {
313
+ key: "updateQuotationPriceAndCart",
314
+ value: function () {
315
+ var _updateQuotationPriceAndCart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(date) {
316
+ var _this$otherParams3,
317
+ _this3 = this;
318
+ var dateRange, scheduleList, scheduleIds, cartItems, _iterator, _step, _loop;
319
+ return _regeneratorRuntime().wrap(function _callee4$(_context5) {
320
+ while (1) switch (_context5.prev = _context5.next) {
321
+ case 0:
322
+ dateRange = this.store.date.getDateRange();
323
+ scheduleList = this.store.schedule.getAvailabilityScheduleDateList() || [];
324
+ scheduleIds = [];
325
+ if (dateRange && dateRange.length) {
326
+ scheduleIds = scheduleList.filter(function (n) {
327
+ return n.date === dateRange[0].date;
328
+ }).flatMap(function (n) {
329
+ return n.schedule_id;
330
+ });
331
+ } else {
332
+ scheduleIds = scheduleList.filter(function (n) {
333
+ return n.date === date;
334
+ }).flatMap(function (n) {
335
+ return n.schedule_id;
336
+ });
337
+ }
338
+ _context5.next = 6;
339
+ return this.loadProducts(_objectSpread(_objectSpread({}, (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.productModuleParams), {}, {
340
+ scheduleIds: scheduleIds,
341
+ schedule_date: date
342
+ }));
343
+ case 6:
344
+ // 更新完商品数据以后,检测当前购物车里是否有商品,如果有,则需要更新购物车里的商品价格
345
+ cartItems = this.store.cart.getItems();
346
+ if (!cartItems.length) {
347
+ _context5.next = 25;
348
+ break;
349
+ }
350
+ _iterator = _createForOfIteratorHelper(cartItems);
351
+ _context5.prev = 9;
352
+ _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
353
+ var _bundle;
354
+ var item, targetProduct, productInfo, bundle;
355
+ return _regeneratorRuntime().wrap(function _loop$(_context4) {
356
+ while (1) switch (_context4.prev = _context4.next) {
357
+ case 0:
358
+ item = _step.value;
359
+ _context4.next = 3;
360
+ return _this3.store.products.getProduct(item.id);
361
+ case 3:
362
+ targetProduct = _context4.sent;
363
+ productInfo = cloneDeep(targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.getData());
364
+ bundle = item._bundleOrigin;
365
+ bundle = (_bundle = bundle) === null || _bundle === void 0 ? void 0 : _bundle.map(function (n) {
366
+ var _productInfo$bundle;
367
+ // 尝试到新的 productInfo 里找对应的 bundleitem
368
+ // 然后更新 bundle 的价格
369
+ var targetBundle = productInfo === null || productInfo === void 0 || (_productInfo$bundle = productInfo.bundle) === null || _productInfo$bundle === void 0 ? void 0 : _productInfo$bundle.find(function (m) {
370
+ return m.group_id === n.id;
371
+ });
372
+ if (targetBundle) {
373
+ var targetBundleItem = targetBundle.items.find(function (m) {
374
+ return m.id === n.id;
375
+ });
376
+ if (targetBundleItem) {
377
+ return _objectSpread(_objectSpread({}, n), {}, {
378
+ price: targetBundleItem.price,
379
+ base_price: targetBundleItem.base_price
380
+ });
381
+ }
382
+ }
383
+ return n;
384
+ });
385
+ _this3.store.cart.updateItem({
386
+ _id: item._id,
387
+ product: productInfo,
388
+ bundle: bundle
389
+ });
390
+ case 8:
391
+ case "end":
392
+ return _context4.stop();
393
+ }
394
+ }, _loop);
395
+ });
396
+ _iterator.s();
397
+ case 12:
398
+ if ((_step = _iterator.n()).done) {
399
+ _context5.next = 16;
400
+ break;
401
+ }
402
+ return _context5.delegateYield(_loop(), "t0", 14);
403
+ case 14:
404
+ _context5.next = 12;
405
+ break;
406
+ case 16:
407
+ _context5.next = 21;
408
+ break;
409
+ case 18:
410
+ _context5.prev = 18;
411
+ _context5.t1 = _context5["catch"](9);
412
+ _iterator.e(_context5.t1);
413
+ case 21:
414
+ _context5.prev = 21;
415
+ _iterator.f();
416
+ return _context5.finish(21);
417
+ case 24:
418
+ ;
419
+ case 25:
420
+ case "end":
421
+ return _context5.stop();
422
+ }
423
+ }, _callee4, this, [[9, 18, 21, 24]]);
424
+ }));
425
+ function updateQuotationPriceAndCart(_x5) {
426
+ return _updateQuotationPriceAndCart.apply(this, arguments);
427
+ }
428
+ return updateQuotationPriceAndCart;
299
429
  }() // 加载当前店铺下所有 schedule
300
430
  }, {
301
431
  key: "loadAllSchedule",
302
432
  value: function () {
303
- var _loadAllSchedule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
433
+ var _loadAllSchedule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
304
434
  var _scheduleList$data;
305
435
  var scheduleList;
306
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
307
- while (1) switch (_context4.prev = _context4.next) {
436
+ return _regeneratorRuntime().wrap(function _callee5$(_context6) {
437
+ while (1) switch (_context6.prev = _context6.next) {
308
438
  case 0:
309
- _context4.next = 2;
439
+ _context6.next = 2;
310
440
  return this.request.get("/schedule", {
311
441
  num: 999
312
442
  }, {
313
443
  useCache: true
314
444
  });
315
445
  case 2:
316
- scheduleList = _context4.sent;
446
+ scheduleList = _context6.sent;
317
447
  this.store.schedule.setScheduleList(((_scheduleList$data = scheduleList.data) === null || _scheduleList$data === void 0 ? void 0 : _scheduleList$data.list) || []);
318
448
  case 4:
319
449
  case "end":
320
- return _context4.stop();
450
+ return _context6.stop();
321
451
  }
322
- }, _callee4, this);
452
+ }, _callee5, this);
323
453
  }));
324
454
  function loadAllSchedule() {
325
455
  return _loadAllSchedule.apply(this, arguments);
@@ -329,11 +459,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
329
459
  }, {
330
460
  key: "loadScheduleAvailableDate",
331
461
  value: function () {
332
- var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref3) {
462
+ var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref3) {
333
463
  var _res$data$date_list;
334
464
  var startDate, endDate, custom_page_id, channel, dates, res;
335
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
336
- while (1) switch (_context5.prev = _context5.next) {
465
+ return _regeneratorRuntime().wrap(function _callee6$(_context7) {
466
+ while (1) switch (_context7.prev = _context7.next) {
337
467
  case 0:
338
468
  startDate = _ref3.startDate, endDate = _ref3.endDate, custom_page_id = _ref3.custom_page_id, channel = _ref3.channel;
339
469
  // 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天,需要把 startDate 置为今天
@@ -345,12 +475,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
345
475
  dates = disableAllDates(dates);
346
476
  // 如果 endDate 在今天之前,则不用查接口,直接返回 dates
347
477
  if (!dayjs(endDate).isBefore(dayjs(), 'day')) {
348
- _context5.next = 6;
478
+ _context7.next = 6;
349
479
  break;
350
480
  }
351
- return _context5.abrupt("return", dates);
481
+ return _context7.abrupt("return", dates);
352
482
  case 6:
353
- _context5.next = 8;
483
+ _context7.next = 8;
354
484
  return this.request.get("/schedule/product/availability", {
355
485
  start_date: startDate,
356
486
  end_date: endDate,
@@ -358,14 +488,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
358
488
  channel: channel
359
489
  });
360
490
  case 8:
361
- res = _context5.sent;
491
+ res = _context7.sent;
362
492
  this.store.schedule.setAvailabilityScheduleDateList(res.data.date_list);
363
493
  // 如果没有schedule或者结束日期在今天之前,则所有日期均不可用
364
494
  if (!(!((_res$data$date_list = res.data.date_list) !== null && _res$data$date_list !== void 0 && _res$data$date_list.length) || dayjs(endDate).isBefore(dayjs(), 'day'))) {
365
- _context5.next = 12;
495
+ _context7.next = 12;
366
496
  break;
367
497
  }
368
- return _context5.abrupt("return", dates);
498
+ return _context7.abrupt("return", dates);
369
499
  case 12:
370
500
  res.data.date_list.forEach(function (n) {
371
501
  var index = dates.findIndex(function (m) {
@@ -376,14 +506,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
376
506
  }
377
507
  });
378
508
  dates = disableDatesBeforeOneDay(dates);
379
- return _context5.abrupt("return", dates);
509
+ return _context7.abrupt("return", dates);
380
510
  case 15:
381
511
  case "end":
382
- return _context5.stop();
512
+ return _context7.stop();
383
513
  }
384
- }, _callee5, this);
514
+ }, _callee6, this);
385
515
  }));
386
- function loadScheduleAvailableDate(_x5) {
516
+ function loadScheduleAvailableDate(_x6) {
387
517
  return _loadScheduleAvailableDate.apply(this, arguments);
388
518
  }
389
519
  return loadScheduleAvailableDate;
@@ -391,10 +521,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
391
521
  }, {
392
522
  key: "storeProduct",
393
523
  value: function () {
394
- var _storeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(productData) {
524
+ var _storeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(productData) {
395
525
  var activeAccount, _ref4, bundle, options, origin, product_variant_id, product, addCartItem;
396
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
397
- while (1) switch (_context6.prev = _context6.next) {
526
+ return _regeneratorRuntime().wrap(function _callee7$(_context8) {
527
+ while (1) switch (_context8.prev = _context8.next) {
398
528
  case 0:
399
529
  // 往购物车加商品数据的时候,默认用当前 activeAccount 填充到 product 的 account 里面
400
530
  activeAccount = this.getActiveAccount();
@@ -413,11 +543,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
413
543
  this.store.cart.addItem(addCartItem);
414
544
  case 6:
415
545
  case "end":
416
- return _context6.stop();
546
+ return _context8.stop();
417
547
  }
418
- }, _callee6, this);
548
+ }, _callee7, this);
419
549
  }));
420
- function storeProduct(_x6) {
550
+ function storeProduct(_x7) {
421
551
  return _storeProduct.apply(this, arguments);
422
552
  }
423
553
  return storeProduct;
@@ -425,37 +555,37 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
425
555
  }, {
426
556
  key: "addAccount",
427
557
  value: function () {
428
- var _addAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(account, extra) {
558
+ var _addAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(account, extra) {
429
559
  var accountModules, newAccount;
430
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
431
- while (1) switch (_context7.prev = _context7.next) {
560
+ return _regeneratorRuntime().wrap(function _callee8$(_context9) {
561
+ while (1) switch (_context9.prev = _context9.next) {
432
562
  case 0:
433
563
  if (!((extra === null || extra === void 0 ? void 0 : extra.type) === 'holder')) {
434
- _context7.next = 5;
564
+ _context9.next = 5;
435
565
  break;
436
566
  }
437
- _context7.next = 3;
567
+ _context9.next = 3;
438
568
  return this.store.accountList.addHolderAccounts({
439
569
  holders: [account],
440
570
  customerId: extra.customerId,
441
571
  type: 'unshift'
442
572
  });
443
573
  case 3:
444
- accountModules = _context7.sent;
445
- return _context7.abrupt("return", accountModules[0].getAccount());
574
+ accountModules = _context9.sent;
575
+ return _context9.abrupt("return", accountModules[0].getAccount());
446
576
  case 5:
447
- _context7.next = 7;
577
+ _context9.next = 7;
448
578
  return this.store.accountList.addAccount(account);
449
579
  case 7:
450
- newAccount = _context7.sent;
451
- return _context7.abrupt("return", newAccount.getAccount());
580
+ newAccount = _context9.sent;
581
+ return _context9.abrupt("return", newAccount.getAccount());
452
582
  case 9:
453
583
  case "end":
454
- return _context7.stop();
584
+ return _context9.stop();
455
585
  }
456
- }, _callee7, this);
586
+ }, _callee8, this);
457
587
  }));
458
- function addAccount(_x7, _x8) {
588
+ function addAccount(_x8, _x9) {
459
589
  return _addAccount.apply(this, arguments);
460
590
  }
461
591
  return addAccount;
@@ -463,13 +593,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
463
593
  }, {
464
594
  key: "addAccounts",
465
595
  value: function () {
466
- var _addAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(accounts, extra) {
467
- var res, _iterator, _step, account, accountModule, accountData;
468
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
469
- while (1) switch (_context8.prev = _context8.next) {
596
+ var _addAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(accounts, extra) {
597
+ var res, _iterator2, _step2, account, accountModule, accountData;
598
+ return _regeneratorRuntime().wrap(function _callee9$(_context10) {
599
+ while (1) switch (_context10.prev = _context10.next) {
470
600
  case 0:
471
601
  if (!((extra === null || extra === void 0 ? void 0 : extra.type) === 'holder')) {
472
- _context8.next = 3;
602
+ _context10.next = 3;
473
603
  break;
474
604
  }
475
605
  this.store.accountList.addHolderAccounts({
@@ -477,49 +607,49 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
477
607
  customerId: extra.customerId,
478
608
  type: 'unshift'
479
609
  });
480
- return _context8.abrupt("return");
610
+ return _context10.abrupt("return");
481
611
  case 3:
482
612
  res = [];
483
- _iterator = _createForOfIteratorHelper(accounts);
484
- _context8.prev = 5;
485
- _iterator.s();
613
+ _iterator2 = _createForOfIteratorHelper(accounts);
614
+ _context10.prev = 5;
615
+ _iterator2.s();
486
616
  case 7:
487
- if ((_step = _iterator.n()).done) {
488
- _context8.next = 16;
617
+ if ((_step2 = _iterator2.n()).done) {
618
+ _context10.next = 16;
489
619
  break;
490
620
  }
491
- account = _step.value;
492
- _context8.next = 11;
621
+ account = _step2.value;
622
+ _context10.next = 11;
493
623
  return this.store.accountList.addAccount(account);
494
624
  case 11:
495
- accountModule = _context8.sent;
625
+ accountModule = _context10.sent;
496
626
  accountData = accountModule.getAccount();
497
627
  if (accountData) {
498
628
  res.push(accountData);
499
629
  }
500
630
  case 14:
501
- _context8.next = 7;
631
+ _context10.next = 7;
502
632
  break;
503
633
  case 16:
504
- _context8.next = 21;
634
+ _context10.next = 21;
505
635
  break;
506
636
  case 18:
507
- _context8.prev = 18;
508
- _context8.t0 = _context8["catch"](5);
509
- _iterator.e(_context8.t0);
637
+ _context10.prev = 18;
638
+ _context10.t0 = _context10["catch"](5);
639
+ _iterator2.e(_context10.t0);
510
640
  case 21:
511
- _context8.prev = 21;
512
- _iterator.f();
513
- return _context8.finish(21);
641
+ _context10.prev = 21;
642
+ _iterator2.f();
643
+ return _context10.finish(21);
514
644
  case 24:
515
- return _context8.abrupt("return", res);
645
+ return _context10.abrupt("return", res);
516
646
  case 25:
517
647
  case "end":
518
- return _context8.stop();
648
+ return _context10.stop();
519
649
  }
520
- }, _callee8, this, [[5, 18, 21, 24]]);
650
+ }, _callee9, this, [[5, 18, 21, 24]]);
521
651
  }));
522
- function addAccounts(_x9, _x10) {
652
+ function addAccounts(_x10, _x11) {
523
653
  return _addAccounts.apply(this, arguments);
524
654
  }
525
655
  return addAccounts;
@@ -527,20 +657,20 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
527
657
  }, {
528
658
  key: "getAccounts",
529
659
  value: function () {
530
- var _getAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
660
+ var _getAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
531
661
  var accounts;
532
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
533
- while (1) switch (_context9.prev = _context9.next) {
662
+ return _regeneratorRuntime().wrap(function _callee10$(_context11) {
663
+ while (1) switch (_context11.prev = _context11.next) {
534
664
  case 0:
535
665
  accounts = this.store.accountList.getAccounts();
536
- return _context9.abrupt("return", accounts.map(function (account) {
666
+ return _context11.abrupt("return", accounts.map(function (account) {
537
667
  return account.getAccount();
538
668
  }));
539
669
  case 2:
540
670
  case "end":
541
- return _context9.stop();
671
+ return _context11.stop();
542
672
  }
543
- }, _callee9, this);
673
+ }, _callee10, this);
544
674
  }));
545
675
  function getAccounts() {
546
676
  return _getAccounts.apply(this, arguments);
@@ -581,18 +711,28 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
581
711
  }, {
582
712
  key: "fetchHolderAccountsAsync",
583
713
  value: (function () {
584
- var _fetchHolderAccountsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
585
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
586
- while (1) switch (_context10.prev = _context10.next) {
714
+ var _fetchHolderAccountsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(params) {
715
+ var cartItems, _this$store$date$getD, date, _cartItems$;
716
+ return _regeneratorRuntime().wrap(function _callee11$(_context12) {
717
+ while (1) switch (_context12.prev = _context12.next) {
587
718
  case 0:
588
- return _context10.abrupt("return", this.store.accountList.fetchHolderAccounts(params));
589
- case 1:
719
+ cartItems = this.store.cart.getItems();
720
+ if (cartItems.length) {
721
+ date = (_this$store$date$getD = this.store.date.getDateRange()) === null || _this$store$date$getD === void 0 || (_this$store$date$getD = _this$store$date$getD[0]) === null || _this$store$date$getD === void 0 ? void 0 : _this$store$date$getD.date;
722
+ if (!date) {
723
+ // 如果没有日期,则应该是 session 类先选商品的流程,直接从购物车里拿 start_date
724
+ date = (cartItems === null || cartItems === void 0 || (_cartItems$ = cartItems[0]) === null || _cartItems$ === void 0 ? void 0 : _cartItems$.start_date) || '';
725
+ }
726
+ this.updateQuotationPriceAndCart(date);
727
+ }
728
+ return _context12.abrupt("return", this.store.accountList.fetchHolderAccounts(params));
729
+ case 3:
590
730
  case "end":
591
- return _context10.stop();
731
+ return _context12.stop();
592
732
  }
593
- }, _callee10, this);
733
+ }, _callee11, this);
594
734
  }));
595
- function fetchHolderAccountsAsync(_x11) {
735
+ function fetchHolderAccountsAsync(_x12) {
596
736
  return _fetchHolderAccountsAsync.apply(this, arguments);
597
737
  }
598
738
  return fetchHolderAccountsAsync;
@@ -601,18 +741,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
601
741
  }, {
602
742
  key: "setDateRange",
603
743
  value: function () {
604
- var _setDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(dateRange) {
605
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
606
- while (1) switch (_context11.prev = _context11.next) {
744
+ var _setDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(dateRange) {
745
+ return _regeneratorRuntime().wrap(function _callee12$(_context13) {
746
+ while (1) switch (_context13.prev = _context13.next) {
607
747
  case 0:
608
748
  this.store.date.setDateRange(dateRange);
609
- case 1:
749
+ // 日期数据变更后,如果购物车里有数据,需要更新购物车里的报价单的价格
750
+ if (dateRange.length && this.store.cart.getItems().length) {
751
+ this.updateQuotationPriceAndCart(dateRange[0].date);
752
+ }
753
+ case 2:
610
754
  case "end":
611
- return _context11.stop();
755
+ return _context13.stop();
612
756
  }
613
- }, _callee11, this);
757
+ }, _callee12, this);
614
758
  }));
615
- function setDateRange(_x12) {
759
+ function setDateRange(_x13) {
616
760
  return _setDateRange.apply(this, arguments);
617
761
  }
618
762
  return setDateRange;
@@ -627,16 +771,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
627
771
  }, {
628
772
  key: "getDateRange",
629
773
  value: function () {
630
- var _getDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
631
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
632
- while (1) switch (_context12.prev = _context12.next) {
774
+ var _getDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
775
+ return _regeneratorRuntime().wrap(function _callee13$(_context14) {
776
+ while (1) switch (_context14.prev = _context14.next) {
633
777
  case 0:
634
- return _context12.abrupt("return", this.store.date.getDateRange());
778
+ return _context14.abrupt("return", this.store.date.getDateRange());
635
779
  case 1:
636
780
  case "end":
637
- return _context12.stop();
781
+ return _context14.stop();
638
782
  }
639
- }, _callee12, this);
783
+ }, _callee13, this);
640
784
  }));
641
785
  function getDateRange() {
642
786
  return _getDateRange.apply(this, arguments);
@@ -653,8 +797,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
653
797
  }, {
654
798
  key: "getAvailableDate",
655
799
  value: function () {
656
- var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
657
- var _this3 = this,
800
+ var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
801
+ var _this4 = this,
658
802
  _dateRange$,
659
803
  _dateRange$2,
660
804
  _dateRange$3;
@@ -672,11 +816,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
672
816
  rules,
673
817
  resourcesMap,
674
818
  res,
675
- _args13 = arguments;
676
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
677
- while (1) switch (_context13.prev = _context13.next) {
819
+ _args15 = arguments;
820
+ return _regeneratorRuntime().wrap(function _callee14$(_context15) {
821
+ while (1) switch (_context15.prev = _context15.next) {
678
822
  case 0:
679
- params = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {};
823
+ params = _args15.length > 0 && _args15[0] !== undefined ? _args15[0] : {};
680
824
  // 开始日期如果小于今天,直接以今天当做开始日期
681
825
  products = params.products, startDate = params.startDate, endDate = params.endDate, type = params.type; // 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天 且 endDate 小于或等于今天,需要把 startDate 置为今天
682
826
  if (dayjs(startDate).isBefore(dayjs(), 'day') && (dayjs(endDate).isAfter(dayjs(), 'day') || dayjs(endDate).isSame(dayjs(), 'day'))) {
@@ -688,7 +832,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
688
832
  if (tempProducts.length) {
689
833
  tempProducts.forEach(function (p) {
690
834
  if (p !== null && p !== void 0 && p['schedule.ids']) {
691
- var scheduleData = _this3.getScheduleDataByIds(p['schedule.ids']);
835
+ var scheduleData = _this4.getScheduleDataByIds(p['schedule.ids']);
692
836
  p['_schedule'] = scheduleData;
693
837
  }
694
838
  });
@@ -703,15 +847,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
703
847
  tempStartDate = startDate || (dateRange === null || dateRange === void 0 || (_dateRange$ = dateRange[0]) === null || _dateRange$ === void 0 ? void 0 : _dateRange$.date);
704
848
  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);
705
849
  if (tempProducts.length) {
706
- _context13.next = 11;
850
+ _context15.next = 11;
707
851
  break;
708
852
  }
709
- return _context13.abrupt("return", []);
853
+ return _context15.abrupt("return", []);
710
854
  case 11:
711
855
  // 在这里需要把能收集到的数据都收集上来,拼装好给 date 模块去查询
712
856
  _ref5 = getAvailableProductResources(tempProducts) || {}, resourceIds = _ref5.resourceIds, rules = _ref5.rules, resourcesMap = _ref5.resourcesMap;
713
857
  this.otherParams.currentResourcesMap = resourcesMap;
714
- _context13.next = 15;
858
+ _context15.next = 15;
715
859
  return this.store.date.getResourceDates({
716
860
  url: params.url,
717
861
  query: {
@@ -723,13 +867,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
723
867
  type: type
724
868
  });
725
869
  case 15:
726
- res = _context13.sent;
727
- return _context13.abrupt("return", res);
870
+ res = _context15.sent;
871
+ return _context15.abrupt("return", res);
728
872
  case 17:
729
873
  case "end":
730
- return _context13.stop();
874
+ return _context15.stop();
731
875
  }
732
- }, _callee13, this);
876
+ }, _callee14, this);
733
877
  }));
734
878
  function getAvailableDate() {
735
879
  return _getAvailableDate.apply(this, arguments);
@@ -742,22 +886,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
742
886
  }, {
743
887
  key: "getSummary",
744
888
  value: (function () {
745
- var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
889
+ var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
746
890
  var cartItems, summary;
747
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
748
- while (1) switch (_context14.prev = _context14.next) {
891
+ return _regeneratorRuntime().wrap(function _callee15$(_context16) {
892
+ while (1) switch (_context16.prev = _context16.next) {
749
893
  case 0:
750
894
  cartItems = this.store.cart.getItems();
751
- _context14.next = 3;
895
+ _context16.next = 3;
752
896
  return this.store.summary.getSummary(cartItems);
753
897
  case 3:
754
- summary = _context14.sent;
755
- return _context14.abrupt("return", summary);
898
+ summary = _context16.sent;
899
+ return _context16.abrupt("return", summary);
756
900
  case 5:
757
901
  case "end":
758
- return _context14.stop();
902
+ return _context16.stop();
759
903
  }
760
- }, _callee14, this);
904
+ }, _callee15, this);
761
905
  }));
762
906
  function getSummary() {
763
907
  return _getSummary.apply(this, arguments);
@@ -771,18 +915,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
771
915
  }, {
772
916
  key: "getProtocol",
773
917
  value: (function () {
774
- var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(protocolId) {
775
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
776
- while (1) switch (_context15.prev = _context15.next) {
918
+ var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(protocolId) {
919
+ return _regeneratorRuntime().wrap(function _callee16$(_context17) {
920
+ while (1) switch (_context17.prev = _context17.next) {
777
921
  case 0:
778
- return _context15.abrupt("return", this.store.summary.getProtocol(protocolId));
922
+ return _context17.abrupt("return", this.store.summary.getProtocol(protocolId));
779
923
  case 1:
780
924
  case "end":
781
- return _context15.stop();
925
+ return _context17.stop();
782
926
  }
783
- }, _callee15, this);
927
+ }, _callee16, this);
784
928
  }));
785
- function getProtocol(_x13) {
929
+ function getProtocol(_x14) {
786
930
  return _getProtocol.apply(this, arguments);
787
931
  }
788
932
  return getProtocol;
@@ -791,16 +935,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
791
935
  }, {
792
936
  key: "getProducts",
793
937
  value: function () {
794
- var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
795
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
796
- while (1) switch (_context16.prev = _context16.next) {
938
+ var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
939
+ return _regeneratorRuntime().wrap(function _callee17$(_context18) {
940
+ while (1) switch (_context18.prev = _context18.next) {
797
941
  case 0:
798
- return _context16.abrupt("return", this.store.products.getProducts());
942
+ return _context18.abrupt("return", this.store.products.getProducts());
799
943
  case 1:
800
944
  case "end":
801
- return _context16.stop();
945
+ return _context18.stop();
802
946
  }
803
- }, _callee16, this);
947
+ }, _callee17, this);
804
948
  }));
805
949
  function getProducts() {
806
950
  return _getProducts.apply(this, arguments);
@@ -810,41 +954,50 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
810
954
  }, {
811
955
  key: "setLoginAccount",
812
956
  value: function () {
813
- var _setLoginAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(accountId, accountInfo) {
814
- var _this4 = this;
815
- var account, stateAccountId, cartItems;
816
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
817
- while (1) switch (_context17.prev = _context17.next) {
957
+ var _setLoginAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(accountId, accountInfo) {
958
+ var _this5 = this;
959
+ var account, stateAccountId, cartItems, _this$store$date$getD2, date, _cartItems$2;
960
+ return _regeneratorRuntime().wrap(function _callee18$(_context19) {
961
+ while (1) switch (_context19.prev = _context19.next) {
818
962
  case 0:
819
963
  account = this.store.accountList.getAccount(accountId);
820
964
  if (!account) {
821
- _context17.next = 9;
965
+ _context19.next = 11;
822
966
  break;
823
967
  }
824
968
  stateAccountId = account.getId();
969
+ accountInfo.isLogin = true;
825
970
  account.setAccountInfo(accountInfo);
826
971
  // 然后去购物车,把原先关联了 holder_id 为 accountId 的商品,替换为 holder_id = accountInfo.id
827
972
  cartItems = this.store.cart.getItems();
828
973
  cartItems.forEach(function (item) {
829
974
  if (item.holder_id === accountId) {
830
- _this4.store.cart.updateItem({
975
+ _this5.store.cart.updateItem({
831
976
  _id: item._id,
832
977
  account: accountInfo
833
978
  });
834
979
  }
835
980
  });
836
981
  this.store.accountList.updateAccountListById(stateAccountId, accountInfo);
837
- _context17.next = 10;
982
+ if (cartItems.length) {
983
+ date = (_this$store$date$getD2 = this.store.date.getDateRange()) === null || _this$store$date$getD2 === void 0 || (_this$store$date$getD2 = _this$store$date$getD2[0]) === null || _this$store$date$getD2 === void 0 ? void 0 : _this$store$date$getD2.date;
984
+ if (!date) {
985
+ // 如果没有日期,则应该是 session 类先选商品的流程,直接从购物车里拿 start_date
986
+ date = (cartItems === null || cartItems === void 0 || (_cartItems$2 = cartItems[0]) === null || _cartItems$2 === void 0 ? void 0 : _cartItems$2.start_date) || '';
987
+ }
988
+ this.updateQuotationPriceAndCart(date);
989
+ }
990
+ _context19.next = 12;
838
991
  break;
839
- case 9:
992
+ case 11:
840
993
  throw new Error("\u6CA1\u6709\u627E\u5230".concat(accountId, "\u8D26\u6237"));
841
- case 10:
994
+ case 12:
842
995
  case "end":
843
- return _context17.stop();
996
+ return _context19.stop();
844
997
  }
845
- }, _callee17, this);
998
+ }, _callee18, this);
846
999
  }));
847
- function setLoginAccount(_x14, _x15) {
1000
+ function setLoginAccount(_x15, _x16) {
848
1001
  return _setLoginAccount.apply(this, arguments);
849
1002
  }
850
1003
  return setLoginAccount;
@@ -852,14 +1005,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
852
1005
  }, {
853
1006
  key: "generateCartData",
854
1007
  value: function () {
855
- var _generateCartData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
856
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
857
- while (1) switch (_context18.prev = _context18.next) {
1008
+ var _generateCartData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
1009
+ return _regeneratorRuntime().wrap(function _callee19$(_context20) {
1010
+ while (1) switch (_context20.prev = _context20.next) {
858
1011
  case 0:
859
1012
  case "end":
860
- return _context18.stop();
1013
+ return _context20.stop();
861
1014
  }
862
- }, _callee18);
1015
+ }, _callee19);
863
1016
  }));
864
1017
  function generateCartData() {
865
1018
  return _generateCartData.apply(this, arguments);
@@ -869,23 +1022,23 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
869
1022
  }, {
870
1023
  key: "getFreeProduct",
871
1024
  value: function () {
872
- var _getFreeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(id) {
1025
+ var _getFreeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(id) {
873
1026
  var res;
874
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
875
- while (1) switch (_context19.prev = _context19.next) {
1027
+ return _regeneratorRuntime().wrap(function _callee20$(_context21) {
1028
+ while (1) switch (_context21.prev = _context21.next) {
876
1029
  case 0:
877
- _context19.next = 2;
1030
+ _context21.next = 2;
878
1031
  return this.request.post("/pay/order/free-pay/".concat(id));
879
1032
  case 2:
880
- res = _context19.sent;
881
- return _context19.abrupt("return", res);
1033
+ res = _context21.sent;
1034
+ return _context21.abrupt("return", res);
882
1035
  case 4:
883
1036
  case "end":
884
- return _context19.stop();
1037
+ return _context21.stop();
885
1038
  }
886
- }, _callee19, this);
1039
+ }, _callee20, this);
887
1040
  }));
888
- function getFreeProduct(_x16) {
1041
+ function getFreeProduct(_x17) {
889
1042
  return _getFreeProduct.apply(this, arguments);
890
1043
  }
891
1044
  return getFreeProduct;
@@ -908,10 +1061,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
908
1061
  }, {
909
1062
  key: "submitOrder",
910
1063
  value: function () {
911
- var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
1064
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
912
1065
  var cartItems, newCartItems;
913
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
914
- while (1) switch (_context20.prev = _context20.next) {
1066
+ return _regeneratorRuntime().wrap(function _callee21$(_context22) {
1067
+ while (1) switch (_context22.prev = _context22.next) {
915
1068
  case 0:
916
1069
  cartItems = this.store.cart.getItems();
917
1070
  newCartItems = cloneDeep(cartItems); // 先整个临时的逻辑,把购物车里所有商品的资源给他格式化一下
@@ -937,16 +1090,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
937
1090
  item._origin.metadata.capacity = formatCapacity;
938
1091
  item._origin.number = currentCapacity;
939
1092
  });
940
- return _context20.abrupt("return", this.store.order.submitOrder({
1093
+ return _context22.abrupt("return", this.store.order.submitOrder({
941
1094
  query: {
942
1095
  cartItems: newCartItems
943
1096
  }
944
1097
  }));
945
1098
  case 4:
946
1099
  case "end":
947
- return _context20.stop();
1100
+ return _context22.stop();
948
1101
  }
949
- }, _callee20, this);
1102
+ }, _callee21, this);
950
1103
  }));
951
1104
  function submitOrder() {
952
1105
  return _submitOrder.apply(this, arguments);
@@ -956,14 +1109,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
956
1109
  }, {
957
1110
  key: "pay",
958
1111
  value: function () {
959
- var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
960
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
961
- while (1) switch (_context21.prev = _context21.next) {
1112
+ var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
1113
+ return _regeneratorRuntime().wrap(function _callee22$(_context23) {
1114
+ while (1) switch (_context23.prev = _context23.next) {
962
1115
  case 0:
963
1116
  case "end":
964
- return _context21.stop();
1117
+ return _context23.stop();
965
1118
  }
966
- }, _callee21);
1119
+ }, _callee22);
967
1120
  }));
968
1121
  function pay() {
969
1122
  return _pay.apply(this, arguments);
@@ -973,14 +1126,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
973
1126
  }, {
974
1127
  key: "getPayInfo",
975
1128
  value: function () {
976
- var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
977
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
978
- while (1) switch (_context22.prev = _context22.next) {
1129
+ var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
1130
+ return _regeneratorRuntime().wrap(function _callee23$(_context24) {
1131
+ while (1) switch (_context24.prev = _context24.next) {
979
1132
  case 0:
980
1133
  case "end":
981
- return _context22.stop();
1134
+ return _context24.stop();
982
1135
  }
983
- }, _callee22);
1136
+ }, _callee23);
984
1137
  }));
985
1138
  function getPayInfo() {
986
1139
  return _getPayInfo.apply(this, arguments);
@@ -990,15 +1143,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
990
1143
  }, {
991
1144
  key: "setOtherParams",
992
1145
  value: function () {
993
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
1146
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
994
1147
  var _ref6,
995
1148
  _ref6$cover,
996
1149
  cover,
997
- _args23 = arguments;
998
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
999
- while (1) switch (_context23.prev = _context23.next) {
1150
+ _args25 = arguments;
1151
+ return _regeneratorRuntime().wrap(function _callee24$(_context25) {
1152
+ while (1) switch (_context25.prev = _context25.next) {
1000
1153
  case 0:
1001
- _ref6 = _args23.length > 1 && _args23[1] !== undefined ? _args23[1] : {}, _ref6$cover = _ref6.cover, cover = _ref6$cover === void 0 ? false : _ref6$cover;
1154
+ _ref6 = _args25.length > 1 && _args25[1] !== undefined ? _args25[1] : {}, _ref6$cover = _ref6.cover, cover = _ref6$cover === void 0 ? false : _ref6$cover;
1002
1155
  if (cover) {
1003
1156
  this.otherParams = params;
1004
1157
  } else {
@@ -1006,11 +1159,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1006
1159
  }
1007
1160
  case 2:
1008
1161
  case "end":
1009
- return _context23.stop();
1162
+ return _context25.stop();
1010
1163
  }
1011
- }, _callee23, this);
1164
+ }, _callee24, this);
1012
1165
  }));
1013
- function setOtherParams(_x17) {
1166
+ function setOtherParams(_x18) {
1014
1167
  return _setOtherParams.apply(this, arguments);
1015
1168
  }
1016
1169
  return setOtherParams;
@@ -1018,16 +1171,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1018
1171
  }, {
1019
1172
  key: "getOtherParams",
1020
1173
  value: function () {
1021
- var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
1022
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1023
- while (1) switch (_context24.prev = _context24.next) {
1174
+ var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
1175
+ return _regeneratorRuntime().wrap(function _callee25$(_context26) {
1176
+ while (1) switch (_context26.prev = _context26.next) {
1024
1177
  case 0:
1025
- return _context24.abrupt("return", this.otherParams);
1178
+ return _context26.abrupt("return", this.otherParams);
1026
1179
  case 1:
1027
1180
  case "end":
1028
- return _context24.stop();
1181
+ return _context26.stop();
1029
1182
  }
1030
- }, _callee24, this);
1183
+ }, _callee25, this);
1031
1184
  }));
1032
1185
  function getOtherParams() {
1033
1186
  return _getOtherParams.apply(this, arguments);
@@ -1037,7 +1190,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1037
1190
  }, {
1038
1191
  key: "updateCart",
1039
1192
  value: function updateCart(params) {
1040
- var _this5 = this;
1193
+ var _this6 = this;
1041
1194
  var targetCartItem = this.store.cart.getItem(params._id);
1042
1195
  if (!targetCartItem) {
1043
1196
  throw new Error("\u6CA1\u6709\u627E\u5230".concat(params._id, "\u8D2D\u7269\u8F66\u5546\u54C1"));
@@ -1126,7 +1279,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1126
1279
  var end_time = item.end_time;
1127
1280
  var start_date = item.start_date;
1128
1281
  var end_date = item.end_date;
1129
- _this5.store.cart.updateItem({
1282
+ _this6.store.cart.updateItem({
1130
1283
  _id: item._id,
1131
1284
  resources: resources,
1132
1285
  date: {
@@ -1135,7 +1288,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1135
1288
  }
1136
1289
  });
1137
1290
  } else {
1138
- _this5.store.cart.updateItem({
1291
+ _this6.store.cart.updateItem({
1139
1292
  _id: item._id,
1140
1293
  resources: resources
1141
1294
  });
@@ -1172,10 +1325,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1172
1325
  }, {
1173
1326
  key: "batchUpdateCart",
1174
1327
  value: function batchUpdateCart(paramsList) {
1175
- var _this6 = this;
1328
+ var _this7 = this;
1176
1329
  var cartItems = [];
1177
1330
  paramsList.forEach(function (params) {
1178
- var cartItem = _this6.store.cart.formatCartItem(params);
1331
+ var cartItem = _this7.store.cart.formatCartItem(params);
1179
1332
  cartItems.push(cartItem);
1180
1333
  });
1181
1334
  this.store.cart.batchSetItems(cartItems);
@@ -1203,11 +1356,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1203
1356
  }, {
1204
1357
  key: "checkCartItems",
1205
1358
  value: function checkCartItems(type) {
1206
- var _this7 = this;
1359
+ var _this8 = this;
1207
1360
  var cartItems = this.store.cart.getItems();
1208
1361
  var errorCartItemIds = [];
1209
1362
  cartItems.forEach(function (cartItem) {
1210
- var result = _this7.store.cart.checkCartItemByType(cartItem, type);
1363
+ var result = _this8.store.cart.checkCartItemByType(cartItem, type);
1211
1364
  if (!result) {
1212
1365
  errorCartItemIds.push(cartItem._id);
1213
1366
  }
@@ -1293,6 +1446,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1293
1446
  return false;
1294
1447
  }
1295
1448
  var canUseArr = mTimes.map(function (item) {
1449
+ var _cartItem$_productOri3;
1296
1450
  var res = getIsUsableByTimeItem({
1297
1451
  timeSlice: {
1298
1452
  start_time: startTime.format('HH:mm'),
@@ -1303,7 +1457,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1303
1457
  time: item,
1304
1458
  resource: m,
1305
1459
  currentCount: currentCapacity || 0,
1306
- resourcesUseableMap: resourcesUseableMap
1460
+ resourcesUseableMap: resourcesUseableMap,
1461
+ cut_off_time: (_cartItem$_productOri3 = cartItem._productOrigin) === null || _cartItem$_productOri3 === void 0 ? void 0 : _cartItem$_productOri3.cut_off_time
1307
1462
  });
1308
1463
  // 如果仅仅是因为子资源容量不够,不应该标记子资源是被占用的情况
1309
1464
  if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
@@ -1323,13 +1478,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1323
1478
  // 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
1324
1479
  // 同时,在这一步尝试去拉一下时间片,基于商品的时长,看每个资源是否还有空余时间能对这个商品做服务,如果没有则过滤
1325
1480
  item.renderList = item.renderList.filter(function (n) {
1326
- var _cartItem$_productOri3;
1481
+ var _cartItem$_productOri4;
1327
1482
  var recordCount = n.capacity || 0;
1328
1483
  if (n.onlyComputed) return false;
1329
1484
  // 查一下这个资源基于商品的可用时间片
1330
1485
  var timeSlots = getTimeSlicesByResource({
1331
1486
  resource: n,
1332
- duration: ((_cartItem$_productOri3 = cartItem._productOrigin) === null || _cartItem$_productOri3 === void 0 || (_cartItem$_productOri3 = _cartItem$_productOri3.duration) === null || _cartItem$_productOri3 === void 0 ? void 0 : _cartItem$_productOri3.value) || 0,
1487
+ 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) || 0,
1333
1488
  split: 10,
1334
1489
  currentDate: dateRange[0].date
1335
1490
  });
@@ -1373,10 +1528,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1373
1528
  var cartItems = this.store.cart.getItems();
1374
1529
  var arr = [];
1375
1530
  cartItems.forEach(function (cartItem) {
1376
- var _cartItem$_productOri4, _cartItem$_productOri5;
1531
+ var _cartItem$_productOri5, _cartItem$_productOri6;
1377
1532
  var selectedResources = [];
1378
1533
  var formatCapacity = formatDefaultCapacitys({
1379
- capacity: (_cartItem$_productOri4 = cartItem._productOrigin) === null || _cartItem$_productOri4 === void 0 ? void 0 : _cartItem$_productOri4.capacity,
1534
+ capacity: (_cartItem$_productOri5 = cartItem._productOrigin) === null || _cartItem$_productOri5 === void 0 ? void 0 : _cartItem$_productOri5.capacity,
1380
1535
  product_bundle: cartItem._origin.product.product_bundle
1381
1536
  });
1382
1537
  cartItem._origin.metadata.capacity = formatCapacity;
@@ -1388,7 +1543,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1388
1543
  } else {
1389
1544
  selectedResources = getOthersCartSelectedResources(cartItems, cartItem._id, resourcesMap);
1390
1545
  }
1391
- var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri5 = cartItem._productOrigin) === null || _cartItem$_productOri5 === void 0 || (_cartItem$_productOri5 = _cartItem$_productOri5.product_resource) === null || _cartItem$_productOri5 === void 0 ? void 0 : _cartItem$_productOri5.resources) || [], selectedResources, currentCapacity);
1546
+ var productResources = 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, currentCapacity);
1392
1547
  // 如果购物车里已经有了时间片,则需要按照时间片过滤
1393
1548
  if (cartItem._origin.start_time) {
1394
1549
  var startTime = dayjs("".concat(cartItem._origin.start_date, " ").concat(cartItem._origin.start_time));
@@ -1416,6 +1571,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1416
1571
  return false;
1417
1572
  }
1418
1573
  var canUseArr = mTimes.map(function (item) {
1574
+ var _cartItem$_productOri7;
1419
1575
  var res = getIsUsableByTimeItem({
1420
1576
  timeSlice: {
1421
1577
  start_time: startTime.format('HH:mm'),
@@ -1426,7 +1582,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1426
1582
  time: item,
1427
1583
  resource: m,
1428
1584
  currentCount: currentCapacity || 0,
1429
- resourcesUseableMap: resourcesUseableMap
1585
+ resourcesUseableMap: resourcesUseableMap,
1586
+ cut_off_time: (_cartItem$_productOri7 = cartItem._productOrigin) === null || _cartItem$_productOri7 === void 0 ? void 0 : _cartItem$_productOri7.cut_off_time
1430
1587
  });
1431
1588
  // 如果仅仅是因为子资源容量不够,不应该标记子资源是被占用的情况
1432
1589
  if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
@@ -1446,13 +1603,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1446
1603
  // 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
1447
1604
  // 同时,在这一步尝试去拉一下时间片,基于商品的时长,看每个资源是否还有空余时间能对这个商品做服务,如果没有则过滤
1448
1605
  item.renderList = item.renderList.filter(function (n) {
1449
- var _cartItem$_productOri6;
1606
+ var _cartItem$_productOri8;
1450
1607
  var recordCount = n.capacity || 0;
1451
1608
  if (n.onlyComputed) return false;
1452
1609
  // 查一下这个资源基于商品的可用时间片
1453
1610
  var timeSlots = getTimeSlicesByResource({
1454
1611
  resource: n,
1455
- duration: ((_cartItem$_productOri6 = cartItem._productOrigin) === null || _cartItem$_productOri6 === void 0 || (_cartItem$_productOri6 = _cartItem$_productOri6.duration) === null || _cartItem$_productOri6 === void 0 ? void 0 : _cartItem$_productOri6.value) || 0,
1612
+ duration: ((_cartItem$_productOri8 = cartItem._productOrigin) === null || _cartItem$_productOri8 === void 0 || (_cartItem$_productOri8 = _cartItem$_productOri8.duration) === null || _cartItem$_productOri8 === void 0 ? void 0 : _cartItem$_productOri8.value) || 0,
1456
1613
  split: 10,
1457
1614
  currentDate: dateRange[0].date
1458
1615
  });
@@ -1554,7 +1711,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1554
1711
  }, {
1555
1712
  key: "autoSelectAccountResources",
1556
1713
  value: function autoSelectAccountResources(_ref8) {
1557
- var _cartItem$_productOri7, _allProductResources$;
1714
+ var _cartItem$_productOri9, _allProductResources$;
1558
1715
  var cartItem = _ref8.cartItem,
1559
1716
  holder_id = _ref8.holder_id,
1560
1717
  resources_code = _ref8.resources_code,
@@ -1603,7 +1760,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1603
1760
  var resourcesMap = getResourcesMap(cloneDeep(AllResources));
1604
1761
  var allCartItems = cloneDeep(this.store.cart.getItems());
1605
1762
  var selectedResources = getOthersSelectedResources(allCartItems, holder_id, resourcesMap);
1606
- var allProductResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri7 = cartItem._productOrigin) === null || _cartItem$_productOri7 === void 0 || (_cartItem$_productOri7 = _cartItem$_productOri7.product_resource) === null || _cartItem$_productOri7 === void 0 ? void 0 : _cartItem$_productOri7.resources) || [], selectedResources, 1);
1763
+ var allProductResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri9 = cartItem._productOrigin) === null || _cartItem$_productOri9 === void 0 || (_cartItem$_productOri9 = _cartItem$_productOri9.product_resource) === null || _cartItem$_productOri9 === void 0 ? void 0 : _cartItem$_productOri9.resources) || [], selectedResources, 1);
1607
1764
  var resources = ((_allProductResources$ = allProductResources.find(function (n) {
1608
1765
  return n.code === resources_code;
1609
1766
  })) === null || _allProductResources$ === void 0 ? void 0 : _allProductResources$.renderList) || [];
@@ -1631,11 +1788,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1631
1788
  // .format("HH:mm");
1632
1789
  // 根据 start_time 和 end_time 去匹配资源
1633
1790
  var targetResource = null;
1634
- var _iterator2 = _createForOfIteratorHelper(resources),
1635
- _step2;
1791
+ var _iterator3 = _createForOfIteratorHelper(resources),
1792
+ _step3;
1636
1793
  try {
1637
- var _loop = function _loop() {
1638
- var n = _step2.value;
1794
+ var _loop2 = function _loop2() {
1795
+ var n = _step3.value;
1639
1796
  // 如果资源是独占的,并且 countMap 里选择过这个资源,则直接跳过
1640
1797
  // if (n.resourceType === 'single' && countMap[n.id]) {
1641
1798
  // resourcesUseableMap[n.id] = false;
@@ -1653,12 +1810,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1653
1810
  return 0; // continue
1654
1811
  }
1655
1812
  var canUseTime = mTimes.find(function (item) {
1813
+ var _cartItem$_productOri10;
1656
1814
  var res = getIsUsableByTimeItem({
1657
1815
  timeSlice: timeSlots,
1658
1816
  time: item,
1659
1817
  resource: n,
1660
1818
  currentCount: recordCount + (capacity || 0),
1661
- resourcesUseableMap: resourcesUseableMap
1819
+ resourcesUseableMap: resourcesUseableMap,
1820
+ cut_off_time: (_cartItem$_productOri10 = cartItem._productOrigin) === null || _cartItem$_productOri10 === void 0 ? void 0 : _cartItem$_productOri10.cut_off_time
1662
1821
  });
1663
1822
  // 如果只是因为子资源容量不够,而不是子资源被预约导致没时间片,不应该标记子资源为不可用,从而影响组合资源的情况
1664
1823
  if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[n.id]) !== false && res.reason !== 'capacityOnly') {
@@ -1672,15 +1831,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1672
1831
  }
1673
1832
  },
1674
1833
  _ret;
1675
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
1676
- _ret = _loop();
1834
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
1835
+ _ret = _loop2();
1677
1836
  if (_ret === 0) continue;
1678
1837
  if (_ret === 1) break;
1679
1838
  }
1680
1839
  } catch (err) {
1681
- _iterator2.e(err);
1840
+ _iterator3.e(err);
1682
1841
  } finally {
1683
- _iterator2.f();
1842
+ _iterator3.f();
1684
1843
  }
1685
1844
  return {
1686
1845
  selectedResource: targetResource
@@ -1715,7 +1874,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1715
1874
  key: "autoSelectAllProductResources",
1716
1875
  value: function autoSelectAllProductResources(resources_code, timeSlots) {
1717
1876
  var _dateRange$4,
1718
- _this8 = this;
1877
+ _this9 = this;
1719
1878
  var dateRange = this.store.date.getDateRange();
1720
1879
  var resources = [];
1721
1880
  if (dateRange !== null && dateRange !== void 0 && (_dateRange$4 = dateRange[0]) !== null && _dateRange$4 !== void 0 && _dateRange$4.date) {
@@ -1772,7 +1931,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1772
1931
  };
1773
1932
  }
1774
1933
  // 如果传递了 timeSlots,代表是第二种资源,则直接拿 timeSlots 去匹配
1775
- var res = _this8.autoSelectAccountResources({
1934
+ var res = _this9.autoSelectAccountResources({
1776
1935
  cartItem: item,
1777
1936
  holder_id: item.holder_id,
1778
1937
  resources_code: resources_code,
@@ -1792,7 +1951,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1792
1951
  }
1793
1952
  res.selectedResource.capacity = currentCapacity;
1794
1953
  checkSubResourcesCapacity(res.selectedResource);
1795
- _this8.store.cart.updateItem({
1954
+ _this9.store.cart.updateItem({
1796
1955
  _id: item._id,
1797
1956
  // 这里要做去重,避免出现同样类型的资源被塞进同一个商品
1798
1957
  resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
@@ -1807,7 +1966,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1807
1966
  } else {
1808
1967
  var _item$_productOrigin10, _productResources$fin;
1809
1968
  // 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
1810
- var allCartItems = cloneDeep(_this8.store.cart.getItems());
1969
+ var allCartItems = cloneDeep(_this9.store.cart.getItems());
1811
1970
  // 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
1812
1971
  var selectedResources = [];
1813
1972
  var _resources = cloneDeep(((_item$_productOrigin10 = item._productOrigin) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.product_resource) === null || _item$_productOrigin10 === void 0 ? void 0 : _item$_productOrigin10.resources) || []);
@@ -1866,7 +2025,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1866
2025
  } else {
1867
2026
  selectResourcesMap[targetResource.id] += currentCapacity;
1868
2027
  }
1869
- _this8.store.cart.updateItem({
2028
+ _this9.store.cart.updateItem({
1870
2029
  _id: item._id,
1871
2030
  resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
1872
2031
  return existingRes.resourceType !== targetRenderList[0].resourceType;
@@ -1884,7 +2043,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1884
2043
  // 如果购物车里没有 holderid数据,证明不按 holder 类流程预约走,给所有购物车一次性分派即可,不做账号下资源互斥逻辑
1885
2044
  if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
1886
2045
  accountList.forEach(function (account) {
1887
- var cartItems = _this8.store.cart.getCartByAccount(account.getId());
2046
+ var cartItems = _this9.store.cart.getCartByAccount(account.getId());
1888
2047
  selectForCartResources(cartItems);
1889
2048
  });
1890
2049
  } else {
@@ -1899,9 +2058,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1899
2058
  key: "getTimeSlotByAllResources",
1900
2059
  value: function getTimeSlotByAllResources(resources_code) {
1901
2060
  var _dateRange,
1902
- _this9 = this,
1903
- _cartItems$,
1904
- _cartItems$2;
2061
+ _this10 = this,
2062
+ _cartItems$3,
2063
+ _cartItems$4;
1905
2064
  var dateRange = this.store.date.getDateRange();
1906
2065
  // 取出购物车中所有一已选择的第一步资源
1907
2066
  var resources = [];
@@ -1909,11 +2068,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1909
2068
  // if (cartItems?.[0].start_date) return [];
1910
2069
  var resourceIds = [];
1911
2070
  var resourcesTypeId = undefined;
2071
+ var isSingleResource = false;
1912
2072
  cartItems.forEach(function (item) {
1913
2073
  var _item$_productOrigin11, _item$_productOrigin12;
1914
2074
  (_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.forEach(function (n) {
1915
2075
  if (n.code === resources_code) {
1916
2076
  resources.push.apply(resources, _toConsumableArray(n.renderList || []));
2077
+ isSingleResource = n.type === 'single';
1917
2078
  }
1918
2079
  });
1919
2080
  // item._origin.resources?.forEach((n: any) => {
@@ -1944,8 +2105,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1944
2105
  var checkDuration = function checkDuration(cartItems) {
1945
2106
  var accountDuration = 0;
1946
2107
  cartItems.forEach(function (item) {
1947
- var _item$_productOrigin$3, _item$_productOrigin13;
1948
- accountDuration += (_item$_productOrigin$3 = (_item$_productOrigin13 = item._productOrigin) === null || _item$_productOrigin13 === void 0 || (_item$_productOrigin13 = _item$_productOrigin13.duration) === null || _item$_productOrigin13 === void 0 ? void 0 : _item$_productOrigin13.value) !== null && _item$_productOrigin$3 !== void 0 ? _item$_productOrigin$3 : 0;
2108
+ // 单个预约累加账号 多个预约取最大值
2109
+ if (isSingleResource) {
2110
+ var _item$_productOrigin$3, _item$_productOrigin13;
2111
+ accountDuration += (_item$_productOrigin$3 = (_item$_productOrigin13 = item._productOrigin) === null || _item$_productOrigin13 === void 0 || (_item$_productOrigin13 = _item$_productOrigin13.duration) === null || _item$_productOrigin13 === void 0 ? void 0 : _item$_productOrigin13.value) !== null && _item$_productOrigin$3 !== void 0 ? _item$_productOrigin$3 : 0;
2112
+ } else {
2113
+ var _item$_productOrigin$4, _item$_productOrigin14;
2114
+ if (accountDuration < ((_item$_productOrigin$4 = (_item$_productOrigin14 = item._productOrigin) === null || _item$_productOrigin14 === void 0 || (_item$_productOrigin14 = _item$_productOrigin14.duration) === null || _item$_productOrigin14 === void 0 ? void 0 : _item$_productOrigin14.value) !== null && _item$_productOrigin$4 !== void 0 ? _item$_productOrigin$4 : 0)) {
2115
+ var _item$_productOrigin$5, _item$_productOrigin15;
2116
+ accountDuration = (_item$_productOrigin$5 = (_item$_productOrigin15 = item._productOrigin) === null || _item$_productOrigin15 === void 0 || (_item$_productOrigin15 = _item$_productOrigin15.duration) === null || _item$_productOrigin15 === void 0 ? void 0 : _item$_productOrigin15.value) !== null && _item$_productOrigin$5 !== void 0 ? _item$_productOrigin$5 : 0;
2117
+ }
2118
+ }
1949
2119
  });
1950
2120
  if (accountDuration > duration) {
1951
2121
  duration = accountDuration;
@@ -1953,7 +2123,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1953
2123
  };
1954
2124
  if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
1955
2125
  accountList.forEach(function (account) {
1956
- var cartItems = _this9.store.cart.getCartByAccount(account.getId());
2126
+ var cartItems = _this10.store.cart.getCartByAccount(account.getId());
1957
2127
  checkDuration(cartItems);
1958
2128
  });
1959
2129
  } else {
@@ -1961,18 +2131,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1961
2131
  }
1962
2132
  // 如果 cartItem 上既没有时间,也没有资源,认为外部属于异常调用,直接丢一个空数组出去
1963
2133
  // 同时 session 类商品的流程也不应该调用这个方法
1964
- if (!(cartItems !== null && cartItems !== void 0 && (_cartItems$ = cartItems[0]) !== null && _cartItems$ !== void 0 && _cartItems$.start_date) && !(cartItems !== null && cartItems !== void 0 && (_cartItems$2 = cartItems[0]) !== null && _cartItems$2 !== void 0 && _cartItems$2.resource_id) || !(cartItems !== null && cartItems !== void 0 && cartItems[0].duration)) {
2134
+ if (!(cartItems !== null && cartItems !== void 0 && (_cartItems$3 = cartItems[0]) !== null && _cartItems$3 !== void 0 && _cartItems$3.start_date) && !(cartItems !== null && cartItems !== void 0 && (_cartItems$4 = cartItems[0]) !== null && _cartItems$4 !== void 0 && _cartItems$4.resource_id) || !(cartItems !== null && cartItems !== void 0 && cartItems[0].duration)) {
1965
2135
  return [];
1966
2136
  }
1967
2137
  if (cartItems !== null && cartItems !== void 0 && cartItems[0].start_date && !dateRange) {
1968
- var _cartItems$3, _cartItems$4;
2138
+ var _cartItems$5, _cartItems$6;
1969
2139
  dateRange = [{
1970
2140
  date: cartItems === null || cartItems === void 0 ? void 0 : cartItems[0].start_date,
1971
2141
  status: 'available',
1972
2142
  week: '',
1973
2143
  weekNum: 0
1974
2144
  }, {
1975
- date: (cartItems === null || cartItems === void 0 || (_cartItems$3 = cartItems[0]) === null || _cartItems$3 === void 0 ? void 0 : _cartItems$3.end_date) || (cartItems === null || cartItems === void 0 || (_cartItems$4 = cartItems[0]) === null || _cartItems$4 === void 0 ? void 0 : _cartItems$4.start_date) || '',
2145
+ date: (cartItems === null || cartItems === void 0 || (_cartItems$5 = cartItems[0]) === null || _cartItems$5 === void 0 ? void 0 : _cartItems$5.end_date) || (cartItems === null || cartItems === void 0 || (_cartItems$6 = cartItems[0]) === null || _cartItems$6 === void 0 ? void 0 : _cartItems$6.start_date) || '',
1976
2146
  status: 'available',
1977
2147
  week: '',
1978
2148
  weekNum: 0
@@ -1994,7 +2164,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1994
2164
  }, {
1995
2165
  key: "submitTimeSlot",
1996
2166
  value: function submitTimeSlot(timeSlots) {
1997
- var _this10 = this;
2167
+ var _this11 = this;
1998
2168
  // 以账号为维度处理数据。购物车里每一项的 startTime应该是前一个商品的 endTime,如果是第一个商品则用 timeSlots.start_at
1999
2169
  var cartItems = cloneDeep(this.store.cart.getItems());
2000
2170
 
@@ -2015,12 +2185,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2015
2185
  var _newResources$;
2016
2186
  var newResources = cloneDeep(item._origin.resources);
2017
2187
  newResources.forEach(function (resource) {
2018
- var _item$_productOrigin$4, _item$_productOrigin14, _ref11, _item$_productOrigin15;
2188
+ var _item$_productOrigin$6, _item$_productOrigin16, _ref11, _item$_productOrigin17;
2019
2189
  resource.startTime = currentStartTime;
2020
- resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$4 = (_item$_productOrigin14 = item._productOrigin) === null || _item$_productOrigin14 === void 0 || (_item$_productOrigin14 = _item$_productOrigin14.duration) === null || _item$_productOrigin14 === void 0 ? void 0 : _item$_productOrigin14.value) !== null && _item$_productOrigin$4 !== void 0 ? _item$_productOrigin$4 : 0, (_ref11 = (_item$_productOrigin15 = item._productOrigin) === null || _item$_productOrigin15 === void 0 || (_item$_productOrigin15 = _item$_productOrigin15.duration) === null || _item$_productOrigin15 === void 0 ? void 0 : _item$_productOrigin15.type) !== null && _ref11 !== void 0 ? _ref11 : 'minutes').format('YYYY-MM-DD HH:mm');
2190
+ resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$6 = (_item$_productOrigin16 = item._productOrigin) === null || _item$_productOrigin16 === void 0 || (_item$_productOrigin16 = _item$_productOrigin16.duration) === null || _item$_productOrigin16 === void 0 ? void 0 : _item$_productOrigin16.value) !== null && _item$_productOrigin$6 !== void 0 ? _item$_productOrigin$6 : 0, (_ref11 = (_item$_productOrigin17 = item._productOrigin) === null || _item$_productOrigin17 === void 0 || (_item$_productOrigin17 = _item$_productOrigin17.duration) === null || _item$_productOrigin17 === void 0 ? void 0 : _item$_productOrigin17.type) !== null && _ref11 !== void 0 ? _ref11 : 'minutes').format('YYYY-MM-DD HH:mm');
2021
2191
  delete resource.times;
2022
2192
  });
2023
- _this10.store.cart.updateItem({
2193
+ _this11.store.cart.updateItem({
2024
2194
  _id: item._id,
2025
2195
  resources: newResources
2026
2196
  });
@@ -2068,15 +2238,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2068
2238
  }, {
2069
2239
  key: "openProductDetail",
2070
2240
  value: function () {
2071
- var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(productId) {
2241
+ var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(productId) {
2072
2242
  var targetProduct, targetProductData, newScheduleArr;
2073
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2074
- while (1) switch (_context25.prev = _context25.next) {
2243
+ return _regeneratorRuntime().wrap(function _callee26$(_context27) {
2244
+ while (1) switch (_context27.prev = _context27.next) {
2075
2245
  case 0:
2076
- _context25.next = 2;
2246
+ _context27.next = 2;
2077
2247
  return this.store.products.getProduct(productId);
2078
2248
  case 2:
2079
- targetProduct = _context25.sent;
2249
+ targetProduct = _context27.sent;
2080
2250
  if (targetProduct) {
2081
2251
  targetProductData = targetProduct.getData();
2082
2252
  this.store.currentProduct = targetProduct;
@@ -2085,11 +2255,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2085
2255
  }
2086
2256
  case 4:
2087
2257
  case "end":
2088
- return _context25.stop();
2258
+ return _context27.stop();
2089
2259
  }
2090
- }, _callee25, this);
2260
+ }, _callee26, this);
2091
2261
  }));
2092
- function openProductDetail(_x18) {
2262
+ function openProductDetail(_x19) {
2093
2263
  return _openProductDetail.apply(this, arguments);
2094
2264
  }
2095
2265
  return openProductDetail;
@@ -2207,7 +2377,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2207
2377
  }, {
2208
2378
  key: "addProductToCart",
2209
2379
  value: function addProductToCart(_ref13) {
2210
- var _this11 = this;
2380
+ var _this12 = this;
2211
2381
  var product = _ref13.product,
2212
2382
  date = _ref13.date,
2213
2383
  account = _ref13.account;
@@ -2240,7 +2410,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2240
2410
  });
2241
2411
  if (cartItemsByDate.length) {
2242
2412
  cartItemsByDate.forEach(function (n) {
2243
- _this11.store.cart.removeItem(n._id);
2413
+ _this12.store.cart.removeItem(n._id);
2244
2414
  });
2245
2415
  }
2246
2416
  }
@@ -2266,29 +2436,29 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2266
2436
  }, {
2267
2437
  key: "getProductTypeById",
2268
2438
  value: function () {
2269
- var _getProductTypeById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(id) {
2439
+ var _getProductTypeById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(id) {
2270
2440
  var product;
2271
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2272
- while (1) switch (_context26.prev = _context26.next) {
2441
+ return _regeneratorRuntime().wrap(function _callee27$(_context28) {
2442
+ while (1) switch (_context28.prev = _context28.next) {
2273
2443
  case 0:
2274
- _context26.next = 2;
2444
+ _context28.next = 2;
2275
2445
  return this.store.products.getProduct(id);
2276
2446
  case 2:
2277
- product = _context26.sent;
2447
+ product = _context28.sent;
2278
2448
  if (!product) {
2279
- _context26.next = 5;
2449
+ _context28.next = 5;
2280
2450
  break;
2281
2451
  }
2282
- return _context26.abrupt("return", product.getProductType());
2452
+ return _context28.abrupt("return", product.getProductType());
2283
2453
  case 5:
2284
- return _context26.abrupt("return", 'normal');
2454
+ return _context28.abrupt("return", 'normal');
2285
2455
  case 6:
2286
2456
  case "end":
2287
- return _context26.stop();
2457
+ return _context28.stop();
2288
2458
  }
2289
- }, _callee26, this);
2459
+ }, _callee27, this);
2290
2460
  }));
2291
- function getProductTypeById(_x19) {
2461
+ function getProductTypeById(_x20) {
2292
2462
  return _getProductTypeById.apply(this, arguments);
2293
2463
  }
2294
2464
  return getProductTypeById;