@pisell/pisellos 0.0.38 → 2.0.1

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.
Files changed (45) hide show
  1. package/dist/modules/Cart/types.d.ts +0 -4
  2. package/dist/modules/Cart/utils.js +11 -25
  3. package/dist/modules/Product/index.d.ts +0 -10
  4. package/dist/modules/Product/index.js +0 -13
  5. package/dist/modules/Product/types.d.ts +0 -4
  6. package/dist/modules/Resource/types.d.ts +0 -1
  7. package/dist/modules/index.d.ts +0 -10
  8. package/dist/modules/index.js +1 -11
  9. package/dist/solution/BookingByStep/index.d.ts +3 -13
  10. package/dist/solution/BookingByStep/index.js +163 -300
  11. package/dist/solution/BookingByStep/types.d.ts +10 -3
  12. package/dist/solution/BookingByStep/types.js +7 -3
  13. package/dist/solution/BookingByStep/utils/resources.d.ts +4 -45
  14. package/dist/solution/BookingByStep/utils/resources.js +33 -167
  15. package/lib/modules/Cart/types.d.ts +0 -4
  16. package/lib/modules/Cart/utils.js +11 -26
  17. package/lib/modules/Product/index.d.ts +0 -10
  18. package/lib/modules/Product/index.js +0 -3
  19. package/lib/modules/Product/types.d.ts +0 -4
  20. package/lib/modules/Resource/types.d.ts +0 -1
  21. package/lib/modules/index.d.ts +0 -10
  22. package/lib/modules/index.js +1 -21
  23. package/lib/solution/BookingByStep/index.d.ts +3 -13
  24. package/lib/solution/BookingByStep/index.js +36 -91
  25. package/lib/solution/BookingByStep/types.d.ts +10 -3
  26. package/lib/solution/BookingByStep/types.js +12 -8
  27. package/lib/solution/BookingByStep/utils/resources.d.ts +4 -45
  28. package/lib/solution/BookingByStep/utils/resources.js +25 -115
  29. package/package.json +2 -2
  30. package/dist/modules/Schedule/index.d.ts +0 -13
  31. package/dist/modules/Schedule/index.js +0 -71
  32. package/dist/modules/Schedule/type.d.ts +0 -157
  33. package/dist/modules/Schedule/type.js +0 -1
  34. package/dist/modules/Schedule/types.d.ts +0 -182
  35. package/dist/modules/Schedule/types.js +0 -1
  36. package/dist/modules/Schedule/utils.d.ts +0 -61
  37. package/dist/modules/Schedule/utils.js +0 -700
  38. package/lib/modules/Schedule/index.d.ts +0 -13
  39. package/lib/modules/Schedule/index.js +0 -50
  40. package/lib/modules/Schedule/type.d.ts +0 -157
  41. package/lib/modules/Schedule/type.js +0 -17
  42. package/lib/modules/Schedule/types.d.ts +0 -182
  43. package/lib/modules/Schedule/types.js +0 -17
  44. package/lib/modules/Schedule/utils.d.ts +0 -61
  45. package/lib/modules/Schedule/utils.js +0 -572
@@ -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, formatDefaultCapacitys, getSumCapacity, checkSubResourcesCapacity } from "./utils/resources";
30
+ import { getResourcesByProduct, getTimeSlicesByResource, getTimeSlicesByResources, getIsUsableByTimeItem } from "./utils/resources";
31
31
  import dayjs from "dayjs";
32
32
  import { getResourcesMap } from "../../modules/Resource/utils";
33
33
  import { cloneDeep } from "lodash-es";
@@ -89,7 +89,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
89
89
  targetCacheData = data[this.otherParams.cacheId];
90
90
  }
91
91
  }
92
- moduleArr = ["accountList", "cart", "schedule", "summary", "step", "products", "date", "order", "payment"];
92
+ moduleArr = ["accountList", "cart", "summary", "step", "products", "date", "order", "payment"];
93
93
  moduleArr.forEach(function (step) {
94
94
  var targetModule = createModule(step, _this2.name);
95
95
  if (targetModule) {
@@ -108,8 +108,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
108
108
  }
109
109
  });
110
110
  this.core.effects.emit(BookingByStepHooks.onInited, {});
111
- this.loadAllSchedule();
112
- case 16:
111
+ case 15:
113
112
  case "end":
114
113
  return _context.stop();
115
114
  }
@@ -171,16 +170,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
171
170
  key: "loadProducts",
172
171
  value: function () {
173
172
  var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
174
- var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, _ref$schedule_ids, schedule_ids, productsData;
173
+ var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, productsData;
175
174
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
176
175
  while (1) switch (_context2.prev = _context2.next) {
177
176
  case 0:
178
- _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, _ref$schedule_ids = _ref.schedule_ids, schedule_ids = _ref$schedule_ids === void 0 ? [] : _ref$schedule_ids;
177
+ _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;
179
178
  _context2.next = 3;
180
179
  return this.request.post("/product/query", {
181
180
  open_quotation: 1,
182
181
  open_bundle: 1,
183
- extension_type: ["product_appointment", "appointment_ticket", "session_product"],
182
+ extension_type: ["product_appointment", "appointment_ticket"],
184
183
  with: ["category", "collection"],
185
184
  status: "published",
186
185
  num: 500,
@@ -188,8 +187,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
188
187
  category_ids: category_ids,
189
188
  ids: product_ids,
190
189
  collection: collection,
191
- front_end_cache_id: this.cacheId,
192
- schedule_ids: schedule_ids
190
+ front_end_cache_id: this.cacheId
193
191
  }, {
194
192
  useCache: true
195
193
  });
@@ -209,90 +207,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
209
207
  return loadProducts;
210
208
  }()
211
209
  }, {
212
- key: "loadProductByScheduleDate",
213
- value: function loadProductByScheduleDate(date) {
214
- var scheduleList = this.store.schedule.getAvailabilityDateList();
215
- var scheduleIds = scheduleList.filter(function (n) {
216
- return n.date === date;
217
- }).flatMap(function (n) {
218
- return n.schedule_id;
219
- });
220
- this.loadProducts({
221
- schedule_ids: scheduleIds
222
- });
223
- }
224
-
225
- // 加载当前店铺下所有 schedule
226
- }, {
227
- key: "loadAllSchedule",
210
+ key: "storeProduct",
228
211
  value: function () {
229
- var _loadAllSchedule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
230
- var scheduleList;
212
+ var _storeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(productData) {
213
+ var activeAccount, _ref2, bundle, options, origin, product_variant_id, product;
231
214
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
232
215
  while (1) switch (_context3.prev = _context3.next) {
233
- case 0:
234
- _context3.next = 2;
235
- return this.request.get("/schedule");
236
- case 2:
237
- scheduleList = _context3.sent;
238
- this.store.schedule.setScheduleList(scheduleList.data);
239
- case 4:
240
- case "end":
241
- return _context3.stop();
242
- }
243
- }, _callee3, this);
244
- }));
245
- function loadAllSchedule() {
246
- return _loadAllSchedule.apply(this, arguments);
247
- }
248
- return loadAllSchedule;
249
- }() // ui 层提供日期的起始范围,返回一个起始范围内日期的可用情况
250
- }, {
251
- key: "loadAvailableDate",
252
- value: function () {
253
- var _loadAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref2) {
254
- var startDate, endDate, custom_page_id, res;
255
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
256
- while (1) switch (_context4.prev = _context4.next) {
257
- case 0:
258
- startDate = _ref2.startDate, endDate = _ref2.endDate, custom_page_id = _ref2.custom_page_id;
259
- _context4.next = 3;
260
- return this.request.get("/schedule/product/availability", {
261
- start_date: startDate,
262
- end_date: endDate,
263
- custom_page_id: custom_page_id
264
- });
265
- case 3:
266
- res = _context4.sent;
267
- this.store.schedule.setAvailabilityDateList(res.data.date_list);
268
- case 5:
269
- case "end":
270
- return _context4.stop();
271
- }
272
- }, _callee4, this);
273
- }));
274
- function loadAvailableDate(_x4) {
275
- return _loadAvailableDate.apply(this, arguments);
276
- }
277
- return loadAvailableDate;
278
- }()
279
- }, {
280
- key: "storeProduct",
281
- value: function () {
282
- var _storeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(productData) {
283
- var activeAccount, _ref3, bundle, options, origin, product_variant_id, product;
284
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
285
- while (1) switch (_context5.prev = _context5.next) {
286
216
  case 0:
287
217
  // 往购物车加商品数据的时候,默认用当前 activeAccount 填充到 product 的 account 里面
288
218
  activeAccount = this.getActiveAccount();
289
219
  if (activeAccount) {
290
- _context5.next = 3;
220
+ _context3.next = 3;
291
221
  break;
292
222
  }
293
223
  throw new Error("没有找到当前账户");
294
224
  case 3:
295
- _ref3 = productData || {}, bundle = _ref3.bundle, options = _ref3.options, origin = _ref3.origin, product_variant_id = _ref3.product_variant_id;
225
+ _ref2 = productData || {}, bundle = _ref2.bundle, options = _ref2.options, origin = _ref2.origin, product_variant_id = _ref2.product_variant_id;
296
226
  product = _objectSpread(_objectSpread({}, origin), {}, {
297
227
  product_variant_id: product_variant_id
298
228
  });
@@ -304,11 +234,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
304
234
  });
305
235
  case 6:
306
236
  case "end":
307
- return _context5.stop();
237
+ return _context3.stop();
308
238
  }
309
- }, _callee5, this);
239
+ }, _callee3, this);
310
240
  }));
311
- function storeProduct(_x5) {
241
+ function storeProduct(_x4) {
312
242
  return _storeProduct.apply(this, arguments);
313
243
  }
314
244
  return storeProduct;
@@ -316,21 +246,21 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
316
246
  }, {
317
247
  key: "addAccount",
318
248
  value: function () {
319
- var _addAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(accounts) {
249
+ var _addAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(accounts) {
320
250
  var _this3 = this;
321
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
322
- while (1) switch (_context6.prev = _context6.next) {
251
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
252
+ while (1) switch (_context4.prev = _context4.next) {
323
253
  case 0:
324
254
  accounts.forEach(function (account) {
325
255
  _this3.store.accountList.addAccount(account);
326
256
  });
327
257
  case 1:
328
258
  case "end":
329
- return _context6.stop();
259
+ return _context4.stop();
330
260
  }
331
- }, _callee6);
261
+ }, _callee4);
332
262
  }));
333
- function addAccount(_x6) {
263
+ function addAccount(_x5) {
334
264
  return _addAccount.apply(this, arguments);
335
265
  }
336
266
  return addAccount;
@@ -338,20 +268,20 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
338
268
  }, {
339
269
  key: "getAccounts",
340
270
  value: function () {
341
- var _getAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
271
+ var _getAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
342
272
  var accounts;
343
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
344
- while (1) switch (_context7.prev = _context7.next) {
273
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
274
+ while (1) switch (_context5.prev = _context5.next) {
345
275
  case 0:
346
276
  accounts = this.store.accountList.getAccounts();
347
- return _context7.abrupt("return", accounts.map(function (account) {
277
+ return _context5.abrupt("return", accounts.map(function (account) {
348
278
  return account.getAccount();
349
279
  }));
350
280
  case 2:
351
281
  case "end":
352
- return _context7.stop();
282
+ return _context5.stop();
353
283
  }
354
- }, _callee7, this);
284
+ }, _callee5, this);
355
285
  }));
356
286
  function getAccounts() {
357
287
  return _getAccounts.apply(this, arguments);
@@ -389,18 +319,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
389
319
  }, {
390
320
  key: "setDateRange",
391
321
  value: function () {
392
- var _setDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(dateRange) {
393
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
394
- while (1) switch (_context8.prev = _context8.next) {
322
+ var _setDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(dateRange) {
323
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
324
+ while (1) switch (_context6.prev = _context6.next) {
395
325
  case 0:
396
326
  this.store.date.setDateRange(dateRange);
397
327
  case 1:
398
328
  case "end":
399
- return _context8.stop();
329
+ return _context6.stop();
400
330
  }
401
- }, _callee8, this);
331
+ }, _callee6, this);
402
332
  }));
403
- function setDateRange(_x7) {
333
+ function setDateRange(_x6) {
404
334
  return _setDateRange.apply(this, arguments);
405
335
  }
406
336
  return setDateRange;
@@ -415,16 +345,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
415
345
  }, {
416
346
  key: "getDateRange",
417
347
  value: function () {
418
- var _getDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
419
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
420
- while (1) switch (_context9.prev = _context9.next) {
348
+ var _getDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
349
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
350
+ while (1) switch (_context7.prev = _context7.next) {
421
351
  case 0:
422
- return _context9.abrupt("return", this.store.date.getDateRange());
352
+ return _context7.abrupt("return", this.store.date.getDateRange());
423
353
  case 1:
424
354
  case "end":
425
- return _context9.stop();
355
+ return _context7.stop();
426
356
  }
427
- }, _callee9, this);
357
+ }, _callee7, this);
428
358
  }));
429
359
  function getDateRange() {
430
360
  return _getDateRange.apply(this, arguments);
@@ -441,7 +371,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
441
371
  }, {
442
372
  key: "getAvailableDate",
443
373
  value: function () {
444
- var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
374
+ var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
445
375
  var _this$otherParams3, _this$otherParams4;
446
376
  var params,
447
377
  products,
@@ -450,16 +380,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
450
380
  tempProducts,
451
381
  tempStartDate,
452
382
  tempEndDate,
453
- _ref4,
383
+ _ref3,
454
384
  resourceIds,
455
385
  rules,
456
386
  resourcesMap,
457
387
  res,
458
- _args10 = arguments;
459
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
460
- while (1) switch (_context10.prev = _context10.next) {
388
+ _args8 = arguments;
389
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
390
+ while (1) switch (_context8.prev = _context8.next) {
461
391
  case 0:
462
- params = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : {};
392
+ params = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {};
463
393
  // 开始日期如果小于今天,直接以今天当做开始日期
464
394
  products = params.products, startDate = params.startDate, endDate = params.endDate;
465
395
  tempProducts = products || this.store.cart.getItems().map(function (p) {
@@ -468,16 +398,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
468
398
  tempStartDate = startDate || ((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 || (_this$otherParams3 = _this$otherParams3.dateRange) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3[0]);
469
399
  tempEndDate = endDate || ((_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 || (_this$otherParams4 = _this$otherParams4.dateRange) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4[1]);
470
400
  if (tempProducts.length) {
471
- _context10.next = 7;
401
+ _context8.next = 7;
472
402
  break;
473
403
  }
474
- return _context10.abrupt("return", []);
404
+ return _context8.abrupt("return", []);
475
405
  case 7:
476
406
  // 在这里需要把能收集到的数据都收集上来,拼装好给 date 模块去查询
477
- _ref4 = getAvailableProductResources(tempProducts) || {}, resourceIds = _ref4.resourceIds, rules = _ref4.rules, resourcesMap = _ref4.resourcesMap;
407
+ _ref3 = getAvailableProductResources(tempProducts) || {}, resourceIds = _ref3.resourceIds, rules = _ref3.rules, resourcesMap = _ref3.resourcesMap;
478
408
  console.log("resourceIds", tempProducts);
479
409
  this.otherParams.currentResourcesMap = resourcesMap;
480
- _context10.next = 12;
410
+ _context8.next = 12;
481
411
  return this.store.date.getMonthDates({
482
412
  query: {
483
413
  start_date: tempStartDate,
@@ -487,13 +417,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
487
417
  rules: rules
488
418
  });
489
419
  case 12:
490
- res = _context10.sent;
491
- return _context10.abrupt("return", res);
420
+ res = _context8.sent;
421
+ return _context8.abrupt("return", res);
492
422
  case 14:
493
423
  case "end":
494
- return _context10.stop();
424
+ return _context8.stop();
495
425
  }
496
- }, _callee10, this);
426
+ }, _callee8, this);
497
427
  }));
498
428
  function getAvailableDate() {
499
429
  return _getAvailableDate.apply(this, arguments);
@@ -506,22 +436,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
506
436
  }, {
507
437
  key: "getSummary",
508
438
  value: (function () {
509
- var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
439
+ var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
510
440
  var cartItems, summary;
511
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
512
- while (1) switch (_context11.prev = _context11.next) {
441
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
442
+ while (1) switch (_context9.prev = _context9.next) {
513
443
  case 0:
514
444
  cartItems = this.store.cart.getItems();
515
- _context11.next = 3;
445
+ _context9.next = 3;
516
446
  return this.store.summary.getSummary(cartItems);
517
447
  case 3:
518
- summary = _context11.sent;
519
- return _context11.abrupt("return", summary);
448
+ summary = _context9.sent;
449
+ return _context9.abrupt("return", summary);
520
450
  case 5:
521
451
  case "end":
522
- return _context11.stop();
452
+ return _context9.stop();
523
453
  }
524
- }, _callee11, this);
454
+ }, _callee9, this);
525
455
  }));
526
456
  function getSummary() {
527
457
  return _getSummary.apply(this, arguments);
@@ -532,16 +462,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
532
462
  }, {
533
463
  key: "getProducts",
534
464
  value: function () {
535
- var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
536
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
537
- while (1) switch (_context12.prev = _context12.next) {
465
+ var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
466
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
467
+ while (1) switch (_context10.prev = _context10.next) {
538
468
  case 0:
539
- return _context12.abrupt("return", this.store.products.getProducts());
469
+ return _context10.abrupt("return", this.store.products.getProducts());
540
470
  case 1:
541
471
  case "end":
542
- return _context12.stop();
472
+ return _context10.stop();
543
473
  }
544
- }, _callee12, this);
474
+ }, _callee10, this);
545
475
  }));
546
476
  function getProducts() {
547
477
  return _getProducts.apply(this, arguments);
@@ -551,15 +481,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
551
481
  }, {
552
482
  key: "setLoginAccount",
553
483
  value: function () {
554
- var _setLoginAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(accountId, accountInfo) {
484
+ var _setLoginAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(accountId, accountInfo) {
555
485
  var _this4 = this;
556
486
  var account, stateAccountId, cartItems;
557
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
558
- while (1) switch (_context13.prev = _context13.next) {
487
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
488
+ while (1) switch (_context11.prev = _context11.next) {
559
489
  case 0:
560
490
  account = this.store.accountList.getAccount(accountId);
561
491
  if (!account) {
562
- _context13.next = 9;
492
+ _context11.next = 9;
563
493
  break;
564
494
  }
565
495
  stateAccountId = account.getId();
@@ -575,17 +505,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
575
505
  }
576
506
  });
577
507
  this.store.accountList.updateAccountListById(stateAccountId, accountInfo);
578
- _context13.next = 10;
508
+ _context11.next = 10;
579
509
  break;
580
510
  case 9:
581
511
  throw new Error("\u6CA1\u6709\u627E\u5230".concat(accountId, "\u8D26\u6237"));
582
512
  case 10:
583
513
  case "end":
584
- return _context13.stop();
514
+ return _context11.stop();
585
515
  }
586
- }, _callee13, this);
516
+ }, _callee11, this);
587
517
  }));
588
- function setLoginAccount(_x8, _x9) {
518
+ function setLoginAccount(_x7, _x8) {
589
519
  return _setLoginAccount.apply(this, arguments);
590
520
  }
591
521
  return setLoginAccount;
@@ -593,14 +523,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
593
523
  }, {
594
524
  key: "generateCartData",
595
525
  value: function () {
596
- var _generateCartData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
597
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
598
- while (1) switch (_context14.prev = _context14.next) {
526
+ var _generateCartData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
527
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
528
+ while (1) switch (_context12.prev = _context12.next) {
599
529
  case 0:
600
530
  case "end":
601
- return _context14.stop();
531
+ return _context12.stop();
602
532
  }
603
- }, _callee14);
533
+ }, _callee12);
604
534
  }));
605
535
  function generateCartData() {
606
536
  return _generateCartData.apply(this, arguments);
@@ -610,23 +540,23 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
610
540
  }, {
611
541
  key: "getFreeProduct",
612
542
  value: function () {
613
- var _getFreeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(id) {
543
+ var _getFreeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(id) {
614
544
  var res;
615
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
616
- while (1) switch (_context15.prev = _context15.next) {
545
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
546
+ while (1) switch (_context13.prev = _context13.next) {
617
547
  case 0:
618
- _context15.next = 2;
548
+ _context13.next = 2;
619
549
  return this.request.post("/pay/order/free-pay/".concat(id));
620
550
  case 2:
621
- res = _context15.sent;
622
- return _context15.abrupt("return", res);
551
+ res = _context13.sent;
552
+ return _context13.abrupt("return", res);
623
553
  case 4:
624
554
  case "end":
625
- return _context15.stop();
555
+ return _context13.stop();
626
556
  }
627
- }, _callee15, this);
557
+ }, _callee13, this);
628
558
  }));
629
- function getFreeProduct(_x10) {
559
+ function getFreeProduct(_x9) {
630
560
  return _getFreeProduct.apply(this, arguments);
631
561
  }
632
562
  return getFreeProduct;
@@ -634,10 +564,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
634
564
  }, {
635
565
  key: "submitOrder",
636
566
  value: function () {
637
- var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
567
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
638
568
  var cartItems, newCartItems;
639
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
640
- while (1) switch (_context16.prev = _context16.next) {
569
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
570
+ while (1) switch (_context14.prev = _context14.next) {
641
571
  case 0:
642
572
  cartItems = this.store.cart.getItems();
643
573
  newCartItems = cloneDeep(cartItems); // 先整个临时的逻辑,把购物车里所有商品的资源给他格式化一下
@@ -650,16 +580,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
650
580
  return _objectSpread({}, newResourcesItem);
651
581
  });
652
582
  });
653
- return _context16.abrupt("return", this.store.order.commitOrder({
583
+ return _context14.abrupt("return", this.store.order.commitOrder({
654
584
  query: {
655
585
  cartItems: newCartItems
656
586
  }
657
587
  }));
658
588
  case 4:
659
589
  case "end":
660
- return _context16.stop();
590
+ return _context14.stop();
661
591
  }
662
- }, _callee16, this);
592
+ }, _callee14, this);
663
593
  }));
664
594
  function submitOrder() {
665
595
  return _submitOrder.apply(this, arguments);
@@ -669,14 +599,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
669
599
  }, {
670
600
  key: "pay",
671
601
  value: function () {
672
- var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
673
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
674
- while (1) switch (_context17.prev = _context17.next) {
602
+ var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
603
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
604
+ while (1) switch (_context15.prev = _context15.next) {
675
605
  case 0:
676
606
  case "end":
677
- return _context17.stop();
607
+ return _context15.stop();
678
608
  }
679
- }, _callee17);
609
+ }, _callee15);
680
610
  }));
681
611
  function pay() {
682
612
  return _pay.apply(this, arguments);
@@ -686,14 +616,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
686
616
  }, {
687
617
  key: "getPayInfo",
688
618
  value: function () {
689
- var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
690
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
691
- while (1) switch (_context18.prev = _context18.next) {
619
+ var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
620
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
621
+ while (1) switch (_context16.prev = _context16.next) {
692
622
  case 0:
693
623
  case "end":
694
- return _context18.stop();
624
+ return _context16.stop();
695
625
  }
696
- }, _callee18);
626
+ }, _callee16);
697
627
  }));
698
628
  function getPayInfo() {
699
629
  return _getPayInfo.apply(this, arguments);
@@ -703,15 +633,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
703
633
  }, {
704
634
  key: "setOtherParams",
705
635
  value: function () {
706
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
707
- var _ref5,
708
- _ref5$cover,
636
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
637
+ var _ref4,
638
+ _ref4$cover,
709
639
  cover,
710
- _args19 = arguments;
711
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
712
- while (1) switch (_context19.prev = _context19.next) {
640
+ _args17 = arguments;
641
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
642
+ while (1) switch (_context17.prev = _context17.next) {
713
643
  case 0:
714
- _ref5 = _args19.length > 1 && _args19[1] !== undefined ? _args19[1] : {}, _ref5$cover = _ref5.cover, cover = _ref5$cover === void 0 ? false : _ref5$cover;
644
+ _ref4 = _args17.length > 1 && _args17[1] !== undefined ? _args17[1] : {}, _ref4$cover = _ref4.cover, cover = _ref4$cover === void 0 ? false : _ref4$cover;
715
645
  if (cover) {
716
646
  this.otherParams = params;
717
647
  } else {
@@ -719,11 +649,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
719
649
  }
720
650
  case 2:
721
651
  case "end":
722
- return _context19.stop();
652
+ return _context17.stop();
723
653
  }
724
- }, _callee19, this);
654
+ }, _callee17, this);
725
655
  }));
726
- function setOtherParams(_x11) {
656
+ function setOtherParams(_x10) {
727
657
  return _setOtherParams.apply(this, arguments);
728
658
  }
729
659
  return setOtherParams;
@@ -731,16 +661,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
731
661
  }, {
732
662
  key: "getOtherParams",
733
663
  value: function () {
734
- var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
735
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
736
- while (1) switch (_context20.prev = _context20.next) {
664
+ var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
665
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
666
+ while (1) switch (_context18.prev = _context18.next) {
737
667
  case 0:
738
- return _context20.abrupt("return", this.otherParams);
668
+ return _context18.abrupt("return", this.otherParams);
739
669
  case 1:
740
670
  case "end":
741
- return _context20.stop();
671
+ return _context18.stop();
742
672
  }
743
- }, _callee20, this);
673
+ }, _callee18, this);
744
674
  }));
745
675
  function getOtherParams() {
746
676
  return _getOtherParams.apply(this, arguments);
@@ -762,15 +692,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
762
692
  if (item.holder_id !== (targetCartItem === null || targetCartItem === void 0 ? void 0 : targetCartItem.holder_id)) {
763
693
  var _item$_origin$resourc;
764
694
  var resources = (_item$_origin$resourc = item._origin.resources) === null || _item$_origin$resourc === void 0 ? void 0 : _item$_origin$resourc.filter(function (m) {
765
- // 检查当前资源是否与目标资源的任何资源匹配
766
695
  return !targetCartItem._origin.resources.some(function (targetRes) {
767
- var _targetRes$metadata$c, _m$metadata$combined_;
768
- // 检查主资源ID是否匹配
769
- if (targetRes.id === m.id) return true;
770
- // 检查组合资源的情况
771
- if (((_targetRes$metadata$c = targetRes.metadata.combined_resource) === null || _targetRes$metadata$c === void 0 ? void 0 : _targetRes$metadata$c.status) === 1 && targetRes.metadata.combined_resource.resource_ids.includes(m.id)) return true;
772
- 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;
773
- return false;
696
+ return targetRes.id === m.id;
774
697
  });
775
698
  });
776
699
  _this5.store.cart.updateItem({
@@ -852,18 +775,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
852
775
  var cartItems = this.store.cart.getItems();
853
776
  var arr = [];
854
777
  cartItems.forEach(function (cartItem) {
855
- var _cartItem$_productOri, _cartItem$_productOri2;
856
- // TODO:应该要优化下,理论上流程里不应该有holder_id 为空的购物车数据
857
- if (!cartItem.holder_id) return;
858
- var selectedResources = getOthersSelectedResources(cartItems, cartItem.holder_id, resourcesMap);
859
- var formatCapacity = formatDefaultCapacitys({
860
- capacity: (_cartItem$_productOri = cartItem._productOrigin) === null || _cartItem$_productOri === void 0 ? void 0 : _cartItem$_productOri.capacity,
861
- product_bundle: cartItem._origin.product.product_bundle
862
- });
863
- var currentCapacity = getSumCapacity({
864
- capacity: formatCapacity
865
- });
866
- 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);
778
+ var productResources = getResourcesByProduct(resourcesMap, cartItem, cartItems);
867
779
  arr.push({
868
780
  id: cartItem.id,
869
781
  // 这里返回的是购物车 id ,后面提交的时候要用的,用这个 id 绑定资源和时间
@@ -882,7 +794,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
882
794
  }, {
883
795
  key: "getResourcesListByCartItem",
884
796
  value: function getResourcesListByCartItem(id) {
885
- var _targetCartItem$_prod, _targetCartItem$_prod2;
886
797
  var cartItems = this.store.cart.getItems();
887
798
  var dateRange = this.store.date.getDateRange();
888
799
  var resources = [];
@@ -890,22 +801,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
890
801
  if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
891
802
  });
892
803
  var resourcesMap = getResourcesMap(resources);
804
+ var arr = [];
893
805
  var targetCartItem = cartItems.find(function (n) {
894
806
  return n._id === id;
895
807
  });
896
808
  if (!targetCartItem) {
897
809
  throw new Error("\u6CA1\u6709\u627E\u5230".concat(id, "\u8D2D\u7269\u8F66\u5546\u54C1"));
898
810
  }
899
- if (!targetCartItem.holder_id) return;
900
- var selectedResources = getOthersSelectedResources(cartItems, targetCartItem.holder_id, resourcesMap);
901
- var formatCapacity = formatDefaultCapacitys({
902
- capacity: (_targetCartItem$_prod = targetCartItem._productOrigin) === null || _targetCartItem$_prod === void 0 ? void 0 : _targetCartItem$_prod.capacity,
903
- product_bundle: targetCartItem._origin.product.product_bundle
904
- });
905
- var currentCapacity = getSumCapacity({
906
- capacity: formatCapacity
907
- });
908
- var productResources = getResourcesByProduct(resourcesMap, ((_targetCartItem$_prod2 = targetCartItem._productOrigin) === null || _targetCartItem$_prod2 === void 0 || (_targetCartItem$_prod2 = _targetCartItem$_prod2.product_resource) === null || _targetCartItem$_prod2 === void 0 ? void 0 : _targetCartItem$_prod2.resources) || [], selectedResources, currentCapacity);
811
+ var productResources = getResourcesByProduct(resourcesMap, targetCartItem, cartItems);
909
812
  if (productResources) {
910
813
  return {
911
814
  id: targetCartItem.id,
@@ -923,10 +826,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
923
826
  // 通过资源列表和指定的资源 id,获取指定资源的时间切片
924
827
  }, {
925
828
  key: "getResourceTimeSlot",
926
- value: function getResourceTimeSlot(_ref6) {
927
- var product = _ref6.product,
928
- resources = _ref6.resources,
929
- currentResourceId = _ref6.currentResourceId;
829
+ value: function getResourceTimeSlot(_ref5) {
830
+ var product = _ref5.product,
831
+ resources = _ref5.resources,
832
+ currentResourceId = _ref5.currentResourceId;
930
833
  var dateRange = this.store.date.getDateRange();
931
834
  var timeSlots = getTimeSlicesByResource({
932
835
  resource: resources.find(function (n) {
@@ -939,13 +842,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
939
842
  return timeSlots;
940
843
  }
941
844
 
942
- // 自动分派可用的资源-单种资源类型——此方法目前未使用,未经验证
845
+ // 自动分派可用的资源-单种资源类型
943
846
  }, {
944
847
  key: "autoSelectResource",
945
- value: function autoSelectResource(_ref7) {
946
- var resourceProductData = _ref7.resourceProductData,
947
- resources = _ref7.resources,
948
- timeSlots = _ref7.timeSlots;
848
+ value: function autoSelectResource(_ref6) {
849
+ var resourceProductData = _ref6.resourceProductData,
850
+ resources = _ref6.resources,
851
+ timeSlots = _ref6.timeSlots;
949
852
  var dateRange = this.store.date.getDateRange();
950
853
  if (timeSlots) {
951
854
  // 如果 start_time 存在,则直接根据 start_time 算出商品总共需要的时长,然后根据时长去匹配资源
@@ -1014,12 +917,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1014
917
  // 自动分派可用资源-pro 版,ui 传递某个账号,自动给某个账号下所有商品分配第一种资源
1015
918
  }, {
1016
919
  key: "autoSelectAccountResources",
1017
- value: function autoSelectAccountResources(_ref8) {
1018
- var holder_id = _ref8.holder_id,
1019
- resources_code = _ref8.resources_code,
1020
- timeSlots = _ref8.timeSlots,
1021
- countMap = _ref8.countMap,
1022
- capacity = _ref8.capacity;
920
+ value: function autoSelectAccountResources(_ref7) {
921
+ var _accountCartItems$0$_, _accountCartItems$;
922
+ var holder_id = _ref7.holder_id,
923
+ resources_code = _ref7.resources_code,
924
+ timeSlots = _ref7.timeSlots,
925
+ countMap = _ref7.countMap;
1023
926
  var dateRange = this.store.date.getDateRange();
1024
927
  var cartItems = this.store.cart.getItems();
1025
928
  // 取到账号下所有的商品,然后根据商品的 duration 和资源列表,获取所有可用的资源
@@ -1038,7 +941,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1038
941
  return acc + ((_n$_productOrigin$dur = (_n$_productOrigin = n._productOrigin) === null || _n$_productOrigin === void 0 || (_n$_productOrigin = _n$_productOrigin.duration) === null || _n$_productOrigin === void 0 ? void 0 : _n$_productOrigin.value) !== null && _n$_productOrigin$dur !== void 0 ? _n$_productOrigin$dur : 0);
1039
942
  }, 0);
1040
943
  // 正常来说,能进这个业务的所有商品的 duration 类型都是一样的,所以这里取第一个商品的 duration 类型
1041
- // let durationType = accountCartItems[0]?._productOrigin?.duration?.type ?? "minutes";
944
+ var durationType = (_accountCartItems$0$_ = (_accountCartItems$ = accountCartItems[0]) === null || _accountCartItems$ === void 0 || (_accountCartItems$ = _accountCartItems$._productOrigin) === null || _accountCartItems$ === void 0 || (_accountCartItems$ = _accountCartItems$.duration) === null || _accountCartItems$ === void 0 ? void 0 : _accountCartItems$.type) !== null && _accountCartItems$0$_ !== void 0 ? _accountCartItems$0$_ : "minutes";
1042
945
  // 取出账号下所对应类型的所有的可用资源
1043
946
  var resources = [];
1044
947
  accountCartItems.forEach(function (item) {
@@ -1070,7 +973,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1070
973
  timeSlice: timeSlots,
1071
974
  time: item,
1072
975
  resource: n,
1073
- currentCount: recordCount + (capacity || 0)
976
+ currentCount: recordCount + 1
1074
977
  });
1075
978
  return res.usable;
1076
979
  });
@@ -1100,8 +1003,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1100
1003
  resourcesMap: resourcesMap,
1101
1004
  duration: duration,
1102
1005
  currentDate: dateRange[0].date,
1103
- split: 10,
1104
- capacity: capacity
1006
+ split: 10
1105
1007
  });
1106
1008
  // 如果timeSlots返回了 空数组,代表没有可用的资源了
1107
1009
  if (!_timeSlots2) {
@@ -1130,25 +1032,19 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1130
1032
  var selectResourcesMap = {};
1131
1033
  this.store.accountList.getAccounts().forEach(function (account) {
1132
1034
  var cartItems = _this7.store.cart.getCartByAccount(account.getId());
1035
+ // 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
1036
+ var allCartItems = _this7.store.cart.getItems();
1133
1037
  var recordTimeSlots = cloneDeep(timeSlots);
1134
1038
  // timeSlots 传进来的只是用户选中的时间片,但是实际上需要根据多个商品时间进行累加
1135
1039
  // 假设 timeSlots.start_time 是15:40 duration 是 30min
1136
1040
  // 第一个商品分配完以后,第二个商品分配的start_time应该是第一个商品的 end_time ,然后 end_time 应该是 start_time+duration
1137
1041
 
1138
1042
  cartItems.forEach(function (item, index) {
1139
- var _item$_productOrigin2;
1140
- var formatCapacity = formatDefaultCapacitys({
1141
- capacity: (_item$_productOrigin2 = item._productOrigin) === null || _item$_productOrigin2 === void 0 ? void 0 : _item$_productOrigin2.capacity,
1142
- product_bundle: item._origin.product.product_bundle
1143
- });
1144
- var currentCapacity = getSumCapacity({
1145
- capacity: formatCapacity
1146
- });
1147
1043
  if (timeSlots) {
1148
1044
  if (index !== 0 && recordTimeSlots) {
1149
- var _item$_productOrigin$, _item$_productOrigin3, _ref9, _item$_productOrigin4, _item$_productOrigin$2, _item$_productOrigin5, _ref10, _item$_productOrigin6;
1150
- var start_at = dayjs(recordTimeSlots.end_time).add((_item$_productOrigin$ = (_item$_productOrigin3 = item._productOrigin) === null || _item$_productOrigin3 === void 0 || (_item$_productOrigin3 = _item$_productOrigin3.duration) === null || _item$_productOrigin3 === void 0 ? void 0 : _item$_productOrigin3.value) !== null && _item$_productOrigin$ !== void 0 ? _item$_productOrigin$ : 0, (_ref9 = (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.duration) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.type) !== null && _ref9 !== void 0 ? _ref9 : "minutes");
1151
- var end_at = start_at.add((_item$_productOrigin$2 = (_item$_productOrigin5 = item._productOrigin) === null || _item$_productOrigin5 === void 0 || (_item$_productOrigin5 = _item$_productOrigin5.duration) === null || _item$_productOrigin5 === void 0 ? void 0 : _item$_productOrigin5.value) !== null && _item$_productOrigin$2 !== void 0 ? _item$_productOrigin$2 : 0, (_ref10 = (_item$_productOrigin6 = item._productOrigin) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.duration) === null || _item$_productOrigin6 === void 0 ? void 0 : _item$_productOrigin6.type) !== null && _ref10 !== void 0 ? _ref10 : "minutes");
1045
+ var _item$_productOrigin$, _item$_productOrigin2, _ref8, _item$_productOrigin3, _item$_productOrigin$2, _item$_productOrigin4, _ref9, _item$_productOrigin5;
1046
+ var start_at = dayjs(recordTimeSlots.end_time).add((_item$_productOrigin$ = (_item$_productOrigin2 = item._productOrigin) === null || _item$_productOrigin2 === void 0 || (_item$_productOrigin2 = _item$_productOrigin2.duration) === null || _item$_productOrigin2 === void 0 ? void 0 : _item$_productOrigin2.value) !== null && _item$_productOrigin$ !== void 0 ? _item$_productOrigin$ : 0, (_ref8 = (_item$_productOrigin3 = item._productOrigin) === null || _item$_productOrigin3 === void 0 || (_item$_productOrigin3 = _item$_productOrigin3.duration) === null || _item$_productOrigin3 === void 0 ? void 0 : _item$_productOrigin3.type) !== null && _ref8 !== void 0 ? _ref8 : "minutes");
1047
+ var end_at = start_at.add((_item$_productOrigin$2 = (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.duration) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.value) !== null && _item$_productOrigin$2 !== void 0 ? _item$_productOrigin$2 : 0, (_ref9 = (_item$_productOrigin5 = item._productOrigin) === null || _item$_productOrigin5 === void 0 || (_item$_productOrigin5 = _item$_productOrigin5.duration) === null || _item$_productOrigin5 === void 0 ? void 0 : _item$_productOrigin5.type) !== null && _ref9 !== void 0 ? _ref9 : "minutes");
1152
1048
  recordTimeSlots = {
1153
1049
  start_time: start_at.format("HH:mm"),
1154
1050
  end_time: end_at.format("HH:mm"),
@@ -1161,8 +1057,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1161
1057
  holder_id: item.holder_id,
1162
1058
  resources_code: resources_code,
1163
1059
  timeSlots: recordTimeSlots,
1164
- countMap: selectResourcesMap,
1165
- capacity: currentCapacity
1060
+ countMap: selectResourcesMap
1166
1061
  });
1167
1062
  // // 如果购物车里已经有同类型的 form_id 的资源了,则不处理
1168
1063
  // if (item._origin.resources?.some((n: any) => n.form_id === res?.selectedResource?.form_id)) {
@@ -1170,12 +1065,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1170
1065
  // }
1171
1066
  if (res !== null && res !== void 0 && res.selectedResource) {
1172
1067
  if (!selectResourcesMap[res.selectedResource.id]) {
1173
- selectResourcesMap[res.selectedResource.id] = currentCapacity;
1068
+ selectResourcesMap[res.selectedResource.id] = 1;
1174
1069
  } else {
1175
- selectResourcesMap[res.selectedResource.id] += currentCapacity;
1070
+ selectResourcesMap[res.selectedResource.id]++;
1176
1071
  }
1177
- res.selectedResource.capacity = currentCapacity;
1178
- checkSubResourcesCapacity(res.selectedResource);
1072
+ console.log(_this7.store.cart.getItems());
1073
+ res.selectedResource.capacity = 1;
1179
1074
  _this7.store.cart.updateItem({
1180
1075
  _id: item._id,
1181
1076
  // 这里要做去重,避免出现同样类型的资源被塞进同一个商品
@@ -1183,18 +1078,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1183
1078
  return existingRes.form_id !== res.selectedResource.form_id;
1184
1079
  })), [res.selectedResource])
1185
1080
  });
1081
+ console.log(_this7.store.cart.getItems());
1186
1082
  } else {
1187
1083
  // 如果没有可用的技师了,推到错误列表里让 UI 去提示
1188
1084
  errorList.push(item._id);
1189
1085
  }
1190
1086
  } else {
1191
- var _item$_productOrigin7, _productResources$fin;
1192
- // 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
1193
- var allCartItems = _this7.store.cart.getItems();
1087
+ var _productResources$fin;
1194
1088
  // 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
1195
- if (!item.holder_id) return;
1196
- var selectedResources = getOthersSelectedResources(allCartItems, item.holder_id, resourcesMap);
1197
- var productResources = getResourcesByProduct(resourcesMap, ((_item$_productOrigin7 = item._productOrigin) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.product_resource) === null || _item$_productOrigin7 === void 0 ? void 0 : _item$_productOrigin7.resources) || [], selectedResources, currentCapacity);
1089
+ var productResources = getResourcesByProduct(resourcesMap, item, allCartItems);
1198
1090
  // 自动选择 productResources 中对应 resources_code 的资源
1199
1091
  var targetRenderList = (_productResources$fin = productResources.find(function (n) {
1200
1092
  return n.code === resources_code;
@@ -1208,16 +1100,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1208
1100
  return;
1209
1101
  }
1210
1102
  var targetResource = targetRenderList[0];
1211
- targetResource.capacity = currentCapacity;
1212
- // 在这里处理 children 的数据
1213
- checkSubResourcesCapacity(targetResource);
1103
+ targetResource.capacity = 1;
1214
1104
  _this7.store.cart.updateItem({
1215
1105
  _id: item._id,
1216
1106
  resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
1217
1107
  return existingRes.resourceType !== targetRenderList[0].resourceType;
1218
1108
  })), [targetResource])
1219
1109
  });
1220
- console.log(account, '已分配');
1221
1110
  } else {
1222
1111
  // 如果没有可用的技师了,推到错误列表里让 UI 去提示
1223
1112
  errorList.push(item._id);
@@ -1240,8 +1129,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1240
1129
  var cartItems = this.store.cart.getItems();
1241
1130
  var resourceIds = [];
1242
1131
  cartItems.forEach(function (item) {
1243
- var _item$_productOrigin8;
1244
- (_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.forEach(function (n) {
1132
+ var _item$_productOrigin6;
1133
+ (_item$_productOrigin6 = item._productOrigin) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.product_resource) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.resources) === null || _item$_productOrigin6 === void 0 || _item$_productOrigin6.forEach(function (n) {
1245
1134
  if (n.code === resources_code) {
1246
1135
  resources.push.apply(resources, _toConsumableArray(n.renderList || []));
1247
1136
  }
@@ -1260,8 +1149,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1260
1149
  var accountDuration = 0;
1261
1150
  var cartItems = _this8.store.cart.getCartByAccount(account.getId());
1262
1151
  cartItems.forEach(function (item) {
1263
- var _item$_productOrigin$3, _item$_productOrigin9;
1264
- accountDuration += (_item$_productOrigin$3 = (_item$_productOrigin9 = item._productOrigin) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.duration) === null || _item$_productOrigin9 === void 0 ? void 0 : _item$_productOrigin9.value) !== null && _item$_productOrigin$3 !== void 0 ? _item$_productOrigin$3 : 0;
1152
+ var _item$_productOrigin$3, _item$_productOrigin7;
1153
+ accountDuration += (_item$_productOrigin$3 = (_item$_productOrigin7 = item._productOrigin) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.duration) === null || _item$_productOrigin7 === void 0 ? void 0 : _item$_productOrigin7.value) !== null && _item$_productOrigin$3 !== void 0 ? _item$_productOrigin$3 : 0;
1265
1154
  });
1266
1155
  if (accountDuration > duration) {
1267
1156
  duration = accountDuration;
@@ -1301,9 +1190,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1301
1190
  accountItems.forEach(function (item, index) {
1302
1191
  var newResources = cloneDeep(item._origin.resources);
1303
1192
  newResources.forEach(function (resource) {
1304
- var _item$_productOrigin$4, _item$_productOrigin10, _ref11, _item$_productOrigin11;
1193
+ var _item$_productOrigin$4, _item$_productOrigin8, _ref10, _item$_productOrigin9;
1305
1194
  resource.startTime = currentStartTime;
1306
- resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$4 = (_item$_productOrigin10 = item._productOrigin) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.duration) === null || _item$_productOrigin10 === void 0 ? void 0 : _item$_productOrigin10.value) !== null && _item$_productOrigin$4 !== void 0 ? _item$_productOrigin$4 : 0, (_ref11 = (_item$_productOrigin11 = item._productOrigin) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.duration) === null || _item$_productOrigin11 === void 0 ? void 0 : _item$_productOrigin11.type) !== null && _ref11 !== void 0 ? _ref11 : "minutes").format("YYYY-MM-DD HH:mm");
1195
+ resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$4 = (_item$_productOrigin8 = item._productOrigin) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.duration) === null || _item$_productOrigin8 === void 0 ? void 0 : _item$_productOrigin8.value) !== null && _item$_productOrigin$4 !== void 0 ? _item$_productOrigin$4 : 0, (_ref10 = (_item$_productOrigin9 = item._productOrigin) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.duration) === null || _item$_productOrigin9 === void 0 ? void 0 : _item$_productOrigin9.type) !== null && _ref10 !== void 0 ? _ref10 : "minutes").format("YYYY-MM-DD HH:mm");
1307
1196
  delete resource.times;
1308
1197
  });
1309
1198
  _this9.store.cart.updateItem({
@@ -1324,32 +1213,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1324
1213
  }, {
1325
1214
  key: "clearCacheByModule",
1326
1215
  value: function clearCacheByModule(module) {}
1327
- }, {
1328
- key: "openProductDetail",
1329
- value: function () {
1330
- var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(productId) {
1331
- var targetProduct;
1332
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1333
- while (1) switch (_context21.prev = _context21.next) {
1334
- case 0:
1335
- _context21.next = 2;
1336
- return this.store.products.getProduct(productId);
1337
- case 2:
1338
- targetProduct = _context21.sent;
1339
- if (targetProduct) {
1340
- this.store.currentProduct = targetProduct;
1341
- }
1342
- case 4:
1343
- case "end":
1344
- return _context21.stop();
1345
- }
1346
- }, _callee21, this);
1347
- }));
1348
- function openProductDetail(_x12) {
1349
- return _openProductDetail.apply(this, arguments);
1350
- }
1351
- return openProductDetail;
1352
- }()
1353
1216
  }]);
1354
1217
  return BookingByStepImpl;
1355
1218
  }(BaseModule);