@pisell/pisellos 0.0.141 → 0.0.142
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 +739 -1097
- 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 +361 -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
|
@@ -27,7 +27,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
27
27
|
import { BaseModule } from "../../modules/BaseModule";
|
|
28
28
|
import { BookingByStepHooks, createModule } from "./types";
|
|
29
29
|
import { getAvailableProductResources } from "./utils/products";
|
|
30
|
-
import { getResourcesByProduct, getTimeSlicesByResource, getTimeSlicesByResources, getIsUsableByTimeItem, getOthersSelectedResources,
|
|
30
|
+
import { getResourcesByProduct, getTimeSlicesByResource, getTimeSlicesByResources, getIsUsableByTimeItem, getOthersSelectedResources, getOthersCartSelectedResources, filterScheduleByDateRange, checkSessionProductLeadTime, getResourcesIdsByProduct, sortCombinedResources, filterResourcesByFormItem, checkTwoResourcesIntersection } from "./utils/resources";
|
|
31
31
|
import dayjs from 'dayjs';
|
|
32
32
|
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
|
|
33
33
|
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
|
|
@@ -36,9 +36,11 @@ dayjs.extend(isSameOrAfter);
|
|
|
36
36
|
import { getResourcesMap } from "../../modules/Resource/utils";
|
|
37
37
|
import { cloneDeep } from 'lodash-es';
|
|
38
38
|
import { calcCalendarDataByScheduleResult, calcMinTimeMaxTimeBySchedules, getAllSortedDateRanges } from "../../modules/Schedule/utils";
|
|
39
|
-
import {
|
|
39
|
+
import { handleAvailableDateByResource } from "../../modules/Date/utils";
|
|
40
40
|
import { areAllNormalProducts, isNormalProduct } from "../../modules/Product/utils";
|
|
41
|
-
import { calculateResourceAvailableTime, findFastestAvailableResource } from "./utils/timeslots";
|
|
41
|
+
import { calculateResourceAvailableTime, filterConditionTimeSlots, findFastestAvailableResource } from "./utils/timeslots";
|
|
42
|
+
import { updateAllCartItemPrice } from "../../modules/Cart/utils/changePrice";
|
|
43
|
+
import { getCapacityInfoByCartItem, checkSubResourcesCapacity, checkResourceCanUseByCapacity } from "./utils/capacity";
|
|
42
44
|
export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
43
45
|
_inherits(BookingByStepImpl, _BaseModule);
|
|
44
46
|
var _super = _createSuper(BookingByStepImpl);
|
|
@@ -124,7 +126,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
124
126
|
throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
|
|
125
127
|
}
|
|
126
128
|
});
|
|
127
|
-
this.loadAllSchedule();
|
|
129
|
+
this.store.schedule.loadAllSchedule();
|
|
128
130
|
this.core.effects.emit(BookingByStepHooks.onInited, {});
|
|
129
131
|
case 18:
|
|
130
132
|
case "end":
|
|
@@ -205,65 +207,40 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
205
207
|
this.store.step.updateStep(key, step);
|
|
206
208
|
}
|
|
207
209
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
210
|
+
/**
|
|
211
|
+
*
|
|
212
|
+
* 加载商品,然后导到商品列表里去
|
|
213
|
+
* @param {({
|
|
214
|
+
* category_ids?: number[];
|
|
215
|
+
* product_ids?: number[];
|
|
216
|
+
* collection?: number | string[];
|
|
217
|
+
* schedule_date?: string;
|
|
218
|
+
* })} {
|
|
219
|
+
* category_ids = [],
|
|
220
|
+
* product_ids = [],
|
|
221
|
+
* collection = [],
|
|
222
|
+
* schedule_date,
|
|
223
|
+
* }
|
|
224
|
+
* @return {*}
|
|
225
|
+
* @memberof BookingByStepImpl
|
|
226
|
+
*/
|
|
214
227
|
}, {
|
|
215
228
|
key: "loadProducts",
|
|
216
|
-
value: function () {
|
|
229
|
+
value: (function () {
|
|
217
230
|
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
|
|
218
|
-
var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, schedule_date
|
|
231
|
+
var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, schedule_date;
|
|
219
232
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
220
233
|
while (1) switch (_context2.prev = _context2.next) {
|
|
221
234
|
case 0:
|
|
222
235
|
_ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection, schedule_date = _ref.schedule_date;
|
|
223
|
-
|
|
224
|
-
// if (!schedule_ids?.length) {
|
|
225
|
-
// const schedule_ids_data = this.store.schedule
|
|
226
|
-
// .getScheduleListByIds(schedule_ids)
|
|
227
|
-
// .map((n) => n.id);
|
|
228
|
-
// if (schedule_ids_data.length) {
|
|
229
|
-
// schedule_ids = schedule_ids_data;
|
|
230
|
-
// } else if (schedule_date) {
|
|
231
|
-
// // 后端说如果 schedule_ids 如果为空,需要给[0]
|
|
232
|
-
// schedule_ids = [0];
|
|
233
|
-
// }
|
|
234
|
-
// }
|
|
235
|
-
userPlugin = this.core.getPlugin('user');
|
|
236
|
-
customer_id = undefined;
|
|
237
|
-
try {
|
|
238
|
-
customer_id = userPlugin === null || userPlugin === void 0 || (_userPlugin$get = userPlugin.get()) === null || _userPlugin$get === void 0 ? void 0 : _userPlugin$get.id;
|
|
239
|
-
} catch (error) {
|
|
240
|
-
console.error(error);
|
|
241
|
-
}
|
|
242
|
-
// 如果没传schedule_date,则从
|
|
243
|
-
_context2.next = 6;
|
|
244
|
-
return this.request.post("/product/query", {
|
|
245
|
-
open_quotation: 1,
|
|
246
|
-
open_bundle: 0,
|
|
247
|
-
exclude_extension_type: ['product_party', 'product_event', 'product_series_event', 'product_package_ticket', 'ticket', 'event_item'],
|
|
248
|
-
with: ['category', 'collection', 'resourceRelation'],
|
|
249
|
-
status: 'published',
|
|
250
|
-
num: 500,
|
|
251
|
-
skip: 1,
|
|
252
|
-
customer_id: customer_id,
|
|
236
|
+
return _context2.abrupt("return", this.store.products.loadProducts({
|
|
253
237
|
category_ids: category_ids,
|
|
254
|
-
|
|
238
|
+
product_ids: product_ids,
|
|
255
239
|
collection: collection,
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
useCache: true
|
|
261
|
-
});
|
|
262
|
-
case 6:
|
|
263
|
-
productsData = _context2.sent;
|
|
264
|
-
this.store.products.addProduct(productsData.data.list);
|
|
265
|
-
return _context2.abrupt("return", productsData.data.list);
|
|
266
|
-
case 9:
|
|
240
|
+
schedule_date: schedule_date,
|
|
241
|
+
cacheId: this.cacheId
|
|
242
|
+
}));
|
|
243
|
+
case 2:
|
|
267
244
|
case "end":
|
|
268
245
|
return _context2.stop();
|
|
269
246
|
}
|
|
@@ -274,9 +251,25 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
274
251
|
}
|
|
275
252
|
return loadProducts;
|
|
276
253
|
}()
|
|
254
|
+
/**
|
|
255
|
+
* 通过 schedule 来读取商品,适用于 session 类商品
|
|
256
|
+
*
|
|
257
|
+
* @param {{
|
|
258
|
+
* date: string;
|
|
259
|
+
* product_ids?: number[];
|
|
260
|
+
* category_ids?: number[];
|
|
261
|
+
* }} {
|
|
262
|
+
* date,
|
|
263
|
+
* product_ids = [],
|
|
264
|
+
* category_ids = [],
|
|
265
|
+
* }
|
|
266
|
+
* @return {*}
|
|
267
|
+
* @memberof BookingByStepImpl
|
|
268
|
+
*/
|
|
269
|
+
)
|
|
277
270
|
}, {
|
|
278
271
|
key: "loadProductByScheduleDate",
|
|
279
|
-
value: function () {
|
|
272
|
+
value: (function () {
|
|
280
273
|
var _loadProductByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref2) {
|
|
281
274
|
var _schedule$product_ids;
|
|
282
275
|
var date, _ref2$product_ids, product_ids, _ref2$category_ids, category_ids, scheduleList, schedule, otherProductsIds, allProductIds;
|
|
@@ -296,18 +289,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
296
289
|
week: '',
|
|
297
290
|
weekNum: 0
|
|
298
291
|
}]);
|
|
299
|
-
// const scheduleIds = scheduleList
|
|
300
|
-
// .filter((n) => n.date === date)
|
|
301
|
-
// .flatMap((n) => n.schedule_id)
|
|
302
|
-
// .filter((n) => n !== null && n !== undefined);
|
|
303
|
-
|
|
304
|
-
// 如果外面没传 product_ids,尝试从对应 schedule 里拿 product_ids
|
|
305
|
-
// if (!product_ids?.length) {
|
|
306
|
-
// const schedule = scheduleList.find((n) => n.date === date);
|
|
307
|
-
// if (schedule && schedule.product_ids?.length) {
|
|
308
|
-
// product_ids = schedule.product_ids;
|
|
309
|
-
// }
|
|
310
|
-
// }
|
|
311
292
|
// V2接口修改后,只能从schedule 接口里拿数据,不可以从外面拿,外面给的是装修数据
|
|
312
293
|
schedule = scheduleList.find(function (n) {
|
|
313
294
|
return n.date === date;
|
|
@@ -322,7 +303,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
322
303
|
});
|
|
323
304
|
_context3.next = 9;
|
|
324
305
|
return this.loadProducts({
|
|
325
|
-
// schedule_ids: scheduleIds,
|
|
326
306
|
product_ids: allProductIds,
|
|
327
307
|
category_ids: category_ids,
|
|
328
308
|
schedule_date: date
|
|
@@ -340,29 +320,35 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
340
320
|
}
|
|
341
321
|
return loadProductByScheduleDate;
|
|
342
322
|
}()
|
|
323
|
+
/**
|
|
324
|
+
* 更新完商品数据、切换日期、或者在较后的流程里登录了,检测当前购物车里是否有商品,如果有,则需要更新购物车里的商品价格
|
|
325
|
+
*
|
|
326
|
+
* @param {string} date
|
|
327
|
+
* @memberof BookingByStepImpl
|
|
328
|
+
*/
|
|
329
|
+
)
|
|
343
330
|
}, {
|
|
344
331
|
key: "updateQuotationPriceAndCart",
|
|
345
|
-
value: function () {
|
|
332
|
+
value: (function () {
|
|
346
333
|
var _updateQuotationPriceAndCart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(date) {
|
|
347
334
|
var _this3 = this;
|
|
348
|
-
var cartItems, userPlugin, customer_id, _userPlugin$
|
|
349
|
-
return _regeneratorRuntime().wrap(function _callee4$(
|
|
350
|
-
while (1) switch (
|
|
335
|
+
var cartItems, userPlugin, customer_id, _userPlugin$get, res;
|
|
336
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
337
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
351
338
|
case 0:
|
|
352
|
-
// 更新完商品数据以后,检测当前购物车里是否有商品,如果有,则需要更新购物车里的商品价格
|
|
353
339
|
cartItems = this.store.cart.getItems();
|
|
354
340
|
if (!cartItems.length) {
|
|
355
|
-
|
|
341
|
+
_context4.next = 11;
|
|
356
342
|
break;
|
|
357
343
|
}
|
|
358
344
|
userPlugin = this.core.getPlugin('user');
|
|
359
345
|
customer_id = undefined;
|
|
360
346
|
try {
|
|
361
|
-
customer_id = userPlugin === null || userPlugin === void 0 || (_userPlugin$
|
|
347
|
+
customer_id = userPlugin === null || userPlugin === void 0 || (_userPlugin$get = userPlugin.get()) === null || _userPlugin$get === void 0 ? void 0 : _userPlugin$get.id;
|
|
362
348
|
} catch (error) {
|
|
363
349
|
console.error(error);
|
|
364
350
|
}
|
|
365
|
-
|
|
351
|
+
_context4.next = 7;
|
|
366
352
|
return this.store.products.loadProductsPrice({
|
|
367
353
|
ids: cartItems.map(function (n) {
|
|
368
354
|
return n.id;
|
|
@@ -371,286 +357,104 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
371
357
|
customer_id: customer_id
|
|
372
358
|
});
|
|
373
359
|
case 7:
|
|
374
|
-
res =
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
return _regeneratorRuntime().wrap(function _loop$(_context4) {
|
|
381
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
382
|
-
case 0:
|
|
383
|
-
item = _step.value;
|
|
384
|
-
targetProduct = res.find(function (n) {
|
|
385
|
-
return n.id === item.id;
|
|
386
|
-
});
|
|
387
|
-
_context4.next = 4;
|
|
388
|
-
return _this3.store.products.getProduct(item.id);
|
|
389
|
-
case 4:
|
|
390
|
-
cartProduct = _context4.sent;
|
|
391
|
-
productInfo = cartProduct === null || cartProduct === void 0 ? void 0 : cartProduct.getData();
|
|
392
|
-
bundle = item._bundleOrigin;
|
|
393
|
-
productInfo.price = targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.price;
|
|
394
|
-
productInfo.base_price = targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.base_price;
|
|
395
|
-
bundle = (_bundle = bundle) === null || _bundle === void 0 ? void 0 : _bundle.map(function (n) {
|
|
396
|
-
var _targetProduct$bundle;
|
|
397
|
-
// 更新 bundle 的价格
|
|
398
|
-
var targetBundle = targetProduct === null || targetProduct === void 0 || (_targetProduct$bundle = targetProduct.bundle_group) === null || _targetProduct$bundle === void 0 ? void 0 : _targetProduct$bundle.find(function (m) {
|
|
399
|
-
return m.id === n.group_id;
|
|
400
|
-
});
|
|
401
|
-
if (targetBundle) {
|
|
402
|
-
var targetBundleItem = targetBundle.bundle_item.find(function (m) {
|
|
403
|
-
return m.id === n.id;
|
|
404
|
-
});
|
|
405
|
-
if (targetBundleItem) {
|
|
406
|
-
return _objectSpread(_objectSpread({}, n), {}, {
|
|
407
|
-
price: targetBundleItem.price,
|
|
408
|
-
base_price: targetBundleItem.base_price
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
return n;
|
|
413
|
-
});
|
|
414
|
-
_this3.store.cart.updateItem({
|
|
415
|
-
_id: item._id,
|
|
416
|
-
product: productInfo,
|
|
417
|
-
bundle: bundle
|
|
418
|
-
});
|
|
419
|
-
case 11:
|
|
420
|
-
case "end":
|
|
421
|
-
return _context4.stop();
|
|
422
|
-
}
|
|
423
|
-
}, _loop);
|
|
360
|
+
res = _context4.sent;
|
|
361
|
+
_context4.next = 10;
|
|
362
|
+
return updateAllCartItemPrice(cartItems, res, function (id) {
|
|
363
|
+
return _this3.store.products.getProduct(id);
|
|
364
|
+
}, function (params) {
|
|
365
|
+
return _this3.store.cart.updateItem(params);
|
|
424
366
|
});
|
|
425
|
-
|
|
426
|
-
case 12:
|
|
427
|
-
if ((_step = _iterator.n()).done) {
|
|
428
|
-
_context5.next = 16;
|
|
429
|
-
break;
|
|
430
|
-
}
|
|
431
|
-
return _context5.delegateYield(_loop(), "t0", 14);
|
|
432
|
-
case 14:
|
|
433
|
-
_context5.next = 12;
|
|
434
|
-
break;
|
|
435
|
-
case 16:
|
|
436
|
-
_context5.next = 21;
|
|
437
|
-
break;
|
|
438
|
-
case 18:
|
|
439
|
-
_context5.prev = 18;
|
|
440
|
-
_context5.t1 = _context5["catch"](9);
|
|
441
|
-
_iterator.e(_context5.t1);
|
|
442
|
-
case 21:
|
|
443
|
-
_context5.prev = 21;
|
|
444
|
-
_iterator.f();
|
|
445
|
-
return _context5.finish(21);
|
|
446
|
-
case 24:
|
|
367
|
+
case 10:
|
|
447
368
|
this.core.effects.emit("".concat(this.store.cart.name, ":onUpdateQuotationPrice"), {});
|
|
448
|
-
case
|
|
369
|
+
case 11:
|
|
449
370
|
case "end":
|
|
450
|
-
return
|
|
371
|
+
return _context4.stop();
|
|
451
372
|
}
|
|
452
|
-
}, _callee4, this
|
|
373
|
+
}, _callee4, this);
|
|
453
374
|
}));
|
|
454
375
|
function updateQuotationPriceAndCart(_x5) {
|
|
455
376
|
return _updateQuotationPriceAndCart.apply(this, arguments);
|
|
456
377
|
}
|
|
457
378
|
return updateQuotationPriceAndCart;
|
|
458
|
-
}()
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
});
|
|
474
|
-
case 2:
|
|
475
|
-
scheduleList = _context6.sent;
|
|
476
|
-
this.store.schedule.setScheduleList(((_scheduleList$data = scheduleList.data) === null || _scheduleList$data === void 0 ? void 0 : _scheduleList$data.list) || []);
|
|
477
|
-
case 4:
|
|
478
|
-
case "end":
|
|
479
|
-
return _context6.stop();
|
|
480
|
-
}
|
|
481
|
-
}, _callee5, this);
|
|
482
|
-
}));
|
|
483
|
-
function loadAllSchedule() {
|
|
484
|
-
return _loadAllSchedule.apply(this, arguments);
|
|
485
|
-
}
|
|
486
|
-
return loadAllSchedule;
|
|
487
|
-
}() // ui 层提供日期的起始范围,返回一个起始范围内日期的可用情况
|
|
379
|
+
}()
|
|
380
|
+
/**
|
|
381
|
+
* ui 层提供日期的起始范围,返回一个起始范围内日期的可用情况
|
|
382
|
+
* 适用于先选日期的流程,确定日期是否可用
|
|
383
|
+
* 已知问题:如果挂接的商品的资源不可用,后端是不会计算的
|
|
384
|
+
*
|
|
385
|
+
* @param {LoadScheduleAvailableDateParams} {
|
|
386
|
+
* startDate,
|
|
387
|
+
* endDate,
|
|
388
|
+
* custom_page_id,
|
|
389
|
+
* channel,
|
|
390
|
+
* }
|
|
391
|
+
* @memberof BookingByStepImpl
|
|
392
|
+
*/
|
|
393
|
+
)
|
|
488
394
|
}, {
|
|
489
395
|
key: "loadScheduleAvailableDate",
|
|
490
|
-
value: function () {
|
|
491
|
-
var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
492
|
-
var
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
396
|
+
value: (function () {
|
|
397
|
+
var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref3) {
|
|
398
|
+
var startDate, endDate, custom_page_id, channel;
|
|
399
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
400
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
496
401
|
case 0:
|
|
497
402
|
startDate = _ref3.startDate, endDate = _ref3.endDate, custom_page_id = _ref3.custom_page_id, channel = _ref3.channel;
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
startDate
|
|
501
|
-
|
|
502
|
-
// 1.生成当前月份的所有日期,默认都不可用
|
|
503
|
-
dates = generateMonthDates(startDate, endDate);
|
|
504
|
-
dates = disableAllDates(dates);
|
|
505
|
-
// 如果 endDate 在今天之前,则不用查接口,直接返回 dates
|
|
506
|
-
if (!dayjs(endDate).isBefore(dayjs(), 'day')) {
|
|
507
|
-
_context7.next = 6;
|
|
508
|
-
break;
|
|
509
|
-
}
|
|
510
|
-
return _context7.abrupt("return", dates);
|
|
511
|
-
case 6:
|
|
512
|
-
_context7.next = 8;
|
|
513
|
-
return this.request.get("/schedule/product/availability/v2", {
|
|
514
|
-
start_date: startDate,
|
|
515
|
-
end_date: endDate,
|
|
403
|
+
_context5.next = 3;
|
|
404
|
+
return this.store.schedule.loadScheduleAvailableDate({
|
|
405
|
+
startDate: startDate,
|
|
406
|
+
endDate: endDate,
|
|
516
407
|
custom_page_id: custom_page_id,
|
|
517
408
|
channel: channel
|
|
518
409
|
});
|
|
519
|
-
case
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
this.store.schedule.setOtherProductsIds(res.data.other_product_ids || []);
|
|
523
|
-
// 如果没有schedule或者结束日期在今天之前,则所有日期均不可用
|
|
524
|
-
if (!(!((_res$data$date_list = res.data.date_list) !== null && _res$data$date_list !== void 0 && _res$data$date_list.length) && !((_res$data$other_produ = res.data.other_product_ids) !== null && _res$data$other_produ !== void 0 && _res$data$other_produ.length) || dayjs(endDate).isBefore(dayjs(), 'day'))) {
|
|
525
|
-
_context7.next = 13;
|
|
526
|
-
break;
|
|
527
|
-
}
|
|
528
|
-
return _context7.abrupt("return", dates);
|
|
529
|
-
case 13:
|
|
530
|
-
if ((_res$data$other_produ2 = res.data.other_product_ids) !== null && _res$data$other_produ2 !== void 0 && _res$data$other_produ2.length) {
|
|
531
|
-
// 如果后端有返回 other_product_ids ,意味着有 duration 商品,则今天以及今天以后的日期均可用
|
|
532
|
-
dates.forEach(function (n) {
|
|
533
|
-
n.status = 'available';
|
|
534
|
-
});
|
|
535
|
-
} else {
|
|
536
|
-
res.data.date_list.forEach(function (n) {
|
|
537
|
-
var index = dates.findIndex(function (m) {
|
|
538
|
-
return m.date === n.date;
|
|
539
|
-
});
|
|
540
|
-
if (index !== -1) {
|
|
541
|
-
dates[index].status = 'available';
|
|
542
|
-
}
|
|
543
|
-
});
|
|
544
|
-
}
|
|
545
|
-
dates = disableDatesBeforeOneDay(dates);
|
|
546
|
-
return _context7.abrupt("return", dates);
|
|
547
|
-
case 16:
|
|
410
|
+
case 3:
|
|
411
|
+
return _context5.abrupt("return", _context5.sent);
|
|
412
|
+
case 4:
|
|
548
413
|
case "end":
|
|
549
|
-
return
|
|
414
|
+
return _context5.stop();
|
|
550
415
|
}
|
|
551
|
-
},
|
|
416
|
+
}, _callee5, this);
|
|
552
417
|
}));
|
|
553
418
|
function loadScheduleAvailableDate(_x6) {
|
|
554
419
|
return _loadScheduleAvailableDate.apply(this, arguments);
|
|
555
420
|
}
|
|
556
421
|
return loadScheduleAvailableDate;
|
|
557
|
-
}()
|
|
558
|
-
}, {
|
|
559
|
-
key: "storeProduct",
|
|
560
|
-
value: function () {
|
|
561
|
-
var _storeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(productData) {
|
|
562
|
-
var activeAccount, _ref4, bundle, options, origin, product_variant_id, _ref4$quantity, quantity, rowKey, cartItems, currentAccount, targetCartItem, targetAccount, isSameAccount, product, addCartItem;
|
|
563
|
-
return _regeneratorRuntime().wrap(function _callee7$(_context8) {
|
|
564
|
-
while (1) switch (_context8.prev = _context8.next) {
|
|
565
|
-
case 0:
|
|
566
|
-
// 往购物车加商品数据的时候,默认用当前 activeAccount 填充到 product 的 account 里面
|
|
567
|
-
activeAccount = this.getActiveAccount();
|
|
568
|
-
_ref4 = productData || {}, bundle = _ref4.bundle, options = _ref4.options, origin = _ref4.origin, product_variant_id = _ref4.product_variant_id, _ref4$quantity = _ref4.quantity, quantity = _ref4$quantity === void 0 ? 1 : _ref4$quantity, rowKey = _ref4.rowKey; // 检查购物车里是否已经存在 rowKey相同的数据,如果是则更新数量
|
|
569
|
-
// 还需要判断账号是否一致
|
|
570
|
-
cartItems = this.store.cart.getItems();
|
|
571
|
-
if (!rowKey) {
|
|
572
|
-
_context8.next = 12;
|
|
573
|
-
break;
|
|
574
|
-
}
|
|
575
|
-
currentAccount = this.store.accountList.getActiveAccount();
|
|
576
|
-
targetCartItem = cartItems.find(function (n) {
|
|
577
|
-
var _n$_productOrigin;
|
|
578
|
-
return ((_n$_productOrigin = n._productOrigin) === null || _n$_productOrigin === void 0 ? void 0 : _n$_productOrigin.rowKey) === rowKey && n.holder_id === (currentAccount === null || currentAccount === void 0 ? void 0 : currentAccount.getId());
|
|
579
|
-
});
|
|
580
|
-
targetAccount = targetCartItem === null || targetCartItem === void 0 ? void 0 : targetCartItem.holder_id;
|
|
581
|
-
isSameAccount = (currentAccount === null || currentAccount === void 0 ? void 0 : currentAccount.getId()) === targetAccount;
|
|
582
|
-
if (!(targetCartItem && isNormalProduct(targetCartItem._productOrigin) && isSameAccount)) {
|
|
583
|
-
_context8.next = 12;
|
|
584
|
-
break;
|
|
585
|
-
}
|
|
586
|
-
this.store.cart.updateItem({
|
|
587
|
-
_id: targetCartItem._id,
|
|
588
|
-
product: _objectSpread({}, targetCartItem._productOrigin),
|
|
589
|
-
quantity: (targetCartItem.num || 1) + quantity
|
|
590
|
-
});
|
|
591
|
-
// 这里需要单独触发一个,购物车商品数量发生改变的 hook
|
|
592
|
-
this.core.effects.emit("".concat(this.store.cart.name, ":onUpdateCartItemNums"), {});
|
|
593
|
-
return _context8.abrupt("return");
|
|
594
|
-
case 12:
|
|
595
|
-
product = _objectSpread(_objectSpread({}, origin), {}, {
|
|
596
|
-
product_variant_id: product_variant_id,
|
|
597
|
-
rowKey: rowKey
|
|
598
|
-
});
|
|
599
|
-
addCartItem = {
|
|
600
|
-
product: product,
|
|
601
|
-
bundle: bundle,
|
|
602
|
-
options: options,
|
|
603
|
-
quantity: quantity
|
|
604
|
-
};
|
|
605
|
-
if (activeAccount) {
|
|
606
|
-
addCartItem.account = activeAccount;
|
|
607
|
-
}
|
|
608
|
-
this.store.cart.addItem(addCartItem);
|
|
609
|
-
case 16:
|
|
610
|
-
case "end":
|
|
611
|
-
return _context8.stop();
|
|
612
|
-
}
|
|
613
|
-
}, _callee7, this);
|
|
614
|
-
}));
|
|
615
|
-
function storeProduct(_x7) {
|
|
616
|
-
return _storeProduct.apply(this, arguments);
|
|
617
|
-
}
|
|
618
|
-
return storeProduct;
|
|
619
422
|
}() // 添加单个账户或者 guest
|
|
423
|
+
)
|
|
620
424
|
}, {
|
|
621
425
|
key: "addAccount",
|
|
622
426
|
value: function () {
|
|
623
|
-
var _addAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
427
|
+
var _addAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(account, extra) {
|
|
624
428
|
var accountModules, newAccount;
|
|
625
|
-
return _regeneratorRuntime().wrap(function
|
|
626
|
-
while (1) switch (
|
|
429
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
430
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
627
431
|
case 0:
|
|
628
432
|
if (!((extra === null || extra === void 0 ? void 0 : extra.type) === 'holder')) {
|
|
629
|
-
|
|
433
|
+
_context6.next = 5;
|
|
630
434
|
break;
|
|
631
435
|
}
|
|
632
|
-
|
|
436
|
+
_context6.next = 3;
|
|
633
437
|
return this.store.accountList.addHolderAccounts({
|
|
634
438
|
holders: [account],
|
|
635
439
|
customerId: extra.customerId,
|
|
636
440
|
type: 'unshift'
|
|
637
441
|
});
|
|
638
442
|
case 3:
|
|
639
|
-
accountModules =
|
|
640
|
-
return
|
|
443
|
+
accountModules = _context6.sent;
|
|
444
|
+
return _context6.abrupt("return", accountModules[0].getAccount());
|
|
641
445
|
case 5:
|
|
642
|
-
|
|
446
|
+
_context6.next = 7;
|
|
643
447
|
return this.store.accountList.addAccount(account);
|
|
644
448
|
case 7:
|
|
645
|
-
newAccount =
|
|
646
|
-
return
|
|
449
|
+
newAccount = _context6.sent;
|
|
450
|
+
return _context6.abrupt("return", newAccount.getAccount());
|
|
647
451
|
case 9:
|
|
648
452
|
case "end":
|
|
649
|
-
return
|
|
453
|
+
return _context6.stop();
|
|
650
454
|
}
|
|
651
|
-
},
|
|
455
|
+
}, _callee6, this);
|
|
652
456
|
}));
|
|
653
|
-
function addAccount(
|
|
457
|
+
function addAccount(_x7, _x8) {
|
|
654
458
|
return _addAccount.apply(this, arguments);
|
|
655
459
|
}
|
|
656
460
|
return addAccount;
|
|
@@ -658,13 +462,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
658
462
|
}, {
|
|
659
463
|
key: "addAccounts",
|
|
660
464
|
value: function () {
|
|
661
|
-
var _addAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
662
|
-
var res,
|
|
663
|
-
return _regeneratorRuntime().wrap(function
|
|
664
|
-
while (1) switch (
|
|
465
|
+
var _addAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(accounts, extra) {
|
|
466
|
+
var res, _iterator, _step, account, accountModule, accountData;
|
|
467
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
468
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
665
469
|
case 0:
|
|
666
470
|
if (!((extra === null || extra === void 0 ? void 0 : extra.type) === 'holder')) {
|
|
667
|
-
|
|
471
|
+
_context7.next = 3;
|
|
668
472
|
break;
|
|
669
473
|
}
|
|
670
474
|
this.store.accountList.addHolderAccounts({
|
|
@@ -672,49 +476,49 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
672
476
|
customerId: extra.customerId,
|
|
673
477
|
type: 'unshift'
|
|
674
478
|
});
|
|
675
|
-
return
|
|
479
|
+
return _context7.abrupt("return");
|
|
676
480
|
case 3:
|
|
677
481
|
res = [];
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
482
|
+
_iterator = _createForOfIteratorHelper(accounts);
|
|
483
|
+
_context7.prev = 5;
|
|
484
|
+
_iterator.s();
|
|
681
485
|
case 7:
|
|
682
|
-
if ((
|
|
683
|
-
|
|
486
|
+
if ((_step = _iterator.n()).done) {
|
|
487
|
+
_context7.next = 16;
|
|
684
488
|
break;
|
|
685
489
|
}
|
|
686
|
-
account =
|
|
687
|
-
|
|
490
|
+
account = _step.value;
|
|
491
|
+
_context7.next = 11;
|
|
688
492
|
return this.store.accountList.addAccount(account);
|
|
689
493
|
case 11:
|
|
690
|
-
accountModule =
|
|
494
|
+
accountModule = _context7.sent;
|
|
691
495
|
accountData = accountModule.getAccount();
|
|
692
496
|
if (accountData) {
|
|
693
497
|
res.push(accountData);
|
|
694
498
|
}
|
|
695
499
|
case 14:
|
|
696
|
-
|
|
500
|
+
_context7.next = 7;
|
|
697
501
|
break;
|
|
698
502
|
case 16:
|
|
699
|
-
|
|
503
|
+
_context7.next = 21;
|
|
700
504
|
break;
|
|
701
505
|
case 18:
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
506
|
+
_context7.prev = 18;
|
|
507
|
+
_context7.t0 = _context7["catch"](5);
|
|
508
|
+
_iterator.e(_context7.t0);
|
|
705
509
|
case 21:
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
return
|
|
510
|
+
_context7.prev = 21;
|
|
511
|
+
_iterator.f();
|
|
512
|
+
return _context7.finish(21);
|
|
709
513
|
case 24:
|
|
710
|
-
return
|
|
514
|
+
return _context7.abrupt("return", res);
|
|
711
515
|
case 25:
|
|
712
516
|
case "end":
|
|
713
|
-
return
|
|
517
|
+
return _context7.stop();
|
|
714
518
|
}
|
|
715
|
-
},
|
|
519
|
+
}, _callee7, this, [[5, 18, 21, 24]]);
|
|
716
520
|
}));
|
|
717
|
-
function addAccounts(
|
|
521
|
+
function addAccounts(_x9, _x10) {
|
|
718
522
|
return _addAccounts.apply(this, arguments);
|
|
719
523
|
}
|
|
720
524
|
return addAccounts;
|
|
@@ -722,20 +526,20 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
722
526
|
}, {
|
|
723
527
|
key: "getAccounts",
|
|
724
528
|
value: function () {
|
|
725
|
-
var _getAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
529
|
+
var _getAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
726
530
|
var accounts;
|
|
727
|
-
return _regeneratorRuntime().wrap(function
|
|
728
|
-
while (1) switch (
|
|
531
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
532
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
729
533
|
case 0:
|
|
730
534
|
accounts = this.store.accountList.getAccounts();
|
|
731
|
-
return
|
|
535
|
+
return _context8.abrupt("return", accounts.map(function (account) {
|
|
732
536
|
return account.getAccount();
|
|
733
537
|
}));
|
|
734
538
|
case 2:
|
|
735
539
|
case "end":
|
|
736
|
-
return
|
|
540
|
+
return _context8.stop();
|
|
737
541
|
}
|
|
738
|
-
},
|
|
542
|
+
}, _callee8, this);
|
|
739
543
|
}));
|
|
740
544
|
function getAccounts() {
|
|
741
545
|
return _getAccounts.apply(this, arguments);
|
|
@@ -759,7 +563,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
759
563
|
key: "getActiveAccount",
|
|
760
564
|
value: function getActiveAccount() {
|
|
761
565
|
var activeAccount = this.store.accountList.getActiveAccount();
|
|
762
|
-
|
|
566
|
+
var account = activeAccount === null || activeAccount === void 0 ? void 0 : activeAccount.getAccount();
|
|
567
|
+
return account === null ? undefined : account;
|
|
763
568
|
}
|
|
764
569
|
}, {
|
|
765
570
|
key: "removeAccount",
|
|
@@ -776,10 +581,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
776
581
|
}, {
|
|
777
582
|
key: "fetchHolderAccountsAsync",
|
|
778
583
|
value: (function () {
|
|
779
|
-
var _fetchHolderAccountsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
584
|
+
var _fetchHolderAccountsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
|
|
780
585
|
var cartItems, _this$store$date$getD, date, normalProductCartItem;
|
|
781
|
-
return _regeneratorRuntime().wrap(function
|
|
782
|
-
while (1) switch (
|
|
586
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
587
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
783
588
|
case 0:
|
|
784
589
|
cartItems = this.store.cart.getItems();
|
|
785
590
|
if (cartItems.length) {
|
|
@@ -794,14 +599,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
794
599
|
}
|
|
795
600
|
this.updateQuotationPriceAndCart(date);
|
|
796
601
|
}
|
|
797
|
-
return
|
|
602
|
+
return _context9.abrupt("return", this.store.accountList.fetchHolderAccounts(params));
|
|
798
603
|
case 3:
|
|
799
604
|
case "end":
|
|
800
|
-
return
|
|
605
|
+
return _context9.stop();
|
|
801
606
|
}
|
|
802
|
-
},
|
|
607
|
+
}, _callee9, this);
|
|
803
608
|
}));
|
|
804
|
-
function fetchHolderAccountsAsync(
|
|
609
|
+
function fetchHolderAccountsAsync(_x11) {
|
|
805
610
|
return _fetchHolderAccountsAsync.apply(this, arguments);
|
|
806
611
|
}
|
|
807
612
|
return fetchHolderAccountsAsync;
|
|
@@ -810,9 +615,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
810
615
|
}, {
|
|
811
616
|
key: "setDateRange",
|
|
812
617
|
value: function () {
|
|
813
|
-
var _setDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
814
|
-
return _regeneratorRuntime().wrap(function
|
|
815
|
-
while (1) switch (
|
|
618
|
+
var _setDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(dateRange) {
|
|
619
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
620
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
816
621
|
case 0:
|
|
817
622
|
this.store.date.setDateRange(dateRange);
|
|
818
623
|
// 日期数据变更后,如果购物车里有数据,需要更新购物车里的报价单的价格
|
|
@@ -821,11 +626,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
821
626
|
}
|
|
822
627
|
case 2:
|
|
823
628
|
case "end":
|
|
824
|
-
return
|
|
629
|
+
return _context10.stop();
|
|
825
630
|
}
|
|
826
|
-
},
|
|
631
|
+
}, _callee10, this);
|
|
827
632
|
}));
|
|
828
|
-
function setDateRange(
|
|
633
|
+
function setDateRange(_x12) {
|
|
829
634
|
return _setDateRange.apply(this, arguments);
|
|
830
635
|
}
|
|
831
636
|
return setDateRange;
|
|
@@ -840,16 +645,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
840
645
|
}, {
|
|
841
646
|
key: "getDateRange",
|
|
842
647
|
value: function () {
|
|
843
|
-
var _getDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
844
|
-
return _regeneratorRuntime().wrap(function
|
|
845
|
-
while (1) switch (
|
|
648
|
+
var _getDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
|
|
649
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
650
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
846
651
|
case 0:
|
|
847
|
-
return
|
|
652
|
+
return _context11.abrupt("return", this.store.date.getDateRange());
|
|
848
653
|
case 1:
|
|
849
654
|
case "end":
|
|
850
|
-
return
|
|
655
|
+
return _context11.stop();
|
|
851
656
|
}
|
|
852
|
-
},
|
|
657
|
+
}, _callee11, this);
|
|
853
658
|
}));
|
|
854
659
|
function getDateRange() {
|
|
855
660
|
return _getDateRange.apply(this, arguments);
|
|
@@ -866,7 +671,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
866
671
|
}, {
|
|
867
672
|
key: "getAvailableDate",
|
|
868
673
|
value: function () {
|
|
869
|
-
var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
674
|
+
var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
870
675
|
var _this4 = this,
|
|
871
676
|
_dateRange$,
|
|
872
677
|
_dateRange$2,
|
|
@@ -880,16 +685,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
880
685
|
dateRange,
|
|
881
686
|
tempStartDate,
|
|
882
687
|
tempEndDate,
|
|
883
|
-
|
|
688
|
+
_ref4,
|
|
884
689
|
resourceIds,
|
|
885
690
|
rules,
|
|
886
691
|
resourcesMap,
|
|
887
692
|
res,
|
|
888
|
-
|
|
889
|
-
return _regeneratorRuntime().wrap(function
|
|
890
|
-
while (1) switch (
|
|
693
|
+
_args12 = arguments;
|
|
694
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
695
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
891
696
|
case 0:
|
|
892
|
-
params =
|
|
697
|
+
params = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : {};
|
|
698
|
+
debugger;
|
|
893
699
|
// 开始日期如果小于今天,直接以今天当做开始日期
|
|
894
700
|
products = params.products, startDate = params.startDate, endDate = params.endDate, type = params.type; // 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天 且 endDate 小于或等于今天,需要把 startDate 置为今天
|
|
895
701
|
if (dayjs(startDate).isBefore(dayjs(), 'day') && (dayjs(endDate).isAfter(dayjs(), 'day') || dayjs(endDate).isSame(dayjs(), 'day'))) {
|
|
@@ -916,15 +722,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
916
722
|
tempStartDate = startDate || (dateRange === null || dateRange === void 0 || (_dateRange$ = dateRange[0]) === null || _dateRange$ === void 0 ? void 0 : _dateRange$.date);
|
|
917
723
|
tempEndDate = endDate || (dateRange === null || dateRange === void 0 || (_dateRange$2 = dateRange[1]) === null || _dateRange$2 === void 0 ? void 0 : _dateRange$2.date) || (dateRange === null || dateRange === void 0 || (_dateRange$3 = dateRange[0]) === null || _dateRange$3 === void 0 ? void 0 : _dateRange$3.date);
|
|
918
724
|
if (tempProducts.length) {
|
|
919
|
-
|
|
725
|
+
_context12.next = 12;
|
|
920
726
|
break;
|
|
921
727
|
}
|
|
922
|
-
return
|
|
923
|
-
case
|
|
728
|
+
return _context12.abrupt("return", []);
|
|
729
|
+
case 12:
|
|
924
730
|
// 在这里需要把能收集到的数据都收集上来,拼装好给 date 模块去查询
|
|
925
|
-
|
|
731
|
+
_ref4 = getAvailableProductResources(tempProducts) || {}, resourceIds = _ref4.resourceIds, rules = _ref4.rules, resourcesMap = _ref4.resourcesMap;
|
|
926
732
|
this.otherParams.currentResourcesMap = resourcesMap;
|
|
927
|
-
|
|
733
|
+
_context12.next = 16;
|
|
928
734
|
return this.store.date.getResourceDates({
|
|
929
735
|
url: params.url,
|
|
930
736
|
query: {
|
|
@@ -935,14 +741,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
935
741
|
rules: rules,
|
|
936
742
|
type: type
|
|
937
743
|
});
|
|
938
|
-
case
|
|
939
|
-
res =
|
|
940
|
-
return
|
|
941
|
-
case
|
|
744
|
+
case 16:
|
|
745
|
+
res = _context12.sent;
|
|
746
|
+
return _context12.abrupt("return", res);
|
|
747
|
+
case 18:
|
|
942
748
|
case "end":
|
|
943
|
-
return
|
|
749
|
+
return _context12.stop();
|
|
944
750
|
}
|
|
945
|
-
},
|
|
751
|
+
}, _callee12, this);
|
|
946
752
|
}));
|
|
947
753
|
function getAvailableDate() {
|
|
948
754
|
return _getAvailableDate.apply(this, arguments);
|
|
@@ -955,22 +761,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
955
761
|
}, {
|
|
956
762
|
key: "getSummary",
|
|
957
763
|
value: (function () {
|
|
958
|
-
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
764
|
+
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
959
765
|
var cartItems, summary;
|
|
960
|
-
return _regeneratorRuntime().wrap(function
|
|
961
|
-
while (1) switch (
|
|
766
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
767
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
962
768
|
case 0:
|
|
963
769
|
cartItems = this.store.cart.getItems();
|
|
964
|
-
|
|
770
|
+
_context13.next = 3;
|
|
965
771
|
return this.store.summary.getSummary(cartItems);
|
|
966
772
|
case 3:
|
|
967
|
-
summary =
|
|
968
|
-
return
|
|
773
|
+
summary = _context13.sent;
|
|
774
|
+
return _context13.abrupt("return", summary);
|
|
969
775
|
case 5:
|
|
970
776
|
case "end":
|
|
971
|
-
return
|
|
777
|
+
return _context13.stop();
|
|
972
778
|
}
|
|
973
|
-
},
|
|
779
|
+
}, _callee13, this);
|
|
974
780
|
}));
|
|
975
781
|
function getSummary() {
|
|
976
782
|
return _getSummary.apply(this, arguments);
|
|
@@ -984,18 +790,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
984
790
|
}, {
|
|
985
791
|
key: "getProtocol",
|
|
986
792
|
value: (function () {
|
|
987
|
-
var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
988
|
-
return _regeneratorRuntime().wrap(function
|
|
989
|
-
while (1) switch (
|
|
793
|
+
var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(protocolId) {
|
|
794
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
795
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
990
796
|
case 0:
|
|
991
|
-
return
|
|
797
|
+
return _context14.abrupt("return", this.store.summary.getProtocol(protocolId));
|
|
992
798
|
case 1:
|
|
993
799
|
case "end":
|
|
994
|
-
return
|
|
800
|
+
return _context14.stop();
|
|
995
801
|
}
|
|
996
|
-
},
|
|
802
|
+
}, _callee14, this);
|
|
997
803
|
}));
|
|
998
|
-
function getProtocol(
|
|
804
|
+
function getProtocol(_x13) {
|
|
999
805
|
return _getProtocol.apply(this, arguments);
|
|
1000
806
|
}
|
|
1001
807
|
return getProtocol;
|
|
@@ -1004,16 +810,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1004
810
|
}, {
|
|
1005
811
|
key: "getProducts",
|
|
1006
812
|
value: function () {
|
|
1007
|
-
var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1008
|
-
return _regeneratorRuntime().wrap(function
|
|
1009
|
-
while (1) switch (
|
|
813
|
+
var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
814
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
815
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1010
816
|
case 0:
|
|
1011
|
-
return
|
|
817
|
+
return _context15.abrupt("return", this.store.products.getProducts());
|
|
1012
818
|
case 1:
|
|
1013
819
|
case "end":
|
|
1014
|
-
return
|
|
820
|
+
return _context15.stop();
|
|
1015
821
|
}
|
|
1016
|
-
},
|
|
822
|
+
}, _callee15, this);
|
|
1017
823
|
}));
|
|
1018
824
|
function getProducts() {
|
|
1019
825
|
return _getProducts.apply(this, arguments);
|
|
@@ -1023,15 +829,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1023
829
|
}, {
|
|
1024
830
|
key: "setLoginAccount",
|
|
1025
831
|
value: function () {
|
|
1026
|
-
var _setLoginAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
832
|
+
var _setLoginAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(accountId, accountInfo) {
|
|
1027
833
|
var _this5 = this;
|
|
1028
834
|
var account, stateAccountId, cartItems, _this$store$date$getD2, date, normalProductCartItem;
|
|
1029
|
-
return _regeneratorRuntime().wrap(function
|
|
1030
|
-
while (1) switch (
|
|
835
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
836
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1031
837
|
case 0:
|
|
1032
838
|
account = this.store.accountList.getAccount(accountId);
|
|
1033
839
|
if (!account) {
|
|
1034
|
-
|
|
840
|
+
_context16.next = 11;
|
|
1035
841
|
break;
|
|
1036
842
|
}
|
|
1037
843
|
stateAccountId = account.getId();
|
|
@@ -1060,17 +866,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1060
866
|
}
|
|
1061
867
|
this.updateQuotationPriceAndCart(date);
|
|
1062
868
|
}
|
|
1063
|
-
|
|
869
|
+
_context16.next = 12;
|
|
1064
870
|
break;
|
|
1065
871
|
case 11:
|
|
1066
872
|
throw new Error("\u6CA1\u6709\u627E\u5230".concat(accountId, "\u8D26\u6237"));
|
|
1067
873
|
case 12:
|
|
1068
874
|
case "end":
|
|
1069
|
-
return
|
|
875
|
+
return _context16.stop();
|
|
1070
876
|
}
|
|
1071
|
-
},
|
|
877
|
+
}, _callee16, this);
|
|
1072
878
|
}));
|
|
1073
|
-
function setLoginAccount(
|
|
879
|
+
function setLoginAccount(_x14, _x15) {
|
|
1074
880
|
return _setLoginAccount.apply(this, arguments);
|
|
1075
881
|
}
|
|
1076
882
|
return setLoginAccount;
|
|
@@ -1078,14 +884,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1078
884
|
}, {
|
|
1079
885
|
key: "generateCartData",
|
|
1080
886
|
value: function () {
|
|
1081
|
-
var _generateCartData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1082
|
-
return _regeneratorRuntime().wrap(function
|
|
1083
|
-
while (1) switch (
|
|
887
|
+
var _generateCartData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
888
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
889
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1084
890
|
case 0:
|
|
1085
891
|
case "end":
|
|
1086
|
-
return
|
|
892
|
+
return _context17.stop();
|
|
1087
893
|
}
|
|
1088
|
-
},
|
|
894
|
+
}, _callee17);
|
|
1089
895
|
}));
|
|
1090
896
|
function generateCartData() {
|
|
1091
897
|
return _generateCartData.apply(this, arguments);
|
|
@@ -1095,23 +901,23 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1095
901
|
}, {
|
|
1096
902
|
key: "getFreeProduct",
|
|
1097
903
|
value: function () {
|
|
1098
|
-
var _getFreeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
904
|
+
var _getFreeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(id) {
|
|
1099
905
|
var res;
|
|
1100
|
-
return _regeneratorRuntime().wrap(function
|
|
1101
|
-
while (1) switch (
|
|
906
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
907
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1102
908
|
case 0:
|
|
1103
|
-
|
|
909
|
+
_context18.next = 2;
|
|
1104
910
|
return this.request.post("/pay/order/free-pay/".concat(id));
|
|
1105
911
|
case 2:
|
|
1106
|
-
res =
|
|
1107
|
-
return
|
|
912
|
+
res = _context18.sent;
|
|
913
|
+
return _context18.abrupt("return", res);
|
|
1108
914
|
case 4:
|
|
1109
915
|
case "end":
|
|
1110
|
-
return
|
|
916
|
+
return _context18.stop();
|
|
1111
917
|
}
|
|
1112
|
-
},
|
|
918
|
+
}, _callee18, this);
|
|
1113
919
|
}));
|
|
1114
|
-
function getFreeProduct(
|
|
920
|
+
function getFreeProduct(_x16) {
|
|
1115
921
|
return _getFreeProduct.apply(this, arguments);
|
|
1116
922
|
}
|
|
1117
923
|
return getFreeProduct;
|
|
@@ -1134,16 +940,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1134
940
|
}, {
|
|
1135
941
|
key: "submitOrder",
|
|
1136
942
|
value: function () {
|
|
1137
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
943
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
1138
944
|
var cartItems, newCartItems, type;
|
|
1139
|
-
return _regeneratorRuntime().wrap(function
|
|
1140
|
-
while (1) switch (
|
|
945
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
946
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1141
947
|
case 0:
|
|
1142
948
|
cartItems = this.store.cart.getItems();
|
|
1143
949
|
newCartItems = cloneDeep(cartItems); // 先整个临时的逻辑,把购物车里所有商品的资源给他格式化一下
|
|
1144
950
|
newCartItems.forEach(function (item) {
|
|
1145
951
|
if (item._origin.resources && item._origin.resources.length) {
|
|
1146
|
-
var _item$
|
|
952
|
+
var _item$_origin;
|
|
1147
953
|
item._origin.resources = item._origin.resources.map(function (n) {
|
|
1148
954
|
var newResourcesItem = cloneDeep(n);
|
|
1149
955
|
delete newResourcesItem.id;
|
|
@@ -1151,13 +957,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1151
957
|
delete newResourcesItem.resourceType;
|
|
1152
958
|
return _objectSpread({}, newResourcesItem);
|
|
1153
959
|
});
|
|
1154
|
-
var
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
});
|
|
1158
|
-
var currentCapacity = getSumCapacity({
|
|
1159
|
-
capacity: formatCapacity
|
|
1160
|
-
});
|
|
960
|
+
var _getCapacityInfoByCar = getCapacityInfoByCartItem(item),
|
|
961
|
+
currentCapacity = _getCapacityInfoByCar.currentCapacity,
|
|
962
|
+
formatCapacity = _getCapacityInfoByCar.formatCapacity;
|
|
1161
963
|
if (!((_item$_origin = item._origin) !== null && _item$_origin !== void 0 && _item$_origin.metadata)) {
|
|
1162
964
|
item._origin.metadata = {};
|
|
1163
965
|
}
|
|
@@ -1171,7 +973,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1171
973
|
}))) {
|
|
1172
974
|
type = 'virtual';
|
|
1173
975
|
}
|
|
1174
|
-
return
|
|
976
|
+
return _context19.abrupt("return", this.store.order.submitOrder({
|
|
1175
977
|
query: {
|
|
1176
978
|
cartItems: newCartItems,
|
|
1177
979
|
type: type
|
|
@@ -1179,9 +981,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1179
981
|
}));
|
|
1180
982
|
case 6:
|
|
1181
983
|
case "end":
|
|
1182
|
-
return
|
|
984
|
+
return _context19.stop();
|
|
1183
985
|
}
|
|
1184
|
-
},
|
|
986
|
+
}, _callee19, this);
|
|
1185
987
|
}));
|
|
1186
988
|
function submitOrder() {
|
|
1187
989
|
return _submitOrder.apply(this, arguments);
|
|
@@ -1191,14 +993,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1191
993
|
}, {
|
|
1192
994
|
key: "pay",
|
|
1193
995
|
value: function () {
|
|
1194
|
-
var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1195
|
-
return _regeneratorRuntime().wrap(function
|
|
1196
|
-
while (1) switch (
|
|
996
|
+
var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
997
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
998
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1197
999
|
case 0:
|
|
1198
1000
|
case "end":
|
|
1199
|
-
return
|
|
1001
|
+
return _context20.stop();
|
|
1200
1002
|
}
|
|
1201
|
-
},
|
|
1003
|
+
}, _callee20);
|
|
1202
1004
|
}));
|
|
1203
1005
|
function pay() {
|
|
1204
1006
|
return _pay.apply(this, arguments);
|
|
@@ -1208,14 +1010,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1208
1010
|
}, {
|
|
1209
1011
|
key: "getPayInfo",
|
|
1210
1012
|
value: function () {
|
|
1211
|
-
var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1212
|
-
return _regeneratorRuntime().wrap(function
|
|
1213
|
-
while (1) switch (
|
|
1013
|
+
var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
1014
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1015
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1214
1016
|
case 0:
|
|
1215
1017
|
case "end":
|
|
1216
|
-
return
|
|
1018
|
+
return _context21.stop();
|
|
1217
1019
|
}
|
|
1218
|
-
},
|
|
1020
|
+
}, _callee21);
|
|
1219
1021
|
}));
|
|
1220
1022
|
function getPayInfo() {
|
|
1221
1023
|
return _getPayInfo.apply(this, arguments);
|
|
@@ -1225,15 +1027,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1225
1027
|
}, {
|
|
1226
1028
|
key: "setOtherParams",
|
|
1227
1029
|
value: function () {
|
|
1228
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1229
|
-
var
|
|
1230
|
-
|
|
1030
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
|
|
1031
|
+
var _ref5,
|
|
1032
|
+
_ref5$cover,
|
|
1231
1033
|
cover,
|
|
1232
|
-
|
|
1233
|
-
return _regeneratorRuntime().wrap(function
|
|
1234
|
-
while (1) switch (
|
|
1034
|
+
_args22 = arguments;
|
|
1035
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1036
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1235
1037
|
case 0:
|
|
1236
|
-
|
|
1038
|
+
_ref5 = _args22.length > 1 && _args22[1] !== undefined ? _args22[1] : {}, _ref5$cover = _ref5.cover, cover = _ref5$cover === void 0 ? false : _ref5$cover;
|
|
1237
1039
|
if (cover) {
|
|
1238
1040
|
this.otherParams = params;
|
|
1239
1041
|
} else {
|
|
@@ -1241,11 +1043,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1241
1043
|
}
|
|
1242
1044
|
case 2:
|
|
1243
1045
|
case "end":
|
|
1244
|
-
return
|
|
1046
|
+
return _context22.stop();
|
|
1245
1047
|
}
|
|
1246
|
-
},
|
|
1048
|
+
}, _callee22, this);
|
|
1247
1049
|
}));
|
|
1248
|
-
function setOtherParams(
|
|
1050
|
+
function setOtherParams(_x17) {
|
|
1249
1051
|
return _setOtherParams.apply(this, arguments);
|
|
1250
1052
|
}
|
|
1251
1053
|
return setOtherParams;
|
|
@@ -1253,51 +1055,193 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1253
1055
|
}, {
|
|
1254
1056
|
key: "getOtherParams",
|
|
1255
1057
|
value: function () {
|
|
1256
|
-
var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1257
|
-
return _regeneratorRuntime().wrap(function
|
|
1258
|
-
while (1) switch (
|
|
1058
|
+
var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
1059
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
1060
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1259
1061
|
case 0:
|
|
1260
|
-
return
|
|
1062
|
+
return _context23.abrupt("return", this.otherParams);
|
|
1261
1063
|
case 1:
|
|
1262
1064
|
case "end":
|
|
1263
|
-
return
|
|
1065
|
+
return _context23.stop();
|
|
1264
1066
|
}
|
|
1265
|
-
},
|
|
1067
|
+
}, _callee23, this);
|
|
1266
1068
|
}));
|
|
1267
1069
|
function getOtherParams() {
|
|
1268
1070
|
return _getOtherParams.apply(this, arguments);
|
|
1269
1071
|
}
|
|
1270
1072
|
return getOtherParams;
|
|
1271
|
-
}()
|
|
1073
|
+
}()
|
|
1074
|
+
/**
|
|
1075
|
+
* 往购物车加商品数据(duration 类、普通商品)
|
|
1076
|
+
* 老接口,先不删,怕 UI 有问题,直接桥接到新接口addProductToCart上
|
|
1077
|
+
*
|
|
1078
|
+
* @param {ProductData} productData
|
|
1079
|
+
* @memberof BookingByStepImpl
|
|
1080
|
+
*/
|
|
1272
1081
|
}, {
|
|
1273
|
-
key: "
|
|
1274
|
-
value: function
|
|
1275
|
-
var
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1082
|
+
key: "storeProduct",
|
|
1083
|
+
value: (function () {
|
|
1084
|
+
var _storeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(productData) {
|
|
1085
|
+
var activeAccount;
|
|
1086
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1087
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1088
|
+
case 0:
|
|
1089
|
+
// 往购物车加商品数据的时候,默认用当前 activeAccount 填充到 product 的 account 里面
|
|
1090
|
+
activeAccount = this.getActiveAccount(); // 直接调用 addProductToCart,不传递 date 参数以避免日期检查逻辑
|
|
1091
|
+
this.addProductToCart({
|
|
1092
|
+
product: productData,
|
|
1093
|
+
account: activeAccount
|
|
1094
|
+
});
|
|
1095
|
+
case 2:
|
|
1096
|
+
case "end":
|
|
1097
|
+
return _context24.stop();
|
|
1098
|
+
}
|
|
1099
|
+
}, _callee24, this);
|
|
1100
|
+
}));
|
|
1101
|
+
function storeProduct(_x18) {
|
|
1102
|
+
return _storeProduct.apply(this, arguments);
|
|
1279
1103
|
}
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1104
|
+
return storeProduct;
|
|
1105
|
+
}()
|
|
1106
|
+
/**
|
|
1107
|
+
* 往购物车加商品数据
|
|
1108
|
+
*
|
|
1109
|
+
* @param {({
|
|
1110
|
+
* product: ProductData;
|
|
1111
|
+
* date?: { startTime: string; endTime: string } | null;
|
|
1112
|
+
* account?: Account | null;
|
|
1113
|
+
* })} {
|
|
1114
|
+
* product,
|
|
1115
|
+
* date,
|
|
1116
|
+
* account,
|
|
1117
|
+
* }
|
|
1118
|
+
* @return {*}
|
|
1119
|
+
* @memberof BookingByStepImpl
|
|
1120
|
+
*/
|
|
1121
|
+
)
|
|
1122
|
+
}, {
|
|
1123
|
+
key: "addProductToCart",
|
|
1124
|
+
value: function addProductToCart(_ref6) {
|
|
1125
|
+
var product = _ref6.product,
|
|
1126
|
+
date = _ref6.date,
|
|
1127
|
+
account = _ref6.account;
|
|
1128
|
+
var _ref7 = product || {},
|
|
1129
|
+
bundle = _ref7.bundle,
|
|
1130
|
+
options = _ref7.options,
|
|
1131
|
+
origin = _ref7.origin,
|
|
1132
|
+
product_variant_id = _ref7.product_variant_id,
|
|
1133
|
+
rowKey = _ref7.rowKey,
|
|
1134
|
+
_ref7$quantity = _ref7.quantity,
|
|
1135
|
+
quantity = _ref7$quantity === void 0 ? 1 : _ref7$quantity;
|
|
1136
|
+
var productData = _objectSpread(_objectSpread({}, origin), {}, {
|
|
1137
|
+
product_variant_id: product_variant_id
|
|
1138
|
+
});
|
|
1139
|
+
if (!account) {
|
|
1140
|
+
var activeAccount = this.getActiveAccount();
|
|
1141
|
+
if (activeAccount) {
|
|
1142
|
+
account = activeAccount;
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
var flag = this.store.cart.mergeCartItemByRowKey({
|
|
1146
|
+
rowKey: rowKey,
|
|
1147
|
+
quantity: quantity,
|
|
1148
|
+
account: account || undefined
|
|
1149
|
+
});
|
|
1150
|
+
if (flag) {
|
|
1151
|
+
return;
|
|
1152
|
+
}
|
|
1153
|
+
var addItemParams = {
|
|
1154
|
+
product: productData,
|
|
1155
|
+
bundle: bundle,
|
|
1156
|
+
options: options,
|
|
1157
|
+
quantity: quantity
|
|
1158
|
+
};
|
|
1159
|
+
if (date) {
|
|
1160
|
+
addItemParams.date = date;
|
|
1161
|
+
}
|
|
1162
|
+
if (account) {
|
|
1163
|
+
addItemParams.account = account;
|
|
1164
|
+
}
|
|
1165
|
+
this.addProductCheck({
|
|
1166
|
+
date: date
|
|
1167
|
+
});
|
|
1168
|
+
this.store.cart.addItem(addItemParams);
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
/**
|
|
1172
|
+
* 添加完购物车以后做的一些检测,比如日期是否在同一天
|
|
1173
|
+
*
|
|
1174
|
+
* @param {({ date?: { startTime: string; endTime: string } | null })} { date }
|
|
1175
|
+
* @memberof BookingByStepImpl
|
|
1176
|
+
*/
|
|
1177
|
+
}, {
|
|
1178
|
+
key: "addProductCheck",
|
|
1179
|
+
value: function addProductCheck(_ref8) {
|
|
1180
|
+
var _this6 = this;
|
|
1181
|
+
var date = _ref8.date;
|
|
1182
|
+
// 检测,有传递 date,检查购物车里其他商品的 date 是否在同一天,如果不在,清空那些不在同一天的商品
|
|
1183
|
+
if (date) {
|
|
1184
|
+
var cartItems = this.store.cart.getItems().filter(function (n) {
|
|
1185
|
+
return !isNormalProduct(n._productOrigin);
|
|
1286
1186
|
});
|
|
1287
|
-
var
|
|
1288
|
-
|
|
1187
|
+
var cartItemsByDate = cartItems.filter(function (n) {
|
|
1188
|
+
return !dayjs(n.start_date).isSame(dayjs(date.startTime), 'day');
|
|
1289
1189
|
});
|
|
1190
|
+
if (cartItemsByDate.length) {
|
|
1191
|
+
cartItemsByDate.forEach(function (n) {
|
|
1192
|
+
_this6.store.cart.removeItem(n._id);
|
|
1193
|
+
});
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
}, {
|
|
1198
|
+
key: "beforeUpdateCart",
|
|
1199
|
+
value: function beforeUpdateCart(params, targetCartItem) {
|
|
1200
|
+
if (params.resources) {
|
|
1201
|
+
var _getCapacityInfoByCar2 = getCapacityInfoByCartItem(targetCartItem),
|
|
1202
|
+
currentCapacity = _getCapacityInfoByCar2.currentCapacity;
|
|
1290
1203
|
params.resources = params.resources.map(function (n) {
|
|
1291
1204
|
n.capacity = currentCapacity || 1;
|
|
1292
|
-
currentResourcesCapacityMap[n.id] = currentCapacity;
|
|
1293
1205
|
checkSubResourcesCapacity(n);
|
|
1294
1206
|
return n;
|
|
1295
1207
|
});
|
|
1296
1208
|
}
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
// 更新购物车
|
|
1212
|
+
}, {
|
|
1213
|
+
key: "updateCart",
|
|
1214
|
+
value: function updateCart(params) {
|
|
1215
|
+
var targetCartItem = this.store.cart.getItem(params._id);
|
|
1216
|
+
if (!targetCartItem) {
|
|
1217
|
+
throw new Error("\u6CA1\u6709\u627E\u5230".concat(params._id, "\u8D2D\u7269\u8F66\u5546\u54C1"));
|
|
1218
|
+
}
|
|
1219
|
+
this.beforeUpdateCart(params, targetCartItem);
|
|
1297
1220
|
this.store.cart.updateItem(params);
|
|
1221
|
+
this.updateCartCheck(params, targetCartItem);
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
/**
|
|
1225
|
+
* 更新购物车以后的一些操作,比如检测资源是否重复,检测资源容量是否足够
|
|
1226
|
+
*
|
|
1227
|
+
* @param {IUpdateItemParams} params
|
|
1228
|
+
* @param {CartItem} targetCartItem
|
|
1229
|
+
* @return {*}
|
|
1230
|
+
* @memberof BookingByStepImpl
|
|
1231
|
+
*/
|
|
1232
|
+
}, {
|
|
1233
|
+
key: "updateCartCheck",
|
|
1234
|
+
value: function updateCartCheck(params, targetCartItem) {
|
|
1235
|
+
var _params$resources,
|
|
1236
|
+
_this7 = this;
|
|
1237
|
+
// 零售模板不需要检测
|
|
1298
1238
|
if (this.otherParams.isRetailTemplate) {
|
|
1299
1239
|
return;
|
|
1300
1240
|
}
|
|
1241
|
+
var currentResourcesCapacityMap = {};
|
|
1242
|
+
(_params$resources = params.resources) === null || _params$resources === void 0 || _params$resources.forEach(function (n) {
|
|
1243
|
+
currentResourcesCapacityMap[n.id] = n.capacity;
|
|
1244
|
+
});
|
|
1301
1245
|
var allOriginResources = [];
|
|
1302
1246
|
var dateRange = this.store.date.getDateRange();
|
|
1303
1247
|
if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
|
|
@@ -1319,48 +1263,27 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1319
1263
|
cartItems.forEach(function (item) {
|
|
1320
1264
|
if (item._id !== targetCartItem._id) {
|
|
1321
1265
|
var _item$_origin$resourc;
|
|
1266
|
+
var _getCapacityInfoByCar3 = getCapacityInfoByCartItem(item),
|
|
1267
|
+
currentCapacity = _getCapacityInfoByCar3.currentCapacity;
|
|
1322
1268
|
var resources = (_item$_origin$resourc = item._origin.resources) === null || _item$_origin$resourc === void 0 ? void 0 : _item$_origin$resourc.filter(function (m) {
|
|
1323
1269
|
// 检查当前资源是否与目标资源的任何资源匹配
|
|
1324
1270
|
// 目标资源,应该只取跟当前 m.form_id 相同的资源
|
|
1325
|
-
var sameFormIdResources = targetCartItem._origin.resources.
|
|
1326
|
-
return n.form_id === m.form_id;
|
|
1327
|
-
});
|
|
1271
|
+
var sameFormIdResources = filterResourcesByFormItem(targetCartItem._origin.resources, m.form_id);
|
|
1328
1272
|
if (!(sameFormIdResources !== null && sameFormIdResources !== void 0 && sameFormIdResources.length)) {
|
|
1329
1273
|
return true;
|
|
1330
1274
|
}
|
|
1331
1275
|
return !sameFormIdResources.some(function (targetRes) {
|
|
1332
1276
|
// 如果新更新进来的资源不是单个预约,其实就不需要检测了资源重叠了,但是需要检测资源 capacity 是否足够
|
|
1333
1277
|
if (targetRes.resourceType !== 'single') {
|
|
1334
|
-
var _item$_productOrigin2;
|
|
1335
|
-
var _formatCapacity = formatDefaultCapacitys({
|
|
1336
|
-
capacity: (_item$_productOrigin2 = item._productOrigin) === null || _item$_productOrigin2 === void 0 ? void 0 : _item$_productOrigin2.capacity,
|
|
1337
|
-
product_bundle: item._origin.product.product_bundle
|
|
1338
|
-
});
|
|
1339
|
-
var _currentCapacity = getSumCapacity({
|
|
1340
|
-
capacity: _formatCapacity
|
|
1341
|
-
});
|
|
1342
1278
|
var originResource = allOriginResources.find(function (n) {
|
|
1343
1279
|
return n.id === targetRes.id;
|
|
1344
1280
|
});
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
currentResourcesCapacityMap[m.id] += _currentCapacity;
|
|
1349
|
-
return false;
|
|
1281
|
+
var canUse = checkResourceCanUseByCapacity(currentResourcesCapacityMap[m.id], currentCapacity, originResource === null || originResource === void 0 ? void 0 : originResource.capacity);
|
|
1282
|
+
if (canUse) currentResourcesCapacityMap[m.id] += currentCapacity;
|
|
1283
|
+
return !canUse;
|
|
1350
1284
|
}
|
|
1351
1285
|
if (item.holder_id !== (targetCartItem === null || targetCartItem === void 0 ? void 0 : targetCartItem.holder_id)) {
|
|
1352
|
-
|
|
1353
|
-
// 检查主资源ID是否匹配
|
|
1354
|
-
if (targetRes.id === m.id) return true;
|
|
1355
|
-
// 检查组合资源的情况
|
|
1356
|
-
if (((_targetRes$metadata$c = targetRes.metadata.combined_resource) === null || _targetRes$metadata$c === void 0 ? void 0 : _targetRes$metadata$c.status) === 1 && (
|
|
1357
|
-
// 如果现在选择的是组合资源,需要判断
|
|
1358
|
-
// 1、当前其他购物车里是否选了当前组合资源的子资源
|
|
1359
|
-
// 2、如果其他购物车里的商品也是组合资源,出了组合资源本身的 id 需要判断,还需要判断子资源的 id 是否有交集
|
|
1360
|
-
targetRes.metadata.combined_resource.resource_ids.includes(m.id) || targetRes.metadata.combined_resource.resource_ids.some(function (n) {
|
|
1361
|
-
return m.metadata.combined_resource.resource_ids.includes(n);
|
|
1362
|
-
}))) return true;
|
|
1363
|
-
if (((_m$metadata$combined_ = m.metadata.combined_resource) === null || _m$metadata$combined_ === void 0 ? void 0 : _m$metadata$combined_.status) === 1 && m.metadata.combined_resource.resource_ids.includes(targetRes.id)) return true;
|
|
1286
|
+
return checkTwoResourcesIntersection(targetRes, m);
|
|
1364
1287
|
}
|
|
1365
1288
|
return false;
|
|
1366
1289
|
});
|
|
@@ -1371,7 +1294,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1371
1294
|
var end_time = item.end_time;
|
|
1372
1295
|
var start_date = item.start_date;
|
|
1373
1296
|
var end_date = item.end_date;
|
|
1374
|
-
|
|
1297
|
+
_this7.store.cart.updateItem({
|
|
1375
1298
|
_id: item._id,
|
|
1376
1299
|
resources: resources,
|
|
1377
1300
|
date: {
|
|
@@ -1380,7 +1303,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1380
1303
|
}
|
|
1381
1304
|
});
|
|
1382
1305
|
} else {
|
|
1383
|
-
|
|
1306
|
+
_this7.store.cart.updateItem({
|
|
1384
1307
|
_id: item._id,
|
|
1385
1308
|
resources: resources
|
|
1386
1309
|
});
|
|
@@ -1417,208 +1340,75 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1417
1340
|
}, {
|
|
1418
1341
|
key: "batchUpdateCart",
|
|
1419
1342
|
value: function batchUpdateCart(paramsList) {
|
|
1420
|
-
var
|
|
1343
|
+
var _this8 = this;
|
|
1421
1344
|
var cartItems = [];
|
|
1422
1345
|
paramsList.forEach(function (params) {
|
|
1423
|
-
var cartItem =
|
|
1346
|
+
var cartItem = _this8.store.cart.formatCartItem(params);
|
|
1424
1347
|
cartItems.push(cartItem);
|
|
1425
1348
|
});
|
|
1426
1349
|
this.store.cart.batchSetItems(cartItems);
|
|
1427
1350
|
}
|
|
1428
1351
|
|
|
1429
|
-
/**
|
|
1430
|
-
* 从购物车中按类别删除信息
|
|
1431
|
-
*/
|
|
1432
|
-
}, {
|
|
1433
|
-
key: "deleteCartItemInfo",
|
|
1434
|
-
value: function deleteCartItemInfo(type, _id) {
|
|
1435
|
-
this.store.cart.deleteCartItemInfo(type, _id);
|
|
1436
|
-
}
|
|
1437
|
-
}, {
|
|
1438
|
-
key: "checkCartItemByType",
|
|
1439
|
-
value: function checkCartItemByType(cartItem, type) {
|
|
1440
|
-
return this.store.cart.checkCartItemByType(cartItem, type);
|
|
1441
|
-
}
|
|
1442
|
-
|
|
1443
|
-
/**
|
|
1444
|
-
* 检查购物车商品是否符合条件
|
|
1445
|
-
* @param type 类型
|
|
1446
|
-
* @returns 不符合条件的购物车商品ID列表
|
|
1447
|
-
*/
|
|
1448
|
-
}, {
|
|
1449
|
-
key: "checkCartItems",
|
|
1450
|
-
value: function checkCartItems(type) {
|
|
1451
|
-
var
|
|
1452
|
-
// 预约流程中普通商品无需检测这些东西
|
|
1453
|
-
var cartItems = this.store.cart.getItems().filter(function (n) {
|
|
1454
|
-
return !isNormalProduct(n._productOrigin);
|
|
1455
|
-
});
|
|
1456
|
-
var errorCartItemIds = [];
|
|
1457
|
-
cartItems.forEach(function (cartItem) {
|
|
1458
|
-
var result =
|
|
1459
|
-
if (!result) {
|
|
1460
|
-
errorCartItemIds.push(cartItem._id);
|
|
1461
|
-
}
|
|
1462
|
-
});
|
|
1463
|
-
return errorCartItemIds;
|
|
1464
|
-
}
|
|
1465
|
-
}, {
|
|
1466
|
-
key: "destroy",
|
|
1467
|
-
value: function destroy() {
|
|
1468
|
-
var _this$store$cart, _this$store$step, _this$store$products, _this$store$guests, _this$store$date, _this$store$accountLi;
|
|
1469
|
-
(_this$store$cart = this.store.cart) === null || _this$store$cart === void 0 || _this$store$cart.destroy();
|
|
1470
|
-
(_this$store$step = this.store.step) === null || _this$store$step === void 0 || _this$store$step.destroy();
|
|
1471
|
-
(_this$store$products = this.store.products) === null || _this$store$products === void 0 || _this$store$products.destroy();
|
|
1472
|
-
(_this$store$guests = this.store.guests) === null || _this$store$guests === void 0 || _this$store$guests.destroy();
|
|
1473
|
-
(_this$store$date = this.store.date) === null || _this$store$date === void 0 || _this$store$date.destroy();
|
|
1474
|
-
(_this$store$accountLi = this.store.accountList) === null || _this$store$accountLi === void 0 || _this$store$accountLi.destroy();
|
|
1475
|
-
this.core.effects.offByModuleDestroy(this.name);
|
|
1476
|
-
this.core.unregisterModule(this);
|
|
1477
|
-
}
|
|
1478
|
-
|
|
1479
|
-
// 获取当前购物车内所有关联的资源列表,拼装数据格式
|
|
1480
|
-
}, {
|
|
1481
|
-
key: "getResourcesList",
|
|
1482
|
-
value: function getResourcesList() {
|
|
1483
|
-
var _this9 = this;
|
|
1484
|
-
var dateRange = this.store.date.getDateRange();
|
|
1485
|
-
var resources = [];
|
|
1486
|
-
if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
|
|
1487
|
-
dateRange.forEach(function (n) {
|
|
1488
|
-
if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
|
|
1489
|
-
});
|
|
1490
|
-
}
|
|
1491
|
-
// 如果此时 resources 为空,视作购物车里已经有了 dateRange 数据,此时 dateList 里明确就是那一天的数据
|
|
1492
|
-
if (!resources.length) {
|
|
1493
|
-
var dateList = this.store.date.getDateList();
|
|
1494
|
-
dateList.forEach(function (n) {
|
|
1495
|
-
if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
|
|
1496
|
-
});
|
|
1497
|
-
}
|
|
1498
|
-
var resourcesMap = getResourcesMap(cloneDeep(resources));
|
|
1499
|
-
var cartItems = this.store.cart.getItems().filter(function (n) {
|
|
1500
|
-
return !isNormalProduct(n._productOrigin);
|
|
1501
|
-
});
|
|
1502
|
-
var arr = [];
|
|
1503
|
-
cartItems.forEach(function (cartItem) {
|
|
1504
|
-
var _cartItem$_productOri, _cartItem$_productOri2;
|
|
1505
|
-
var selectedResources = [];
|
|
1506
|
-
var formatCapacity = formatDefaultCapacitys({
|
|
1507
|
-
capacity: (_cartItem$_productOri = cartItem._productOrigin) === null || _cartItem$_productOri === void 0 ? void 0 : _cartItem$_productOri.capacity,
|
|
1508
|
-
product_bundle: cartItem._origin.product.product_bundle
|
|
1509
|
-
});
|
|
1510
|
-
cartItem._origin.metadata.capacity = formatCapacity;
|
|
1511
|
-
var currentCapacity = getSumCapacity({
|
|
1512
|
-
capacity: formatCapacity
|
|
1513
|
-
});
|
|
1514
|
-
if (cartItem.holder_id) {
|
|
1515
|
-
selectedResources = getOthersSelectedResources(cartItems, cartItem.holder_id, resourcesMap);
|
|
1516
|
-
} else {
|
|
1517
|
-
selectedResources = getOthersCartSelectedResources(cartItems, cartItem._id, resourcesMap);
|
|
1518
|
-
}
|
|
1519
|
-
var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri2 = cartItem._productOrigin) === null || _cartItem$_productOri2 === void 0 || (_cartItem$_productOri2 = _cartItem$_productOri2.product_resource) === null || _cartItem$_productOri2 === void 0 ? void 0 : _cartItem$_productOri2.resources) || [], selectedResources, currentCapacity);
|
|
1520
|
-
// 如果购物车里已经有了时间片,则需要按照时间片过滤
|
|
1521
|
-
if (cartItem._origin.start_time) {
|
|
1522
|
-
var startTime = dayjs("".concat(cartItem._origin.start_date, " ").concat(cartItem._origin.start_time));
|
|
1523
|
-
var endTime = dayjs("".concat(cartItem._origin.end_date, " ").concat(cartItem._origin.end_time));
|
|
1524
|
-
var resourcesUseableMap = {};
|
|
1525
|
-
productResources.forEach(function (n) {
|
|
1526
|
-
// 资源排下序,把单个资源靠前,组合资源排在后面
|
|
1527
|
-
n.renderList = n.renderList.sort(function (a, b) {
|
|
1528
|
-
var _a$metadata, _b$metadata;
|
|
1529
|
-
var aIsCombined = ((_a$metadata = a.metadata) === null || _a$metadata === void 0 || (_a$metadata = _a$metadata.combined_resource) === null || _a$metadata === void 0 ? void 0 : _a$metadata.status) === 1;
|
|
1530
|
-
var bIsCombined = ((_b$metadata = b.metadata) === null || _b$metadata === void 0 || (_b$metadata = _b$metadata.combined_resource) === null || _b$metadata === void 0 ? void 0 : _b$metadata.status) === 1;
|
|
1531
|
-
if (aIsCombined && !bIsCombined) return 1;
|
|
1532
|
-
if (!aIsCombined && bIsCombined) return -1;
|
|
1533
|
-
return 0;
|
|
1534
|
-
});
|
|
1535
|
-
n.renderList = n.renderList.filter(function (m) {
|
|
1536
|
-
// m.times 需要做个过滤,假设 timeSlice.start_at 是 09:30 timeSlice.end_at 是 11:30
|
|
1537
|
-
// time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
|
|
1538
|
-
// 需要判断 time 的开始结束时间 是否包含timeSlice的开始结束时间
|
|
1539
|
-
var mTimes = m.times.filter(function (n) {
|
|
1540
|
-
return !dayjs(n.start_at).isAfter(dayjs(startTime)) && !dayjs(n.end_at).isBefore(dayjs(endTime));
|
|
1541
|
-
});
|
|
1542
|
-
// 如果在这个区间的时间一个都没有,可以直接认为这个资源不可用
|
|
1543
|
-
if (mTimes.length === 0) {
|
|
1544
|
-
return false;
|
|
1545
|
-
}
|
|
1546
|
-
var canUseArr = mTimes.map(function (item) {
|
|
1547
|
-
var _cartItem$_productOri3;
|
|
1548
|
-
var res = getIsUsableByTimeItem({
|
|
1549
|
-
timeSlice: {
|
|
1550
|
-
start_time: startTime.format('HH:mm'),
|
|
1551
|
-
end_time: endTime.format('HH:mm'),
|
|
1552
|
-
start_at: startTime,
|
|
1553
|
-
end_at: endTime
|
|
1554
|
-
},
|
|
1555
|
-
time: item,
|
|
1556
|
-
resource: m,
|
|
1557
|
-
currentCount: currentCapacity || 0,
|
|
1558
|
-
resourcesUseableMap: resourcesUseableMap,
|
|
1559
|
-
cut_off_time: (_cartItem$_productOri3 = cartItem._productOrigin) === null || _cartItem$_productOri3 === void 0 ? void 0 : _cartItem$_productOri3.cut_off_time
|
|
1560
|
-
});
|
|
1561
|
-
// 如果仅仅是因为子资源容量不够,不应该标记子资源是被占用的情况
|
|
1562
|
-
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
|
|
1563
|
-
resourcesUseableMap[m.id] = res.usable;
|
|
1564
|
-
}
|
|
1565
|
-
return res.usable;
|
|
1566
|
-
});
|
|
1567
|
-
if (m.onlyComputed) return false;
|
|
1568
|
-
// 在已经选定时间的情况下,只要canUseTime 里有一个 false,那就代表不可用
|
|
1569
|
-
return !canUseArr.some(function (n) {
|
|
1570
|
-
return n === false;
|
|
1571
|
-
});
|
|
1572
|
-
});
|
|
1573
|
-
});
|
|
1574
|
-
} else {
|
|
1575
|
-
var _cartItem$_productOri4, _this9$shopStore$get;
|
|
1576
|
-
var hasFlexibleDuration = ((_cartItem$_productOri4 = cartItem._productOrigin) === null || _cartItem$_productOri4 === void 0 || (_cartItem$_productOri4 = _cartItem$_productOri4.duration) === null || _cartItem$_productOri4 === void 0 ? void 0 : _cartItem$_productOri4.type) === 'flexible';
|
|
1577
|
-
var operating_day_boundary = (_this9$shopStore$get = _this9.shopStore.get('core')) === null || _this9$shopStore$get === void 0 || (_this9$shopStore$get = _this9$shopStore$get.core) === null || _this9$shopStore$get === void 0 ? void 0 : _this9$shopStore$get.operating_day_boundary;
|
|
1578
|
-
productResources.forEach(function (item) {
|
|
1579
|
-
// 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
|
|
1580
|
-
// 同时,在这一步尝试去拉一下时间片,基于商品的时长,看每个资源是否还有空余时间能对这个商品做服务,如果没有则过滤
|
|
1581
|
-
item.renderList = item.renderList.filter(function (n) {
|
|
1582
|
-
var _cartItem$_productOri5, _cartItem$_productOri6;
|
|
1583
|
-
var recordCount = n.capacity || 0;
|
|
1584
|
-
if (n.onlyComputed) return false;
|
|
1585
|
-
// 查一下这个资源基于商品的可用时间片
|
|
1586
|
-
var timeSlots = getTimeSlicesByResource({
|
|
1587
|
-
resource: n,
|
|
1588
|
-
duration: ((_cartItem$_productOri5 = cartItem._productOrigin) === null || _cartItem$_productOri5 === void 0 || (_cartItem$_productOri5 = _cartItem$_productOri5.duration) === null || _cartItem$_productOri5 === void 0 ? void 0 : _cartItem$_productOri5.value) || 10,
|
|
1589
|
-
split: 10,
|
|
1590
|
-
currentDate: dateRange[0].date,
|
|
1591
|
-
hasFlexibleDuration: hasFlexibleDuration,
|
|
1592
|
-
cut_off_time: (_cartItem$_productOri6 = cartItem._productOrigin) === null || _cartItem$_productOri6 === void 0 ? void 0 : _cartItem$_productOri6.cut_off_time,
|
|
1593
|
-
operating_day_boundary: operating_day_boundary
|
|
1594
|
-
});
|
|
1595
|
-
return recordCount >= currentCapacity && timeSlots.length > 0;
|
|
1596
|
-
});
|
|
1597
|
-
});
|
|
1352
|
+
/**
|
|
1353
|
+
* 从购物车中按类别删除信息
|
|
1354
|
+
*/
|
|
1355
|
+
}, {
|
|
1356
|
+
key: "deleteCartItemInfo",
|
|
1357
|
+
value: function deleteCartItemInfo(type, _id) {
|
|
1358
|
+
this.store.cart.deleteCartItemInfo(type, _id);
|
|
1359
|
+
}
|
|
1360
|
+
}, {
|
|
1361
|
+
key: "checkCartItemByType",
|
|
1362
|
+
value: function checkCartItemByType(cartItem, type) {
|
|
1363
|
+
return this.store.cart.checkCartItemByType(cartItem, type);
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
/**
|
|
1367
|
+
* 检查购物车商品是否符合条件
|
|
1368
|
+
* @param type 类型
|
|
1369
|
+
* @returns 不符合条件的购物车商品ID列表
|
|
1370
|
+
*/
|
|
1371
|
+
}, {
|
|
1372
|
+
key: "checkCartItems",
|
|
1373
|
+
value: function checkCartItems(type) {
|
|
1374
|
+
var _this9 = this;
|
|
1375
|
+
// 预约流程中普通商品无需检测这些东西
|
|
1376
|
+
var cartItems = this.store.cart.getItems().filter(function (n) {
|
|
1377
|
+
return !isNormalProduct(n._productOrigin);
|
|
1378
|
+
});
|
|
1379
|
+
var errorCartItemIds = [];
|
|
1380
|
+
cartItems.forEach(function (cartItem) {
|
|
1381
|
+
var result = _this9.store.cart.checkCartItemByType(cartItem, type);
|
|
1382
|
+
if (!result) {
|
|
1383
|
+
errorCartItemIds.push(cartItem._id);
|
|
1598
1384
|
}
|
|
1599
|
-
arr.push({
|
|
1600
|
-
id: cartItem.id,
|
|
1601
|
-
// 这里返回的是购物车 id ,后面提交的时候要用的,用这个 id 绑定资源和时间
|
|
1602
|
-
_id: cartItem._id,
|
|
1603
|
-
// 这里返回的是购物车 id ,后面提交的时候要用的,用这个 id 绑定资源和时间
|
|
1604
|
-
product: cartItem._productOrigin,
|
|
1605
|
-
resources: productResources,
|
|
1606
|
-
holder_id: cartItem.holder_id,
|
|
1607
|
-
holder_name: cartItem.holder_title
|
|
1608
|
-
});
|
|
1609
1385
|
});
|
|
1610
|
-
return
|
|
1386
|
+
return errorCartItemIds;
|
|
1387
|
+
}
|
|
1388
|
+
}, {
|
|
1389
|
+
key: "destroy",
|
|
1390
|
+
value: function destroy() {
|
|
1391
|
+
var _this$store$cart, _this$store$step, _this$store$products, _this$store$guests, _this$store$date, _this$store$accountLi;
|
|
1392
|
+
(_this$store$cart = this.store.cart) === null || _this$store$cart === void 0 || _this$store$cart.destroy();
|
|
1393
|
+
(_this$store$step = this.store.step) === null || _this$store$step === void 0 || _this$store$step.destroy();
|
|
1394
|
+
(_this$store$products = this.store.products) === null || _this$store$products === void 0 || _this$store$products.destroy();
|
|
1395
|
+
(_this$store$guests = this.store.guests) === null || _this$store$guests === void 0 || _this$store$guests.destroy();
|
|
1396
|
+
(_this$store$date = this.store.date) === null || _this$store$date === void 0 || _this$store$date.destroy();
|
|
1397
|
+
(_this$store$accountLi = this.store.accountList) === null || _this$store$accountLi === void 0 || _this$store$accountLi.destroy();
|
|
1398
|
+
this.core.effects.offByModuleDestroy(this.name);
|
|
1399
|
+
this.core.unregisterModule(this);
|
|
1611
1400
|
}
|
|
1612
1401
|
|
|
1613
|
-
//
|
|
1402
|
+
// 获取当前购物车内所有关联的资源列表,拼装数据格式
|
|
1614
1403
|
}, {
|
|
1615
|
-
key: "
|
|
1616
|
-
value: function
|
|
1404
|
+
key: "getResourcesList",
|
|
1405
|
+
value: function getResourcesList() {
|
|
1406
|
+
var _this10 = this;
|
|
1617
1407
|
var dateRange = this.store.date.getDateRange();
|
|
1618
1408
|
var resources = [];
|
|
1619
1409
|
if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
|
|
1620
1410
|
dateRange.forEach(function (n) {
|
|
1621
|
-
|
|
1411
|
+
resources.push.apply(resources, _toConsumableArray(_this10.store.date.getResourcesListByDate(n.date) || []));
|
|
1622
1412
|
});
|
|
1623
1413
|
}
|
|
1624
1414
|
// 如果此时 resources 为空,视作购物车里已经有了 dateRange 数据,此时 dateList 里明确就是那一天的数据
|
|
@@ -1634,22 +1424,19 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1634
1424
|
});
|
|
1635
1425
|
var arr = [];
|
|
1636
1426
|
cartItems.forEach(function (cartItem) {
|
|
1637
|
-
var _cartItem$
|
|
1427
|
+
var _cartItem$_productOri;
|
|
1638
1428
|
var selectedResources = [];
|
|
1639
|
-
var
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
});
|
|
1429
|
+
var _getCapacityInfoByCar4 = getCapacityInfoByCartItem(cartItem),
|
|
1430
|
+
currentCapacity = _getCapacityInfoByCar4.currentCapacity,
|
|
1431
|
+
formatCapacity = _getCapacityInfoByCar4.formatCapacity;
|
|
1643
1432
|
cartItem._origin.metadata.capacity = formatCapacity;
|
|
1644
|
-
var currentCapacity = getSumCapacity({
|
|
1645
|
-
capacity: formatCapacity
|
|
1646
|
-
});
|
|
1647
1433
|
if (cartItem.holder_id) {
|
|
1648
1434
|
selectedResources = getOthersSelectedResources(cartItems, cartItem.holder_id, resourcesMap);
|
|
1649
1435
|
} else {
|
|
1650
1436
|
selectedResources = getOthersCartSelectedResources(cartItems, cartItem._id, resourcesMap);
|
|
1651
1437
|
}
|
|
1652
|
-
|
|
1438
|
+
// TODO:下面这一坨要放到 resources 模块去
|
|
1439
|
+
var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri = cartItem._productOrigin) === null || _cartItem$_productOri === void 0 || (_cartItem$_productOri = _cartItem$_productOri.product_resource) === null || _cartItem$_productOri === void 0 ? void 0 : _cartItem$_productOri.resources) || [], selectedResources, currentCapacity);
|
|
1653
1440
|
// 如果购物车里已经有了时间片,则需要按照时间片过滤
|
|
1654
1441
|
if (cartItem._origin.start_time) {
|
|
1655
1442
|
var startTime = dayjs("".concat(cartItem._origin.start_date, " ").concat(cartItem._origin.start_time));
|
|
@@ -1657,27 +1444,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1657
1444
|
var resourcesUseableMap = {};
|
|
1658
1445
|
productResources.forEach(function (n) {
|
|
1659
1446
|
// 资源排下序,把单个资源靠前,组合资源排在后面
|
|
1660
|
-
n.renderList = n.renderList
|
|
1661
|
-
var _a$metadata2, _b$metadata2;
|
|
1662
|
-
var aIsCombined = ((_a$metadata2 = a.metadata) === null || _a$metadata2 === void 0 || (_a$metadata2 = _a$metadata2.combined_resource) === null || _a$metadata2 === void 0 ? void 0 : _a$metadata2.status) === 1;
|
|
1663
|
-
var bIsCombined = ((_b$metadata2 = b.metadata) === null || _b$metadata2 === void 0 || (_b$metadata2 = _b$metadata2.combined_resource) === null || _b$metadata2 === void 0 ? void 0 : _b$metadata2.status) === 1;
|
|
1664
|
-
if (aIsCombined && !bIsCombined) return 1;
|
|
1665
|
-
if (!aIsCombined && bIsCombined) return -1;
|
|
1666
|
-
return 0;
|
|
1667
|
-
});
|
|
1447
|
+
n.renderList = sortCombinedResources(n.renderList);
|
|
1668
1448
|
n.renderList = n.renderList.filter(function (m) {
|
|
1669
1449
|
// m.times 需要做个过滤,假设 timeSlice.start_at 是 09:30 timeSlice.end_at 是 11:30
|
|
1670
1450
|
// time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
|
|
1671
1451
|
// 需要判断 time 的开始结束时间 是否包含timeSlice的开始结束时间
|
|
1672
|
-
var mTimes = m.times
|
|
1673
|
-
return !dayjs(n.start_at).isAfter(dayjs(startTime)) && !dayjs(n.end_at).isBefore(dayjs(endTime));
|
|
1674
|
-
});
|
|
1452
|
+
var mTimes = filterConditionTimeSlots(m.times, startTime, endTime);
|
|
1675
1453
|
// 如果在这个区间的时间一个都没有,可以直接认为这个资源不可用
|
|
1676
1454
|
if (mTimes.length === 0) {
|
|
1677
1455
|
return false;
|
|
1678
1456
|
}
|
|
1679
1457
|
var canUseArr = mTimes.map(function (item) {
|
|
1680
|
-
var _cartItem$
|
|
1458
|
+
var _cartItem$_productOri2;
|
|
1681
1459
|
var res = getIsUsableByTimeItem({
|
|
1682
1460
|
timeSlice: {
|
|
1683
1461
|
start_time: startTime.format('HH:mm'),
|
|
@@ -1689,9 +1467,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1689
1467
|
resource: m,
|
|
1690
1468
|
currentCount: currentCapacity || 0,
|
|
1691
1469
|
resourcesUseableMap: resourcesUseableMap,
|
|
1692
|
-
cut_off_time: (_cartItem$
|
|
1470
|
+
cut_off_time: (_cartItem$_productOri2 = cartItem._productOrigin) === null || _cartItem$_productOri2 === void 0 ? void 0 : _cartItem$_productOri2.cut_off_time
|
|
1693
1471
|
});
|
|
1694
|
-
// 如果仅仅是因为子资源容量不够,不应该标记子资源是被占用的情况
|
|
1472
|
+
// 如果仅仅是因为子资源容量不够,不应该标记子资源是被占用的情况(因为组合资源还需要判断子资源够不够)
|
|
1695
1473
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
|
|
1696
1474
|
resourcesUseableMap[m.id] = res.usable;
|
|
1697
1475
|
}
|
|
@@ -1705,19 +1483,25 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1705
1483
|
});
|
|
1706
1484
|
});
|
|
1707
1485
|
} else {
|
|
1486
|
+
var _cartItem$_productOri3, _this10$shopStore$get;
|
|
1487
|
+
var hasFlexibleDuration = ((_cartItem$_productOri3 = cartItem._productOrigin) === null || _cartItem$_productOri3 === void 0 || (_cartItem$_productOri3 = _cartItem$_productOri3.duration) === null || _cartItem$_productOri3 === void 0 ? void 0 : _cartItem$_productOri3.type) === 'flexible';
|
|
1488
|
+
var operating_day_boundary = (_this10$shopStore$get = _this10.shopStore.get('core')) === null || _this10$shopStore$get === void 0 || (_this10$shopStore$get = _this10$shopStore$get.core) === null || _this10$shopStore$get === void 0 ? void 0 : _this10$shopStore$get.operating_day_boundary;
|
|
1708
1489
|
productResources.forEach(function (item) {
|
|
1709
1490
|
// 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
|
|
1710
1491
|
// 同时,在这一步尝试去拉一下时间片,基于商品的时长,看每个资源是否还有空余时间能对这个商品做服务,如果没有则过滤
|
|
1711
1492
|
item.renderList = item.renderList.filter(function (n) {
|
|
1712
|
-
var _cartItem$
|
|
1493
|
+
var _cartItem$_productOri4, _cartItem$_productOri5;
|
|
1713
1494
|
var recordCount = n.capacity || 0;
|
|
1714
1495
|
if (n.onlyComputed) return false;
|
|
1715
1496
|
// 查一下这个资源基于商品的可用时间片
|
|
1716
1497
|
var timeSlots = getTimeSlicesByResource({
|
|
1717
1498
|
resource: n,
|
|
1718
|
-
duration: ((_cartItem$
|
|
1499
|
+
duration: ((_cartItem$_productOri4 = cartItem._productOrigin) === null || _cartItem$_productOri4 === void 0 || (_cartItem$_productOri4 = _cartItem$_productOri4.duration) === null || _cartItem$_productOri4 === void 0 ? void 0 : _cartItem$_productOri4.value) || 10,
|
|
1719
1500
|
split: 10,
|
|
1720
|
-
currentDate: dateRange[0].date
|
|
1501
|
+
currentDate: dateRange[0].date,
|
|
1502
|
+
hasFlexibleDuration: hasFlexibleDuration,
|
|
1503
|
+
cut_off_time: (_cartItem$_productOri5 = cartItem._productOrigin) === null || _cartItem$_productOri5 === void 0 ? void 0 : _cartItem$_productOri5.cut_off_time,
|
|
1504
|
+
operating_day_boundary: operating_day_boundary
|
|
1721
1505
|
});
|
|
1722
1506
|
return recordCount >= currentCapacity && timeSlots.length > 0;
|
|
1723
1507
|
});
|
|
@@ -1728,23 +1512,46 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1728
1512
|
// 这里返回的是购物车 id ,后面提交的时候要用的,用这个 id 绑定资源和时间
|
|
1729
1513
|
_id: cartItem._id,
|
|
1730
1514
|
// 这里返回的是购物车 id ,后面提交的时候要用的,用这个 id 绑定资源和时间
|
|
1731
|
-
|
|
1515
|
+
product: cartItem._productOrigin,
|
|
1516
|
+
resources: productResources,
|
|
1517
|
+
holder_id: cartItem.holder_id,
|
|
1518
|
+
holder_name: cartItem.holder_title
|
|
1732
1519
|
});
|
|
1733
1520
|
});
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1521
|
+
return arr;
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
/**
|
|
1525
|
+
* 在日期那边点击下一步的时候,检查这一天购物车里的商品是不是都有资源可以用
|
|
1526
|
+
*
|
|
1527
|
+
* @return {*}
|
|
1528
|
+
* @memberof BookingByStepImpl
|
|
1529
|
+
*/
|
|
1530
|
+
}, {
|
|
1531
|
+
key: "checkResourceListForDate",
|
|
1532
|
+
value: function checkResourceListForDate() {
|
|
1533
|
+
var resourcesList = this.getResourcesList();
|
|
1534
|
+
|
|
1535
|
+
// 检查每一项资源的 renderList 里是否都有数据
|
|
1536
|
+
var hasResource = resourcesList.every(function (item) {
|
|
1537
|
+
return item.resources.every(function (resource) {
|
|
1538
|
+
return resource.renderList.length > 0;
|
|
1738
1539
|
});
|
|
1739
1540
|
});
|
|
1740
1541
|
return hasResource;
|
|
1741
1542
|
}
|
|
1742
1543
|
|
|
1743
|
-
|
|
1544
|
+
/**
|
|
1545
|
+
* 给单个购物车里的商品获取资源列表,给 UI 用的
|
|
1546
|
+
*
|
|
1547
|
+
* @param {(string | number)} id
|
|
1548
|
+
* @return {*}
|
|
1549
|
+
* @memberof BookingByStepImpl
|
|
1550
|
+
*/
|
|
1744
1551
|
}, {
|
|
1745
1552
|
key: "getResourcesListByCartItem",
|
|
1746
1553
|
value: function getResourcesListByCartItem(id) {
|
|
1747
|
-
var _targetCartItem$
|
|
1554
|
+
var _targetCartItem$_prod;
|
|
1748
1555
|
var cartItems = this.store.cart.getItems().filter(function (n) {
|
|
1749
1556
|
return !isNormalProduct(n._productOrigin);
|
|
1750
1557
|
});
|
|
@@ -1762,19 +1569,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1762
1569
|
throw new Error("\u6CA1\u6709\u627E\u5230".concat(id, "\u8D2D\u7269\u8F66\u5546\u54C1"));
|
|
1763
1570
|
}
|
|
1764
1571
|
var selectedResources = [];
|
|
1765
|
-
var
|
|
1766
|
-
|
|
1767
|
-
product_bundle: targetCartItem._origin.product.product_bundle
|
|
1768
|
-
});
|
|
1769
|
-
var currentCapacity = getSumCapacity({
|
|
1770
|
-
capacity: formatCapacity
|
|
1771
|
-
});
|
|
1572
|
+
var _getCapacityInfoByCar5 = getCapacityInfoByCartItem(targetCartItem),
|
|
1573
|
+
currentCapacity = _getCapacityInfoByCar5.currentCapacity;
|
|
1772
1574
|
if (targetCartItem.holder_id) {
|
|
1773
1575
|
selectedResources = getOthersSelectedResources(cartItems, targetCartItem.holder_id, resourcesMap);
|
|
1774
1576
|
} else {
|
|
1775
1577
|
selectedResources = getOthersCartSelectedResources(cartItems, targetCartItem._id, resourcesMap);
|
|
1776
1578
|
}
|
|
1777
|
-
var productResources = getResourcesByProduct(resourcesMap, ((_targetCartItem$
|
|
1579
|
+
var productResources = getResourcesByProduct(resourcesMap, ((_targetCartItem$_prod = targetCartItem._productOrigin) === null || _targetCartItem$_prod === void 0 || (_targetCartItem$_prod = _targetCartItem$_prod.product_resource) === null || _targetCartItem$_prod === void 0 ? void 0 : _targetCartItem$_prod.resources) || [], selectedResources, currentCapacity);
|
|
1778
1580
|
productResources.forEach(function (item) {
|
|
1779
1581
|
item.renderList = item.renderList.filter(function (n) {
|
|
1780
1582
|
var recordCount = n.capacity || 0;
|
|
@@ -1796,36 +1598,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1796
1598
|
}
|
|
1797
1599
|
}
|
|
1798
1600
|
|
|
1799
|
-
// 通过资源列表和指定的资源 id,获取指定资源的时间切片
|
|
1800
|
-
}, {
|
|
1801
|
-
key: "getResourceTimeSlot",
|
|
1802
|
-
value: function getResourceTimeSlot(_ref7) {
|
|
1803
|
-
var product = _ref7.product,
|
|
1804
|
-
resources = _ref7.resources,
|
|
1805
|
-
currentResourceId = _ref7.currentResourceId;
|
|
1806
|
-
var dateRange = this.store.date.getDateRange();
|
|
1807
|
-
var timeSlots = getTimeSlicesByResource({
|
|
1808
|
-
resource: resources.find(function (n) {
|
|
1809
|
-
return n.id === currentResourceId;
|
|
1810
|
-
}),
|
|
1811
|
-
duration: product.duration.value,
|
|
1812
|
-
split: 10,
|
|
1813
|
-
currentDate: dateRange[0].date
|
|
1814
|
-
});
|
|
1815
|
-
return timeSlots;
|
|
1816
|
-
}
|
|
1817
|
-
|
|
1818
1601
|
// 自动分派可用资源-pro 版,ui 传递某个账号,自动给某个账号下所有商品分配第一种资源
|
|
1819
1602
|
}, {
|
|
1820
1603
|
key: "autoSelectAccountResources",
|
|
1821
|
-
value: function autoSelectAccountResources(
|
|
1822
|
-
var _cartItem$
|
|
1823
|
-
var cartItem =
|
|
1824
|
-
holder_id =
|
|
1825
|
-
resources_code =
|
|
1826
|
-
timeSlots =
|
|
1827
|
-
countMap =
|
|
1828
|
-
capacity =
|
|
1604
|
+
value: function autoSelectAccountResources(_ref9) {
|
|
1605
|
+
var _cartItem$_productOri6, _allProductResources$;
|
|
1606
|
+
var cartItem = _ref9.cartItem,
|
|
1607
|
+
holder_id = _ref9.holder_id,
|
|
1608
|
+
resources_code = _ref9.resources_code,
|
|
1609
|
+
timeSlots = _ref9.timeSlots,
|
|
1610
|
+
countMap = _ref9.countMap,
|
|
1611
|
+
capacity = _ref9.capacity;
|
|
1829
1612
|
if (isNormalProduct(cartItem._productOrigin)) {
|
|
1830
1613
|
return {};
|
|
1831
1614
|
}
|
|
@@ -1839,10 +1622,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1839
1622
|
if (!accountCartItems.length) {
|
|
1840
1623
|
accountCartItems = cartItems;
|
|
1841
1624
|
}
|
|
1842
|
-
// duration
|
|
1625
|
+
// duration=所有商品时间的集合,如果是灵活时长,当做占用 10 分钟处理
|
|
1843
1626
|
var duration = accountCartItems.reduce(function (acc, n) {
|
|
1844
|
-
var _n$
|
|
1845
|
-
return acc + (((_n$
|
|
1627
|
+
var _n$_productOrigin;
|
|
1628
|
+
return acc + (((_n$_productOrigin = n._productOrigin) === null || _n$_productOrigin === void 0 || (_n$_productOrigin = _n$_productOrigin.duration) === null || _n$_productOrigin === void 0 ? void 0 : _n$_productOrigin.value) || 10);
|
|
1846
1629
|
}, 0);
|
|
1847
1630
|
var AllResources = [];
|
|
1848
1631
|
if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
|
|
@@ -1860,15 +1643,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1860
1643
|
var resourcesMap = getResourcesMap(cloneDeep(AllResources));
|
|
1861
1644
|
var allCartItems = cloneDeep(this.store.cart.getItems());
|
|
1862
1645
|
var selectedResources = getOthersSelectedResources(allCartItems, holder_id, resourcesMap);
|
|
1863
|
-
var allProductResources = getResourcesByProduct(resourcesMap, ((_cartItem$
|
|
1646
|
+
var allProductResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri6 = cartItem._productOrigin) === null || _cartItem$_productOri6 === void 0 || (_cartItem$_productOri6 = _cartItem$_productOri6.product_resource) === null || _cartItem$_productOri6 === void 0 ? void 0 : _cartItem$_productOri6.resources) || [], selectedResources, 1);
|
|
1864
1647
|
var resources = ((_allProductResources$ = allProductResources.find(function (n) {
|
|
1865
1648
|
return n.code === resources_code;
|
|
1866
1649
|
})) === null || _allProductResources$ === void 0 ? void 0 : _allProductResources$.renderList) || [];
|
|
1867
1650
|
// 资源排下序,把单个资源靠前,组合资源排在后面
|
|
1868
1651
|
resources.sort(function (a, b) {
|
|
1869
|
-
var _a$
|
|
1870
|
-
var aIsCombined = ((_a$
|
|
1871
|
-
var bIsCombined = ((_b$
|
|
1652
|
+
var _a$metadata, _b$metadata;
|
|
1653
|
+
var aIsCombined = ((_a$metadata = a.metadata) === null || _a$metadata === void 0 || (_a$metadata = _a$metadata.combined_resource) === null || _a$metadata === void 0 ? void 0 : _a$metadata.status) === 1;
|
|
1654
|
+
var bIsCombined = ((_b$metadata = b.metadata) === null || _b$metadata === void 0 || (_b$metadata = _b$metadata.combined_resource) === null || _b$metadata === void 0 ? void 0 : _b$metadata.status) === 1;
|
|
1872
1655
|
if (aIsCombined && !bIsCombined) return 1;
|
|
1873
1656
|
if (!aIsCombined && bIsCombined) return -1;
|
|
1874
1657
|
return 0;
|
|
@@ -1889,11 +1672,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1889
1672
|
// 根据 start_time 和 end_time 去匹配资源
|
|
1890
1673
|
var targetResource = null;
|
|
1891
1674
|
var targetResourceTime = 0;
|
|
1892
|
-
var
|
|
1893
|
-
|
|
1675
|
+
var _iterator2 = _createForOfIteratorHelper(resources),
|
|
1676
|
+
_step2;
|
|
1894
1677
|
try {
|
|
1895
|
-
var
|
|
1896
|
-
var n =
|
|
1678
|
+
var _loop = function _loop() {
|
|
1679
|
+
var n = _step2.value;
|
|
1897
1680
|
// 如果资源是独占的,并且 countMap 里选择过这个资源,则直接跳过
|
|
1898
1681
|
// if (n.resourceType === 'single' && countMap[n.id]) {
|
|
1899
1682
|
// resourcesUseableMap[n.id] = false;
|
|
@@ -1921,14 +1704,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1921
1704
|
return 0; // continue
|
|
1922
1705
|
}
|
|
1923
1706
|
var canUseTime = mTimes.find(function (item) {
|
|
1924
|
-
var _cartItem$
|
|
1707
|
+
var _cartItem$_productOri7;
|
|
1925
1708
|
var res = getIsUsableByTimeItem({
|
|
1926
1709
|
timeSlice: timeSlots,
|
|
1927
1710
|
time: item,
|
|
1928
1711
|
resource: n,
|
|
1929
1712
|
currentCount: totalCapacity + (capacity || 0),
|
|
1930
1713
|
resourcesUseableMap: resourcesUseableMap,
|
|
1931
|
-
cut_off_time: (_cartItem$
|
|
1714
|
+
cut_off_time: (_cartItem$_productOri7 = cartItem._productOrigin) === null || _cartItem$_productOri7 === void 0 ? void 0 : _cartItem$_productOri7.cut_off_time
|
|
1932
1715
|
});
|
|
1933
1716
|
// 如果只是因为子资源容量不够,而不是子资源被预约导致没时间片,不应该标记子资源为不可用,从而影响组合资源的情况
|
|
1934
1717
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[n.id]) !== false && res.reason !== 'capacityOnly') {
|
|
@@ -1948,15 +1731,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1948
1731
|
}
|
|
1949
1732
|
},
|
|
1950
1733
|
_ret;
|
|
1951
|
-
for (
|
|
1952
|
-
_ret =
|
|
1734
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
1735
|
+
_ret = _loop();
|
|
1953
1736
|
if (_ret === 0) continue;
|
|
1954
1737
|
if (_ret === 1) break;
|
|
1955
1738
|
}
|
|
1956
1739
|
} catch (err) {
|
|
1957
|
-
|
|
1740
|
+
_iterator2.e(err);
|
|
1958
1741
|
} finally {
|
|
1959
|
-
|
|
1742
|
+
_iterator2.f();
|
|
1960
1743
|
}
|
|
1961
1744
|
return {
|
|
1962
1745
|
selectedResource: targetResource
|
|
@@ -1991,7 +1774,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1991
1774
|
key: "autoSelectAllProductResources",
|
|
1992
1775
|
value: function autoSelectAllProductResources(resources_code, timeSlots) {
|
|
1993
1776
|
var _dateRange$4,
|
|
1994
|
-
|
|
1777
|
+
_this11 = this;
|
|
1995
1778
|
var dateRange = this.store.date.getDateRange();
|
|
1996
1779
|
var resources = [];
|
|
1997
1780
|
if (dateRange !== null && dateRange !== void 0 && (_dateRange$4 = dateRange[0]) !== null && _dateRange$4 !== void 0 && _dateRange$4.date) {
|
|
@@ -1999,10 +1782,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1999
1782
|
if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
|
|
2000
1783
|
});
|
|
2001
1784
|
}
|
|
2002
|
-
// const resourcesMap = getResourcesMap(cloneDeep(resources));
|
|
2003
1785
|
// 一个账号一个账号处理
|
|
2004
1786
|
var errorList = [];
|
|
1787
|
+
// 资源使用情况-单个预约
|
|
2005
1788
|
var selectResourcesMap = {};
|
|
1789
|
+
// 资源使用情况-多个预约
|
|
2006
1790
|
var selectResourcesWithTimeSlots = {};
|
|
2007
1791
|
var accountList = this.store.accountList.getAccounts();
|
|
2008
1792
|
var selectForCartResources = function selectForCartResources(cartItems) {
|
|
@@ -2012,18 +1796,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2012
1796
|
// 第一个商品分配完以后,第二个商品分配的start_time应该是第一个商品的 end_time ,然后 end_time 应该是 start_time+duration
|
|
2013
1797
|
// 判断购物车里是否有 flexible 类型的商品,如果有则不累加时间
|
|
2014
1798
|
var hasFlexibleProduct = cartItems.some(function (item) {
|
|
2015
|
-
var _item$
|
|
2016
|
-
return ((_item$
|
|
1799
|
+
var _item$_productOrigin;
|
|
1800
|
+
return ((_item$_productOrigin = item._productOrigin) === null || _item$_productOrigin === void 0 || (_item$_productOrigin = _item$_productOrigin.duration) === null || _item$_productOrigin === void 0 ? void 0 : _item$_productOrigin.type) === 'flexible';
|
|
2017
1801
|
});
|
|
2018
1802
|
cartItems.forEach(function (item, index) {
|
|
2019
|
-
var
|
|
2020
|
-
|
|
2021
|
-
capacity: (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.capacity,
|
|
2022
|
-
product_bundle: item._origin.product.product_bundle
|
|
2023
|
-
});
|
|
2024
|
-
var currentCapacity = getSumCapacity({
|
|
2025
|
-
capacity: formatCapacity
|
|
2026
|
-
});
|
|
1803
|
+
var _getCapacityInfoByCar6 = getCapacityInfoByCartItem(item),
|
|
1804
|
+
currentCapacity = _getCapacityInfoByCar6.currentCapacity;
|
|
2027
1805
|
// 如果商品已经有时间数据了,意味着是通过先选日期再选商品流程进来的,相当于时间切片已经选中了
|
|
2028
1806
|
if (item._origin.start_time && !(timeSlots !== null && timeSlots !== void 0 && timeSlots.start_time)) {
|
|
2029
1807
|
recordTimeSlots = {
|
|
@@ -2034,18 +1812,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2034
1812
|
};
|
|
2035
1813
|
}
|
|
2036
1814
|
if (recordTimeSlots) {
|
|
2037
|
-
var _item$
|
|
1815
|
+
var _item$_productOrigin2, _item$_productOrigin3;
|
|
2038
1816
|
// 同一账号下,如果当前商品不是第一个,则需要根据上一个商品的 end_time 和 duration 计算出当前商品的 start_time 和 end_time
|
|
2039
1817
|
// 前提:当前资源是单个预约才需要这么做
|
|
2040
|
-
var currentResourceConfig = (_item$
|
|
1818
|
+
var currentResourceConfig = (_item$_productOrigin2 = item._productOrigin) === null || _item$_productOrigin2 === void 0 || (_item$_productOrigin2 = _item$_productOrigin2.product_resource) === null || _item$_productOrigin2 === void 0 || (_item$_productOrigin2 = _item$_productOrigin2.resources) === null || _item$_productOrigin2 === void 0 ? void 0 : _item$_productOrigin2.find(function (n) {
|
|
2041
1819
|
return n.code === resources_code;
|
|
2042
1820
|
});
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
var _item$
|
|
2047
|
-
var
|
|
2048
|
-
var end_at = start_at.add(((_item$_productOrigin8 = item._productOrigin) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.duration) === null || _item$_productOrigin8 === void 0 ? void 0 : _item$_productOrigin8.value) || 10, 'minutes');
|
|
1821
|
+
// 只有 duration 类商品且不含有灵活时间的商品需要这个操作
|
|
1822
|
+
if (index !== 0 && recordTimeSlots && (currentResourceConfig === null || currentResourceConfig === void 0 ? void 0 : currentResourceConfig.type) === 'single' && (_item$_productOrigin3 = item._productOrigin) !== null && _item$_productOrigin3 !== void 0 && _item$_productOrigin3.duration && !hasFlexibleProduct) {
|
|
1823
|
+
var _item$_productOrigin4, _item$_productOrigin5;
|
|
1824
|
+
var start_at = dayjs(recordTimeSlots.end_time).add(((_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.duration) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.value) || 10, 'minutes');
|
|
1825
|
+
var end_at = start_at.add(((_item$_productOrigin5 = item._productOrigin) === null || _item$_productOrigin5 === void 0 || (_item$_productOrigin5 = _item$_productOrigin5.duration) === null || _item$_productOrigin5 === void 0 ? void 0 : _item$_productOrigin5.value) || 10, 'minutes');
|
|
2049
1826
|
recordTimeSlots = {
|
|
2050
1827
|
start_time: start_at.format('HH:mm'),
|
|
2051
1828
|
end_time: end_at.format('HH:mm'),
|
|
@@ -2054,7 +1831,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2054
1831
|
};
|
|
2055
1832
|
}
|
|
2056
1833
|
// 如果传递了 timeSlots,代表是第二种资源,则直接拿 timeSlots 去匹配
|
|
2057
|
-
var res =
|
|
1834
|
+
var res = _this11.autoSelectAccountResources({
|
|
2058
1835
|
cartItem: item,
|
|
2059
1836
|
holder_id: item.holder_id,
|
|
2060
1837
|
resources_code: resources_code,
|
|
@@ -2062,10 +1839,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2062
1839
|
countMap: selectResourcesWithTimeSlots,
|
|
2063
1840
|
capacity: currentCapacity
|
|
2064
1841
|
});
|
|
2065
|
-
// // 如果购物车里已经有同类型的 form_id 的资源了,则不处理
|
|
2066
|
-
// if (item._origin.resources?.some((n: any) => n.form_id === res?.selectedResource?.form_id)) {
|
|
2067
|
-
// return
|
|
2068
|
-
// }
|
|
2069
1842
|
if (res !== null && res !== void 0 && res.selectedResource) {
|
|
2070
1843
|
if (!selectResourcesWithTimeSlots[res.selectedResource.id]) {
|
|
2071
1844
|
selectResourcesWithTimeSlots[res.selectedResource.id] = [{
|
|
@@ -2080,7 +1853,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2080
1853
|
}
|
|
2081
1854
|
res.selectedResource.capacity = currentCapacity;
|
|
2082
1855
|
checkSubResourcesCapacity(res.selectedResource);
|
|
2083
|
-
|
|
1856
|
+
_this11.store.cart.updateItem({
|
|
2084
1857
|
_id: item._id,
|
|
2085
1858
|
// 这里要做去重,避免出现同样类型的资源被塞进同一个商品
|
|
2086
1859
|
resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
|
|
@@ -2093,12 +1866,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2093
1866
|
errorList.push(item._id);
|
|
2094
1867
|
}
|
|
2095
1868
|
} else {
|
|
2096
|
-
var _item$
|
|
1869
|
+
var _item$_productOrigin6, _productResources$fin;
|
|
2097
1870
|
// 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
|
|
2098
|
-
|
|
1871
|
+
// 能进到这种逻辑,说明是 duration 类商品或者灵活时长商品,且是第一种资源,还没有确定时间
|
|
1872
|
+
var allCartItems = cloneDeep(_this11.store.cart.getItems());
|
|
2099
1873
|
// 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
|
|
2100
1874
|
var selectedResources = [];
|
|
2101
|
-
var _resources = cloneDeep(((_item$
|
|
1875
|
+
var _resources = cloneDeep(((_item$_productOrigin6 = item._productOrigin) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.product_resource) === null || _item$_productOrigin6 === void 0 ? void 0 : _item$_productOrigin6.resources) || []);
|
|
2102
1876
|
var currentResourcesRenderList = [];
|
|
2103
1877
|
_resources.forEach(function (n) {
|
|
2104
1878
|
var _n$renderList;
|
|
@@ -2159,7 +1933,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2159
1933
|
} else {
|
|
2160
1934
|
selectResourcesMap[targetResource.id] += currentCapacity;
|
|
2161
1935
|
}
|
|
2162
|
-
|
|
1936
|
+
_this11.store.cart.updateItem({
|
|
2163
1937
|
_id: item._id,
|
|
2164
1938
|
resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
|
|
2165
1939
|
return existingRes.resourceType !== targetRenderList[0].resourceType;
|
|
@@ -2179,7 +1953,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2179
1953
|
// 如果购物车里没有 holderid数据,证明不按 holder 类流程预约走,给所有购物车一次性分派即可,不做账号下资源互斥逻辑
|
|
2180
1954
|
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
2181
1955
|
accountList.forEach(function (account) {
|
|
2182
|
-
var cartItems =
|
|
1956
|
+
var cartItems = _this11.store.cart.getCartByAccount(account.getId());
|
|
2183
1957
|
selectForCartResources(cartItems);
|
|
2184
1958
|
});
|
|
2185
1959
|
} else {
|
|
@@ -2194,7 +1968,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2194
1968
|
key: "getTimeSlotByAllResources",
|
|
2195
1969
|
value: function getTimeSlotByAllResources(resources_code) {
|
|
2196
1970
|
var _dateRange,
|
|
2197
|
-
|
|
1971
|
+
_this12 = this,
|
|
2198
1972
|
_cartItems$,
|
|
2199
1973
|
_cartItems$2,
|
|
2200
1974
|
_this$shopStore$get;
|
|
@@ -2213,8 +1987,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2213
1987
|
var maxCutOffTime = undefined;
|
|
2214
1988
|
var maxCutOffTimeValue = dayjs();
|
|
2215
1989
|
cartItems.forEach(function (item) {
|
|
2216
|
-
var _item$
|
|
2217
|
-
(_item$
|
|
1990
|
+
var _item$_productOrigin7, _item$_productOrigin8, _item$_productOrigin9, _item$_productOrigin10;
|
|
1991
|
+
(_item$_productOrigin7 = item._productOrigin) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.product_resource) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.resources) === null || _item$_productOrigin7 === void 0 || _item$_productOrigin7.forEach(function (n) {
|
|
2218
1992
|
// TODO: 少了个 status 的判断
|
|
2219
1993
|
if (n.code === resources_code) {
|
|
2220
1994
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
@@ -2227,10 +2001,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2227
2001
|
if (item.resource_id) {
|
|
2228
2002
|
resourceIds.push(item.resource_id);
|
|
2229
2003
|
}
|
|
2230
|
-
resourcesTypeId = item === null || item === void 0 || (_item$
|
|
2004
|
+
resourcesTypeId = item === null || item === void 0 || (_item$_productOrigin8 = item._productOrigin) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.product_resource) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.resources) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.find(function (n) {
|
|
2231
2005
|
return n.code === resources_code;
|
|
2232
|
-
})) === null || _item$
|
|
2233
|
-
if ((_item$
|
|
2006
|
+
})) === null || _item$_productOrigin8 === void 0 ? void 0 : _item$_productOrigin8.id;
|
|
2007
|
+
if ((_item$_productOrigin9 = item._productOrigin) !== null && _item$_productOrigin9 !== void 0 && _item$_productOrigin9.cut_off_time && ((_item$_productOrigin10 = item._productOrigin) === null || _item$_productOrigin10 === void 0 ? void 0 : _item$_productOrigin10.cut_off_time.type) === 'advance') {
|
|
2234
2008
|
var currentCutOffTime = dayjs().add(item._productOrigin.cut_off_time.unit, item._productOrigin.cut_off_time.unit_type);
|
|
2235
2009
|
if (currentCutOffTime.isAfter(maxCutOffTimeValue, 'minute')) {
|
|
2236
2010
|
maxCutOffTimeValue = currentCutOffTime;
|
|
@@ -2258,13 +2032,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2258
2032
|
cartItems.forEach(function (item) {
|
|
2259
2033
|
// 单个预约累加账号 多个预约取最大值
|
|
2260
2034
|
if (isSingleResource) {
|
|
2261
|
-
var _item$
|
|
2262
|
-
accountDuration += ((_item$
|
|
2035
|
+
var _item$_productOrigin11;
|
|
2036
|
+
accountDuration += ((_item$_productOrigin11 = item._productOrigin) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.duration) === null || _item$_productOrigin11 === void 0 ? void 0 : _item$_productOrigin11.value) || 10;
|
|
2263
2037
|
} else {
|
|
2264
|
-
var _item$
|
|
2265
|
-
if (accountDuration < (((_item$
|
|
2266
|
-
var _item$
|
|
2267
|
-
accountDuration = ((_item$
|
|
2038
|
+
var _item$_productOrigin12;
|
|
2039
|
+
if (accountDuration < (((_item$_productOrigin12 = item._productOrigin) === null || _item$_productOrigin12 === void 0 || (_item$_productOrigin12 = _item$_productOrigin12.duration) === null || _item$_productOrigin12 === void 0 ? void 0 : _item$_productOrigin12.value) || 10)) {
|
|
2040
|
+
var _item$_productOrigin13;
|
|
2041
|
+
accountDuration = ((_item$_productOrigin13 = item._productOrigin) === null || _item$_productOrigin13 === void 0 || (_item$_productOrigin13 = _item$_productOrigin13.duration) === null || _item$_productOrigin13 === void 0 ? void 0 : _item$_productOrigin13.value) || 10;
|
|
2268
2042
|
}
|
|
2269
2043
|
}
|
|
2270
2044
|
});
|
|
@@ -2274,7 +2048,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2274
2048
|
};
|
|
2275
2049
|
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
2276
2050
|
accountList.forEach(function (account) {
|
|
2277
|
-
var cartItems =
|
|
2051
|
+
var cartItems = _this12.store.cart.getCartByAccount(account.getId());
|
|
2278
2052
|
checkDuration(cartItems);
|
|
2279
2053
|
});
|
|
2280
2054
|
} else {
|
|
@@ -2301,8 +2075,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2301
2075
|
}
|
|
2302
2076
|
var resourcesUseableMap = {};
|
|
2303
2077
|
var hasFlexibleDuration = cartItems.some(function (item) {
|
|
2304
|
-
var _item$
|
|
2305
|
-
return ((_item$
|
|
2078
|
+
var _item$_productOrigin14;
|
|
2079
|
+
return ((_item$_productOrigin14 = item._productOrigin) === null || _item$_productOrigin14 === void 0 || (_item$_productOrigin14 = _item$_productOrigin14.duration) === null || _item$_productOrigin14 === void 0 ? void 0 : _item$_productOrigin14.type) === 'flexible';
|
|
2306
2080
|
});
|
|
2307
2081
|
var operating_day_boundary = (_this$shopStore$get = this.shopStore.get('core')) === null || _this$shopStore$get === void 0 || (_this$shopStore$get = _this$shopStore$get.core) === null || _this$shopStore$get === void 0 ? void 0 : _this$shopStore$get.operating_day_boundary;
|
|
2308
2082
|
var timeSlots = getTimeSlicesByResources({
|
|
@@ -2324,7 +2098,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2324
2098
|
key: "submitTimeSlot",
|
|
2325
2099
|
value: function submitTimeSlot(timeSlots) {
|
|
2326
2100
|
var _this$shopStore$get2,
|
|
2327
|
-
|
|
2101
|
+
_this13 = this;
|
|
2328
2102
|
// 以账号为维度处理数据。购物车里每一项的 startTime应该是前一个商品的 endTime,如果是第一个商品则用 timeSlots.start_at
|
|
2329
2103
|
var cartItems = this.store.cart.getItems().filter(function (n) {
|
|
2330
2104
|
return !isNormalProduct(n._productOrigin);
|
|
@@ -2353,9 +2127,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2353
2127
|
var _newResources$;
|
|
2354
2128
|
var newResources = cloneDeep(item._origin.resources);
|
|
2355
2129
|
newResources.forEach(function (resource) {
|
|
2356
|
-
var _item$
|
|
2130
|
+
var _item$_productOrigin15;
|
|
2357
2131
|
// 如果商品配置的是灵活时长,开始时间设置为提交的时间,结束时间从资源的可用最晚时间和店铺营业结束时间里取一个最早的
|
|
2358
|
-
if (((_item$
|
|
2132
|
+
if (((_item$_productOrigin15 = item._productOrigin) === null || _item$_productOrigin15 === void 0 || (_item$_productOrigin15 = _item$_productOrigin15.duration) === null || _item$_productOrigin15 === void 0 ? void 0 : _item$_productOrigin15.type) === 'flexible') {
|
|
2359
2133
|
var _allResources$find;
|
|
2360
2134
|
item.duration = {
|
|
2361
2135
|
type: 'minutes',
|
|
@@ -2372,7 +2146,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2372
2146
|
|
|
2373
2147
|
// 将 operating_day_boundary 转换为与 resourcesEndTime.end_at 相同日期的完整日期时间
|
|
2374
2148
|
var resourceDate = dayjs(resourcesEndTime.end_at).format('YYYY-MM-DD');
|
|
2375
|
-
var operatingBoundaryDateTime = "".concat(resourceDate, " ").concat(operating_day_boundary.type === 'start_time' ?
|
|
2149
|
+
var operatingBoundaryDateTime = "".concat(resourceDate, " ").concat(operating_day_boundary.type === 'start_time' ? '23:59' : operating_day_boundary.time);
|
|
2376
2150
|
var endTime = dayjs(resourcesEndTime.end_at).isBefore(dayjs(operatingBoundaryDateTime)) ? resourcesEndTime.end_at : operatingBoundaryDateTime;
|
|
2377
2151
|
// 修复:如果 endTime 只是时间格式(如 "17:00"),需要加上日期
|
|
2378
2152
|
var formattedEndTime;
|
|
@@ -2385,13 +2159,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2385
2159
|
}
|
|
2386
2160
|
resource.endTime = formattedEndTime.format('YYYY-MM-DD HH:mm');
|
|
2387
2161
|
} else {
|
|
2388
|
-
var _item$
|
|
2162
|
+
var _item$_productOrigin16;
|
|
2389
2163
|
resource.startTime = currentStartTime;
|
|
2390
|
-
resource.endTime = dayjs(currentStartTime).add(((_item$
|
|
2164
|
+
resource.endTime = dayjs(currentStartTime).add(((_item$_productOrigin16 = item._productOrigin) === null || _item$_productOrigin16 === void 0 || (_item$_productOrigin16 = _item$_productOrigin16.duration) === null || _item$_productOrigin16 === void 0 ? void 0 : _item$_productOrigin16.value) || 10, 'minutes').format('YYYY-MM-DD HH:mm');
|
|
2391
2165
|
}
|
|
2392
2166
|
// delete resource.times;
|
|
2393
2167
|
});
|
|
2394
|
-
|
|
2168
|
+
_this13.store.cart.updateItem({
|
|
2395
2169
|
_id: item._id,
|
|
2396
2170
|
resources: newResources
|
|
2397
2171
|
});
|
|
@@ -2439,26 +2213,59 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2439
2213
|
}, {
|
|
2440
2214
|
key: "openProductDetail",
|
|
2441
2215
|
value: function () {
|
|
2442
|
-
var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2443
|
-
var targetProduct, targetProductData, newScheduleArr;
|
|
2444
|
-
return _regeneratorRuntime().wrap(function
|
|
2445
|
-
while (1) switch (
|
|
2216
|
+
var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(productId) {
|
|
2217
|
+
var targetProduct, targetProductData, newScheduleArr, dateRange;
|
|
2218
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
2219
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2446
2220
|
case 0:
|
|
2447
|
-
|
|
2221
|
+
_context25.next = 2;
|
|
2448
2222
|
return this.store.products.getProduct(productId);
|
|
2449
2223
|
case 2:
|
|
2450
|
-
targetProduct =
|
|
2451
|
-
if (targetProduct) {
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
newScheduleArr = this.getScheduleDataByIds(targetProductData['schedule.ids']);
|
|
2455
|
-
targetProduct.setOtherParams('schedule', newScheduleArr);
|
|
2224
|
+
targetProduct = _context25.sent;
|
|
2225
|
+
if (!targetProduct) {
|
|
2226
|
+
_context25.next = 16;
|
|
2227
|
+
break;
|
|
2456
2228
|
}
|
|
2457
|
-
|
|
2229
|
+
targetProductData = targetProduct.getData();
|
|
2230
|
+
this.store.currentProduct = targetProduct;
|
|
2231
|
+
// 资源预加载,如果是 duration 类型的商品,且是先选日期的流程,在这里预拉取资源数据
|
|
2232
|
+
if (!targetProductData['schedule.ids']) {
|
|
2233
|
+
_context25.next = 11;
|
|
2234
|
+
break;
|
|
2235
|
+
}
|
|
2236
|
+
newScheduleArr = this.getScheduleDataByIds(targetProductData['schedule.ids']);
|
|
2237
|
+
targetProduct.setOtherParams('schedule', newScheduleArr);
|
|
2238
|
+
_context25.next = 16;
|
|
2239
|
+
break;
|
|
2240
|
+
case 11:
|
|
2241
|
+
if (!targetProductData.duration) {
|
|
2242
|
+
_context25.next = 16;
|
|
2243
|
+
break;
|
|
2244
|
+
}
|
|
2245
|
+
dateRange = this.store.date.getDateRange(); // 如果不是先选日期的流程 duration 商品就啥也不做
|
|
2246
|
+
if (dateRange.length) {
|
|
2247
|
+
_context25.next = 15;
|
|
2248
|
+
break;
|
|
2249
|
+
}
|
|
2250
|
+
return _context25.abrupt("return");
|
|
2251
|
+
case 15:
|
|
2252
|
+
// this.store.date.getResourceDates({
|
|
2253
|
+
// query: {
|
|
2254
|
+
// start_date: dateRange[0].date,
|
|
2255
|
+
// end_date: dateRange[dateRange.length - 1].date,
|
|
2256
|
+
// resource_ids: targetProductData.product_resource?.resources?.map((n: any) => n.id),
|
|
2257
|
+
// },
|
|
2258
|
+
// });
|
|
2259
|
+
this.getAvailableDate({
|
|
2260
|
+
startDate: dateRange[0].date,
|
|
2261
|
+
endDate: dateRange[dateRange.length - 1].date,
|
|
2262
|
+
products: [targetProductData]
|
|
2263
|
+
});
|
|
2264
|
+
case 16:
|
|
2458
2265
|
case "end":
|
|
2459
|
-
return
|
|
2266
|
+
return _context25.stop();
|
|
2460
2267
|
}
|
|
2461
|
-
},
|
|
2268
|
+
}, _callee25, this);
|
|
2462
2269
|
}));
|
|
2463
2270
|
function openProductDetail(_x19) {
|
|
2464
2271
|
return _openProductDetail.apply(this, arguments);
|
|
@@ -2474,12 +2281,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2474
2281
|
}
|
|
2475
2282
|
}, {
|
|
2476
2283
|
key: "getTimeslotBySchedule",
|
|
2477
|
-
value: function getTimeslotBySchedule(
|
|
2284
|
+
value: function getTimeslotBySchedule(_ref10) {
|
|
2478
2285
|
var _this$store$currentPr2, _targetProductData$pr;
|
|
2479
|
-
var date =
|
|
2480
|
-
scheduleIds =
|
|
2481
|
-
resources =
|
|
2482
|
-
product =
|
|
2286
|
+
var date = _ref10.date,
|
|
2287
|
+
scheduleIds = _ref10.scheduleIds,
|
|
2288
|
+
resources = _ref10.resources,
|
|
2289
|
+
product = _ref10.product;
|
|
2483
2290
|
var targetProduct = this.store.currentProduct;
|
|
2484
2291
|
// 如果外面传递了product 优先用外面的
|
|
2485
2292
|
var targetProductData = product || (targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.getData());
|
|
@@ -2506,9 +2313,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2506
2313
|
});
|
|
2507
2314
|
// 资源排下序,把单个资源靠前,组合资源排在后面
|
|
2508
2315
|
allProductResources.sort(function (a, b) {
|
|
2509
|
-
var _a$
|
|
2510
|
-
var aIsCombined = ((_a$
|
|
2511
|
-
var bIsCombined = ((_b$
|
|
2316
|
+
var _a$metadata2, _b$metadata2;
|
|
2317
|
+
var aIsCombined = ((_a$metadata2 = a.metadata) === null || _a$metadata2 === void 0 || (_a$metadata2 = _a$metadata2.combined_resource) === null || _a$metadata2 === void 0 ? void 0 : _a$metadata2.status) === 1;
|
|
2318
|
+
var bIsCombined = ((_b$metadata2 = b.metadata) === null || _b$metadata2 === void 0 || (_b$metadata2 = _b$metadata2.combined_resource) === null || _b$metadata2 === void 0 ? void 0 : _b$metadata2.status) === 1;
|
|
2512
2319
|
if (aIsCombined && !bIsCombined) return 1;
|
|
2513
2320
|
if (!aIsCombined && bIsCombined) return -1;
|
|
2514
2321
|
return 0;
|
|
@@ -2571,9 +2378,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2571
2378
|
// 在已经选定时间的情况下,只要canUseTime如果有一个 false 那就不可用
|
|
2572
2379
|
if (!currentResourcesTimeSlotCanUsedArr.some(function (n) {
|
|
2573
2380
|
return n === false;
|
|
2574
|
-
})
|
|
2381
|
+
}) &&
|
|
2575
2382
|
// 只统计第一种资源的容量和 left
|
|
2576
|
-
|
|
2383
|
+
m.form_id === firstEnabledResourceId) {
|
|
2577
2384
|
if (currentResourcesCount >= count) {
|
|
2578
2385
|
count = currentResourcesCount;
|
|
2579
2386
|
}
|
|
@@ -2595,75 +2402,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2595
2402
|
});
|
|
2596
2403
|
return formatScheduleTimeSlots;
|
|
2597
2404
|
}
|
|
2598
|
-
}, {
|
|
2599
|
-
key: "addProductToCart",
|
|
2600
|
-
value: function addProductToCart(_ref10) {
|
|
2601
|
-
var _this13 = this;
|
|
2602
|
-
var product = _ref10.product,
|
|
2603
|
-
date = _ref10.date,
|
|
2604
|
-
account = _ref10.account;
|
|
2605
|
-
var _ref11 = product || {},
|
|
2606
|
-
bundle = _ref11.bundle,
|
|
2607
|
-
options = _ref11.options,
|
|
2608
|
-
origin = _ref11.origin,
|
|
2609
|
-
product_variant_id = _ref11.product_variant_id,
|
|
2610
|
-
rowKey = _ref11.rowKey,
|
|
2611
|
-
_ref11$quantity = _ref11.quantity,
|
|
2612
|
-
quantity = _ref11$quantity === void 0 ? 1 : _ref11$quantity;
|
|
2613
|
-
var productData = _objectSpread(_objectSpread({}, origin), {}, {
|
|
2614
|
-
product_variant_id: product_variant_id,
|
|
2615
|
-
rowKey: rowKey
|
|
2616
|
-
});
|
|
2617
|
-
if (!account) {
|
|
2618
|
-
var activeAccount = this.getActiveAccount();
|
|
2619
|
-
if (activeAccount) {
|
|
2620
|
-
account = activeAccount;
|
|
2621
|
-
}
|
|
2622
|
-
}
|
|
2623
|
-
if (rowKey) {
|
|
2624
|
-
var cartItems = this.store.cart.getItems();
|
|
2625
|
-
var targetCartItem = cartItems.find(function (n) {
|
|
2626
|
-
var _n$_productOrigin3;
|
|
2627
|
-
return ((_n$_productOrigin3 = n._productOrigin) === null || _n$_productOrigin3 === void 0 ? void 0 : _n$_productOrigin3.rowKey) === rowKey;
|
|
2628
|
-
});
|
|
2629
|
-
if (targetCartItem && isNormalProduct(targetCartItem._productOrigin)) {
|
|
2630
|
-
this.store.cart.updateItem({
|
|
2631
|
-
_id: targetCartItem._id,
|
|
2632
|
-
product: _objectSpread(_objectSpread({}, targetCartItem._productOrigin), {}, {
|
|
2633
|
-
quantity: (targetCartItem.num || 1) + quantity
|
|
2634
|
-
}),
|
|
2635
|
-
bundle: targetCartItem._bundleOrigin,
|
|
2636
|
-
options: targetCartItem._optionsOrigin,
|
|
2637
|
-
quantity: (targetCartItem.num || 1) + quantity
|
|
2638
|
-
});
|
|
2639
|
-
// 这里需要单独触发一个,购物车商品数量发生改变的 hook
|
|
2640
|
-
this.core.effects.emit("".concat(this.store.cart.name, ":onUpdateCartItemNums"), {});
|
|
2641
|
-
return;
|
|
2642
|
-
}
|
|
2643
|
-
}
|
|
2644
|
-
this.store.cart.addItem({
|
|
2645
|
-
product: productData,
|
|
2646
|
-
date: date,
|
|
2647
|
-
account: account,
|
|
2648
|
-
bundle: bundle,
|
|
2649
|
-
options: options,
|
|
2650
|
-
quantity: quantity
|
|
2651
|
-
});
|
|
2652
|
-
// 检测,有传递 date,检查购物车里其他商品的 date 是否在同一天,如果不在,清空那些不在同一天的商品
|
|
2653
|
-
if (date) {
|
|
2654
|
-
var _cartItems = this.store.cart.getItems().filter(function (n) {
|
|
2655
|
-
return !isNormalProduct(n._productOrigin);
|
|
2656
|
-
});
|
|
2657
|
-
var cartItemsByDate = _cartItems.filter(function (n) {
|
|
2658
|
-
return !dayjs(n.start_date).isSame(dayjs(date.startTime), 'day');
|
|
2659
|
-
});
|
|
2660
|
-
if (cartItemsByDate.length) {
|
|
2661
|
-
cartItemsByDate.forEach(function (n) {
|
|
2662
|
-
_this13.store.cart.removeItem(n._id);
|
|
2663
|
-
});
|
|
2664
|
-
}
|
|
2665
|
-
}
|
|
2666
|
-
}
|
|
2667
2405
|
}, {
|
|
2668
2406
|
key: "setOtherData",
|
|
2669
2407
|
value: function setOtherData(key, value) {
|
|
@@ -2685,27 +2423,27 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2685
2423
|
}, {
|
|
2686
2424
|
key: "getProductTypeById",
|
|
2687
2425
|
value: function () {
|
|
2688
|
-
var _getProductTypeById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2426
|
+
var _getProductTypeById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(id) {
|
|
2689
2427
|
var product;
|
|
2690
|
-
return _regeneratorRuntime().wrap(function
|
|
2691
|
-
while (1) switch (
|
|
2428
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
2429
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2692
2430
|
case 0:
|
|
2693
|
-
|
|
2431
|
+
_context26.next = 2;
|
|
2694
2432
|
return this.store.products.getProduct(id);
|
|
2695
2433
|
case 2:
|
|
2696
|
-
product =
|
|
2434
|
+
product = _context26.sent;
|
|
2697
2435
|
if (!product) {
|
|
2698
|
-
|
|
2436
|
+
_context26.next = 5;
|
|
2699
2437
|
break;
|
|
2700
2438
|
}
|
|
2701
|
-
return
|
|
2439
|
+
return _context26.abrupt("return", product.getProductType());
|
|
2702
2440
|
case 5:
|
|
2703
|
-
return
|
|
2441
|
+
return _context26.abrupt("return", 'normal');
|
|
2704
2442
|
case 6:
|
|
2705
2443
|
case "end":
|
|
2706
|
-
return
|
|
2444
|
+
return _context26.stop();
|
|
2707
2445
|
}
|
|
2708
|
-
},
|
|
2446
|
+
}, _callee26, this);
|
|
2709
2447
|
}));
|
|
2710
2448
|
function getProductTypeById(_x20) {
|
|
2711
2449
|
return _getProductTypeById.apply(this, arguments);
|
|
@@ -2723,7 +2461,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2723
2461
|
}, {
|
|
2724
2462
|
key: "getResourcesByCartItemAndCode",
|
|
2725
2463
|
value: function getResourcesByCartItemAndCode(cartItemId, resourceCode) {
|
|
2726
|
-
var _cartItem$
|
|
2464
|
+
var _cartItem$_productOri8;
|
|
2727
2465
|
var dateRange = this.store.date.getDateRange();
|
|
2728
2466
|
var resources = [];
|
|
2729
2467
|
if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
|
|
@@ -2746,20 +2484,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2746
2484
|
});
|
|
2747
2485
|
if (!cartItem) return [];
|
|
2748
2486
|
var selectedResources = [];
|
|
2749
|
-
var
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
});
|
|
2487
|
+
var _getCapacityInfoByCar7 = getCapacityInfoByCartItem(cartItem),
|
|
2488
|
+
currentCapacity = _getCapacityInfoByCar7.currentCapacity,
|
|
2489
|
+
formatCapacity = _getCapacityInfoByCar7.formatCapacity;
|
|
2753
2490
|
cartItem._origin.metadata.capacity = formatCapacity;
|
|
2754
|
-
var currentCapacity = getSumCapacity({
|
|
2755
|
-
capacity: formatCapacity
|
|
2756
|
-
});
|
|
2757
2491
|
if (cartItem.holder_id) {
|
|
2758
2492
|
selectedResources = getOthersSelectedResources(cartItems, cartItem.holder_id, resourcesMap);
|
|
2759
2493
|
} else {
|
|
2760
2494
|
selectedResources = getOthersCartSelectedResources(cartItems, cartItem._id, resourcesMap);
|
|
2761
2495
|
}
|
|
2762
|
-
var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$
|
|
2496
|
+
var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri8 = cartItem._productOrigin) === null || _cartItem$_productOri8 === void 0 || (_cartItem$_productOri8 = _cartItem$_productOri8.product_resource) === null || _cartItem$_productOri8 === void 0 ? void 0 : _cartItem$_productOri8.resources) || [], selectedResources, currentCapacity);
|
|
2763
2497
|
var targetResource = productResources.find(function (resource) {
|
|
2764
2498
|
return resource.code === resourceCode;
|
|
2765
2499
|
});
|
|
@@ -2769,9 +2503,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2769
2503
|
var endTime = dayjs("".concat(cartItem._origin.end_date, " ").concat(cartItem._origin.end_time));
|
|
2770
2504
|
var resourcesUseableMap = {};
|
|
2771
2505
|
targetResource.renderList = targetResource.renderList.sort(function (a, b) {
|
|
2772
|
-
var _a$
|
|
2773
|
-
var aIsCombined = ((_a$
|
|
2774
|
-
var bIsCombined = ((_b$
|
|
2506
|
+
var _a$metadata3, _b$metadata3;
|
|
2507
|
+
var aIsCombined = ((_a$metadata3 = a.metadata) === null || _a$metadata3 === void 0 || (_a$metadata3 = _a$metadata3.combined_resource) === null || _a$metadata3 === void 0 ? void 0 : _a$metadata3.status) === 1;
|
|
2508
|
+
var bIsCombined = ((_b$metadata3 = b.metadata) === null || _b$metadata3 === void 0 || (_b$metadata3 = _b$metadata3.combined_resource) === null || _b$metadata3 === void 0 ? void 0 : _b$metadata3.status) === 1;
|
|
2775
2509
|
if (aIsCombined && !bIsCombined) return 1;
|
|
2776
2510
|
if (!aIsCombined && bIsCombined) return -1;
|
|
2777
2511
|
return 0;
|
|
@@ -2782,7 +2516,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2782
2516
|
});
|
|
2783
2517
|
if (mTimes.length === 0) return false;
|
|
2784
2518
|
var canUseArr = mTimes.map(function (item) {
|
|
2785
|
-
var _cartItem$
|
|
2519
|
+
var _cartItem$_productOri9;
|
|
2786
2520
|
var res = getIsUsableByTimeItem({
|
|
2787
2521
|
timeSlice: {
|
|
2788
2522
|
start_time: startTime.format('HH:mm'),
|
|
@@ -2794,7 +2528,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2794
2528
|
resource: m,
|
|
2795
2529
|
currentCount: currentCapacity || 0,
|
|
2796
2530
|
resourcesUseableMap: resourcesUseableMap,
|
|
2797
|
-
cut_off_time: (_cartItem$
|
|
2531
|
+
cut_off_time: (_cartItem$_productOri9 = cartItem._productOrigin) === null || _cartItem$_productOri9 === void 0 ? void 0 : _cartItem$_productOri9.cut_off_time
|
|
2798
2532
|
});
|
|
2799
2533
|
if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
|
|
2800
2534
|
resourcesUseableMap[m.id] = res.usable;
|
|
@@ -2808,12 +2542,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2808
2542
|
});
|
|
2809
2543
|
} else {
|
|
2810
2544
|
targetResource.renderList = targetResource.renderList.filter(function (n) {
|
|
2811
|
-
var _cartItem$
|
|
2545
|
+
var _cartItem$_productOri10;
|
|
2812
2546
|
var recordCount = n.capacity || 0;
|
|
2813
2547
|
if (n.onlyComputed) return false;
|
|
2814
2548
|
var timeSlots = getTimeSlicesByResource({
|
|
2815
2549
|
resource: n,
|
|
2816
|
-
duration: ((_cartItem$
|
|
2550
|
+
duration: ((_cartItem$_productOri10 = cartItem._productOrigin) === null || _cartItem$_productOri10 === void 0 || (_cartItem$_productOri10 = _cartItem$_productOri10.duration) === null || _cartItem$_productOri10 === void 0 ? void 0 : _cartItem$_productOri10.value) || 10,
|
|
2817
2551
|
split: 10,
|
|
2818
2552
|
currentDate: dateRange[0].date
|
|
2819
2553
|
});
|
|
@@ -2831,12 +2565,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2831
2565
|
}, {
|
|
2832
2566
|
key: "getTimeslotsScheduleByDateRange",
|
|
2833
2567
|
value: (function () {
|
|
2834
|
-
var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2568
|
+
var _getTimeslotsScheduleByDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(_ref11) {
|
|
2835
2569
|
var startDate, endDate, scheduleIds, resources, dates, currentDate, end, results, _i, _dates, date;
|
|
2836
|
-
return _regeneratorRuntime().wrap(function
|
|
2837
|
-
while (1) switch (
|
|
2570
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2571
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
2838
2572
|
case 0:
|
|
2839
|
-
startDate =
|
|
2573
|
+
startDate = _ref11.startDate, endDate = _ref11.endDate, scheduleIds = _ref11.scheduleIds, resources = _ref11.resources;
|
|
2840
2574
|
console.log('appoimentBooking-session-date-getTimeslotsScheduleByDateRange', {
|
|
2841
2575
|
startDate: startDate,
|
|
2842
2576
|
endDate: endDate,
|
|
@@ -2861,138 +2595,46 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2861
2595
|
resources: resources
|
|
2862
2596
|
});
|
|
2863
2597
|
}
|
|
2864
|
-
return
|
|
2598
|
+
return _context27.abrupt("return", results);
|
|
2865
2599
|
case 9:
|
|
2866
2600
|
case "end":
|
|
2867
|
-
return
|
|
2601
|
+
return _context27.stop();
|
|
2868
2602
|
}
|
|
2869
|
-
},
|
|
2603
|
+
}, _callee27, this);
|
|
2870
2604
|
}));
|
|
2871
2605
|
function getTimeslotsScheduleByDateRange(_x21) {
|
|
2872
2606
|
return _getTimeslotsScheduleByDateRange.apply(this, arguments);
|
|
2873
2607
|
}
|
|
2874
2608
|
return getTimeslotsScheduleByDateRange;
|
|
2875
2609
|
}())
|
|
2876
|
-
}, {
|
|
2877
|
-
key: "getAvailableDateForSession",
|
|
2878
|
-
value: function () {
|
|
2879
|
-
var _getAvailableDateForSession = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
2880
|
-
var params,
|
|
2881
|
-
startDate,
|
|
2882
|
-
endDate,
|
|
2883
|
-
type,
|
|
2884
|
-
tempProducts,
|
|
2885
|
-
_ref13,
|
|
2886
|
-
resourceIds,
|
|
2887
|
-
rules,
|
|
2888
|
-
resourcesMap,
|
|
2889
|
-
res,
|
|
2890
|
-
dateListWithTimeSlots,
|
|
2891
|
-
firstAvailableDate,
|
|
2892
|
-
_args30 = arguments;
|
|
2893
|
-
return _regeneratorRuntime().wrap(function _callee29$(_context30) {
|
|
2894
|
-
while (1) switch (_context30.prev = _context30.next) {
|
|
2895
|
-
case 0:
|
|
2896
|
-
params = _args30.length > 0 && _args30[0] !== undefined ? _args30[0] : {};
|
|
2897
|
-
// 开始日期如果小于今天,直接以今天当做开始日期
|
|
2898
|
-
startDate = params.startDate, endDate = params.endDate, type = params.type; // 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天 且 endDate 小于或等于今天,需要把 startDate 置为今天
|
|
2899
|
-
if (dayjs(startDate).isBefore(dayjs(), 'day') && (dayjs(endDate).isAfter(dayjs(), 'day') || dayjs(endDate).isSame(dayjs(), 'day'))) {
|
|
2900
|
-
startDate = dayjs().format('YYYY-MM-DD');
|
|
2901
|
-
}
|
|
2902
|
-
// 不管前端传什么 endDate 默认查一个月的,以今天为开始日期。用于找到一个月内最近可用的日期
|
|
2903
|
-
endDate = dayjs().add(1, 'month').format('YYYY-MM-DD');
|
|
2904
|
-
tempProducts = []; // 如果当前打开了某个的商品详情弹窗,则应该默认用这个商品
|
|
2905
|
-
if (this.store.currentProduct) {
|
|
2906
|
-
tempProducts = [_objectSpread(_objectSpread({}, this.store.currentProduct.getData()), {}, {
|
|
2907
|
-
_schedule: this.store.currentProduct.getOtherParams()['schedule']
|
|
2908
|
-
})];
|
|
2909
|
-
}
|
|
2910
|
-
// 在这里需要把能收集到的数据都收集上来,拼装好给 date 模块去查询
|
|
2911
|
-
_ref13 = getAvailableProductResources(tempProducts) || {}, resourceIds = _ref13.resourceIds, rules = _ref13.rules, resourcesMap = _ref13.resourcesMap;
|
|
2912
|
-
this.otherParams.currentResourcesMap = resourcesMap;
|
|
2913
|
-
_context30.next = 10;
|
|
2914
|
-
return this.store.date.getResourceDates({
|
|
2915
|
-
query: {
|
|
2916
|
-
start_date: startDate || '',
|
|
2917
|
-
end_date: endDate || '',
|
|
2918
|
-
resource_ids: resourceIds
|
|
2919
|
-
},
|
|
2920
|
-
rules: rules,
|
|
2921
|
-
type: type
|
|
2922
|
-
});
|
|
2923
|
-
case 10:
|
|
2924
|
-
res = _context30.sent;
|
|
2925
|
-
if (!this.store.currentProduct) {
|
|
2926
|
-
_context30.next = 16;
|
|
2927
|
-
break;
|
|
2928
|
-
}
|
|
2929
|
-
_context30.next = 14;
|
|
2930
|
-
return this.getTimeslotsScheduleByDateRange({
|
|
2931
|
-
startDate: startDate || '',
|
|
2932
|
-
endDate: endDate || ''
|
|
2933
|
-
});
|
|
2934
|
-
case 14:
|
|
2935
|
-
dateListWithTimeSlots = _context30.sent;
|
|
2936
|
-
res.forEach(function (n) {
|
|
2937
|
-
if (!dateListWithTimeSlots[n.date]) {
|
|
2938
|
-
n.status = 'unavailable';
|
|
2939
|
-
} else {
|
|
2940
|
-
var allTimeSlotsCanUse = dateListWithTimeSlots[n.date].every(function (d) {
|
|
2941
|
-
return d.count;
|
|
2942
|
-
});
|
|
2943
|
-
if (!allTimeSlotsCanUse) {
|
|
2944
|
-
n.status = 'unavailable';
|
|
2945
|
-
}
|
|
2946
|
-
}
|
|
2947
|
-
});
|
|
2948
|
-
case 16:
|
|
2949
|
-
// 找到第一个可用的日期返回给 UI
|
|
2950
|
-
firstAvailableDate = res.find(function (n) {
|
|
2951
|
-
return n.status === 'available';
|
|
2952
|
-
});
|
|
2953
|
-
return _context30.abrupt("return", {
|
|
2954
|
-
dateList: res,
|
|
2955
|
-
firstAvailableDate: firstAvailableDate
|
|
2956
|
-
});
|
|
2957
|
-
case 18:
|
|
2958
|
-
case "end":
|
|
2959
|
-
return _context30.stop();
|
|
2960
|
-
}
|
|
2961
|
-
}, _callee29, this);
|
|
2962
|
-
}));
|
|
2963
|
-
function getAvailableDateForSession() {
|
|
2964
|
-
return _getAvailableDateForSession.apply(this, arguments);
|
|
2965
|
-
}
|
|
2966
|
-
return getAvailableDateForSession;
|
|
2967
|
-
}()
|
|
2968
2610
|
}, {
|
|
2969
2611
|
key: "getAvailableDateForSessionOptimize",
|
|
2970
2612
|
value: function () {
|
|
2971
|
-
var _getAvailableDateForSessionOptimize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2613
|
+
var _getAvailableDateForSessionOptimize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
|
|
2972
2614
|
var _this$store$currentPr3, _this$store$currentPr4, _this$store$currentPr5, _tempProducts, _this$store$currentPr6;
|
|
2973
2615
|
var params,
|
|
2974
2616
|
startDate,
|
|
2975
2617
|
endDate,
|
|
2976
2618
|
endDateAfterMonth,
|
|
2977
2619
|
tempEndDate,
|
|
2620
|
+
cache,
|
|
2978
2621
|
tempProducts,
|
|
2979
2622
|
schedule,
|
|
2980
2623
|
filteredSchedule,
|
|
2981
2624
|
tempResourceIds,
|
|
2982
2625
|
res,
|
|
2983
|
-
cache,
|
|
2984
2626
|
dates,
|
|
2985
2627
|
currentDate,
|
|
2986
2628
|
firstAvailableDate,
|
|
2987
2629
|
openResources,
|
|
2988
2630
|
allProductResources,
|
|
2989
2631
|
targetSchedules,
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
return _regeneratorRuntime().wrap(function
|
|
2993
|
-
while (1) switch (
|
|
2632
|
+
_loop2,
|
|
2633
|
+
_args29 = arguments;
|
|
2634
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context29) {
|
|
2635
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
2994
2636
|
case 0:
|
|
2995
|
-
params =
|
|
2637
|
+
params = _args29.length > 0 && _args29[0] !== undefined ? _args29[0] : {};
|
|
2996
2638
|
// 开始日期如果小于今天,直接以今天当做开始日期
|
|
2997
2639
|
startDate = params.startDate, endDate = params.endDate; // 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天 且 endDate 小于或等于今天,需要把 startDate 置为今天
|
|
2998
2640
|
if (dayjs(startDate).isBefore(dayjs(), 'day') && (dayjs(endDate).isAfter(dayjs(), 'day') || dayjs(endDate).isSame(dayjs(), 'day'))) {
|
|
@@ -3013,38 +2655,38 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3013
2655
|
tempEndDate = endDate || '';
|
|
3014
2656
|
}
|
|
3015
2657
|
endDate = tempEndDate;
|
|
3016
|
-
|
|
3017
|
-
tempProducts = (_this$store$currentPr3 = this.store.currentProduct) === null || _this$store$currentPr3 === void 0 ? void 0 : _this$store$currentPr3.getData();
|
|
3018
|
-
schedule = (_this$store$currentPr4 = this.store.currentProduct) === null || _this$store$currentPr4 === void 0 ? void 0 : _this$store$currentPr4.getOtherParams()['schedule'];
|
|
3019
|
-
filteredSchedule = filterScheduleByDateRange(schedule, startDate || '', endDate || ''); // 1.后端返回的数据,确定资源在每一天的可用和使用情况
|
|
3020
|
-
tempResourceIds = getResourcesIdsByProduct(tempProducts);
|
|
3021
|
-
_context32.next = 14;
|
|
3022
|
-
return this.store.date.fetchResourceDates({
|
|
3023
|
-
query: {
|
|
3024
|
-
start_date: startDate || '',
|
|
3025
|
-
end_date: endDate || '',
|
|
3026
|
-
resource_ids: tempResourceIds
|
|
3027
|
-
}
|
|
3028
|
-
});
|
|
3029
|
-
case 14:
|
|
3030
|
-
res = _context32.sent;
|
|
2658
|
+
|
|
3031
2659
|
// 先去读缓存结果,因为正常 UI 调用的是 7 天,而下面我会直接计算 30 天(最少也是 14 天),所以先去读缓存结果,如果缓存结果存在,则直接返回
|
|
3032
|
-
|
|
3033
|
-
cache = (_this$store$currentPr5 = this.store.currentProduct) === null || _this$store$currentPr5 === void 0 ? void 0 : _this$store$currentPr5.getOtherParams()['timeSlotBySchedule'];
|
|
2660
|
+
cache = (_this$store$currentPr3 = this.store.currentProduct) === null || _this$store$currentPr3 === void 0 ? void 0 : _this$store$currentPr3.getOtherParams()['timeSlotBySchedule'];
|
|
3034
2661
|
if (!cache) {
|
|
3035
|
-
|
|
2662
|
+
_context29.next = 13;
|
|
3036
2663
|
break;
|
|
3037
2664
|
}
|
|
3038
2665
|
if (!(dayjs(params.startDate).isSameOrAfter(dayjs(cache.startDate), 'day') && dayjs(params.endDate).isSameOrBefore(dayjs(cache.endDate), 'day'))) {
|
|
3039
|
-
|
|
2666
|
+
_context29.next = 13;
|
|
3040
2667
|
break;
|
|
3041
2668
|
}
|
|
3042
2669
|
this.store.date.setDateList(cache.dateList);
|
|
3043
|
-
return
|
|
2670
|
+
return _context29.abrupt("return", {
|
|
3044
2671
|
dateList: cache.dateList,
|
|
3045
2672
|
firstAvailableDate: cache.firstAvailableDate
|
|
3046
2673
|
});
|
|
3047
|
-
case
|
|
2674
|
+
case 13:
|
|
2675
|
+
// 如果当前打开了某个的商品详情弹窗,则应该默认用这个商品
|
|
2676
|
+
tempProducts = (_this$store$currentPr4 = this.store.currentProduct) === null || _this$store$currentPr4 === void 0 ? void 0 : _this$store$currentPr4.getData();
|
|
2677
|
+
schedule = (_this$store$currentPr5 = this.store.currentProduct) === null || _this$store$currentPr5 === void 0 ? void 0 : _this$store$currentPr5.getOtherParams()['schedule'];
|
|
2678
|
+
filteredSchedule = filterScheduleByDateRange(schedule, startDate || '', endDate || ''); // 1.后端返回的数据,确定资源在每一天的可用和使用情况
|
|
2679
|
+
tempResourceIds = getResourcesIdsByProduct(tempProducts);
|
|
2680
|
+
_context29.next = 19;
|
|
2681
|
+
return this.store.date.fetchResourceDates({
|
|
2682
|
+
query: {
|
|
2683
|
+
start_date: startDate || '',
|
|
2684
|
+
end_date: endDate || '',
|
|
2685
|
+
resource_ids: tempResourceIds
|
|
2686
|
+
}
|
|
2687
|
+
});
|
|
2688
|
+
case 19:
|
|
2689
|
+
res = _context29.sent;
|
|
3048
2690
|
// 2. 商品 schedule 数据,确定日程在每一天的时间片
|
|
3049
2691
|
// 3. 把后端返回的和 schedule 的数据进行合并,确定每一天的可用和使用情况
|
|
3050
2692
|
dates = [];
|
|
@@ -3064,10 +2706,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3064
2706
|
}
|
|
3065
2707
|
});
|
|
3066
2708
|
targetSchedules = this.store.schedule.getScheduleListByIds(tempProducts['schedule.ids']);
|
|
3067
|
-
|
|
2709
|
+
_loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
|
|
3068
2710
|
var currentDateStr, status, _checkSessionProductL, latestStartDate, earliestEndDate, scheduleByDate, minTimeMaxTime, scheduleTimeSlots, timesSlotCanUse;
|
|
3069
|
-
return _regeneratorRuntime().wrap(function
|
|
3070
|
-
while (1) switch (
|
|
2711
|
+
return _regeneratorRuntime().wrap(function _loop2$(_context28) {
|
|
2712
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
3071
2713
|
case 0:
|
|
3072
2714
|
currentDateStr = currentDate.format('YYYY-MM-DD');
|
|
3073
2715
|
status = 'available'; // 1. 检查商品的提前量等情况是否满足
|
|
@@ -3159,32 +2801,32 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3159
2801
|
|
|
3160
2802
|
// 如果 firstAvailableDate 距离 startDate 大于 14 天了,则后面就不需要再找了,也是一种性能保护
|
|
3161
2803
|
if (!(firstAvailableDate && dayjs(currentDate).diff(dayjs(startDate), 'day') > 14)) {
|
|
3162
|
-
|
|
2804
|
+
_context28.next = 9;
|
|
3163
2805
|
break;
|
|
3164
2806
|
}
|
|
3165
|
-
return
|
|
2807
|
+
return _context28.abrupt("return", 1);
|
|
3166
2808
|
case 9:
|
|
3167
2809
|
currentDate = dayjs(currentDate).add(1, 'day');
|
|
3168
2810
|
case 10:
|
|
3169
2811
|
case "end":
|
|
3170
|
-
return
|
|
2812
|
+
return _context28.stop();
|
|
3171
2813
|
}
|
|
3172
|
-
},
|
|
2814
|
+
}, _loop2);
|
|
3173
2815
|
});
|
|
3174
2816
|
case 28:
|
|
3175
2817
|
if (!(dayjs(currentDate).isBefore(dayjs(endDate), 'day') || dayjs(currentDate).isSame(dayjs(endDate), 'day'))) {
|
|
3176
|
-
|
|
2818
|
+
_context29.next = 34;
|
|
3177
2819
|
break;
|
|
3178
2820
|
}
|
|
3179
|
-
return
|
|
2821
|
+
return _context29.delegateYield(_loop2(), "t0", 30);
|
|
3180
2822
|
case 30:
|
|
3181
|
-
if (!
|
|
3182
|
-
|
|
2823
|
+
if (!_context29.t0) {
|
|
2824
|
+
_context29.next = 32;
|
|
3183
2825
|
break;
|
|
3184
2826
|
}
|
|
3185
|
-
return
|
|
2827
|
+
return _context29.abrupt("break", 34);
|
|
3186
2828
|
case 32:
|
|
3187
|
-
|
|
2829
|
+
_context29.next = 28;
|
|
3188
2830
|
break;
|
|
3189
2831
|
case 34:
|
|
3190
2832
|
// 最终把资源数据也加到日期内
|
|
@@ -3198,15 +2840,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3198
2840
|
startDate: startDate,
|
|
3199
2841
|
endDate: dayjs(currentDate).format('YYYY-MM-DD')
|
|
3200
2842
|
});
|
|
3201
|
-
return
|
|
2843
|
+
return _context29.abrupt("return", {
|
|
3202
2844
|
dateList: dates,
|
|
3203
2845
|
firstAvailableDate: firstAvailableDate
|
|
3204
2846
|
});
|
|
3205
2847
|
case 38:
|
|
3206
2848
|
case "end":
|
|
3207
|
-
return
|
|
2849
|
+
return _context29.stop();
|
|
3208
2850
|
}
|
|
3209
|
-
},
|
|
2851
|
+
}, _callee28, this);
|
|
3210
2852
|
}));
|
|
3211
2853
|
function getAvailableDateForSessionOptimize() {
|
|
3212
2854
|
return _getAvailableDateForSessionOptimize.apply(this, arguments);
|
|
@@ -3228,8 +2870,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3228
2870
|
return !isNormalProduct(n._productOrigin);
|
|
3229
2871
|
});
|
|
3230
2872
|
return cartItems.some(function (n) {
|
|
3231
|
-
var _n$
|
|
3232
|
-
return (_n$
|
|
2873
|
+
var _n$_productOrigin2;
|
|
2874
|
+
return (_n$_productOrigin2 = n._productOrigin) === null || _n$_productOrigin2 === void 0 ? void 0 : _n$_productOrigin2.duration;
|
|
3233
2875
|
});
|
|
3234
2876
|
}
|
|
3235
2877
|
}, {
|