@pisell/pisellos 0.0.55 → 0.0.56

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.
@@ -176,6 +176,8 @@ export interface IUpdateItemParams {
176
176
  quantity?: number;
177
177
  /** 资源 */
178
178
  resources?: Resource[];
179
+ /** 元数据 */
180
+ metadata?: any;
179
181
  /** 备注 */
180
182
  note?: string;
181
183
  /** 日期 */
@@ -878,6 +878,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
878
878
  cartItems = this.store.cart.getItems();
879
879
  newCartItems = cloneDeep(cartItems); // 先整个临时的逻辑,把购物车里所有商品的资源给他格式化一下
880
880
  newCartItems.forEach(function (item) {
881
+ var _item$_productOrigin;
881
882
  item._origin.resources = item._origin.resources.map(function (n) {
882
883
  var newResourcesItem = cloneDeep(n);
883
884
  delete newResourcesItem.id;
@@ -885,6 +886,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
885
886
  delete newResourcesItem.resourceType;
886
887
  return _objectSpread({}, newResourcesItem);
887
888
  });
889
+ var formatCapacity = formatDefaultCapacitys({
890
+ capacity: (_item$_productOrigin = item._productOrigin) === null || _item$_productOrigin === void 0 ? void 0 : _item$_productOrigin.capacity,
891
+ product_bundle: item._origin.product.product_bundle
892
+ });
893
+ item._origin.metadata.capacity = formatCapacity;
888
894
  });
889
895
  return _context20.abrupt("return", this.store.order.submitOrder({
890
896
  query: {
@@ -992,8 +998,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
992
998
  throw new Error("\u6CA1\u6709\u627E\u5230".concat(params._id, "\u8D2D\u7269\u8F66\u5546\u54C1"));
993
999
  }
994
1000
  if (params.resources) {
1001
+ var _targetCartItem$_prod;
1002
+ var formatCapacity = formatDefaultCapacitys({
1003
+ capacity: (_targetCartItem$_prod = targetCartItem._productOrigin) === null || _targetCartItem$_prod === void 0 ? void 0 : _targetCartItem$_prod.capacity,
1004
+ product_bundle: targetCartItem._origin.product.product_bundle
1005
+ });
1006
+ var currentCapacity = getSumCapacity({
1007
+ capacity: formatCapacity
1008
+ });
995
1009
  params.resources = params.resources.map(function (n) {
996
- n.capacity = targetCartItem.num || 1;
1010
+ n.capacity = currentCapacity || 1;
997
1011
  checkSubResourcesCapacity(n);
998
1012
  return n;
999
1013
  });
@@ -1116,6 +1130,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1116
1130
  capacity: (_cartItem$_productOri = cartItem._productOrigin) === null || _cartItem$_productOri === void 0 ? void 0 : _cartItem$_productOri.capacity,
1117
1131
  product_bundle: cartItem._origin.product.product_bundle
1118
1132
  });
1133
+ cartItem._origin.metadata.capacity = formatCapacity;
1119
1134
  var currentCapacity = getSumCapacity({
1120
1135
  capacity: formatCapacity
1121
1136
  });
@@ -1163,7 +1178,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1163
1178
  }, {
1164
1179
  key: "getResourcesListByCartItem",
1165
1180
  value: function getResourcesListByCartItem(id) {
1166
- var _targetCartItem$_prod, _targetCartItem$_prod2;
1181
+ var _targetCartItem$_prod2, _targetCartItem$_prod3;
1167
1182
  var cartItems = this.store.cart.getItems();
1168
1183
  var dateRange = this.store.date.getDateRange();
1169
1184
  var resources = [];
@@ -1186,13 +1201,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1186
1201
  selectedResources = getOthersCartSelectedResources(cartItems, targetCartItem._id, resourcesMap);
1187
1202
  }
1188
1203
  var formatCapacity = formatDefaultCapacitys({
1189
- capacity: (_targetCartItem$_prod = targetCartItem._productOrigin) === null || _targetCartItem$_prod === void 0 ? void 0 : _targetCartItem$_prod.capacity,
1204
+ capacity: (_targetCartItem$_prod2 = targetCartItem._productOrigin) === null || _targetCartItem$_prod2 === void 0 ? void 0 : _targetCartItem$_prod2.capacity,
1190
1205
  product_bundle: targetCartItem._origin.product.product_bundle
1191
1206
  });
1192
1207
  var currentCapacity = getSumCapacity({
1193
1208
  capacity: formatCapacity
1194
1209
  });
1195
- var productResources = getResourcesByProduct(resourcesMap, ((_targetCartItem$_prod2 = targetCartItem._productOrigin) === null || _targetCartItem$_prod2 === void 0 || (_targetCartItem$_prod2 = _targetCartItem$_prod2.product_resource) === null || _targetCartItem$_prod2 === void 0 ? void 0 : _targetCartItem$_prod2.resources) || [], selectedResources, currentCapacity);
1210
+ 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);
1196
1211
  if (productResources) {
1197
1212
  return {
1198
1213
  id: targetCartItem.id,
@@ -1327,8 +1342,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1327
1342
  // 取出账号下所对应类型的所有的可用资源
1328
1343
  var resources = [];
1329
1344
  accountCartItems.forEach(function (item) {
1330
- var _item$_productOrigin;
1331
- (_item$_productOrigin = item._productOrigin) === null || _item$_productOrigin === void 0 || (_item$_productOrigin = _item$_productOrigin.product_resource) === null || _item$_productOrigin === void 0 || (_item$_productOrigin = _item$_productOrigin.resources) === null || _item$_productOrigin === void 0 || _item$_productOrigin.forEach(function (n) {
1345
+ var _item$_productOrigin2;
1346
+ (_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 || _item$_productOrigin2.forEach(function (n) {
1332
1347
  if (n.code === resources_code) {
1333
1348
  resources.push.apply(resources, _toConsumableArray(n.renderList || []));
1334
1349
  }
@@ -1424,9 +1439,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1424
1439
  // 第一个商品分配完以后,第二个商品分配的start_time应该是第一个商品的 end_time ,然后 end_time 应该是 start_time+duration
1425
1440
 
1426
1441
  cartItems.forEach(function (item, index) {
1427
- var _item$_productOrigin2;
1442
+ var _item$_productOrigin3;
1428
1443
  var formatCapacity = formatDefaultCapacitys({
1429
- capacity: (_item$_productOrigin2 = item._productOrigin) === null || _item$_productOrigin2 === void 0 ? void 0 : _item$_productOrigin2.capacity,
1444
+ capacity: (_item$_productOrigin3 = item._productOrigin) === null || _item$_productOrigin3 === void 0 ? void 0 : _item$_productOrigin3.capacity,
1430
1445
  product_bundle: item._origin.product.product_bundle
1431
1446
  });
1432
1447
  var currentCapacity = getSumCapacity({
@@ -1443,9 +1458,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1443
1458
  }
1444
1459
  if (recordTimeSlots) {
1445
1460
  if (index !== 0 && recordTimeSlots) {
1446
- var _item$_productOrigin$, _item$_productOrigin3, _ref10, _item$_productOrigin4, _item$_productOrigin$2, _item$_productOrigin5, _ref11, _item$_productOrigin6;
1447
- var start_at = dayjs(recordTimeSlots.end_time).add((_item$_productOrigin$ = (_item$_productOrigin3 = item._productOrigin) === null || _item$_productOrigin3 === void 0 || (_item$_productOrigin3 = _item$_productOrigin3.duration) === null || _item$_productOrigin3 === void 0 ? void 0 : _item$_productOrigin3.value) !== null && _item$_productOrigin$ !== void 0 ? _item$_productOrigin$ : 0, (_ref10 = (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.duration) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.type) !== null && _ref10 !== void 0 ? _ref10 : 'minutes');
1448
- var end_at = start_at.add((_item$_productOrigin$2 = (_item$_productOrigin5 = item._productOrigin) === null || _item$_productOrigin5 === void 0 || (_item$_productOrigin5 = _item$_productOrigin5.duration) === null || _item$_productOrigin5 === void 0 ? void 0 : _item$_productOrigin5.value) !== null && _item$_productOrigin$2 !== void 0 ? _item$_productOrigin$2 : 0, (_ref11 = (_item$_productOrigin6 = item._productOrigin) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.duration) === null || _item$_productOrigin6 === void 0 ? void 0 : _item$_productOrigin6.type) !== null && _ref11 !== void 0 ? _ref11 : 'minutes');
1461
+ var _item$_productOrigin$, _item$_productOrigin4, _ref10, _item$_productOrigin5, _item$_productOrigin$2, _item$_productOrigin6, _ref11, _item$_productOrigin7;
1462
+ var start_at = dayjs(recordTimeSlots.end_time).add((_item$_productOrigin$ = (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.duration) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.value) !== null && _item$_productOrigin$ !== void 0 ? _item$_productOrigin$ : 0, (_ref10 = (_item$_productOrigin5 = item._productOrigin) === null || _item$_productOrigin5 === void 0 || (_item$_productOrigin5 = _item$_productOrigin5.duration) === null || _item$_productOrigin5 === void 0 ? void 0 : _item$_productOrigin5.type) !== null && _ref10 !== void 0 ? _ref10 : 'minutes');
1463
+ var end_at = start_at.add((_item$_productOrigin$2 = (_item$_productOrigin6 = item._productOrigin) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.duration) === null || _item$_productOrigin6 === void 0 ? void 0 : _item$_productOrigin6.value) !== null && _item$_productOrigin$2 !== void 0 ? _item$_productOrigin$2 : 0, (_ref11 = (_item$_productOrigin7 = item._productOrigin) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.duration) === null || _item$_productOrigin7 === void 0 ? void 0 : _item$_productOrigin7.type) !== null && _ref11 !== void 0 ? _ref11 : 'minutes');
1449
1464
  recordTimeSlots = {
1450
1465
  start_time: start_at.format('HH:mm'),
1451
1466
  end_time: end_at.format('HH:mm'),
@@ -1485,7 +1500,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1485
1500
  errorList.push(item._id);
1486
1501
  }
1487
1502
  } else {
1488
- var _item$_productOrigin7, _productResources$fin;
1503
+ var _item$_productOrigin8, _productResources$fin;
1489
1504
  // 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
1490
1505
  var allCartItems = _this7.store.cart.getItems();
1491
1506
  // 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
@@ -1495,7 +1510,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1495
1510
  } else {
1496
1511
  selectedResources = getOthersCartSelectedResources(allCartItems, item._id, resourcesMap);
1497
1512
  }
1498
- var productResources = getResourcesByProduct(resourcesMap, ((_item$_productOrigin7 = item._productOrigin) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.product_resource) === null || _item$_productOrigin7 === void 0 ? void 0 : _item$_productOrigin7.resources) || [], selectedResources, currentCapacity);
1513
+ var productResources = getResourcesByProduct(resourcesMap, ((_item$_productOrigin8 = item._productOrigin) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.product_resource) === null || _item$_productOrigin8 === void 0 ? void 0 : _item$_productOrigin8.resources) || [], selectedResources, currentCapacity);
1499
1514
  // 自动选择 productResources 中对应 resources_code 的资源
1500
1515
  var targetRenderList = (_productResources$fin = productResources.find(function (n) {
1501
1516
  return n.code === resources_code;
@@ -1552,8 +1567,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1552
1567
  // if (cartItems?.[0].start_date) return [];
1553
1568
  var resourceIds = [];
1554
1569
  cartItems.forEach(function (item) {
1555
- var _item$_productOrigin8;
1556
- (_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.forEach(function (n) {
1570
+ var _item$_productOrigin9;
1571
+ (_item$_productOrigin9 = item._productOrigin) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.product_resource) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.resources) === null || _item$_productOrigin9 === void 0 || _item$_productOrigin9.forEach(function (n) {
1557
1572
  if (n.code === resources_code) {
1558
1573
  resources.push.apply(resources, _toConsumableArray(n.renderList || []));
1559
1574
  }
@@ -1572,8 +1587,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1572
1587
  var checkDuration = function checkDuration(cartItems) {
1573
1588
  var accountDuration = 0;
1574
1589
  cartItems.forEach(function (item) {
1575
- var _item$_productOrigin$3, _item$_productOrigin9;
1576
- accountDuration += (_item$_productOrigin$3 = (_item$_productOrigin9 = item._productOrigin) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.duration) === null || _item$_productOrigin9 === void 0 ? void 0 : _item$_productOrigin9.value) !== null && _item$_productOrigin$3 !== void 0 ? _item$_productOrigin$3 : 0;
1590
+ var _item$_productOrigin$3, _item$_productOrigin10;
1591
+ accountDuration += (_item$_productOrigin$3 = (_item$_productOrigin10 = item._productOrigin) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.duration) === null || _item$_productOrigin10 === void 0 ? void 0 : _item$_productOrigin10.value) !== null && _item$_productOrigin$3 !== void 0 ? _item$_productOrigin$3 : 0;
1577
1592
  });
1578
1593
  if (accountDuration > duration) {
1579
1594
  duration = accountDuration;
@@ -1587,9 +1602,20 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1587
1602
  } else {
1588
1603
  checkDuration(cartItems);
1589
1604
  }
1590
- this.store.accountList.getAccounts().forEach(function (account) {
1591
- var cartItems = _this8.store.cart.getCartByAccount(account.getId());
1592
- });
1605
+ if (cartItems !== null && cartItems !== void 0 && cartItems[0].start_date && !dateRange) {
1606
+ var _cartItems$, _cartItems$2;
1607
+ dateRange = [{
1608
+ date: cartItems === null || cartItems === void 0 ? void 0 : cartItems[0].start_date,
1609
+ status: 'available',
1610
+ week: '',
1611
+ weekNum: 0
1612
+ }, {
1613
+ date: (cartItems === null || cartItems === void 0 || (_cartItems$ = cartItems[0]) === null || _cartItems$ === void 0 ? void 0 : _cartItems$.end_date) || (cartItems === null || cartItems === void 0 || (_cartItems$2 = cartItems[0]) === null || _cartItems$2 === void 0 ? void 0 : _cartItems$2.start_date) || '',
1614
+ status: 'available',
1615
+ week: '',
1616
+ weekNum: 0
1617
+ }];
1618
+ }
1593
1619
  var timeSlots = getTimeSlicesByResources({
1594
1620
  resourceIds: resourceIds,
1595
1621
  resourcesMap: resourcesMap,
@@ -1624,9 +1650,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1624
1650
  accountItems.forEach(function (item, index) {
1625
1651
  var newResources = cloneDeep(item._origin.resources);
1626
1652
  newResources.forEach(function (resource) {
1627
- var _item$_productOrigin$4, _item$_productOrigin10, _ref12, _item$_productOrigin11;
1653
+ var _item$_productOrigin$4, _item$_productOrigin11, _ref12, _item$_productOrigin12;
1628
1654
  resource.startTime = currentStartTime;
1629
- resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$4 = (_item$_productOrigin10 = item._productOrigin) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.duration) === null || _item$_productOrigin10 === void 0 ? void 0 : _item$_productOrigin10.value) !== null && _item$_productOrigin$4 !== void 0 ? _item$_productOrigin$4 : 0, (_ref12 = (_item$_productOrigin11 = item._productOrigin) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.duration) === null || _item$_productOrigin11 === void 0 ? void 0 : _item$_productOrigin11.type) !== null && _ref12 !== void 0 ? _ref12 : 'minutes').format('YYYY-MM-DD HH:mm');
1655
+ resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$4 = (_item$_productOrigin11 = item._productOrigin) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.duration) === null || _item$_productOrigin11 === void 0 ? void 0 : _item$_productOrigin11.value) !== null && _item$_productOrigin$4 !== void 0 ? _item$_productOrigin$4 : 0, (_ref12 = (_item$_productOrigin12 = item._productOrigin) === null || _item$_productOrigin12 === void 0 || (_item$_productOrigin12 = _item$_productOrigin12.duration) === null || _item$_productOrigin12 === void 0 ? void 0 : _item$_productOrigin12.type) !== null && _ref12 !== void 0 ? _ref12 : 'minutes').format('YYYY-MM-DD HH:mm');
1630
1656
  delete resource.times;
1631
1657
  });
1632
1658
  _this9.store.cart.updateItem({
@@ -1713,7 +1739,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1713
1739
  var date = _ref13.date,
1714
1740
  scheduleIds = _ref13.scheduleIds,
1715
1741
  resources = _ref13.resources;
1716
- debugger;
1717
1742
  var targetProduct = this.store.currentProduct;
1718
1743
  var targetProductData = targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.getData();
1719
1744
  var targetSchedules = [];
@@ -176,6 +176,8 @@ export interface IUpdateItemParams {
176
176
  quantity?: number;
177
177
  /** 资源 */
178
178
  resources?: Resource[];
179
+ /** 元数据 */
180
+ metadata?: any;
179
181
  /** 备注 */
180
182
  note?: string;
181
183
  /** 日期 */
@@ -427,6 +427,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
427
427
  const cartItems = this.store.cart.getItems();
428
428
  const newCartItems = (0, import_lodash_es.cloneDeep)(cartItems);
429
429
  newCartItems.forEach((item) => {
430
+ var _a;
430
431
  item._origin.resources = item._origin.resources.map((n) => {
431
432
  const newResourcesItem = (0, import_lodash_es.cloneDeep)(n);
432
433
  delete newResourcesItem.id;
@@ -434,6 +435,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
434
435
  delete newResourcesItem.resourceType;
435
436
  return { ...newResourcesItem };
436
437
  });
438
+ const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
439
+ capacity: (_a = item._productOrigin) == null ? void 0 : _a.capacity,
440
+ product_bundle: item._origin.product.product_bundle
441
+ });
442
+ item._origin.metadata.capacity = formatCapacity;
437
443
  });
438
444
  return this.store.order.submitOrder({ query: { cartItems: newCartItems } });
439
445
  }
@@ -455,13 +461,19 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
455
461
  }
456
462
  // 更新购物车
457
463
  updateCart(params) {
464
+ var _a;
458
465
  const targetCartItem = this.store.cart.getItem(params._id);
459
466
  if (!targetCartItem) {
460
467
  throw new Error(`没有找到${params._id}购物车商品`);
461
468
  }
462
469
  if (params.resources) {
470
+ const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
471
+ capacity: (_a = targetCartItem._productOrigin) == null ? void 0 : _a.capacity,
472
+ product_bundle: targetCartItem._origin.product.product_bundle
473
+ });
474
+ const currentCapacity = (0, import_resources.getSumCapacity)({ capacity: formatCapacity });
463
475
  params.resources = params.resources.map((n) => {
464
- n.capacity = targetCartItem.num || 1;
476
+ n.capacity = currentCapacity || 1;
465
477
  (0, import_resources.checkSubResourcesCapacity)(n);
466
478
  return n;
467
479
  });
@@ -469,14 +481,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
469
481
  this.store.cart.updateItem(params);
470
482
  const cartItems = this.store.cart.getItems();
471
483
  cartItems.forEach((item) => {
472
- var _a;
484
+ var _a2;
473
485
  if (item.holder_id !== (targetCartItem == null ? void 0 : targetCartItem.holder_id)) {
474
- const resources = (_a = item._origin.resources) == null ? void 0 : _a.filter((m) => {
486
+ const resources = (_a2 = item._origin.resources) == null ? void 0 : _a2.filter((m) => {
475
487
  return !targetCartItem._origin.resources.some((targetRes) => {
476
- var _a2, _b;
488
+ var _a3, _b;
477
489
  if (targetRes.id === m.id)
478
490
  return true;
479
- if (((_a2 = targetRes.metadata.combined_resource) == null ? void 0 : _a2.status) === 1 && targetRes.metadata.combined_resource.resource_ids.includes(m.id))
491
+ if (((_a3 = targetRes.metadata.combined_resource) == null ? void 0 : _a3.status) === 1 && targetRes.metadata.combined_resource.resource_ids.includes(m.id))
480
492
  return true;
481
493
  if (((_b = m.metadata.combined_resource) == null ? void 0 : _b.status) === 1 && m.metadata.combined_resource.resource_ids.includes(targetRes.id))
482
494
  return true;
@@ -571,6 +583,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
571
583
  capacity: (_a = cartItem._productOrigin) == null ? void 0 : _a.capacity,
572
584
  product_bundle: cartItem._origin.product.product_bundle
573
585
  });
586
+ cartItem._origin.metadata.capacity = formatCapacity;
574
587
  const currentCapacity = (0, import_resources.getSumCapacity)({ capacity: formatCapacity });
575
588
  const productResources = (0, import_resources.getResourcesByProduct)(
576
589
  resourcesMap,
@@ -941,13 +954,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
941
954
  }
942
955
  // 从购物车中获取已经分配好第一步资源的所有时间片
943
956
  getTimeSlotByAllResources(resources_code) {
944
- const dateRange = this.store.date.getDateRange();
957
+ var _a, _b;
958
+ let dateRange = this.store.date.getDateRange();
945
959
  const resources = [];
946
960
  const cartItems = this.store.cart.getItems();
947
961
  const resourceIds = [];
948
962
  cartItems.forEach((item) => {
949
- var _a, _b, _c;
950
- (_c = (_b = (_a = item._productOrigin) == null ? void 0 : _a.product_resource) == null ? void 0 : _b.resources) == null ? void 0 : _c.forEach((n) => {
963
+ var _a2, _b2, _c;
964
+ (_c = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c.forEach((n) => {
951
965
  if (n.code === resources_code) {
952
966
  resources.push(...n.renderList || []);
953
967
  }
@@ -962,8 +976,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
962
976
  const checkDuration = (cartItems2) => {
963
977
  let accountDuration = 0;
964
978
  cartItems2.forEach((item) => {
965
- var _a, _b;
966
- accountDuration += ((_b = (_a = item._productOrigin) == null ? void 0 : _a.duration) == null ? void 0 : _b.value) ?? 0;
979
+ var _a2, _b2;
980
+ accountDuration += ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) ?? 0;
967
981
  });
968
982
  if (accountDuration > duration) {
969
983
  duration = accountDuration;
@@ -977,9 +991,22 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
977
991
  } else {
978
992
  checkDuration(cartItems);
979
993
  }
980
- this.store.accountList.getAccounts().forEach((account) => {
981
- const cartItems2 = this.store.cart.getCartByAccount(account.getId());
982
- });
994
+ if ((cartItems == null ? void 0 : cartItems[0].start_date) && !dateRange) {
995
+ dateRange = [
996
+ {
997
+ date: cartItems == null ? void 0 : cartItems[0].start_date,
998
+ status: "available",
999
+ week: "",
1000
+ weekNum: 0
1001
+ },
1002
+ {
1003
+ date: ((_a = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _a.end_date) || ((_b = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _b.start_date) || "",
1004
+ status: "available",
1005
+ week: "",
1006
+ weekNum: 0
1007
+ }
1008
+ ];
1009
+ }
983
1010
  const timeSlots = (0, import_resources.getTimeSlicesByResources)({
984
1011
  resourceIds,
985
1012
  resourcesMap,
@@ -1070,7 +1097,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1070
1097
  resources
1071
1098
  }) {
1072
1099
  var _a, _b, _c;
1073
- debugger;
1074
1100
  const targetProduct = this.store.currentProduct;
1075
1101
  const targetProductData = targetProduct == null ? void 0 : targetProduct.getData();
1076
1102
  let targetSchedules = [];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.55",
4
+ "version": "0.0.56",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",