@pisell/pisellos 0.0.210 → 0.0.211

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.
@@ -258,7 +258,8 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
258
258
  resources = params.resources,
259
259
  note = params.note,
260
260
  date = params.date,
261
- relationForms = params.relationForms;
261
+ relationForms = params.relationForms,
262
+ osWarnTips = params.osWarnTips;
262
263
  var quantity = params.quantity;
263
264
  var tempCartItem = this.store.list.find(function (i) {
264
265
  return i._id === _id;
@@ -324,6 +325,9 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
324
325
  note: note
325
326
  });
326
327
  }
328
+ if (osWarnTips) {
329
+ tempCartItem.osWarnTips = osWarnTips;
330
+ }
327
331
  return tempCartItem;
328
332
  }
329
333
 
@@ -110,6 +110,8 @@ export interface CartItem {
110
110
  bundle?: any[];
111
111
  /** 商品规格信息 */
112
112
  options?: any[];
113
+ /** 商品规格选项字符串 */
114
+ product_option_string?: string;
113
115
  /** 是否为普通商品 */
114
116
  isNormalProduct?: boolean;
115
117
  /** 资源ID */
@@ -142,8 +144,8 @@ export interface CartItem {
142
144
  _bundleOrigin?: any[];
143
145
  /** 商品规格原始数据 */
144
146
  _optionsOrigin?: any[];
145
- /** 商品规格组合字符串,提供给 UI 展示的 */
146
- product_option_string?: string;
147
+ /** 操作系统提示 */
148
+ osWarnTips?: string[];
147
149
  }
148
150
  /**
149
151
  * 购物车状态接口
@@ -217,6 +219,8 @@ export interface IUpdateItemParams {
217
219
  }[];
218
220
  /** 商品组合规格ID */
219
221
  product_variant_id?: number;
222
+ /** 操作系统提示 */
223
+ osWarnTips?: string[];
220
224
  }
221
225
  /**
222
226
  * 折扣
@@ -105,6 +105,11 @@ export interface ProductData {
105
105
  type: string;
106
106
  /** 值 */
107
107
  value: number;
108
+ flexible_config?: {
109
+ is_enable_minimum_duration?: 0 | 1;
110
+ warning_threshold?: number;
111
+ block_threshold?: number;
112
+ };
108
113
  };
109
114
  /** 商品显示设置 */
110
115
  product_display_setting: {
@@ -1528,25 +1528,27 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1528
1528
  });
1529
1529
  });
1530
1530
  } else {
1531
- var _cartItem$_productOri3, _this10$shopStore$get;
1531
+ var _cartItem$_productOri3, _this10$shopStore$get, _cartItem$_productOri4, _cartItem$_productOri5;
1532
1532
  var hasFlexibleDuration = ((_cartItem$_productOri3 = cartItem._productOrigin) === null || _cartItem$_productOri3 === void 0 || (_cartItem$_productOri3 = _cartItem$_productOri3.duration) === null || _cartItem$_productOri3 === void 0 ? void 0 : _cartItem$_productOri3.type) === 'flexible';
1533
1533
  var operating_day_boundary = (_this10$shopStore$get = _this10.shopStore.get('core')) === null || _this10$shopStore$get === void 0 || (_this10$shopStore$get = _this10$shopStore$get.core) === null || _this10$shopStore$get === void 0 ? void 0 : _this10$shopStore$get.operating_day_boundary;
1534
+ var maxBlockThreshold = (_cartItem$_productOri4 = cartItem._productOrigin) !== null && _cartItem$_productOri4 !== void 0 && (_cartItem$_productOri4 = _cartItem$_productOri4.duration) !== null && _cartItem$_productOri4 !== void 0 && (_cartItem$_productOri4 = _cartItem$_productOri4.flexible_config) !== null && _cartItem$_productOri4 !== void 0 && _cartItem$_productOri4.is_enable_minimum_duration ? ((_cartItem$_productOri5 = cartItem._productOrigin) === null || _cartItem$_productOri5 === void 0 || (_cartItem$_productOri5 = _cartItem$_productOri5.duration) === null || _cartItem$_productOri5 === void 0 || (_cartItem$_productOri5 = _cartItem$_productOri5.flexible_config) === null || _cartItem$_productOri5 === void 0 ? void 0 : _cartItem$_productOri5.block_threshold) || 0 : 0;
1534
1535
  productResources.forEach(function (item) {
1535
1536
  // 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
1536
1537
  // 同时,在这一步尝试去拉一下时间片,基于商品的时长,看每个资源是否还有空余时间能对这个商品做服务,如果没有则过滤
1537
1538
  item.renderList = item.renderList.filter(function (n) {
1538
- var _cartItem$_productOri4, _cartItem$_productOri5;
1539
+ var _cartItem$_productOri6, _cartItem$_productOri7;
1539
1540
  var recordCount = n.capacity || 0;
1540
1541
  if (n.onlyComputed) return false;
1541
1542
  // 查一下这个资源基于商品的可用时间片
1542
1543
  var timeSlots = getTimeSlicesByResource({
1543
1544
  resource: n,
1544
- duration: ((_cartItem$_productOri4 = cartItem._productOrigin) === null || _cartItem$_productOri4 === void 0 || (_cartItem$_productOri4 = _cartItem$_productOri4.duration) === null || _cartItem$_productOri4 === void 0 ? void 0 : _cartItem$_productOri4.value) || 10,
1545
+ 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) || 10,
1545
1546
  split: 10,
1546
1547
  currentDate: dateRange[0].date,
1547
1548
  hasFlexibleDuration: hasFlexibleDuration,
1548
- cut_off_time: (_cartItem$_productOri5 = cartItem._productOrigin) === null || _cartItem$_productOri5 === void 0 ? void 0 : _cartItem$_productOri5.cut_off_time,
1549
- operating_day_boundary: operating_day_boundary
1549
+ cut_off_time: (_cartItem$_productOri7 = cartItem._productOrigin) === null || _cartItem$_productOri7 === void 0 ? void 0 : _cartItem$_productOri7.cut_off_time,
1550
+ operating_day_boundary: operating_day_boundary,
1551
+ maxBlockThreshold: maxBlockThreshold
1550
1552
  });
1551
1553
  return recordCount >= currentCapacity && timeSlots.length > 0;
1552
1554
  });
@@ -1647,7 +1649,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1647
1649
  }, {
1648
1650
  key: "autoSelectAccountResources",
1649
1651
  value: function autoSelectAccountResources(_ref9) {
1650
- var _cartItem$_productOri6, _allProductResources$;
1652
+ var _cartItem$_productOri8, _allProductResources$;
1651
1653
  var cartItem = _ref9.cartItem,
1652
1654
  holder_id = _ref9.holder_id,
1653
1655
  resources_code = _ref9.resources_code,
@@ -1696,7 +1698,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1696
1698
  var resourcesMap = getResourcesMap(cloneDeep(AllResources));
1697
1699
  var allCartItems = cloneDeep(this.store.cart.getItems());
1698
1700
  var selectedResources = getOthersSelectedResources(allCartItems, holder_id, resourcesMap);
1699
- var allProductResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri6 = cartItem._productOrigin) === null || _cartItem$_productOri6 === void 0 || (_cartItem$_productOri6 = _cartItem$_productOri6.product_resource) === null || _cartItem$_productOri6 === void 0 ? void 0 : _cartItem$_productOri6.resources) || [], selectedResources, 1);
1701
+ var allProductResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri8 = cartItem._productOrigin) === null || _cartItem$_productOri8 === void 0 || (_cartItem$_productOri8 = _cartItem$_productOri8.product_resource) === null || _cartItem$_productOri8 === void 0 ? void 0 : _cartItem$_productOri8.resources) || [], selectedResources, 1);
1700
1702
  var resources = ((_allProductResources$ = allProductResources.find(function (n) {
1701
1703
  return n.code === resources_code;
1702
1704
  })) === null || _allProductResources$ === void 0 ? void 0 : _allProductResources$.renderList) || [];
@@ -1757,14 +1759,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1757
1759
  return 0; // continue
1758
1760
  }
1759
1761
  var canUseTime = mTimes.find(function (item) {
1760
- var _cartItem$_productOri7;
1762
+ var _cartItem$_productOri9;
1761
1763
  var res = getIsUsableByTimeItem({
1762
1764
  timeSlice: timeSlots,
1763
1765
  time: item,
1764
1766
  resource: n,
1765
1767
  currentCount: totalCapacity + (capacity || 0),
1766
1768
  resourcesUseableMap: resourcesUseableMap,
1767
- cut_off_time: (_cartItem$_productOri7 = cartItem._productOrigin) === null || _cartItem$_productOri7 === void 0 ? void 0 : _cartItem$_productOri7.cut_off_time
1769
+ cut_off_time: (_cartItem$_productOri9 = cartItem._productOrigin) === null || _cartItem$_productOri9 === void 0 ? void 0 : _cartItem$_productOri9.cut_off_time
1768
1770
  });
1769
1771
  // 如果只是因为子资源容量不够,而不是子资源被预约导致没时间片,不应该标记子资源为不可用,从而影响组合资源的情况
1770
1772
  if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[n.id]) !== false && res.reason !== 'capacityOnly') {
@@ -2132,6 +2134,20 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2132
2134
  return ((_item$_productOrigin14 = item._productOrigin) === null || _item$_productOrigin14 === void 0 || (_item$_productOrigin14 = _item$_productOrigin14.duration) === null || _item$_productOrigin14 === void 0 ? void 0 : _item$_productOrigin14.type) === 'flexible';
2133
2135
  });
2134
2136
  var operating_day_boundary = (_this$shopStore$get = this.shopStore.get('core')) === null || _this$shopStore$get === void 0 || (_this$shopStore$get = _this$shopStore$get.core) === null || _this$shopStore$get === void 0 ? void 0 : _this$shopStore$get.operating_day_boundary;
2137
+
2138
+ // 如果有 hasFlexibleDuration,需要把动态时长商品(可能是多个,取最长的那个最低禁止购买时长)的最低禁止购买时长作为 split 的值
2139
+ var maxBlockThreshold = 0;
2140
+ if (hasFlexibleDuration) {
2141
+ maxBlockThreshold = cartItems.reduce(function (max, item) {
2142
+ var _item$_productOrigin15;
2143
+ // 如果开启了灵活时长商品配置,则取 block_threshold 的值
2144
+ if ((_item$_productOrigin15 = item._productOrigin) !== null && _item$_productOrigin15 !== void 0 && (_item$_productOrigin15 = _item$_productOrigin15.duration) !== null && _item$_productOrigin15 !== void 0 && (_item$_productOrigin15 = _item$_productOrigin15.flexible_config) !== null && _item$_productOrigin15 !== void 0 && _item$_productOrigin15.is_enable_minimum_duration) {
2145
+ var _item$_productOrigin16;
2146
+ return Math.max(max, ((_item$_productOrigin16 = item._productOrigin) === null || _item$_productOrigin16 === void 0 || (_item$_productOrigin16 = _item$_productOrigin16.duration) === null || _item$_productOrigin16 === void 0 || (_item$_productOrigin16 = _item$_productOrigin16.flexible_config) === null || _item$_productOrigin16 === void 0 ? void 0 : _item$_productOrigin16.block_threshold) || 0);
2147
+ }
2148
+ return 0;
2149
+ }, 0);
2150
+ }
2135
2151
  var timeSlots = getTimeSlicesByResources({
2136
2152
  resourceIds: resourceIds,
2137
2153
  resourcesMap: resourcesMap,
@@ -2141,7 +2157,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2141
2157
  resourcesUseableMap: resourcesUseableMap,
2142
2158
  cut_off_time: maxCutOffTime,
2143
2159
  hasFlexibleDuration: hasFlexibleDuration,
2144
- operating_day_boundary: operating_day_boundary
2160
+ operating_day_boundary: operating_day_boundary,
2161
+ maxBlockThreshold: maxBlockThreshold
2145
2162
  });
2146
2163
  return timeSlots;
2147
2164
  }
@@ -2178,12 +2195,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2178
2195
  var currentStartTime = timeSlots.start_at.format('YYYY-MM-DD HH:mm');
2179
2196
  accountItems.forEach(function (item, index) {
2180
2197
  var _newResources$;
2198
+ var osWarnTips = [];
2181
2199
  var newResources = cloneDeep(item._origin.resources);
2182
2200
  newResources.forEach(function (resource) {
2183
- var _item$_productOrigin15;
2201
+ var _item$_productOrigin17;
2184
2202
  // 如果商品配置的是灵活时长,开始时间设置为提交的时间,结束时间从资源的可用最晚时间和店铺营业结束时间里取一个最早的
2185
- if (((_item$_productOrigin15 = item._productOrigin) === null || _item$_productOrigin15 === void 0 || (_item$_productOrigin15 = _item$_productOrigin15.duration) === null || _item$_productOrigin15 === void 0 ? void 0 : _item$_productOrigin15.type) === 'flexible') {
2186
- var _allResources$find;
2203
+ if (((_item$_productOrigin17 = item._productOrigin) === null || _item$_productOrigin17 === void 0 || (_item$_productOrigin17 = _item$_productOrigin17.duration) === null || _item$_productOrigin17 === void 0 ? void 0 : _item$_productOrigin17.type) === 'flexible') {
2204
+ var _allResources$find, _item$_productOrigin18;
2187
2205
  item.duration = {
2188
2206
  type: 'minutes',
2189
2207
  value: 10
@@ -2211,16 +2229,24 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2211
2229
  formattedEndTime = dayjs(endTime);
2212
2230
  }
2213
2231
  resource.endTime = formattedEndTime.format('YYYY-MM-DD HH:mm');
2232
+ // 如果是动态时长商品,并且当前选择的时间的结束时间小于了最低提示时长(warningThreshold),则追加一个提示
2233
+ // 如果currentStartTime + warningThreshold 大于 currentEndTime,且 osWarnTips 没有pisell2.product.card.closing-soon.warning 这一项,则加入这一项
2234
+ if (dayjs(currentStartTime).add(((_item$_productOrigin18 = item._productOrigin) === null || _item$_productOrigin18 === void 0 || (_item$_productOrigin18 = _item$_productOrigin18.duration) === null || _item$_productOrigin18 === void 0 || (_item$_productOrigin18 = _item$_productOrigin18.flexible_config) === null || _item$_productOrigin18 === void 0 ? void 0 : _item$_productOrigin18.warning_threshold) || 0, 'minutes').isAfter(dayjs(formattedEndTime))) {
2235
+ if (!osWarnTips.includes('pisell2.product.card.closing-soon.warning')) {
2236
+ osWarnTips.push('pisell2.product.card.closing-soon.warning');
2237
+ }
2238
+ }
2214
2239
  } else {
2215
- var _item$_productOrigin16;
2240
+ var _item$_productOrigin19;
2216
2241
  resource.startTime = currentStartTime;
2217
- resource.endTime = dayjs(currentStartTime).add(((_item$_productOrigin16 = item._productOrigin) === null || _item$_productOrigin16 === void 0 || (_item$_productOrigin16 = _item$_productOrigin16.duration) === null || _item$_productOrigin16 === void 0 ? void 0 : _item$_productOrigin16.value) || 10, 'minutes').format('YYYY-MM-DD HH:mm');
2242
+ resource.endTime = dayjs(currentStartTime).add(((_item$_productOrigin19 = item._productOrigin) === null || _item$_productOrigin19 === void 0 || (_item$_productOrigin19 = _item$_productOrigin19.duration) === null || _item$_productOrigin19 === void 0 ? void 0 : _item$_productOrigin19.value) || 10, 'minutes').format('YYYY-MM-DD HH:mm');
2218
2243
  }
2219
2244
  // delete resource.times;
2220
2245
  });
2221
2246
  _this13.store.cart.updateItem({
2222
2247
  _id: item._id,
2223
- resources: newResources
2248
+ resources: newResources,
2249
+ osWarnTips: osWarnTips
2224
2250
  });
2225
2251
 
2226
2252
  // 更新下一个商品的开始时间为当前商品的结束时间
@@ -2514,7 +2540,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2514
2540
  }, {
2515
2541
  key: "getResourcesByCartItemAndCode",
2516
2542
  value: function getResourcesByCartItemAndCode(cartItemId, resourceCode) {
2517
- var _cartItem$_productOri8;
2543
+ var _cartItem$_productOri10;
2518
2544
  var dateRange = this.store.date.getDateRange();
2519
2545
  var resources = [];
2520
2546
  if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
@@ -2546,7 +2572,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2546
2572
  } else {
2547
2573
  selectedResources = getOthersCartSelectedResources(cartItems, cartItem._id, resourcesMap);
2548
2574
  }
2549
- var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri8 = cartItem._productOrigin) === null || _cartItem$_productOri8 === void 0 || (_cartItem$_productOri8 = _cartItem$_productOri8.product_resource) === null || _cartItem$_productOri8 === void 0 ? void 0 : _cartItem$_productOri8.resources) || [], selectedResources, currentCapacity);
2575
+ var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri10 = cartItem._productOrigin) === null || _cartItem$_productOri10 === void 0 || (_cartItem$_productOri10 = _cartItem$_productOri10.product_resource) === null || _cartItem$_productOri10 === void 0 ? void 0 : _cartItem$_productOri10.resources) || [], selectedResources, currentCapacity);
2550
2576
  var targetResource = productResources.find(function (resource) {
2551
2577
  return resource.code === resourceCode;
2552
2578
  });
@@ -2569,7 +2595,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2569
2595
  });
2570
2596
  if (mTimes.length === 0) return false;
2571
2597
  var canUseArr = mTimes.map(function (item) {
2572
- var _cartItem$_productOri9;
2598
+ var _cartItem$_productOri11;
2573
2599
  var res = getIsUsableByTimeItem({
2574
2600
  timeSlice: {
2575
2601
  start_time: startTime.format('HH:mm'),
@@ -2581,7 +2607,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2581
2607
  resource: m,
2582
2608
  currentCount: currentCapacity || 0,
2583
2609
  resourcesUseableMap: resourcesUseableMap,
2584
- cut_off_time: (_cartItem$_productOri9 = cartItem._productOrigin) === null || _cartItem$_productOri9 === void 0 ? void 0 : _cartItem$_productOri9.cut_off_time
2610
+ cut_off_time: (_cartItem$_productOri11 = cartItem._productOrigin) === null || _cartItem$_productOri11 === void 0 ? void 0 : _cartItem$_productOri11.cut_off_time
2585
2611
  });
2586
2612
  if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
2587
2613
  resourcesUseableMap[m.id] = res.usable;
@@ -2595,12 +2621,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2595
2621
  });
2596
2622
  } else {
2597
2623
  targetResource.renderList = targetResource.renderList.filter(function (n) {
2598
- var _cartItem$_productOri10;
2624
+ var _cartItem$_productOri12;
2599
2625
  var recordCount = n.capacity || 0;
2600
2626
  if (n.onlyComputed) return false;
2601
2627
  var timeSlots = getTimeSlicesByResource({
2602
2628
  resource: n,
2603
- duration: ((_cartItem$_productOri10 = cartItem._productOrigin) === null || _cartItem$_productOri10 === void 0 || (_cartItem$_productOri10 = _cartItem$_productOri10.duration) === null || _cartItem$_productOri10 === void 0 ? void 0 : _cartItem$_productOri10.value) || 10,
2629
+ duration: ((_cartItem$_productOri12 = cartItem._productOrigin) === null || _cartItem$_productOri12 === void 0 || (_cartItem$_productOri12 = _cartItem$_productOri12.duration) === null || _cartItem$_productOri12 === void 0 ? void 0 : _cartItem$_productOri12.value) || 10,
2604
2630
  split: 10,
2605
2631
  currentDate: dateRange[0].date
2606
2632
  });
@@ -79,7 +79,7 @@ export declare const formatResources: ({ booking, resources, }: {
79
79
  * @return {*}
80
80
  * @Author: zhiwei.Wang
81
81
  */
82
- export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary, }: {
82
+ export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary, maxBlockThreshold }: {
83
83
  resource: ResourceItem;
84
84
  duration: number;
85
85
  split: number;
@@ -101,6 +101,7 @@ export declare const getTimeSlicesByResource: ({ resource, duration, split, curr
101
101
  type: string;
102
102
  time: string;
103
103
  } | undefined;
104
+ maxBlockThreshold?: number | undefined;
104
105
  }) => TimeSliceItem[];
105
106
  /**
106
107
  * @title: 获取时间切片列表的交集
@@ -138,7 +139,7 @@ export declare const mergeSubResourcesTimeSlices: (resources: ResourceItem[], re
138
139
  * @return {*}
139
140
  * @Author: zhiwei.Wang
140
141
  */
141
- export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary, }: {
142
+ export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary, maxBlockThreshold }: {
142
143
  resourceIds: number[];
143
144
  resourcesMap: any;
144
145
  duration: number;
@@ -161,6 +162,7 @@ export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, dur
161
162
  type: string;
162
163
  time: string;
163
164
  } | undefined;
165
+ maxBlockThreshold?: number | undefined;
164
166
  }) => any[];
165
167
  /**
166
168
  * @title: 获取其他人的已选资源
@@ -425,7 +425,8 @@ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref5) {
425
425
  resourcesUseableMap = _ref5$resourcesUseabl === void 0 ? {} : _ref5$resourcesUseabl,
426
426
  cut_off_time = _ref5.cut_off_time,
427
427
  hasFlexibleDuration = _ref5.hasFlexibleDuration,
428
- operating_day_boundary = _ref5.operating_day_boundary;
428
+ operating_day_boundary = _ref5.operating_day_boundary,
429
+ maxBlockThreshold = _ref5.maxBlockThreshold;
429
430
  var times = resource.times;
430
431
 
431
432
  // 存储所有时间切片
@@ -475,6 +476,13 @@ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref5) {
475
476
  if (hasFlexibleDuration && operating_day_boundary && timeSlice.start_time >= (operatingBoundaryDateTime || '23:59')) {
476
477
  break;
477
478
  }
479
+ // 如果有配置了最低禁止购买时长,则需要判断时间切片是否在最低禁止购买时长内
480
+ // 看一下endTime和operatingBoundaryDateTime哪个早,哪个早用哪个去比较
481
+ var operatingBoundaryDateTimeObj = dayjs("".concat(endTime.format('YYYY-MM-DD'), " ").concat(operatingBoundaryDateTime));
482
+ var earlyTime = endTime.isBefore(operatingBoundaryDateTimeObj) ? endTime : operatingBoundaryDateTimeObj;
483
+ if (hasFlexibleDuration && operating_day_boundary && maxBlockThreshold && timeSlice.start_at.add(maxBlockThreshold || 0, 'minutes').isAfter(earlyTime)) {
484
+ break;
485
+ }
478
486
  // 添加时间切片 09:00 ~ 10:00 09:20 ~ 10:20 09:00 ~ 10:00 09:20 ~ 10:20 11:00 ~ 12:00 11:20 ~ 12:20
479
487
  timeSlices.push(_objectSpread(_objectSpread({}, timeSlice), {}, {
480
488
  // 这里需要补充这个时间段内是否可预约
@@ -582,7 +590,8 @@ export var getTimeSlicesByResources = function getTimeSlicesByResources(_ref6) {
582
590
  resourcesUseableMap = _ref6.resourcesUseableMap,
583
591
  cut_off_time = _ref6.cut_off_time,
584
592
  hasFlexibleDuration = _ref6.hasFlexibleDuration,
585
- operating_day_boundary = _ref6.operating_day_boundary;
593
+ operating_day_boundary = _ref6.operating_day_boundary,
594
+ maxBlockThreshold = _ref6.maxBlockThreshold;
586
595
  // 获取资源列表
587
596
  var resources = getResourcesByIds(resourcesMap, resourceIds);
588
597
  mergeSubResourcesTimeSlices(resources, resourcesMap);
@@ -607,7 +616,8 @@ export var getTimeSlicesByResources = function getTimeSlicesByResources(_ref6) {
607
616
  resourcesUseableMap: resourcesUseableMap,
608
617
  cut_off_time: cut_off_time,
609
618
  hasFlexibleDuration: hasFlexibleDuration,
610
- operating_day_boundary: operating_day_boundary
619
+ operating_day_boundary: operating_day_boundary,
620
+ maxBlockThreshold: maxBlockThreshold
611
621
  }));
612
622
  }, []);
613
623
 
@@ -144,7 +144,8 @@ var CartModule = class extends import_BaseModule.BaseModule {
144
144
  resources,
145
145
  note,
146
146
  date,
147
- relationForms
147
+ relationForms,
148
+ osWarnTips
148
149
  } = params;
149
150
  let quantity = params.quantity;
150
151
  let tempCartItem = this.store.list.find((i) => i._id === _id);
@@ -202,6 +203,9 @@ var CartModule = class extends import_BaseModule.BaseModule {
202
203
  if (note) {
203
204
  tempCartItem = (0, import_utils.formatNoteToCartItem)({ cartItem: tempCartItem, note });
204
205
  }
206
+ if (osWarnTips) {
207
+ tempCartItem.osWarnTips = osWarnTips;
208
+ }
205
209
  return tempCartItem;
206
210
  }
207
211
  /**
@@ -110,6 +110,8 @@ export interface CartItem {
110
110
  bundle?: any[];
111
111
  /** 商品规格信息 */
112
112
  options?: any[];
113
+ /** 商品规格选项字符串 */
114
+ product_option_string?: string;
113
115
  /** 是否为普通商品 */
114
116
  isNormalProduct?: boolean;
115
117
  /** 资源ID */
@@ -142,8 +144,8 @@ export interface CartItem {
142
144
  _bundleOrigin?: any[];
143
145
  /** 商品规格原始数据 */
144
146
  _optionsOrigin?: any[];
145
- /** 商品规格组合字符串,提供给 UI 展示的 */
146
- product_option_string?: string;
147
+ /** 操作系统提示 */
148
+ osWarnTips?: string[];
147
149
  }
148
150
  /**
149
151
  * 购物车状态接口
@@ -217,6 +219,8 @@ export interface IUpdateItemParams {
217
219
  }[];
218
220
  /** 商品组合规格ID */
219
221
  product_variant_id?: number;
222
+ /** 操作系统提示 */
223
+ osWarnTips?: string[];
220
224
  }
221
225
  /**
222
226
  * 折扣
@@ -105,6 +105,11 @@ export interface ProductData {
105
105
  type: string;
106
106
  /** 值 */
107
107
  value: number;
108
+ flexible_config?: {
109
+ is_enable_minimum_duration?: 0 | 1;
110
+ warning_threshold?: number;
111
+ block_threshold?: number;
112
+ };
108
113
  };
109
114
  /** 商品显示设置 */
110
115
  product_display_setting: {
@@ -854,7 +854,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
854
854
  const resourcesMap = (0, import_utils.getResourcesMap)((0, import_lodash_es.cloneDeep)(resources));
855
855
  const arr = [];
856
856
  cartItems.forEach((cartItem) => {
857
- var _a, _b, _c, _d, _e, _f;
857
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
858
858
  let selectedResources = [];
859
859
  const { currentCapacity, formatCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(cartItem);
860
860
  cartItem._origin.metadata.capacity = formatCapacity;
@@ -924,6 +924,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
924
924
  } else {
925
925
  const hasFlexibleDuration = ((_d = (_c = cartItem._productOrigin) == null ? void 0 : _c.duration) == null ? void 0 : _d.type) === "flexible";
926
926
  const operating_day_boundary = (_f = (_e = this.shopStore.get("core")) == null ? void 0 : _e.core) == null ? void 0 : _f.operating_day_boundary;
927
+ const maxBlockThreshold = ((_i = (_h = (_g = cartItem._productOrigin) == null ? void 0 : _g.duration) == null ? void 0 : _h.flexible_config) == null ? void 0 : _i.is_enable_minimum_duration) ? ((_l = (_k = (_j = cartItem._productOrigin) == null ? void 0 : _j.duration) == null ? void 0 : _k.flexible_config) == null ? void 0 : _l.block_threshold) || 0 : 0;
927
928
  productResources.forEach((item) => {
928
929
  item.renderList = item.renderList.filter((n) => {
929
930
  var _a2, _b2, _c2;
@@ -937,7 +938,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
937
938
  currentDate: dateRange[0].date,
938
939
  hasFlexibleDuration,
939
940
  cut_off_time: (_c2 = cartItem._productOrigin) == null ? void 0 : _c2.cut_off_time,
940
- operating_day_boundary
941
+ operating_day_boundary,
942
+ maxBlockThreshold
941
943
  });
942
944
  return recordCount >= currentCapacity && timeSlots.length > 0;
943
945
  });
@@ -1468,7 +1470,17 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1468
1470
  return ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.type) === "flexible";
1469
1471
  }
1470
1472
  );
1471
- const operating_day_boundary = (_h = (_g = this.shopStore.get("core")) == null ? void 0 : _g.core) == null ? void 0 : _h.operating_day_boundary;
1473
+ let operating_day_boundary = (_h = (_g = this.shopStore.get("core")) == null ? void 0 : _g.core) == null ? void 0 : _h.operating_day_boundary;
1474
+ let maxBlockThreshold = 0;
1475
+ if (hasFlexibleDuration) {
1476
+ maxBlockThreshold = cartItems.reduce((max, item) => {
1477
+ var _a2, _b2, _c2, _d2, _e2, _f2;
1478
+ if ((_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.flexible_config) == null ? void 0 : _c2.is_enable_minimum_duration) {
1479
+ return Math.max(max, ((_f2 = (_e2 = (_d2 = item._productOrigin) == null ? void 0 : _d2.duration) == null ? void 0 : _e2.flexible_config) == null ? void 0 : _f2.block_threshold) || 0);
1480
+ }
1481
+ return 0;
1482
+ }, 0);
1483
+ }
1472
1484
  const timeSlots = (0, import_resources.getTimeSlicesByResources)({
1473
1485
  resourceIds,
1474
1486
  resourcesMap,
@@ -1478,7 +1490,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1478
1490
  resourcesUseableMap,
1479
1491
  cut_off_time: maxCutOffTime,
1480
1492
  hasFlexibleDuration,
1481
- operating_day_boundary
1493
+ operating_day_boundary,
1494
+ maxBlockThreshold
1482
1495
  });
1483
1496
  return timeSlots;
1484
1497
  }
@@ -1505,9 +1518,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1505
1518
  let currentStartTime = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
1506
1519
  accountItems.forEach((item, index) => {
1507
1520
  var _a2;
1521
+ const osWarnTips = [];
1508
1522
  const newResources = (0, import_lodash_es.cloneDeep)(item._origin.resources);
1509
1523
  newResources.forEach((resource) => {
1510
- var _a3, _b2, _c, _d, _e;
1524
+ var _a3, _b2, _c, _d, _e, _f, _g, _h;
1511
1525
  if (((_b2 = (_a3 = item._productOrigin) == null ? void 0 : _a3.duration) == null ? void 0 : _b2.type) === "flexible") {
1512
1526
  item.duration = {
1513
1527
  type: "minutes",
@@ -1538,14 +1552,20 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1538
1552
  formattedEndTime = (0, import_dayjs.default)(endTime);
1539
1553
  }
1540
1554
  resource.endTime = formattedEndTime.format("YYYY-MM-DD HH:mm");
1555
+ if ((0, import_dayjs.default)(currentStartTime).add(((_f = (_e = (_d = item._productOrigin) == null ? void 0 : _d.duration) == null ? void 0 : _e.flexible_config) == null ? void 0 : _f.warning_threshold) || 0, "minutes").isAfter((0, import_dayjs.default)(formattedEndTime))) {
1556
+ if (!osWarnTips.includes("pisell2.product.card.closing-soon.warning")) {
1557
+ osWarnTips.push("pisell2.product.card.closing-soon.warning");
1558
+ }
1559
+ }
1541
1560
  } else {
1542
1561
  resource.startTime = currentStartTime;
1543
- resource.endTime = (0, import_dayjs.default)(currentStartTime).add(((_e = (_d = item._productOrigin) == null ? void 0 : _d.duration) == null ? void 0 : _e.value) || 10, "minutes").format("YYYY-MM-DD HH:mm");
1562
+ resource.endTime = (0, import_dayjs.default)(currentStartTime).add(((_h = (_g = item._productOrigin) == null ? void 0 : _g.duration) == null ? void 0 : _h.value) || 10, "minutes").format("YYYY-MM-DD HH:mm");
1544
1563
  }
1545
1564
  });
1546
1565
  this.store.cart.updateItem({
1547
1566
  _id: item._id,
1548
- resources: newResources
1567
+ resources: newResources,
1568
+ osWarnTips
1549
1569
  });
1550
1570
  if (index < accountItems.length - 1 && ((_a2 = newResources == null ? void 0 : newResources[0]) == null ? void 0 : _a2.resourceType) === "single") {
1551
1571
  currentStartTime = newResources[0].endTime;
@@ -79,7 +79,7 @@ export declare const formatResources: ({ booking, resources, }: {
79
79
  * @return {*}
80
80
  * @Author: zhiwei.Wang
81
81
  */
82
- export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary, }: {
82
+ export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary, maxBlockThreshold }: {
83
83
  resource: ResourceItem;
84
84
  duration: number;
85
85
  split: number;
@@ -101,6 +101,7 @@ export declare const getTimeSlicesByResource: ({ resource, duration, split, curr
101
101
  type: string;
102
102
  time: string;
103
103
  } | undefined;
104
+ maxBlockThreshold?: number | undefined;
104
105
  }) => TimeSliceItem[];
105
106
  /**
106
107
  * @title: 获取时间切片列表的交集
@@ -138,7 +139,7 @@ export declare const mergeSubResourcesTimeSlices: (resources: ResourceItem[], re
138
139
  * @return {*}
139
140
  * @Author: zhiwei.Wang
140
141
  */
141
- export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary, }: {
142
+ export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split, capacity, resourcesUseableMap, cut_off_time, hasFlexibleDuration, operating_day_boundary, maxBlockThreshold }: {
142
143
  resourceIds: number[];
143
144
  resourcesMap: any;
144
145
  duration: number;
@@ -161,6 +162,7 @@ export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, dur
161
162
  type: string;
162
163
  time: string;
163
164
  } | undefined;
165
+ maxBlockThreshold?: number | undefined;
164
166
  }) => any[];
165
167
  /**
166
168
  * @title: 获取其他人的已选资源
@@ -342,7 +342,8 @@ var getTimeSlicesByResource = ({
342
342
  resourcesUseableMap = {},
343
343
  cut_off_time,
344
344
  hasFlexibleDuration,
345
- operating_day_boundary
345
+ operating_day_boundary,
346
+ maxBlockThreshold
346
347
  }) => {
347
348
  const { times } = resource;
348
349
  const timeSlices = [];
@@ -377,6 +378,11 @@ var getTimeSlicesByResource = ({
377
378
  if (hasFlexibleDuration && operating_day_boundary && timeSlice.start_time >= (operatingBoundaryDateTime || "23:59")) {
378
379
  break;
379
380
  }
381
+ const operatingBoundaryDateTimeObj = (0, import_dayjs.default)(`${endTime.format("YYYY-MM-DD")} ${operatingBoundaryDateTime}`);
382
+ const earlyTime = endTime.isBefore(operatingBoundaryDateTimeObj) ? endTime : operatingBoundaryDateTimeObj;
383
+ if (hasFlexibleDuration && operating_day_boundary && maxBlockThreshold && timeSlice.start_at.add(maxBlockThreshold || 0, "minutes").isAfter(earlyTime)) {
384
+ break;
385
+ }
380
386
  timeSlices.push({
381
387
  ...timeSlice,
382
388
  // 这里需要补充这个时间段内是否可预约
@@ -436,7 +442,8 @@ var getTimeSlicesByResources = ({
436
442
  resourcesUseableMap,
437
443
  cut_off_time,
438
444
  hasFlexibleDuration,
439
- operating_day_boundary
445
+ operating_day_boundary,
446
+ maxBlockThreshold
440
447
  }) => {
441
448
  let resources = getResourcesByIds(resourcesMap, resourceIds);
442
449
  mergeSubResourcesTimeSlices(resources, resourcesMap);
@@ -462,7 +469,8 @@ var getTimeSlicesByResources = ({
462
469
  resourcesUseableMap,
463
470
  cut_off_time,
464
471
  hasFlexibleDuration,
465
- operating_day_boundary
472
+ operating_day_boundary,
473
+ maxBlockThreshold
466
474
  })
467
475
  );
468
476
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.210",
4
+ "version": "0.0.211",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",