@pisell/pisellos 0.0.116 → 0.0.118
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.
- package/dist/modules/Cart/index.js +16 -35
- package/dist/modules/Cart/utils/cartAccount.d.ts +21 -0
- package/dist/modules/Cart/utils/cartAccount.js +52 -0
- package/dist/modules/Cart/utils/cartDate.d.ts +31 -0
- package/dist/modules/Cart/utils/cartDate.js +55 -0
- package/dist/modules/Cart/utils/cartDiscount.d.ts +19 -0
- package/dist/modules/Cart/utils/cartDiscount.js +35 -0
- package/dist/modules/Cart/utils/cartNote.d.ts +19 -0
- package/dist/modules/Cart/utils/cartNote.js +29 -0
- package/dist/modules/Cart/utils/cartProduct.d.ts +107 -0
- package/dist/modules/Cart/{utils.js → utils/cartProduct.js} +77 -416
- package/dist/modules/Cart/utils/cartRelationForms.d.ts +26 -0
- package/dist/modules/Cart/utils/cartRelationForms.js +29 -0
- package/dist/modules/Cart/utils/cartResource.d.ts +21 -0
- package/dist/modules/Cart/utils/cartResource.js +102 -0
- package/dist/modules/Cart/utils/index.d.ts +34 -0
- package/dist/modules/Cart/utils/index.js +63 -0
- package/dist/modules/Order/index.js +3 -2
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Product/types.d.ts +4 -0
- package/dist/modules/Product/utils.d.ts +17 -0
- package/dist/modules/Product/utils.js +41 -0
- package/dist/solution/BookingByStep/index.d.ts +25 -0
- package/dist/solution/BookingByStep/index.js +305 -56
- package/lib/modules/Cart/index.js +14 -25
- package/lib/modules/Cart/utils/cartAccount.d.ts +21 -0
- package/lib/modules/Cart/utils/cartAccount.js +65 -0
- package/lib/modules/Cart/utils/cartDate.d.ts +31 -0
- package/lib/modules/Cart/utils/cartDate.js +75 -0
- package/lib/modules/Cart/utils/cartDiscount.d.ts +19 -0
- package/lib/modules/Cart/utils/cartDiscount.js +52 -0
- package/lib/modules/Cart/utils/cartNote.d.ts +19 -0
- package/lib/modules/Cart/utils/cartNote.js +46 -0
- package/lib/modules/Cart/utils/cartProduct.d.ts +107 -0
- package/lib/modules/Cart/{utils.js → utils/cartProduct.js} +78 -328
- package/lib/modules/Cart/utils/cartRelationForms.d.ts +26 -0
- package/lib/modules/Cart/utils/cartRelationForms.js +48 -0
- package/lib/modules/Cart/utils/cartResource.d.ts +21 -0
- package/lib/modules/Cart/utils/cartResource.js +124 -0
- package/lib/modules/Cart/utils/index.d.ts +34 -0
- package/lib/modules/Cart/utils/index.js +91 -0
- package/lib/modules/Order/index.js +2 -1
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Product/types.d.ts +4 -0
- package/lib/modules/Product/utils.d.ts +17 -0
- package/lib/modules/Product/utils.js +46 -0
- package/lib/solution/BookingByStep/index.d.ts +25 -0
- package/lib/solution/BookingByStep/index.js +166 -21
- package/package.json +1 -1
- package/dist/modules/Cart/utils.d.ts +0 -257
- 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);
|
|
@@ -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
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
// 拉起支付模块
|
|
@@ -643,7 +667,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
643
667
|
var _a2;
|
|
644
668
|
if (item._id !== targetCartItem._id) {
|
|
645
669
|
const resources = (_a2 = item._origin.resources) == null ? void 0 : _a2.filter((m) => {
|
|
646
|
-
|
|
670
|
+
const sameFormIdResources = targetCartItem._origin.resources.filter((n) => n.form_id === m.form_id);
|
|
671
|
+
if (!(sameFormIdResources == null ? void 0 : sameFormIdResources.length)) {
|
|
672
|
+
return true;
|
|
673
|
+
}
|
|
674
|
+
return !sameFormIdResources.some((targetRes) => {
|
|
647
675
|
var _a3, _b, _c;
|
|
648
676
|
if (targetRes.resourceType !== "single") {
|
|
649
677
|
const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
|
|
@@ -656,10 +684,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
656
684
|
const originResource = allOriginResources.find(
|
|
657
685
|
(n) => n.id === targetRes.id
|
|
658
686
|
);
|
|
659
|
-
if (currentResourcesCapacityMap[
|
|
687
|
+
if (currentResourcesCapacityMap[m.id] + currentCapacity > (originResource == null ? void 0 : originResource.capacity)) {
|
|
660
688
|
return true;
|
|
661
689
|
}
|
|
662
|
-
currentResourcesCapacityMap[
|
|
690
|
+
currentResourcesCapacityMap[m.id] += currentCapacity;
|
|
663
691
|
return false;
|
|
664
692
|
}
|
|
665
693
|
if (item.holder_id !== (targetCartItem == null ? void 0 : targetCartItem.holder_id)) {
|
|
@@ -790,7 +818,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
790
818
|
});
|
|
791
819
|
}
|
|
792
820
|
const resourcesMap = (0, import_utils.getResourcesMap)((0, import_lodash_es.cloneDeep)(resources));
|
|
793
|
-
const cartItems = this.store.cart.getItems();
|
|
821
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
|
|
794
822
|
const arr = [];
|
|
795
823
|
cartItems.forEach((cartItem) => {
|
|
796
824
|
var _a, _b, _c;
|
|
@@ -919,7 +947,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
919
947
|
});
|
|
920
948
|
}
|
|
921
949
|
const resourcesMap = (0, import_utils.getResourcesMap)((0, import_lodash_es.cloneDeep)(resources));
|
|
922
|
-
const cartItems = this.store.cart.getItems();
|
|
950
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
|
|
923
951
|
const arr = [];
|
|
924
952
|
cartItems.forEach((cartItem) => {
|
|
925
953
|
var _a, _b, _c;
|
|
@@ -1033,7 +1061,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1033
1061
|
// 给单个购物车里的商品获取资源列表
|
|
1034
1062
|
getResourcesListByCartItem(id) {
|
|
1035
1063
|
var _a, _b, _c;
|
|
1036
|
-
const cartItems =
|
|
1064
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
|
|
1037
1065
|
const dateRange = this.store.date.getDateRange();
|
|
1038
1066
|
const resources = [];
|
|
1039
1067
|
dateRange.forEach((n) => {
|
|
@@ -1116,6 +1144,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1116
1144
|
capacity
|
|
1117
1145
|
}) {
|
|
1118
1146
|
var _a, _b, _c;
|
|
1147
|
+
if ((0, import_utils4.isNormalProduct)(cartItem._productOrigin)) {
|
|
1148
|
+
return {};
|
|
1149
|
+
}
|
|
1119
1150
|
const dateRange = this.store.date.getDateRange();
|
|
1120
1151
|
const cartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
1121
1152
|
let accountCartItems = cartItems.filter((n) => n.holder_id === holder_id) || [];
|
|
@@ -1420,7 +1451,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1420
1451
|
}
|
|
1421
1452
|
});
|
|
1422
1453
|
};
|
|
1423
|
-
const cartItems =
|
|
1454
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
|
|
1424
1455
|
if (cartItems == null ? void 0 : cartItems[0].holder_id) {
|
|
1425
1456
|
accountList.forEach((account) => {
|
|
1426
1457
|
const cartItems2 = this.store.cart.getCartByAccount(account.getId());
|
|
@@ -1436,7 +1467,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1436
1467
|
var _a, _b, _c, _d, _e, _f;
|
|
1437
1468
|
let dateRange = this.store.date.getDateRange();
|
|
1438
1469
|
const resources = [];
|
|
1439
|
-
const cartItems =
|
|
1470
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
|
|
1440
1471
|
const resourceIds = [];
|
|
1441
1472
|
let resourcesTypeId = void 0;
|
|
1442
1473
|
let isSingleResource = false;
|
|
@@ -1534,7 +1565,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1534
1565
|
}
|
|
1535
1566
|
// 提交时间切片,绑定到对应购物车的商品上,更新购物车
|
|
1536
1567
|
submitTimeSlot(timeSlots) {
|
|
1537
|
-
const cartItems =
|
|
1568
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
|
|
1538
1569
|
const itemsByAccount = cartItems.reduce(
|
|
1539
1570
|
(acc, item) => {
|
|
1540
1571
|
const holderId = item.holder_id;
|
|
@@ -1723,7 +1754,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1723
1754
|
date,
|
|
1724
1755
|
account
|
|
1725
1756
|
}) {
|
|
1726
|
-
const { bundle, options, origin, product_variant_id } = product || {};
|
|
1757
|
+
const { bundle, options, origin, product_variant_id, rowKey, quantity = 1 } = product || {};
|
|
1727
1758
|
const productData = { ...origin, product_variant_id };
|
|
1728
1759
|
if (!account) {
|
|
1729
1760
|
const activeAccount = this.getActiveAccount();
|
|
@@ -1731,15 +1762,33 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1731
1762
|
account = activeAccount;
|
|
1732
1763
|
}
|
|
1733
1764
|
}
|
|
1765
|
+
if (rowKey) {
|
|
1766
|
+
const cartItems = this.store.cart.getItems();
|
|
1767
|
+
const targetCartItem = cartItems.find((n) => {
|
|
1768
|
+
var _a;
|
|
1769
|
+
return ((_a = n._productOrigin) == null ? void 0 : _a.rowKey) === rowKey;
|
|
1770
|
+
});
|
|
1771
|
+
if (targetCartItem && (0, import_utils4.isNormalProduct)(targetCartItem._productOrigin)) {
|
|
1772
|
+
this.store.cart.updateItem({
|
|
1773
|
+
_id: targetCartItem._id,
|
|
1774
|
+
product: {
|
|
1775
|
+
...targetCartItem._productOrigin,
|
|
1776
|
+
quantity: (targetCartItem.num || 1) + quantity
|
|
1777
|
+
}
|
|
1778
|
+
});
|
|
1779
|
+
return;
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1734
1782
|
this.store.cart.addItem({
|
|
1735
1783
|
product: productData,
|
|
1736
1784
|
date,
|
|
1737
1785
|
account,
|
|
1738
1786
|
bundle,
|
|
1739
|
-
options
|
|
1787
|
+
options,
|
|
1788
|
+
quantity
|
|
1740
1789
|
});
|
|
1741
1790
|
if (date) {
|
|
1742
|
-
const cartItems =
|
|
1791
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
|
|
1743
1792
|
const cartItemsByDate = cartItems.filter(
|
|
1744
1793
|
(n) => !(0, import_dayjs.default)(n.start_date).isSame((0, import_dayjs.default)(date.startTime), "day")
|
|
1745
1794
|
);
|
|
@@ -1795,7 +1844,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1795
1844
|
});
|
|
1796
1845
|
}
|
|
1797
1846
|
const resourcesMap = (0, import_utils.getResourcesMap)((0, import_lodash_es.cloneDeep)(resources));
|
|
1798
|
-
const cartItems = this.store.cart.getItems();
|
|
1847
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
|
|
1799
1848
|
const cartItem = cartItems.find((item) => item._id === cartItemId);
|
|
1800
1849
|
if (!cartItem)
|
|
1801
1850
|
return [];
|
|
@@ -1897,6 +1946,88 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1897
1946
|
}
|
|
1898
1947
|
return targetResource.renderList;
|
|
1899
1948
|
}
|
|
1949
|
+
/**
|
|
1950
|
+
* 根据日期范围批量获取时间槽
|
|
1951
|
+
* @param params 参数对象
|
|
1952
|
+
* @returns Promise<Record<string, TimeSliceItem[]>> 返回日期到时间槽的映射
|
|
1953
|
+
*/
|
|
1954
|
+
async getTimeslotsScheduleByDateRange({
|
|
1955
|
+
startDate,
|
|
1956
|
+
endDate,
|
|
1957
|
+
scheduleIds,
|
|
1958
|
+
resources
|
|
1959
|
+
}) {
|
|
1960
|
+
console.log(
|
|
1961
|
+
"appoimentBooking-session-date-getTimeslotsScheduleByDateRange",
|
|
1962
|
+
{ startDate, endDate, scheduleIds, resources }
|
|
1963
|
+
);
|
|
1964
|
+
const dates = [];
|
|
1965
|
+
let currentDate = (0, import_dayjs.default)(startDate);
|
|
1966
|
+
const end = (0, import_dayjs.default)(endDate);
|
|
1967
|
+
while (currentDate.isSameOrBefore(end)) {
|
|
1968
|
+
dates.push(currentDate.format("YYYY-MM-DD"));
|
|
1969
|
+
currentDate = currentDate.add(1, "day");
|
|
1970
|
+
}
|
|
1971
|
+
const results = {};
|
|
1972
|
+
for (const date of dates) {
|
|
1973
|
+
results[date] = this.getTimeslotBySchedule({
|
|
1974
|
+
date,
|
|
1975
|
+
scheduleIds,
|
|
1976
|
+
resources
|
|
1977
|
+
});
|
|
1978
|
+
}
|
|
1979
|
+
return results;
|
|
1980
|
+
}
|
|
1981
|
+
async getAvailableDateForSession(params = {}) {
|
|
1982
|
+
let { startDate, endDate, type } = params;
|
|
1983
|
+
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"))) {
|
|
1984
|
+
startDate = (0, import_dayjs.default)().format("YYYY-MM-DD");
|
|
1985
|
+
}
|
|
1986
|
+
endDate = (0, import_dayjs.default)().add(1, "month").format("YYYY-MM-DD");
|
|
1987
|
+
let tempProducts = [];
|
|
1988
|
+
if (this.store.currentProduct) {
|
|
1989
|
+
tempProducts = [
|
|
1990
|
+
{
|
|
1991
|
+
...this.store.currentProduct.getData(),
|
|
1992
|
+
_schedule: this.store.currentProduct.getOtherParams()["schedule"]
|
|
1993
|
+
}
|
|
1994
|
+
];
|
|
1995
|
+
}
|
|
1996
|
+
const { resourceIds, rules, resourcesMap } = (0, import_products.getAvailableProductResources)(tempProducts) || {};
|
|
1997
|
+
this.otherParams.currentResourcesMap = resourcesMap;
|
|
1998
|
+
const res = await this.store.date.getResourceDates({
|
|
1999
|
+
query: {
|
|
2000
|
+
start_date: startDate || "",
|
|
2001
|
+
end_date: endDate || "",
|
|
2002
|
+
resource_ids: resourceIds
|
|
2003
|
+
},
|
|
2004
|
+
rules,
|
|
2005
|
+
type
|
|
2006
|
+
});
|
|
2007
|
+
if (this.store.currentProduct) {
|
|
2008
|
+
const dateListWithTimeSlots = await this.getTimeslotsScheduleByDateRange({
|
|
2009
|
+
startDate: startDate || "",
|
|
2010
|
+
endDate: endDate || ""
|
|
2011
|
+
});
|
|
2012
|
+
res.forEach((n) => {
|
|
2013
|
+
if (!dateListWithTimeSlots[n.date]) {
|
|
2014
|
+
n.status = "unavailable";
|
|
2015
|
+
} else {
|
|
2016
|
+
const allTimeSlotsCanUse = dateListWithTimeSlots[n.date].every(
|
|
2017
|
+
(d) => d.count
|
|
2018
|
+
);
|
|
2019
|
+
if (!allTimeSlotsCanUse) {
|
|
2020
|
+
n.status = "unavailable";
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
});
|
|
2024
|
+
}
|
|
2025
|
+
const firstAvailableDate = res.find((n) => n.status === "available");
|
|
2026
|
+
return {
|
|
2027
|
+
dateList: res,
|
|
2028
|
+
firstAvailableDate
|
|
2029
|
+
};
|
|
2030
|
+
}
|
|
1900
2031
|
async getAvailableDateForSessionOptimize(params = {}) {
|
|
1901
2032
|
var _a, _b, _c, _d, _e, _f;
|
|
1902
2033
|
const cache = (_a = this.store.currentProduct) == null ? void 0 : _a.getOtherParams()["timeSlotBySchedule"];
|
|
@@ -2033,6 +2164,20 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2033
2164
|
firstAvailableDate
|
|
2034
2165
|
};
|
|
2035
2166
|
}
|
|
2167
|
+
isCartAllNormalProducts() {
|
|
2168
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
|
|
2169
|
+
return !cartItems.length;
|
|
2170
|
+
}
|
|
2171
|
+
isCartHasDurationProduct() {
|
|
2172
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
|
|
2173
|
+
return cartItems.some((n) => {
|
|
2174
|
+
var _a;
|
|
2175
|
+
return (_a = n._productOrigin) == null ? void 0 : _a.duration;
|
|
2176
|
+
});
|
|
2177
|
+
}
|
|
2178
|
+
isTargetNormalProduct(product) {
|
|
2179
|
+
return (0, import_utils4.isNormalProduct)(product);
|
|
2180
|
+
}
|
|
2036
2181
|
};
|
|
2037
2182
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2038
2183
|
0 && (module.exports = {
|
package/package.json
CHANGED
|
@@ -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;
|