@pisell/pisellos 0.0.38 → 2.0.1
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/types.d.ts +0 -4
- package/dist/modules/Cart/utils.js +11 -25
- package/dist/modules/Product/index.d.ts +0 -10
- package/dist/modules/Product/index.js +0 -13
- package/dist/modules/Product/types.d.ts +0 -4
- package/dist/modules/Resource/types.d.ts +0 -1
- package/dist/modules/index.d.ts +0 -10
- package/dist/modules/index.js +1 -11
- package/dist/solution/BookingByStep/index.d.ts +3 -13
- package/dist/solution/BookingByStep/index.js +163 -300
- package/dist/solution/BookingByStep/types.d.ts +10 -3
- package/dist/solution/BookingByStep/types.js +7 -3
- package/dist/solution/BookingByStep/utils/resources.d.ts +4 -45
- package/dist/solution/BookingByStep/utils/resources.js +33 -167
- package/lib/modules/Cart/types.d.ts +0 -4
- package/lib/modules/Cart/utils.js +11 -26
- package/lib/modules/Product/index.d.ts +0 -10
- package/lib/modules/Product/index.js +0 -3
- package/lib/modules/Product/types.d.ts +0 -4
- package/lib/modules/Resource/types.d.ts +0 -1
- package/lib/modules/index.d.ts +0 -10
- package/lib/modules/index.js +1 -21
- package/lib/solution/BookingByStep/index.d.ts +3 -13
- package/lib/solution/BookingByStep/index.js +36 -91
- package/lib/solution/BookingByStep/types.d.ts +10 -3
- package/lib/solution/BookingByStep/types.js +12 -8
- package/lib/solution/BookingByStep/utils/resources.d.ts +4 -45
- package/lib/solution/BookingByStep/utils/resources.js +25 -115
- package/package.json +2 -2
- package/dist/modules/Schedule/index.d.ts +0 -13
- package/dist/modules/Schedule/index.js +0 -71
- package/dist/modules/Schedule/type.d.ts +0 -157
- package/dist/modules/Schedule/type.js +0 -1
- package/dist/modules/Schedule/types.d.ts +0 -182
- package/dist/modules/Schedule/types.js +0 -1
- package/dist/modules/Schedule/utils.d.ts +0 -61
- package/dist/modules/Schedule/utils.js +0 -700
- package/lib/modules/Schedule/index.d.ts +0 -13
- package/lib/modules/Schedule/index.js +0 -50
- package/lib/modules/Schedule/type.d.ts +0 -157
- package/lib/modules/Schedule/type.js +0 -17
- package/lib/modules/Schedule/types.d.ts +0 -182
- package/lib/modules/Schedule/types.js +0 -17
- package/lib/modules/Schedule/utils.d.ts +0 -61
- package/lib/modules/Schedule/utils.js +0 -572
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import { ProductList, CartModule
|
|
1
|
+
import { ProductList, CartModule } from "../../modules";
|
|
2
|
+
import { AccountModule } from "../../modules/Account";
|
|
3
|
+
import { AccountListModule } from "../../modules/AccountList";
|
|
4
|
+
import { DateModule } from "../../modules/Date";
|
|
5
|
+
import { GuestListModule } from "../../modules/Guests";
|
|
6
|
+
import { OrderModule } from "../../modules/Order";
|
|
7
|
+
import { PaymentModule } from "../../modules/Payment";
|
|
8
|
+
import { ResourceListModule } from "../../modules/Resource";
|
|
9
|
+
import { StepModule } from "../../modules/Step";
|
|
10
|
+
import { SummaryModule } from "../../modules/Summary";
|
|
2
11
|
export interface BookingByStepState {
|
|
3
12
|
cart: CartModule;
|
|
4
13
|
summary: SummaryModule;
|
|
@@ -11,8 +20,6 @@ export interface BookingByStepState {
|
|
|
11
20
|
accountList: AccountListModule;
|
|
12
21
|
order: OrderModule;
|
|
13
22
|
payment: PaymentModule;
|
|
14
|
-
currentProduct: Product;
|
|
15
|
-
schedule: ScheduleModule;
|
|
16
23
|
}
|
|
17
24
|
export declare function createModule<T extends keyof BookingByStepState>(moduleName: T, solutionName: string, name?: string, version?: string): BookingByStepState[T];
|
|
18
25
|
export declare enum BookingByStepHooks {
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import { ProductList, CartModule
|
|
1
|
+
import { ProductList, CartModule } from "../../modules";
|
|
2
|
+
import { AccountListModule } from "../../modules/AccountList";
|
|
3
|
+
import { DateModule } from "../../modules/Date";
|
|
4
|
+
import { OrderModule } from "../../modules/Order";
|
|
5
|
+
import { PaymentModule } from "../../modules/Payment";
|
|
6
|
+
import { StepModule } from "../../modules/Step";
|
|
7
|
+
import { SummaryModule } from "../../modules/Summary";
|
|
2
8
|
export function createModule(moduleName, solutionName, name, version) {
|
|
3
9
|
switch (moduleName) {
|
|
4
10
|
case "cart":
|
|
@@ -17,8 +23,6 @@ export function createModule(moduleName, solutionName, name, version) {
|
|
|
17
23
|
return new OrderModule("".concat(solutionName, "_").concat(name || moduleName), version);
|
|
18
24
|
case "payment":
|
|
19
25
|
return new PaymentModule("".concat(solutionName, "_").concat(name || moduleName), version);
|
|
20
|
-
case "schedule":
|
|
21
|
-
return new ScheduleModule("".concat(solutionName, "_").concat(name || moduleName), version);
|
|
22
26
|
default:
|
|
23
27
|
throw new Error("Unknown module type: ".concat(moduleName));
|
|
24
28
|
}
|
|
@@ -45,7 +45,8 @@ export declare const getIsUsableByTimeItem: ({ timeSlice, time, resource, curren
|
|
|
45
45
|
* @return {*}
|
|
46
46
|
* @Author: zhiwei.Wang
|
|
47
47
|
*/
|
|
48
|
-
export declare const getResourcesByProduct: (resourcesMap: Record<string, ResourceItem>,
|
|
48
|
+
export declare const getResourcesByProduct: (resourcesMap: Record<string, ResourceItem>, cartItem: CartItem, cartList: CartItem[]) => ResourceItem[];
|
|
49
|
+
export declare const getSumCapacity: () => number;
|
|
49
50
|
/**
|
|
50
51
|
* @title: 获取资源列表
|
|
51
52
|
* @description:
|
|
@@ -66,12 +67,11 @@ export declare const formatResources: ({ booking, resources }: {
|
|
|
66
67
|
* @return {*}
|
|
67
68
|
* @Author: zhiwei.Wang
|
|
68
69
|
*/
|
|
69
|
-
export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate
|
|
70
|
+
export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate }: {
|
|
70
71
|
resource: ResourceItem;
|
|
71
72
|
duration: number;
|
|
72
73
|
split: number;
|
|
73
74
|
currentDate: DateType | string;
|
|
74
|
-
capacity?: number | undefined;
|
|
75
75
|
}) => TimeSliceItem[];
|
|
76
76
|
/**
|
|
77
77
|
* @title: 获取时间切片列表的交集
|
|
@@ -100,52 +100,11 @@ export declare const getResourcesByIds: (resourcesMap: Record<string, ResourceIt
|
|
|
100
100
|
* @return {*}
|
|
101
101
|
* @Author: zhiwei.Wang
|
|
102
102
|
*/
|
|
103
|
-
export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split
|
|
103
|
+
export declare const getTimeSlicesByResources: ({ resourceIds, resourcesMap, duration, currentDate, split }: {
|
|
104
104
|
resourceIds: number[];
|
|
105
105
|
resourcesMap: any;
|
|
106
106
|
duration: number;
|
|
107
107
|
currentDate: DateType | string;
|
|
108
108
|
split: number;
|
|
109
|
-
capacity?: number | undefined;
|
|
110
109
|
}) => any[];
|
|
111
|
-
/**
|
|
112
|
-
* @title: 获取其他人的已选资源
|
|
113
|
-
* @description:
|
|
114
|
-
* @param {CartItem[]} cartItems
|
|
115
|
-
* @param {number | string} accountId
|
|
116
|
-
* @return {*}
|
|
117
|
-
* @Author: jinglin.tan
|
|
118
|
-
*/
|
|
119
|
-
export declare const getOthersSelectedResources: (cartItems: CartItem[], accountId: number | string, resourcesMap: Record<string, ResourceItem>) => number[];
|
|
120
|
-
interface CapacityItem {
|
|
121
|
-
id: number;
|
|
122
|
-
value: number;
|
|
123
|
-
name: string;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* @title: 基于选择的商品格式化容量
|
|
127
|
-
* @description:
|
|
128
|
-
* @param {any} param1
|
|
129
|
-
* @return {*}
|
|
130
|
-
* @Author: zhiwei.Wang
|
|
131
|
-
*/
|
|
132
|
-
export declare const formatDefaultCapacitys: ({ capacity, product_bundle }: any) => CapacityItem[];
|
|
133
|
-
/**
|
|
134
|
-
* @title: 获取总容量
|
|
135
|
-
* @description:
|
|
136
|
-
* @param {object} capacity 为 formatDefaultCapacitys()的结果
|
|
137
|
-
* @return {*}
|
|
138
|
-
* @Author: zhiwei.Wang
|
|
139
|
-
*/
|
|
140
|
-
export declare const getSumCapacity: ({ capacity }: {
|
|
141
|
-
capacity: CapacityItem[];
|
|
142
|
-
}) => number;
|
|
143
|
-
/**
|
|
144
|
-
* @title: 传入资源,如果有子资源,会根据组合资源的 capacity 计算修改子资源的 capacity
|
|
145
|
-
* @description:
|
|
146
|
-
* @param {object} resource
|
|
147
|
-
* @return {*}
|
|
148
|
-
* @Author: jinglin.tan
|
|
149
|
-
*/
|
|
150
|
-
export declare const checkSubResourcesCapacity: (resource: ResourceItem) => void;
|
|
151
110
|
export {};
|
|
@@ -191,56 +191,45 @@ export var getIsUsableByTimeItem = function getIsUsableByTimeItem(_ref2) {
|
|
|
191
191
|
* @return {*}
|
|
192
192
|
* @Author: zhiwei.Wang
|
|
193
193
|
*/
|
|
194
|
-
export var getResourcesByProduct = function getResourcesByProduct(resourcesMap,
|
|
195
|
-
var
|
|
196
|
-
|
|
194
|
+
export var getResourcesByProduct = function getResourcesByProduct(resourcesMap, cartItem, cartList) {
|
|
195
|
+
var _product$product_reso;
|
|
196
|
+
var product = cartItem._productOrigin;
|
|
197
|
+
return ((product === null || product === void 0 || (_product$product_reso = product.product_resource) === null || _product$product_reso === void 0 ? void 0 : _product$product_reso.resources) || []).reduce(function (acc, item) {
|
|
197
198
|
if ((item === null || item === void 0 ? void 0 : item.status) == 1) {
|
|
198
199
|
var form_id = item.id;
|
|
199
200
|
// 去重 可选资源和必选资源可能会有重复的
|
|
200
201
|
item.optional_resource = (item.optional_resource || []).filter(function (d) {
|
|
201
202
|
return item.default_resource.indexOf(d) == -1;
|
|
202
203
|
});
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
204
|
+
|
|
205
|
+
// 如果购物车里有 某一项的 resources 选中过了某些资源,则把这些资源给过滤掉
|
|
206
|
+
// 这里做一个拍平,把非当前 holder_id 的资源洗到一个数组里
|
|
207
|
+
var selectedResources = cartList.reduce(function (acc, d) {
|
|
208
|
+
if (d.holder_id !== cartItem.holder_id) {
|
|
209
|
+
var _d$_origin;
|
|
210
|
+
if ((_d$_origin = d._origin) !== null && _d$_origin !== void 0 && _d$_origin.resources) {
|
|
211
|
+
d._origin.resources.forEach(function (n) {
|
|
212
|
+
acc.push(n.id);
|
|
212
213
|
});
|
|
213
214
|
}
|
|
215
|
+
}
|
|
216
|
+
return acc;
|
|
217
|
+
}, []);
|
|
218
|
+
var optional_resource = item.optional_resource.reduce(function (childAcc, d) {
|
|
219
|
+
if (resourcesMap[d] && !selectedResources.includes(resourcesMap[d].id)) {
|
|
214
220
|
childAcc.push(Object.assign({}, resourcesMap[d], {
|
|
215
221
|
form_id: form_id,
|
|
216
|
-
resourceType: item.type
|
|
217
|
-
children: combiningResources,
|
|
218
|
-
metadata: _objectSpread(_objectSpread({}, resourcesMap[d].metadata), {}, {
|
|
219
|
-
combined_resource: resourcesMap[d].combined_resource
|
|
220
|
-
})
|
|
222
|
+
resourceType: item.type
|
|
221
223
|
}));
|
|
222
224
|
}
|
|
223
225
|
return childAcc;
|
|
224
226
|
}, []);
|
|
225
227
|
var default_resource = item.default_resource.reduce(function (childAcc, d) {
|
|
226
|
-
if (resourcesMap[d] && !selectedResources.includes(resourcesMap[d].id)
|
|
227
|
-
// 拼装组合资源的数据
|
|
228
|
-
var combiningResources = [];
|
|
229
|
-
if (resourcesMap[d].combined_resource && resourcesMap[d].combined_resource.status === 1) {
|
|
230
|
-
resourcesMap[d].combined_resource.resource_ids.forEach(function (id) {
|
|
231
|
-
if (resourcesMap[id]) {
|
|
232
|
-
combiningResources.push(resourcesMap[id]);
|
|
233
|
-
}
|
|
234
|
-
});
|
|
235
|
-
}
|
|
228
|
+
if (resourcesMap[d] && !selectedResources.includes(resourcesMap[d].id)) {
|
|
236
229
|
childAcc.push(Object.assign({}, resourcesMap[d], {
|
|
237
230
|
form_id: form_id,
|
|
238
231
|
resourceType: item.type,
|
|
239
|
-
is_default: 1
|
|
240
|
-
children: combiningResources,
|
|
241
|
-
metadata: _objectSpread(_objectSpread({}, resourcesMap[d].metadata), {}, {
|
|
242
|
-
combined_resource: resourcesMap[d].combined_resource
|
|
243
|
-
})
|
|
232
|
+
is_default: 1
|
|
244
233
|
}));
|
|
245
234
|
}
|
|
246
235
|
return childAcc;
|
|
@@ -260,6 +249,14 @@ export var getResourcesByProduct = function getResourcesByProduct(resourcesMap,
|
|
|
260
249
|
return acc;
|
|
261
250
|
}, []);
|
|
262
251
|
};
|
|
252
|
+
export var getSumCapacity = function getSumCapacity() {
|
|
253
|
+
// let sum = 0;
|
|
254
|
+
// for (let item of booking._extend.capacity || []) {
|
|
255
|
+
// sum += item.value;
|
|
256
|
+
// }
|
|
257
|
+
// 一期默认为1人
|
|
258
|
+
return 1;
|
|
259
|
+
};
|
|
263
260
|
|
|
264
261
|
/**
|
|
265
262
|
* @title: 获取资源列表
|
|
@@ -322,8 +319,7 @@ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref4) {
|
|
|
322
319
|
_ref4$split = _ref4.split,
|
|
323
320
|
split = _ref4$split === void 0 ? 10 : _ref4$split,
|
|
324
321
|
_ref4$currentDate = _ref4.currentDate,
|
|
325
|
-
currentDate = _ref4$currentDate === void 0 ? dayjs() : _ref4$currentDate
|
|
326
|
-
capacity = _ref4.capacity;
|
|
322
|
+
currentDate = _ref4$currentDate === void 0 ? dayjs() : _ref4$currentDate;
|
|
327
323
|
var times = resource.times;
|
|
328
324
|
|
|
329
325
|
// 存储所有时间切片
|
|
@@ -360,7 +356,7 @@ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref4) {
|
|
|
360
356
|
timeSlice: timeSlice,
|
|
361
357
|
time: time,
|
|
362
358
|
resource: resource,
|
|
363
|
-
currentCount:
|
|
359
|
+
currentCount: getSumCapacity()
|
|
364
360
|
});
|
|
365
361
|
if (_status.usable) {
|
|
366
362
|
// 添加时间切片 09:00 ~ 10:00 09:20 ~ 10:20 09:00 ~ 10:00 09:20 ~ 10:20 11:00 ~ 12:00 11:20 ~ 12:20
|
|
@@ -434,8 +430,7 @@ export var getTimeSlicesByResources = function getTimeSlicesByResources(_ref5) {
|
|
|
434
430
|
resourcesMap = _ref5.resourcesMap,
|
|
435
431
|
duration = _ref5.duration,
|
|
436
432
|
currentDate = _ref5.currentDate,
|
|
437
|
-
split = _ref5.split
|
|
438
|
-
capacity = _ref5.capacity;
|
|
433
|
+
split = _ref5.split;
|
|
439
434
|
// 获取资源列表
|
|
440
435
|
var resources = getResourcesByIds(resourcesMap, resourceIds);
|
|
441
436
|
|
|
@@ -445,140 +440,11 @@ export var getTimeSlicesByResources = function getTimeSlicesByResources(_ref5) {
|
|
|
445
440
|
resource: item,
|
|
446
441
|
duration: duration,
|
|
447
442
|
split: split,
|
|
448
|
-
currentDate: currentDate
|
|
449
|
-
capacity: capacity
|
|
443
|
+
currentDate: currentDate
|
|
450
444
|
}));
|
|
451
445
|
}, []);
|
|
452
446
|
|
|
453
447
|
// 获取时间切片列表的交集
|
|
454
448
|
var intersection = getTimesIntersection(timeSliceList, resources.length);
|
|
455
449
|
return intersection;
|
|
456
|
-
};
|
|
457
|
-
|
|
458
|
-
/**
|
|
459
|
-
* @title: 获取其他人的已选资源
|
|
460
|
-
* @description:
|
|
461
|
-
* @param {CartItem[]} cartItems
|
|
462
|
-
* @param {number | string} accountId
|
|
463
|
-
* @return {*}
|
|
464
|
-
* @Author: jinglin.tan
|
|
465
|
-
*/
|
|
466
|
-
export var getOthersSelectedResources = function getOthersSelectedResources(cartItems, accountId, resourcesMap) {
|
|
467
|
-
return cartItems.reduce(function (acc, d) {
|
|
468
|
-
if (d.holder_id !== accountId) {
|
|
469
|
-
var _d$_origin;
|
|
470
|
-
if ((_d$_origin = d._origin) !== null && _d$_origin !== void 0 && _d$_origin.resources) {
|
|
471
|
-
d._origin.resources.forEach(function (n) {
|
|
472
|
-
// 如果是组合资源,还需要检查组合资源里子资源是否被占用过
|
|
473
|
-
if (n.metadata.combined_resource && n.metadata.combined_resource.status === 1) {
|
|
474
|
-
// 如果组合资源里子资源被占用过,则这个资源不可以进待选列表了
|
|
475
|
-
if (n.metadata.combined_resource.resource_ids.some(function (m) {
|
|
476
|
-
return acc.includes(m);
|
|
477
|
-
})) {
|
|
478
|
-
return acc;
|
|
479
|
-
}
|
|
480
|
-
acc.push.apply(acc, _toConsumableArray(n.metadata.combined_resource.resource_ids));
|
|
481
|
-
} else {
|
|
482
|
-
// 如果当前选中的不是组合资源,但是是别的组合资源里的子资源,则还需要把别的组合资源也加进来
|
|
483
|
-
// 去 resourcesMap 里找一下 n.id 是不是别的组合资源里的子资源,是的话把别的组合资源也加进来
|
|
484
|
-
Object.values(resourcesMap).forEach(function (m) {
|
|
485
|
-
if (m.combined_resource && m.combined_resource.status === 1) {
|
|
486
|
-
if (m.combined_resource.resource_ids.includes(n.id)) {
|
|
487
|
-
acc.push(m.id);
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
});
|
|
491
|
-
}
|
|
492
|
-
acc.push(n.id);
|
|
493
|
-
});
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
return acc;
|
|
497
|
-
}, []);
|
|
498
|
-
};
|
|
499
|
-
/**
|
|
500
|
-
* @title: 基于选择的商品格式化容量
|
|
501
|
-
* @description:
|
|
502
|
-
* @param {any} param1
|
|
503
|
-
* @return {*}
|
|
504
|
-
* @Author: zhiwei.Wang
|
|
505
|
-
*/
|
|
506
|
-
export var formatDefaultCapacitys = function formatDefaultCapacitys(_ref6) {
|
|
507
|
-
var capacity = _ref6.capacity,
|
|
508
|
-
product_bundle = _ref6.product_bundle;
|
|
509
|
-
if ((capacity === null || capacity === void 0 ? void 0 : capacity.type) === 'package') {
|
|
510
|
-
return (product_bundle || []).map(function (d) {
|
|
511
|
-
var id = d.bundle_product_id;
|
|
512
|
-
var item = ((capacity === null || capacity === void 0 ? void 0 : capacity.package) || []).find(function (item) {
|
|
513
|
-
return item.product_id === id;
|
|
514
|
-
});
|
|
515
|
-
return {
|
|
516
|
-
id: id,
|
|
517
|
-
value: item ? d.num || 0 : 0,
|
|
518
|
-
name: (item === null || item === void 0 ? void 0 : item.name) || (d === null || d === void 0 ? void 0 : d.title)
|
|
519
|
-
};
|
|
520
|
-
});
|
|
521
|
-
}
|
|
522
|
-
if ((capacity === null || capacity === void 0 ? void 0 : capacity.type) === 'custom') {
|
|
523
|
-
return ((capacity === null || capacity === void 0 ? void 0 : capacity.custom) || []).map(function (d) {
|
|
524
|
-
return {
|
|
525
|
-
id: d.id,
|
|
526
|
-
value: d.min,
|
|
527
|
-
name: d.name
|
|
528
|
-
};
|
|
529
|
-
});
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
// 默认为1
|
|
533
|
-
return [{
|
|
534
|
-
id: 0,
|
|
535
|
-
value: 1,
|
|
536
|
-
name: ''
|
|
537
|
-
}];
|
|
538
|
-
};
|
|
539
|
-
|
|
540
|
-
/**
|
|
541
|
-
* @title: 获取总容量
|
|
542
|
-
* @description:
|
|
543
|
-
* @param {object} capacity 为 formatDefaultCapacitys()的结果
|
|
544
|
-
* @return {*}
|
|
545
|
-
* @Author: zhiwei.Wang
|
|
546
|
-
*/
|
|
547
|
-
export var getSumCapacity = function getSumCapacity(_ref7) {
|
|
548
|
-
var capacity = _ref7.capacity;
|
|
549
|
-
var sum = 0;
|
|
550
|
-
var _iterator2 = _createForOfIteratorHelper(capacity || []),
|
|
551
|
-
_step2;
|
|
552
|
-
try {
|
|
553
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
554
|
-
var item = _step2.value;
|
|
555
|
-
sum += item.value;
|
|
556
|
-
}
|
|
557
|
-
} catch (err) {
|
|
558
|
-
_iterator2.e(err);
|
|
559
|
-
} finally {
|
|
560
|
-
_iterator2.f();
|
|
561
|
-
}
|
|
562
|
-
return sum;
|
|
563
|
-
};
|
|
564
|
-
|
|
565
|
-
/**
|
|
566
|
-
* @title: 传入资源,如果有子资源,会根据组合资源的 capacity 计算修改子资源的 capacity
|
|
567
|
-
* @description:
|
|
568
|
-
* @param {object} resource
|
|
569
|
-
* @return {*}
|
|
570
|
-
* @Author: jinglin.tan
|
|
571
|
-
*/
|
|
572
|
-
export var checkSubResourcesCapacity = function checkSubResourcesCapacity(resource) {
|
|
573
|
-
if (resource.children && resource.children.length) {
|
|
574
|
-
var countCapacity = resource.capacity;
|
|
575
|
-
resource.children.forEach(function (child) {
|
|
576
|
-
if (child.capacity <= countCapacity) {
|
|
577
|
-
countCapacity -= child.capacity;
|
|
578
|
-
} else {
|
|
579
|
-
child.capacity = countCapacity;
|
|
580
|
-
countCapacity = 0;
|
|
581
|
-
}
|
|
582
|
-
});
|
|
583
|
-
}
|
|
584
450
|
};
|
|
@@ -77,7 +77,7 @@ var createCartItemOrigin = () => {
|
|
|
77
77
|
// 资源相关
|
|
78
78
|
// 资源状态 -固定
|
|
79
79
|
like_status: "common",
|
|
80
|
-
// 资源类型 -
|
|
80
|
+
// // 资源类型 - 固定----谭景琳备注:马天宇说现在平行资源是不传这个的
|
|
81
81
|
// relation_type: "form",
|
|
82
82
|
// 所选资源
|
|
83
83
|
resources: null,
|
|
@@ -213,32 +213,17 @@ var formatResourceToCartItemOrigin = (params) => {
|
|
|
213
213
|
let origin = cartItem._origin;
|
|
214
214
|
if (resources && (resources == null ? void 0 : resources.length)) {
|
|
215
215
|
origin.resources = [];
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
like_status: "common",
|
|
226
|
-
id: resource.id,
|
|
227
|
-
main_field: resource.main_field,
|
|
228
|
-
resourceType: resource.resourceType,
|
|
229
|
-
form_id: resource.form_id,
|
|
230
|
-
relation_id: resource.id,
|
|
231
|
-
capacity: (resource == null ? void 0 : resource.capacity) || 0,
|
|
232
|
-
metadata: (resource == null ? void 0 : resource.metadata) || {}
|
|
233
|
-
// 后端可以在这里挂一个前端用于计算的数据
|
|
234
|
-
};
|
|
235
|
-
if (childArr.length) {
|
|
236
|
-
obj.children = childArr;
|
|
237
|
-
}
|
|
238
|
-
arr.push(obj);
|
|
216
|
+
resources.forEach((resource) => {
|
|
217
|
+
origin.resources.push({
|
|
218
|
+
like_status: "common",
|
|
219
|
+
id: resource.id,
|
|
220
|
+
main_field: resource.main_field,
|
|
221
|
+
resourceType: resource.resourceType,
|
|
222
|
+
form_id: resource.form_id,
|
|
223
|
+
relation_id: resource.id,
|
|
224
|
+
capacity: (resource == null ? void 0 : resource.capacity) || 0
|
|
239
225
|
});
|
|
240
|
-
};
|
|
241
|
-
checkResourcesFormat(resources, origin.resources);
|
|
226
|
+
});
|
|
242
227
|
const { startTime, endTime } = resources[0];
|
|
243
228
|
if (startTime && endTime) {
|
|
244
229
|
origin.select_date = (0, import_dayjs.default)(startTime).format("YYYY-MM-DD");
|
|
@@ -2,20 +2,10 @@ import { Module, PisellCore } from '../../types';
|
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
3
|
import { ProductData, ProductMedia, ProductTag, ProductCategory, ProductBundleGroup } from './types';
|
|
4
4
|
export * from './types';
|
|
5
|
-
/**
|
|
6
|
-
* 商品详情模块
|
|
7
|
-
* 除了跟商品列表模块组合外,还会提供单独的商品详情页的一些方法
|
|
8
|
-
*
|
|
9
|
-
* @export
|
|
10
|
-
* @class Product
|
|
11
|
-
* @extends {BaseModule}
|
|
12
|
-
* @implements {Module}
|
|
13
|
-
*/
|
|
14
5
|
export declare class Product extends BaseModule implements Module {
|
|
15
6
|
protected defaultName: string;
|
|
16
7
|
protected defaultVersion: string;
|
|
17
8
|
private store;
|
|
18
|
-
protected otherParams: any;
|
|
19
9
|
constructor(name?: string, version?: string);
|
|
20
10
|
initialize(core: PisellCore, options: any): Promise<void>;
|
|
21
11
|
/**
|
|
@@ -30,9 +30,6 @@ var Product = class extends import_BaseModule.BaseModule {
|
|
|
30
30
|
super(name, version);
|
|
31
31
|
this.defaultName = "product";
|
|
32
32
|
this.defaultVersion = "1.0.0";
|
|
33
|
-
this.otherParams = {
|
|
34
|
-
scheduler: []
|
|
35
|
-
};
|
|
36
33
|
}
|
|
37
34
|
async initialize(core, options) {
|
|
38
35
|
this.core = core;
|
package/lib/modules/index.d.ts
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
1
|
export * from './Product';
|
|
2
2
|
export * from './ProductList';
|
|
3
3
|
export * from './Cart';
|
|
4
|
-
export * from './Account';
|
|
5
|
-
export * from './AccountList';
|
|
6
|
-
export * from './Date';
|
|
7
|
-
export * from './Guests';
|
|
8
|
-
export * from './Order';
|
|
9
|
-
export * from './Payment';
|
|
10
|
-
export * from './Resource';
|
|
11
|
-
export * from './Step';
|
|
12
|
-
export * from './Summary';
|
|
13
|
-
export * from './Schedule';
|
package/lib/modules/index.js
CHANGED
|
@@ -19,29 +19,9 @@ module.exports = __toCommonJS(modules_exports);
|
|
|
19
19
|
__reExport(modules_exports, require("./Product"), module.exports);
|
|
20
20
|
__reExport(modules_exports, require("./ProductList"), module.exports);
|
|
21
21
|
__reExport(modules_exports, require("./Cart"), module.exports);
|
|
22
|
-
__reExport(modules_exports, require("./Account"), module.exports);
|
|
23
|
-
__reExport(modules_exports, require("./AccountList"), module.exports);
|
|
24
|
-
__reExport(modules_exports, require("./Date"), module.exports);
|
|
25
|
-
__reExport(modules_exports, require("./Guests"), module.exports);
|
|
26
|
-
__reExport(modules_exports, require("./Order"), module.exports);
|
|
27
|
-
__reExport(modules_exports, require("./Payment"), module.exports);
|
|
28
|
-
__reExport(modules_exports, require("./Resource"), module.exports);
|
|
29
|
-
__reExport(modules_exports, require("./Step"), module.exports);
|
|
30
|
-
__reExport(modules_exports, require("./Summary"), module.exports);
|
|
31
|
-
__reExport(modules_exports, require("./Schedule"), module.exports);
|
|
32
22
|
// Annotate the CommonJS export names for ESM import in node:
|
|
33
23
|
0 && (module.exports = {
|
|
34
24
|
...require("./Product"),
|
|
35
25
|
...require("./ProductList"),
|
|
36
|
-
...require("./Cart")
|
|
37
|
-
...require("./Account"),
|
|
38
|
-
...require("./AccountList"),
|
|
39
|
-
...require("./Date"),
|
|
40
|
-
...require("./Guests"),
|
|
41
|
-
...require("./Order"),
|
|
42
|
-
...require("./Payment"),
|
|
43
|
-
...require("./Resource"),
|
|
44
|
-
...require("./Step"),
|
|
45
|
-
...require("./Summary"),
|
|
46
|
-
...require("./Schedule")
|
|
26
|
+
...require("./Cart")
|
|
47
27
|
});
|
|
@@ -27,19 +27,11 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
27
27
|
back(): void;
|
|
28
28
|
gotoStep(index: number): void;
|
|
29
29
|
getStepList(): IStep[];
|
|
30
|
-
loadProducts({ category_ids, product_ids, collection,
|
|
30
|
+
loadProducts({ category_ids, product_ids, collection, }: {
|
|
31
31
|
category_ids?: number[];
|
|
32
32
|
product_ids?: number[];
|
|
33
33
|
collection?: number | string[];
|
|
34
|
-
schedule_ids?: number[];
|
|
35
34
|
}): Promise<any>;
|
|
36
|
-
loadProductByScheduleDate(date: string): void;
|
|
37
|
-
loadAllSchedule(): Promise<void>;
|
|
38
|
-
loadAvailableDate({ startDate, endDate, custom_page_id }: {
|
|
39
|
-
startDate: string;
|
|
40
|
-
endDate: string;
|
|
41
|
-
custom_page_id?: number;
|
|
42
|
-
}): Promise<void>;
|
|
43
35
|
storeProduct(productData: ProductData): Promise<void>;
|
|
44
36
|
addAccount(accounts: Account[]): Promise<void>;
|
|
45
37
|
getAccounts(): Promise<(Account | null)[]>;
|
|
@@ -96,7 +88,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
96
88
|
_id: string;
|
|
97
89
|
product: ProductData | undefined;
|
|
98
90
|
resources: import("./utils/resources").ResourceItem[];
|
|
99
|
-
holder_id: string | number;
|
|
91
|
+
holder_id: string | number | undefined;
|
|
100
92
|
holder_name: string | undefined;
|
|
101
93
|
} | undefined;
|
|
102
94
|
getResourceTimeSlot({ product, resources, currentResourceId, }: {
|
|
@@ -115,12 +107,11 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
115
107
|
timeSlots: any[];
|
|
116
108
|
selectedResource: any;
|
|
117
109
|
} | undefined;
|
|
118
|
-
autoSelectAccountResources({ holder_id, resources_code, timeSlots, countMap,
|
|
110
|
+
autoSelectAccountResources({ holder_id, resources_code, timeSlots, countMap, }: {
|
|
119
111
|
holder_id: string;
|
|
120
112
|
resources_code: string | number;
|
|
121
113
|
timeSlots?: TimeSliceItem;
|
|
122
114
|
countMap: Record<number, number>;
|
|
123
|
-
capacity?: number;
|
|
124
115
|
}): {
|
|
125
116
|
selectedResource: any;
|
|
126
117
|
timeSlots?: undefined;
|
|
@@ -135,5 +126,4 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
135
126
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
136
127
|
clearCache(): void;
|
|
137
128
|
clearCacheByModule(module: string): void;
|
|
138
|
-
openProductDetail(productId: number): Promise<void>;
|
|
139
129
|
}
|