@pisell/pisellos 0.0.141 → 0.0.143
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 +14 -0
- package/dist/modules/Cart/index.js +36 -0
- package/dist/modules/Cart/utils/changePrice.d.ts +3 -0
- package/dist/modules/Cart/utils/changePrice.js +100 -0
- package/dist/modules/Date/index.js +57 -6
- package/dist/modules/ProductList/index.d.ts +7 -0
- package/dist/modules/ProductList/index.js +102 -39
- package/dist/modules/Schedule/index.d.ts +9 -1
- package/dist/modules/Schedule/index.js +121 -1
- package/dist/modules/Schedule/types.d.ts +13 -0
- package/dist/solution/BookingByStep/index.d.ts +120 -30
- package/dist/solution/BookingByStep/index.js +735 -1094
- package/dist/solution/BookingByStep/utils/capacity.d.ts +47 -0
- package/dist/solution/BookingByStep/utils/capacity.js +132 -0
- package/dist/solution/BookingByStep/utils/resources.d.ts +21 -29
- package/dist/solution/BookingByStep/utils/resources.js +39 -95
- package/dist/solution/BookingByStep/utils/timeslots.d.ts +11 -0
- package/dist/solution/BookingByStep/utils/timeslots.js +15 -0
- package/lib/modules/Cart/index.d.ts +14 -0
- package/lib/modules/Cart/index.js +32 -0
- package/lib/modules/Cart/utils/changePrice.d.ts +3 -0
- package/lib/modules/Cart/utils/changePrice.js +64 -0
- package/lib/modules/Date/index.js +62 -10
- package/lib/modules/ProductList/index.d.ts +7 -0
- package/lib/modules/ProductList/index.js +45 -0
- package/lib/modules/Schedule/index.d.ts +9 -1
- package/lib/modules/Schedule/index.js +78 -0
- package/lib/modules/Schedule/types.d.ts +13 -0
- package/lib/solution/BookingByStep/index.d.ts +120 -30
- package/lib/solution/BookingByStep/index.js +360 -580
- package/lib/solution/BookingByStep/utils/capacity.d.ts +47 -0
- package/lib/solution/BookingByStep/utils/capacity.js +106 -0
- package/lib/solution/BookingByStep/utils/resources.d.ts +21 -29
- package/lib/solution/BookingByStep/utils/resources.js +21 -58
- package/lib/solution/BookingByStep/utils/timeslots.d.ts +11 -0
- package/lib/solution/BookingByStep/utils/timeslots.js +7 -0
- package/package.json +1 -1
|
@@ -45,6 +45,8 @@ var import_utils2 = require("../../modules/Schedule/utils");
|
|
|
45
45
|
var import_utils3 = require("../../modules/Date/utils");
|
|
46
46
|
var import_utils4 = require("../../modules/Product/utils");
|
|
47
47
|
var import_timeslots = require("./utils/timeslots");
|
|
48
|
+
var import_changePrice = require("../../modules/Cart/utils/changePrice");
|
|
49
|
+
var import_capacity = require("./utils/capacity");
|
|
48
50
|
import_dayjs.default.extend(import_isSameOrBefore.default);
|
|
49
51
|
import_dayjs.default.extend(import_isSameOrAfter.default);
|
|
50
52
|
var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
@@ -111,7 +113,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
111
113
|
throw new Error(`模块 ${step} 不存在`);
|
|
112
114
|
}
|
|
113
115
|
});
|
|
114
|
-
this.loadAllSchedule();
|
|
116
|
+
this.store.schedule.loadAllSchedule();
|
|
115
117
|
this.core.effects.emit(import_types.BookingByStepHooks.onInited, {});
|
|
116
118
|
}
|
|
117
119
|
// 初始化step
|
|
@@ -158,56 +160,52 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
158
160
|
updateStep(key, step) {
|
|
159
161
|
this.store.step.updateStep(key, step);
|
|
160
162
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
/**
|
|
164
|
+
*
|
|
165
|
+
* 加载商品,然后导到商品列表里去
|
|
166
|
+
* @param {({
|
|
167
|
+
* category_ids?: number[];
|
|
168
|
+
* product_ids?: number[];
|
|
169
|
+
* collection?: number | string[];
|
|
170
|
+
* schedule_date?: string;
|
|
171
|
+
* })} {
|
|
172
|
+
* category_ids = [],
|
|
173
|
+
* product_ids = [],
|
|
174
|
+
* collection = [],
|
|
175
|
+
* schedule_date,
|
|
176
|
+
* }
|
|
177
|
+
* @return {*}
|
|
178
|
+
* @memberof BookingByStepImpl
|
|
179
|
+
*/
|
|
166
180
|
async loadProducts({
|
|
167
181
|
category_ids = [],
|
|
168
182
|
product_ids = [],
|
|
169
183
|
collection = [],
|
|
170
|
-
// schedule_ids = [],
|
|
171
184
|
schedule_date
|
|
172
185
|
}) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
const productsData = await this.request.post(
|
|
182
|
-
`/product/query`,
|
|
183
|
-
{
|
|
184
|
-
open_quotation: 1,
|
|
185
|
-
open_bundle: 0,
|
|
186
|
-
exclude_extension_type: [
|
|
187
|
-
"product_party",
|
|
188
|
-
"product_event",
|
|
189
|
-
"product_series_event",
|
|
190
|
-
"product_package_ticket",
|
|
191
|
-
"ticket",
|
|
192
|
-
"event_item"
|
|
193
|
-
],
|
|
194
|
-
with: ["category", "collection", "resourceRelation"],
|
|
195
|
-
status: "published",
|
|
196
|
-
num: 500,
|
|
197
|
-
skip: 1,
|
|
198
|
-
customer_id,
|
|
199
|
-
category_ids,
|
|
200
|
-
ids: product_ids,
|
|
201
|
-
collection,
|
|
202
|
-
front_end_cache_id: this.cacheId,
|
|
203
|
-
// client_schedule_ids: schedule_ids,
|
|
204
|
-
schedule_date
|
|
205
|
-
},
|
|
206
|
-
{ useCache: true }
|
|
207
|
-
);
|
|
208
|
-
this.store.products.addProduct(productsData.data.list);
|
|
209
|
-
return productsData.data.list;
|
|
186
|
+
return this.store.products.loadProducts({
|
|
187
|
+
category_ids,
|
|
188
|
+
product_ids,
|
|
189
|
+
collection,
|
|
190
|
+
schedule_date,
|
|
191
|
+
cacheId: this.cacheId
|
|
192
|
+
});
|
|
210
193
|
}
|
|
194
|
+
/**
|
|
195
|
+
* 通过 schedule 来读取商品,适用于 session 类商品
|
|
196
|
+
*
|
|
197
|
+
* @param {{
|
|
198
|
+
* date: string;
|
|
199
|
+
* product_ids?: number[];
|
|
200
|
+
* category_ids?: number[];
|
|
201
|
+
* }} {
|
|
202
|
+
* date,
|
|
203
|
+
* product_ids = [],
|
|
204
|
+
* category_ids = [],
|
|
205
|
+
* }
|
|
206
|
+
* @return {*}
|
|
207
|
+
* @memberof BookingByStepImpl
|
|
208
|
+
*/
|
|
211
209
|
async loadProductByScheduleDate({
|
|
212
210
|
date,
|
|
213
211
|
product_ids = [],
|
|
@@ -228,12 +226,17 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
228
226
|
(n, index, self) => self.indexOf(n) === index
|
|
229
227
|
);
|
|
230
228
|
return await this.loadProducts({
|
|
231
|
-
// schedule_ids: scheduleIds,
|
|
232
229
|
product_ids: allProductIds,
|
|
233
230
|
category_ids,
|
|
234
231
|
schedule_date: date
|
|
235
232
|
});
|
|
236
233
|
}
|
|
234
|
+
/**
|
|
235
|
+
* 更新完商品数据、切换日期、或者在较后的流程里登录了,检测当前购物车里是否有商品,如果有,则需要更新购物车里的商品价格
|
|
236
|
+
*
|
|
237
|
+
* @param {string} date
|
|
238
|
+
* @memberof BookingByStepImpl
|
|
239
|
+
*/
|
|
237
240
|
async updateQuotationPriceAndCart(date) {
|
|
238
241
|
var _a;
|
|
239
242
|
const cartItems = this.store.cart.getItems();
|
|
@@ -250,133 +253,43 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
250
253
|
schedule_date: date,
|
|
251
254
|
customer_id
|
|
252
255
|
});
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
)
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
var _a2;
|
|
264
|
-
const targetBundle = (_a2 = targetProduct == null ? void 0 : targetProduct.bundle_group) == null ? void 0 : _a2.find(
|
|
265
|
-
(m) => m.id === n.group_id
|
|
266
|
-
);
|
|
267
|
-
if (targetBundle) {
|
|
268
|
-
const targetBundleItem = targetBundle.bundle_item.find(
|
|
269
|
-
(m) => m.id === n.id
|
|
270
|
-
);
|
|
271
|
-
if (targetBundleItem) {
|
|
272
|
-
return {
|
|
273
|
-
...n,
|
|
274
|
-
price: targetBundleItem.price,
|
|
275
|
-
base_price: targetBundleItem.base_price
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
return n;
|
|
280
|
-
});
|
|
281
|
-
this.store.cart.updateItem({
|
|
282
|
-
_id: item._id,
|
|
283
|
-
product: productInfo,
|
|
284
|
-
bundle
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
this.core.effects.emit(`${this.store.cart.name}:onUpdateQuotationPrice`, {});
|
|
256
|
+
await (0, import_changePrice.updateAllCartItemPrice)(
|
|
257
|
+
cartItems,
|
|
258
|
+
res,
|
|
259
|
+
(id) => this.store.products.getProduct(id),
|
|
260
|
+
(params) => this.store.cart.updateItem(params)
|
|
261
|
+
);
|
|
262
|
+
this.core.effects.emit(
|
|
263
|
+
`${this.store.cart.name}:onUpdateQuotationPrice`,
|
|
264
|
+
{}
|
|
265
|
+
);
|
|
288
266
|
}
|
|
289
267
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
268
|
+
/**
|
|
269
|
+
* ui 层提供日期的起始范围,返回一个起始范围内日期的可用情况
|
|
270
|
+
* 适用于先选日期的流程,确定日期是否可用
|
|
271
|
+
* 已知问题:如果挂接的商品的资源不可用,后端是不会计算的
|
|
272
|
+
*
|
|
273
|
+
* @param {LoadScheduleAvailableDateParams} {
|
|
274
|
+
* startDate,
|
|
275
|
+
* endDate,
|
|
276
|
+
* custom_page_id,
|
|
277
|
+
* channel,
|
|
278
|
+
* }
|
|
279
|
+
* @memberof BookingByStepImpl
|
|
280
|
+
*/
|
|
301
281
|
async loadScheduleAvailableDate({
|
|
302
282
|
startDate,
|
|
303
283
|
endDate,
|
|
304
284
|
custom_page_id,
|
|
305
285
|
channel
|
|
306
286
|
}) {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
if ((0, import_dayjs.default)(endDate).isBefore((0, import_dayjs.default)(), "day")) {
|
|
314
|
-
return dates;
|
|
315
|
-
}
|
|
316
|
-
const res = await this.request.get(
|
|
317
|
-
`/schedule/product/availability/v2`,
|
|
318
|
-
{
|
|
319
|
-
start_date: startDate,
|
|
320
|
-
end_date: endDate,
|
|
321
|
-
custom_page_id,
|
|
322
|
-
channel
|
|
323
|
-
}
|
|
324
|
-
);
|
|
325
|
-
this.store.schedule.setAvailabilityScheduleDateList(res.data.date_list);
|
|
326
|
-
this.store.schedule.setOtherProductsIds(res.data.other_product_ids || []);
|
|
327
|
-
if (!((_a = res.data.date_list) == null ? void 0 : _a.length) && !((_b = res.data.other_product_ids) == null ? void 0 : _b.length) || (0, import_dayjs.default)(endDate).isBefore((0, import_dayjs.default)(), "day")) {
|
|
328
|
-
return dates;
|
|
329
|
-
}
|
|
330
|
-
if ((_c = res.data.other_product_ids) == null ? void 0 : _c.length) {
|
|
331
|
-
dates.forEach((n) => {
|
|
332
|
-
n.status = "available";
|
|
333
|
-
});
|
|
334
|
-
} else {
|
|
335
|
-
res.data.date_list.forEach((n) => {
|
|
336
|
-
const index = dates.findIndex((m) => m.date === n.date);
|
|
337
|
-
if (index !== -1) {
|
|
338
|
-
dates[index].status = "available";
|
|
339
|
-
}
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
dates = (0, import_utils3.disableDatesBeforeOneDay)(dates);
|
|
343
|
-
return dates;
|
|
344
|
-
}
|
|
345
|
-
async storeProduct(productData) {
|
|
346
|
-
const activeAccount = this.getActiveAccount();
|
|
347
|
-
const { bundle, options, origin, product_variant_id, quantity = 1, rowKey } = productData || {};
|
|
348
|
-
const cartItems = this.store.cart.getItems();
|
|
349
|
-
if (rowKey) {
|
|
350
|
-
const currentAccount = this.store.accountList.getActiveAccount();
|
|
351
|
-
const targetCartItem = cartItems.find((n) => {
|
|
352
|
-
var _a;
|
|
353
|
-
return ((_a = n._productOrigin) == null ? void 0 : _a.rowKey) === rowKey && n.holder_id === (currentAccount == null ? void 0 : currentAccount.getId());
|
|
354
|
-
});
|
|
355
|
-
const targetAccount = targetCartItem == null ? void 0 : targetCartItem.holder_id;
|
|
356
|
-
const isSameAccount = (currentAccount == null ? void 0 : currentAccount.getId()) === targetAccount;
|
|
357
|
-
if (targetCartItem && (0, import_utils4.isNormalProduct)(targetCartItem._productOrigin) && isSameAccount) {
|
|
358
|
-
this.store.cart.updateItem({
|
|
359
|
-
_id: targetCartItem._id,
|
|
360
|
-
product: {
|
|
361
|
-
...targetCartItem._productOrigin
|
|
362
|
-
},
|
|
363
|
-
quantity: (targetCartItem.num || 1) + quantity
|
|
364
|
-
});
|
|
365
|
-
this.core.effects.emit(`${this.store.cart.name}:onUpdateCartItemNums`, {});
|
|
366
|
-
return;
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
const product = { ...origin, product_variant_id, rowKey };
|
|
370
|
-
const addCartItem = {
|
|
371
|
-
product,
|
|
372
|
-
bundle,
|
|
373
|
-
options,
|
|
374
|
-
quantity
|
|
375
|
-
};
|
|
376
|
-
if (activeAccount) {
|
|
377
|
-
addCartItem.account = activeAccount;
|
|
378
|
-
}
|
|
379
|
-
this.store.cart.addItem(addCartItem);
|
|
287
|
+
return await this.store.schedule.loadScheduleAvailableDate({
|
|
288
|
+
startDate,
|
|
289
|
+
endDate,
|
|
290
|
+
custom_page_id,
|
|
291
|
+
channel
|
|
292
|
+
});
|
|
380
293
|
}
|
|
381
294
|
// 添加单个账户或者 guest
|
|
382
295
|
async addAccount(account, extra) {
|
|
@@ -429,7 +342,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
429
342
|
}
|
|
430
343
|
getActiveAccount() {
|
|
431
344
|
const activeAccount = this.store.accountList.getActiveAccount();
|
|
432
|
-
|
|
345
|
+
const account = activeAccount == null ? void 0 : activeAccount.getAccount();
|
|
346
|
+
return account === null ? void 0 : account;
|
|
433
347
|
}
|
|
434
348
|
removeAccount(id) {
|
|
435
349
|
this.store.accountList.removeAccount(id);
|
|
@@ -445,7 +359,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
445
359
|
if (cartItems.length) {
|
|
446
360
|
let date = (_b = (_a = this.store.date.getDateRange()) == null ? void 0 : _a[0]) == null ? void 0 : _b.date;
|
|
447
361
|
if (!date) {
|
|
448
|
-
const normalProductCartItem = cartItems.find(
|
|
362
|
+
const normalProductCartItem = cartItems.find(
|
|
363
|
+
(n) => !(0, import_utils4.isNormalProduct)(n._productOrigin)
|
|
364
|
+
);
|
|
449
365
|
date = (normalProductCartItem == null ? void 0 : normalProductCartItem.start_date) || "";
|
|
450
366
|
}
|
|
451
367
|
this.updateQuotationPriceAndCart(date);
|
|
@@ -552,7 +468,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
552
468
|
if (cartItems.length) {
|
|
553
469
|
let date = (_b = (_a = this.store.date.getDateRange()) == null ? void 0 : _a[0]) == null ? void 0 : _b.date;
|
|
554
470
|
if (!date) {
|
|
555
|
-
const normalProductCartItem = cartItems.find(
|
|
471
|
+
const normalProductCartItem = cartItems.find(
|
|
472
|
+
(n) => !(0, import_utils4.isNormalProduct)(n._productOrigin)
|
|
473
|
+
);
|
|
556
474
|
date = (normalProductCartItem == null ? void 0 : normalProductCartItem.start_date) || "";
|
|
557
475
|
}
|
|
558
476
|
this.updateQuotationPriceAndCart(date);
|
|
@@ -585,7 +503,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
585
503
|
const cartItems = this.store.cart.getItems();
|
|
586
504
|
const newCartItems = (0, import_lodash_es.cloneDeep)(cartItems);
|
|
587
505
|
newCartItems.forEach((item) => {
|
|
588
|
-
var _a
|
|
506
|
+
var _a;
|
|
589
507
|
if (item._origin.resources && item._origin.resources.length) {
|
|
590
508
|
item._origin.resources = item._origin.resources.map((n) => {
|
|
591
509
|
const newResourcesItem = (0, import_lodash_es.cloneDeep)(n);
|
|
@@ -594,12 +512,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
594
512
|
delete newResourcesItem.resourceType;
|
|
595
513
|
return { ...newResourcesItem };
|
|
596
514
|
});
|
|
597
|
-
const formatCapacity = (0,
|
|
598
|
-
|
|
599
|
-
product_bundle: item._origin.product.product_bundle
|
|
600
|
-
});
|
|
601
|
-
const currentCapacity = (0, import_resources.getSumCapacity)({ capacity: formatCapacity });
|
|
602
|
-
if (!((_b = item._origin) == null ? void 0 : _b.metadata)) {
|
|
515
|
+
const { currentCapacity, formatCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(item);
|
|
516
|
+
if (!((_a = item._origin) == null ? void 0 : _a.metadata)) {
|
|
603
517
|
item._origin.metadata = {};
|
|
604
518
|
}
|
|
605
519
|
item._origin.metadata.capacity = formatCapacity;
|
|
@@ -607,10 +521,14 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
607
521
|
}
|
|
608
522
|
});
|
|
609
523
|
let type = this.otherParams.isRetailTemplate ? "virtual" : "appointment_booking";
|
|
610
|
-
if ((0, import_utils4.areAllNormalProducts)(
|
|
524
|
+
if ((0, import_utils4.areAllNormalProducts)(
|
|
525
|
+
newCartItems.map((n) => n._productOrigin)
|
|
526
|
+
)) {
|
|
611
527
|
type = "virtual";
|
|
612
528
|
}
|
|
613
|
-
return this.store.order.submitOrder({
|
|
529
|
+
return this.store.order.submitOrder({
|
|
530
|
+
query: { cartItems: newCartItems, type }
|
|
531
|
+
});
|
|
614
532
|
}
|
|
615
533
|
// 拉起支付模块
|
|
616
534
|
async pay() {
|
|
@@ -628,31 +546,136 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
628
546
|
async getOtherParams() {
|
|
629
547
|
return this.otherParams;
|
|
630
548
|
}
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
549
|
+
/**
|
|
550
|
+
* 往购物车加商品数据(duration 类、普通商品)
|
|
551
|
+
* 老接口,先不删,怕 UI 有问题,直接桥接到新接口addProductToCart上
|
|
552
|
+
*
|
|
553
|
+
* @param {ProductData} productData
|
|
554
|
+
* @memberof BookingByStepImpl
|
|
555
|
+
*/
|
|
556
|
+
async storeProduct(productData) {
|
|
557
|
+
const activeAccount = this.getActiveAccount();
|
|
558
|
+
this.addProductToCart({
|
|
559
|
+
product: productData,
|
|
560
|
+
account: activeAccount
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* 往购物车加商品数据
|
|
565
|
+
*
|
|
566
|
+
* @param {({
|
|
567
|
+
* product: ProductData;
|
|
568
|
+
* date?: { startTime: string; endTime: string } | null;
|
|
569
|
+
* account?: Account | null;
|
|
570
|
+
* })} {
|
|
571
|
+
* product,
|
|
572
|
+
* date,
|
|
573
|
+
* account,
|
|
574
|
+
* }
|
|
575
|
+
* @return {*}
|
|
576
|
+
* @memberof BookingByStepImpl
|
|
577
|
+
*/
|
|
578
|
+
addProductToCart({
|
|
579
|
+
product,
|
|
580
|
+
date,
|
|
581
|
+
account
|
|
582
|
+
}) {
|
|
583
|
+
const {
|
|
584
|
+
bundle,
|
|
585
|
+
options,
|
|
586
|
+
origin,
|
|
587
|
+
product_variant_id,
|
|
588
|
+
rowKey,
|
|
589
|
+
quantity = 1
|
|
590
|
+
} = product || {};
|
|
591
|
+
const productData = { ...origin, product_variant_id };
|
|
592
|
+
if (!account) {
|
|
593
|
+
const activeAccount = this.getActiveAccount();
|
|
594
|
+
if (activeAccount) {
|
|
595
|
+
account = activeAccount;
|
|
596
|
+
}
|
|
637
597
|
}
|
|
638
|
-
|
|
598
|
+
const flag = this.store.cart.mergeCartItemByRowKey({
|
|
599
|
+
rowKey,
|
|
600
|
+
quantity,
|
|
601
|
+
account: account || void 0
|
|
602
|
+
});
|
|
603
|
+
if (flag) {
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
const addItemParams = {
|
|
607
|
+
product: productData,
|
|
608
|
+
bundle,
|
|
609
|
+
options,
|
|
610
|
+
quantity
|
|
611
|
+
};
|
|
612
|
+
if (date) {
|
|
613
|
+
addItemParams.date = date;
|
|
614
|
+
}
|
|
615
|
+
if (account) {
|
|
616
|
+
addItemParams.account = account;
|
|
617
|
+
}
|
|
618
|
+
this.addProductCheck({ date });
|
|
619
|
+
this.store.cart.addItem(addItemParams);
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* 添加完购物车以后做的一些检测,比如日期是否在同一天
|
|
623
|
+
*
|
|
624
|
+
* @param {({ date?: { startTime: string; endTime: string } | null })} { date }
|
|
625
|
+
* @memberof BookingByStepImpl
|
|
626
|
+
*/
|
|
627
|
+
addProductCheck({
|
|
628
|
+
date
|
|
629
|
+
}) {
|
|
630
|
+
if (date) {
|
|
631
|
+
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
|
|
632
|
+
const cartItemsByDate = cartItems.filter(
|
|
633
|
+
(n) => !(0, import_dayjs.default)(n.start_date).isSame((0, import_dayjs.default)(date.startTime), "day")
|
|
634
|
+
);
|
|
635
|
+
if (cartItemsByDate.length) {
|
|
636
|
+
cartItemsByDate.forEach((n) => {
|
|
637
|
+
this.store.cart.removeItem(n._id);
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
beforeUpdateCart(params, targetCartItem) {
|
|
639
643
|
if (params.resources) {
|
|
640
|
-
const
|
|
641
|
-
capacity: (_a = targetCartItem._productOrigin) == null ? void 0 : _a.capacity,
|
|
642
|
-
product_bundle: targetCartItem._origin.product.product_bundle
|
|
643
|
-
});
|
|
644
|
-
const currentCapacity = (0, import_resources.getSumCapacity)({ capacity: formatCapacity });
|
|
644
|
+
const { currentCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(targetCartItem);
|
|
645
645
|
params.resources = params.resources.map((n) => {
|
|
646
646
|
n.capacity = currentCapacity || 1;
|
|
647
|
-
|
|
648
|
-
(0, import_resources.checkSubResourcesCapacity)(n);
|
|
647
|
+
(0, import_capacity.checkSubResourcesCapacity)(n);
|
|
649
648
|
return n;
|
|
650
649
|
});
|
|
651
650
|
}
|
|
651
|
+
}
|
|
652
|
+
// 更新购物车
|
|
653
|
+
updateCart(params) {
|
|
654
|
+
const targetCartItem = this.store.cart.getItem(params._id);
|
|
655
|
+
if (!targetCartItem) {
|
|
656
|
+
throw new Error(`没有找到${params._id}购物车商品`);
|
|
657
|
+
}
|
|
658
|
+
this.beforeUpdateCart(params, targetCartItem);
|
|
652
659
|
this.store.cart.updateItem(params);
|
|
660
|
+
this.updateCartCheck(params, targetCartItem);
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* 更新购物车以后的一些操作,比如检测资源是否重复,检测资源容量是否足够
|
|
664
|
+
*
|
|
665
|
+
* @param {IUpdateItemParams} params
|
|
666
|
+
* @param {CartItem} targetCartItem
|
|
667
|
+
* @return {*}
|
|
668
|
+
* @memberof BookingByStepImpl
|
|
669
|
+
*/
|
|
670
|
+
updateCartCheck(params, targetCartItem) {
|
|
671
|
+
var _a;
|
|
653
672
|
if (this.otherParams.isRetailTemplate) {
|
|
654
673
|
return;
|
|
655
674
|
}
|
|
675
|
+
let currentResourcesCapacityMap = {};
|
|
676
|
+
(_a = params.resources) == null ? void 0 : _a.forEach((n) => {
|
|
677
|
+
currentResourcesCapacityMap[n.id] = n.capacity;
|
|
678
|
+
});
|
|
656
679
|
const allOriginResources = [];
|
|
657
680
|
const dateRange = this.store.date.getDateRange();
|
|
658
681
|
if (dateRange == null ? void 0 : dateRange.length) {
|
|
@@ -673,50 +696,31 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
673
696
|
cartItems.forEach((item) => {
|
|
674
697
|
var _a2;
|
|
675
698
|
if (item._id !== targetCartItem._id) {
|
|
699
|
+
const { currentCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(item);
|
|
676
700
|
const resources = (_a2 = item._origin.resources) == null ? void 0 : _a2.filter((m) => {
|
|
677
|
-
const sameFormIdResources =
|
|
701
|
+
const sameFormIdResources = (0, import_resources.filterResourcesByFormItem)(
|
|
702
|
+
targetCartItem._origin.resources,
|
|
703
|
+
m.form_id
|
|
704
|
+
);
|
|
678
705
|
if (!(sameFormIdResources == null ? void 0 : sameFormIdResources.length)) {
|
|
679
706
|
return true;
|
|
680
707
|
}
|
|
681
708
|
return !sameFormIdResources.some((targetRes) => {
|
|
682
|
-
var _a3, _b, _c;
|
|
683
709
|
if (targetRes.resourceType !== "single") {
|
|
684
|
-
const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
|
|
685
|
-
capacity: (_a3 = item._productOrigin) == null ? void 0 : _a3.capacity,
|
|
686
|
-
product_bundle: item._origin.product.product_bundle
|
|
687
|
-
});
|
|
688
|
-
const currentCapacity = (0, import_resources.getSumCapacity)({
|
|
689
|
-
capacity: formatCapacity
|
|
690
|
-
});
|
|
691
710
|
const originResource = allOriginResources.find(
|
|
692
711
|
(n) => n.id === targetRes.id
|
|
693
712
|
);
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
713
|
+
const canUse = (0, import_capacity.checkResourceCanUseByCapacity)(
|
|
714
|
+
currentResourcesCapacityMap[m.id],
|
|
715
|
+
currentCapacity,
|
|
716
|
+
originResource == null ? void 0 : originResource.capacity
|
|
717
|
+
);
|
|
718
|
+
if (canUse)
|
|
719
|
+
currentResourcesCapacityMap[m.id] += currentCapacity;
|
|
720
|
+
return !canUse;
|
|
699
721
|
}
|
|
700
722
|
if (item.holder_id !== (targetCartItem == null ? void 0 : targetCartItem.holder_id)) {
|
|
701
|
-
|
|
702
|
-
return true;
|
|
703
|
-
if (((_b = targetRes.metadata.combined_resource) == null ? void 0 : _b.status) === 1 && // 如果现在选择的是组合资源,需要判断
|
|
704
|
-
// 1、当前其他购物车里是否选了当前组合资源的子资源
|
|
705
|
-
// 2、如果其他购物车里的商品也是组合资源,出了组合资源本身的 id 需要判断,还需要判断子资源的 id 是否有交集
|
|
706
|
-
(targetRes.metadata.combined_resource.resource_ids.includes(
|
|
707
|
-
m.id
|
|
708
|
-
) || targetRes.metadata.combined_resource.resource_ids.some(
|
|
709
|
-
(n) => {
|
|
710
|
-
return m.metadata.combined_resource.resource_ids.includes(
|
|
711
|
-
n
|
|
712
|
-
);
|
|
713
|
-
}
|
|
714
|
-
)))
|
|
715
|
-
return true;
|
|
716
|
-
if (((_c = m.metadata.combined_resource) == null ? void 0 : _c.status) === 1 && m.metadata.combined_resource.resource_ids.includes(
|
|
717
|
-
targetRes.id
|
|
718
|
-
))
|
|
719
|
-
return true;
|
|
723
|
+
return (0, import_resources.checkTwoResourcesIntersection)(targetRes, m);
|
|
720
724
|
}
|
|
721
725
|
return false;
|
|
722
726
|
});
|
|
@@ -813,8 +817,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
813
817
|
const resources = [];
|
|
814
818
|
if (dateRange == null ? void 0 : dateRange.length) {
|
|
815
819
|
dateRange.forEach((n) => {
|
|
816
|
-
|
|
817
|
-
resources.push(...n.resource);
|
|
820
|
+
resources.push(...this.store.date.getResourcesListByDate(n.date) || []);
|
|
818
821
|
});
|
|
819
822
|
}
|
|
820
823
|
if (!resources.length) {
|
|
@@ -828,14 +831,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
828
831
|
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
|
|
829
832
|
const arr = [];
|
|
830
833
|
cartItems.forEach((cartItem) => {
|
|
831
|
-
var _a, _b, _c, _d, _e, _f
|
|
834
|
+
var _a, _b, _c, _d, _e, _f;
|
|
832
835
|
let selectedResources = [];
|
|
833
|
-
const formatCapacity = (0,
|
|
834
|
-
capacity: (_a = cartItem._productOrigin) == null ? void 0 : _a.capacity,
|
|
835
|
-
product_bundle: cartItem._origin.product.product_bundle
|
|
836
|
-
});
|
|
836
|
+
const { currentCapacity, formatCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(cartItem);
|
|
837
837
|
cartItem._origin.metadata.capacity = formatCapacity;
|
|
838
|
-
const currentCapacity = (0, import_resources.getSumCapacity)({ capacity: formatCapacity });
|
|
839
838
|
if (cartItem.holder_id) {
|
|
840
839
|
selectedResources = (0, import_resources.getOthersSelectedResources)(
|
|
841
840
|
cartItems,
|
|
@@ -851,7 +850,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
851
850
|
}
|
|
852
851
|
const productResources = (0, import_resources.getResourcesByProduct)(
|
|
853
852
|
resourcesMap,
|
|
854
|
-
((
|
|
853
|
+
((_b = (_a = cartItem._productOrigin) == null ? void 0 : _a.product_resource) == null ? void 0 : _b.resources) || [],
|
|
855
854
|
selectedResources,
|
|
856
855
|
currentCapacity
|
|
857
856
|
);
|
|
@@ -864,20 +863,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
864
863
|
);
|
|
865
864
|
const resourcesUseableMap = {};
|
|
866
865
|
productResources.forEach((n) => {
|
|
867
|
-
n.renderList =
|
|
868
|
-
var _a2, _b2, _c2, _d2;
|
|
869
|
-
const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
|
|
870
|
-
const bIsCombined = ((_d2 = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d2.status) === 1;
|
|
871
|
-
if (aIsCombined && !bIsCombined)
|
|
872
|
-
return 1;
|
|
873
|
-
if (!aIsCombined && bIsCombined)
|
|
874
|
-
return -1;
|
|
875
|
-
return 0;
|
|
876
|
-
});
|
|
866
|
+
n.renderList = (0, import_resources.sortCombinedResources)(n.renderList);
|
|
877
867
|
n.renderList = n.renderList.filter((m) => {
|
|
878
|
-
const mTimes =
|
|
879
|
-
|
|
880
|
-
|
|
868
|
+
const mTimes = (0, import_timeslots.filterConditionTimeSlots)(
|
|
869
|
+
m.times,
|
|
870
|
+
startTime,
|
|
871
|
+
endTime
|
|
872
|
+
);
|
|
881
873
|
if (mTimes.length === 0) {
|
|
882
874
|
return false;
|
|
883
875
|
}
|
|
@@ -907,8 +899,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
907
899
|
});
|
|
908
900
|
});
|
|
909
901
|
} else {
|
|
910
|
-
const hasFlexibleDuration = ((
|
|
911
|
-
const operating_day_boundary = (
|
|
902
|
+
const hasFlexibleDuration = ((_d = (_c = cartItem._productOrigin) == null ? void 0 : _c.duration) == null ? void 0 : _d.type) === "flexible";
|
|
903
|
+
const operating_day_boundary = (_f = (_e = this.shopStore.get("core")) == null ? void 0 : _e.core) == null ? void 0 : _f.operating_day_boundary;
|
|
912
904
|
productResources.forEach((item) => {
|
|
913
905
|
item.renderList = item.renderList.filter((n) => {
|
|
914
906
|
var _a2, _b2, _c2;
|
|
@@ -941,138 +933,28 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
941
933
|
});
|
|
942
934
|
return arr;
|
|
943
935
|
}
|
|
944
|
-
|
|
936
|
+
/**
|
|
937
|
+
* 在日期那边点击下一步的时候,检查这一天购物车里的商品是不是都有资源可以用
|
|
938
|
+
*
|
|
939
|
+
* @return {*}
|
|
940
|
+
* @memberof BookingByStepImpl
|
|
941
|
+
*/
|
|
945
942
|
checkResourceListForDate() {
|
|
946
|
-
const
|
|
947
|
-
const
|
|
948
|
-
|
|
949
|
-
dateRange.forEach((n) => {
|
|
950
|
-
if (n.resource)
|
|
951
|
-
resources.push(...n.resource);
|
|
952
|
-
});
|
|
953
|
-
}
|
|
954
|
-
if (!resources.length) {
|
|
955
|
-
const dateList = this.store.date.getDateList();
|
|
956
|
-
dateList.forEach((n) => {
|
|
957
|
-
if (n.resource)
|
|
958
|
-
resources.push(...n.resource);
|
|
959
|
-
});
|
|
960
|
-
}
|
|
961
|
-
const resourcesMap = (0, import_utils.getResourcesMap)((0, import_lodash_es.cloneDeep)(resources));
|
|
962
|
-
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
|
|
963
|
-
const arr = [];
|
|
964
|
-
cartItems.forEach((cartItem) => {
|
|
965
|
-
var _a, _b, _c;
|
|
966
|
-
let selectedResources = [];
|
|
967
|
-
const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
|
|
968
|
-
capacity: (_a = cartItem._productOrigin) == null ? void 0 : _a.capacity,
|
|
969
|
-
product_bundle: cartItem._origin.product.product_bundle
|
|
970
|
-
});
|
|
971
|
-
cartItem._origin.metadata.capacity = formatCapacity;
|
|
972
|
-
const currentCapacity = (0, import_resources.getSumCapacity)({ capacity: formatCapacity });
|
|
973
|
-
if (cartItem.holder_id) {
|
|
974
|
-
selectedResources = (0, import_resources.getOthersSelectedResources)(
|
|
975
|
-
cartItems,
|
|
976
|
-
cartItem.holder_id,
|
|
977
|
-
resourcesMap
|
|
978
|
-
);
|
|
979
|
-
} else {
|
|
980
|
-
selectedResources = (0, import_resources.getOthersCartSelectedResources)(
|
|
981
|
-
cartItems,
|
|
982
|
-
cartItem._id,
|
|
983
|
-
resourcesMap
|
|
984
|
-
);
|
|
985
|
-
}
|
|
986
|
-
const productResources = (0, import_resources.getResourcesByProduct)(
|
|
987
|
-
resourcesMap,
|
|
988
|
-
((_c = (_b = cartItem._productOrigin) == null ? void 0 : _b.product_resource) == null ? void 0 : _c.resources) || [],
|
|
989
|
-
selectedResources,
|
|
990
|
-
currentCapacity
|
|
991
|
-
);
|
|
992
|
-
if (cartItem._origin.start_time) {
|
|
993
|
-
const startTime = (0, import_dayjs.default)(
|
|
994
|
-
`${cartItem._origin.start_date} ${cartItem._origin.start_time}`
|
|
995
|
-
);
|
|
996
|
-
const endTime = (0, import_dayjs.default)(
|
|
997
|
-
`${cartItem._origin.end_date} ${cartItem._origin.end_time}`
|
|
998
|
-
);
|
|
999
|
-
const resourcesUseableMap = {};
|
|
1000
|
-
productResources.forEach((n) => {
|
|
1001
|
-
n.renderList = n.renderList.sort((a, b) => {
|
|
1002
|
-
var _a2, _b2, _c2, _d;
|
|
1003
|
-
const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
|
|
1004
|
-
const bIsCombined = ((_d = (_c2 = b.metadata) == null ? void 0 : _c2.combined_resource) == null ? void 0 : _d.status) === 1;
|
|
1005
|
-
if (aIsCombined && !bIsCombined)
|
|
1006
|
-
return 1;
|
|
1007
|
-
if (!aIsCombined && bIsCombined)
|
|
1008
|
-
return -1;
|
|
1009
|
-
return 0;
|
|
1010
|
-
});
|
|
1011
|
-
n.renderList = n.renderList.filter((m) => {
|
|
1012
|
-
const mTimes = m.times.filter((n2) => {
|
|
1013
|
-
return !(0, import_dayjs.default)(n2.start_at).isAfter((0, import_dayjs.default)(startTime)) && !(0, import_dayjs.default)(n2.end_at).isBefore((0, import_dayjs.default)(endTime));
|
|
1014
|
-
});
|
|
1015
|
-
if (mTimes.length === 0) {
|
|
1016
|
-
return false;
|
|
1017
|
-
}
|
|
1018
|
-
const canUseArr = mTimes.map((item) => {
|
|
1019
|
-
var _a2;
|
|
1020
|
-
const res = (0, import_resources.getIsUsableByTimeItem)({
|
|
1021
|
-
timeSlice: {
|
|
1022
|
-
start_time: startTime.format("HH:mm"),
|
|
1023
|
-
end_time: endTime.format("HH:mm"),
|
|
1024
|
-
start_at: startTime,
|
|
1025
|
-
end_at: endTime
|
|
1026
|
-
},
|
|
1027
|
-
time: item,
|
|
1028
|
-
resource: m,
|
|
1029
|
-
currentCount: currentCapacity || 0,
|
|
1030
|
-
resourcesUseableMap,
|
|
1031
|
-
cut_off_time: (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.cut_off_time
|
|
1032
|
-
});
|
|
1033
|
-
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== "capacityOnly") {
|
|
1034
|
-
resourcesUseableMap[m.id] = res.usable;
|
|
1035
|
-
}
|
|
1036
|
-
return res.usable;
|
|
1037
|
-
});
|
|
1038
|
-
if (m.onlyComputed)
|
|
1039
|
-
return false;
|
|
1040
|
-
return !canUseArr.some((n2) => n2 === false);
|
|
1041
|
-
});
|
|
1042
|
-
});
|
|
1043
|
-
} else {
|
|
1044
|
-
productResources.forEach((item) => {
|
|
1045
|
-
item.renderList = item.renderList.filter((n) => {
|
|
1046
|
-
var _a2, _b2;
|
|
1047
|
-
const recordCount = n.capacity || 0;
|
|
1048
|
-
if (n.onlyComputed)
|
|
1049
|
-
return false;
|
|
1050
|
-
const timeSlots = (0, import_resources.getTimeSlicesByResource)({
|
|
1051
|
-
resource: n,
|
|
1052
|
-
duration: ((_b2 = (_a2 = cartItem._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10,
|
|
1053
|
-
split: 10,
|
|
1054
|
-
currentDate: dateRange[0].date
|
|
1055
|
-
});
|
|
1056
|
-
return recordCount >= currentCapacity && timeSlots.length > 0;
|
|
1057
|
-
});
|
|
1058
|
-
});
|
|
1059
|
-
}
|
|
1060
|
-
arr.push({
|
|
1061
|
-
id: cartItem.id,
|
|
1062
|
-
// 这里返回的是购物车 id ,后面提交的时候要用的,用这个 id 绑定资源和时间
|
|
1063
|
-
_id: cartItem._id,
|
|
1064
|
-
// 这里返回的是购物车 id ,后面提交的时候要用的,用这个 id 绑定资源和时间
|
|
1065
|
-
productResources
|
|
1066
|
-
});
|
|
1067
|
-
});
|
|
1068
|
-
const hasResource = arr.every(
|
|
1069
|
-
(n) => n.productResources.every((m) => m.renderList.length > 0)
|
|
943
|
+
const resourcesList = this.getResourcesList();
|
|
944
|
+
const hasResource = resourcesList.every(
|
|
945
|
+
(item) => item.resources.every((resource) => resource.renderList.length > 0)
|
|
1070
946
|
);
|
|
1071
947
|
return hasResource;
|
|
1072
948
|
}
|
|
1073
|
-
|
|
949
|
+
/**
|
|
950
|
+
* 给单个购物车里的商品获取资源列表,给 UI 用的
|
|
951
|
+
*
|
|
952
|
+
* @param {(string | number)} id
|
|
953
|
+
* @return {*}
|
|
954
|
+
* @memberof BookingByStepImpl
|
|
955
|
+
*/
|
|
1074
956
|
getResourcesListByCartItem(id) {
|
|
1075
|
-
var _a, _b
|
|
957
|
+
var _a, _b;
|
|
1076
958
|
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
|
|
1077
959
|
const dateRange = this.store.date.getDateRange();
|
|
1078
960
|
const resources = [];
|
|
@@ -1086,11 +968,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1086
968
|
throw new Error(`没有找到${id}购物车商品`);
|
|
1087
969
|
}
|
|
1088
970
|
let selectedResources = [];
|
|
1089
|
-
const
|
|
1090
|
-
capacity: (_a = targetCartItem._productOrigin) == null ? void 0 : _a.capacity,
|
|
1091
|
-
product_bundle: targetCartItem._origin.product.product_bundle
|
|
1092
|
-
});
|
|
1093
|
-
const currentCapacity = (0, import_resources.getSumCapacity)({ capacity: formatCapacity });
|
|
971
|
+
const { currentCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(targetCartItem);
|
|
1094
972
|
if (targetCartItem.holder_id) {
|
|
1095
973
|
selectedResources = (0, import_resources.getOthersSelectedResources)(
|
|
1096
974
|
cartItems,
|
|
@@ -1106,7 +984,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1106
984
|
}
|
|
1107
985
|
const productResources = (0, import_resources.getResourcesByProduct)(
|
|
1108
986
|
resourcesMap,
|
|
1109
|
-
((
|
|
987
|
+
((_b = (_a = targetCartItem._productOrigin) == null ? void 0 : _a.product_resource) == null ? void 0 : _b.resources) || [],
|
|
1110
988
|
selectedResources,
|
|
1111
989
|
currentCapacity
|
|
1112
990
|
);
|
|
@@ -1131,21 +1009,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1131
1009
|
};
|
|
1132
1010
|
}
|
|
1133
1011
|
}
|
|
1134
|
-
// 通过资源列表和指定的资源 id,获取指定资源的时间切片
|
|
1135
|
-
getResourceTimeSlot({
|
|
1136
|
-
product,
|
|
1137
|
-
resources,
|
|
1138
|
-
currentResourceId
|
|
1139
|
-
}) {
|
|
1140
|
-
const dateRange = this.store.date.getDateRange();
|
|
1141
|
-
const timeSlots = (0, import_resources.getTimeSlicesByResource)({
|
|
1142
|
-
resource: resources.find((n) => n.id === currentResourceId),
|
|
1143
|
-
duration: product.duration.value,
|
|
1144
|
-
split: 10,
|
|
1145
|
-
currentDate: dateRange[0].date
|
|
1146
|
-
});
|
|
1147
|
-
return timeSlots;
|
|
1148
|
-
}
|
|
1149
1012
|
// 自动分派可用资源-pro 版,ui 传递某个账号,自动给某个账号下所有商品分配第一种资源
|
|
1150
1013
|
autoSelectAccountResources({
|
|
1151
1014
|
cartItem,
|
|
@@ -1301,17 +1164,15 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1301
1164
|
const accountList = this.store.accountList.getAccounts();
|
|
1302
1165
|
const selectForCartResources = (cartItems2) => {
|
|
1303
1166
|
let recordTimeSlots = (0, import_lodash_es.cloneDeep)(timeSlots);
|
|
1304
|
-
const hasFlexibleProduct = cartItems2.some(
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1167
|
+
const hasFlexibleProduct = cartItems2.some(
|
|
1168
|
+
(item) => {
|
|
1169
|
+
var _a2, _b;
|
|
1170
|
+
return ((_b = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b.type) === "flexible";
|
|
1171
|
+
}
|
|
1172
|
+
);
|
|
1308
1173
|
cartItems2.forEach((item, index) => {
|
|
1309
|
-
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l
|
|
1310
|
-
const
|
|
1311
|
-
capacity: (_a2 = item._productOrigin) == null ? void 0 : _a2.capacity,
|
|
1312
|
-
product_bundle: item._origin.product.product_bundle
|
|
1313
|
-
});
|
|
1314
|
-
const currentCapacity = (0, import_resources.getSumCapacity)({ capacity: formatCapacity });
|
|
1174
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
1175
|
+
const { currentCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(item);
|
|
1315
1176
|
if (item._origin.start_time && !(timeSlots == null ? void 0 : timeSlots.start_time)) {
|
|
1316
1177
|
recordTimeSlots = {
|
|
1317
1178
|
start_time: item._origin.start_time,
|
|
@@ -1321,17 +1182,16 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1321
1182
|
};
|
|
1322
1183
|
}
|
|
1323
1184
|
if (recordTimeSlots) {
|
|
1324
|
-
const currentResourceConfig = (
|
|
1185
|
+
const currentResourceConfig = (_c = (_b = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b.resources) == null ? void 0 : _c.find(
|
|
1325
1186
|
(n) => n.code === resources_code
|
|
1326
1187
|
);
|
|
1327
|
-
|
|
1328
|
-
if (index !== 0 && recordTimeSlots && (currentResourceConfig == null ? void 0 : currentResourceConfig.type) === "single" && ((_e = item._productOrigin) == null ? void 0 : _e.duration) && !hasFlexibleProduct) {
|
|
1188
|
+
if (index !== 0 && recordTimeSlots && (currentResourceConfig == null ? void 0 : currentResourceConfig.type) === "single" && ((_d = item._productOrigin) == null ? void 0 : _d.duration) && !hasFlexibleProduct) {
|
|
1329
1189
|
let start_at = (0, import_dayjs.default)(recordTimeSlots.end_time).add(
|
|
1330
|
-
((
|
|
1190
|
+
((_f = (_e = item._productOrigin) == null ? void 0 : _e.duration) == null ? void 0 : _f.value) || 10,
|
|
1331
1191
|
"minutes"
|
|
1332
1192
|
);
|
|
1333
1193
|
let end_at = start_at.add(
|
|
1334
|
-
((
|
|
1194
|
+
((_h = (_g = item._productOrigin) == null ? void 0 : _g.duration) == null ? void 0 : _h.value) || 10,
|
|
1335
1195
|
"minutes"
|
|
1336
1196
|
);
|
|
1337
1197
|
recordTimeSlots = {
|
|
@@ -1364,7 +1224,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1364
1224
|
});
|
|
1365
1225
|
}
|
|
1366
1226
|
res.selectedResource.capacity = currentCapacity;
|
|
1367
|
-
(0,
|
|
1227
|
+
(0, import_capacity.checkSubResourcesCapacity)(res.selectedResource);
|
|
1368
1228
|
this.store.cart.updateItem({
|
|
1369
1229
|
_id: item._id,
|
|
1370
1230
|
// 这里要做去重,避免出现同样类型的资源被塞进同一个商品
|
|
@@ -1385,7 +1245,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1385
1245
|
const allCartItems = (0, import_lodash_es.cloneDeep)(this.store.cart.getItems());
|
|
1386
1246
|
let selectedResources = [];
|
|
1387
1247
|
const resources2 = (0, import_lodash_es.cloneDeep)(
|
|
1388
|
-
((
|
|
1248
|
+
((_j = (_i = item._productOrigin) == null ? void 0 : _i.product_resource) == null ? void 0 : _j.resources) || []
|
|
1389
1249
|
);
|
|
1390
1250
|
const currentResourcesRenderList = [];
|
|
1391
1251
|
resources2.forEach((n) => {
|
|
@@ -1433,11 +1293,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1433
1293
|
return recordCount >= currentCapacity;
|
|
1434
1294
|
});
|
|
1435
1295
|
});
|
|
1436
|
-
const targetRenderList = (
|
|
1296
|
+
const targetRenderList = (_k = productResources.find(
|
|
1437
1297
|
(n) => n.code === resources_code
|
|
1438
|
-
)) == null ? void 0 :
|
|
1298
|
+
)) == null ? void 0 : _k.renderList;
|
|
1439
1299
|
if (targetRenderList && targetRenderList.length > 0) {
|
|
1440
|
-
if ((
|
|
1300
|
+
if ((_l = item._origin.resources) == null ? void 0 : _l.some(
|
|
1441
1301
|
(n) => n.form_id === targetRenderList[0].form_id
|
|
1442
1302
|
)) {
|
|
1443
1303
|
return;
|
|
@@ -1449,7 +1309,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1449
1309
|
});
|
|
1450
1310
|
const targetResource = fastestResource || targetRenderList[0];
|
|
1451
1311
|
targetResource.capacity = currentCapacity;
|
|
1452
|
-
(0,
|
|
1312
|
+
(0, import_capacity.checkSubResourcesCapacity)(targetResource);
|
|
1453
1313
|
if (!selectResourcesMap[targetResource.id]) {
|
|
1454
1314
|
selectResourcesMap[targetResource.id] = currentCapacity;
|
|
1455
1315
|
} else {
|
|
@@ -1571,10 +1431,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1571
1431
|
];
|
|
1572
1432
|
}
|
|
1573
1433
|
const resourcesUseableMap = {};
|
|
1574
|
-
const hasFlexibleDuration = cartItems.some(
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1434
|
+
const hasFlexibleDuration = cartItems.some(
|
|
1435
|
+
(item) => {
|
|
1436
|
+
var _a2, _b2;
|
|
1437
|
+
return ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.type) === "flexible";
|
|
1438
|
+
}
|
|
1439
|
+
);
|
|
1578
1440
|
const operating_day_boundary = (_h = (_g = this.shopStore.get("core")) == null ? void 0 : _g.core) == null ? void 0 : _h.operating_day_boundary;
|
|
1579
1441
|
const timeSlots = (0, import_resources.getTimeSlicesByResources)({
|
|
1580
1442
|
resourceIds,
|
|
@@ -1593,7 +1455,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1593
1455
|
submitTimeSlot(timeSlots) {
|
|
1594
1456
|
var _a, _b;
|
|
1595
1457
|
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
|
|
1596
|
-
const allResources = this.store.date.getResourcesListByDate(
|
|
1458
|
+
const allResources = this.store.date.getResourcesListByDate(
|
|
1459
|
+
timeSlots.start_at.format("YYYY-MM-DD")
|
|
1460
|
+
);
|
|
1597
1461
|
const itemsByAccount = cartItems.reduce(
|
|
1598
1462
|
(acc, item) => {
|
|
1599
1463
|
const holderId = item.holder_id;
|
|
@@ -1619,13 +1483,22 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1619
1483
|
value: 10
|
|
1620
1484
|
};
|
|
1621
1485
|
resource.startTime = timeSlots.start_at.format("YYYY-MM-DD HH:mm");
|
|
1622
|
-
const targetResourceTimes = (_c = allResources == null ? void 0 : allResources.find(
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1486
|
+
const targetResourceTimes = (_c = allResources == null ? void 0 : allResources.find(
|
|
1487
|
+
(n) => n.id === resource.id
|
|
1488
|
+
)) == null ? void 0 : _c.times;
|
|
1489
|
+
const resourcesEndTime = targetResourceTimes.reduce(
|
|
1490
|
+
(acc, curr) => {
|
|
1491
|
+
return (0, import_dayjs.default)(curr.end_at).isBefore((0, import_dayjs.default)(acc.end_at)) ? curr : acc;
|
|
1492
|
+
},
|
|
1493
|
+
targetResourceTimes[0]
|
|
1494
|
+
);
|
|
1495
|
+
const resourceDate = (0, import_dayjs.default)(resourcesEndTime.end_at).format(
|
|
1496
|
+
"YYYY-MM-DD"
|
|
1497
|
+
);
|
|
1627
1498
|
const operatingBoundaryDateTime = `${resourceDate} ${operating_day_boundary.type === "start_time" ? "23:59" : operating_day_boundary.time}`;
|
|
1628
|
-
const endTime = (0, import_dayjs.default)(resourcesEndTime.end_at).isBefore(
|
|
1499
|
+
const endTime = (0, import_dayjs.default)(resourcesEndTime.end_at).isBefore(
|
|
1500
|
+
(0, import_dayjs.default)(operatingBoundaryDateTime)
|
|
1501
|
+
) ? resourcesEndTime.end_at : operatingBoundaryDateTime;
|
|
1629
1502
|
let formattedEndTime;
|
|
1630
1503
|
if (typeof endTime === "string" && endTime.includes(":") && !endTime.includes(" ") && !endTime.includes("T")) {
|
|
1631
1504
|
const currentDate = timeSlots.start_at.format("YYYY-MM-DD");
|
|
@@ -1636,10 +1509,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1636
1509
|
resource.endTime = formattedEndTime.format("YYYY-MM-DD HH:mm");
|
|
1637
1510
|
} else {
|
|
1638
1511
|
resource.startTime = currentStartTime;
|
|
1639
|
-
resource.endTime = (0, import_dayjs.default)(currentStartTime).add(
|
|
1640
|
-
((_e = (_d = item._productOrigin) == null ? void 0 : _d.duration) == null ? void 0 : _e.value) || 10,
|
|
1641
|
-
"minutes"
|
|
1642
|
-
).format("YYYY-MM-DD HH:mm");
|
|
1512
|
+
resource.endTime = (0, import_dayjs.default)(currentStartTime).add(((_e = (_d = item._productOrigin) == null ? void 0 : _d.duration) == null ? void 0 : _e.value) || 10, "minutes").format("YYYY-MM-DD HH:mm");
|
|
1643
1513
|
}
|
|
1644
1514
|
});
|
|
1645
1515
|
this.store.cart.updateItem({
|
|
@@ -1685,10 +1555,21 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1685
1555
|
if (targetProduct) {
|
|
1686
1556
|
const targetProductData = targetProduct.getData();
|
|
1687
1557
|
this.store.currentProduct = targetProduct;
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1558
|
+
if (targetProductData["schedule.ids"]) {
|
|
1559
|
+
const newScheduleArr = this.getScheduleDataByIds(
|
|
1560
|
+
targetProductData["schedule.ids"]
|
|
1561
|
+
);
|
|
1562
|
+
targetProduct.setOtherParams("schedule", newScheduleArr);
|
|
1563
|
+
} else if (targetProductData.duration) {
|
|
1564
|
+
const dateRange = this.store.date.getDateRange();
|
|
1565
|
+
if (!dateRange.length)
|
|
1566
|
+
return;
|
|
1567
|
+
this.getAvailableDate({
|
|
1568
|
+
startDate: dateRange[0].date,
|
|
1569
|
+
endDate: dateRange[dateRange.length - 1].date,
|
|
1570
|
+
products: [targetProductData]
|
|
1571
|
+
});
|
|
1572
|
+
}
|
|
1692
1573
|
}
|
|
1693
1574
|
}
|
|
1694
1575
|
closeProductDetail() {
|
|
@@ -1745,7 +1626,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1745
1626
|
return -1;
|
|
1746
1627
|
return 0;
|
|
1747
1628
|
});
|
|
1748
|
-
const firstEnabledResourceId = (_f = (_e = (_d = targetProductData == null ? void 0 : targetProductData.product_resource) == null ? void 0 : _d.resources) == null ? void 0 : _e.find(
|
|
1629
|
+
const firstEnabledResourceId = (_f = (_e = (_d = targetProductData == null ? void 0 : targetProductData.product_resource) == null ? void 0 : _d.resources) == null ? void 0 : _e.find(
|
|
1630
|
+
(n) => n.status === 1
|
|
1631
|
+
)) == null ? void 0 : _f.id;
|
|
1749
1632
|
const formatScheduleTimeSlots = scheduleTimeSlots.map((item) => {
|
|
1750
1633
|
const resourcesUseableMap = {};
|
|
1751
1634
|
let count = 0;
|
|
@@ -1781,7 +1664,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1781
1664
|
}
|
|
1782
1665
|
currentResourcesTimeSlotCanUsedArr.push(res.usable);
|
|
1783
1666
|
});
|
|
1784
|
-
if (!currentResourcesTimeSlotCanUsedArr.some(
|
|
1667
|
+
if (!currentResourcesTimeSlotCanUsedArr.some(
|
|
1668
|
+
(n) => n === false
|
|
1669
|
+
) && // 只统计第一种资源的容量和 left
|
|
1670
|
+
m.form_id === firstEnabledResourceId) {
|
|
1785
1671
|
if (currentResourcesCount >= count) {
|
|
1786
1672
|
count = currentResourcesCount;
|
|
1787
1673
|
}
|
|
@@ -1803,60 +1689,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1803
1689
|
});
|
|
1804
1690
|
return formatScheduleTimeSlots;
|
|
1805
1691
|
}
|
|
1806
|
-
addProductToCart({
|
|
1807
|
-
product,
|
|
1808
|
-
date,
|
|
1809
|
-
account
|
|
1810
|
-
}) {
|
|
1811
|
-
const { bundle, options, origin, product_variant_id, rowKey, quantity = 1 } = product || {};
|
|
1812
|
-
const productData = { ...origin, product_variant_id, rowKey };
|
|
1813
|
-
if (!account) {
|
|
1814
|
-
const activeAccount = this.getActiveAccount();
|
|
1815
|
-
if (activeAccount) {
|
|
1816
|
-
account = activeAccount;
|
|
1817
|
-
}
|
|
1818
|
-
}
|
|
1819
|
-
if (rowKey) {
|
|
1820
|
-
const cartItems = this.store.cart.getItems();
|
|
1821
|
-
const targetCartItem = cartItems.find((n) => {
|
|
1822
|
-
var _a;
|
|
1823
|
-
return ((_a = n._productOrigin) == null ? void 0 : _a.rowKey) === rowKey;
|
|
1824
|
-
});
|
|
1825
|
-
if (targetCartItem && (0, import_utils4.isNormalProduct)(targetCartItem._productOrigin)) {
|
|
1826
|
-
this.store.cart.updateItem({
|
|
1827
|
-
_id: targetCartItem._id,
|
|
1828
|
-
product: {
|
|
1829
|
-
...targetCartItem._productOrigin,
|
|
1830
|
-
quantity: (targetCartItem.num || 1) + quantity
|
|
1831
|
-
},
|
|
1832
|
-
bundle: targetCartItem._bundleOrigin,
|
|
1833
|
-
options: targetCartItem._optionsOrigin,
|
|
1834
|
-
quantity: (targetCartItem.num || 1) + quantity
|
|
1835
|
-
});
|
|
1836
|
-
this.core.effects.emit(`${this.store.cart.name}:onUpdateCartItemNums`, {});
|
|
1837
|
-
return;
|
|
1838
|
-
}
|
|
1839
|
-
}
|
|
1840
|
-
this.store.cart.addItem({
|
|
1841
|
-
product: productData,
|
|
1842
|
-
date,
|
|
1843
|
-
account,
|
|
1844
|
-
bundle,
|
|
1845
|
-
options,
|
|
1846
|
-
quantity
|
|
1847
|
-
});
|
|
1848
|
-
if (date) {
|
|
1849
|
-
const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
|
|
1850
|
-
const cartItemsByDate = cartItems.filter(
|
|
1851
|
-
(n) => !(0, import_dayjs.default)(n.start_date).isSame((0, import_dayjs.default)(date.startTime), "day")
|
|
1852
|
-
);
|
|
1853
|
-
if (cartItemsByDate.length) {
|
|
1854
|
-
cartItemsByDate.forEach((n) => {
|
|
1855
|
-
this.store.cart.removeItem(n._id);
|
|
1856
|
-
});
|
|
1857
|
-
}
|
|
1858
|
-
}
|
|
1859
|
-
}
|
|
1860
1692
|
setOtherData(key, value) {
|
|
1861
1693
|
this.otherData[key] = value;
|
|
1862
1694
|
this.checkSaveCache({
|
|
@@ -1885,7 +1717,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1885
1717
|
* @memberof BookingByStepImpl
|
|
1886
1718
|
*/
|
|
1887
1719
|
getResourcesByCartItemAndCode(cartItemId, resourceCode) {
|
|
1888
|
-
var _a, _b
|
|
1720
|
+
var _a, _b;
|
|
1889
1721
|
const dateRange = this.store.date.getDateRange();
|
|
1890
1722
|
const resources = [];
|
|
1891
1723
|
if (dateRange == null ? void 0 : dateRange.length) {
|
|
@@ -1907,12 +1739,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1907
1739
|
if (!cartItem)
|
|
1908
1740
|
return [];
|
|
1909
1741
|
let selectedResources = [];
|
|
1910
|
-
const formatCapacity = (0,
|
|
1911
|
-
capacity: (_a = cartItem._productOrigin) == null ? void 0 : _a.capacity,
|
|
1912
|
-
product_bundle: cartItem._origin.product.product_bundle
|
|
1913
|
-
});
|
|
1742
|
+
const { currentCapacity, formatCapacity } = (0, import_capacity.getCapacityInfoByCartItem)(cartItem);
|
|
1914
1743
|
cartItem._origin.metadata.capacity = formatCapacity;
|
|
1915
|
-
const currentCapacity = (0, import_resources.getSumCapacity)({ capacity: formatCapacity });
|
|
1916
1744
|
if (cartItem.holder_id) {
|
|
1917
1745
|
selectedResources = (0, import_resources.getOthersSelectedResources)(
|
|
1918
1746
|
cartItems,
|
|
@@ -1928,7 +1756,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1928
1756
|
}
|
|
1929
1757
|
const productResources = (0, import_resources.getResourcesByProduct)(
|
|
1930
1758
|
resourcesMap,
|
|
1931
|
-
((
|
|
1759
|
+
((_b = (_a = cartItem._productOrigin) == null ? void 0 : _a.product_resource) == null ? void 0 : _b.resources) || [],
|
|
1932
1760
|
selectedResources,
|
|
1933
1761
|
currentCapacity
|
|
1934
1762
|
);
|
|
@@ -1947,9 +1775,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1947
1775
|
const resourcesUseableMap = {};
|
|
1948
1776
|
targetResource.renderList = targetResource.renderList.sort(
|
|
1949
1777
|
(a, b) => {
|
|
1950
|
-
var _a2, _b2,
|
|
1778
|
+
var _a2, _b2, _c, _d;
|
|
1951
1779
|
const aIsCombined = ((_b2 = (_a2 = a.metadata) == null ? void 0 : _a2.combined_resource) == null ? void 0 : _b2.status) === 1;
|
|
1952
|
-
const bIsCombined = ((_d = (
|
|
1780
|
+
const bIsCombined = ((_d = (_c = b.metadata) == null ? void 0 : _c.combined_resource) == null ? void 0 : _d.status) === 1;
|
|
1953
1781
|
if (aIsCombined && !bIsCombined)
|
|
1954
1782
|
return 1;
|
|
1955
1783
|
if (!aIsCombined && bIsCombined)
|
|
@@ -2036,56 +1864,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2036
1864
|
}
|
|
2037
1865
|
return results;
|
|
2038
1866
|
}
|
|
2039
|
-
async getAvailableDateForSession(params = {}) {
|
|
2040
|
-
let { startDate, endDate, type } = params;
|
|
2041
|
-
if ((0, import_dayjs.default)(startDate).isBefore((0, import_dayjs.default)(), "day") && ((0, import_dayjs.default)(endDate).isAfter((0, import_dayjs.default)(), "day") || (0, import_dayjs.default)(endDate).isSame((0, import_dayjs.default)(), "day"))) {
|
|
2042
|
-
startDate = (0, import_dayjs.default)().format("YYYY-MM-DD");
|
|
2043
|
-
}
|
|
2044
|
-
endDate = (0, import_dayjs.default)().add(1, "month").format("YYYY-MM-DD");
|
|
2045
|
-
let tempProducts = [];
|
|
2046
|
-
if (this.store.currentProduct) {
|
|
2047
|
-
tempProducts = [
|
|
2048
|
-
{
|
|
2049
|
-
...this.store.currentProduct.getData(),
|
|
2050
|
-
_schedule: this.store.currentProduct.getOtherParams()["schedule"]
|
|
2051
|
-
}
|
|
2052
|
-
];
|
|
2053
|
-
}
|
|
2054
|
-
const { resourceIds, rules, resourcesMap } = (0, import_products.getAvailableProductResources)(tempProducts) || {};
|
|
2055
|
-
this.otherParams.currentResourcesMap = resourcesMap;
|
|
2056
|
-
const res = await this.store.date.getResourceDates({
|
|
2057
|
-
query: {
|
|
2058
|
-
start_date: startDate || "",
|
|
2059
|
-
end_date: endDate || "",
|
|
2060
|
-
resource_ids: resourceIds
|
|
2061
|
-
},
|
|
2062
|
-
rules,
|
|
2063
|
-
type
|
|
2064
|
-
});
|
|
2065
|
-
if (this.store.currentProduct) {
|
|
2066
|
-
const dateListWithTimeSlots = await this.getTimeslotsScheduleByDateRange({
|
|
2067
|
-
startDate: startDate || "",
|
|
2068
|
-
endDate: endDate || ""
|
|
2069
|
-
});
|
|
2070
|
-
res.forEach((n) => {
|
|
2071
|
-
if (!dateListWithTimeSlots[n.date]) {
|
|
2072
|
-
n.status = "unavailable";
|
|
2073
|
-
} else {
|
|
2074
|
-
const allTimeSlotsCanUse = dateListWithTimeSlots[n.date].every(
|
|
2075
|
-
(d) => d.count
|
|
2076
|
-
);
|
|
2077
|
-
if (!allTimeSlotsCanUse) {
|
|
2078
|
-
n.status = "unavailable";
|
|
2079
|
-
}
|
|
2080
|
-
}
|
|
2081
|
-
});
|
|
2082
|
-
}
|
|
2083
|
-
const firstAvailableDate = res.find((n) => n.status === "available");
|
|
2084
|
-
return {
|
|
2085
|
-
dateList: res,
|
|
2086
|
-
firstAvailableDate
|
|
2087
|
-
};
|
|
2088
|
-
}
|
|
2089
1867
|
async getAvailableDateForSessionOptimize(params = {}) {
|
|
2090
1868
|
var _a, _b, _c, _d, _e, _f;
|
|
2091
1869
|
let { startDate, endDate } = params;
|
|
@@ -2103,9 +1881,19 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2103
1881
|
tempEndDate = endDate || "";
|
|
2104
1882
|
}
|
|
2105
1883
|
endDate = tempEndDate;
|
|
1884
|
+
const cache = (_a = this.store.currentProduct) == null ? void 0 : _a.getOtherParams()["timeSlotBySchedule"];
|
|
1885
|
+
if (cache) {
|
|
1886
|
+
if ((0, import_dayjs.default)(params.startDate).isSameOrAfter((0, import_dayjs.default)(cache.startDate), "day") && (0, import_dayjs.default)(params.endDate).isSameOrBefore((0, import_dayjs.default)(cache.endDate), "day")) {
|
|
1887
|
+
this.store.date.setDateList(cache.dateList);
|
|
1888
|
+
return {
|
|
1889
|
+
dateList: cache.dateList,
|
|
1890
|
+
firstAvailableDate: cache.firstAvailableDate
|
|
1891
|
+
};
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
2106
1894
|
let tempProducts;
|
|
2107
|
-
tempProducts = (
|
|
2108
|
-
const schedule = (
|
|
1895
|
+
tempProducts = (_b = this.store.currentProduct) == null ? void 0 : _b.getData();
|
|
1896
|
+
const schedule = (_c = this.store.currentProduct) == null ? void 0 : _c.getOtherParams()["schedule"];
|
|
2109
1897
|
const filteredSchedule = (0, import_resources.filterScheduleByDateRange)(
|
|
2110
1898
|
schedule,
|
|
2111
1899
|
startDate || "",
|
|
@@ -2119,16 +1907,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2119
1907
|
resource_ids: tempResourceIds
|
|
2120
1908
|
}
|
|
2121
1909
|
});
|
|
2122
|
-
const cache = (_c = this.store.currentProduct) == null ? void 0 : _c.getOtherParams()["timeSlotBySchedule"];
|
|
2123
|
-
if (cache) {
|
|
2124
|
-
if ((0, import_dayjs.default)(params.startDate).isSameOrAfter((0, import_dayjs.default)(cache.startDate), "day") && (0, import_dayjs.default)(params.endDate).isSameOrBefore((0, import_dayjs.default)(cache.endDate), "day")) {
|
|
2125
|
-
this.store.date.setDateList(cache.dateList);
|
|
2126
|
-
return {
|
|
2127
|
-
dateList: cache.dateList,
|
|
2128
|
-
firstAvailableDate: cache.firstAvailableDate
|
|
2129
|
-
};
|
|
2130
|
-
}
|
|
2131
|
-
}
|
|
2132
1910
|
let dates = [];
|
|
2133
1911
|
let currentDate = (0, import_dayjs.default)(startDate);
|
|
2134
1912
|
let firstAvailableDate = "";
|
|
@@ -2188,25 +1966,27 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
2188
1966
|
if (mTimes.length === 0) {
|
|
2189
1967
|
return;
|
|
2190
1968
|
}
|
|
2191
|
-
const targetCanUseTimes = mTimes.some(
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
resourcesUseableMap[m.id]
|
|
1969
|
+
const targetCanUseTimes = mTimes.some(
|
|
1970
|
+
(childTiem) => {
|
|
1971
|
+
const res2 = (0, import_resources.getIsUsableByTimeItem)({
|
|
1972
|
+
timeSlice: {
|
|
1973
|
+
start_time: item.start,
|
|
1974
|
+
end_time: item.end,
|
|
1975
|
+
start_at: (0, import_dayjs.default)(item.start),
|
|
1976
|
+
end_at: (0, import_dayjs.default)(item.end)
|
|
1977
|
+
},
|
|
1978
|
+
time: childTiem,
|
|
1979
|
+
resource: m,
|
|
1980
|
+
currentCount: 1,
|
|
1981
|
+
resourcesUseableMap,
|
|
1982
|
+
cut_off_time: tempProducts == null ? void 0 : tempProducts.cut_off_time
|
|
1983
|
+
});
|
|
1984
|
+
if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res2.reason !== "capacityOnly") {
|
|
1985
|
+
resourcesUseableMap[m.id] = res2.usable;
|
|
1986
|
+
}
|
|
1987
|
+
return res2.usable && !m.onlyComputed;
|
|
2207
1988
|
}
|
|
2208
|
-
|
|
2209
|
-
});
|
|
1989
|
+
);
|
|
2210
1990
|
return targetCanUseTimes;
|
|
2211
1991
|
});
|
|
2212
1992
|
});
|