@pisell/pisellos 0.0.34 → 0.0.36

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