@pisell/pisellos 3.0.35 → 3.0.37

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.
Files changed (53) hide show
  1. package/dist/modules/Cart/index.js +20 -34
  2. package/dist/modules/Cart/utils/cartAccount.d.ts +21 -0
  3. package/dist/modules/Cart/utils/cartAccount.js +52 -0
  4. package/dist/modules/Cart/utils/cartDate.d.ts +31 -0
  5. package/dist/modules/Cart/utils/cartDate.js +55 -0
  6. package/dist/modules/Cart/utils/cartDiscount.d.ts +19 -0
  7. package/dist/modules/Cart/utils/cartDiscount.js +35 -0
  8. package/dist/modules/Cart/utils/cartNote.d.ts +19 -0
  9. package/dist/modules/Cart/utils/cartNote.js +29 -0
  10. package/dist/modules/Cart/utils/cartProduct.d.ts +107 -0
  11. package/dist/modules/Cart/{utils.js → utils/cartProduct.js} +77 -416
  12. package/dist/modules/Cart/utils/cartRelationForms.d.ts +26 -0
  13. package/dist/modules/Cart/utils/cartRelationForms.js +29 -0
  14. package/dist/modules/Cart/utils/cartResource.d.ts +21 -0
  15. package/dist/modules/Cart/utils/cartResource.js +102 -0
  16. package/dist/modules/Cart/utils/index.d.ts +34 -0
  17. package/dist/modules/Cart/utils/index.js +63 -0
  18. package/dist/modules/Discount/index.js +2 -2
  19. package/dist/modules/Order/index.js +10 -4
  20. package/dist/modules/Product/types.d.ts +4 -0
  21. package/dist/modules/Product/utils.d.ts +17 -0
  22. package/dist/modules/Product/utils.js +41 -0
  23. package/dist/solution/BookingByStep/index.d.ts +8 -1
  24. package/dist/solution/BookingByStep/index.js +212 -78
  25. package/dist/solution/ShopDiscount/index.js +5 -4
  26. package/lib/modules/Cart/index.js +16 -24
  27. package/lib/modules/Cart/utils/cartAccount.d.ts +21 -0
  28. package/lib/modules/Cart/utils/cartAccount.js +65 -0
  29. package/lib/modules/Cart/utils/cartDate.d.ts +31 -0
  30. package/lib/modules/Cart/utils/cartDate.js +75 -0
  31. package/lib/modules/Cart/utils/cartDiscount.d.ts +19 -0
  32. package/lib/modules/Cart/utils/cartDiscount.js +52 -0
  33. package/lib/modules/Cart/utils/cartNote.d.ts +19 -0
  34. package/lib/modules/Cart/utils/cartNote.js +46 -0
  35. package/lib/modules/Cart/utils/cartProduct.d.ts +107 -0
  36. package/lib/modules/Cart/{utils.js → utils/cartProduct.js} +78 -328
  37. package/lib/modules/Cart/utils/cartRelationForms.d.ts +26 -0
  38. package/lib/modules/Cart/utils/cartRelationForms.js +48 -0
  39. package/lib/modules/Cart/utils/cartResource.d.ts +21 -0
  40. package/lib/modules/Cart/utils/cartResource.js +124 -0
  41. package/lib/modules/Cart/utils/index.d.ts +34 -0
  42. package/lib/modules/Cart/utils/index.js +91 -0
  43. package/lib/modules/Discount/index.js +3 -7
  44. package/lib/modules/Order/index.js +7 -3
  45. package/lib/modules/Product/types.d.ts +4 -0
  46. package/lib/modules/Product/utils.d.ts +17 -0
  47. package/lib/modules/Product/utils.js +46 -0
  48. package/lib/solution/BookingByStep/index.d.ts +8 -1
  49. package/lib/solution/BookingByStep/index.js +117 -47
  50. package/lib/solution/ShopDiscount/index.js +5 -9
  51. package/package.json +3 -3
  52. package/dist/modules/Cart/utils.d.ts +0 -257
  53. package/lib/modules/Cart/utils.d.ts +0 -257
@@ -43,6 +43,7 @@ var import_utils = require("../../modules/Resource/utils");
43
43
  var import_lodash_es = require("lodash-es");
44
44
  var import_utils2 = require("../../modules/Schedule/utils");
45
45
  var import_utils3 = require("../../modules/Date/utils");
46
+ var import_utils4 = require("../../modules/Product/utils");
46
47
  var import_timeslots = require("./utils/timeslots");
47
48
  import_dayjs.default.extend(import_isSameOrBefore.default);
48
49
  import_dayjs.default.extend(import_isSameOrAfter.default);
@@ -179,12 +180,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
179
180
  {
180
181
  open_quotation: 1,
181
182
  open_bundle: 0,
182
- extension_type: [
183
- "product_appointment",
184
- "appointment_ticket",
185
- "session_product",
186
- "session_ticket",
187
- "normal"
183
+ exclude_extension_type: [
184
+ "product_party",
185
+ "product_event",
186
+ "product_series_event",
187
+ "product_package_ticket",
188
+ "ticket",
189
+ "event_item"
188
190
  ],
189
191
  with: ["category", "collection", "resourceRelation"],
190
192
  status: "published",
@@ -214,11 +216,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
214
216
  { date, status: "available", week: "", weekNum: 0 },
215
217
  { date, status: "available", week: "", weekNum: 0 }
216
218
  ]);
217
- if (!(product_ids == null ? void 0 : product_ids.length)) {
218
- const schedule = scheduleList.find((n) => n.date === date);
219
- if (schedule && ((_a = schedule.product_ids) == null ? void 0 : _a.length)) {
220
- product_ids = schedule.product_ids;
221
- }
219
+ const schedule = scheduleList.find((n) => n.date === date);
220
+ if (schedule && ((_a = schedule.product_ids) == null ? void 0 : _a.length)) {
221
+ product_ids = schedule.product_ids;
222
222
  }
223
223
  const otherProductsIds = this.store.schedule.getOtherProductsIds() || [];
224
224
  const allProductIds = [...product_ids, ...otherProductsIds].filter(
@@ -281,6 +281,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
281
281
  bundle
282
282
  });
283
283
  }
284
+ this.core.effects.emit(`${this.store.cart.name}:onUpdateQuotationPrice`, {});
284
285
  }
285
286
  }
286
287
  // 加载当前店铺下所有 schedule
@@ -340,12 +341,30 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
340
341
  }
341
342
  async storeProduct(productData) {
342
343
  const activeAccount = this.getActiveAccount();
343
- const { bundle, options, origin, product_variant_id } = productData || {};
344
- const product = { ...origin, product_variant_id };
344
+ const { bundle, options, origin, product_variant_id, quantity = 1, rowKey } = productData || {};
345
+ const cartItems = this.store.cart.getItems();
346
+ if (rowKey) {
347
+ const targetCartItem = cartItems.find((n) => {
348
+ var _a;
349
+ return ((_a = n._productOrigin) == null ? void 0 : _a.rowKey) === rowKey;
350
+ });
351
+ if (targetCartItem && (0, import_utils4.isNormalProduct)(targetCartItem._productOrigin)) {
352
+ this.store.cart.updateItem({
353
+ _id: targetCartItem._id,
354
+ product: {
355
+ ...targetCartItem._productOrigin
356
+ },
357
+ quantity: (targetCartItem.num || 1) + quantity
358
+ });
359
+ return;
360
+ }
361
+ }
362
+ const product = { ...origin, product_variant_id, rowKey };
345
363
  const addCartItem = {
346
364
  product,
347
365
  bundle,
348
- options
366
+ options,
367
+ quantity
349
368
  };
350
369
  if (activeAccount) {
351
370
  addCartItem.account = activeAccount;
@@ -414,12 +433,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
414
433
  * @param params
415
434
  */
416
435
  async fetchHolderAccountsAsync(params) {
417
- var _a, _b, _c;
436
+ var _a, _b;
418
437
  const cartItems = this.store.cart.getItems();
419
438
  if (cartItems.length) {
420
439
  let date = (_b = (_a = this.store.date.getDateRange()) == null ? void 0 : _a[0]) == null ? void 0 : _b.date;
421
440
  if (!date) {
422
- date = ((_c = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _c.start_date) || "";
441
+ const normalProductCartItem = cartItems.find((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
442
+ date = (normalProductCartItem == null ? void 0 : normalProductCartItem.start_date) || "";
423
443
  }
424
444
  this.updateQuotationPriceAndCart(date);
425
445
  }
@@ -506,7 +526,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
506
526
  }
507
527
  // 如果用户登录
508
528
  async setLoginAccount(accountId, accountInfo) {
509
- var _a, _b, _c;
529
+ var _a, _b;
510
530
  const account = this.store.accountList.getAccount(accountId);
511
531
  if (account) {
512
532
  let stateAccountId = account.getId();
@@ -525,7 +545,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
525
545
  if (cartItems.length) {
526
546
  let date = (_b = (_a = this.store.date.getDateRange()) == null ? void 0 : _a[0]) == null ? void 0 : _b.date;
527
547
  if (!date) {
528
- date = ((_c = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _c.start_date) || "";
548
+ const normalProductCartItem = cartItems.find((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
549
+ date = (normalProductCartItem == null ? void 0 : normalProductCartItem.start_date) || "";
529
550
  }
530
551
  this.updateQuotationPriceAndCart(date);
531
552
  }
@@ -578,7 +599,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
578
599
  item._origin.number = currentCapacity;
579
600
  }
580
601
  });
581
- const type = this.otherParams.isRetailTemplate ? "virtual" : "appointment_booking";
602
+ let type = this.otherParams.isRetailTemplate ? "virtual" : "appointment_booking";
603
+ if ((0, import_utils4.areAllNormalProducts)(newCartItems.map((n) => n._productOrigin))) {
604
+ type = "virtual";
605
+ }
582
606
  return this.store.order.submitOrder({ query: { cartItems: newCartItems, type } });
583
607
  }
584
608
  // 拉起支付模块
@@ -755,7 +779,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
755
779
  * @returns 不符合条件的购物车商品ID列表
756
780
  */
757
781
  checkCartItems(type) {
758
- const cartItems = this.store.cart.getItems();
782
+ const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
759
783
  const errorCartItemIds = [];
760
784
  cartItems.forEach((cartItem) => {
761
785
  const result = this.store.cart.checkCartItemByType(cartItem, type);
@@ -794,7 +818,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
794
818
  });
795
819
  }
796
820
  const resourcesMap = (0, import_utils.getResourcesMap)((0, import_lodash_es.cloneDeep)(resources));
797
- const cartItems = this.store.cart.getItems();
821
+ const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
798
822
  const arr = [];
799
823
  cartItems.forEach((cartItem) => {
800
824
  var _a, _b, _c;
@@ -923,7 +947,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
923
947
  });
924
948
  }
925
949
  const resourcesMap = (0, import_utils.getResourcesMap)((0, import_lodash_es.cloneDeep)(resources));
926
- const cartItems = this.store.cart.getItems();
950
+ const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
927
951
  const arr = [];
928
952
  cartItems.forEach((cartItem) => {
929
953
  var _a, _b, _c;
@@ -1037,7 +1061,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1037
1061
  // 给单个购物车里的商品获取资源列表
1038
1062
  getResourcesListByCartItem(id) {
1039
1063
  var _a, _b, _c;
1040
- const cartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
1064
+ const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
1041
1065
  const dateRange = this.store.date.getDateRange();
1042
1066
  const resources = [];
1043
1067
  dateRange.forEach((n) => {
@@ -1120,6 +1144,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1120
1144
  capacity
1121
1145
  }) {
1122
1146
  var _a, _b, _c;
1147
+ if ((0, import_utils4.isNormalProduct)(cartItem._productOrigin)) {
1148
+ return {};
1149
+ }
1123
1150
  const dateRange = this.store.date.getDateRange();
1124
1151
  const cartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
1125
1152
  let accountCartItems = cartItems.filter((n) => n.holder_id === holder_id) || [];
@@ -1423,7 +1450,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1423
1450
  }
1424
1451
  });
1425
1452
  };
1426
- const cartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
1453
+ const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
1427
1454
  if (cartItems == null ? void 0 : cartItems[0].holder_id) {
1428
1455
  accountList.forEach((account) => {
1429
1456
  const cartItems2 = this.store.cart.getCartByAccount(account.getId());
@@ -1439,7 +1466,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1439
1466
  var _a, _b, _c, _d, _e, _f;
1440
1467
  let dateRange = this.store.date.getDateRange();
1441
1468
  const resources = [];
1442
- const cartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
1469
+ const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
1443
1470
  const resourceIds = [];
1444
1471
  let resourcesTypeId = void 0;
1445
1472
  let isSingleResource = false;
@@ -1537,7 +1564,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1537
1564
  }
1538
1565
  // 提交时间切片,绑定到对应购物车的商品上,更新购物车
1539
1566
  submitTimeSlot(timeSlots) {
1540
- const cartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
1567
+ const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
1541
1568
  const itemsByAccount = cartItems.reduce(
1542
1569
  (acc, item) => {
1543
1570
  const holderId = item.holder_id;
@@ -1623,7 +1650,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1623
1650
  resources,
1624
1651
  product
1625
1652
  }) {
1626
- var _a, _b, _c;
1653
+ var _a, _b, _c, _d, _e, _f;
1627
1654
  const targetProduct = this.store.currentProduct;
1628
1655
  const targetProductData = product || (targetProduct == null ? void 0 : targetProduct.getData());
1629
1656
  let targetSchedules = [];
@@ -1657,15 +1684,16 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1657
1684
  const scheduleTimeSlots = (0, import_utils2.getAllSortedDateRanges)(minTimeMaxTime);
1658
1685
  let allProductResources = productResources.flatMap((n) => n.renderList);
1659
1686
  allProductResources.sort((a, b) => {
1660
- var _a2, _b2, _c2, _d;
1687
+ var _a2, _b2, _c2, _d2;
1661
1688
  const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
1662
- const bIsCombined = ((_d = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d.status) === 1;
1689
+ const bIsCombined = ((_d2 = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d2.status) === 1;
1663
1690
  if (aIsCombined && !bIsCombined)
1664
1691
  return 1;
1665
1692
  if (!aIsCombined && bIsCombined)
1666
1693
  return -1;
1667
1694
  return 0;
1668
1695
  });
1696
+ const firstEnabledResourceId = (_f = (_e = (_d = targetProductData == null ? void 0 : targetProductData.product_resource) == null ? void 0 : _d.resources) == null ? void 0 : _e.find((n) => n.status === 1)) == null ? void 0 : _f.id;
1669
1697
  const formatScheduleTimeSlots = scheduleTimeSlots.map((item) => {
1670
1698
  const resourcesUseableMap = {};
1671
1699
  let count = 0;
@@ -1701,7 +1729,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1701
1729
  }
1702
1730
  currentResourcesTimeSlotCanUsedArr.push(res.usable);
1703
1731
  });
1704
- if (!currentResourcesTimeSlotCanUsedArr.some((n) => n === false)) {
1732
+ if (!currentResourcesTimeSlotCanUsedArr.some((n) => n === false) && m.form_id === firstEnabledResourceId) {
1705
1733
  if (currentResourcesCount >= count) {
1706
1734
  count = currentResourcesCount;
1707
1735
  }
@@ -1728,7 +1756,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1728
1756
  date,
1729
1757
  account
1730
1758
  }) {
1731
- const { bundle, options, origin, product_variant_id } = product || {};
1759
+ const { bundle, options, origin, product_variant_id, rowKey, quantity = 1 } = product || {};
1732
1760
  const productData = { ...origin, product_variant_id };
1733
1761
  if (!account) {
1734
1762
  const activeAccount = this.getActiveAccount();
@@ -1736,15 +1764,33 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1736
1764
  account = activeAccount;
1737
1765
  }
1738
1766
  }
1767
+ if (rowKey) {
1768
+ const cartItems = this.store.cart.getItems();
1769
+ const targetCartItem = cartItems.find((n) => {
1770
+ var _a;
1771
+ return ((_a = n._productOrigin) == null ? void 0 : _a.rowKey) === rowKey;
1772
+ });
1773
+ if (targetCartItem && (0, import_utils4.isNormalProduct)(targetCartItem._productOrigin)) {
1774
+ this.store.cart.updateItem({
1775
+ _id: targetCartItem._id,
1776
+ product: {
1777
+ ...targetCartItem._productOrigin,
1778
+ quantity: (targetCartItem.num || 1) + quantity
1779
+ }
1780
+ });
1781
+ return;
1782
+ }
1783
+ }
1739
1784
  this.store.cart.addItem({
1740
1785
  product: productData,
1741
1786
  date,
1742
1787
  account,
1743
1788
  bundle,
1744
- options
1789
+ options,
1790
+ quantity
1745
1791
  });
1746
1792
  if (date) {
1747
- const cartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
1793
+ const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
1748
1794
  const cartItemsByDate = cartItems.filter(
1749
1795
  (n) => !(0, import_dayjs.default)(n.start_date).isSame((0, import_dayjs.default)(date.startTime), "day")
1750
1796
  );
@@ -1800,7 +1846,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1800
1846
  });
1801
1847
  }
1802
1848
  const resourcesMap = (0, import_utils.getResourcesMap)((0, import_lodash_es.cloneDeep)(resources));
1803
- const cartItems = this.store.cart.getItems();
1849
+ const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
1804
1850
  const cartItem = cartItems.find((item) => item._id === cartItemId);
1805
1851
  if (!cartItem)
1806
1852
  return [];
@@ -1986,23 +2032,19 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1986
2032
  }
1987
2033
  async getAvailableDateForSessionOptimize(params = {}) {
1988
2034
  var _a, _b, _c, _d, _e, _f;
1989
- const cache = (_a = this.store.currentProduct) == null ? void 0 : _a.getOtherParams()["timeSlotBySchedule"];
1990
- if (cache) {
1991
- if ((0, import_dayjs.default)(params.startDate).isSameOrAfter((0, import_dayjs.default)(cache.startDate), "day") && (0, import_dayjs.default)(params.endDate).isSameOrBefore((0, import_dayjs.default)(cache.endDate), "day")) {
1992
- return {
1993
- dateList: cache.dateList,
1994
- firstAvailableDate: cache.firstAvailableDate
1995
- };
1996
- }
1997
- }
1998
2035
  let { startDate, endDate } = params;
1999
2036
  if ((0, import_dayjs.default)(startDate).isBefore((0, import_dayjs.default)(), "day") && ((0, import_dayjs.default)(endDate).isAfter((0, import_dayjs.default)(), "day") || (0, import_dayjs.default)(endDate).isSame((0, import_dayjs.default)(), "day"))) {
2000
2037
  startDate = (0, import_dayjs.default)().format("YYYY-MM-DD");
2001
2038
  }
2002
- endDate = (0, import_dayjs.default)().add(1, "month").format("YYYY-MM-DD");
2039
+ const endDateAfterMonth = (0, import_dayjs.default)().add(1, "month").format("YYYY-MM-DD");
2040
+ if ((0, import_dayjs.default)(startDate).add(7, "day").isAfter((0, import_dayjs.default)(endDateAfterMonth), "day")) {
2041
+ endDate = (0, import_dayjs.default)(startDate).add(7, "day").format("YYYY-MM-DD");
2042
+ } else {
2043
+ endDate = endDateAfterMonth;
2044
+ }
2003
2045
  let tempProducts;
2004
- tempProducts = (_b = this.store.currentProduct) == null ? void 0 : _b.getData();
2005
- const schedule = (_c = this.store.currentProduct) == null ? void 0 : _c.getOtherParams()["schedule"];
2046
+ tempProducts = (_a = this.store.currentProduct) == null ? void 0 : _a.getData();
2047
+ const schedule = (_b = this.store.currentProduct) == null ? void 0 : _b.getOtherParams()["schedule"];
2006
2048
  const filteredSchedule = (0, import_resources.filterScheduleByDateRange)(
2007
2049
  schedule,
2008
2050
  startDate || "",
@@ -2016,6 +2058,16 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2016
2058
  resource_ids: tempResourceIds
2017
2059
  }
2018
2060
  });
2061
+ const cache = (_c = this.store.currentProduct) == null ? void 0 : _c.getOtherParams()["timeSlotBySchedule"];
2062
+ if (cache) {
2063
+ if ((0, import_dayjs.default)(params.startDate).isSameOrAfter((0, import_dayjs.default)(cache.startDate), "day") && (0, import_dayjs.default)(params.endDate).isSameOrBefore((0, import_dayjs.default)(cache.endDate), "day")) {
2064
+ this.store.date.setDateList(cache.dateList);
2065
+ return {
2066
+ dateList: cache.dateList,
2067
+ firstAvailableDate: cache.firstAvailableDate
2068
+ };
2069
+ }
2070
+ }
2019
2071
  let dates = [];
2020
2072
  let currentDate = (0, import_dayjs.default)(startDate);
2021
2073
  let firstAvailableDate = "";
@@ -2122,13 +2174,31 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2122
2174
  dateList: dates,
2123
2175
  firstAvailableDate,
2124
2176
  startDate,
2125
- endDate
2177
+ endDate: (0, import_dayjs.default)(currentDate).format("YYYY-MM-DD")
2126
2178
  });
2127
2179
  return {
2128
2180
  dateList: dates,
2129
2181
  firstAvailableDate
2130
2182
  };
2131
2183
  }
2184
+ isCartAllNormalProducts() {
2185
+ const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
2186
+ return !cartItems.length;
2187
+ }
2188
+ isCartHasDurationProduct() {
2189
+ const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
2190
+ return cartItems.some((n) => {
2191
+ var _a;
2192
+ return (_a = n._productOrigin) == null ? void 0 : _a.duration;
2193
+ });
2194
+ }
2195
+ isTargetNormalProduct(product) {
2196
+ return (0, import_utils4.isNormalProduct)(product);
2197
+ }
2198
+ isTargetCartIdNormalProduct(id) {
2199
+ const cartItem = this.store.cart.getItems().find((n) => n._id === id);
2200
+ return cartItem && (0, import_utils4.isNormalProduct)(cartItem._productOrigin);
2201
+ }
2132
2202
  };
2133
2203
  // Annotate the CommonJS export names for ESM import in node:
2134
2204
  0 && (module.exports = {
@@ -27,7 +27,6 @@ var import_BaseModule = require("../../modules/BaseModule");
27
27
  var import_types = require("./types");
28
28
  var import_Discount = require("../../modules/Discount");
29
29
  var import_Rules = require("../../modules/Rules");
30
- var import_utils = require("./utils");
31
30
  var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
32
31
  constructor(name, version) {
33
32
  super(name, version);
@@ -173,7 +172,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
173
172
  isManualSelect: !isSelected
174
173
  };
175
174
  }
176
- return discount;
175
+ return { ...discount, isManualSelect: !(discount == null ? void 0 : discount.isSelected) };
177
176
  });
178
177
  this.setDiscountList(newDiscountList);
179
178
  return this.calcDiscount(this.store.productList || [], {
@@ -288,13 +287,10 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
288
287
  });
289
288
  }
290
289
  });
291
- const newDiscountList = (0, import_utils.uniqueById)(
292
- [
293
- ...editModeDiscountList,
294
- ...discountList.filter((item) => !item.isDisabled)
295
- ],
296
- "product_id"
297
- );
290
+ const newDiscountList = [
291
+ ...editModeDiscountList,
292
+ ...discountList.filter((item) => !item.isDisabled)
293
+ ];
298
294
  (_a = this.store.discount) == null ? void 0 : _a.setDiscountList(newDiscountList);
299
295
  this.emitDiscountListChange(newDiscountList);
300
296
  return newDiscountList;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "3.0.35",
4
+ "version": "3.0.37",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -22,7 +22,7 @@
22
22
  "docs": "typedoc --out docs src/index.ts",
23
23
  "sync": "node sync.js",
24
24
  "prepublishOnly": "npm run build",
25
- "deploy": "yarn run build && yarn run changeset && yarn run version && npm run release"
25
+ "deploy": "npm run build && npm run changeset && npm run version && npm run release"
26
26
  },
27
27
  "repository": {
28
28
  "type": "git",
@@ -67,4 +67,4 @@
67
67
  "publishConfig": {
68
68
  "access": "public"
69
69
  }
70
- }
70
+ }
@@ -1,257 +0,0 @@
1
- import { Account } from '../Account';
2
- import { ProductData } from '../Product/types';
3
- import { Resource } from '../Resource/types';
4
- import { CartItem, IDiscount } from './types';
5
- import Decimal from 'decimal.js';
6
- /**
7
- * 生成一个唯一的 ID
8
- */
9
- export declare const getUniqueId: (prefix?: string, maxLength?: number) => string;
10
- /**
11
- * 创建购物车原始数据
12
- */
13
- export declare const createCartItemOrigin: () => {
14
- id: number;
15
- number: number;
16
- registration_type: string;
17
- relation_products: never[];
18
- is_all: boolean;
19
- product: null;
20
- sub_type: null;
21
- duration: null;
22
- like_status: string;
23
- resources: null;
24
- schedule_id: number;
25
- start_date: null;
26
- start_time: null;
27
- select_date: null;
28
- end_time: null;
29
- end_date: null;
30
- metadata: {};
31
- holder: null;
32
- };
33
- /**
34
- * 格式化商品到购物车
35
- * @param product 商品
36
- * @returns 格式化后的商品
37
- */
38
- export declare const formatProductToCartItem: (params: {
39
- cartItem: CartItem;
40
- product: ProductData;
41
- bundle?: any;
42
- options?: any;
43
- product_variant_id?: number;
44
- }) => CartItem;
45
- export declare const formatProductToCartItemOrigin: (params: {
46
- cartItem: CartItem;
47
- product: ProductData;
48
- bundle?: any;
49
- options?: any;
50
- product_variant_id?: number;
51
- }) => any;
52
- /**
53
- * 格式化折扣到购物车
54
- * @param params 参数
55
- * @returns 格式化后的购物车
56
- */
57
- export declare const formatDiscountToCartItem: (params: {
58
- cartItem: CartItem;
59
- discounts: IDiscount[];
60
- }) => CartItem;
61
- /**
62
- * 格式化折扣到购物车原始数据
63
- * @param params 参数
64
- * @returns 格式化后的购物车原始数据
65
- */
66
- export declare const formatDiscountToCartItemOrigin: (params: {
67
- cartItem: CartItem;
68
- discounts: IDiscount[];
69
- }) => any;
70
- /**
71
- * 格式化账户到购物车
72
- * @param account 账户
73
- * @returns 格式化后的账户
74
- */
75
- export declare const formatAccountToCartItem: (params: {
76
- cartItem: CartItem;
77
- account: Account;
78
- }) => CartItem;
79
- export declare const formatAccountToCartItemOrigin: (params: {
80
- cartItem: CartItem;
81
- account: Account;
82
- }) => any;
83
- /**
84
- * 格式化资源到购物车
85
- * @param resource 资源
86
- * @returns 格式化后的资源
87
- */
88
- export declare const formatResourceToCartItem: (params: {
89
- cartItem: CartItem;
90
- resources: Resource[];
91
- }) => CartItem;
92
- export declare const formatResourceToCartItemOrigin: (params: {
93
- cartItem: CartItem;
94
- resources: Resource[];
95
- }) => any;
96
- /**
97
- * 格式化关联表单到购物车
98
- * @param params 参数
99
- * @returns 格式化后的购物车
100
- */
101
- export declare const formatRelationFormsToCartItem: (params: {
102
- cartItem: CartItem;
103
- relationForms: {
104
- form_id: number;
105
- form_record_ids: number[];
106
- }[];
107
- }) => CartItem;
108
- export declare const formatRelationFormsToCartItemOrigin: (params: {
109
- cartItem: CartItem;
110
- relationForms: {
111
- form_id: number;
112
- form_record_ids: number[];
113
- }[];
114
- }) => any;
115
- /**
116
- * 格式化日期到购物车
117
- * @param date 开始时间和结束时间
118
- * @returns 格式化后的日期
119
- */
120
- export declare const formatDateToCartItem: (params: {
121
- cartItem: CartItem;
122
- date: {
123
- startTime: string;
124
- endTime: string;
125
- };
126
- }) => CartItem;
127
- /**
128
- * 格式化日期到购物车原始数据
129
- * @param date 开始时间和结束时间
130
- * @returns 格式化后的日期原始数据
131
- */
132
- export declare const formatDateToCartItemOrigin: (params: {
133
- cartItem: CartItem;
134
- date: {
135
- startTime: string;
136
- endTime: string;
137
- };
138
- }) => any;
139
- /**
140
- * 格式化备注到购物车
141
- * @param params 参数
142
- * @returns 格式化后的购物车
143
- */
144
- export declare const formatNoteToCartItem: (params: {
145
- cartItem: CartItem;
146
- note: string;
147
- }) => CartItem;
148
- /**
149
- * 格式化备注到购物车原始数据
150
- * @param params 参数
151
- * @returns 格式化后的购物车原始数据
152
- */
153
- export declare const formatNoteToCartItemOrigin: (params: {
154
- cartItem: CartItem;
155
- note: string;
156
- }) => any;
157
- /**
158
- * 格式化套餐规格信息
159
- * @param options 套餐规格信息
160
- * @returns 格式化后的套餐规格信息
161
- */
162
- export declare const formatOptions: (options: any) => any;
163
- export declare const formatOptionsToOrigin: (options: any) => any;
164
- /**
165
- * 格式化商品套餐信息
166
- * @param bundle 商品套餐信息
167
- * @returns 格式化后的商品套餐信息
168
- */
169
- export declare const formatBundle: (bundle: any) => any;
170
- export declare const formatBundleToOrigin: (bundle: any) => any;
171
- /**
172
- * 判断是否是普通商品
173
- * @param product 商品
174
- * @returns 是否是普通商品
175
- */
176
- export declare const isNormalProduct: (product: any) => boolean;
177
- /**
178
- * 获取商品总价
179
- * @description 当前总价计算基于商品数量为1
180
- * @param item 商品
181
- * @returns 商品总价
182
- */
183
- export declare const getProductTotalPrice: (params: {
184
- product: ProductData;
185
- bundle?: any;
186
- options?: any;
187
- num?: number;
188
- }) => number;
189
- /**
190
- * 获取商品原始总价
191
- * @description 当前总价计算基于商品数量为1
192
- * @param item 商品
193
- * @returns 商品原始总价
194
- */
195
- export declare const getProductOriginTotalPrice: (params: {
196
- product: ProductData;
197
- bundle?: any;
198
- options?: any;
199
- num?: number;
200
- }) => number | undefined;
201
- /**
202
- * 获取商品定金
203
- * @description 定金基于商品售价来算,最终乘商品数量
204
- * 1、如果套餐主商品有定金规则,则定金为:(套餐商品总售价 * 定金百分比 + 定金固定金额)* 商品数量
205
- * 2、如果套餐主商品没有定金规则,子商品有定金规则,则定金为:(套餐子商品售价 * 套餐子商品定金百分比 + 套餐子商品定金固定金额)* 商品数量,最终将所有子商品定金相加
206
- * 3、普通商品/单规格商品/组合规则商品,定金规则:(商品总售价 * 定金百分比 + 定金固定金额)* 商品数量
207
- * @param params 参数
208
- * @returns 商品定金
209
- */
210
- export declare const getProductDeposit: (params: {
211
- cartItem: CartItem;
212
- product: ProductData;
213
- bundle?: any;
214
- options?: any;
215
- num?: number;
216
- }) => {
217
- total: number;
218
- protocols: {
219
- id: number;
220
- title: string;
221
- }[];
222
- } | null;
223
- /**
224
- * 计算商品定金
225
- * @param params 参数
226
- * @returns 商品定金
227
- */
228
- export declare const handleProductDeposit: (params: {
229
- depositData: {
230
- deposit_fixed?: string;
231
- deposit_percentage?: string;
232
- };
233
- total: string | number;
234
- num: number;
235
- }) => {
236
- result: boolean;
237
- depositTotal: Decimal;
238
- };
239
- /**
240
- * 从购物车中删除资源相关信息
241
- * @param cartItem 购物车
242
- * @returns 删除后的购物车
243
- */
244
- export declare const deleteResourceFromCartItem: (cartItem: CartItem) => CartItem;
245
- /**
246
- * 从购物车中删除时间
247
- * @param cartItem 购物车
248
- * @returns 删除后的购物车
249
- */
250
- export declare const deleteTimeFromCartItem: (cartItem: CartItem) => CartItem;
251
- /**
252
- * 从购物车中删除关联表单信息
253
- * @param cartItem 购物车
254
- * @returns 删除后的购物车
255
- */
256
- export declare const deleteRelationFormsFromCartItem: (cartItem: CartItem) => CartItem;
257
- export declare const deleteHolderFromCartItem: (cartItem: CartItem) => CartItem;