@pisell/pisellos 2.1.61 → 2.1.63

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.
@@ -188,7 +188,7 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
188
188
  tags: ['good_pass', 'product_discount_card'],
189
189
  available: 1,
190
190
  relation_product: 1,
191
- with: ['extensionData', 'holder.detail'],
191
+ with: ['extensionData', 'customScheduleSnapshot', 'holder.detail'],
192
192
  order_behavior_count: 1,
193
193
  order_behavior_count_customer_id: customerId || 1
194
194
  });
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "duration" | "session" | "normal";
52
+ getProductType(): "normal" | "duration" | "session";
53
53
  }
@@ -349,8 +349,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
349
349
 
350
350
  // 对扁平化后的列表按价格降序排序(用于应用优惠券时优先选择高价商品)
351
351
  var sortedFlattenedList = flattenedList.sort(function (a, b) {
352
- var priceA = new Decimal(a.price || '0');
353
- var priceB = new Decimal(b.price || '0');
352
+ var _ref3, _a$original_price, _ref4, _b$original_price;
353
+ // 子商品优先使用 original_price,主商品使用 price
354
+ var priceA = new Decimal(a.type === 'bundle' ? (_ref3 = (_a$original_price = a.original_price) !== null && _a$original_price !== void 0 ? _a$original_price : a.price) !== null && _ref3 !== void 0 ? _ref3 : '0' : a.price || '0');
355
+ var priceB = new Decimal(b.type === 'bundle' ? (_ref4 = (_b$original_price = b.original_price) !== null && _b$original_price !== void 0 ? _b$original_price : b.price) !== null && _ref4 !== void 0 ? _ref4 : '0' : b.price || '0');
354
356
  if (priceA.equals(priceB)) {
355
357
  // 价格相同时,主商品优先
356
358
  if (a.type !== b.type) {
@@ -419,6 +421,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
419
421
  product = flatItem.product;
420
422
  originProduct = flatItem.originProduct;
421
423
  } else {
424
+ var _flatItem$parentProdu;
422
425
  // bundle子商品:构造虚拟商品对象
423
426
  product = {
424
427
  _id: flatItem._id,
@@ -429,7 +432,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
429
432
  total: flatItem.total,
430
433
  origin_total: flatItem.origin_total,
431
434
  booking_id: flatItem.booking_id,
432
- discount_list: flatItem.discount_list || []
435
+ discount_list: flatItem.discount_list || [],
436
+ startDate: (_flatItem$parentProdu = flatItem.parentProduct) === null || _flatItem$parentProdu === void 0 ? void 0 : _flatItem$parentProdu.startDate
433
437
  };
434
438
  originProduct = flatItem.originProduct;
435
439
  }
@@ -504,7 +508,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
504
508
  product = flatItem.product;
505
509
  originProduct = flatItem.originProduct;
506
510
  } else {
507
- var _flatItem$bundleItem2, _flatItem$bundleItem3, _flatItem$bundleItem4;
511
+ var _flatItem$bundleItem2, _flatItem$bundleItem3, _flatItem$bundleItem4, _flatItem$parentProdu2;
508
512
  // bundle子商品
509
513
  product = {
510
514
  _id: flatItem._id,
@@ -516,7 +520,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
516
520
  original_price: flatItem === null || flatItem === void 0 || (_flatItem$bundleItem2 = flatItem.bundleItem) === null || _flatItem$bundleItem2 === void 0 ? void 0 : _flatItem$bundleItem2.original_price,
517
521
  origin_total: flatItem === null || flatItem === void 0 || (_flatItem$bundleItem3 = flatItem.bundleItem) === null || _flatItem$bundleItem3 === void 0 ? void 0 : _flatItem$bundleItem3.original_price,
518
522
  booking_id: flatItem.booking_id,
519
- discount_list: (flatItem === null || flatItem === void 0 || (_flatItem$bundleItem4 = flatItem.bundleItem) === null || _flatItem$bundleItem4 === void 0 ? void 0 : _flatItem$bundleItem4.discount_list) || []
523
+ discount_list: (flatItem === null || flatItem === void 0 || (_flatItem$bundleItem4 = flatItem.bundleItem) === null || _flatItem$bundleItem4 === void 0 ? void 0 : _flatItem$bundleItem4.discount_list) || [],
524
+ startDate: (_flatItem$parentProdu2 = flatItem.parentProduct) === null || _flatItem$parentProdu2 === void 0 ? void 0 : _flatItem$parentProdu2.startDate
520
525
  };
521
526
  originProduct = flatItem.originProduct;
522
527
  }
@@ -597,8 +602,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
597
602
  var _product$discount_lis5, _product7, _product7$every;
598
603
  // 主商品:判断自身是否手动折扣
599
604
  isManualDiscount = typeof product.isManualDiscount === 'boolean' ? product.isManualDiscount : product.total != product.origin_total && (product.bundle || []).every(function (item) {
600
- var _ref3;
601
- return !((_ref3 = item.discount_list || []) !== null && _ref3 !== void 0 && _ref3.length);
605
+ var _ref5;
606
+ return !((_ref5 = item.discount_list || []) !== null && _ref5 !== void 0 && _ref5.length);
602
607
  }) && (!((_product$discount_lis5 = product.discount_list) !== null && _product$discount_lis5 !== void 0 && _product$discount_lis5.length) || ((_product7 = product) === null || _product7 === void 0 || (_product7 = _product7.discount_list) === null || _product7 === void 0 || (_product7$every = _product7.every) === null || _product7$every === void 0 ? void 0 : _product7$every.call(_product7, function (item) {
603
608
  return item.type === 'product';
604
609
  })));
@@ -608,8 +613,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
608
613
  if (parentProduct) {
609
614
  var _parentProduct$discou, _parentProduct$discou2, _parentProduct$discou3;
610
615
  isManualDiscount = typeof parentProduct.isManualDiscount === 'boolean' ? parentProduct.isManualDiscount : parentProduct.total != parentProduct.origin_total && (parentProduct.bundle || []).every(function (item) {
611
- var _ref4;
612
- return !((_ref4 = item.discount_list || []) !== null && _ref4 !== void 0 && _ref4.length);
616
+ var _ref6;
617
+ return !((_ref6 = item.discount_list || []) !== null && _ref6 !== void 0 && _ref6.length);
613
618
  }) && (!((_parentProduct$discou = parentProduct.discount_list) !== null && _parentProduct$discou !== void 0 && _parentProduct$discou.length) || (parentProduct === null || parentProduct === void 0 || (_parentProduct$discou2 = parentProduct.discount_list) === null || _parentProduct$discou2 === void 0 || (_parentProduct$discou3 = _parentProduct$discou2.every) === null || _parentProduct$discou3 === void 0 ? void 0 : _parentProduct$discou3.call(_parentProduct$discou2, function (item) {
614
619
  return item.type === 'product';
615
620
  })));
@@ -628,11 +633,11 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
628
633
  }
629
634
  // bundle子商品:检查自己的 discount_list 或父主商品的 discount_list
630
635
  if (flatItem.type === 'bundle') {
631
- var _product$discount_lis7, _flatItem$parentProdu;
636
+ var _product$discount_lis7, _flatItem$parentProdu3;
632
637
  if ((_product$discount_lis7 = product.discount_list) !== null && _product$discount_lis7 !== void 0 && _product$discount_lis7.some(function (item) {
633
638
  var _item$discount2;
634
639
  return ((_item$discount2 = item.discount) === null || _item$discount2 === void 0 ? void 0 : _item$discount2.resource_id) === options.discountId;
635
- }) || (_flatItem$parentProdu = flatItem.parentProduct) !== null && _flatItem$parentProdu !== void 0 && (_flatItem$parentProdu = _flatItem$parentProdu.discount_list) !== null && _flatItem$parentProdu !== void 0 && _flatItem$parentProdu.some(function (item) {
640
+ }) || (_flatItem$parentProdu3 = flatItem.parentProduct) !== null && _flatItem$parentProdu3 !== void 0 && (_flatItem$parentProdu3 = _flatItem$parentProdu3.discount_list) !== null && _flatItem$parentProdu3 !== void 0 && _flatItem$parentProdu3.some(function (item) {
636
641
  var _item$discount3;
637
642
  return ((_item$discount3 = item.discount) === null || _item$discount3 === void 0 ? void 0 : _item$discount3.resource_id) === options.discountId;
638
643
  })) {
@@ -654,14 +659,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
654
659
  }
655
660
  // bundle子商品:检查自己的 discount_list 或父主商品的 discount_list
656
661
  if (flatItem.type === 'bundle') {
657
- var _product$discount_lis9, _flatItem$parentProdu2;
662
+ var _product$discount_lis9, _flatItem$parentProdu4;
658
663
  if ((_product$discount_lis9 = product.discount_list) !== null && _product$discount_lis9 !== void 0 && _product$discount_lis9.some(function (item) {
659
664
  var _options$selectedList2;
660
665
  return options === null || options === void 0 || (_options$selectedList2 = options.selectedList) === null || _options$selectedList2 === void 0 ? void 0 : _options$selectedList2.some(function (n) {
661
666
  var _item$discount5;
662
667
  return n.discountId === ((_item$discount5 = item.discount) === null || _item$discount5 === void 0 ? void 0 : _item$discount5.resource_id);
663
668
  });
664
- }) || (_flatItem$parentProdu2 = flatItem.parentProduct) !== null && _flatItem$parentProdu2 !== void 0 && (_flatItem$parentProdu2 = _flatItem$parentProdu2.discount_list) !== null && _flatItem$parentProdu2 !== void 0 && _flatItem$parentProdu2.some(function (item) {
669
+ }) || (_flatItem$parentProdu4 = flatItem.parentProduct) !== null && _flatItem$parentProdu4 !== void 0 && (_flatItem$parentProdu4 = _flatItem$parentProdu4.discount_list) !== null && _flatItem$parentProdu4 !== void 0 && _flatItem$parentProdu4.some(function (item) {
665
670
  var _options$selectedList3;
666
671
  return options === null || options === void 0 || (_options$selectedList3 = options.selectedList) === null || _options$selectedList3 === void 0 ? void 0 : _options$selectedList3.some(function (n) {
667
672
  var _item$discount6;
@@ -897,7 +902,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
897
902
  }));
898
903
  }
899
904
  } else {
900
- var _selectedDiscount3$me, _flatItem$parentProdu3;
905
+ var _selectedDiscount3$me, _flatItem$parentProdu5;
901
906
  // 折扣卡:不拆分数量,直接应用
902
907
  var _selectedDiscount3 = selectedDiscountCard || applicableDiscounts[0];
903
908
  usedDiscounts.set(_selectedDiscount3.id, true);
@@ -923,7 +928,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
923
928
  custom_product_bundle_map_id: _uniqueId,
924
929
  num: product.num || 1
925
930
  },
926
- _num: (product.num || 1) * ((flatItem === null || flatItem === void 0 || (_flatItem$parentProdu3 = flatItem.parentProduct) === null || _flatItem$parentProdu3 === void 0 ? void 0 : _flatItem$parentProdu3.num) || 1)
931
+ _num: (product.num || 1) * ((flatItem === null || flatItem === void 0 || (_flatItem$parentProdu5 = flatItem.parentProduct) === null || _flatItem$parentProdu5 === void 0 ? void 0 : _flatItem$parentProdu5.num) || 1)
927
932
  };
928
933
 
929
934
  // 记录实际应用的折扣
@@ -315,6 +315,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
315
315
  end_at: dayjs.Dayjs;
316
316
  count: number;
317
317
  left: number;
318
+ summaryCount: number;
318
319
  }[];
319
320
  /**
320
321
  * 找到多个资源的公共可用时间段
@@ -2470,10 +2470,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2470
2470
  var resourcesUseableMap = {};
2471
2471
  var count = 0;
2472
2472
  var bookingLeft = 0;
2473
+ var summaryCount = 0;
2473
2474
  // 遍历所有资源
2474
2475
  allProductResources === null || allProductResources === void 0 || allProductResources.forEach(function (m) {
2475
2476
  // 遍历所有资源的上工时间片
2476
2477
  var currentResourcesCount = 0;
2478
+ var currentResourcesSummaryCount = 0;
2477
2479
  var currentResourcesTimeSlotCanUsedArr = [];
2478
2480
  // m.times 需要做个过滤,假设 timeSlice.start_at 是 09:30 timeSlice.end_at 是 11:30
2479
2481
  // time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
@@ -2511,6 +2513,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2511
2513
  if (res.usable && res.remainingCapacity >= count && !m.onlyComputed) {
2512
2514
  currentResourcesCount = res.remainingCapacity;
2513
2515
  }
2516
+ if (res.usable && !m.onlyComputed && res.remainingCapacity >= currentResourcesSummaryCount) {
2517
+ currentResourcesSummaryCount = res.remainingCapacity;
2518
+ }
2514
2519
  currentResourcesTimeSlotCanUsedArr.push(res.usable);
2515
2520
  });
2516
2521
  // 在已经选定时间的情况下,只要canUseTime如果有一个 false 那就不可用
@@ -2524,6 +2529,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2524
2529
  }
2525
2530
  if (!m.onlyComputed) {
2526
2531
  bookingLeft += 1;
2532
+ summaryCount += currentResourcesSummaryCount;
2527
2533
  }
2528
2534
  }
2529
2535
  });
@@ -2543,6 +2549,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2543
2549
  if (sameCartItems.length > 0 && sameCartItems.length >= currentResourcesSet.size || sameCartItems.length > bookingLeft) {
2544
2550
  bookingLeft = 0;
2545
2551
  count = 0;
2552
+ summaryCount = 0;
2546
2553
  }
2547
2554
  // 规则 2
2548
2555
  var otherCartItems = cartItems.filter(function (m) {
@@ -2577,6 +2584,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2577
2584
  if (currentResourcesSet.size > 0 && otherCartItems.length + sameCartItems.length >= currentResourcesSet.size) {
2578
2585
  bookingLeft = 0;
2579
2586
  count = 0;
2587
+ summaryCount = 0;
2580
2588
  }
2581
2589
  } else {
2582
2590
  // 多个预约的检测规则:
@@ -2594,6 +2602,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2594
2602
  if (sameCartNeedCapacity >= currentProductResourcesCapacity) {
2595
2603
  bookingLeft = 0;
2596
2604
  count = 0;
2605
+ summaryCount = 0;
2597
2606
  }
2598
2607
  // 规则2、不管是不是跟我一样的商品,只需要跟我当前商品有同一种类型的资源的同一时间的,把所有购物车的 capacity 之和 和 所有当前类型资源的 capacity 之和比较,如果超过了resourcesCapacity,则不可用
2599
2608
  // const otherCartItems = cartItems.filter((m) => m._productOrigin?.id?.toString() !== targetProductData?.id?.toString() && m.start_time === item.start && m.end_time === item.end);
@@ -2656,6 +2665,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2656
2665
  if (otherCartNeedCapacity + usedCapacity >= currentTypeResourcesCapacity) {
2657
2666
  bookingLeft = 0;
2658
2667
  count = 0;
2668
+ summaryCount = 0;
2659
2669
  }
2660
2670
  }
2661
2671
  });
@@ -2667,7 +2677,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2667
2677
  start_at: startDayJs,
2668
2678
  end_at: endDayJs,
2669
2679
  count: count,
2670
- left: bookingLeft
2680
+ left: bookingLeft,
2681
+ summaryCount: summaryCount
2671
2682
  };
2672
2683
  });
2673
2684
  return formatScheduleTimeSlots;
@@ -109,7 +109,7 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
109
109
  tags: ["good_pass", "product_discount_card"],
110
110
  available: 1,
111
111
  relation_product: 1,
112
- with: ["extensionData", "holder.detail"],
112
+ with: ["extensionData", "customScheduleSnapshot", "holder.detail"],
113
113
  order_behavior_count: 1,
114
114
  order_behavior_count_customer_id: customerId || 1
115
115
  });
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "duration" | "session" | "normal";
52
+ getProductType(): "normal" | "duration" | "session";
53
53
  }
@@ -241,8 +241,12 @@ var RulesModule = class extends import_BaseModule.BaseModule {
241
241
  const flattenedList = flattenProductsWithBundle(productList);
242
242
  const sortedFlattenedList = flattenedList.sort((a, b) => {
243
243
  var _a, _b;
244
- const priceA = new import_decimal.default(a.price || "0");
245
- const priceB = new import_decimal.default(b.price || "0");
244
+ const priceA = new import_decimal.default(
245
+ a.type === "bundle" ? a.original_price ?? a.price ?? "0" : a.price || "0"
246
+ );
247
+ const priceB = new import_decimal.default(
248
+ b.type === "bundle" ? b.original_price ?? b.price ?? "0" : b.price || "0"
249
+ );
246
250
  if (priceA.equals(priceB)) {
247
251
  if (a.type !== b.type) {
248
252
  return a.type === "main" ? -1 : 1;
@@ -269,6 +273,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
269
273
  const processedProductsMap = /* @__PURE__ */ new Map();
270
274
  const appliedDiscountProducts = /* @__PURE__ */ new Map();
271
275
  sortedFlattenedList.forEach((flatItem) => {
276
+ var _a;
272
277
  let product, originProduct;
273
278
  if (flatItem.type === "main") {
274
279
  product = flatItem.product;
@@ -283,12 +288,13 @@ var RulesModule = class extends import_BaseModule.BaseModule {
283
288
  total: flatItem.total,
284
289
  origin_total: flatItem.origin_total,
285
290
  booking_id: flatItem.booking_id,
286
- discount_list: flatItem.discount_list || []
291
+ discount_list: flatItem.discount_list || [],
292
+ startDate: (_a = flatItem.parentProduct) == null ? void 0 : _a.startDate
287
293
  };
288
294
  originProduct = flatItem.originProduct;
289
295
  }
290
296
  addModeDiscount.forEach((discount) => {
291
- var _a, _b, _c, _d, _e, _f;
297
+ var _a2, _b, _c, _d, _e, _f;
292
298
  const limitedData = discount == null ? void 0 : discount.limited_relation_product_data;
293
299
  const _tempVar = (flatItem == null ? void 0 : flatItem.type) === "bundle" ? flatItem == null ? void 0 : flatItem.parentProduct : flatItem == null ? void 0 : flatItem.product;
294
300
  const isHolderMatch = this.checkHolderMatch(
@@ -302,7 +308,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
302
308
  let timeLimit = true;
303
309
  timeLimit = !!(0, import_utils.filterDiscountListByBookingTime)([discount], ((product == null ? void 0 : product.startDate) || (0, import_dayjs.default)()).format("YYYY-MM-DD HH:mm:ss")).length;
304
310
  const isLimitedProduct = (limitedData.type === "product_all" || limitedData.product_ids && limitedData.product_ids.includes(product.id)) && isHolderMatch;
305
- const isAvailableProduct = flatItem.type === "main" ? !((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.tag || discount2.type)))) : !((flatItem == null ? void 0 : flatItem.booking_id) && ((_d = (_c = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _c.metadata) == null ? void 0 : _d.custom_product_bundle_map_id));
311
+ const isAvailableProduct = flatItem.type === "main" ? !((product == null ? void 0 : product.booking_id) && ((_a2 = product == null ? void 0 : product.discount_list) == null ? void 0 : _a2.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.tag || discount2.type)))) : !((flatItem == null ? void 0 : flatItem.booking_id) && ((_d = (_c = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _c.metadata) == null ? void 0 : _d.custom_product_bundle_map_id));
306
312
  const isBundleAvailable = this.checkPackageSubItemUsageRules(discount, flatItem);
307
313
  if (isAvailableProduct && isLimitedProduct && timeLimit && isBundleAvailable) {
308
314
  (_e = discountApplicability.get(discount.id)) == null ? void 0 : _e.push(product.id);
@@ -334,7 +340,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
334
340
  });
335
341
  const processedFlatItemsMap = /* @__PURE__ */ new Map();
336
342
  sortedFlattenedList.forEach((flatItem, index) => {
337
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
343
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
338
344
  let product, originProduct;
339
345
  if (flatItem.type === "main") {
340
346
  product = flatItem.product;
@@ -350,11 +356,12 @@ var RulesModule = class extends import_BaseModule.BaseModule {
350
356
  original_price: (_a = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _a.original_price,
351
357
  origin_total: (_b = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _b.original_price,
352
358
  booking_id: flatItem.booking_id,
353
- discount_list: ((_c = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _c.discount_list) || []
359
+ discount_list: ((_c = flatItem == null ? void 0 : flatItem.bundleItem) == null ? void 0 : _c.discount_list) || [],
360
+ startDate: (_d = flatItem.parentProduct) == null ? void 0 : _d.startDate
354
361
  };
355
362
  originProduct = flatItem.originProduct;
356
363
  }
357
- if ((product == null ? void 0 : product.booking_id) && ((_d = product.discount_list) == null ? void 0 : _d.length) && ((_e = product == null ? void 0 : product.discount_list) == null ? void 0 : _e.every((discount) => discount.id && ["good_pass", "discount_card", "product_discount_card"].includes(discount.tag || discount.type)))) {
364
+ if ((product == null ? void 0 : product.booking_id) && ((_e = product.discount_list) == null ? void 0 : _e.length) && ((_f = product == null ? void 0 : product.discount_list) == null ? void 0 : _f.every((discount) => discount.id && ["good_pass", "discount_card", "product_discount_card"].includes(discount.tag || discount.type)))) {
358
365
  if (flatItem.type === "main") {
359
366
  processedProductsMap.set(product._id, [originProduct]);
360
367
  } else {
@@ -414,28 +421,28 @@ var RulesModule = class extends import_BaseModule.BaseModule {
414
421
  isManualDiscount = typeof product.isManualDiscount === "boolean" ? product.isManualDiscount : product.total != product.origin_total && (product.bundle || []).every((item) => {
415
422
  var _a2;
416
423
  return !((_a2 = item.discount_list || []) == null ? void 0 : _a2.length);
417
- }) && (!((_f = product.discount_list) == null ? void 0 : _f.length) || ((_h = (_g = product == null ? void 0 : product.discount_list) == null ? void 0 : _g.every) == null ? void 0 : _h.call(_g, (item) => item.type === "product")));
424
+ }) && (!((_g = product.discount_list) == null ? void 0 : _g.length) || ((_i = (_h = product == null ? void 0 : product.discount_list) == null ? void 0 : _h.every) == null ? void 0 : _i.call(_h, (item) => item.type === "product")));
418
425
  } else {
419
426
  const parentProduct = flatItem.parentProduct;
420
427
  if (parentProduct) {
421
428
  isManualDiscount = typeof parentProduct.isManualDiscount === "boolean" ? parentProduct.isManualDiscount : parentProduct.total != parentProduct.origin_total && (parentProduct.bundle || []).every((item) => {
422
429
  var _a2;
423
430
  return !((_a2 = item.discount_list || []) == null ? void 0 : _a2.length);
424
- }) && (!((_i = parentProduct.discount_list) == null ? void 0 : _i.length) || ((_k = (_j = parentProduct == null ? void 0 : parentProduct.discount_list) == null ? void 0 : _j.every) == null ? void 0 : _k.call(_j, (item) => item.type === "product")));
431
+ }) && (!((_j = parentProduct.discount_list) == null ? void 0 : _j.length) || ((_l = (_k = parentProduct == null ? void 0 : parentProduct.discount_list) == null ? void 0 : _k.every) == null ? void 0 : _l.call(_k, (item) => item.type === "product")));
425
432
  }
426
433
  }
427
434
  if (options == null ? void 0 : options.discountId) {
428
- if (flatItem.type === "main" && ((_l = product.discount_list) == null ? void 0 : _l.some((item) => {
435
+ if (flatItem.type === "main" && ((_m = product.discount_list) == null ? void 0 : _m.some((item) => {
429
436
  var _a2;
430
437
  return ((_a2 = item.discount) == null ? void 0 : _a2.resource_id) === options.discountId;
431
438
  }))) {
432
439
  isManualDiscount = false;
433
440
  }
434
441
  if (flatItem.type === "bundle") {
435
- if (((_m = product.discount_list) == null ? void 0 : _m.some((item) => {
442
+ if (((_n = product.discount_list) == null ? void 0 : _n.some((item) => {
436
443
  var _a2;
437
444
  return ((_a2 = item.discount) == null ? void 0 : _a2.resource_id) === options.discountId;
438
- })) || ((_o = (_n = flatItem.parentProduct) == null ? void 0 : _n.discount_list) == null ? void 0 : _o.some((item) => {
445
+ })) || ((_p = (_o = flatItem.parentProduct) == null ? void 0 : _o.discount_list) == null ? void 0 : _p.some((item) => {
439
446
  var _a2;
440
447
  return ((_a2 = item.discount) == null ? void 0 : _a2.resource_id) === options.discountId;
441
448
  }))) {
@@ -444,7 +451,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
444
451
  }
445
452
  }
446
453
  if (options == null ? void 0 : options.selectedList) {
447
- if (flatItem.type === "main" && ((_p = product.discount_list) == null ? void 0 : _p.some((item) => {
454
+ if (flatItem.type === "main" && ((_q = product.discount_list) == null ? void 0 : _q.some((item) => {
448
455
  var _a2;
449
456
  return (_a2 = options == null ? void 0 : options.selectedList) == null ? void 0 : _a2.some((n) => {
450
457
  var _a3;
@@ -454,13 +461,13 @@ var RulesModule = class extends import_BaseModule.BaseModule {
454
461
  isManualDiscount = false;
455
462
  }
456
463
  if (flatItem.type === "bundle") {
457
- if (((_q = product.discount_list) == null ? void 0 : _q.some((item) => {
464
+ if (((_r = product.discount_list) == null ? void 0 : _r.some((item) => {
458
465
  var _a2;
459
466
  return (_a2 = options == null ? void 0 : options.selectedList) == null ? void 0 : _a2.some((n) => {
460
467
  var _a3;
461
468
  return n.discountId === ((_a3 = item.discount) == null ? void 0 : _a3.resource_id);
462
469
  });
463
- })) || ((_s = (_r = flatItem.parentProduct) == null ? void 0 : _r.discount_list) == null ? void 0 : _s.some((item) => {
470
+ })) || ((_t = (_s = flatItem.parentProduct) == null ? void 0 : _s.discount_list) == null ? void 0 : _t.some((item) => {
464
471
  var _a2;
465
472
  return (_a2 = options == null ? void 0 : options.selectedList) == null ? void 0 : _a2.some((n) => {
466
473
  var _a3;
@@ -547,10 +554,10 @@ var RulesModule = class extends import_BaseModule.BaseModule {
547
554
  usedDiscounts.set(selectedDiscount2.id, true);
548
555
  const appliedProducts = appliedDiscountProducts.get(selectedDiscount2.id) || [];
549
556
  let productOriginTotal = product.origin_total || product.total || 0;
550
- if (((_t = product.discount_list) == null ? void 0 : _t.length) && product.origin_total) {
557
+ if (((_u = product.discount_list) == null ? void 0 : _u.length) && product.origin_total) {
551
558
  productOriginTotal = product.origin_total;
552
559
  }
553
- if (Number(((_u = originProduct == null ? void 0 : originProduct._productInit) == null ? void 0 : _u.original_price) || 0) > 0 && product.origin_total && product.total && product.origin_total !== product.total) {
560
+ if (Number(((_v = originProduct == null ? void 0 : originProduct._productInit) == null ? void 0 : _v.original_price) || 0) > 0 && product.origin_total && product.total && product.origin_total !== product.total) {
554
561
  productOriginTotal = product.total;
555
562
  }
556
563
  const targetProductTotal = (0, import_utils.getDiscountAmount)(selectedDiscount2, product.price, product.price);
@@ -561,7 +568,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
561
568
  amount,
562
569
  type: selectedDiscount2.tag === "product_discount_card" ? "discount_card" : discountType,
563
570
  discount: {
564
- discount_card_type: (_v = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _v.discount_card_type,
571
+ discount_card_type: (_w = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _w.discount_card_type,
565
572
  fixed_amount: amount,
566
573
  resource_id: selectedDiscount2.id,
567
574
  title: selectedDiscount2.format_title,
@@ -683,7 +690,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
683
690
  amount: new import_decimal.default(productOriginTotal).minus(targetProductTotal).toNumber() * (product.num || 1),
684
691
  type: selectedDiscount2.tag === "product_discount_card" ? "discount_card" : selectedDiscount2.tag,
685
692
  discount: {
686
- discount_card_type: (_w = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _w.discount_card_type,
693
+ discount_card_type: (_x = selectedDiscount2 == null ? void 0 : selectedDiscount2.metadata) == null ? void 0 : _x.discount_card_type,
687
694
  fixed_amount: new import_decimal.default(productOriginTotal).minus(targetProductTotal).toNumber(),
688
695
  resource_id: selectedDiscount2.id,
689
696
  title: selectedDiscount2.format_title,
@@ -696,7 +703,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
696
703
  custom_product_bundle_map_id: uniqueId,
697
704
  num: product.num || 1
698
705
  },
699
- _num: (product.num || 1) * (((_x = flatItem == null ? void 0 : flatItem.parentProduct) == null ? void 0 : _x.num) || 1)
706
+ _num: (product.num || 1) * (((_y = flatItem == null ? void 0 : flatItem.parentProduct) == null ? void 0 : _y.num) || 1)
700
707
  };
701
708
  const appliedProducts = appliedDiscountProducts.get(selectedDiscount2.id) || [];
702
709
  appliedProducts.push(discountDetail);
@@ -315,6 +315,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
315
315
  end_at: dayjs.Dayjs;
316
316
  count: number;
317
317
  left: number;
318
+ summaryCount: number;
318
319
  }[];
319
320
  /**
320
321
  * 找到多个资源的公共可用时间段
@@ -1735,8 +1735,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1735
1735
  const resourcesUseableMap = {};
1736
1736
  let count = 0;
1737
1737
  let bookingLeft = 0;
1738
+ let summaryCount = 0;
1738
1739
  allProductResources == null ? void 0 : allProductResources.forEach((m) => {
1739
1740
  let currentResourcesCount = 0;
1741
+ let currentResourcesSummaryCount = 0;
1740
1742
  const currentResourcesTimeSlotCanUsedArr = [];
1741
1743
  const mTimes = m.times.filter((n) => {
1742
1744
  return !(0, import_dayjs.default)(n.start_at).isAfter((0, import_dayjs.default)(item.start), "minute") && !(0, import_dayjs.default)(n.end_at).isBefore((0, import_dayjs.default)(item.end), "minute") || (0, import_dayjs.default)(n.start_at).isBefore((0, import_dayjs.default)(item.end), "minute") && (0, import_dayjs.default)(n.end_at).isAfter((0, import_dayjs.default)(item.start), "minute");
@@ -1764,6 +1766,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1764
1766
  if (res.usable && res.remainingCapacity >= count && !m.onlyComputed) {
1765
1767
  currentResourcesCount = res.remainingCapacity;
1766
1768
  }
1769
+ if (res.usable && !m.onlyComputed && res.remainingCapacity >= currentResourcesSummaryCount) {
1770
+ currentResourcesSummaryCount = res.remainingCapacity;
1771
+ }
1767
1772
  currentResourcesTimeSlotCanUsedArr.push(res.usable);
1768
1773
  });
1769
1774
  if (!currentResourcesTimeSlotCanUsedArr.some(
@@ -1775,6 +1780,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1775
1780
  }
1776
1781
  if (!m.onlyComputed) {
1777
1782
  bookingLeft += 1;
1783
+ summaryCount += currentResourcesSummaryCount;
1778
1784
  }
1779
1785
  }
1780
1786
  });
@@ -1789,6 +1795,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1789
1795
  if (sameCartItems.length > 0 && sameCartItems.length >= currentResourcesSet.size || sameCartItems.length > bookingLeft) {
1790
1796
  bookingLeft = 0;
1791
1797
  count = 0;
1798
+ summaryCount = 0;
1792
1799
  }
1793
1800
  const otherCartItems = cartItems2.filter((m) => {
1794
1801
  var _a2, _b2, _c2;
@@ -1814,6 +1821,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1814
1821
  if (currentResourcesSet.size > 0 && otherCartItems.length + sameCartItems.length >= currentResourcesSet.size) {
1815
1822
  bookingLeft = 0;
1816
1823
  count = 0;
1824
+ summaryCount = 0;
1817
1825
  }
1818
1826
  } else {
1819
1827
  const sameCartItems = cartItems2.filter((m) => {
@@ -1825,6 +1833,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1825
1833
  if (sameCartNeedCapacity >= currentProductResourcesCapacity) {
1826
1834
  bookingLeft = 0;
1827
1835
  count = 0;
1836
+ summaryCount = 0;
1828
1837
  }
1829
1838
  const otherSameTimesCartItems = cartItems2.filter((m) => `${m.start_date} ${m.start_time}` === item.start && `${m.start_date} ${m.end_time}` === item.end);
1830
1839
  const otherCartNeedCapacity = otherSameTimesCartItems.reduce((acc, curr) => acc + (0, import_capacity.getCapacityInfoByCartItem)(curr).currentCapacity, 0);
@@ -1869,6 +1878,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1869
1878
  if (otherCartNeedCapacity + usedCapacity >= currentTypeResourcesCapacity) {
1870
1879
  bookingLeft = 0;
1871
1880
  count = 0;
1881
+ summaryCount = 0;
1872
1882
  }
1873
1883
  }
1874
1884
  });
@@ -1880,7 +1890,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1880
1890
  start_at: startDayJs,
1881
1891
  end_at: endDayJs,
1882
1892
  count,
1883
- left: bookingLeft
1893
+ left: bookingLeft,
1894
+ summaryCount
1884
1895
  };
1885
1896
  });
1886
1897
  return formatScheduleTimeSlots;
@@ -122,12 +122,6 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
122
122
  throw error;
123
123
  }
124
124
  }
125
- /**
126
- * 初始化外设扫码结果监听
127
- */
128
- initPeripheralsListener() {
129
- this.scan.initPeripheralsListener();
130
- }
131
125
  /**
132
126
  * 获取商品列表(不加载到模块中)
133
127
  * @returns 商品列表
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.1.61",
4
+ "version": "2.1.63",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",