@pisell/pisellos 2.0.20 → 2.0.22
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/Account/index.d.ts +1 -0
- package/dist/modules/Account/index.js +6 -0
- package/dist/modules/Account/types.d.ts +2 -0
- package/dist/modules/AccountList/index.d.ts +1 -0
- package/dist/modules/AccountList/index.js +7 -0
- package/dist/modules/Product/index.d.ts +1 -0
- package/dist/modules/Product/index.js +6 -0
- package/dist/modules/ProductList/index.d.ts +7 -0
- package/dist/modules/ProductList/index.js +84 -38
- package/dist/plugins/user.d.ts +7 -0
- package/dist/plugins/user.js +1 -0
- package/dist/solution/BookingByStep/index.d.ts +3 -1
- package/dist/solution/BookingByStep/index.js +416 -253
- package/dist/solution/BookingByStep/utils/resources.d.ts +22 -2
- package/dist/solution/BookingByStep/utils/resources.js +8 -4
- package/lib/modules/Account/index.d.ts +1 -0
- package/lib/modules/Account/index.js +4 -0
- package/lib/modules/Account/types.d.ts +2 -0
- package/lib/modules/AccountList/index.d.ts +1 -0
- package/lib/modules/AccountList/index.js +3 -0
- package/lib/modules/Product/index.d.ts +1 -0
- package/lib/modules/Product/index.js +3 -0
- package/lib/modules/ProductList/index.d.ts +7 -0
- package/lib/modules/ProductList/index.js +35 -2
- package/lib/plugins/user.d.ts +7 -0
- package/lib/plugins/user.js +17 -0
- package/lib/solution/BookingByStep/index.d.ts +3 -1
- package/lib/solution/BookingByStep/index.js +94 -6
- package/lib/solution/BookingByStep/utils/resources.d.ts +22 -2
- package/lib/solution/BookingByStep/utils/resources.js +8 -4
- package/package.json +1 -1
|
@@ -204,7 +204,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
204
204
|
value: function () {
|
|
205
205
|
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
|
|
206
206
|
var _schedule_ids;
|
|
207
|
-
var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, _ref$schedule_ids, schedule_ids, schedule_date, schedule_ids_data, productsData;
|
|
207
|
+
var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, _ref$schedule_ids, schedule_ids, schedule_date, schedule_ids_data, userPlugin, customer_id, _userPlugin$get, productsData;
|
|
208
208
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
209
209
|
while (1) switch (_context2.prev = _context2.next) {
|
|
210
210
|
case 0:
|
|
@@ -221,15 +221,24 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
221
221
|
schedule_ids = [0];
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
|
-
|
|
224
|
+
userPlugin = this.core.getPlugin('user');
|
|
225
|
+
customer_id = undefined;
|
|
226
|
+
try {
|
|
227
|
+
customer_id = userPlugin === null || userPlugin === void 0 || (_userPlugin$get = userPlugin.get()) === null || _userPlugin$get === void 0 ? void 0 : _userPlugin$get.id;
|
|
228
|
+
} catch (error) {
|
|
229
|
+
console.error(error);
|
|
230
|
+
}
|
|
231
|
+
// 如果没传schedule_date,则从
|
|
232
|
+
_context2.next = 7;
|
|
225
233
|
return this.request.post("/product/query", {
|
|
226
234
|
open_quotation: 1,
|
|
227
|
-
open_bundle:
|
|
235
|
+
open_bundle: 0,
|
|
228
236
|
extension_type: ['product_appointment', 'appointment_ticket', 'session_product', 'session_ticket'],
|
|
229
237
|
with: ['category', 'collection', 'resourceRelation'],
|
|
230
238
|
status: 'published',
|
|
231
239
|
num: 500,
|
|
232
240
|
skip: 1,
|
|
241
|
+
customer_id: customer_id,
|
|
233
242
|
category_ids: category_ids,
|
|
234
243
|
ids: product_ids,
|
|
235
244
|
collection: collection,
|
|
@@ -239,11 +248,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
239
248
|
}, {
|
|
240
249
|
useCache: true
|
|
241
250
|
});
|
|
242
|
-
case
|
|
251
|
+
case 7:
|
|
243
252
|
productsData = _context2.sent;
|
|
244
253
|
this.store.products.addProduct(productsData.data.list);
|
|
245
254
|
return _context2.abrupt("return", productsData.data.list);
|
|
246
|
-
case
|
|
255
|
+
case 10:
|
|
247
256
|
case "end":
|
|
248
257
|
return _context2.stop();
|
|
249
258
|
}
|
|
@@ -299,30 +308,146 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
299
308
|
return _loadProductByScheduleDate.apply(this, arguments);
|
|
300
309
|
}
|
|
301
310
|
return loadProductByScheduleDate;
|
|
311
|
+
}()
|
|
312
|
+
}, {
|
|
313
|
+
key: "updateQuotationPriceAndCart",
|
|
314
|
+
value: function () {
|
|
315
|
+
var _updateQuotationPriceAndCart = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(date) {
|
|
316
|
+
var _this3 = this;
|
|
317
|
+
var cartItems, userPlugin, customer_id, _userPlugin$get2, res, _iterator, _step, _loop;
|
|
318
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context5) {
|
|
319
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
320
|
+
case 0:
|
|
321
|
+
// 更新完商品数据以后,检测当前购物车里是否有商品,如果有,则需要更新购物车里的商品价格
|
|
322
|
+
cartItems = this.store.cart.getItems();
|
|
323
|
+
if (!cartItems.length) {
|
|
324
|
+
_context5.next = 25;
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
userPlugin = this.core.getPlugin('user');
|
|
328
|
+
customer_id = undefined;
|
|
329
|
+
try {
|
|
330
|
+
customer_id = userPlugin === null || userPlugin === void 0 || (_userPlugin$get2 = userPlugin.get()) === null || _userPlugin$get2 === void 0 ? void 0 : _userPlugin$get2.id;
|
|
331
|
+
} catch (error) {
|
|
332
|
+
console.error(error);
|
|
333
|
+
}
|
|
334
|
+
_context5.next = 7;
|
|
335
|
+
return this.store.products.loadProductsPrice({
|
|
336
|
+
ids: cartItems.map(function (n) {
|
|
337
|
+
return n.id;
|
|
338
|
+
}),
|
|
339
|
+
schedule_date: date,
|
|
340
|
+
customer_id: customer_id
|
|
341
|
+
});
|
|
342
|
+
case 7:
|
|
343
|
+
res = _context5.sent;
|
|
344
|
+
_iterator = _createForOfIteratorHelper(cartItems);
|
|
345
|
+
_context5.prev = 9;
|
|
346
|
+
_loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
|
|
347
|
+
var _bundle;
|
|
348
|
+
var item, targetProduct, cartProduct, productInfo, bundle;
|
|
349
|
+
return _regeneratorRuntime().wrap(function _loop$(_context4) {
|
|
350
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
351
|
+
case 0:
|
|
352
|
+
item = _step.value;
|
|
353
|
+
targetProduct = res.find(function (n) {
|
|
354
|
+
return n.id === item.id;
|
|
355
|
+
});
|
|
356
|
+
_context4.next = 4;
|
|
357
|
+
return _this3.store.products.getProduct(item.id);
|
|
358
|
+
case 4:
|
|
359
|
+
cartProduct = _context4.sent;
|
|
360
|
+
productInfo = cartProduct === null || cartProduct === void 0 ? void 0 : cartProduct.getData();
|
|
361
|
+
bundle = item._bundleOrigin;
|
|
362
|
+
productInfo.price = targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.price;
|
|
363
|
+
productInfo.base_price = targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.base_price;
|
|
364
|
+
bundle = (_bundle = bundle) === null || _bundle === void 0 ? void 0 : _bundle.map(function (n) {
|
|
365
|
+
var _targetProduct$bundle;
|
|
366
|
+
// 更新 bundle 的价格
|
|
367
|
+
var targetBundle = targetProduct === null || targetProduct === void 0 || (_targetProduct$bundle = targetProduct.bundle_group) === null || _targetProduct$bundle === void 0 ? void 0 : _targetProduct$bundle.find(function (m) {
|
|
368
|
+
return m.id === n.group_id;
|
|
369
|
+
});
|
|
370
|
+
if (targetBundle) {
|
|
371
|
+
var targetBundleItem = targetBundle.bundle_item.find(function (m) {
|
|
372
|
+
return m.id === n.id;
|
|
373
|
+
});
|
|
374
|
+
if (targetBundleItem) {
|
|
375
|
+
return _objectSpread(_objectSpread({}, n), {}, {
|
|
376
|
+
price: targetBundleItem.price,
|
|
377
|
+
base_price: targetBundleItem.base_price
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
return n;
|
|
382
|
+
});
|
|
383
|
+
_this3.store.cart.updateItem({
|
|
384
|
+
_id: item._id,
|
|
385
|
+
product: productInfo,
|
|
386
|
+
bundle: bundle
|
|
387
|
+
});
|
|
388
|
+
case 11:
|
|
389
|
+
case "end":
|
|
390
|
+
return _context4.stop();
|
|
391
|
+
}
|
|
392
|
+
}, _loop);
|
|
393
|
+
});
|
|
394
|
+
_iterator.s();
|
|
395
|
+
case 12:
|
|
396
|
+
if ((_step = _iterator.n()).done) {
|
|
397
|
+
_context5.next = 16;
|
|
398
|
+
break;
|
|
399
|
+
}
|
|
400
|
+
return _context5.delegateYield(_loop(), "t0", 14);
|
|
401
|
+
case 14:
|
|
402
|
+
_context5.next = 12;
|
|
403
|
+
break;
|
|
404
|
+
case 16:
|
|
405
|
+
_context5.next = 21;
|
|
406
|
+
break;
|
|
407
|
+
case 18:
|
|
408
|
+
_context5.prev = 18;
|
|
409
|
+
_context5.t1 = _context5["catch"](9);
|
|
410
|
+
_iterator.e(_context5.t1);
|
|
411
|
+
case 21:
|
|
412
|
+
_context5.prev = 21;
|
|
413
|
+
_iterator.f();
|
|
414
|
+
return _context5.finish(21);
|
|
415
|
+
case 24:
|
|
416
|
+
;
|
|
417
|
+
case 25:
|
|
418
|
+
case "end":
|
|
419
|
+
return _context5.stop();
|
|
420
|
+
}
|
|
421
|
+
}, _callee4, this, [[9, 18, 21, 24]]);
|
|
422
|
+
}));
|
|
423
|
+
function updateQuotationPriceAndCart(_x5) {
|
|
424
|
+
return _updateQuotationPriceAndCart.apply(this, arguments);
|
|
425
|
+
}
|
|
426
|
+
return updateQuotationPriceAndCart;
|
|
302
427
|
}() // 加载当前店铺下所有 schedule
|
|
303
428
|
}, {
|
|
304
429
|
key: "loadAllSchedule",
|
|
305
430
|
value: function () {
|
|
306
|
-
var _loadAllSchedule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
431
|
+
var _loadAllSchedule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
307
432
|
var _scheduleList$data;
|
|
308
433
|
var scheduleList;
|
|
309
|
-
return _regeneratorRuntime().wrap(function
|
|
310
|
-
while (1) switch (
|
|
434
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context6) {
|
|
435
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
311
436
|
case 0:
|
|
312
|
-
|
|
437
|
+
_context6.next = 2;
|
|
313
438
|
return this.request.get("/schedule", {
|
|
314
439
|
num: 999
|
|
315
440
|
}, {
|
|
316
441
|
useCache: true
|
|
317
442
|
});
|
|
318
443
|
case 2:
|
|
319
|
-
scheduleList =
|
|
444
|
+
scheduleList = _context6.sent;
|
|
320
445
|
this.store.schedule.setScheduleList(((_scheduleList$data = scheduleList.data) === null || _scheduleList$data === void 0 ? void 0 : _scheduleList$data.list) || []);
|
|
321
446
|
case 4:
|
|
322
447
|
case "end":
|
|
323
|
-
return
|
|
448
|
+
return _context6.stop();
|
|
324
449
|
}
|
|
325
|
-
},
|
|
450
|
+
}, _callee5, this);
|
|
326
451
|
}));
|
|
327
452
|
function loadAllSchedule() {
|
|
328
453
|
return _loadAllSchedule.apply(this, arguments);
|
|
@@ -332,11 +457,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
332
457
|
}, {
|
|
333
458
|
key: "loadScheduleAvailableDate",
|
|
334
459
|
value: function () {
|
|
335
|
-
var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
460
|
+
var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref3) {
|
|
336
461
|
var _res$data$date_list;
|
|
337
462
|
var startDate, endDate, custom_page_id, channel, dates, res;
|
|
338
|
-
return _regeneratorRuntime().wrap(function
|
|
339
|
-
while (1) switch (
|
|
463
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context7) {
|
|
464
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
340
465
|
case 0:
|
|
341
466
|
startDate = _ref3.startDate, endDate = _ref3.endDate, custom_page_id = _ref3.custom_page_id, channel = _ref3.channel;
|
|
342
467
|
// 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天,需要把 startDate 置为今天
|
|
@@ -348,12 +473,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
348
473
|
dates = disableAllDates(dates);
|
|
349
474
|
// 如果 endDate 在今天之前,则不用查接口,直接返回 dates
|
|
350
475
|
if (!dayjs(endDate).isBefore(dayjs(), 'day')) {
|
|
351
|
-
|
|
476
|
+
_context7.next = 6;
|
|
352
477
|
break;
|
|
353
478
|
}
|
|
354
|
-
return
|
|
479
|
+
return _context7.abrupt("return", dates);
|
|
355
480
|
case 6:
|
|
356
|
-
|
|
481
|
+
_context7.next = 8;
|
|
357
482
|
return this.request.get("/schedule/product/availability", {
|
|
358
483
|
start_date: startDate,
|
|
359
484
|
end_date: endDate,
|
|
@@ -361,14 +486,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
361
486
|
channel: channel
|
|
362
487
|
});
|
|
363
488
|
case 8:
|
|
364
|
-
res =
|
|
489
|
+
res = _context7.sent;
|
|
365
490
|
this.store.schedule.setAvailabilityScheduleDateList(res.data.date_list);
|
|
366
491
|
// 如果没有schedule或者结束日期在今天之前,则所有日期均不可用
|
|
367
492
|
if (!(!((_res$data$date_list = res.data.date_list) !== null && _res$data$date_list !== void 0 && _res$data$date_list.length) || dayjs(endDate).isBefore(dayjs(), 'day'))) {
|
|
368
|
-
|
|
493
|
+
_context7.next = 12;
|
|
369
494
|
break;
|
|
370
495
|
}
|
|
371
|
-
return
|
|
496
|
+
return _context7.abrupt("return", dates);
|
|
372
497
|
case 12:
|
|
373
498
|
res.data.date_list.forEach(function (n) {
|
|
374
499
|
var index = dates.findIndex(function (m) {
|
|
@@ -379,14 +504,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
379
504
|
}
|
|
380
505
|
});
|
|
381
506
|
dates = disableDatesBeforeOneDay(dates);
|
|
382
|
-
return
|
|
507
|
+
return _context7.abrupt("return", dates);
|
|
383
508
|
case 15:
|
|
384
509
|
case "end":
|
|
385
|
-
return
|
|
510
|
+
return _context7.stop();
|
|
386
511
|
}
|
|
387
|
-
},
|
|
512
|
+
}, _callee6, this);
|
|
388
513
|
}));
|
|
389
|
-
function loadScheduleAvailableDate(
|
|
514
|
+
function loadScheduleAvailableDate(_x6) {
|
|
390
515
|
return _loadScheduleAvailableDate.apply(this, arguments);
|
|
391
516
|
}
|
|
392
517
|
return loadScheduleAvailableDate;
|
|
@@ -394,10 +519,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
394
519
|
}, {
|
|
395
520
|
key: "storeProduct",
|
|
396
521
|
value: function () {
|
|
397
|
-
var _storeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
522
|
+
var _storeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(productData) {
|
|
398
523
|
var activeAccount, _ref4, bundle, options, origin, product_variant_id, product, addCartItem;
|
|
399
|
-
return _regeneratorRuntime().wrap(function
|
|
400
|
-
while (1) switch (
|
|
524
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context8) {
|
|
525
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
401
526
|
case 0:
|
|
402
527
|
// 往购物车加商品数据的时候,默认用当前 activeAccount 填充到 product 的 account 里面
|
|
403
528
|
activeAccount = this.getActiveAccount();
|
|
@@ -416,11 +541,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
416
541
|
this.store.cart.addItem(addCartItem);
|
|
417
542
|
case 6:
|
|
418
543
|
case "end":
|
|
419
|
-
return
|
|
544
|
+
return _context8.stop();
|
|
420
545
|
}
|
|
421
|
-
},
|
|
546
|
+
}, _callee7, this);
|
|
422
547
|
}));
|
|
423
|
-
function storeProduct(
|
|
548
|
+
function storeProduct(_x7) {
|
|
424
549
|
return _storeProduct.apply(this, arguments);
|
|
425
550
|
}
|
|
426
551
|
return storeProduct;
|
|
@@ -428,37 +553,37 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
428
553
|
}, {
|
|
429
554
|
key: "addAccount",
|
|
430
555
|
value: function () {
|
|
431
|
-
var _addAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
556
|
+
var _addAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(account, extra) {
|
|
432
557
|
var accountModules, newAccount;
|
|
433
|
-
return _regeneratorRuntime().wrap(function
|
|
434
|
-
while (1) switch (
|
|
558
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context9) {
|
|
559
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
435
560
|
case 0:
|
|
436
561
|
if (!((extra === null || extra === void 0 ? void 0 : extra.type) === 'holder')) {
|
|
437
|
-
|
|
562
|
+
_context9.next = 5;
|
|
438
563
|
break;
|
|
439
564
|
}
|
|
440
|
-
|
|
565
|
+
_context9.next = 3;
|
|
441
566
|
return this.store.accountList.addHolderAccounts({
|
|
442
567
|
holders: [account],
|
|
443
568
|
customerId: extra.customerId,
|
|
444
569
|
type: 'unshift'
|
|
445
570
|
});
|
|
446
571
|
case 3:
|
|
447
|
-
accountModules =
|
|
448
|
-
return
|
|
572
|
+
accountModules = _context9.sent;
|
|
573
|
+
return _context9.abrupt("return", accountModules[0].getAccount());
|
|
449
574
|
case 5:
|
|
450
|
-
|
|
575
|
+
_context9.next = 7;
|
|
451
576
|
return this.store.accountList.addAccount(account);
|
|
452
577
|
case 7:
|
|
453
|
-
newAccount =
|
|
454
|
-
return
|
|
578
|
+
newAccount = _context9.sent;
|
|
579
|
+
return _context9.abrupt("return", newAccount.getAccount());
|
|
455
580
|
case 9:
|
|
456
581
|
case "end":
|
|
457
|
-
return
|
|
582
|
+
return _context9.stop();
|
|
458
583
|
}
|
|
459
|
-
},
|
|
584
|
+
}, _callee8, this);
|
|
460
585
|
}));
|
|
461
|
-
function addAccount(
|
|
586
|
+
function addAccount(_x8, _x9) {
|
|
462
587
|
return _addAccount.apply(this, arguments);
|
|
463
588
|
}
|
|
464
589
|
return addAccount;
|
|
@@ -466,13 +591,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
466
591
|
}, {
|
|
467
592
|
key: "addAccounts",
|
|
468
593
|
value: function () {
|
|
469
|
-
var _addAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
470
|
-
var res,
|
|
471
|
-
return _regeneratorRuntime().wrap(function
|
|
472
|
-
while (1) switch (
|
|
594
|
+
var _addAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(accounts, extra) {
|
|
595
|
+
var res, _iterator2, _step2, account, accountModule, accountData;
|
|
596
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context10) {
|
|
597
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
473
598
|
case 0:
|
|
474
599
|
if (!((extra === null || extra === void 0 ? void 0 : extra.type) === 'holder')) {
|
|
475
|
-
|
|
600
|
+
_context10.next = 3;
|
|
476
601
|
break;
|
|
477
602
|
}
|
|
478
603
|
this.store.accountList.addHolderAccounts({
|
|
@@ -480,49 +605,49 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
480
605
|
customerId: extra.customerId,
|
|
481
606
|
type: 'unshift'
|
|
482
607
|
});
|
|
483
|
-
return
|
|
608
|
+
return _context10.abrupt("return");
|
|
484
609
|
case 3:
|
|
485
610
|
res = [];
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
611
|
+
_iterator2 = _createForOfIteratorHelper(accounts);
|
|
612
|
+
_context10.prev = 5;
|
|
613
|
+
_iterator2.s();
|
|
489
614
|
case 7:
|
|
490
|
-
if ((
|
|
491
|
-
|
|
615
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
616
|
+
_context10.next = 16;
|
|
492
617
|
break;
|
|
493
618
|
}
|
|
494
|
-
account =
|
|
495
|
-
|
|
619
|
+
account = _step2.value;
|
|
620
|
+
_context10.next = 11;
|
|
496
621
|
return this.store.accountList.addAccount(account);
|
|
497
622
|
case 11:
|
|
498
|
-
accountModule =
|
|
623
|
+
accountModule = _context10.sent;
|
|
499
624
|
accountData = accountModule.getAccount();
|
|
500
625
|
if (accountData) {
|
|
501
626
|
res.push(accountData);
|
|
502
627
|
}
|
|
503
628
|
case 14:
|
|
504
|
-
|
|
629
|
+
_context10.next = 7;
|
|
505
630
|
break;
|
|
506
631
|
case 16:
|
|
507
|
-
|
|
632
|
+
_context10.next = 21;
|
|
508
633
|
break;
|
|
509
634
|
case 18:
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
635
|
+
_context10.prev = 18;
|
|
636
|
+
_context10.t0 = _context10["catch"](5);
|
|
637
|
+
_iterator2.e(_context10.t0);
|
|
513
638
|
case 21:
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
return
|
|
639
|
+
_context10.prev = 21;
|
|
640
|
+
_iterator2.f();
|
|
641
|
+
return _context10.finish(21);
|
|
517
642
|
case 24:
|
|
518
|
-
return
|
|
643
|
+
return _context10.abrupt("return", res);
|
|
519
644
|
case 25:
|
|
520
645
|
case "end":
|
|
521
|
-
return
|
|
646
|
+
return _context10.stop();
|
|
522
647
|
}
|
|
523
|
-
},
|
|
648
|
+
}, _callee9, this, [[5, 18, 21, 24]]);
|
|
524
649
|
}));
|
|
525
|
-
function addAccounts(
|
|
650
|
+
function addAccounts(_x10, _x11) {
|
|
526
651
|
return _addAccounts.apply(this, arguments);
|
|
527
652
|
}
|
|
528
653
|
return addAccounts;
|
|
@@ -530,20 +655,20 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
530
655
|
}, {
|
|
531
656
|
key: "getAccounts",
|
|
532
657
|
value: function () {
|
|
533
|
-
var _getAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
658
|
+
var _getAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
534
659
|
var accounts;
|
|
535
|
-
return _regeneratorRuntime().wrap(function
|
|
536
|
-
while (1) switch (
|
|
660
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context11) {
|
|
661
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
537
662
|
case 0:
|
|
538
663
|
accounts = this.store.accountList.getAccounts();
|
|
539
|
-
return
|
|
664
|
+
return _context11.abrupt("return", accounts.map(function (account) {
|
|
540
665
|
return account.getAccount();
|
|
541
666
|
}));
|
|
542
667
|
case 2:
|
|
543
668
|
case "end":
|
|
544
|
-
return
|
|
669
|
+
return _context11.stop();
|
|
545
670
|
}
|
|
546
|
-
},
|
|
671
|
+
}, _callee10, this);
|
|
547
672
|
}));
|
|
548
673
|
function getAccounts() {
|
|
549
674
|
return _getAccounts.apply(this, arguments);
|
|
@@ -584,18 +709,28 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
584
709
|
}, {
|
|
585
710
|
key: "fetchHolderAccountsAsync",
|
|
586
711
|
value: (function () {
|
|
587
|
-
var _fetchHolderAccountsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
588
|
-
|
|
589
|
-
|
|
712
|
+
var _fetchHolderAccountsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(params) {
|
|
713
|
+
var cartItems, _this$store$date$getD, date, _cartItems$;
|
|
714
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context12) {
|
|
715
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
590
716
|
case 0:
|
|
591
|
-
|
|
592
|
-
|
|
717
|
+
cartItems = this.store.cart.getItems();
|
|
718
|
+
if (cartItems.length) {
|
|
719
|
+
date = (_this$store$date$getD = this.store.date.getDateRange()) === null || _this$store$date$getD === void 0 || (_this$store$date$getD = _this$store$date$getD[0]) === null || _this$store$date$getD === void 0 ? void 0 : _this$store$date$getD.date;
|
|
720
|
+
if (!date) {
|
|
721
|
+
// 如果没有日期,则应该是 session 类先选商品的流程,直接从购物车里拿 start_date
|
|
722
|
+
date = (cartItems === null || cartItems === void 0 || (_cartItems$ = cartItems[0]) === null || _cartItems$ === void 0 ? void 0 : _cartItems$.start_date) || '';
|
|
723
|
+
}
|
|
724
|
+
this.updateQuotationPriceAndCart(date);
|
|
725
|
+
}
|
|
726
|
+
return _context12.abrupt("return", this.store.accountList.fetchHolderAccounts(params));
|
|
727
|
+
case 3:
|
|
593
728
|
case "end":
|
|
594
|
-
return
|
|
729
|
+
return _context12.stop();
|
|
595
730
|
}
|
|
596
|
-
},
|
|
731
|
+
}, _callee11, this);
|
|
597
732
|
}));
|
|
598
|
-
function fetchHolderAccountsAsync(
|
|
733
|
+
function fetchHolderAccountsAsync(_x12) {
|
|
599
734
|
return _fetchHolderAccountsAsync.apply(this, arguments);
|
|
600
735
|
}
|
|
601
736
|
return fetchHolderAccountsAsync;
|
|
@@ -604,18 +739,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
604
739
|
}, {
|
|
605
740
|
key: "setDateRange",
|
|
606
741
|
value: function () {
|
|
607
|
-
var _setDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
608
|
-
return _regeneratorRuntime().wrap(function
|
|
609
|
-
while (1) switch (
|
|
742
|
+
var _setDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(dateRange) {
|
|
743
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context13) {
|
|
744
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
610
745
|
case 0:
|
|
611
746
|
this.store.date.setDateRange(dateRange);
|
|
612
|
-
|
|
747
|
+
// 日期数据变更后,如果购物车里有数据,需要更新购物车里的报价单的价格
|
|
748
|
+
if (dateRange.length && this.store.cart.getItems().length) {
|
|
749
|
+
this.updateQuotationPriceAndCart(dateRange[0].date);
|
|
750
|
+
}
|
|
751
|
+
case 2:
|
|
613
752
|
case "end":
|
|
614
|
-
return
|
|
753
|
+
return _context13.stop();
|
|
615
754
|
}
|
|
616
|
-
},
|
|
755
|
+
}, _callee12, this);
|
|
617
756
|
}));
|
|
618
|
-
function setDateRange(
|
|
757
|
+
function setDateRange(_x13) {
|
|
619
758
|
return _setDateRange.apply(this, arguments);
|
|
620
759
|
}
|
|
621
760
|
return setDateRange;
|
|
@@ -630,16 +769,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
630
769
|
}, {
|
|
631
770
|
key: "getDateRange",
|
|
632
771
|
value: function () {
|
|
633
|
-
var _getDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
634
|
-
return _regeneratorRuntime().wrap(function
|
|
635
|
-
while (1) switch (
|
|
772
|
+
var _getDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
773
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context14) {
|
|
774
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
636
775
|
case 0:
|
|
637
|
-
return
|
|
776
|
+
return _context14.abrupt("return", this.store.date.getDateRange());
|
|
638
777
|
case 1:
|
|
639
778
|
case "end":
|
|
640
|
-
return
|
|
779
|
+
return _context14.stop();
|
|
641
780
|
}
|
|
642
|
-
},
|
|
781
|
+
}, _callee13, this);
|
|
643
782
|
}));
|
|
644
783
|
function getDateRange() {
|
|
645
784
|
return _getDateRange.apply(this, arguments);
|
|
@@ -656,8 +795,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
656
795
|
}, {
|
|
657
796
|
key: "getAvailableDate",
|
|
658
797
|
value: function () {
|
|
659
|
-
var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
660
|
-
var
|
|
798
|
+
var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
799
|
+
var _this4 = this,
|
|
661
800
|
_dateRange$,
|
|
662
801
|
_dateRange$2,
|
|
663
802
|
_dateRange$3;
|
|
@@ -675,11 +814,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
675
814
|
rules,
|
|
676
815
|
resourcesMap,
|
|
677
816
|
res,
|
|
678
|
-
|
|
679
|
-
return _regeneratorRuntime().wrap(function
|
|
680
|
-
while (1) switch (
|
|
817
|
+
_args15 = arguments;
|
|
818
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context15) {
|
|
819
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
681
820
|
case 0:
|
|
682
|
-
params =
|
|
821
|
+
params = _args15.length > 0 && _args15[0] !== undefined ? _args15[0] : {};
|
|
683
822
|
// 开始日期如果小于今天,直接以今天当做开始日期
|
|
684
823
|
products = params.products, startDate = params.startDate, endDate = params.endDate, type = params.type; // 前端传递的 startDate,可能是今天之前的,如果 startDate 小于今天 且 endDate 小于或等于今天,需要把 startDate 置为今天
|
|
685
824
|
if (dayjs(startDate).isBefore(dayjs(), 'day') && (dayjs(endDate).isAfter(dayjs(), 'day') || dayjs(endDate).isSame(dayjs(), 'day'))) {
|
|
@@ -691,7 +830,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
691
830
|
if (tempProducts.length) {
|
|
692
831
|
tempProducts.forEach(function (p) {
|
|
693
832
|
if (p !== null && p !== void 0 && p['schedule.ids']) {
|
|
694
|
-
var scheduleData =
|
|
833
|
+
var scheduleData = _this4.getScheduleDataByIds(p['schedule.ids']);
|
|
695
834
|
p['_schedule'] = scheduleData;
|
|
696
835
|
}
|
|
697
836
|
});
|
|
@@ -706,15 +845,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
706
845
|
tempStartDate = startDate || (dateRange === null || dateRange === void 0 || (_dateRange$ = dateRange[0]) === null || _dateRange$ === void 0 ? void 0 : _dateRange$.date);
|
|
707
846
|
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);
|
|
708
847
|
if (tempProducts.length) {
|
|
709
|
-
|
|
848
|
+
_context15.next = 11;
|
|
710
849
|
break;
|
|
711
850
|
}
|
|
712
|
-
return
|
|
851
|
+
return _context15.abrupt("return", []);
|
|
713
852
|
case 11:
|
|
714
853
|
// 在这里需要把能收集到的数据都收集上来,拼装好给 date 模块去查询
|
|
715
854
|
_ref5 = getAvailableProductResources(tempProducts) || {}, resourceIds = _ref5.resourceIds, rules = _ref5.rules, resourcesMap = _ref5.resourcesMap;
|
|
716
855
|
this.otherParams.currentResourcesMap = resourcesMap;
|
|
717
|
-
|
|
856
|
+
_context15.next = 15;
|
|
718
857
|
return this.store.date.getResourceDates({
|
|
719
858
|
url: params.url,
|
|
720
859
|
query: {
|
|
@@ -726,13 +865,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
726
865
|
type: type
|
|
727
866
|
});
|
|
728
867
|
case 15:
|
|
729
|
-
res =
|
|
730
|
-
return
|
|
868
|
+
res = _context15.sent;
|
|
869
|
+
return _context15.abrupt("return", res);
|
|
731
870
|
case 17:
|
|
732
871
|
case "end":
|
|
733
|
-
return
|
|
872
|
+
return _context15.stop();
|
|
734
873
|
}
|
|
735
|
-
},
|
|
874
|
+
}, _callee14, this);
|
|
736
875
|
}));
|
|
737
876
|
function getAvailableDate() {
|
|
738
877
|
return _getAvailableDate.apply(this, arguments);
|
|
@@ -745,22 +884,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
745
884
|
}, {
|
|
746
885
|
key: "getSummary",
|
|
747
886
|
value: (function () {
|
|
748
|
-
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
887
|
+
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
749
888
|
var cartItems, summary;
|
|
750
|
-
return _regeneratorRuntime().wrap(function
|
|
751
|
-
while (1) switch (
|
|
889
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context16) {
|
|
890
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
752
891
|
case 0:
|
|
753
892
|
cartItems = this.store.cart.getItems();
|
|
754
|
-
|
|
893
|
+
_context16.next = 3;
|
|
755
894
|
return this.store.summary.getSummary(cartItems);
|
|
756
895
|
case 3:
|
|
757
|
-
summary =
|
|
758
|
-
return
|
|
896
|
+
summary = _context16.sent;
|
|
897
|
+
return _context16.abrupt("return", summary);
|
|
759
898
|
case 5:
|
|
760
899
|
case "end":
|
|
761
|
-
return
|
|
900
|
+
return _context16.stop();
|
|
762
901
|
}
|
|
763
|
-
},
|
|
902
|
+
}, _callee15, this);
|
|
764
903
|
}));
|
|
765
904
|
function getSummary() {
|
|
766
905
|
return _getSummary.apply(this, arguments);
|
|
@@ -774,18 +913,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
774
913
|
}, {
|
|
775
914
|
key: "getProtocol",
|
|
776
915
|
value: (function () {
|
|
777
|
-
var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
778
|
-
return _regeneratorRuntime().wrap(function
|
|
779
|
-
while (1) switch (
|
|
916
|
+
var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(protocolId) {
|
|
917
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context17) {
|
|
918
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
780
919
|
case 0:
|
|
781
|
-
return
|
|
920
|
+
return _context17.abrupt("return", this.store.summary.getProtocol(protocolId));
|
|
782
921
|
case 1:
|
|
783
922
|
case "end":
|
|
784
|
-
return
|
|
923
|
+
return _context17.stop();
|
|
785
924
|
}
|
|
786
|
-
},
|
|
925
|
+
}, _callee16, this);
|
|
787
926
|
}));
|
|
788
|
-
function getProtocol(
|
|
927
|
+
function getProtocol(_x14) {
|
|
789
928
|
return _getProtocol.apply(this, arguments);
|
|
790
929
|
}
|
|
791
930
|
return getProtocol;
|
|
@@ -794,16 +933,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
794
933
|
}, {
|
|
795
934
|
key: "getProducts",
|
|
796
935
|
value: function () {
|
|
797
|
-
var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
798
|
-
return _regeneratorRuntime().wrap(function
|
|
799
|
-
while (1) switch (
|
|
936
|
+
var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
937
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context18) {
|
|
938
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
800
939
|
case 0:
|
|
801
|
-
return
|
|
940
|
+
return _context18.abrupt("return", this.store.products.getProducts());
|
|
802
941
|
case 1:
|
|
803
942
|
case "end":
|
|
804
|
-
return
|
|
943
|
+
return _context18.stop();
|
|
805
944
|
}
|
|
806
|
-
},
|
|
945
|
+
}, _callee17, this);
|
|
807
946
|
}));
|
|
808
947
|
function getProducts() {
|
|
809
948
|
return _getProducts.apply(this, arguments);
|
|
@@ -813,41 +952,50 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
813
952
|
}, {
|
|
814
953
|
key: "setLoginAccount",
|
|
815
954
|
value: function () {
|
|
816
|
-
var _setLoginAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
817
|
-
var
|
|
818
|
-
var account, stateAccountId, cartItems;
|
|
819
|
-
return _regeneratorRuntime().wrap(function
|
|
820
|
-
while (1) switch (
|
|
955
|
+
var _setLoginAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(accountId, accountInfo) {
|
|
956
|
+
var _this5 = this;
|
|
957
|
+
var account, stateAccountId, cartItems, _this$store$date$getD2, date, _cartItems$2;
|
|
958
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context19) {
|
|
959
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
821
960
|
case 0:
|
|
822
961
|
account = this.store.accountList.getAccount(accountId);
|
|
823
962
|
if (!account) {
|
|
824
|
-
|
|
963
|
+
_context19.next = 11;
|
|
825
964
|
break;
|
|
826
965
|
}
|
|
827
966
|
stateAccountId = account.getId();
|
|
967
|
+
accountInfo.isLogin = true;
|
|
828
968
|
account.setAccountInfo(accountInfo);
|
|
829
969
|
// 然后去购物车,把原先关联了 holder_id 为 accountId 的商品,替换为 holder_id = accountInfo.id
|
|
830
970
|
cartItems = this.store.cart.getItems();
|
|
831
971
|
cartItems.forEach(function (item) {
|
|
832
972
|
if (item.holder_id === accountId) {
|
|
833
|
-
|
|
973
|
+
_this5.store.cart.updateItem({
|
|
834
974
|
_id: item._id,
|
|
835
975
|
account: accountInfo
|
|
836
976
|
});
|
|
837
977
|
}
|
|
838
978
|
});
|
|
839
979
|
this.store.accountList.updateAccountListById(stateAccountId, accountInfo);
|
|
840
|
-
|
|
980
|
+
if (cartItems.length) {
|
|
981
|
+
date = (_this$store$date$getD2 = this.store.date.getDateRange()) === null || _this$store$date$getD2 === void 0 || (_this$store$date$getD2 = _this$store$date$getD2[0]) === null || _this$store$date$getD2 === void 0 ? void 0 : _this$store$date$getD2.date;
|
|
982
|
+
if (!date) {
|
|
983
|
+
// 如果没有日期,则应该是 session 类先选商品的流程,直接从购物车里拿 start_date
|
|
984
|
+
date = (cartItems === null || cartItems === void 0 || (_cartItems$2 = cartItems[0]) === null || _cartItems$2 === void 0 ? void 0 : _cartItems$2.start_date) || '';
|
|
985
|
+
}
|
|
986
|
+
this.updateQuotationPriceAndCart(date);
|
|
987
|
+
}
|
|
988
|
+
_context19.next = 12;
|
|
841
989
|
break;
|
|
842
|
-
case
|
|
990
|
+
case 11:
|
|
843
991
|
throw new Error("\u6CA1\u6709\u627E\u5230".concat(accountId, "\u8D26\u6237"));
|
|
844
|
-
case
|
|
992
|
+
case 12:
|
|
845
993
|
case "end":
|
|
846
|
-
return
|
|
994
|
+
return _context19.stop();
|
|
847
995
|
}
|
|
848
|
-
},
|
|
996
|
+
}, _callee18, this);
|
|
849
997
|
}));
|
|
850
|
-
function setLoginAccount(
|
|
998
|
+
function setLoginAccount(_x15, _x16) {
|
|
851
999
|
return _setLoginAccount.apply(this, arguments);
|
|
852
1000
|
}
|
|
853
1001
|
return setLoginAccount;
|
|
@@ -855,14 +1003,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
855
1003
|
}, {
|
|
856
1004
|
key: "generateCartData",
|
|
857
1005
|
value: function () {
|
|
858
|
-
var _generateCartData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
859
|
-
return _regeneratorRuntime().wrap(function
|
|
860
|
-
while (1) switch (
|
|
1006
|
+
var _generateCartData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
1007
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context20) {
|
|
1008
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
861
1009
|
case 0:
|
|
862
1010
|
case "end":
|
|
863
|
-
return
|
|
1011
|
+
return _context20.stop();
|
|
864
1012
|
}
|
|
865
|
-
},
|
|
1013
|
+
}, _callee19);
|
|
866
1014
|
}));
|
|
867
1015
|
function generateCartData() {
|
|
868
1016
|
return _generateCartData.apply(this, arguments);
|
|
@@ -872,23 +1020,23 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
872
1020
|
}, {
|
|
873
1021
|
key: "getFreeProduct",
|
|
874
1022
|
value: function () {
|
|
875
|
-
var _getFreeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1023
|
+
var _getFreeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(id) {
|
|
876
1024
|
var res;
|
|
877
|
-
return _regeneratorRuntime().wrap(function
|
|
878
|
-
while (1) switch (
|
|
1025
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context21) {
|
|
1026
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
879
1027
|
case 0:
|
|
880
|
-
|
|
1028
|
+
_context21.next = 2;
|
|
881
1029
|
return this.request.post("/pay/order/free-pay/".concat(id));
|
|
882
1030
|
case 2:
|
|
883
|
-
res =
|
|
884
|
-
return
|
|
1031
|
+
res = _context21.sent;
|
|
1032
|
+
return _context21.abrupt("return", res);
|
|
885
1033
|
case 4:
|
|
886
1034
|
case "end":
|
|
887
|
-
return
|
|
1035
|
+
return _context21.stop();
|
|
888
1036
|
}
|
|
889
|
-
},
|
|
1037
|
+
}, _callee20, this);
|
|
890
1038
|
}));
|
|
891
|
-
function getFreeProduct(
|
|
1039
|
+
function getFreeProduct(_x17) {
|
|
892
1040
|
return _getFreeProduct.apply(this, arguments);
|
|
893
1041
|
}
|
|
894
1042
|
return getFreeProduct;
|
|
@@ -911,10 +1059,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
911
1059
|
}, {
|
|
912
1060
|
key: "submitOrder",
|
|
913
1061
|
value: function () {
|
|
914
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1062
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
915
1063
|
var cartItems, newCartItems;
|
|
916
|
-
return _regeneratorRuntime().wrap(function
|
|
917
|
-
while (1) switch (
|
|
1064
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context22) {
|
|
1065
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
918
1066
|
case 0:
|
|
919
1067
|
cartItems = this.store.cart.getItems();
|
|
920
1068
|
newCartItems = cloneDeep(cartItems); // 先整个临时的逻辑,把购物车里所有商品的资源给他格式化一下
|
|
@@ -940,16 +1088,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
940
1088
|
item._origin.metadata.capacity = formatCapacity;
|
|
941
1089
|
item._origin.number = currentCapacity;
|
|
942
1090
|
});
|
|
943
|
-
return
|
|
1091
|
+
return _context22.abrupt("return", this.store.order.submitOrder({
|
|
944
1092
|
query: {
|
|
945
1093
|
cartItems: newCartItems
|
|
946
1094
|
}
|
|
947
1095
|
}));
|
|
948
1096
|
case 4:
|
|
949
1097
|
case "end":
|
|
950
|
-
return
|
|
1098
|
+
return _context22.stop();
|
|
951
1099
|
}
|
|
952
|
-
},
|
|
1100
|
+
}, _callee21, this);
|
|
953
1101
|
}));
|
|
954
1102
|
function submitOrder() {
|
|
955
1103
|
return _submitOrder.apply(this, arguments);
|
|
@@ -959,14 +1107,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
959
1107
|
}, {
|
|
960
1108
|
key: "pay",
|
|
961
1109
|
value: function () {
|
|
962
|
-
var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
963
|
-
return _regeneratorRuntime().wrap(function
|
|
964
|
-
while (1) switch (
|
|
1110
|
+
var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
|
1111
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context23) {
|
|
1112
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
965
1113
|
case 0:
|
|
966
1114
|
case "end":
|
|
967
|
-
return
|
|
1115
|
+
return _context23.stop();
|
|
968
1116
|
}
|
|
969
|
-
},
|
|
1117
|
+
}, _callee22);
|
|
970
1118
|
}));
|
|
971
1119
|
function pay() {
|
|
972
1120
|
return _pay.apply(this, arguments);
|
|
@@ -976,14 +1124,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
976
1124
|
}, {
|
|
977
1125
|
key: "getPayInfo",
|
|
978
1126
|
value: function () {
|
|
979
|
-
var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
980
|
-
return _regeneratorRuntime().wrap(function
|
|
981
|
-
while (1) switch (
|
|
1127
|
+
var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
1128
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context24) {
|
|
1129
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
982
1130
|
case 0:
|
|
983
1131
|
case "end":
|
|
984
|
-
return
|
|
1132
|
+
return _context24.stop();
|
|
985
1133
|
}
|
|
986
|
-
},
|
|
1134
|
+
}, _callee23);
|
|
987
1135
|
}));
|
|
988
1136
|
function getPayInfo() {
|
|
989
1137
|
return _getPayInfo.apply(this, arguments);
|
|
@@ -993,15 +1141,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
993
1141
|
}, {
|
|
994
1142
|
key: "setOtherParams",
|
|
995
1143
|
value: function () {
|
|
996
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1144
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
|
|
997
1145
|
var _ref6,
|
|
998
1146
|
_ref6$cover,
|
|
999
1147
|
cover,
|
|
1000
|
-
|
|
1001
|
-
return _regeneratorRuntime().wrap(function
|
|
1002
|
-
while (1) switch (
|
|
1148
|
+
_args25 = arguments;
|
|
1149
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context25) {
|
|
1150
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1003
1151
|
case 0:
|
|
1004
|
-
_ref6 =
|
|
1152
|
+
_ref6 = _args25.length > 1 && _args25[1] !== undefined ? _args25[1] : {}, _ref6$cover = _ref6.cover, cover = _ref6$cover === void 0 ? false : _ref6$cover;
|
|
1005
1153
|
if (cover) {
|
|
1006
1154
|
this.otherParams = params;
|
|
1007
1155
|
} else {
|
|
@@ -1009,11 +1157,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1009
1157
|
}
|
|
1010
1158
|
case 2:
|
|
1011
1159
|
case "end":
|
|
1012
|
-
return
|
|
1160
|
+
return _context25.stop();
|
|
1013
1161
|
}
|
|
1014
|
-
},
|
|
1162
|
+
}, _callee24, this);
|
|
1015
1163
|
}));
|
|
1016
|
-
function setOtherParams(
|
|
1164
|
+
function setOtherParams(_x18) {
|
|
1017
1165
|
return _setOtherParams.apply(this, arguments);
|
|
1018
1166
|
}
|
|
1019
1167
|
return setOtherParams;
|
|
@@ -1021,16 +1169,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1021
1169
|
}, {
|
|
1022
1170
|
key: "getOtherParams",
|
|
1023
1171
|
value: function () {
|
|
1024
|
-
var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1025
|
-
return _regeneratorRuntime().wrap(function
|
|
1026
|
-
while (1) switch (
|
|
1172
|
+
var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
1173
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context26) {
|
|
1174
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
1027
1175
|
case 0:
|
|
1028
|
-
return
|
|
1176
|
+
return _context26.abrupt("return", this.otherParams);
|
|
1029
1177
|
case 1:
|
|
1030
1178
|
case "end":
|
|
1031
|
-
return
|
|
1179
|
+
return _context26.stop();
|
|
1032
1180
|
}
|
|
1033
|
-
},
|
|
1181
|
+
}, _callee25, this);
|
|
1034
1182
|
}));
|
|
1035
1183
|
function getOtherParams() {
|
|
1036
1184
|
return _getOtherParams.apply(this, arguments);
|
|
@@ -1040,7 +1188,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1040
1188
|
}, {
|
|
1041
1189
|
key: "updateCart",
|
|
1042
1190
|
value: function updateCart(params) {
|
|
1043
|
-
var
|
|
1191
|
+
var _this6 = this;
|
|
1044
1192
|
var targetCartItem = this.store.cart.getItem(params._id);
|
|
1045
1193
|
if (!targetCartItem) {
|
|
1046
1194
|
throw new Error("\u6CA1\u6709\u627E\u5230".concat(params._id, "\u8D2D\u7269\u8F66\u5546\u54C1"));
|
|
@@ -1129,7 +1277,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1129
1277
|
var end_time = item.end_time;
|
|
1130
1278
|
var start_date = item.start_date;
|
|
1131
1279
|
var end_date = item.end_date;
|
|
1132
|
-
|
|
1280
|
+
_this6.store.cart.updateItem({
|
|
1133
1281
|
_id: item._id,
|
|
1134
1282
|
resources: resources,
|
|
1135
1283
|
date: {
|
|
@@ -1138,7 +1286,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1138
1286
|
}
|
|
1139
1287
|
});
|
|
1140
1288
|
} else {
|
|
1141
|
-
|
|
1289
|
+
_this6.store.cart.updateItem({
|
|
1142
1290
|
_id: item._id,
|
|
1143
1291
|
resources: resources
|
|
1144
1292
|
});
|
|
@@ -1175,10 +1323,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1175
1323
|
}, {
|
|
1176
1324
|
key: "batchUpdateCart",
|
|
1177
1325
|
value: function batchUpdateCart(paramsList) {
|
|
1178
|
-
var
|
|
1326
|
+
var _this7 = this;
|
|
1179
1327
|
var cartItems = [];
|
|
1180
1328
|
paramsList.forEach(function (params) {
|
|
1181
|
-
var cartItem =
|
|
1329
|
+
var cartItem = _this7.store.cart.formatCartItem(params);
|
|
1182
1330
|
cartItems.push(cartItem);
|
|
1183
1331
|
});
|
|
1184
1332
|
this.store.cart.batchSetItems(cartItems);
|
|
@@ -1206,11 +1354,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1206
1354
|
}, {
|
|
1207
1355
|
key: "checkCartItems",
|
|
1208
1356
|
value: function checkCartItems(type) {
|
|
1209
|
-
var
|
|
1357
|
+
var _this8 = this;
|
|
1210
1358
|
var cartItems = this.store.cart.getItems();
|
|
1211
1359
|
var errorCartItemIds = [];
|
|
1212
1360
|
cartItems.forEach(function (cartItem) {
|
|
1213
|
-
var result =
|
|
1361
|
+
var result = _this8.store.cart.checkCartItemByType(cartItem, type);
|
|
1214
1362
|
if (!result) {
|
|
1215
1363
|
errorCartItemIds.push(cartItem._id);
|
|
1216
1364
|
}
|
|
@@ -1638,11 +1786,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1638
1786
|
// .format("HH:mm");
|
|
1639
1787
|
// 根据 start_time 和 end_time 去匹配资源
|
|
1640
1788
|
var targetResource = null;
|
|
1641
|
-
var
|
|
1642
|
-
|
|
1789
|
+
var _iterator3 = _createForOfIteratorHelper(resources),
|
|
1790
|
+
_step3;
|
|
1643
1791
|
try {
|
|
1644
|
-
var
|
|
1645
|
-
var n =
|
|
1792
|
+
var _loop2 = function _loop2() {
|
|
1793
|
+
var n = _step3.value;
|
|
1646
1794
|
// 如果资源是独占的,并且 countMap 里选择过这个资源,则直接跳过
|
|
1647
1795
|
// if (n.resourceType === 'single' && countMap[n.id]) {
|
|
1648
1796
|
// resourcesUseableMap[n.id] = false;
|
|
@@ -1681,15 +1829,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1681
1829
|
}
|
|
1682
1830
|
},
|
|
1683
1831
|
_ret;
|
|
1684
|
-
for (
|
|
1685
|
-
_ret =
|
|
1832
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
1833
|
+
_ret = _loop2();
|
|
1686
1834
|
if (_ret === 0) continue;
|
|
1687
1835
|
if (_ret === 1) break;
|
|
1688
1836
|
}
|
|
1689
1837
|
} catch (err) {
|
|
1690
|
-
|
|
1838
|
+
_iterator3.e(err);
|
|
1691
1839
|
} finally {
|
|
1692
|
-
|
|
1840
|
+
_iterator3.f();
|
|
1693
1841
|
}
|
|
1694
1842
|
return {
|
|
1695
1843
|
selectedResource: targetResource
|
|
@@ -1724,7 +1872,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1724
1872
|
key: "autoSelectAllProductResources",
|
|
1725
1873
|
value: function autoSelectAllProductResources(resources_code, timeSlots) {
|
|
1726
1874
|
var _dateRange$4,
|
|
1727
|
-
|
|
1875
|
+
_this9 = this;
|
|
1728
1876
|
var dateRange = this.store.date.getDateRange();
|
|
1729
1877
|
var resources = [];
|
|
1730
1878
|
if (dateRange !== null && dateRange !== void 0 && (_dateRange$4 = dateRange[0]) !== null && _dateRange$4 !== void 0 && _dateRange$4.date) {
|
|
@@ -1781,7 +1929,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1781
1929
|
};
|
|
1782
1930
|
}
|
|
1783
1931
|
// 如果传递了 timeSlots,代表是第二种资源,则直接拿 timeSlots 去匹配
|
|
1784
|
-
var res =
|
|
1932
|
+
var res = _this9.autoSelectAccountResources({
|
|
1785
1933
|
cartItem: item,
|
|
1786
1934
|
holder_id: item.holder_id,
|
|
1787
1935
|
resources_code: resources_code,
|
|
@@ -1801,7 +1949,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1801
1949
|
}
|
|
1802
1950
|
res.selectedResource.capacity = currentCapacity;
|
|
1803
1951
|
checkSubResourcesCapacity(res.selectedResource);
|
|
1804
|
-
|
|
1952
|
+
_this9.store.cart.updateItem({
|
|
1805
1953
|
_id: item._id,
|
|
1806
1954
|
// 这里要做去重,避免出现同样类型的资源被塞进同一个商品
|
|
1807
1955
|
resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
|
|
@@ -1816,7 +1964,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1816
1964
|
} else {
|
|
1817
1965
|
var _item$_productOrigin10, _productResources$fin;
|
|
1818
1966
|
// 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
|
|
1819
|
-
var allCartItems = cloneDeep(
|
|
1967
|
+
var allCartItems = cloneDeep(_this9.store.cart.getItems());
|
|
1820
1968
|
// 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
|
|
1821
1969
|
var selectedResources = [];
|
|
1822
1970
|
var _resources = cloneDeep(((_item$_productOrigin10 = item._productOrigin) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.product_resource) === null || _item$_productOrigin10 === void 0 ? void 0 : _item$_productOrigin10.resources) || []);
|
|
@@ -1875,7 +2023,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1875
2023
|
} else {
|
|
1876
2024
|
selectResourcesMap[targetResource.id] += currentCapacity;
|
|
1877
2025
|
}
|
|
1878
|
-
|
|
2026
|
+
_this9.store.cart.updateItem({
|
|
1879
2027
|
_id: item._id,
|
|
1880
2028
|
resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
|
|
1881
2029
|
return existingRes.resourceType !== targetRenderList[0].resourceType;
|
|
@@ -1893,7 +2041,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1893
2041
|
// 如果购物车里没有 holderid数据,证明不按 holder 类流程预约走,给所有购物车一次性分派即可,不做账号下资源互斥逻辑
|
|
1894
2042
|
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
1895
2043
|
accountList.forEach(function (account) {
|
|
1896
|
-
var cartItems =
|
|
2044
|
+
var cartItems = _this9.store.cart.getCartByAccount(account.getId());
|
|
1897
2045
|
selectForCartResources(cartItems);
|
|
1898
2046
|
});
|
|
1899
2047
|
} else {
|
|
@@ -1908,9 +2056,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1908
2056
|
key: "getTimeSlotByAllResources",
|
|
1909
2057
|
value: function getTimeSlotByAllResources(resources_code) {
|
|
1910
2058
|
var _dateRange,
|
|
1911
|
-
|
|
1912
|
-
_cartItems
|
|
1913
|
-
_cartItems$
|
|
2059
|
+
_this10 = this,
|
|
2060
|
+
_cartItems$3,
|
|
2061
|
+
_cartItems$4;
|
|
1914
2062
|
var dateRange = this.store.date.getDateRange();
|
|
1915
2063
|
// 取出购物车中所有一已选择的第一步资源
|
|
1916
2064
|
var resources = [];
|
|
@@ -1919,9 +2067,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1919
2067
|
var resourceIds = [];
|
|
1920
2068
|
var resourcesTypeId = undefined;
|
|
1921
2069
|
var isSingleResource = false;
|
|
2070
|
+
|
|
2071
|
+
// 找出购物车里最大的 cut_off_time
|
|
2072
|
+
var maxCutOffTime = undefined;
|
|
2073
|
+
var maxCutOffTimeValue = dayjs();
|
|
1922
2074
|
cartItems.forEach(function (item) {
|
|
1923
|
-
var _item$_productOrigin11, _item$_productOrigin12;
|
|
2075
|
+
var _item$_productOrigin11, _item$_productOrigin12, _item$_productOrigin13, _item$_productOrigin14;
|
|
1924
2076
|
(_item$_productOrigin11 = item._productOrigin) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.product_resource) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.resources) === null || _item$_productOrigin11 === void 0 || _item$_productOrigin11.forEach(function (n) {
|
|
2077
|
+
// TODO: 少了个 status 的判断
|
|
1925
2078
|
if (n.code === resources_code) {
|
|
1926
2079
|
resources.push.apply(resources, _toConsumableArray(n.renderList || []));
|
|
1927
2080
|
isSingleResource = n.type === 'single';
|
|
@@ -1936,6 +2089,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1936
2089
|
resourcesTypeId = item === null || item === void 0 || (_item$_productOrigin12 = item._productOrigin) === null || _item$_productOrigin12 === void 0 || (_item$_productOrigin12 = _item$_productOrigin12.product_resource) === null || _item$_productOrigin12 === void 0 || (_item$_productOrigin12 = _item$_productOrigin12.resources) === null || _item$_productOrigin12 === void 0 || (_item$_productOrigin12 = _item$_productOrigin12.find(function (n) {
|
|
1937
2090
|
return n.code === resources_code;
|
|
1938
2091
|
})) === null || _item$_productOrigin12 === void 0 ? void 0 : _item$_productOrigin12.id;
|
|
2092
|
+
if ((_item$_productOrigin13 = item._productOrigin) !== null && _item$_productOrigin13 !== void 0 && _item$_productOrigin13.cut_off_time && ((_item$_productOrigin14 = item._productOrigin) === null || _item$_productOrigin14 === void 0 ? void 0 : _item$_productOrigin14.cut_off_time.type) === 'advance') {
|
|
2093
|
+
var currentCutOffTime = dayjs().add(item._productOrigin.cut_off_time.unit, item._productOrigin.cut_off_time.unit_type);
|
|
2094
|
+
if (currentCutOffTime.isAfter(maxCutOffTimeValue, 'minute')) {
|
|
2095
|
+
maxCutOffTimeValue = currentCutOffTime;
|
|
2096
|
+
maxCutOffTime = item._productOrigin.cut_off_time;
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
1939
2099
|
});
|
|
1940
2100
|
// 保险起见,在这里如果 dateRange 里也有 resources 的话,也 push 进去
|
|
1941
2101
|
if ((_dateRange = dateRange) !== null && _dateRange !== void 0 && (_dateRange = _dateRange[0]) !== null && _dateRange !== void 0 && (_dateRange = _dateRange.resource) !== null && _dateRange !== void 0 && _dateRange.length) {
|
|
@@ -1957,13 +2117,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1957
2117
|
cartItems.forEach(function (item) {
|
|
1958
2118
|
// 单个预约累加账号 多个预约取最大值
|
|
1959
2119
|
if (isSingleResource) {
|
|
1960
|
-
var _item$_productOrigin$3, _item$
|
|
1961
|
-
accountDuration += (_item$_productOrigin$3 = (_item$
|
|
2120
|
+
var _item$_productOrigin$3, _item$_productOrigin15;
|
|
2121
|
+
accountDuration += (_item$_productOrigin$3 = (_item$_productOrigin15 = item._productOrigin) === null || _item$_productOrigin15 === void 0 || (_item$_productOrigin15 = _item$_productOrigin15.duration) === null || _item$_productOrigin15 === void 0 ? void 0 : _item$_productOrigin15.value) !== null && _item$_productOrigin$3 !== void 0 ? _item$_productOrigin$3 : 0;
|
|
1962
2122
|
} else {
|
|
1963
|
-
var _item$_productOrigin$4, _item$
|
|
1964
|
-
if (accountDuration < ((_item$_productOrigin$4 = (_item$
|
|
1965
|
-
var _item$_productOrigin$5, _item$
|
|
1966
|
-
accountDuration = (_item$_productOrigin$5 = (_item$
|
|
2123
|
+
var _item$_productOrigin$4, _item$_productOrigin16;
|
|
2124
|
+
if (accountDuration < ((_item$_productOrigin$4 = (_item$_productOrigin16 = item._productOrigin) === null || _item$_productOrigin16 === void 0 || (_item$_productOrigin16 = _item$_productOrigin16.duration) === null || _item$_productOrigin16 === void 0 ? void 0 : _item$_productOrigin16.value) !== null && _item$_productOrigin$4 !== void 0 ? _item$_productOrigin$4 : 0)) {
|
|
2125
|
+
var _item$_productOrigin$5, _item$_productOrigin17;
|
|
2126
|
+
accountDuration = (_item$_productOrigin$5 = (_item$_productOrigin17 = item._productOrigin) === null || _item$_productOrigin17 === void 0 || (_item$_productOrigin17 = _item$_productOrigin17.duration) === null || _item$_productOrigin17 === void 0 ? void 0 : _item$_productOrigin17.value) !== null && _item$_productOrigin$5 !== void 0 ? _item$_productOrigin$5 : 0;
|
|
1967
2127
|
}
|
|
1968
2128
|
}
|
|
1969
2129
|
});
|
|
@@ -1973,7 +2133,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1973
2133
|
};
|
|
1974
2134
|
if (cartItems !== null && cartItems !== void 0 && cartItems[0].holder_id) {
|
|
1975
2135
|
accountList.forEach(function (account) {
|
|
1976
|
-
var cartItems =
|
|
2136
|
+
var cartItems = _this10.store.cart.getCartByAccount(account.getId());
|
|
1977
2137
|
checkDuration(cartItems);
|
|
1978
2138
|
});
|
|
1979
2139
|
} else {
|
|
@@ -1981,18 +2141,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1981
2141
|
}
|
|
1982
2142
|
// 如果 cartItem 上既没有时间,也没有资源,认为外部属于异常调用,直接丢一个空数组出去
|
|
1983
2143
|
// 同时 session 类商品的流程也不应该调用这个方法
|
|
1984
|
-
if (!(cartItems !== null && cartItems !== void 0 && (_cartItems$ = cartItems[0]) !== null && _cartItems$ !== void 0 && _cartItems
|
|
2144
|
+
if (!(cartItems !== null && cartItems !== void 0 && (_cartItems$3 = cartItems[0]) !== null && _cartItems$3 !== void 0 && _cartItems$3.start_date) && !(cartItems !== null && cartItems !== void 0 && (_cartItems$4 = cartItems[0]) !== null && _cartItems$4 !== void 0 && _cartItems$4.resource_id) || !(cartItems !== null && cartItems !== void 0 && cartItems[0].duration)) {
|
|
1985
2145
|
return [];
|
|
1986
2146
|
}
|
|
1987
2147
|
if (cartItems !== null && cartItems !== void 0 && cartItems[0].start_date && !dateRange) {
|
|
1988
|
-
var _cartItems$
|
|
2148
|
+
var _cartItems$5, _cartItems$6;
|
|
1989
2149
|
dateRange = [{
|
|
1990
2150
|
date: cartItems === null || cartItems === void 0 ? void 0 : cartItems[0].start_date,
|
|
1991
2151
|
status: 'available',
|
|
1992
2152
|
week: '',
|
|
1993
2153
|
weekNum: 0
|
|
1994
2154
|
}, {
|
|
1995
|
-
date: (cartItems === null || cartItems === void 0 || (_cartItems$
|
|
2155
|
+
date: (cartItems === null || cartItems === void 0 || (_cartItems$5 = cartItems[0]) === null || _cartItems$5 === void 0 ? void 0 : _cartItems$5.end_date) || (cartItems === null || cartItems === void 0 || (_cartItems$6 = cartItems[0]) === null || _cartItems$6 === void 0 ? void 0 : _cartItems$6.start_date) || '',
|
|
1996
2156
|
status: 'available',
|
|
1997
2157
|
week: '',
|
|
1998
2158
|
weekNum: 0
|
|
@@ -2005,7 +2165,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2005
2165
|
duration: duration,
|
|
2006
2166
|
currentDate: dateRange[0].date,
|
|
2007
2167
|
split: 10,
|
|
2008
|
-
resourcesUseableMap: resourcesUseableMap
|
|
2168
|
+
resourcesUseableMap: resourcesUseableMap,
|
|
2169
|
+
cut_off_time: maxCutOffTime
|
|
2009
2170
|
});
|
|
2010
2171
|
return timeSlots;
|
|
2011
2172
|
}
|
|
@@ -2014,7 +2175,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2014
2175
|
}, {
|
|
2015
2176
|
key: "submitTimeSlot",
|
|
2016
2177
|
value: function submitTimeSlot(timeSlots) {
|
|
2017
|
-
var
|
|
2178
|
+
var _this11 = this;
|
|
2018
2179
|
// 以账号为维度处理数据。购物车里每一项的 startTime应该是前一个商品的 endTime,如果是第一个商品则用 timeSlots.start_at
|
|
2019
2180
|
var cartItems = cloneDeep(this.store.cart.getItems());
|
|
2020
2181
|
|
|
@@ -2035,12 +2196,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2035
2196
|
var _newResources$;
|
|
2036
2197
|
var newResources = cloneDeep(item._origin.resources);
|
|
2037
2198
|
newResources.forEach(function (resource) {
|
|
2038
|
-
var _item$_productOrigin$6, _item$
|
|
2199
|
+
var _item$_productOrigin$6, _item$_productOrigin18, _ref11, _item$_productOrigin19;
|
|
2039
2200
|
resource.startTime = currentStartTime;
|
|
2040
|
-
resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$6 = (_item$
|
|
2201
|
+
resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$6 = (_item$_productOrigin18 = item._productOrigin) === null || _item$_productOrigin18 === void 0 || (_item$_productOrigin18 = _item$_productOrigin18.duration) === null || _item$_productOrigin18 === void 0 ? void 0 : _item$_productOrigin18.value) !== null && _item$_productOrigin$6 !== void 0 ? _item$_productOrigin$6 : 0, (_ref11 = (_item$_productOrigin19 = item._productOrigin) === null || _item$_productOrigin19 === void 0 || (_item$_productOrigin19 = _item$_productOrigin19.duration) === null || _item$_productOrigin19 === void 0 ? void 0 : _item$_productOrigin19.type) !== null && _ref11 !== void 0 ? _ref11 : 'minutes').format('YYYY-MM-DD HH:mm');
|
|
2041
2202
|
delete resource.times;
|
|
2042
2203
|
});
|
|
2043
|
-
|
|
2204
|
+
_this11.store.cart.updateItem({
|
|
2044
2205
|
_id: item._id,
|
|
2045
2206
|
resources: newResources
|
|
2046
2207
|
});
|
|
@@ -2088,15 +2249,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2088
2249
|
}, {
|
|
2089
2250
|
key: "openProductDetail",
|
|
2090
2251
|
value: function () {
|
|
2091
|
-
var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2252
|
+
var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(productId) {
|
|
2092
2253
|
var targetProduct, targetProductData, newScheduleArr;
|
|
2093
|
-
return _regeneratorRuntime().wrap(function
|
|
2094
|
-
while (1) switch (
|
|
2254
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context27) {
|
|
2255
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
2095
2256
|
case 0:
|
|
2096
|
-
|
|
2257
|
+
_context27.next = 2;
|
|
2097
2258
|
return this.store.products.getProduct(productId);
|
|
2098
2259
|
case 2:
|
|
2099
|
-
targetProduct =
|
|
2260
|
+
targetProduct = _context27.sent;
|
|
2100
2261
|
if (targetProduct) {
|
|
2101
2262
|
targetProductData = targetProduct.getData();
|
|
2102
2263
|
this.store.currentProduct = targetProduct;
|
|
@@ -2105,11 +2266,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2105
2266
|
}
|
|
2106
2267
|
case 4:
|
|
2107
2268
|
case "end":
|
|
2108
|
-
return
|
|
2269
|
+
return _context27.stop();
|
|
2109
2270
|
}
|
|
2110
|
-
},
|
|
2271
|
+
}, _callee26, this);
|
|
2111
2272
|
}));
|
|
2112
|
-
function openProductDetail(
|
|
2273
|
+
function openProductDetail(_x19) {
|
|
2113
2274
|
return _openProductDetail.apply(this, arguments);
|
|
2114
2275
|
}
|
|
2115
2276
|
return openProductDetail;
|
|
@@ -2127,9 +2288,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2127
2288
|
var _this$store$currentPr2;
|
|
2128
2289
|
var date = _ref12.date,
|
|
2129
2290
|
scheduleIds = _ref12.scheduleIds,
|
|
2130
|
-
resources = _ref12.resources
|
|
2291
|
+
resources = _ref12.resources,
|
|
2292
|
+
product = _ref12.product;
|
|
2131
2293
|
var targetProduct = this.store.currentProduct;
|
|
2132
|
-
|
|
2294
|
+
// 如果外面传递了product 优先用外面的
|
|
2295
|
+
var targetProductData = product || (targetProduct === null || targetProduct === void 0 ? void 0 : targetProduct.getData());
|
|
2133
2296
|
var targetSchedules = [];
|
|
2134
2297
|
// 如果外面传递了 scheduleIds,优先取入参
|
|
2135
2298
|
if (scheduleIds !== null && scheduleIds !== void 0 && scheduleIds.length) {
|
|
@@ -2176,7 +2339,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2176
2339
|
// time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
|
|
2177
2340
|
// 需要判断 time 的开始结束时间 是否包含timeSlice的开始结束时间
|
|
2178
2341
|
var mTimes = m.times.filter(function (n) {
|
|
2179
|
-
return !dayjs(n.start_at).isAfter(dayjs(item.start)) && !dayjs(n.end_at).isBefore(dayjs(item.end));
|
|
2342
|
+
return !dayjs(n.start_at).isAfter(dayjs(item.start), 'minute') && !dayjs(n.end_at).isBefore(dayjs(item.end), 'minute');
|
|
2180
2343
|
});
|
|
2181
2344
|
// 如果在这个区间的时间一个都没有,可以直接认为这个资源不可用
|
|
2182
2345
|
if (mTimes.length === 0) {
|
|
@@ -2227,7 +2390,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2227
2390
|
}, {
|
|
2228
2391
|
key: "addProductToCart",
|
|
2229
2392
|
value: function addProductToCart(_ref13) {
|
|
2230
|
-
var
|
|
2393
|
+
var _this12 = this;
|
|
2231
2394
|
var product = _ref13.product,
|
|
2232
2395
|
date = _ref13.date,
|
|
2233
2396
|
account = _ref13.account;
|
|
@@ -2260,7 +2423,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2260
2423
|
});
|
|
2261
2424
|
if (cartItemsByDate.length) {
|
|
2262
2425
|
cartItemsByDate.forEach(function (n) {
|
|
2263
|
-
|
|
2426
|
+
_this12.store.cart.removeItem(n._id);
|
|
2264
2427
|
});
|
|
2265
2428
|
}
|
|
2266
2429
|
}
|
|
@@ -2286,29 +2449,29 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2286
2449
|
}, {
|
|
2287
2450
|
key: "getProductTypeById",
|
|
2288
2451
|
value: function () {
|
|
2289
|
-
var _getProductTypeById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2452
|
+
var _getProductTypeById = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(id) {
|
|
2290
2453
|
var product;
|
|
2291
|
-
return _regeneratorRuntime().wrap(function
|
|
2292
|
-
while (1) switch (
|
|
2454
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context28) {
|
|
2455
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
2293
2456
|
case 0:
|
|
2294
|
-
|
|
2457
|
+
_context28.next = 2;
|
|
2295
2458
|
return this.store.products.getProduct(id);
|
|
2296
2459
|
case 2:
|
|
2297
|
-
product =
|
|
2460
|
+
product = _context28.sent;
|
|
2298
2461
|
if (!product) {
|
|
2299
|
-
|
|
2462
|
+
_context28.next = 5;
|
|
2300
2463
|
break;
|
|
2301
2464
|
}
|
|
2302
|
-
return
|
|
2465
|
+
return _context28.abrupt("return", product.getProductType());
|
|
2303
2466
|
case 5:
|
|
2304
|
-
return
|
|
2467
|
+
return _context28.abrupt("return", 'normal');
|
|
2305
2468
|
case 6:
|
|
2306
2469
|
case "end":
|
|
2307
|
-
return
|
|
2470
|
+
return _context28.stop();
|
|
2308
2471
|
}
|
|
2309
|
-
},
|
|
2472
|
+
}, _callee27, this);
|
|
2310
2473
|
}));
|
|
2311
|
-
function getProductTypeById(
|
|
2474
|
+
function getProductTypeById(_x20) {
|
|
2312
2475
|
return _getProductTypeById.apply(this, arguments);
|
|
2313
2476
|
}
|
|
2314
2477
|
return getProductTypeById;
|