@pisell/pisellos 0.0.34 → 0.0.36
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 +4 -0
- package/dist/modules/Cart/utils.js +3 -1
- package/dist/modules/Discount/types.d.ts +1 -0
- package/dist/modules/Product/index.d.ts +10 -0
- package/dist/modules/Product/index.js +13 -0
- package/dist/modules/Product/types.d.ts +4 -0
- package/dist/modules/Resource/types.d.ts +1 -0
- package/dist/modules/Schedule/index.d.ts +10 -0
- package/dist/modules/Schedule/index.js +56 -0
- package/dist/modules/Schedule/type.d.ts +157 -0
- package/dist/modules/Schedule/type.js +1 -0
- package/dist/modules/Schedule/types.d.ts +177 -0
- package/dist/modules/Schedule/types.js +1 -0
- package/dist/modules/Schedule/utils.d.ts +61 -0
- package/dist/modules/Schedule/utils.js +700 -0
- package/dist/modules/index.d.ts +9 -0
- package/dist/modules/index.js +10 -1
- package/dist/solution/BookingByStep/index.d.ts +14 -5
- package/dist/solution/BookingByStep/index.js +284 -163
- package/dist/solution/BookingByStep/types.d.ts +2 -10
- package/dist/solution/BookingByStep/types.js +1 -7
- package/dist/solution/BookingByStep/utils/resources.d.ts +45 -4
- package/dist/solution/BookingByStep/utils/resources.js +153 -32
- package/dist/solution/ShopDiscount/index.js +31 -22
- package/lib/modules/Cart/types.d.ts +4 -0
- package/lib/modules/Cart/utils.js +4 -1
- package/lib/modules/Discount/types.d.ts +1 -0
- package/lib/modules/Product/index.d.ts +10 -0
- package/lib/modules/Product/index.js +3 -0
- package/lib/modules/Product/types.d.ts +4 -0
- package/lib/modules/Resource/types.d.ts +1 -0
- package/lib/modules/Schedule/index.d.ts +10 -0
- package/lib/modules/Schedule/index.js +41 -0
- package/lib/modules/Schedule/type.d.ts +157 -0
- package/lib/modules/Schedule/type.js +17 -0
- package/lib/modules/Schedule/types.d.ts +177 -0
- package/lib/modules/Schedule/types.js +17 -0
- package/lib/modules/Schedule/utils.d.ts +61 -0
- package/lib/modules/Schedule/utils.js +572 -0
- package/lib/modules/index.d.ts +9 -0
- package/lib/modules/index.js +19 -1
- package/lib/solution/BookingByStep/index.d.ts +14 -5
- package/lib/solution/BookingByStep/index.js +84 -35
- package/lib/solution/BookingByStep/types.d.ts +2 -10
- package/lib/solution/BookingByStep/types.js +6 -12
- package/lib/solution/BookingByStep/utils/resources.d.ts +45 -4
- package/lib/solution/BookingByStep/utils/resources.js +101 -24
- package/lib/solution/ShopDiscount/index.js +13 -5
- package/package.json +1 -1
|
@@ -1,13 +1,4 @@
|
|
|
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";
|
|
1
|
+
import { ProductList, CartModule, Product, AccountModule, AccountListModule, DateModule, GuestListModule, OrderModule, PaymentModule, ResourceListModule, StepModule, SummaryModule } from "../../modules";
|
|
11
2
|
export interface BookingByStepState {
|
|
12
3
|
cart: CartModule;
|
|
13
4
|
summary: SummaryModule;
|
|
@@ -20,6 +11,7 @@ export interface BookingByStepState {
|
|
|
20
11
|
accountList: AccountListModule;
|
|
21
12
|
order: OrderModule;
|
|
22
13
|
payment: PaymentModule;
|
|
14
|
+
currentProduct: Product;
|
|
23
15
|
}
|
|
24
16
|
export declare function createModule<T extends keyof BookingByStepState>(moduleName: T, solutionName: string, name?: string, version?: string): BookingByStepState[T];
|
|
25
17
|
export declare enum BookingByStepHooks {
|
|
@@ -1,10 +1,4 @@
|
|
|
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";
|
|
1
|
+
import { ProductList, CartModule, AccountListModule, DateModule, OrderModule, PaymentModule, StepModule, SummaryModule } from "../../modules";
|
|
8
2
|
export function createModule(moduleName, solutionName, name, version) {
|
|
9
3
|
switch (moduleName) {
|
|
10
4
|
case "cart":
|
|
@@ -45,8 +45,7 @@ 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>,
|
|
49
|
-
export declare const getSumCapacity: () => number;
|
|
48
|
+
export declare const getResourcesByProduct: (resourcesMap: Record<string, ResourceItem>, resources: ResourceItem[], selectedResources: number[], capacity?: number) => ResourceItem[];
|
|
50
49
|
/**
|
|
51
50
|
* @title: 获取资源列表
|
|
52
51
|
* @description:
|
|
@@ -67,11 +66,12 @@ export declare const formatResources: ({ booking, resources }: {
|
|
|
67
66
|
* @return {*}
|
|
68
67
|
* @Author: zhiwei.Wang
|
|
69
68
|
*/
|
|
70
|
-
export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate }: {
|
|
69
|
+
export declare const getTimeSlicesByResource: ({ resource, duration, split, currentDate, capacity }: {
|
|
71
70
|
resource: ResourceItem;
|
|
72
71
|
duration: number;
|
|
73
72
|
split: number;
|
|
74
73
|
currentDate: DateType | string;
|
|
74
|
+
capacity?: number | undefined;
|
|
75
75
|
}) => TimeSliceItem[];
|
|
76
76
|
/**
|
|
77
77
|
* @title: 获取时间切片列表的交集
|
|
@@ -100,11 +100,52 @@ 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, capacity }: {
|
|
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;
|
|
109
110
|
}) => 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;
|
|
110
151
|
export {};
|
|
@@ -191,41 +191,39 @@ 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
|
-
|
|
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) {
|
|
194
|
+
export var getResourcesByProduct = function getResourcesByProduct(resourcesMap, resources, selectedResources) {
|
|
195
|
+
var capacity = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
196
|
+
return (resources || []).reduce(function (acc, item) {
|
|
198
197
|
if ((item === null || item === void 0 ? void 0 : item.status) == 1) {
|
|
199
198
|
var form_id = item.id;
|
|
200
199
|
// 去重 可选资源和必选资源可能会有重复的
|
|
201
200
|
item.optional_resource = (item.optional_resource || []).filter(function (d) {
|
|
202
201
|
return item.default_resource.indexOf(d) == -1;
|
|
203
202
|
});
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
203
|
+
var optional_resource = item.optional_resource.reduce(function (childAcc, d) {
|
|
204
|
+
if (resourcesMap[d] && !selectedResources.includes(resourcesMap[d].id) && capacity <= resourcesMap[d].capacity) {
|
|
205
|
+
// 拼装组合资源的数据
|
|
206
|
+
var combiningResources = [];
|
|
207
|
+
if (resourcesMap[d].combined_resource && resourcesMap[d].combined_resource.status === 1) {
|
|
208
|
+
resourcesMap[d].combined_resource.resource_ids.forEach(function (id) {
|
|
209
|
+
if (resourcesMap[id]) {
|
|
210
|
+
combiningResources.push(resourcesMap[id]);
|
|
211
|
+
}
|
|
213
212
|
});
|
|
214
213
|
}
|
|
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)) {
|
|
220
214
|
childAcc.push(Object.assign({}, resourcesMap[d], {
|
|
221
215
|
form_id: form_id,
|
|
222
|
-
resourceType: item.type
|
|
216
|
+
resourceType: item.type,
|
|
217
|
+
children: combiningResources,
|
|
218
|
+
metadata: _objectSpread(_objectSpread({}, resourcesMap[d].metadata), {}, {
|
|
219
|
+
combined_resource: resourcesMap[d].combined_resource
|
|
220
|
+
})
|
|
223
221
|
}));
|
|
224
222
|
}
|
|
225
223
|
return childAcc;
|
|
226
224
|
}, []);
|
|
227
225
|
var default_resource = item.default_resource.reduce(function (childAcc, d) {
|
|
228
|
-
if (resourcesMap[d] && !selectedResources.includes(resourcesMap[d].id)) {
|
|
226
|
+
if (resourcesMap[d] && !selectedResources.includes(resourcesMap[d].id) && capacity <= resourcesMap[d].capacity) {
|
|
229
227
|
childAcc.push(Object.assign({}, resourcesMap[d], {
|
|
230
228
|
form_id: form_id,
|
|
231
229
|
resourceType: item.type,
|
|
@@ -249,14 +247,6 @@ export var getResourcesByProduct = function getResourcesByProduct(resourcesMap,
|
|
|
249
247
|
return acc;
|
|
250
248
|
}, []);
|
|
251
249
|
};
|
|
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
|
-
};
|
|
260
250
|
|
|
261
251
|
/**
|
|
262
252
|
* @title: 获取资源列表
|
|
@@ -319,7 +309,8 @@ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref4) {
|
|
|
319
309
|
_ref4$split = _ref4.split,
|
|
320
310
|
split = _ref4$split === void 0 ? 10 : _ref4$split,
|
|
321
311
|
_ref4$currentDate = _ref4.currentDate,
|
|
322
|
-
currentDate = _ref4$currentDate === void 0 ? dayjs() : _ref4$currentDate
|
|
312
|
+
currentDate = _ref4$currentDate === void 0 ? dayjs() : _ref4$currentDate,
|
|
313
|
+
capacity = _ref4.capacity;
|
|
323
314
|
var times = resource.times;
|
|
324
315
|
|
|
325
316
|
// 存储所有时间切片
|
|
@@ -356,7 +347,7 @@ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref4) {
|
|
|
356
347
|
timeSlice: timeSlice,
|
|
357
348
|
time: time,
|
|
358
349
|
resource: resource,
|
|
359
|
-
currentCount:
|
|
350
|
+
currentCount: capacity || 1
|
|
360
351
|
});
|
|
361
352
|
if (_status.usable) {
|
|
362
353
|
// 添加时间切片 09:00 ~ 10:00 09:20 ~ 10:20 09:00 ~ 10:00 09:20 ~ 10:20 11:00 ~ 12:00 11:20 ~ 12:20
|
|
@@ -430,7 +421,8 @@ export var getTimeSlicesByResources = function getTimeSlicesByResources(_ref5) {
|
|
|
430
421
|
resourcesMap = _ref5.resourcesMap,
|
|
431
422
|
duration = _ref5.duration,
|
|
432
423
|
currentDate = _ref5.currentDate,
|
|
433
|
-
split = _ref5.split
|
|
424
|
+
split = _ref5.split,
|
|
425
|
+
capacity = _ref5.capacity;
|
|
434
426
|
// 获取资源列表
|
|
435
427
|
var resources = getResourcesByIds(resourcesMap, resourceIds);
|
|
436
428
|
|
|
@@ -440,11 +432,140 @@ export var getTimeSlicesByResources = function getTimeSlicesByResources(_ref5) {
|
|
|
440
432
|
resource: item,
|
|
441
433
|
duration: duration,
|
|
442
434
|
split: split,
|
|
443
|
-
currentDate: currentDate
|
|
435
|
+
currentDate: currentDate,
|
|
436
|
+
capacity: capacity
|
|
444
437
|
}));
|
|
445
438
|
}, []);
|
|
446
439
|
|
|
447
440
|
// 获取时间切片列表的交集
|
|
448
441
|
var intersection = getTimesIntersection(timeSliceList, resources.length);
|
|
449
442
|
return intersection;
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* @title: 获取其他人的已选资源
|
|
447
|
+
* @description:
|
|
448
|
+
* @param {CartItem[]} cartItems
|
|
449
|
+
* @param {number | string} accountId
|
|
450
|
+
* @return {*}
|
|
451
|
+
* @Author: jinglin.tan
|
|
452
|
+
*/
|
|
453
|
+
export var getOthersSelectedResources = function getOthersSelectedResources(cartItems, accountId, resourcesMap) {
|
|
454
|
+
return cartItems.reduce(function (acc, d) {
|
|
455
|
+
if (d.holder_id !== accountId) {
|
|
456
|
+
var _d$_origin;
|
|
457
|
+
if ((_d$_origin = d._origin) !== null && _d$_origin !== void 0 && _d$_origin.resources) {
|
|
458
|
+
d._origin.resources.forEach(function (n) {
|
|
459
|
+
// 如果是组合资源,还需要检查组合资源里子资源是否被占用过
|
|
460
|
+
if (n.metadata.combined_resource && n.metadata.combined_resource.status === 1) {
|
|
461
|
+
// 如果组合资源里子资源被占用过,则这个资源不可以进待选列表了
|
|
462
|
+
if (n.metadata.combined_resource.resource_ids.some(function (m) {
|
|
463
|
+
return acc.includes(m);
|
|
464
|
+
})) {
|
|
465
|
+
return acc;
|
|
466
|
+
}
|
|
467
|
+
acc.push.apply(acc, _toConsumableArray(n.metadata.combined_resource.resource_ids));
|
|
468
|
+
} else {
|
|
469
|
+
// 如果当前选中的不是组合资源,但是是别的组合资源里的子资源,则还需要把别的组合资源也加进来
|
|
470
|
+
// 去 resourcesMap 里找一下 n.id 是不是别的组合资源里的子资源,是的话把别的组合资源也加进来
|
|
471
|
+
Object.values(resourcesMap).forEach(function (m) {
|
|
472
|
+
if (m.combined_resource && m.combined_resource.status === 1) {
|
|
473
|
+
if (m.combined_resource.resource_ids.includes(n.id)) {
|
|
474
|
+
acc.push(m.id);
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
acc.push(n.id);
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
return acc;
|
|
484
|
+
}, []);
|
|
485
|
+
};
|
|
486
|
+
/**
|
|
487
|
+
* @title: 基于选择的商品格式化容量
|
|
488
|
+
* @description:
|
|
489
|
+
* @param {any} param1
|
|
490
|
+
* @return {*}
|
|
491
|
+
* @Author: zhiwei.Wang
|
|
492
|
+
*/
|
|
493
|
+
export var formatDefaultCapacitys = function formatDefaultCapacitys(_ref6) {
|
|
494
|
+
var capacity = _ref6.capacity,
|
|
495
|
+
product_bundle = _ref6.product_bundle;
|
|
496
|
+
if ((capacity === null || capacity === void 0 ? void 0 : capacity.type) === 'package') {
|
|
497
|
+
return (product_bundle || []).map(function (d) {
|
|
498
|
+
var id = d.bundle_product_id;
|
|
499
|
+
var item = ((capacity === null || capacity === void 0 ? void 0 : capacity.package) || []).find(function (item) {
|
|
500
|
+
return item.product_id === id;
|
|
501
|
+
});
|
|
502
|
+
return {
|
|
503
|
+
id: id,
|
|
504
|
+
value: item ? d.num || 0 : 0,
|
|
505
|
+
name: (item === null || item === void 0 ? void 0 : item.name) || (d === null || d === void 0 ? void 0 : d.title)
|
|
506
|
+
};
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
if ((capacity === null || capacity === void 0 ? void 0 : capacity.type) === 'custom') {
|
|
510
|
+
return ((capacity === null || capacity === void 0 ? void 0 : capacity.custom) || []).map(function (d) {
|
|
511
|
+
return {
|
|
512
|
+
id: d.id,
|
|
513
|
+
value: d.min,
|
|
514
|
+
name: d.name
|
|
515
|
+
};
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// 默认为1
|
|
520
|
+
return [{
|
|
521
|
+
id: 0,
|
|
522
|
+
value: 1,
|
|
523
|
+
name: ''
|
|
524
|
+
}];
|
|
525
|
+
};
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* @title: 获取总容量
|
|
529
|
+
* @description:
|
|
530
|
+
* @param {object} capacity 为 formatDefaultCapacitys()的结果
|
|
531
|
+
* @return {*}
|
|
532
|
+
* @Author: zhiwei.Wang
|
|
533
|
+
*/
|
|
534
|
+
export var getSumCapacity = function getSumCapacity(_ref7) {
|
|
535
|
+
var capacity = _ref7.capacity;
|
|
536
|
+
var sum = 0;
|
|
537
|
+
var _iterator2 = _createForOfIteratorHelper(capacity || []),
|
|
538
|
+
_step2;
|
|
539
|
+
try {
|
|
540
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
541
|
+
var item = _step2.value;
|
|
542
|
+
sum += item.value;
|
|
543
|
+
}
|
|
544
|
+
} catch (err) {
|
|
545
|
+
_iterator2.e(err);
|
|
546
|
+
} finally {
|
|
547
|
+
_iterator2.f();
|
|
548
|
+
}
|
|
549
|
+
return sum;
|
|
550
|
+
};
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* @title: 传入资源,如果有子资源,会根据组合资源的 capacity 计算修改子资源的 capacity
|
|
554
|
+
* @description:
|
|
555
|
+
* @param {object} resource
|
|
556
|
+
* @return {*}
|
|
557
|
+
* @Author: jinglin.tan
|
|
558
|
+
*/
|
|
559
|
+
export var checkSubResourcesCapacity = function checkSubResourcesCapacity(resource) {
|
|
560
|
+
if (resource.children && resource.children.length) {
|
|
561
|
+
var countCapacity = resource.capacity;
|
|
562
|
+
resource.children.forEach(function (child) {
|
|
563
|
+
if (child.capacity <= countCapacity) {
|
|
564
|
+
countCapacity -= child.capacity;
|
|
565
|
+
} else {
|
|
566
|
+
child.capacity = countCapacity;
|
|
567
|
+
countCapacity = 0;
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
}
|
|
450
571
|
};
|
|
@@ -301,7 +301,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
301
301
|
key: "scanCode",
|
|
302
302
|
value: function () {
|
|
303
303
|
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code) {
|
|
304
|
-
var _this$store$discount3, resultDiscountList, rulesModule, _ref3, newProductList, newDiscountList, isAvailable, _this$options$otherPa6;
|
|
304
|
+
var _this$store$discount3, resultDiscountList, rulesModule, withScanList, _ref3, newProductList, newDiscountList, isAvailable, _this$options$otherPa6;
|
|
305
305
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
306
306
|
while (1) switch (_context5.prev = _context5.next) {
|
|
307
307
|
case 0:
|
|
@@ -328,35 +328,40 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
328
328
|
discountList: this.getDiscountList()
|
|
329
329
|
});
|
|
330
330
|
case 10:
|
|
331
|
+
withScanList = resultDiscountList.map(function (item) {
|
|
332
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
333
|
+
isScan: true
|
|
334
|
+
});
|
|
335
|
+
});
|
|
331
336
|
_ref3 = rulesModule.isDiscountListAvailable({
|
|
332
337
|
productList: this.store.productList || [],
|
|
333
338
|
oldDiscountList: this.getDiscountList(),
|
|
334
|
-
newDiscountList:
|
|
339
|
+
newDiscountList: withScanList
|
|
335
340
|
}) || {
|
|
336
341
|
isAvailable: false,
|
|
337
342
|
productList: this.store.productList || [],
|
|
338
343
|
discountList: this.getDiscountList()
|
|
339
344
|
}, newProductList = _ref3.productList, newDiscountList = _ref3.discountList, isAvailable = _ref3.isAvailable;
|
|
340
345
|
if (!isAvailable) {
|
|
341
|
-
_context5.next =
|
|
346
|
+
_context5.next = 18;
|
|
342
347
|
break;
|
|
343
348
|
}
|
|
344
349
|
this.setDiscountList(newDiscountList || []);
|
|
345
350
|
this.setProductList(newProductList || []);
|
|
346
351
|
if (!(this.isWalkIn() && resultDiscountList.length && ((_this$options$otherPa6 = this.options.otherParams) === null || _this$options$otherPa6 === void 0 ? void 0 : _this$options$otherPa6.platform) === 'shop')) {
|
|
347
|
-
_context5.next =
|
|
352
|
+
_context5.next = 18;
|
|
348
353
|
break;
|
|
349
354
|
}
|
|
350
|
-
_context5.next =
|
|
355
|
+
_context5.next = 18;
|
|
351
356
|
return this.getCustomerWallet(resultDiscountList[0].customer_id);
|
|
352
|
-
case
|
|
357
|
+
case 18:
|
|
353
358
|
return _context5.abrupt("return", {
|
|
354
359
|
isAvailable: isAvailable || false,
|
|
355
360
|
productList: newProductList || this.store.productList || [],
|
|
356
361
|
discountList: newDiscountList || this.getDiscountList()
|
|
357
362
|
});
|
|
358
|
-
case
|
|
359
|
-
_context5.prev =
|
|
363
|
+
case 21:
|
|
364
|
+
_context5.prev = 21;
|
|
360
365
|
_context5.t1 = _context5["catch"](0);
|
|
361
366
|
console.error("[ShopDiscount] 扫码出错:", _context5.t1);
|
|
362
367
|
return _context5.abrupt("return", {
|
|
@@ -364,11 +369,11 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
364
369
|
productList: this.store.productList || [],
|
|
365
370
|
discountList: this.getDiscountList()
|
|
366
371
|
});
|
|
367
|
-
case
|
|
372
|
+
case 25:
|
|
368
373
|
case "end":
|
|
369
374
|
return _context5.stop();
|
|
370
375
|
}
|
|
371
|
-
}, _callee5, this, [[0,
|
|
376
|
+
}, _callee5, this, [[0, 21]]);
|
|
372
377
|
}));
|
|
373
378
|
function scanCode(_x4) {
|
|
374
379
|
return _scanCode.apply(this, arguments);
|
|
@@ -503,7 +508,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
503
508
|
key: "loadPrepareConfig",
|
|
504
509
|
value: function () {
|
|
505
510
|
var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
|
|
506
|
-
var _this$getCustomer2, _this$store$discount7, _this$store$productLi, customerId, goodPassList, result;
|
|
511
|
+
var _this$getCustomer2, _this$store$discount7, _this$getDiscountList, _this$store$productLi, customerId, goodPassList, scanDiscount, newDiscountList, result;
|
|
507
512
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
508
513
|
while (1) switch (_context8.prev = _context8.next) {
|
|
509
514
|
case 0:
|
|
@@ -519,29 +524,33 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
519
524
|
});
|
|
520
525
|
case 4:
|
|
521
526
|
goodPassList = _context8.sent;
|
|
522
|
-
this.
|
|
527
|
+
scanDiscount = (_this$getDiscountList = this.getDiscountList()) === null || _this$getDiscountList === void 0 ? void 0 : _this$getDiscountList.filter(function (item) {
|
|
528
|
+
return item.isScan;
|
|
529
|
+
});
|
|
530
|
+
newDiscountList = [].concat(_toConsumableArray(scanDiscount), _toConsumableArray(goodPassList || []));
|
|
531
|
+
this.setDiscountList(newDiscountList || []);
|
|
523
532
|
if (!((_this$store$productLi = this.store.productList) !== null && _this$store$productLi !== void 0 && _this$store$productLi.length)) {
|
|
524
|
-
_context8.next =
|
|
533
|
+
_context8.next = 12;
|
|
525
534
|
break;
|
|
526
535
|
}
|
|
527
536
|
result = this.calcDiscount(this.store.productList);
|
|
528
|
-
_context8.next = 10;
|
|
529
|
-
return this.core.effects.emit(ShopDiscountHooks.onLoadPrepareCalcResult, result);
|
|
530
|
-
case 10:
|
|
531
537
|
_context8.next = 12;
|
|
532
|
-
return this.core.effects.emit(ShopDiscountHooks.
|
|
538
|
+
return this.core.effects.emit(ShopDiscountHooks.onLoadPrepareCalcResult, result);
|
|
533
539
|
case 12:
|
|
534
|
-
_context8.next =
|
|
535
|
-
|
|
540
|
+
_context8.next = 14;
|
|
541
|
+
return this.core.effects.emit(ShopDiscountHooks.onLoadDiscountList, newDiscountList);
|
|
536
542
|
case 14:
|
|
537
|
-
_context8.
|
|
543
|
+
_context8.next = 19;
|
|
544
|
+
break;
|
|
545
|
+
case 16:
|
|
546
|
+
_context8.prev = 16;
|
|
538
547
|
_context8.t0 = _context8["catch"](0);
|
|
539
548
|
console.error("[ShopDiscount] 加载准备配置出错:", _context8.t0);
|
|
540
|
-
case
|
|
549
|
+
case 19:
|
|
541
550
|
case "end":
|
|
542
551
|
return _context8.stop();
|
|
543
552
|
}
|
|
544
|
-
}, _callee8, this, [[0,
|
|
553
|
+
}, _callee8, this, [[0, 16]]);
|
|
545
554
|
}));
|
|
546
555
|
function loadPrepareConfig(_x7) {
|
|
547
556
|
return _loadPrepareConfig.apply(this, arguments);
|
|
@@ -222,7 +222,10 @@ var formatResourceToCartItemOrigin = (params) => {
|
|
|
222
222
|
resourceType: resource.resourceType,
|
|
223
223
|
form_id: resource.form_id,
|
|
224
224
|
relation_id: resource.id,
|
|
225
|
-
capacity: (resource == null ? void 0 : resource.capacity) || 0
|
|
225
|
+
capacity: (resource == null ? void 0 : resource.capacity) || 0,
|
|
226
|
+
children: (resource == null ? void 0 : resource.children) || [],
|
|
227
|
+
metadata: (resource == null ? void 0 : resource.metadata) || {}
|
|
228
|
+
// 后端可以在这里挂一个前端用于计算的数据
|
|
226
229
|
});
|
|
227
230
|
});
|
|
228
231
|
const { startTime, endTime } = resources[0];
|
|
@@ -2,10 +2,20 @@ 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
|
+
*/
|
|
5
14
|
export declare class Product extends BaseModule implements Module {
|
|
6
15
|
protected defaultName: string;
|
|
7
16
|
protected defaultVersion: string;
|
|
8
17
|
private store;
|
|
18
|
+
protected otherParams: any;
|
|
9
19
|
constructor(name?: string, version?: string);
|
|
10
20
|
initialize(core: PisellCore, options: any): Promise<void>;
|
|
11
21
|
/**
|
|
@@ -30,6 +30,9 @@ 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
|
+
};
|
|
33
36
|
}
|
|
34
37
|
async initialize(core, options) {
|
|
35
38
|
this.core = core;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Module, PisellCore, ModuleOptions } from '../../types';
|
|
2
|
+
import { BaseModule } from '../BaseModule';
|
|
3
|
+
import { ScheduleModuleAPI } from './types';
|
|
4
|
+
export declare class ScheduleModule extends BaseModule implements Module, ScheduleModuleAPI {
|
|
5
|
+
protected defaultName: string;
|
|
6
|
+
protected defaultVersion: string;
|
|
7
|
+
private store;
|
|
8
|
+
constructor(name?: string, version?: string);
|
|
9
|
+
initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/modules/Schedule/index.ts
|
|
20
|
+
var Schedule_exports = {};
|
|
21
|
+
__export(Schedule_exports, {
|
|
22
|
+
ScheduleModule: () => ScheduleModule
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(Schedule_exports);
|
|
25
|
+
var import_BaseModule = require("../BaseModule");
|
|
26
|
+
var ScheduleModule = class extends import_BaseModule.BaseModule {
|
|
27
|
+
constructor(name, version) {
|
|
28
|
+
super(name, version);
|
|
29
|
+
this.defaultName = "schedule";
|
|
30
|
+
this.defaultVersion = "1.0.0";
|
|
31
|
+
this.store = {};
|
|
32
|
+
}
|
|
33
|
+
async initialize(core, options) {
|
|
34
|
+
this.core = core;
|
|
35
|
+
this.store = options == null ? void 0 : options.store;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
ScheduleModule
|
|
41
|
+
});
|