@pisell/pisellos 0.0.37 → 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 (47) hide show
  1. package/dist/modules/Cart/types.d.ts +0 -4
  2. package/dist/modules/Cart/utils.d.ts +0 -1
  3. package/dist/modules/Cart/utils.js +12 -23
  4. package/dist/modules/Product/index.d.ts +0 -10
  5. package/dist/modules/Product/index.js +0 -13
  6. package/dist/modules/Product/types.d.ts +0 -4
  7. package/dist/modules/Resource/types.d.ts +0 -1
  8. package/dist/modules/index.d.ts +0 -9
  9. package/dist/modules/index.js +1 -10
  10. package/dist/solution/BookingByStep/index.d.ts +5 -14
  11. package/dist/solution/BookingByStep/index.js +163 -284
  12. package/dist/solution/BookingByStep/types.d.ts +10 -2
  13. package/dist/solution/BookingByStep/types.js +7 -1
  14. package/dist/solution/BookingByStep/utils/resources.d.ts +4 -45
  15. package/dist/solution/BookingByStep/utils/resources.js +32 -153
  16. package/lib/modules/Cart/types.d.ts +0 -4
  17. package/lib/modules/Cart/utils.d.ts +0 -1
  18. package/lib/modules/Cart/utils.js +12 -24
  19. package/lib/modules/Product/index.d.ts +0 -10
  20. package/lib/modules/Product/index.js +0 -3
  21. package/lib/modules/Product/types.d.ts +0 -4
  22. package/lib/modules/Resource/types.d.ts +0 -1
  23. package/lib/modules/index.d.ts +0 -9
  24. package/lib/modules/index.js +1 -19
  25. package/lib/solution/BookingByStep/index.d.ts +5 -14
  26. package/lib/solution/BookingByStep/index.js +35 -84
  27. package/lib/solution/BookingByStep/types.d.ts +10 -2
  28. package/lib/solution/BookingByStep/types.js +12 -6
  29. package/lib/solution/BookingByStep/utils/resources.d.ts +4 -45
  30. package/lib/solution/BookingByStep/utils/resources.js +24 -101
  31. package/package.json +2 -2
  32. package/dist/modules/Schedule/index.d.ts +0 -10
  33. package/dist/modules/Schedule/index.js +0 -56
  34. package/dist/modules/Schedule/type.d.ts +0 -157
  35. package/dist/modules/Schedule/type.js +0 -1
  36. package/dist/modules/Schedule/types.d.ts +0 -177
  37. package/dist/modules/Schedule/types.js +0 -1
  38. package/dist/modules/Schedule/utils.d.ts +0 -61
  39. package/dist/modules/Schedule/utils.js +0 -700
  40. package/lib/modules/Schedule/index.d.ts +0 -10
  41. package/lib/modules/Schedule/index.js +0 -41
  42. package/lib/modules/Schedule/type.d.ts +0 -157
  43. package/lib/modules/Schedule/type.js +0 -17
  44. package/lib/modules/Schedule/types.d.ts +0 -177
  45. package/lib/modules/Schedule/types.js +0 -17
  46. package/lib/modules/Schedule/utils.d.ts +0 -61
  47. 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";
@@ -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
  });
@@ -207,76 +205,24 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
207
205
  return _loadProducts.apply(this, arguments);
208
206
  }
209
207
  return loadProducts;
210
- }() // 加载当前店铺下所有 schedule
211
- }, {
212
- key: "loadAllSchedule",
213
- value: function () {
214
- var _loadAllSchedule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
215
- var scheduleList;
216
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
217
- while (1) switch (_context3.prev = _context3.next) {
218
- case 0:
219
- _context3.next = 2;
220
- return this.request.get("/schedule");
221
- case 2:
222
- scheduleList = _context3.sent;
223
- case 3:
224
- case "end":
225
- return _context3.stop();
226
- }
227
- }, _callee3, this);
228
- }));
229
- function loadAllSchedule() {
230
- return _loadAllSchedule.apply(this, arguments);
231
- }
232
- return loadAllSchedule;
233
- }() // ui 层提供日期的起始范围,返回一个起始范围内日期的可用情况
234
- }, {
235
- key: "loadAvailableDate",
236
- value: function () {
237
- var _loadAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref2) {
238
- var startDate, endDate, custom_page_id, res;
239
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
240
- while (1) switch (_context4.prev = _context4.next) {
241
- case 0:
242
- startDate = _ref2.startDate, endDate = _ref2.endDate, custom_page_id = _ref2.custom_page_id;
243
- _context4.next = 3;
244
- return this.request.get("/schedule/product/availability", {
245
- start_date: startDate,
246
- end_date: endDate,
247
- custom_page_id: custom_page_id
248
- });
249
- case 3:
250
- res = _context4.sent;
251
- return _context4.abrupt("return", res.data.list);
252
- case 5:
253
- case "end":
254
- return _context4.stop();
255
- }
256
- }, _callee4, this);
257
- }));
258
- function loadAvailableDate(_x4) {
259
- return _loadAvailableDate.apply(this, arguments);
260
- }
261
- return loadAvailableDate;
262
208
  }()
263
209
  }, {
264
210
  key: "storeProduct",
265
211
  value: function () {
266
- var _storeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(productData) {
267
- var activeAccount, _ref3, bundle, options, origin, product_variant_id, product;
268
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
269
- while (1) switch (_context5.prev = _context5.next) {
212
+ var _storeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(productData) {
213
+ var activeAccount, _ref2, bundle, options, origin, product_variant_id, product;
214
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
215
+ while (1) switch (_context3.prev = _context3.next) {
270
216
  case 0:
271
217
  // 往购物车加商品数据的时候,默认用当前 activeAccount 填充到 product 的 account 里面
272
218
  activeAccount = this.getActiveAccount();
273
219
  if (activeAccount) {
274
- _context5.next = 3;
220
+ _context3.next = 3;
275
221
  break;
276
222
  }
277
223
  throw new Error("没有找到当前账户");
278
224
  case 3:
279
- _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;
280
226
  product = _objectSpread(_objectSpread({}, origin), {}, {
281
227
  product_variant_id: product_variant_id
282
228
  });
@@ -288,11 +234,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
288
234
  });
289
235
  case 6:
290
236
  case "end":
291
- return _context5.stop();
237
+ return _context3.stop();
292
238
  }
293
- }, _callee5, this);
239
+ }, _callee3, this);
294
240
  }));
295
- function storeProduct(_x5) {
241
+ function storeProduct(_x4) {
296
242
  return _storeProduct.apply(this, arguments);
297
243
  }
298
244
  return storeProduct;
@@ -300,21 +246,21 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
300
246
  }, {
301
247
  key: "addAccount",
302
248
  value: function () {
303
- var _addAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(accounts) {
249
+ var _addAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(accounts) {
304
250
  var _this3 = this;
305
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
306
- while (1) switch (_context6.prev = _context6.next) {
251
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
252
+ while (1) switch (_context4.prev = _context4.next) {
307
253
  case 0:
308
254
  accounts.forEach(function (account) {
309
255
  _this3.store.accountList.addAccount(account);
310
256
  });
311
257
  case 1:
312
258
  case "end":
313
- return _context6.stop();
259
+ return _context4.stop();
314
260
  }
315
- }, _callee6);
261
+ }, _callee4);
316
262
  }));
317
- function addAccount(_x6) {
263
+ function addAccount(_x5) {
318
264
  return _addAccount.apply(this, arguments);
319
265
  }
320
266
  return addAccount;
@@ -322,20 +268,20 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
322
268
  }, {
323
269
  key: "getAccounts",
324
270
  value: function () {
325
- var _getAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
271
+ var _getAccounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
326
272
  var accounts;
327
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
328
- while (1) switch (_context7.prev = _context7.next) {
273
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
274
+ while (1) switch (_context5.prev = _context5.next) {
329
275
  case 0:
330
276
  accounts = this.store.accountList.getAccounts();
331
- return _context7.abrupt("return", accounts.map(function (account) {
277
+ return _context5.abrupt("return", accounts.map(function (account) {
332
278
  return account.getAccount();
333
279
  }));
334
280
  case 2:
335
281
  case "end":
336
- return _context7.stop();
282
+ return _context5.stop();
337
283
  }
338
- }, _callee7, this);
284
+ }, _callee5, this);
339
285
  }));
340
286
  function getAccounts() {
341
287
  return _getAccounts.apply(this, arguments);
@@ -373,18 +319,18 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
373
319
  }, {
374
320
  key: "setDateRange",
375
321
  value: function () {
376
- var _setDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(dateRange) {
377
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
378
- 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) {
379
325
  case 0:
380
326
  this.store.date.setDateRange(dateRange);
381
327
  case 1:
382
328
  case "end":
383
- return _context8.stop();
329
+ return _context6.stop();
384
330
  }
385
- }, _callee8, this);
331
+ }, _callee6, this);
386
332
  }));
387
- function setDateRange(_x7) {
333
+ function setDateRange(_x6) {
388
334
  return _setDateRange.apply(this, arguments);
389
335
  }
390
336
  return setDateRange;
@@ -399,16 +345,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
399
345
  }, {
400
346
  key: "getDateRange",
401
347
  value: function () {
402
- var _getDateRange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
403
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
404
- 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) {
405
351
  case 0:
406
- return _context9.abrupt("return", this.store.date.getDateRange());
352
+ return _context7.abrupt("return", this.store.date.getDateRange());
407
353
  case 1:
408
354
  case "end":
409
- return _context9.stop();
355
+ return _context7.stop();
410
356
  }
411
- }, _callee9, this);
357
+ }, _callee7, this);
412
358
  }));
413
359
  function getDateRange() {
414
360
  return _getDateRange.apply(this, arguments);
@@ -425,7 +371,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
425
371
  }, {
426
372
  key: "getAvailableDate",
427
373
  value: function () {
428
- var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
374
+ var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
429
375
  var _this$otherParams3, _this$otherParams4;
430
376
  var params,
431
377
  products,
@@ -434,16 +380,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
434
380
  tempProducts,
435
381
  tempStartDate,
436
382
  tempEndDate,
437
- _ref4,
383
+ _ref3,
438
384
  resourceIds,
439
385
  rules,
440
386
  resourcesMap,
441
387
  res,
442
- _args10 = arguments;
443
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
444
- 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) {
445
391
  case 0:
446
- params = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : {};
392
+ params = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {};
447
393
  // 开始日期如果小于今天,直接以今天当做开始日期
448
394
  products = params.products, startDate = params.startDate, endDate = params.endDate;
449
395
  tempProducts = products || this.store.cart.getItems().map(function (p) {
@@ -452,16 +398,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
452
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]);
453
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]);
454
400
  if (tempProducts.length) {
455
- _context10.next = 7;
401
+ _context8.next = 7;
456
402
  break;
457
403
  }
458
- return _context10.abrupt("return", []);
404
+ return _context8.abrupt("return", []);
459
405
  case 7:
460
406
  // 在这里需要把能收集到的数据都收集上来,拼装好给 date 模块去查询
461
- _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;
462
408
  console.log("resourceIds", tempProducts);
463
409
  this.otherParams.currentResourcesMap = resourcesMap;
464
- _context10.next = 12;
410
+ _context8.next = 12;
465
411
  return this.store.date.getMonthDates({
466
412
  query: {
467
413
  start_date: tempStartDate,
@@ -471,13 +417,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
471
417
  rules: rules
472
418
  });
473
419
  case 12:
474
- res = _context10.sent;
475
- return _context10.abrupt("return", res);
420
+ res = _context8.sent;
421
+ return _context8.abrupt("return", res);
476
422
  case 14:
477
423
  case "end":
478
- return _context10.stop();
424
+ return _context8.stop();
479
425
  }
480
- }, _callee10, this);
426
+ }, _callee8, this);
481
427
  }));
482
428
  function getAvailableDate() {
483
429
  return _getAvailableDate.apply(this, arguments);
@@ -490,22 +436,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
490
436
  }, {
491
437
  key: "getSummary",
492
438
  value: (function () {
493
- var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
439
+ var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
494
440
  var cartItems, summary;
495
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
496
- while (1) switch (_context11.prev = _context11.next) {
441
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
442
+ while (1) switch (_context9.prev = _context9.next) {
497
443
  case 0:
498
444
  cartItems = this.store.cart.getItems();
499
- _context11.next = 3;
445
+ _context9.next = 3;
500
446
  return this.store.summary.getSummary(cartItems);
501
447
  case 3:
502
- summary = _context11.sent;
503
- return _context11.abrupt("return", summary);
448
+ summary = _context9.sent;
449
+ return _context9.abrupt("return", summary);
504
450
  case 5:
505
451
  case "end":
506
- return _context11.stop();
452
+ return _context9.stop();
507
453
  }
508
- }, _callee11, this);
454
+ }, _callee9, this);
509
455
  }));
510
456
  function getSummary() {
511
457
  return _getSummary.apply(this, arguments);
@@ -516,16 +462,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
516
462
  }, {
517
463
  key: "getProducts",
518
464
  value: function () {
519
- var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
520
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
521
- 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) {
522
468
  case 0:
523
- return _context12.abrupt("return", this.store.products.getProducts());
469
+ return _context10.abrupt("return", this.store.products.getProducts());
524
470
  case 1:
525
471
  case "end":
526
- return _context12.stop();
472
+ return _context10.stop();
527
473
  }
528
- }, _callee12, this);
474
+ }, _callee10, this);
529
475
  }));
530
476
  function getProducts() {
531
477
  return _getProducts.apply(this, arguments);
@@ -535,15 +481,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
535
481
  }, {
536
482
  key: "setLoginAccount",
537
483
  value: function () {
538
- var _setLoginAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(accountId, accountInfo) {
484
+ var _setLoginAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(accountId, accountInfo) {
539
485
  var _this4 = this;
540
486
  var account, stateAccountId, cartItems;
541
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
542
- while (1) switch (_context13.prev = _context13.next) {
487
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
488
+ while (1) switch (_context11.prev = _context11.next) {
543
489
  case 0:
544
490
  account = this.store.accountList.getAccount(accountId);
545
491
  if (!account) {
546
- _context13.next = 9;
492
+ _context11.next = 9;
547
493
  break;
548
494
  }
549
495
  stateAccountId = account.getId();
@@ -559,17 +505,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
559
505
  }
560
506
  });
561
507
  this.store.accountList.updateAccountListById(stateAccountId, accountInfo);
562
- _context13.next = 10;
508
+ _context11.next = 10;
563
509
  break;
564
510
  case 9:
565
511
  throw new Error("\u6CA1\u6709\u627E\u5230".concat(accountId, "\u8D26\u6237"));
566
512
  case 10:
567
513
  case "end":
568
- return _context13.stop();
514
+ return _context11.stop();
569
515
  }
570
- }, _callee13, this);
516
+ }, _callee11, this);
571
517
  }));
572
- function setLoginAccount(_x8, _x9) {
518
+ function setLoginAccount(_x7, _x8) {
573
519
  return _setLoginAccount.apply(this, arguments);
574
520
  }
575
521
  return setLoginAccount;
@@ -577,14 +523,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
577
523
  }, {
578
524
  key: "generateCartData",
579
525
  value: function () {
580
- var _generateCartData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
581
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
582
- 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) {
583
529
  case 0:
584
530
  case "end":
585
- return _context14.stop();
531
+ return _context12.stop();
586
532
  }
587
- }, _callee14);
533
+ }, _callee12);
588
534
  }));
589
535
  function generateCartData() {
590
536
  return _generateCartData.apply(this, arguments);
@@ -594,23 +540,23 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
594
540
  }, {
595
541
  key: "getFreeProduct",
596
542
  value: function () {
597
- var _getFreeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(id) {
543
+ var _getFreeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(id) {
598
544
  var res;
599
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
600
- while (1) switch (_context15.prev = _context15.next) {
545
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
546
+ while (1) switch (_context13.prev = _context13.next) {
601
547
  case 0:
602
- _context15.next = 2;
548
+ _context13.next = 2;
603
549
  return this.request.post("/pay/order/free-pay/".concat(id));
604
550
  case 2:
605
- res = _context15.sent;
606
- return _context15.abrupt("return", res);
551
+ res = _context13.sent;
552
+ return _context13.abrupt("return", res);
607
553
  case 4:
608
554
  case "end":
609
- return _context15.stop();
555
+ return _context13.stop();
610
556
  }
611
- }, _callee15, this);
557
+ }, _callee13, this);
612
558
  }));
613
- function getFreeProduct(_x10) {
559
+ function getFreeProduct(_x9) {
614
560
  return _getFreeProduct.apply(this, arguments);
615
561
  }
616
562
  return getFreeProduct;
@@ -618,10 +564,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
618
564
  }, {
619
565
  key: "submitOrder",
620
566
  value: function () {
621
- var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
567
+ var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
622
568
  var cartItems, newCartItems;
623
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
624
- while (1) switch (_context16.prev = _context16.next) {
569
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
570
+ while (1) switch (_context14.prev = _context14.next) {
625
571
  case 0:
626
572
  cartItems = this.store.cart.getItems();
627
573
  newCartItems = cloneDeep(cartItems); // 先整个临时的逻辑,把购物车里所有商品的资源给他格式化一下
@@ -634,16 +580,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
634
580
  return _objectSpread({}, newResourcesItem);
635
581
  });
636
582
  });
637
- return _context16.abrupt("return", this.store.order.commitOrder({
583
+ return _context14.abrupt("return", this.store.order.commitOrder({
638
584
  query: {
639
585
  cartItems: newCartItems
640
586
  }
641
587
  }));
642
588
  case 4:
643
589
  case "end":
644
- return _context16.stop();
590
+ return _context14.stop();
645
591
  }
646
- }, _callee16, this);
592
+ }, _callee14, this);
647
593
  }));
648
594
  function submitOrder() {
649
595
  return _submitOrder.apply(this, arguments);
@@ -653,14 +599,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
653
599
  }, {
654
600
  key: "pay",
655
601
  value: function () {
656
- var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
657
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
658
- 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) {
659
605
  case 0:
660
606
  case "end":
661
- return _context17.stop();
607
+ return _context15.stop();
662
608
  }
663
- }, _callee17);
609
+ }, _callee15);
664
610
  }));
665
611
  function pay() {
666
612
  return _pay.apply(this, arguments);
@@ -670,14 +616,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
670
616
  }, {
671
617
  key: "getPayInfo",
672
618
  value: function () {
673
- var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
674
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
675
- 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) {
676
622
  case 0:
677
623
  case "end":
678
- return _context18.stop();
624
+ return _context16.stop();
679
625
  }
680
- }, _callee18);
626
+ }, _callee16);
681
627
  }));
682
628
  function getPayInfo() {
683
629
  return _getPayInfo.apply(this, arguments);
@@ -687,15 +633,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
687
633
  }, {
688
634
  key: "setOtherParams",
689
635
  value: function () {
690
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
691
- var _ref5,
692
- _ref5$cover,
636
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
637
+ var _ref4,
638
+ _ref4$cover,
693
639
  cover,
694
- _args19 = arguments;
695
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
696
- 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) {
697
643
  case 0:
698
- _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;
699
645
  if (cover) {
700
646
  this.otherParams = params;
701
647
  } else {
@@ -703,11 +649,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
703
649
  }
704
650
  case 2:
705
651
  case "end":
706
- return _context19.stop();
652
+ return _context17.stop();
707
653
  }
708
- }, _callee19, this);
654
+ }, _callee17, this);
709
655
  }));
710
- function setOtherParams(_x11) {
656
+ function setOtherParams(_x10) {
711
657
  return _setOtherParams.apply(this, arguments);
712
658
  }
713
659
  return setOtherParams;
@@ -715,16 +661,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
715
661
  }, {
716
662
  key: "getOtherParams",
717
663
  value: function () {
718
- var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
719
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
720
- 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) {
721
667
  case 0:
722
- return _context20.abrupt("return", this.otherParams);
668
+ return _context18.abrupt("return", this.otherParams);
723
669
  case 1:
724
670
  case "end":
725
- return _context20.stop();
671
+ return _context18.stop();
726
672
  }
727
- }, _callee20, this);
673
+ }, _callee18, this);
728
674
  }));
729
675
  function getOtherParams() {
730
676
  return _getOtherParams.apply(this, arguments);
@@ -746,15 +692,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
746
692
  if (item.holder_id !== (targetCartItem === null || targetCartItem === void 0 ? void 0 : targetCartItem.holder_id)) {
747
693
  var _item$_origin$resourc;
748
694
  var resources = (_item$_origin$resourc = item._origin.resources) === null || _item$_origin$resourc === void 0 ? void 0 : _item$_origin$resourc.filter(function (m) {
749
- // 检查当前资源是否与目标资源的任何资源匹配
750
695
  return !targetCartItem._origin.resources.some(function (targetRes) {
751
- var _targetRes$metadata$c, _m$metadata$combined_;
752
- // 检查主资源ID是否匹配
753
- if (targetRes.id === m.id) return true;
754
- // 检查组合资源的情况
755
- 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;
756
- 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;
757
- return false;
696
+ return targetRes.id === m.id;
758
697
  });
759
698
  });
760
699
  _this5.store.cart.updateItem({
@@ -836,18 +775,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
836
775
  var cartItems = this.store.cart.getItems();
837
776
  var arr = [];
838
777
  cartItems.forEach(function (cartItem) {
839
- var _cartItem$_productOri, _cartItem$_productOri2;
840
- // TODO:应该要优化下,理论上流程里不应该有holder_id 为空的购物车数据
841
- if (!cartItem.holder_id) return;
842
- var selectedResources = getOthersSelectedResources(cartItems, cartItem.holder_id, resourcesMap);
843
- var formatCapacity = formatDefaultCapacitys({
844
- capacity: (_cartItem$_productOri = cartItem._productOrigin) === null || _cartItem$_productOri === void 0 ? void 0 : _cartItem$_productOri.capacity,
845
- product_bundle: cartItem._origin.product.product_bundle
846
- });
847
- var currentCapacity = getSumCapacity({
848
- capacity: formatCapacity
849
- });
850
- 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);
851
779
  arr.push({
852
780
  id: cartItem.id,
853
781
  // 这里返回的是购物车 id ,后面提交的时候要用的,用这个 id 绑定资源和时间
@@ -866,7 +794,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
866
794
  }, {
867
795
  key: "getResourcesListByCartItem",
868
796
  value: function getResourcesListByCartItem(id) {
869
- var _targetCartItem$_prod, _targetCartItem$_prod2;
870
797
  var cartItems = this.store.cart.getItems();
871
798
  var dateRange = this.store.date.getDateRange();
872
799
  var resources = [];
@@ -874,22 +801,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
874
801
  if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
875
802
  });
876
803
  var resourcesMap = getResourcesMap(resources);
804
+ var arr = [];
877
805
  var targetCartItem = cartItems.find(function (n) {
878
806
  return n._id === id;
879
807
  });
880
808
  if (!targetCartItem) {
881
809
  throw new Error("\u6CA1\u6709\u627E\u5230".concat(id, "\u8D2D\u7269\u8F66\u5546\u54C1"));
882
810
  }
883
- if (!targetCartItem.holder_id) return;
884
- var selectedResources = getOthersSelectedResources(cartItems, targetCartItem.holder_id, resourcesMap);
885
- var formatCapacity = formatDefaultCapacitys({
886
- capacity: (_targetCartItem$_prod = targetCartItem._productOrigin) === null || _targetCartItem$_prod === void 0 ? void 0 : _targetCartItem$_prod.capacity,
887
- product_bundle: targetCartItem._origin.product.product_bundle
888
- });
889
- var currentCapacity = getSumCapacity({
890
- capacity: formatCapacity
891
- });
892
- 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);
893
812
  if (productResources) {
894
813
  return {
895
814
  id: targetCartItem.id,
@@ -907,10 +826,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
907
826
  // 通过资源列表和指定的资源 id,获取指定资源的时间切片
908
827
  }, {
909
828
  key: "getResourceTimeSlot",
910
- value: function getResourceTimeSlot(_ref6) {
911
- var product = _ref6.product,
912
- resources = _ref6.resources,
913
- currentResourceId = _ref6.currentResourceId;
829
+ value: function getResourceTimeSlot(_ref5) {
830
+ var product = _ref5.product,
831
+ resources = _ref5.resources,
832
+ currentResourceId = _ref5.currentResourceId;
914
833
  var dateRange = this.store.date.getDateRange();
915
834
  var timeSlots = getTimeSlicesByResource({
916
835
  resource: resources.find(function (n) {
@@ -923,13 +842,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
923
842
  return timeSlots;
924
843
  }
925
844
 
926
- // 自动分派可用的资源-单种资源类型——此方法目前未使用,未经验证
845
+ // 自动分派可用的资源-单种资源类型
927
846
  }, {
928
847
  key: "autoSelectResource",
929
- value: function autoSelectResource(_ref7) {
930
- var resourceProductData = _ref7.resourceProductData,
931
- resources = _ref7.resources,
932
- timeSlots = _ref7.timeSlots;
848
+ value: function autoSelectResource(_ref6) {
849
+ var resourceProductData = _ref6.resourceProductData,
850
+ resources = _ref6.resources,
851
+ timeSlots = _ref6.timeSlots;
933
852
  var dateRange = this.store.date.getDateRange();
934
853
  if (timeSlots) {
935
854
  // 如果 start_time 存在,则直接根据 start_time 算出商品总共需要的时长,然后根据时长去匹配资源
@@ -998,12 +917,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
998
917
  // 自动分派可用资源-pro 版,ui 传递某个账号,自动给某个账号下所有商品分配第一种资源
999
918
  }, {
1000
919
  key: "autoSelectAccountResources",
1001
- value: function autoSelectAccountResources(_ref8) {
1002
- var holder_id = _ref8.holder_id,
1003
- resources_code = _ref8.resources_code,
1004
- timeSlots = _ref8.timeSlots,
1005
- countMap = _ref8.countMap,
1006
- 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;
1007
926
  var dateRange = this.store.date.getDateRange();
1008
927
  var cartItems = this.store.cart.getItems();
1009
928
  // 取到账号下所有的商品,然后根据商品的 duration 和资源列表,获取所有可用的资源
@@ -1022,7 +941,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1022
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);
1023
942
  }, 0);
1024
943
  // 正常来说,能进这个业务的所有商品的 duration 类型都是一样的,所以这里取第一个商品的 duration 类型
1025
- // 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";
1026
945
  // 取出账号下所对应类型的所有的可用资源
1027
946
  var resources = [];
1028
947
  accountCartItems.forEach(function (item) {
@@ -1054,7 +973,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1054
973
  timeSlice: timeSlots,
1055
974
  time: item,
1056
975
  resource: n,
1057
- currentCount: recordCount + (capacity || 0)
976
+ currentCount: recordCount + 1
1058
977
  });
1059
978
  return res.usable;
1060
979
  });
@@ -1084,8 +1003,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1084
1003
  resourcesMap: resourcesMap,
1085
1004
  duration: duration,
1086
1005
  currentDate: dateRange[0].date,
1087
- split: 10,
1088
- capacity: capacity
1006
+ split: 10
1089
1007
  });
1090
1008
  // 如果timeSlots返回了 空数组,代表没有可用的资源了
1091
1009
  if (!_timeSlots2) {
@@ -1114,25 +1032,19 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1114
1032
  var selectResourcesMap = {};
1115
1033
  this.store.accountList.getAccounts().forEach(function (account) {
1116
1034
  var cartItems = _this7.store.cart.getCartByAccount(account.getId());
1035
+ // 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
1036
+ var allCartItems = _this7.store.cart.getItems();
1117
1037
  var recordTimeSlots = cloneDeep(timeSlots);
1118
1038
  // timeSlots 传进来的只是用户选中的时间片,但是实际上需要根据多个商品时间进行累加
1119
1039
  // 假设 timeSlots.start_time 是15:40 duration 是 30min
1120
1040
  // 第一个商品分配完以后,第二个商品分配的start_time应该是第一个商品的 end_time ,然后 end_time 应该是 start_time+duration
1121
1041
 
1122
1042
  cartItems.forEach(function (item, index) {
1123
- var _item$_productOrigin2;
1124
- var formatCapacity = formatDefaultCapacitys({
1125
- capacity: (_item$_productOrigin2 = item._productOrigin) === null || _item$_productOrigin2 === void 0 ? void 0 : _item$_productOrigin2.capacity,
1126
- product_bundle: item._origin.product.product_bundle
1127
- });
1128
- var currentCapacity = getSumCapacity({
1129
- capacity: formatCapacity
1130
- });
1131
1043
  if (timeSlots) {
1132
1044
  if (index !== 0 && recordTimeSlots) {
1133
- var _item$_productOrigin$, _item$_productOrigin3, _ref9, _item$_productOrigin4, _item$_productOrigin$2, _item$_productOrigin5, _ref10, _item$_productOrigin6;
1134
- 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");
1135
- 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");
1136
1048
  recordTimeSlots = {
1137
1049
  start_time: start_at.format("HH:mm"),
1138
1050
  end_time: end_at.format("HH:mm"),
@@ -1145,8 +1057,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1145
1057
  holder_id: item.holder_id,
1146
1058
  resources_code: resources_code,
1147
1059
  timeSlots: recordTimeSlots,
1148
- countMap: selectResourcesMap,
1149
- capacity: currentCapacity
1060
+ countMap: selectResourcesMap
1150
1061
  });
1151
1062
  // // 如果购物车里已经有同类型的 form_id 的资源了,则不处理
1152
1063
  // if (item._origin.resources?.some((n: any) => n.form_id === res?.selectedResource?.form_id)) {
@@ -1154,12 +1065,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1154
1065
  // }
1155
1066
  if (res !== null && res !== void 0 && res.selectedResource) {
1156
1067
  if (!selectResourcesMap[res.selectedResource.id]) {
1157
- selectResourcesMap[res.selectedResource.id] = currentCapacity;
1068
+ selectResourcesMap[res.selectedResource.id] = 1;
1158
1069
  } else {
1159
- selectResourcesMap[res.selectedResource.id] += currentCapacity;
1070
+ selectResourcesMap[res.selectedResource.id]++;
1160
1071
  }
1161
- res.selectedResource.capacity = currentCapacity;
1162
- checkSubResourcesCapacity(res.selectedResource);
1072
+ console.log(_this7.store.cart.getItems());
1073
+ res.selectedResource.capacity = 1;
1163
1074
  _this7.store.cart.updateItem({
1164
1075
  _id: item._id,
1165
1076
  // 这里要做去重,避免出现同样类型的资源被塞进同一个商品
@@ -1167,18 +1078,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1167
1078
  return existingRes.form_id !== res.selectedResource.form_id;
1168
1079
  })), [res.selectedResource])
1169
1080
  });
1081
+ console.log(_this7.store.cart.getItems());
1170
1082
  } else {
1171
1083
  // 如果没有可用的技师了,推到错误列表里让 UI 去提示
1172
1084
  errorList.push(item._id);
1173
1085
  }
1174
1086
  } else {
1175
- var _item$_productOrigin7, _productResources$fin;
1176
- // 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
1177
- var allCartItems = _this7.store.cart.getItems();
1087
+ var _productResources$fin;
1178
1088
  // 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
1179
- if (!item.holder_id) return;
1180
- var selectedResources = getOthersSelectedResources(allCartItems, item.holder_id, resourcesMap);
1181
- 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);
1182
1090
  // 自动选择 productResources 中对应 resources_code 的资源
1183
1091
  var targetRenderList = (_productResources$fin = productResources.find(function (n) {
1184
1092
  return n.code === resources_code;
@@ -1192,16 +1100,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1192
1100
  return;
1193
1101
  }
1194
1102
  var targetResource = targetRenderList[0];
1195
- targetResource.capacity = currentCapacity;
1196
- // 在这里处理 children 的数据
1197
- checkSubResourcesCapacity(targetResource);
1103
+ targetResource.capacity = 1;
1198
1104
  _this7.store.cart.updateItem({
1199
1105
  _id: item._id,
1200
1106
  resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
1201
1107
  return existingRes.resourceType !== targetRenderList[0].resourceType;
1202
1108
  })), [targetResource])
1203
1109
  });
1204
- console.log(account, '已分配');
1205
1110
  } else {
1206
1111
  // 如果没有可用的技师了,推到错误列表里让 UI 去提示
1207
1112
  errorList.push(item._id);
@@ -1224,8 +1129,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1224
1129
  var cartItems = this.store.cart.getItems();
1225
1130
  var resourceIds = [];
1226
1131
  cartItems.forEach(function (item) {
1227
- var _item$_productOrigin8;
1228
- (_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) {
1229
1134
  if (n.code === resources_code) {
1230
1135
  resources.push.apply(resources, _toConsumableArray(n.renderList || []));
1231
1136
  }
@@ -1244,8 +1149,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1244
1149
  var accountDuration = 0;
1245
1150
  var cartItems = _this8.store.cart.getCartByAccount(account.getId());
1246
1151
  cartItems.forEach(function (item) {
1247
- var _item$_productOrigin$3, _item$_productOrigin9;
1248
- 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;
1249
1154
  });
1250
1155
  if (accountDuration > duration) {
1251
1156
  duration = accountDuration;
@@ -1285,9 +1190,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1285
1190
  accountItems.forEach(function (item, index) {
1286
1191
  var newResources = cloneDeep(item._origin.resources);
1287
1192
  newResources.forEach(function (resource) {
1288
- var _item$_productOrigin$4, _item$_productOrigin10, _ref11, _item$_productOrigin11;
1193
+ var _item$_productOrigin$4, _item$_productOrigin8, _ref10, _item$_productOrigin9;
1289
1194
  resource.startTime = currentStartTime;
1290
- 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");
1291
1196
  delete resource.times;
1292
1197
  });
1293
1198
  _this9.store.cart.updateItem({
@@ -1308,32 +1213,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1308
1213
  }, {
1309
1214
  key: "clearCacheByModule",
1310
1215
  value: function clearCacheByModule(module) {}
1311
- }, {
1312
- key: "openProductDetail",
1313
- value: function () {
1314
- var _openProductDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(productId) {
1315
- var targetProduct;
1316
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1317
- while (1) switch (_context21.prev = _context21.next) {
1318
- case 0:
1319
- _context21.next = 2;
1320
- return this.store.products.getProduct(productId);
1321
- case 2:
1322
- targetProduct = _context21.sent;
1323
- if (targetProduct) {
1324
- this.store.currentProduct = targetProduct;
1325
- }
1326
- case 4:
1327
- case "end":
1328
- return _context21.stop();
1329
- }
1330
- }, _callee21, this);
1331
- }));
1332
- function openProductDetail(_x12) {
1333
- return _openProductDetail.apply(this, arguments);
1334
- }
1335
- return openProductDetail;
1336
- }()
1337
1216
  }]);
1338
1217
  return BookingByStepImpl;
1339
1218
  }(BaseModule);