@pisell/pisellos 0.0.130 → 0.0.132

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.
@@ -1909,6 +1909,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1909
1909
  var hasOverlap = !dayjs(item.time.start_at).isAfter(dayjs(timeSlots.start_at)) && !dayjs(item.time.end_at).isBefore(dayjs(timeSlots.end_at));
1910
1910
  return hasOverlap ? sum + item.pax : sum;
1911
1911
  }, 0);
1912
+
1913
+ // 如果资源是单个预约,并且有 totalCapacity,则认为在当前 timeSlots 资源已经被选择过,就不可用了
1914
+ if (n.resourceType === 'single' && totalCapacity > 0) {
1915
+ return 0; // continue
1916
+ }
1912
1917
  var canUseTime = mTimes.find(function (item) {
1913
1918
  var _cartItem$_productOri12;
1914
1919
  var res = getIsUsableByTimeItem({
@@ -1999,11 +2004,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1999
2004
  // timeSlots 传进来的只是用户选中的时间片,但是实际上需要根据多个商品时间进行累加
2000
2005
  // 假设 timeSlots.start_time 是15:40 duration 是 30min
2001
2006
  // 第一个商品分配完以后,第二个商品分配的start_time应该是第一个商品的 end_time ,然后 end_time 应该是 start_time+duration
2002
-
2003
- cartItems.forEach(function (item, index) {
2007
+ // 判断购物车里是否有 flexible 类型的商品,如果有则不累加时间
2008
+ var hasFlexibleProduct = cartItems.some(function (item) {
2004
2009
  var _item$_productOrigin3;
2010
+ return ((_item$_productOrigin3 = item._productOrigin) === null || _item$_productOrigin3 === void 0 || (_item$_productOrigin3 = _item$_productOrigin3.duration) === null || _item$_productOrigin3 === void 0 ? void 0 : _item$_productOrigin3.type) === 'flexible';
2011
+ });
2012
+ cartItems.forEach(function (item, index) {
2013
+ var _item$_productOrigin4;
2005
2014
  var formatCapacity = formatDefaultCapacitys({
2006
- capacity: (_item$_productOrigin3 = item._productOrigin) === null || _item$_productOrigin3 === void 0 ? void 0 : _item$_productOrigin3.capacity,
2015
+ capacity: (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.capacity,
2007
2016
  product_bundle: item._origin.product.product_bundle
2008
2017
  });
2009
2018
  var currentCapacity = getSumCapacity({
@@ -2019,15 +2028,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2019
2028
  };
2020
2029
  }
2021
2030
  if (recordTimeSlots) {
2022
- var _item$_productOrigin4, _item$_productOrigin5, _item$_productOrigin6;
2031
+ var _item$_productOrigin5, _item$_productOrigin6;
2023
2032
  // 同一账号下,如果当前商品不是第一个,则需要根据上一个商品的 end_time 和 duration 计算出当前商品的 start_time 和 end_time
2024
2033
  // 前提:当前资源是单个预约才需要这么做
2025
- var currentResourceConfig = (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.product_resource) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.resources) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.find(function (n) {
2034
+ var currentResourceConfig = (_item$_productOrigin5 = item._productOrigin) === null || _item$_productOrigin5 === void 0 || (_item$_productOrigin5 = _item$_productOrigin5.product_resource) === null || _item$_productOrigin5 === void 0 || (_item$_productOrigin5 = _item$_productOrigin5.resources) === null || _item$_productOrigin5 === void 0 ? void 0 : _item$_productOrigin5.find(function (n) {
2026
2035
  return n.code === resources_code;
2027
2036
  });
2028
2037
  var resourceBookingType = (currentResourceConfig === null || currentResourceConfig === void 0 ? void 0 : currentResourceConfig.type) || 'single';
2029
2038
  // 只有 duration 类商品需要这个操作
2030
- if (index !== 0 && recordTimeSlots && (currentResourceConfig === null || currentResourceConfig === void 0 ? void 0 : currentResourceConfig.type) === 'single' && (_item$_productOrigin5 = item._productOrigin) !== null && _item$_productOrigin5 !== void 0 && _item$_productOrigin5.duration && ((_item$_productOrigin6 = item._productOrigin) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.duration) === null || _item$_productOrigin6 === void 0 ? void 0 : _item$_productOrigin6.type) !== 'flexible') {
2039
+ if (index !== 0 && recordTimeSlots && (currentResourceConfig === null || currentResourceConfig === void 0 ? void 0 : currentResourceConfig.type) === 'single' && (_item$_productOrigin6 = item._productOrigin) !== null && _item$_productOrigin6 !== void 0 && _item$_productOrigin6.duration && !hasFlexibleProduct) {
2031
2040
  var _item$_productOrigin7, _item$_productOrigin8;
2032
2041
  var start_at = dayjs(recordTimeSlots.end_time).add(((_item$_productOrigin7 = item._productOrigin) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.duration) === null || _item$_productOrigin7 === void 0 ? void 0 : _item$_productOrigin7.value) || 10, 'minutes');
2033
2042
  var end_at = start_at.add(((_item$_productOrigin8 = item._productOrigin) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.duration) === null || _item$_productOrigin8 === void 0 ? void 0 : _item$_productOrigin8.value) || 10, 'minutes');
@@ -1227,6 +1227,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1227
1227
  },
1228
1228
  0
1229
1229
  );
1230
+ if (n.resourceType === "single" && totalCapacity > 0) {
1231
+ continue;
1232
+ }
1230
1233
  const canUseTime = mTimes.find((item) => {
1231
1234
  var _a2;
1232
1235
  const res = (0, import_resources.getIsUsableByTimeItem)({
@@ -1294,8 +1297,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1294
1297
  const accountList = this.store.accountList.getAccounts();
1295
1298
  const selectForCartResources = (cartItems2) => {
1296
1299
  let recordTimeSlots = (0, import_lodash_es.cloneDeep)(timeSlots);
1300
+ const hasFlexibleProduct = cartItems2.some((item) => {
1301
+ var _a2, _b;
1302
+ return ((_b = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b.type) === "flexible";
1303
+ });
1297
1304
  cartItems2.forEach((item, index) => {
1298
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
1305
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
1299
1306
  const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
1300
1307
  capacity: (_a2 = item._productOrigin) == null ? void 0 : _a2.capacity,
1301
1308
  product_bundle: item._origin.product.product_bundle
@@ -1314,13 +1321,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1314
1321
  (n) => n.code === resources_code
1315
1322
  );
1316
1323
  const resourceBookingType = (currentResourceConfig == null ? void 0 : currentResourceConfig.type) || "single";
1317
- if (index !== 0 && recordTimeSlots && (currentResourceConfig == null ? void 0 : currentResourceConfig.type) === "single" && ((_e = item._productOrigin) == null ? void 0 : _e.duration) && ((_g = (_f = item._productOrigin) == null ? void 0 : _f.duration) == null ? void 0 : _g.type) !== "flexible") {
1324
+ if (index !== 0 && recordTimeSlots && (currentResourceConfig == null ? void 0 : currentResourceConfig.type) === "single" && ((_e = item._productOrigin) == null ? void 0 : _e.duration) && !hasFlexibleProduct) {
1318
1325
  let start_at = (0, import_dayjs.default)(recordTimeSlots.end_time).add(
1319
- ((_i = (_h = item._productOrigin) == null ? void 0 : _h.duration) == null ? void 0 : _i.value) || 10,
1326
+ ((_g = (_f = item._productOrigin) == null ? void 0 : _f.duration) == null ? void 0 : _g.value) || 10,
1320
1327
  "minutes"
1321
1328
  );
1322
1329
  let end_at = start_at.add(
1323
- ((_k = (_j = item._productOrigin) == null ? void 0 : _j.duration) == null ? void 0 : _k.value) || 10,
1330
+ ((_i = (_h = item._productOrigin) == null ? void 0 : _h.duration) == null ? void 0 : _i.value) || 10,
1324
1331
  "minutes"
1325
1332
  );
1326
1333
  recordTimeSlots = {
@@ -1374,7 +1381,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1374
1381
  const allCartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
1375
1382
  let selectedResources = [];
1376
1383
  const resources2 = (0, import_lodash_es.cloneDeep)(
1377
- ((_m = (_l = item._productOrigin) == null ? void 0 : _l.product_resource) == null ? void 0 : _m.resources) || []
1384
+ ((_k = (_j = item._productOrigin) == null ? void 0 : _j.product_resource) == null ? void 0 : _k.resources) || []
1378
1385
  );
1379
1386
  const currentResourcesRenderList = [];
1380
1387
  resources2.forEach((n) => {
@@ -1422,11 +1429,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1422
1429
  return recordCount >= currentCapacity;
1423
1430
  });
1424
1431
  });
1425
- const targetRenderList = (_n = productResources.find(
1432
+ const targetRenderList = (_l = productResources.find(
1426
1433
  (n) => n.code === resources_code
1427
- )) == null ? void 0 : _n.renderList;
1434
+ )) == null ? void 0 : _l.renderList;
1428
1435
  if (targetRenderList && targetRenderList.length > 0) {
1429
- if ((_o = item._origin.resources) == null ? void 0 : _o.some(
1436
+ if ((_m = item._origin.resources) == null ? void 0 : _m.some(
1430
1437
  (n) => n.form_id === targetRenderList[0].form_id
1431
1438
  )) {
1432
1439
  return;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.130",
4
+ "version": "0.0.132",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",