@pisell/pisellos 0.0.53 → 0.0.55
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.d.ts +4 -2
- package/dist/modules/Cart/index.js +28 -11
- package/dist/modules/Cart/types.d.ts +15 -0
- package/dist/modules/Cart/types.js +11 -0
- package/dist/modules/Cart/utils.d.ts +1 -0
- package/dist/modules/Cart/utils.js +9 -0
- package/dist/modules/Date/index.js +1 -3
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingByStep/index.js +35 -15
- package/lib/modules/Cart/index.d.ts +4 -2
- package/lib/modules/Cart/index.js +21 -7
- package/lib/modules/Cart/types.d.ts +15 -0
- package/lib/modules/Cart/types.js +11 -2
- package/lib/modules/Cart/utils.d.ts +1 -0
- package/lib/modules/Cart/utils.js +8 -0
- package/lib/modules/Date/index.js +2 -3
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingByStep/index.js +33 -20
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { CartItem, CartModuleAPI, IAddItemParams, IUpdateItemParams } from './types';
|
|
3
|
+
import { CartItem, CartModuleAPI, ECartItemInfoType, IAddItemParams, IUpdateItemParams } from './types';
|
|
4
4
|
export * from './types';
|
|
5
5
|
/**
|
|
6
6
|
* 购物车模块实现
|
|
@@ -57,8 +57,10 @@ export declare class CartModule extends BaseModule implements Module, CartModule
|
|
|
57
57
|
clearCartByAccount(account_id: string): void;
|
|
58
58
|
/**
|
|
59
59
|
* 清除购物车商品中的信息
|
|
60
|
+
* @param type 清除购物车商品中的信息类型
|
|
61
|
+
* @param _id 购物车商品ID
|
|
60
62
|
*/
|
|
61
|
-
deleteCartItemInfo(
|
|
63
|
+
deleteCartItemInfo(type: ECartItemInfoType, _id?: string): void;
|
|
62
64
|
/**
|
|
63
65
|
* 清除购物车
|
|
64
66
|
*/
|
|
@@ -22,7 +22,8 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
22
22
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
23
23
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
24
24
|
import { BaseModule } from "../BaseModule";
|
|
25
|
-
import {
|
|
25
|
+
import { ECartItemInfoType } from "./types";
|
|
26
|
+
import { createCartItemOrigin, deleteHolderFromCartItem, deleteRelationFormsFromCartItem, deleteResourceFromCartItem, deleteTimeFromCartItem, formatAccountToCartItem, formatDateToCartItem, formatDiscountToCartItem, formatNoteToCartItem, formatProductToCartItem, formatRelationFormsToCartItem, formatResourceToCartItem, getUniqueId } from "./utils";
|
|
26
27
|
import { cloneDeep } from 'lodash-es';
|
|
27
28
|
export * from "./types";
|
|
28
29
|
|
|
@@ -379,20 +380,36 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
379
380
|
|
|
380
381
|
/**
|
|
381
382
|
* 清除购物车商品中的信息
|
|
383
|
+
* @param type 清除购物车商品中的信息类型
|
|
384
|
+
* @param _id 购物车商品ID
|
|
382
385
|
*/
|
|
383
386
|
}, {
|
|
384
387
|
key: "deleteCartItemInfo",
|
|
385
|
-
value: function deleteCartItemInfo(
|
|
388
|
+
value: function deleteCartItemInfo(type, _id) {
|
|
386
389
|
var list = this.store.list.map(function (item) {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
390
|
+
var needDelete = _id ? item._id === _id : true;
|
|
391
|
+
|
|
392
|
+
// 如果存在_id,则只需要操作对应的购物车数据,否则操作所有
|
|
393
|
+
if (!needDelete) {
|
|
394
|
+
return item;
|
|
395
|
+
}
|
|
396
|
+
switch (type) {
|
|
397
|
+
case ECartItemInfoType.Resource:
|
|
398
|
+
// 清除购物车商品中的资源信息
|
|
399
|
+
item = deleteResourceFromCartItem(item);
|
|
400
|
+
break;
|
|
401
|
+
case ECartItemInfoType.Time:
|
|
402
|
+
// 清除购物车商品中的时间信息
|
|
403
|
+
item = deleteTimeFromCartItem(item);
|
|
404
|
+
break;
|
|
405
|
+
case ECartItemInfoType.RelationForms:
|
|
406
|
+
// 清除购物车商品中的关联表单信息
|
|
407
|
+
item = deleteRelationFormsFromCartItem(item);
|
|
408
|
+
break;
|
|
409
|
+
case ECartItemInfoType.Holder:
|
|
410
|
+
// 清除购物车商品中的账户信息
|
|
411
|
+
item = deleteHolderFromCartItem(item);
|
|
412
|
+
break;
|
|
396
413
|
}
|
|
397
414
|
return item;
|
|
398
415
|
});
|
|
@@ -7,6 +7,19 @@ export declare enum CartHooks {
|
|
|
7
7
|
OnCartUpdateItem = "card:onCartUpdateItem",
|
|
8
8
|
OnCartRemove = "card:onCartRemove"
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* 购物车商品信息类型
|
|
12
|
+
*/
|
|
13
|
+
export declare enum ECartItemInfoType {
|
|
14
|
+
/** 资源信息 */
|
|
15
|
+
Resource = "resource",
|
|
16
|
+
/** 时间信息 */
|
|
17
|
+
Time = "time",
|
|
18
|
+
/** 关联表单信息 */
|
|
19
|
+
RelationForms = "relationForms",
|
|
20
|
+
/** 账户信息 */
|
|
21
|
+
Holder = "holder"
|
|
22
|
+
}
|
|
10
23
|
export interface CartModuleAPI {
|
|
11
24
|
/** 添加商品到购物车 */
|
|
12
25
|
addItem: (item: IAddItemParams) => Promise<void>;
|
|
@@ -26,6 +39,8 @@ export interface CartModuleAPI {
|
|
|
26
39
|
getCartByAccount: (account_id: string) => CartItem[];
|
|
27
40
|
/** 清除购物车 */
|
|
28
41
|
clear: () => void;
|
|
42
|
+
/** 清除购物车商品中的信息 */
|
|
43
|
+
deleteCartItemInfo: (type: ECartItemInfoType, _id?: string) => void;
|
|
29
44
|
}
|
|
30
45
|
/**
|
|
31
46
|
* 购物车商品接口
|
|
@@ -6,6 +6,17 @@ export var CartHooks = /*#__PURE__*/function (CartHooks) {
|
|
|
6
6
|
return CartHooks;
|
|
7
7
|
}({});
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* 购物车商品信息类型
|
|
11
|
+
*/
|
|
12
|
+
export var ECartItemInfoType = /*#__PURE__*/function (ECartItemInfoType) {
|
|
13
|
+
ECartItemInfoType["Resource"] = "resource";
|
|
14
|
+
ECartItemInfoType["Time"] = "time";
|
|
15
|
+
ECartItemInfoType["RelationForms"] = "relationForms";
|
|
16
|
+
ECartItemInfoType["Holder"] = "holder";
|
|
17
|
+
return ECartItemInfoType;
|
|
18
|
+
}({});
|
|
19
|
+
|
|
9
20
|
/**
|
|
10
21
|
* 购物车商品接口
|
|
11
22
|
*/
|
|
@@ -251,3 +251,4 @@ export declare const deleteTimeFromCartItem: (cartItem: CartItem) => CartItem;
|
|
|
251
251
|
* @returns 删除后的购物车
|
|
252
252
|
*/
|
|
253
253
|
export declare const deleteRelationFormsFromCartItem: (cartItem: CartItem) => CartItem;
|
|
254
|
+
export declare const deleteHolderFromCartItem: (cartItem: CartItem) => CartItem;
|
|
@@ -671,4 +671,13 @@ export var deleteRelationFormsFromCartItem = function deleteRelationFormsFromCar
|
|
|
671
671
|
// 删除原始数据
|
|
672
672
|
cartItem._origin.relation_forms = null;
|
|
673
673
|
return cartItem;
|
|
674
|
+
};
|
|
675
|
+
export var deleteHolderFromCartItem = function deleteHolderFromCartItem(cartItem) {
|
|
676
|
+
// 删除UI层的数据
|
|
677
|
+
cartItem.holder_id = undefined;
|
|
678
|
+
cartItem.holder_title = undefined;
|
|
679
|
+
|
|
680
|
+
// 删除原始数据
|
|
681
|
+
cartItem._origin.holder = null;
|
|
682
|
+
return cartItem;
|
|
674
683
|
};
|
|
@@ -132,7 +132,7 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
132
132
|
case 5:
|
|
133
133
|
// 1.生成当前月份的所有日期,默认都是可用的
|
|
134
134
|
dates = generateMonthDates(start_date, end_date, type); // 如果没有资源或者结束日期在今天之前,则所有日期均不可用
|
|
135
|
-
if (!(!(resource_ids !== null && resource_ids !== void 0 && resource_ids.length) || dayjs(end_date).isBefore(dayjs()))) {
|
|
135
|
+
if (!(!(resource_ids !== null && resource_ids !== void 0 && resource_ids.length) || dayjs(end_date).isBefore(dayjs().startOf('day')))) {
|
|
136
136
|
_context3.next = 8;
|
|
137
137
|
break;
|
|
138
138
|
}
|
|
@@ -145,8 +145,6 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
145
145
|
end_date: end_date,
|
|
146
146
|
resource_ids: resource_ids,
|
|
147
147
|
front_end_cache_id: this.cacheId
|
|
148
|
-
}, {
|
|
149
|
-
useCache: true
|
|
150
148
|
});
|
|
151
149
|
case 11:
|
|
152
150
|
res = _context3.sent;
|
|
@@ -2,7 +2,7 @@ import { Module, PisellCore } from '../../types';
|
|
|
2
2
|
import { BaseModule } from '../../modules/BaseModule';
|
|
3
3
|
import { Response } from '../../plugins';
|
|
4
4
|
import { BookingByStepState } from './types';
|
|
5
|
-
import { CartItem, IUpdateItemParams, ProductData, ProductResourceItem } from '../../modules';
|
|
5
|
+
import { CartItem, IUpdateItemParams, ProductData, ProductResourceItem, ECartItemInfoType } from '../../modules';
|
|
6
6
|
import { Account } from '../../modules/Account/types';
|
|
7
7
|
import { IStep } from '../../modules/Step/tyeps';
|
|
8
8
|
import { TimeSliceItem } from './utils/resources';
|
|
@@ -130,7 +130,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
130
130
|
/**
|
|
131
131
|
* 从购物车中按类别删除信息
|
|
132
132
|
*/
|
|
133
|
-
deleteCartItemInfo(
|
|
133
|
+
deleteCartItemInfo(type: ECartItemInfoType, _id?: string): void;
|
|
134
134
|
destroy(): void;
|
|
135
135
|
getResourcesList(): any[];
|
|
136
136
|
getResourcesListByCartItem(id: string | number): {
|
|
@@ -244,6 +244,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
244
244
|
status: 'available',
|
|
245
245
|
week: '',
|
|
246
246
|
weekNum: 0
|
|
247
|
+
}, {
|
|
248
|
+
date: date,
|
|
249
|
+
status: 'available',
|
|
250
|
+
week: '',
|
|
251
|
+
weekNum: 0
|
|
247
252
|
}]);
|
|
248
253
|
scheduleIds = scheduleList.filter(function (n) {
|
|
249
254
|
return n.date === date;
|
|
@@ -656,22 +661,19 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
656
661
|
_schedule: this.store.currentProduct.getOtherParams()['schedule']
|
|
657
662
|
})];
|
|
658
663
|
}
|
|
659
|
-
|
|
660
|
-
return this.getDateRange();
|
|
661
|
-
case 8:
|
|
662
|
-
dateRange = _context13.sent;
|
|
664
|
+
dateRange = this.store.date.getDateRange();
|
|
663
665
|
tempStartDate = startDate || (dateRange === null || dateRange === void 0 ? void 0 : dateRange[0].date);
|
|
664
|
-
tempEndDate = endDate || (dateRange === null || dateRange === void 0 ? void 0 : dateRange[
|
|
666
|
+
tempEndDate = endDate || (dateRange === null || dateRange === void 0 ? void 0 : dateRange[1].date);
|
|
665
667
|
if (tempProducts.length) {
|
|
666
|
-
_context13.next =
|
|
668
|
+
_context13.next = 11;
|
|
667
669
|
break;
|
|
668
670
|
}
|
|
669
671
|
return _context13.abrupt("return", []);
|
|
670
|
-
case
|
|
672
|
+
case 11:
|
|
671
673
|
// 在这里需要把能收集到的数据都收集上来,拼装好给 date 模块去查询
|
|
672
674
|
_ref5 = getAvailableProductResources(tempProducts) || {}, resourceIds = _ref5.resourceIds, rules = _ref5.rules, resourcesMap = _ref5.resourcesMap;
|
|
673
675
|
this.otherParams.currentResourcesMap = resourcesMap;
|
|
674
|
-
_context13.next =
|
|
676
|
+
_context13.next = 15;
|
|
675
677
|
return this.store.date.getResourceDates({
|
|
676
678
|
url: params.url,
|
|
677
679
|
query: {
|
|
@@ -682,10 +684,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
682
684
|
rules: rules,
|
|
683
685
|
type: type
|
|
684
686
|
});
|
|
685
|
-
case
|
|
687
|
+
case 15:
|
|
686
688
|
res = _context13.sent;
|
|
687
689
|
return _context13.abrupt("return", res);
|
|
688
|
-
case
|
|
690
|
+
case 17:
|
|
689
691
|
case "end":
|
|
690
692
|
return _context13.stop();
|
|
691
693
|
}
|
|
@@ -1063,8 +1065,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1063
1065
|
*/
|
|
1064
1066
|
}, {
|
|
1065
1067
|
key: "deleteCartItemInfo",
|
|
1066
|
-
value: function deleteCartItemInfo(
|
|
1067
|
-
this.store.cart.deleteCartItemInfo(
|
|
1068
|
+
value: function deleteCartItemInfo(type, _id) {
|
|
1069
|
+
this.store.cart.deleteCartItemInfo(type, _id);
|
|
1068
1070
|
}
|
|
1069
1071
|
}, {
|
|
1070
1072
|
key: "destroy",
|
|
@@ -1547,7 +1549,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1547
1549
|
// 取出购物车中所有一已选择的第一步资源
|
|
1548
1550
|
var resources = [];
|
|
1549
1551
|
var cartItems = this.store.cart.getItems();
|
|
1550
|
-
if (cartItems
|
|
1552
|
+
// if (cartItems?.[0].start_date) return [];
|
|
1551
1553
|
var resourceIds = [];
|
|
1552
1554
|
cartItems.forEach(function (item) {
|
|
1553
1555
|
var _item$_productOrigin8;
|
|
@@ -1566,9 +1568,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1566
1568
|
var resourcesMap = getResourcesMap(resources);
|
|
1567
1569
|
var duration = 0;
|
|
1568
1570
|
// duration = 不同账号的最长时间
|
|
1569
|
-
this.store.accountList.getAccounts()
|
|
1571
|
+
var accountList = this.store.accountList.getAccounts();
|
|
1572
|
+
var checkDuration = function checkDuration(cartItems) {
|
|
1570
1573
|
var accountDuration = 0;
|
|
1571
|
-
var cartItems = _this8.store.cart.getCartByAccount(account.getId());
|
|
1572
1574
|
cartItems.forEach(function (item) {
|
|
1573
1575
|
var _item$_productOrigin$3, _item$_productOrigin9;
|
|
1574
1576
|
accountDuration += (_item$_productOrigin$3 = (_item$_productOrigin9 = item._productOrigin) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.duration) === null || _item$_productOrigin9 === void 0 ? void 0 : _item$_productOrigin9.value) !== null && _item$_productOrigin$3 !== void 0 ? _item$_productOrigin$3 : 0;
|
|
@@ -1576,6 +1578,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1576
1578
|
if (accountDuration > duration) {
|
|
1577
1579
|
duration = accountDuration;
|
|
1578
1580
|
}
|
|
1581
|
+
};
|
|
1582
|
+
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
1583
|
+
accountList.forEach(function (account) {
|
|
1584
|
+
var cartItems = _this8.store.cart.getCartByAccount(account.getId());
|
|
1585
|
+
checkDuration(cartItems);
|
|
1586
|
+
});
|
|
1587
|
+
} else {
|
|
1588
|
+
checkDuration(cartItems);
|
|
1589
|
+
}
|
|
1590
|
+
this.store.accountList.getAccounts().forEach(function (account) {
|
|
1591
|
+
var cartItems = _this8.store.cart.getCartByAccount(account.getId());
|
|
1579
1592
|
});
|
|
1580
1593
|
var timeSlots = getTimeSlicesByResources({
|
|
1581
1594
|
resourceIds: resourceIds,
|
|
@@ -1700,6 +1713,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1700
1713
|
var date = _ref13.date,
|
|
1701
1714
|
scheduleIds = _ref13.scheduleIds,
|
|
1702
1715
|
resources = _ref13.resources;
|
|
1716
|
+
debugger;
|
|
1703
1717
|
var targetProduct = this.store.currentProduct;
|
|
1704
1718
|
var targetProductData = targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.getData();
|
|
1705
1719
|
var targetSchedules = [];
|
|
@@ -1776,6 +1790,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1776
1790
|
var productData = _objectSpread(_objectSpread({}, origin), {}, {
|
|
1777
1791
|
product_variant_id: product_variant_id
|
|
1778
1792
|
});
|
|
1793
|
+
if (!account) {
|
|
1794
|
+
var activeAccount = this.getActiveAccount();
|
|
1795
|
+
if (activeAccount) {
|
|
1796
|
+
account = activeAccount;
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1779
1799
|
this.store.cart.addItem({
|
|
1780
1800
|
product: productData,
|
|
1781
1801
|
date: date,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { CartItem, CartModuleAPI, IAddItemParams, IUpdateItemParams } from './types';
|
|
3
|
+
import { CartItem, CartModuleAPI, ECartItemInfoType, IAddItemParams, IUpdateItemParams } from './types';
|
|
4
4
|
export * from './types';
|
|
5
5
|
/**
|
|
6
6
|
* 购物车模块实现
|
|
@@ -57,8 +57,10 @@ export declare class CartModule extends BaseModule implements Module, CartModule
|
|
|
57
57
|
clearCartByAccount(account_id: string): void;
|
|
58
58
|
/**
|
|
59
59
|
* 清除购物车商品中的信息
|
|
60
|
+
* @param type 清除购物车商品中的信息类型
|
|
61
|
+
* @param _id 购物车商品ID
|
|
60
62
|
*/
|
|
61
|
-
deleteCartItemInfo(
|
|
63
|
+
deleteCartItemInfo(type: ECartItemInfoType, _id?: string): void;
|
|
62
64
|
/**
|
|
63
65
|
* 清除购物车
|
|
64
66
|
*/
|
|
@@ -24,6 +24,7 @@ __export(Cart_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(Cart_exports);
|
|
26
26
|
var import_BaseModule = require("../BaseModule");
|
|
27
|
+
var import_types = require("./types");
|
|
27
28
|
var import_utils = require("./utils");
|
|
28
29
|
var import_lodash_es = require("lodash-es");
|
|
29
30
|
__reExport(Cart_exports, require("./types"), module.exports);
|
|
@@ -226,15 +227,28 @@ var CartModule = class extends import_BaseModule.BaseModule {
|
|
|
226
227
|
}
|
|
227
228
|
/**
|
|
228
229
|
* 清除购物车商品中的信息
|
|
230
|
+
* @param type 清除购物车商品中的信息类型
|
|
231
|
+
* @param _id 购物车商品ID
|
|
229
232
|
*/
|
|
230
|
-
deleteCartItemInfo(
|
|
233
|
+
deleteCartItemInfo(type, _id) {
|
|
231
234
|
const list = this.store.list.map((item) => {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
235
|
+
const needDelete = _id ? item._id === _id : true;
|
|
236
|
+
if (!needDelete) {
|
|
237
|
+
return item;
|
|
238
|
+
}
|
|
239
|
+
switch (type) {
|
|
240
|
+
case import_types.ECartItemInfoType.Resource:
|
|
241
|
+
item = (0, import_utils.deleteResourceFromCartItem)(item);
|
|
242
|
+
break;
|
|
243
|
+
case import_types.ECartItemInfoType.Time:
|
|
244
|
+
item = (0, import_utils.deleteTimeFromCartItem)(item);
|
|
245
|
+
break;
|
|
246
|
+
case import_types.ECartItemInfoType.RelationForms:
|
|
247
|
+
item = (0, import_utils.deleteRelationFormsFromCartItem)(item);
|
|
248
|
+
break;
|
|
249
|
+
case import_types.ECartItemInfoType.Holder:
|
|
250
|
+
item = (0, import_utils.deleteHolderFromCartItem)(item);
|
|
251
|
+
break;
|
|
238
252
|
}
|
|
239
253
|
return item;
|
|
240
254
|
});
|
|
@@ -7,6 +7,19 @@ export declare enum CartHooks {
|
|
|
7
7
|
OnCartUpdateItem = "card:onCartUpdateItem",
|
|
8
8
|
OnCartRemove = "card:onCartRemove"
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* 购物车商品信息类型
|
|
12
|
+
*/
|
|
13
|
+
export declare enum ECartItemInfoType {
|
|
14
|
+
/** 资源信息 */
|
|
15
|
+
Resource = "resource",
|
|
16
|
+
/** 时间信息 */
|
|
17
|
+
Time = "time",
|
|
18
|
+
/** 关联表单信息 */
|
|
19
|
+
RelationForms = "relationForms",
|
|
20
|
+
/** 账户信息 */
|
|
21
|
+
Holder = "holder"
|
|
22
|
+
}
|
|
10
23
|
export interface CartModuleAPI {
|
|
11
24
|
/** 添加商品到购物车 */
|
|
12
25
|
addItem: (item: IAddItemParams) => Promise<void>;
|
|
@@ -26,6 +39,8 @@ export interface CartModuleAPI {
|
|
|
26
39
|
getCartByAccount: (account_id: string) => CartItem[];
|
|
27
40
|
/** 清除购物车 */
|
|
28
41
|
clear: () => void;
|
|
42
|
+
/** 清除购物车商品中的信息 */
|
|
43
|
+
deleteCartItemInfo: (type: ECartItemInfoType, _id?: string) => void;
|
|
29
44
|
}
|
|
30
45
|
/**
|
|
31
46
|
* 购物车商品接口
|
|
@@ -19,7 +19,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
// src/modules/Cart/types.ts
|
|
20
20
|
var types_exports = {};
|
|
21
21
|
__export(types_exports, {
|
|
22
|
-
CartHooks: () => CartHooks
|
|
22
|
+
CartHooks: () => CartHooks,
|
|
23
|
+
ECartItemInfoType: () => ECartItemInfoType
|
|
23
24
|
});
|
|
24
25
|
module.exports = __toCommonJS(types_exports);
|
|
25
26
|
var CartHooks = /* @__PURE__ */ ((CartHooks2) => {
|
|
@@ -29,7 +30,15 @@ var CartHooks = /* @__PURE__ */ ((CartHooks2) => {
|
|
|
29
30
|
CartHooks2["OnCartRemove"] = "card:onCartRemove";
|
|
30
31
|
return CartHooks2;
|
|
31
32
|
})(CartHooks || {});
|
|
33
|
+
var ECartItemInfoType = /* @__PURE__ */ ((ECartItemInfoType2) => {
|
|
34
|
+
ECartItemInfoType2["Resource"] = "resource";
|
|
35
|
+
ECartItemInfoType2["Time"] = "time";
|
|
36
|
+
ECartItemInfoType2["RelationForms"] = "relationForms";
|
|
37
|
+
ECartItemInfoType2["Holder"] = "holder";
|
|
38
|
+
return ECartItemInfoType2;
|
|
39
|
+
})(ECartItemInfoType || {});
|
|
32
40
|
// Annotate the CommonJS export names for ESM import in node:
|
|
33
41
|
0 && (module.exports = {
|
|
34
|
-
CartHooks
|
|
42
|
+
CartHooks,
|
|
43
|
+
ECartItemInfoType
|
|
35
44
|
});
|
|
@@ -251,3 +251,4 @@ export declare const deleteTimeFromCartItem: (cartItem: CartItem) => CartItem;
|
|
|
251
251
|
* @returns 删除后的购物车
|
|
252
252
|
*/
|
|
253
253
|
export declare const deleteRelationFormsFromCartItem: (cartItem: CartItem) => CartItem;
|
|
254
|
+
export declare const deleteHolderFromCartItem: (cartItem: CartItem) => CartItem;
|
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
var utils_exports = {};
|
|
31
31
|
__export(utils_exports, {
|
|
32
32
|
createCartItemOrigin: () => createCartItemOrigin,
|
|
33
|
+
deleteHolderFromCartItem: () => deleteHolderFromCartItem,
|
|
33
34
|
deleteRelationFormsFromCartItem: () => deleteRelationFormsFromCartItem,
|
|
34
35
|
deleteResourceFromCartItem: () => deleteResourceFromCartItem,
|
|
35
36
|
deleteTimeFromCartItem: () => deleteTimeFromCartItem,
|
|
@@ -511,9 +512,16 @@ var deleteRelationFormsFromCartItem = (cartItem) => {
|
|
|
511
512
|
cartItem._origin.relation_forms = null;
|
|
512
513
|
return cartItem;
|
|
513
514
|
};
|
|
515
|
+
var deleteHolderFromCartItem = (cartItem) => {
|
|
516
|
+
cartItem.holder_id = void 0;
|
|
517
|
+
cartItem.holder_title = void 0;
|
|
518
|
+
cartItem._origin.holder = null;
|
|
519
|
+
return cartItem;
|
|
520
|
+
};
|
|
514
521
|
// Annotate the CommonJS export names for ESM import in node:
|
|
515
522
|
0 && (module.exports = {
|
|
516
523
|
createCartItemOrigin,
|
|
524
|
+
deleteHolderFromCartItem,
|
|
517
525
|
deleteRelationFormsFromCartItem,
|
|
518
526
|
deleteResourceFromCartItem,
|
|
519
527
|
deleteTimeFromCartItem,
|
|
@@ -85,7 +85,7 @@ var DateModule = class extends import_BaseModule.BaseModule {
|
|
|
85
85
|
return [];
|
|
86
86
|
}
|
|
87
87
|
let dates = (0, import_utils.generateMonthDates)(start_date, end_date, type);
|
|
88
|
-
if (!(resource_ids == null ? void 0 : resource_ids.length) || (0, import_dayjs.default)(end_date).isBefore((0, import_dayjs.default)())) {
|
|
88
|
+
if (!(resource_ids == null ? void 0 : resource_ids.length) || (0, import_dayjs.default)(end_date).isBefore((0, import_dayjs.default)().startOf("day"))) {
|
|
89
89
|
return (0, import_utils.disableAllDates)(dates);
|
|
90
90
|
}
|
|
91
91
|
try {
|
|
@@ -96,8 +96,7 @@ var DateModule = class extends import_BaseModule.BaseModule {
|
|
|
96
96
|
end_date,
|
|
97
97
|
resource_ids,
|
|
98
98
|
front_end_cache_id: this.cacheId
|
|
99
|
-
}
|
|
100
|
-
{ useCache: true }
|
|
99
|
+
}
|
|
101
100
|
);
|
|
102
101
|
if (!((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.length)) {
|
|
103
102
|
return (0, import_utils.disableAllDates)(dates);
|
|
@@ -2,7 +2,7 @@ import { Module, PisellCore } from '../../types';
|
|
|
2
2
|
import { BaseModule } from '../../modules/BaseModule';
|
|
3
3
|
import { Response } from '../../plugins';
|
|
4
4
|
import { BookingByStepState } from './types';
|
|
5
|
-
import { CartItem, IUpdateItemParams, ProductData, ProductResourceItem } from '../../modules';
|
|
5
|
+
import { CartItem, IUpdateItemParams, ProductData, ProductResourceItem, ECartItemInfoType } from '../../modules';
|
|
6
6
|
import { Account } from '../../modules/Account/types';
|
|
7
7
|
import { IStep } from '../../modules/Step/tyeps';
|
|
8
8
|
import { TimeSliceItem } from './utils/resources';
|
|
@@ -130,7 +130,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
130
130
|
/**
|
|
131
131
|
* 从购物车中按类别删除信息
|
|
132
132
|
*/
|
|
133
|
-
deleteCartItemInfo(
|
|
133
|
+
deleteCartItemInfo(type: ECartItemInfoType, _id?: string): void;
|
|
134
134
|
destroy(): void;
|
|
135
135
|
getResourcesList(): any[];
|
|
136
136
|
getResourcesListByCartItem(id: string | number): {
|
|
@@ -184,7 +184,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
184
184
|
product_ids
|
|
185
185
|
}) {
|
|
186
186
|
const scheduleList = this.store.schedule.getAvailabilityScheduleDateList();
|
|
187
|
-
this.setDateRange([{ date, status: "available", week: "", weekNum: 0 }]);
|
|
187
|
+
this.setDateRange([{ date, status: "available", week: "", weekNum: 0 }, { date, status: "available", week: "", weekNum: 0 }]);
|
|
188
188
|
const scheduleIds = scheduleList.filter((n) => n.date === date).flatMap((n) => n.schedule_id);
|
|
189
189
|
return await this.loadProducts({ schedule_ids: scheduleIds, product_ids });
|
|
190
190
|
}
|
|
@@ -345,9 +345,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
345
345
|
}
|
|
346
346
|
];
|
|
347
347
|
}
|
|
348
|
-
|
|
348
|
+
let dateRange = this.store.date.getDateRange();
|
|
349
349
|
const tempStartDate = startDate || (dateRange == null ? void 0 : dateRange[0].date);
|
|
350
|
-
const tempEndDate = endDate || (dateRange == null ? void 0 : dateRange[
|
|
350
|
+
const tempEndDate = endDate || (dateRange == null ? void 0 : dateRange[1].date);
|
|
351
351
|
if (!tempProducts.length) {
|
|
352
352
|
return [];
|
|
353
353
|
}
|
|
@@ -516,8 +516,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
516
516
|
/**
|
|
517
517
|
* 从购物车中按类别删除信息
|
|
518
518
|
*/
|
|
519
|
-
deleteCartItemInfo(
|
|
520
|
-
this.store.cart.deleteCartItemInfo(
|
|
519
|
+
deleteCartItemInfo(type, _id) {
|
|
520
|
+
this.store.cart.deleteCartItemInfo(type, _id);
|
|
521
521
|
}
|
|
522
522
|
destroy() {
|
|
523
523
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -944,8 +944,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
944
944
|
const dateRange = this.store.date.getDateRange();
|
|
945
945
|
const resources = [];
|
|
946
946
|
const cartItems = this.store.cart.getItems();
|
|
947
|
-
if (cartItems == null ? void 0 : cartItems[0].start_date)
|
|
948
|
-
return [];
|
|
949
947
|
const resourceIds = [];
|
|
950
948
|
cartItems.forEach((item) => {
|
|
951
949
|
var _a, _b, _c;
|
|
@@ -960,9 +958,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
960
958
|
});
|
|
961
959
|
const resourcesMap = (0, import_utils.getResourcesMap)(resources);
|
|
962
960
|
let duration = 0;
|
|
963
|
-
this.store.accountList.getAccounts()
|
|
961
|
+
const accountList = this.store.accountList.getAccounts();
|
|
962
|
+
const checkDuration = (cartItems2) => {
|
|
964
963
|
let accountDuration = 0;
|
|
965
|
-
const cartItems2 = this.store.cart.getCartByAccount(account.getId());
|
|
966
964
|
cartItems2.forEach((item) => {
|
|
967
965
|
var _a, _b;
|
|
968
966
|
accountDuration += ((_b = (_a = item._productOrigin) == null ? void 0 : _a.duration) == null ? void 0 : _b.value) ?? 0;
|
|
@@ -970,6 +968,17 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
970
968
|
if (accountDuration > duration) {
|
|
971
969
|
duration = accountDuration;
|
|
972
970
|
}
|
|
971
|
+
};
|
|
972
|
+
if (cartItems == null ? void 0 : cartItems[0].holder_id) {
|
|
973
|
+
accountList.forEach((account) => {
|
|
974
|
+
const cartItems2 = this.store.cart.getCartByAccount(account.getId());
|
|
975
|
+
checkDuration(cartItems2);
|
|
976
|
+
});
|
|
977
|
+
} else {
|
|
978
|
+
checkDuration(cartItems);
|
|
979
|
+
}
|
|
980
|
+
this.store.accountList.getAccounts().forEach((account) => {
|
|
981
|
+
const cartItems2 = this.store.cart.getCartByAccount(account.getId());
|
|
973
982
|
});
|
|
974
983
|
const timeSlots = (0, import_resources.getTimeSlicesByResources)({
|
|
975
984
|
resourceIds,
|
|
@@ -983,17 +992,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
983
992
|
// 提交时间切片,绑定到对应购物车的商品上,更新购物车
|
|
984
993
|
submitTimeSlot(timeSlots) {
|
|
985
994
|
const cartItems = this.store.cart.getItems();
|
|
986
|
-
const itemsByAccount = cartItems.reduce(
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
},
|
|
995
|
-
{}
|
|
996
|
-
);
|
|
995
|
+
const itemsByAccount = cartItems.reduce((acc, item) => {
|
|
996
|
+
const holderId = item.holder_id;
|
|
997
|
+
if (!acc[holderId]) {
|
|
998
|
+
acc[holderId] = [];
|
|
999
|
+
}
|
|
1000
|
+
acc[holderId].push(item);
|
|
1001
|
+
return acc;
|
|
1002
|
+
}, {});
|
|
997
1003
|
Object.values(itemsByAccount).forEach((accountItems) => {
|
|
998
1004
|
let currentStartTime = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
|
|
999
1005
|
accountItems.forEach((item, index) => {
|
|
@@ -1064,6 +1070,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1064
1070
|
resources
|
|
1065
1071
|
}) {
|
|
1066
1072
|
var _a, _b, _c;
|
|
1073
|
+
debugger;
|
|
1067
1074
|
const targetProduct = this.store.currentProduct;
|
|
1068
1075
|
const targetProductData = targetProduct == null ? void 0 : targetProduct.getData();
|
|
1069
1076
|
let targetSchedules = [];
|
|
@@ -1136,6 +1143,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1136
1143
|
}) {
|
|
1137
1144
|
const { bundle, options, origin, product_variant_id } = product || {};
|
|
1138
1145
|
const productData = { ...origin, product_variant_id };
|
|
1146
|
+
if (!account) {
|
|
1147
|
+
const activeAccount = this.getActiveAccount();
|
|
1148
|
+
if (activeAccount) {
|
|
1149
|
+
account = activeAccount;
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1139
1152
|
this.store.cart.addItem({
|
|
1140
1153
|
product: productData,
|
|
1141
1154
|
date,
|