@pisell/pisellos 1.0.108 → 1.0.110

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.
@@ -431,8 +431,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
431
431
 
432
432
  // 对扁平化后的列表按价格降序排序(用于应用优惠券时优先选择高价商品)
433
433
  var sortedFlattenedList = flattenedList.sort(function (a, b) {
434
- var priceA = new Decimal(a.price || '0');
435
- var priceB = new Decimal(b.price || '0');
434
+ var _ref3, _a$original_price, _ref4, _b$original_price;
435
+ // 子商品优先使用 original_price,主商品使用 price
436
+ 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');
437
+ 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');
436
438
  if (priceA.equals(priceB)) {
437
439
  // 价格相同时,主商品优先
438
440
  if (a.type !== b.type) {
@@ -943,8 +945,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
943
945
  var _product$discount_lis5, _product11, _product11$every;
944
946
  // 主商品:判断自身是否手动折扣
945
947
  isManualDiscount = typeof product.isManualDiscount === 'boolean' ? product.isManualDiscount : product.total != product.origin_total && (product.bundle || []).every(function (item) {
946
- var _ref3;
947
- return !((_ref3 = item.discount_list || []) !== null && _ref3 !== void 0 && _ref3.length);
948
+ var _ref5;
949
+ return !((_ref5 = item.discount_list || []) !== null && _ref5 !== void 0 && _ref5.length);
948
950
  }) && (!((_product$discount_lis5 = product.discount_list) !== null && _product$discount_lis5 !== void 0 && _product$discount_lis5.length) || ((_product11 = product) === null || _product11 === void 0 || (_product11 = _product11.discount_list) === null || _product11 === void 0 || (_product11$every = _product11.every) === null || _product11$every === void 0 ? void 0 : _product11$every.call(_product11, function (item) {
949
951
  return item.type === 'product';
950
952
  })));
@@ -954,8 +956,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
954
956
  if (parentProduct) {
955
957
  var _parentProduct$discou, _parentProduct$discou2, _parentProduct$discou3;
956
958
  isManualDiscount = typeof parentProduct.isManualDiscount === 'boolean' ? parentProduct.isManualDiscount : parentProduct.total != parentProduct.origin_total && (parentProduct.bundle || []).every(function (item) {
957
- var _ref4;
958
- return !((_ref4 = item.discount_list || []) !== null && _ref4 !== void 0 && _ref4.length);
959
+ var _ref6;
960
+ return !((_ref6 = item.discount_list || []) !== null && _ref6 !== void 0 && _ref6.length);
959
961
  }) && (!((_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) {
960
962
  return item.type === 'product';
961
963
  })));
@@ -316,6 +316,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
316
316
  end_at: dayjs.Dayjs;
317
317
  count: number;
318
318
  left: number;
319
+ summaryCount: number;
319
320
  }[];
320
321
  /**
321
322
  * 找到多个资源的公共可用时间段
@@ -2473,10 +2473,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2473
2473
  var resourcesUseableMap = {};
2474
2474
  var count = 0;
2475
2475
  var bookingLeft = 0;
2476
+ var summaryCount = 0;
2476
2477
  // 遍历所有资源
2477
2478
  allProductResources === null || allProductResources === void 0 || allProductResources.forEach(function (m) {
2478
2479
  // 遍历所有资源的上工时间片
2479
2480
  var currentResourcesCount = 0;
2481
+ var currentResourcesSummaryCount = 0;
2480
2482
  var currentResourcesTimeSlotCanUsedArr = [];
2481
2483
  // m.times 需要做个过滤,假设 timeSlice.start_at 是 09:30 timeSlice.end_at 是 11:30
2482
2484
  // time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
@@ -2514,6 +2516,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2514
2516
  if (res.usable && res.remainingCapacity >= count && !m.onlyComputed) {
2515
2517
  currentResourcesCount = res.remainingCapacity;
2516
2518
  }
2519
+ if (res.usable && !m.onlyComputed && res.remainingCapacity >= currentResourcesSummaryCount) {
2520
+ currentResourcesSummaryCount = res.remainingCapacity;
2521
+ }
2517
2522
  currentResourcesTimeSlotCanUsedArr.push(res.usable);
2518
2523
  });
2519
2524
  // 在已经选定时间的情况下,只要canUseTime如果有一个 false 那就不可用
@@ -2527,6 +2532,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2527
2532
  }
2528
2533
  if (!m.onlyComputed) {
2529
2534
  bookingLeft += 1;
2535
+ summaryCount += currentResourcesSummaryCount;
2530
2536
  }
2531
2537
  }
2532
2538
  });
@@ -2546,6 +2552,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2546
2552
  if (sameCartItems.length > 0 && sameCartItems.length >= currentResourcesSet.size || sameCartItems.length > bookingLeft) {
2547
2553
  bookingLeft = 0;
2548
2554
  count = 0;
2555
+ summaryCount = 0;
2549
2556
  }
2550
2557
  // 规则 2
2551
2558
  var otherCartItems = cartItems.filter(function (m) {
@@ -2580,6 +2587,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2580
2587
  if (currentResourcesSet.size > 0 && otherCartItems.length + sameCartItems.length >= currentResourcesSet.size) {
2581
2588
  bookingLeft = 0;
2582
2589
  count = 0;
2590
+ summaryCount = 0;
2583
2591
  }
2584
2592
  } else {
2585
2593
  // 多个预约的检测规则:
@@ -2597,6 +2605,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2597
2605
  if (sameCartNeedCapacity >= currentProductResourcesCapacity) {
2598
2606
  bookingLeft = 0;
2599
2607
  count = 0;
2608
+ summaryCount = 0;
2600
2609
  }
2601
2610
  // 规则2、不管是不是跟我一样的商品,只需要跟我当前商品有同一种类型的资源的同一时间的,把所有购物车的 capacity 之和 和 所有当前类型资源的 capacity 之和比较,如果超过了resourcesCapacity,则不可用
2602
2611
  // const otherCartItems = cartItems.filter((m) => m._productOrigin?.id?.toString() !== targetProductData?.id?.toString() && m.start_time === item.start && m.end_time === item.end);
@@ -2659,6 +2668,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2659
2668
  if (otherCartNeedCapacity + usedCapacity >= currentTypeResourcesCapacity) {
2660
2669
  bookingLeft = 0;
2661
2670
  count = 0;
2671
+ summaryCount = 0;
2662
2672
  }
2663
2673
  }
2664
2674
  });
@@ -2670,7 +2680,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2670
2680
  start_at: startDayJs,
2671
2681
  end_at: endDayJs,
2672
2682
  count: count,
2673
- left: bookingLeft
2683
+ left: bookingLeft,
2684
+ summaryCount: summaryCount
2674
2685
  };
2675
2686
  });
2676
2687
  return formatScheduleTimeSlots;
@@ -305,8 +305,12 @@ var RulesModule = class extends import_BaseModule.BaseModule {
305
305
  const flattenedList = flattenProductsWithBundle(productList);
306
306
  const sortedFlattenedList = flattenedList.sort((a, b) => {
307
307
  var _a, _b;
308
- const priceA = new import_decimal.default(a.price || "0");
309
- const priceB = new import_decimal.default(b.price || "0");
308
+ const priceA = new import_decimal.default(
309
+ a.type === "bundle" ? a.original_price ?? a.price ?? "0" : a.price || "0"
310
+ );
311
+ const priceB = new import_decimal.default(
312
+ b.type === "bundle" ? b.original_price ?? b.price ?? "0" : b.price || "0"
313
+ );
310
314
  if (priceA.equals(priceB)) {
311
315
  if (a.type !== b.type) {
312
316
  return a.type === "main" ? -1 : 1;
@@ -316,6 +316,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
316
316
  end_at: dayjs.Dayjs;
317
317
  count: number;
318
318
  left: number;
319
+ summaryCount: number;
319
320
  }[];
320
321
  /**
321
322
  * 找到多个资源的公共可用时间段
@@ -1738,8 +1738,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1738
1738
  const resourcesUseableMap = {};
1739
1739
  let count = 0;
1740
1740
  let bookingLeft = 0;
1741
+ let summaryCount = 0;
1741
1742
  allProductResources == null ? void 0 : allProductResources.forEach((m) => {
1742
1743
  let currentResourcesCount = 0;
1744
+ let currentResourcesSummaryCount = 0;
1743
1745
  const currentResourcesTimeSlotCanUsedArr = [];
1744
1746
  const mTimes = m.times.filter((n) => {
1745
1747
  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");
@@ -1767,6 +1769,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1767
1769
  if (res.usable && res.remainingCapacity >= count && !m.onlyComputed) {
1768
1770
  currentResourcesCount = res.remainingCapacity;
1769
1771
  }
1772
+ if (res.usable && !m.onlyComputed && res.remainingCapacity >= currentResourcesSummaryCount) {
1773
+ currentResourcesSummaryCount = res.remainingCapacity;
1774
+ }
1770
1775
  currentResourcesTimeSlotCanUsedArr.push(res.usable);
1771
1776
  });
1772
1777
  if (!currentResourcesTimeSlotCanUsedArr.some(
@@ -1778,6 +1783,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1778
1783
  }
1779
1784
  if (!m.onlyComputed) {
1780
1785
  bookingLeft += 1;
1786
+ summaryCount += currentResourcesSummaryCount;
1781
1787
  }
1782
1788
  }
1783
1789
  });
@@ -1792,6 +1798,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1792
1798
  if (sameCartItems.length > 0 && sameCartItems.length >= currentResourcesSet.size || sameCartItems.length > bookingLeft) {
1793
1799
  bookingLeft = 0;
1794
1800
  count = 0;
1801
+ summaryCount = 0;
1795
1802
  }
1796
1803
  const otherCartItems = cartItems2.filter((m) => {
1797
1804
  var _a2, _b2, _c2;
@@ -1817,6 +1824,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1817
1824
  if (currentResourcesSet.size > 0 && otherCartItems.length + sameCartItems.length >= currentResourcesSet.size) {
1818
1825
  bookingLeft = 0;
1819
1826
  count = 0;
1827
+ summaryCount = 0;
1820
1828
  }
1821
1829
  } else {
1822
1830
  const sameCartItems = cartItems2.filter((m) => {
@@ -1828,6 +1836,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1828
1836
  if (sameCartNeedCapacity >= currentProductResourcesCapacity) {
1829
1837
  bookingLeft = 0;
1830
1838
  count = 0;
1839
+ summaryCount = 0;
1831
1840
  }
1832
1841
  const otherSameTimesCartItems = cartItems2.filter((m) => `${m.start_date} ${m.start_time}` === item.start && `${m.start_date} ${m.end_time}` === item.end);
1833
1842
  const otherCartNeedCapacity = otherSameTimesCartItems.reduce((acc, curr) => acc + (0, import_capacity.getCapacityInfoByCartItem)(curr).currentCapacity, 0);
@@ -1872,6 +1881,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1872
1881
  if (otherCartNeedCapacity + usedCapacity >= currentTypeResourcesCapacity) {
1873
1882
  bookingLeft = 0;
1874
1883
  count = 0;
1884
+ summaryCount = 0;
1875
1885
  }
1876
1886
  }
1877
1887
  });
@@ -1883,7 +1893,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1883
1893
  start_at: startDayJs,
1884
1894
  end_at: endDayJs,
1885
1895
  count,
1886
- left: bookingLeft
1896
+ left: bookingLeft,
1897
+ summaryCount
1887
1898
  };
1888
1899
  });
1889
1900
  return formatScheduleTimeSlots;
@@ -122,6 +122,12 @@ 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
+ }
125
131
  /**
126
132
  * 获取商品列表(不加载到模块中)
127
133
  * @returns 商品列表
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "1.0.108",
4
+ "version": "1.0.110",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",