@pisell/pisellos 0.0.13 → 0.0.15
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 +26 -8
- package/dist/modules/Cart/index.js +134 -122
- package/dist/modules/Cart/types.d.ts +36 -15
- package/dist/modules/Cart/types.js +3 -3
- package/dist/modules/Cart/utils.d.ts +49 -1
- package/dist/modules/Cart/utils.js +109 -0
- package/dist/modules/Date/index.js +6 -1
- package/dist/modules/Rules/index.js +6 -4
- package/dist/modules/Summary/index.js +6 -1
- package/dist/modules/Summary/utils.js +4 -5
- package/dist/solution/BookingByStep/index.d.ts +11 -4
- package/dist/solution/BookingByStep/index.js +185 -159
- package/dist/solution/BookingByStep/utils/resources.js +4 -2
- package/lib/modules/Cart/index.d.ts +26 -8
- package/lib/modules/Cart/index.js +67 -52
- package/lib/modules/Cart/types.d.ts +36 -15
- package/lib/modules/Cart/utils.d.ts +49 -1
- package/lib/modules/Cart/utils.js +74 -0
- package/lib/modules/Date/index.js +3 -0
- package/lib/modules/Rules/index.js +6 -4
- package/lib/modules/Summary/index.js +3 -0
- package/lib/modules/Summary/utils.js +4 -5
- package/lib/solution/BookingByStep/index.d.ts +11 -4
- package/lib/solution/BookingByStep/index.js +60 -30
- package/lib/solution/BookingByStep/utils/resources.js +4 -1
- package/package.json +1 -1
|
@@ -107,9 +107,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
107
107
|
return this.store.step.getStepList();
|
|
108
108
|
}
|
|
109
109
|
// 获取购物车里 temp.xxx的方法
|
|
110
|
-
async getStoreCart(key) {
|
|
111
|
-
|
|
112
|
-
}
|
|
110
|
+
// async getStoreCart(key?: string) {
|
|
111
|
+
// return this.store.cart.getTemp(key);
|
|
112
|
+
// }
|
|
113
113
|
// 加载商品,然后导到商品列表里去
|
|
114
114
|
async loadProducts({
|
|
115
115
|
category_ids = [],
|
|
@@ -272,7 +272,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
272
272
|
this.store.cart.updateItem(params);
|
|
273
273
|
}
|
|
274
274
|
// 删除购物车里某个商品
|
|
275
|
-
deleteCart(
|
|
275
|
+
deleteCart(cartItemId) {
|
|
276
|
+
this.store.cart.removeItem(cartItemId);
|
|
276
277
|
}
|
|
277
278
|
// 清空购物车
|
|
278
279
|
clearCart() {
|
|
@@ -282,6 +283,23 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
282
283
|
clearCartByAccount(account_id) {
|
|
283
284
|
this.store.cart.clearCartByAccount(account_id);
|
|
284
285
|
}
|
|
286
|
+
/**
|
|
287
|
+
* 批量更新购物车
|
|
288
|
+
*/
|
|
289
|
+
batchUpdateCart(paramsList) {
|
|
290
|
+
const cartItems = [];
|
|
291
|
+
paramsList.forEach((params) => {
|
|
292
|
+
const cartItem = this.store.cart.formatCartItem(params);
|
|
293
|
+
cartItems.push(cartItem);
|
|
294
|
+
});
|
|
295
|
+
this.store.cart.batchSetItems(cartItems);
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* 从购物车中按类别删除信息
|
|
299
|
+
*/
|
|
300
|
+
deleteCartItemInfo(types) {
|
|
301
|
+
this.store.cart.deleteCartItemInfo(types);
|
|
302
|
+
}
|
|
285
303
|
destory() {
|
|
286
304
|
var _a, _b, _c, _d, _e, _f;
|
|
287
305
|
(_a = this.store.cart) == null ? void 0 : _a.destory();
|
|
@@ -305,11 +323,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
305
323
|
const cartItems = this.store.cart.getItems();
|
|
306
324
|
const arr = [];
|
|
307
325
|
cartItems.forEach((cartItem) => {
|
|
308
|
-
const productResources = (0, import_resources.getResourcesByProduct)(
|
|
309
|
-
resourcesMap,
|
|
310
|
-
cartItem,
|
|
311
|
-
cartItems
|
|
312
|
-
);
|
|
326
|
+
const productResources = (0, import_resources.getResourcesByProduct)(resourcesMap, cartItem, cartItems);
|
|
313
327
|
arr.push({
|
|
314
328
|
id: cartItem.id,
|
|
315
329
|
// 这里返回的是购物车 id ,后面提交的时候要用的,用这个 id 绑定资源和时间
|
|
@@ -393,18 +407,24 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
393
407
|
resources_code,
|
|
394
408
|
timeSlots
|
|
395
409
|
}) {
|
|
396
|
-
var _a;
|
|
410
|
+
var _a, _b, _c;
|
|
397
411
|
const dateRange = this.store.date.getDateRange();
|
|
398
412
|
const cartItems = this.store.cart.getItems();
|
|
399
|
-
const accountCartItems = cartItems.filter((n) => n.holder_id === holder_id);
|
|
413
|
+
const accountCartItems = cartItems.filter((n) => n.holder_id === holder_id) || [];
|
|
414
|
+
if (!accountCartItems.length) {
|
|
415
|
+
return {
|
|
416
|
+
selectedResource: null
|
|
417
|
+
};
|
|
418
|
+
}
|
|
400
419
|
let duration = accountCartItems.reduce((acc, n) => {
|
|
401
|
-
|
|
420
|
+
var _a2, _b2;
|
|
421
|
+
return acc + (((_b2 = (_a2 = n._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) ?? 0);
|
|
402
422
|
}, 0);
|
|
403
|
-
let durationType = ((_a = accountCartItems == null ? void 0 :
|
|
423
|
+
let durationType = ((_c = (_b = (_a = accountCartItems[0]) == null ? void 0 : _a._productOrigin) == null ? void 0 : _b.duration) == null ? void 0 : _c.type) ?? "minutes";
|
|
404
424
|
const resources = [];
|
|
405
425
|
accountCartItems.forEach((item) => {
|
|
406
|
-
var _a2,
|
|
407
|
-
(
|
|
426
|
+
var _a2, _b2, _c2;
|
|
427
|
+
(_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.forEach((n) => {
|
|
408
428
|
if (n.code === resources_code) {
|
|
409
429
|
resources.push(...n.renderList || []);
|
|
410
430
|
}
|
|
@@ -475,25 +495,30 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
475
495
|
console.log(this.store.cart.getItems());
|
|
476
496
|
this.store.cart.updateItem({
|
|
477
497
|
_id: item._id,
|
|
478
|
-
|
|
498
|
+
// 这里要做去重,避免出现同样类型的资源被塞进同一个商品
|
|
499
|
+
resources: [
|
|
500
|
+
...(item._origin.resources || []).filter(
|
|
501
|
+
(existingRes) => existingRes.form_id !== res.selectedResource.form_id
|
|
502
|
+
),
|
|
503
|
+
res.selectedResource
|
|
504
|
+
]
|
|
479
505
|
});
|
|
480
506
|
console.log(this.store.cart.getItems());
|
|
481
507
|
} else {
|
|
482
508
|
errorList.push(item._id);
|
|
483
509
|
}
|
|
484
510
|
} else {
|
|
485
|
-
const productResources = (0, import_resources.getResourcesByProduct)(
|
|
486
|
-
|
|
487
|
-
item,
|
|
488
|
-
allCartItems
|
|
489
|
-
);
|
|
490
|
-
const targetRenderList = (_a = productResources.find(
|
|
491
|
-
(n) => n.code === resources_code
|
|
492
|
-
)) == null ? void 0 : _a.renderList;
|
|
511
|
+
const productResources = (0, import_resources.getResourcesByProduct)(resourcesMap, item, allCartItems);
|
|
512
|
+
const targetRenderList = (_a = productResources.find((n) => n.code === resources_code)) == null ? void 0 : _a.renderList;
|
|
493
513
|
if (targetRenderList && targetRenderList.length > 0) {
|
|
494
514
|
this.store.cart.updateItem({
|
|
495
515
|
_id: item._id,
|
|
496
|
-
resources: [
|
|
516
|
+
resources: [
|
|
517
|
+
...(item._origin.resources || []).filter(
|
|
518
|
+
(existingRes) => existingRes.resourceType !== targetRenderList[0].resourceType
|
|
519
|
+
),
|
|
520
|
+
targetRenderList[0]
|
|
521
|
+
]
|
|
497
522
|
});
|
|
498
523
|
} else {
|
|
499
524
|
errorList.push(item._id);
|
|
@@ -510,13 +535,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
510
535
|
const cartItems = this.store.cart.getItems();
|
|
511
536
|
const resourceIds = [];
|
|
512
537
|
cartItems.forEach((item) => {
|
|
513
|
-
var _a, _b, _c;
|
|
514
|
-
(_b = (_a = item._productOrigin.product_resource) == null ? void 0 :
|
|
538
|
+
var _a, _b, _c, _d;
|
|
539
|
+
(_c = (_b = (_a = item._productOrigin) == null ? void 0 : _a.product_resource) == null ? void 0 : _b.resources) == null ? void 0 : _c.forEach((n) => {
|
|
515
540
|
if (n.code === resources_code) {
|
|
516
541
|
resources.push(...n.renderList || []);
|
|
517
542
|
}
|
|
518
543
|
});
|
|
519
|
-
(
|
|
544
|
+
(_d = item._origin.resources) == null ? void 0 : _d.forEach((n) => {
|
|
520
545
|
resourceIds.push(n.relation_id);
|
|
521
546
|
});
|
|
522
547
|
});
|
|
@@ -526,7 +551,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
526
551
|
let accountDuration = 0;
|
|
527
552
|
const cartItems2 = this.store.cart.getCartByAccount(account.getId());
|
|
528
553
|
cartItems2.forEach((item) => {
|
|
529
|
-
|
|
554
|
+
var _a, _b;
|
|
555
|
+
accountDuration += ((_b = (_a = item._productOrigin) == null ? void 0 : _a.duration) == null ? void 0 : _b.value) ?? 0;
|
|
530
556
|
});
|
|
531
557
|
if (accountDuration > duration) {
|
|
532
558
|
duration = accountDuration;
|
|
@@ -572,8 +598,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
572
598
|
cartItems.forEach((item) => {
|
|
573
599
|
const newResources = (0, import_lodash_es.cloneDeep)(item._origin.resources);
|
|
574
600
|
newResources.forEach((n) => {
|
|
601
|
+
var _a, _b, _c, _d;
|
|
575
602
|
n.startTime = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
|
|
576
|
-
n.endTime = (0, import_dayjs.default)(n.startTime).add(
|
|
603
|
+
n.endTime = (0, import_dayjs.default)(n.startTime).add(
|
|
604
|
+
((_b = (_a = item._productOrigin) == null ? void 0 : _a.duration) == null ? void 0 : _b.value) ?? 0,
|
|
605
|
+
((_d = (_c = item._productOrigin) == null ? void 0 : _c.duration) == null ? void 0 : _d.type) ?? "minutes"
|
|
606
|
+
).format("YYYY-MM-DD HH:mm");
|
|
577
607
|
delete n.times;
|
|
578
608
|
});
|
|
579
609
|
this.store.cart.updateItem({
|
|
@@ -149,7 +149,10 @@ var getResourcesByProduct = (resourcesMap, cartItem, cartList) => {
|
|
|
149
149
|
}, []);
|
|
150
150
|
item.renderList = optional_resource.concat(default_resource);
|
|
151
151
|
item.renderList = item.renderList.filter((d) => {
|
|
152
|
-
|
|
152
|
+
const latestTime = d.times.reduce((latest, current) => {
|
|
153
|
+
return (0, import_dayjs.default)(current.end_at).isAfter((0, import_dayjs.default)(latest.end_at)) ? current : latest;
|
|
154
|
+
}, d.times[0]);
|
|
155
|
+
return (0, import_dayjs.default)(latestTime.end_at).isAfter((0, import_dayjs.default)());
|
|
153
156
|
});
|
|
154
157
|
item.form_id = form_id;
|
|
155
158
|
acc.push(item);
|