@pisell/pisellos 0.0.132 → 0.0.135

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.
@@ -206,7 +206,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
206
206
  }
207
207
  if (discount.appliedProductDetails) {
208
208
  return discount.appliedProductDetails.reduce(function (total, product) {
209
- var price = new Decimal((product === null || product === void 0 ? void 0 : product.amount) || 0);
209
+ var price = new Decimal((product === null || product === void 0 ? void 0 : product.amount) || 0).mul((product === null || product === void 0 ? void 0 : product.num) || 1);
210
210
  return new Decimal(total).plus(price).toNumber();
211
211
  }, 0);
212
212
  }
@@ -27,6 +27,7 @@ interface ApplicableProductDetails {
27
27
  resource_id: number;
28
28
  title: string;
29
29
  original_amount: string;
30
+ num: number;
30
31
  }
31
32
  export interface Discount {
32
33
  id: number;
@@ -242,7 +242,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
242
242
 
243
243
  // 编辑的商品 使用了优惠券不可用
244
244
  var isAvailableProduct = !(product !== null && product !== void 0 && product.booking_id && product !== null && product !== void 0 && (_product$discount_lis = product.discount_list) !== null && _product$discount_lis !== void 0 && _product$discount_lis.length && product !== null && product !== void 0 && (_product$discount_lis2 = product.discount_list) !== null && _product$discount_lis2 !== void 0 && _product$discount_lis2.every(function (discount) {
245
- return discount.id && discount.type === 'good_pass';
245
+ return discount.id && ['good_pass', 'discount_card', 'product_discount_card'].includes(discount.type);
246
246
  }));
247
247
 
248
248
  // 判断优惠券是否适用于该商品
@@ -261,7 +261,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
261
261
  title: discount.format_title,
262
262
  original_amount: product.origin_total,
263
263
  pre_value: discount.par_value
264
- }
264
+ },
265
+ num: product.num || 1
265
266
  });
266
267
  discountApplicableProducts.set(discount.id, applicableProducts);
267
268
  }
@@ -273,7 +274,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
273
274
  var _product$discount_lis3, _product$discount_lis4, _product$discount_lis5, _product$discount_lis6, _product$discount_lis7;
274
275
  var product = _this3.hooks.getProduct(originProduct);
275
276
  if (product !== null && product !== void 0 && product.booking_id && (_product$discount_lis3 = product.discount_list) !== null && _product$discount_lis3 !== void 0 && _product$discount_lis3.length && product !== null && product !== void 0 && (_product$discount_lis4 = product.discount_list) !== null && _product$discount_lis4 !== void 0 && _product$discount_lis4.every(function (discount) {
276
- return discount.id && discount.type === 'good_pass';
277
+ return discount.id && ['good_pass', 'discount_card', 'product_discount_card'].includes(discount.type);
277
278
  })) {
278
279
  processedProductsMap.set(product._id, originProduct);
279
280
  return;
@@ -358,7 +359,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
358
359
  original_amount: product.price,
359
360
  product_id: selectedDiscount.product_id,
360
361
  percent: selectedDiscount.par_value
361
- }
362
+ },
363
+ num: product.num || 1
362
364
  };
363
365
  appliedProducts.push(discountDetail);
364
366
  appliedDiscountProducts.set(selectedDiscount.id, appliedProducts);
@@ -388,7 +390,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
388
390
  processedProductsMap.set(product._id, _this3.hooks.setProduct(originProduct, {
389
391
  discount_list: [discountDetail],
390
392
  price: new Decimal(targetProductPrice).toNumber(),
391
- total: new Decimal(product.origin_total || product.total || 0).minus(new Decimal(product.price || 0)).toNumber(),
393
+ total: new Decimal(product.origin_total || product.total || 0).minus(new Decimal(product.price || 0).minus(new Decimal(targetProductPrice))).toNumber(),
392
394
  origin_total: product.origin_total || product.total
393
395
  }));
394
396
  }
@@ -37,6 +37,7 @@ type ProductDetail = {
37
37
  options?: any[];
38
38
  bundle?: any[];
39
39
  original_price?: number | string;
40
+ num?: number;
40
41
  };
41
42
  export interface RulesParamsHooks {
42
43
  getProduct: (product: Record<string, any>) => ProductDetail;
@@ -568,7 +568,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
568
568
  _ref4 = productData || {}, bundle = _ref4.bundle, options = _ref4.options, origin = _ref4.origin, product_variant_id = _ref4.product_variant_id, _ref4$quantity = _ref4.quantity, quantity = _ref4$quantity === void 0 ? 1 : _ref4$quantity, rowKey = _ref4.rowKey; // 检查购物车里是否已经存在 rowKey相同的数据,如果是则更新数量
569
569
  cartItems = this.store.cart.getItems();
570
570
  if (!rowKey) {
571
- _context8.next = 8;
571
+ _context8.next = 9;
572
572
  break;
573
573
  }
574
574
  targetCartItem = cartItems.find(function (n) {
@@ -576,7 +576,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
576
576
  return ((_n$_productOrigin = n._productOrigin) === null || _n$_productOrigin === void 0 ? void 0 : _n$_productOrigin.rowKey) === rowKey;
577
577
  });
578
578
  if (!(targetCartItem && isNormalProduct(targetCartItem._productOrigin))) {
579
- _context8.next = 8;
579
+ _context8.next = 9;
580
580
  break;
581
581
  }
582
582
  this.store.cart.updateItem({
@@ -584,8 +584,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
584
584
  product: _objectSpread({}, targetCartItem._productOrigin),
585
585
  quantity: (targetCartItem.num || 1) + quantity
586
586
  });
587
+ // 这里需要单独触发一个,购物车商品数量发生改变的 hook
588
+ this.core.effects.emit("".concat(this.store.cart.name, ":onUpdateCartItemNums"), {});
587
589
  return _context8.abrupt("return");
588
- case 8:
590
+ case 9:
589
591
  product = _objectSpread(_objectSpread({}, origin), {}, {
590
592
  product_variant_id: product_variant_id,
591
593
  rowKey: rowKey
@@ -600,7 +602,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
600
602
  addCartItem.account = activeAccount;
601
603
  }
602
604
  this.store.cart.addItem(addCartItem);
603
- case 12:
605
+ case 13:
604
606
  case "end":
605
607
  return _context8.stop();
606
608
  }
@@ -1568,7 +1570,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1568
1570
  } else {
1569
1571
  var _cartItem$_productOri4, _this9$shopStore$get;
1570
1572
  var hasFlexibleDuration = ((_cartItem$_productOri4 = cartItem._productOrigin) === null || _cartItem$_productOri4 === void 0 || (_cartItem$_productOri4 = _cartItem$_productOri4.duration) === null || _cartItem$_productOri4 === void 0 ? void 0 : _cartItem$_productOri4.type) === 'flexible';
1571
- var operating_day_boundary = (_this9$shopStore$get = _this9.shopStore.get('core')) === null || _this9$shopStore$get === void 0 || (_this9$shopStore$get = _this9$shopStore$get.core) === null || _this9$shopStore$get === void 0 || (_this9$shopStore$get = _this9$shopStore$get.operating_day_boundary) === null || _this9$shopStore$get === void 0 ? void 0 : _this9$shopStore$get.time;
1573
+ var operating_day_boundary = (_this9$shopStore$get = _this9.shopStore.get('core')) === null || _this9$shopStore$get === void 0 || (_this9$shopStore$get = _this9$shopStore$get.core) === null || _this9$shopStore$get === void 0 ? void 0 : _this9$shopStore$get.operating_day_boundary;
1572
1574
  productResources.forEach(function (item) {
1573
1575
  // 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
1574
1576
  // 同时,在这一步尝试去拉一下时间片,基于商品的时长,看每个资源是否还有空余时间能对这个商品做服务,如果没有则过滤
@@ -2298,7 +2300,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2298
2300
  var _item$_productOrigin17;
2299
2301
  return ((_item$_productOrigin17 = item._productOrigin) === null || _item$_productOrigin17 === void 0 || (_item$_productOrigin17 = _item$_productOrigin17.duration) === null || _item$_productOrigin17 === void 0 ? void 0 : _item$_productOrigin17.type) === 'flexible';
2300
2302
  });
2301
- 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 || (_this$shopStore$get = _this$shopStore$get.operating_day_boundary) === null || _this$shopStore$get === void 0 ? void 0 : _this$shopStore$get.time;
2303
+ 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;
2302
2304
  var timeSlots = getTimeSlicesByResources({
2303
2305
  resourceIds: resourceIds,
2304
2306
  resourcesMap: resourcesMap,
@@ -2338,7 +2340,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2338
2340
  }, {});
2339
2341
 
2340
2342
  // 店铺营业结束时间
2341
- var operating_day_boundary = (_this$shopStore$get2 = this.shopStore.get('core')) === null || _this$shopStore$get2 === void 0 || (_this$shopStore$get2 = _this$shopStore$get2.core) === null || _this$shopStore$get2 === void 0 || (_this$shopStore$get2 = _this$shopStore$get2.operating_day_boundary) === null || _this$shopStore$get2 === void 0 ? void 0 : _this$shopStore$get2.time;
2343
+ var operating_day_boundary = (_this$shopStore$get2 = this.shopStore.get('core')) === null || _this$shopStore$get2 === void 0 || (_this$shopStore$get2 = _this$shopStore$get2.core) === null || _this$shopStore$get2 === void 0 ? void 0 : _this$shopStore$get2.operating_day_boundary;
2342
2344
 
2343
2345
  // 处理每个账号的商品
2344
2346
  Object.values(itemsByAccount).forEach(function (accountItems) {
@@ -2363,7 +2365,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2363
2365
  var resourcesEndTime = targetResourceTimes.reduce(function (acc, curr) {
2364
2366
  return dayjs(curr.end_at).isBefore(dayjs(acc.end_at)) ? curr : acc;
2365
2367
  }, targetResourceTimes[0]);
2366
- var endTime = dayjs(resourcesEndTime.end_at).isBefore(dayjs(operating_day_boundary)) ? resourcesEndTime.end_at : operating_day_boundary;
2368
+
2369
+ // 将 operating_day_boundary 转换为与 resourcesEndTime.end_at 相同日期的完整日期时间
2370
+ var resourceDate = dayjs(resourcesEndTime.end_at).format('YYYY-MM-DD');
2371
+ var operatingBoundaryDateTime = "".concat(resourceDate, " ").concat(operating_day_boundary.type === 'start_time' ? "23:59" : operating_day_boundary.time);
2372
+ var endTime = dayjs(resourcesEndTime.end_at).isBefore(dayjs(operatingBoundaryDateTime)) ? resourcesEndTime.end_at : operatingBoundaryDateTime;
2367
2373
  // 修复:如果 endTime 只是时间格式(如 "17:00"),需要加上日期
2368
2374
  var formattedEndTime;
2369
2375
  if (typeof endTime === 'string' && endTime.includes(':') && !endTime.includes(' ') && !endTime.includes('T')) {
@@ -2626,6 +2632,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2626
2632
  options: targetCartItem._optionsOrigin,
2627
2633
  quantity: (targetCartItem.num || 1) + quantity
2628
2634
  });
2635
+ // 这里需要单独触发一个,购物车商品数量发生改变的 hook
2636
+ this.core.effects.emit("".concat(this.store.cart.name, ":onUpdateCartItemNums"), {});
2629
2637
  return;
2630
2638
  }
2631
2639
  }
@@ -97,7 +97,10 @@ export declare const getTimeSlicesByResource: ({ resource, duration, split, curr
97
97
  } | undefined;
98
98
  } | undefined;
99
99
  hasFlexibleDuration?: boolean | undefined;
100
- operating_day_boundary?: string | undefined;
100
+ operating_day_boundary?: {
101
+ type: string;
102
+ time: string;
103
+ } | undefined;
101
104
  }) => TimeSliceItem[];
102
105
  /**
103
106
  * @title: 获取时间切片列表的交集
@@ -154,7 +157,10 @@ export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, dur
154
157
  } | undefined;
155
158
  } | undefined;
156
159
  hasFlexibleDuration?: boolean | undefined;
157
- operating_day_boundary?: string | undefined;
160
+ operating_day_boundary?: {
161
+ type: string;
162
+ time: string;
163
+ } | undefined;
158
164
  }) => any[];
159
165
  /**
160
166
  * @title: 获取其他人的已选资源
@@ -463,7 +463,8 @@ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref5) {
463
463
  }
464
464
  if (_status.usable) {
465
465
  // 如果有hasFlexibleDuration,且timeSlice.start_at 大于等于operating_day_boundary,则不添加时间切片
466
- if (hasFlexibleDuration && operating_day_boundary && timeSlice.start_time >= operating_day_boundary) {
466
+ var operatingBoundaryDateTime = (operating_day_boundary === null || operating_day_boundary === void 0 ? void 0 : operating_day_boundary.type) === 'start_time' ? "23:59" : operating_day_boundary === null || operating_day_boundary === void 0 ? void 0 : operating_day_boundary.time;
467
+ if (hasFlexibleDuration && operating_day_boundary && timeSlice.start_time >= (operatingBoundaryDateTime || "23:59")) {
467
468
  break;
468
469
  }
469
470
  // 添加时间切片 09:00 ~ 10:00 09:20 ~ 10:20 09:00 ~ 10:00 09:20 ~ 10:20 11:00 ~ 12:00 11:20 ~ 12:20
@@ -434,7 +434,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
434
434
  productList.forEach(function (item) {
435
435
  if (item.booking_id) {
436
436
  (item.discount_list || []).forEach(function (discount) {
437
- if (discount.id && discount.type === 'good_pass') {
437
+ if (discount.id && ['good_pass', 'discount_card'].includes(discount.type)) {
438
438
  var _discount$discount, _discount$discount2, _discount$discount3;
439
439
  editModeDiscountList.push(_objectSpread(_objectSpread({}, discount), {}, {
440
440
  isEditMode: true,
@@ -122,7 +122,7 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
122
122
  }
123
123
  if (discount.appliedProductDetails) {
124
124
  return discount.appliedProductDetails.reduce((total, product) => {
125
- const price = new import_decimal.default((product == null ? void 0 : product.amount) || 0);
125
+ const price = new import_decimal.default((product == null ? void 0 : product.amount) || 0).mul((product == null ? void 0 : product.num) || 1);
126
126
  return new import_decimal.default(total).plus(price).toNumber();
127
127
  }, 0);
128
128
  }
@@ -27,6 +27,7 @@ interface ApplicableProductDetails {
27
27
  resource_id: number;
28
28
  title: string;
29
29
  original_amount: string;
30
+ num: number;
30
31
  }
31
32
  export interface Discount {
32
33
  id: number;
@@ -164,7 +164,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
164
164
  var _a, _b, _c;
165
165
  const limitedData = discount == null ? void 0 : discount.limited_relation_product_data;
166
166
  const isLimitedProduct = limitedData.type === "product_all" || limitedData.product_ids && limitedData.product_ids.includes(product.id);
167
- const isAvailableProduct = !((product == null ? void 0 : product.booking_id) && ((_a = product == null ? void 0 : product.discount_list) == null ? void 0 : _a.length) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.every((discount2) => discount2.id && discount2.type === "good_pass")));
167
+ const isAvailableProduct = !((product == null ? void 0 : product.booking_id) && ((_a = product == null ? void 0 : product.discount_list) == null ? void 0 : _a.length) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.every((discount2) => discount2.id && ["good_pass", "discount_card", "product_discount_card"].includes(discount2.type))));
168
168
  if (isAvailableProduct && isLimitedProduct) {
169
169
  (_c = discountApplicability.get(discount.id)) == null ? void 0 : _c.push(product.id);
170
170
  const applicableProducts = discountApplicableProducts.get(discount.id) || [];
@@ -176,7 +176,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
176
176
  title: discount.format_title,
177
177
  original_amount: product.origin_total,
178
178
  pre_value: discount.par_value
179
- }
179
+ },
180
+ num: product.num || 1
180
181
  });
181
182
  discountApplicableProducts.set(discount.id, applicableProducts);
182
183
  }
@@ -185,7 +186,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
185
186
  sortedProductList.forEach((originProduct) => {
186
187
  var _a, _b, _c, _d, _e;
187
188
  const product = this.hooks.getProduct(originProduct);
188
- if ((product == null ? void 0 : product.booking_id) && ((_a = product.discount_list) == null ? void 0 : _a.length) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.every((discount) => discount.id && discount.type === "good_pass"))) {
189
+ if ((product == null ? void 0 : product.booking_id) && ((_a = product.discount_list) == null ? void 0 : _a.length) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.every((discount) => discount.id && ["good_pass", "discount_card", "product_discount_card"].includes(discount.type)))) {
189
190
  processedProductsMap.set(product._id, originProduct);
190
191
  return;
191
192
  }
@@ -259,7 +260,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
259
260
  original_amount: product.price,
260
261
  product_id: selectedDiscount.product_id,
261
262
  percent: selectedDiscount.par_value
262
- }
263
+ },
264
+ num: product.num || 1
263
265
  };
264
266
  appliedProducts.push(discountDetail);
265
267
  appliedDiscountProducts.set(selectedDiscount.id, appliedProducts);
@@ -291,7 +293,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
291
293
  this.hooks.setProduct(originProduct, {
292
294
  discount_list: [discountDetail],
293
295
  price: new import_decimal.default(targetProductPrice).toNumber(),
294
- total: new import_decimal.default(product.origin_total || product.total || 0).minus(new import_decimal.default(product.price || 0)).toNumber(),
296
+ total: new import_decimal.default(product.origin_total || product.total || 0).minus(new import_decimal.default(product.price || 0).minus(new import_decimal.default(targetProductPrice))).toNumber(),
295
297
  origin_total: product.origin_total || product.total
296
298
  })
297
299
  );
@@ -37,6 +37,7 @@ type ProductDetail = {
37
37
  options?: any[];
38
38
  bundle?: any[];
39
39
  original_price?: number | string;
40
+ num?: number;
40
41
  };
41
42
  export interface RulesParamsHooks {
42
43
  getProduct: (product: Record<string, any>) => ProductDetail;
@@ -359,6 +359,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
359
359
  },
360
360
  quantity: (targetCartItem.num || 1) + quantity
361
361
  });
362
+ this.core.effects.emit(`${this.store.cart.name}:onUpdateCartItemNums`, {});
362
363
  return;
363
364
  }
364
365
  }
@@ -824,7 +825,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
824
825
  const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
825
826
  const arr = [];
826
827
  cartItems.forEach((cartItem) => {
827
- var _a, _b, _c, _d, _e, _f, _g, _h;
828
+ var _a, _b, _c, _d, _e, _f, _g;
828
829
  let selectedResources = [];
829
830
  const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
830
831
  capacity: (_a = cartItem._productOrigin) == null ? void 0 : _a.capacity,
@@ -904,7 +905,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
904
905
  });
905
906
  } else {
906
907
  const hasFlexibleDuration = ((_e = (_d = cartItem._productOrigin) == null ? void 0 : _d.duration) == null ? void 0 : _e.type) === "flexible";
907
- const operating_day_boundary = (_h = (_g = (_f = this.shopStore.get("core")) == null ? void 0 : _f.core) == null ? void 0 : _g.operating_day_boundary) == null ? void 0 : _h.time;
908
+ const operating_day_boundary = (_g = (_f = this.shopStore.get("core")) == null ? void 0 : _f.core) == null ? void 0 : _g.operating_day_boundary;
908
909
  productResources.forEach((item) => {
909
910
  item.renderList = item.renderList.filter((n) => {
910
911
  var _a2, _b2, _c2;
@@ -1479,7 +1480,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1479
1480
  }
1480
1481
  // 从购物车中获取已经分配好第一步资源的所有时间片
1481
1482
  getTimeSlotByAllResources(resources_code) {
1482
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
1483
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1483
1484
  let dateRange = this.store.date.getDateRange();
1484
1485
  const resources = [];
1485
1486
  const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
@@ -1489,7 +1490,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1489
1490
  let maxCutOffTime = void 0;
1490
1491
  let maxCutOffTimeValue = (0, import_dayjs.default)();
1491
1492
  cartItems.forEach((item) => {
1492
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2;
1493
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i;
1493
1494
  (_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.forEach((n) => {
1494
1495
  if (n.code === resources_code) {
1495
1496
  resources.push(...n.renderList || []);
@@ -1502,7 +1503,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1502
1503
  resourcesTypeId = (_g2 = (_f2 = (_e2 = (_d2 = item == null ? void 0 : item._productOrigin) == null ? void 0 : _d2.product_resource) == null ? void 0 : _e2.resources) == null ? void 0 : _f2.find(
1503
1504
  (n) => n.code === resources_code
1504
1505
  )) == null ? void 0 : _g2.id;
1505
- if (((_h2 = item._productOrigin) == null ? void 0 : _h2.cut_off_time) && ((_i2 = item._productOrigin) == null ? void 0 : _i2.cut_off_time.type) === "advance") {
1506
+ if (((_h2 = item._productOrigin) == null ? void 0 : _h2.cut_off_time) && ((_i = item._productOrigin) == null ? void 0 : _i.cut_off_time.type) === "advance") {
1506
1507
  const currentCutOffTime = (0, import_dayjs.default)().add(
1507
1508
  item._productOrigin.cut_off_time.unit,
1508
1509
  item._productOrigin.cut_off_time.unit_type
@@ -1571,7 +1572,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1571
1572
  var _a2, _b2;
1572
1573
  return ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.type) === "flexible";
1573
1574
  });
1574
- const operating_day_boundary = (_i = (_h = (_g = this.shopStore.get("core")) == null ? void 0 : _g.core) == null ? void 0 : _h.operating_day_boundary) == null ? void 0 : _i.time;
1575
+ const operating_day_boundary = (_h = (_g = this.shopStore.get("core")) == null ? void 0 : _g.core) == null ? void 0 : _h.operating_day_boundary;
1575
1576
  const timeSlots = (0, import_resources.getTimeSlicesByResources)({
1576
1577
  resourceIds,
1577
1578
  resourcesMap,
@@ -1587,7 +1588,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1587
1588
  }
1588
1589
  // 提交时间切片,绑定到对应购物车的商品上,更新购物车---只有 duration 商品
1589
1590
  submitTimeSlot(timeSlots) {
1590
- var _a, _b, _c;
1591
+ var _a, _b;
1591
1592
  const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
1592
1593
  const allResources = this.store.date.getResourcesListByDate(timeSlots.start_at.format("YYYY-MM-DD"));
1593
1594
  const itemsByAccount = cartItems.reduce(
@@ -1601,25 +1602,27 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1601
1602
  },
1602
1603
  {}
1603
1604
  );
1604
- const operating_day_boundary = (_c = (_b = (_a = this.shopStore.get("core")) == null ? void 0 : _a.core) == null ? void 0 : _b.operating_day_boundary) == null ? void 0 : _c.time;
1605
+ const operating_day_boundary = (_b = (_a = this.shopStore.get("core")) == null ? void 0 : _a.core) == null ? void 0 : _b.operating_day_boundary;
1605
1606
  Object.values(itemsByAccount).forEach((accountItems) => {
1606
1607
  let currentStartTime = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
1607
1608
  accountItems.forEach((item, index) => {
1608
1609
  var _a2;
1609
1610
  const newResources = (0, import_lodash_es.cloneDeep)(item._origin.resources);
1610
1611
  newResources.forEach((resource) => {
1611
- var _a3, _b2, _c2, _d, _e;
1612
+ var _a3, _b2, _c, _d, _e;
1612
1613
  if (((_b2 = (_a3 = item._productOrigin) == null ? void 0 : _a3.duration) == null ? void 0 : _b2.type) === "flexible") {
1613
1614
  item.duration = {
1614
1615
  type: "minutes",
1615
1616
  value: 10
1616
1617
  };
1617
1618
  resource.startTime = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
1618
- const targetResourceTimes = (_c2 = allResources == null ? void 0 : allResources.find((n) => n.id === resource.id)) == null ? void 0 : _c2.times;
1619
+ const targetResourceTimes = (_c = allResources == null ? void 0 : allResources.find((n) => n.id === resource.id)) == null ? void 0 : _c.times;
1619
1620
  const resourcesEndTime = targetResourceTimes.reduce((acc, curr) => {
1620
1621
  return (0, import_dayjs.default)(curr.end_at).isBefore((0, import_dayjs.default)(acc.end_at)) ? curr : acc;
1621
1622
  }, targetResourceTimes[0]);
1622
- const endTime = (0, import_dayjs.default)(resourcesEndTime.end_at).isBefore((0, import_dayjs.default)(operating_day_boundary)) ? resourcesEndTime.end_at : operating_day_boundary;
1623
+ const resourceDate = (0, import_dayjs.default)(resourcesEndTime.end_at).format("YYYY-MM-DD");
1624
+ const operatingBoundaryDateTime = `${resourceDate} ${operating_day_boundary.type === "start_time" ? "23:59" : operating_day_boundary.time}`;
1625
+ const endTime = (0, import_dayjs.default)(resourcesEndTime.end_at).isBefore((0, import_dayjs.default)(operatingBoundaryDateTime)) ? resourcesEndTime.end_at : operatingBoundaryDateTime;
1623
1626
  let formattedEndTime;
1624
1627
  if (typeof endTime === "string" && endTime.includes(":") && !endTime.includes(" ") && !endTime.includes("T")) {
1625
1628
  const currentDate = timeSlots.start_at.format("YYYY-MM-DD");
@@ -1827,6 +1830,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1827
1830
  options: targetCartItem._optionsOrigin,
1828
1831
  quantity: (targetCartItem.num || 1) + quantity
1829
1832
  });
1833
+ this.core.effects.emit(`${this.store.cart.name}:onUpdateCartItemNums`, {});
1830
1834
  return;
1831
1835
  }
1832
1836
  }
@@ -97,7 +97,10 @@ export declare const getTimeSlicesByResource: ({ resource, duration, split, curr
97
97
  } | undefined;
98
98
  } | undefined;
99
99
  hasFlexibleDuration?: boolean | undefined;
100
- operating_day_boundary?: string | undefined;
100
+ operating_day_boundary?: {
101
+ type: string;
102
+ time: string;
103
+ } | undefined;
101
104
  }) => TimeSliceItem[];
102
105
  /**
103
106
  * @title: 获取时间切片列表的交集
@@ -154,7 +157,10 @@ export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, dur
154
157
  } | undefined;
155
158
  } | undefined;
156
159
  hasFlexibleDuration?: boolean | undefined;
157
- operating_day_boundary?: string | undefined;
160
+ operating_day_boundary?: {
161
+ type: string;
162
+ time: string;
163
+ } | undefined;
158
164
  }) => any[];
159
165
  /**
160
166
  * @title: 获取其他人的已选资源
@@ -366,7 +366,8 @@ var getTimeSlicesByResource = ({
366
366
  resourcesUseableMap[resource.id] = _status.usable;
367
367
  }
368
368
  if (_status.usable) {
369
- if (hasFlexibleDuration && operating_day_boundary && timeSlice.start_time >= operating_day_boundary) {
369
+ const operatingBoundaryDateTime = (operating_day_boundary == null ? void 0 : operating_day_boundary.type) === "start_time" ? "23:59" : operating_day_boundary == null ? void 0 : operating_day_boundary.time;
370
+ if (hasFlexibleDuration && operating_day_boundary && timeSlice.start_time >= (operatingBoundaryDateTime || "23:59")) {
370
371
  break;
371
372
  }
372
373
  timeSlices.push({
@@ -271,7 +271,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
271
271
  if (item.booking_id) {
272
272
  (item.discount_list || []).forEach((discount) => {
273
273
  var _a2, _b, _c;
274
- if (discount.id && discount.type === "good_pass") {
274
+ if (discount.id && ["good_pass", "discount_card"].includes(discount.type)) {
275
275
  editModeDiscountList.push({
276
276
  ...discount,
277
277
  isEditMode: true,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.132",
4
+ "version": "0.0.135",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",