@pisell/pisellos 3.0.33 → 3.0.35

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.
@@ -14,5 +14,7 @@ export declare class ScheduleModule extends BaseModule implements Module, Schedu
14
14
  getScheduleListByIds(ids: number[]): ScheduleItem[];
15
15
  setAvailabilityScheduleDateList(list: ScheduleAvailabilityDateItem[]): void;
16
16
  getAvailabilityScheduleDateList(): ScheduleAvailabilityDateItem[];
17
+ setOtherProductsIds(ids: number[]): void;
18
+ getOtherProductsIds(): number[];
17
19
  storeChange(): void;
18
20
  }
@@ -92,6 +92,16 @@ export var ScheduleModule = /*#__PURE__*/function (_BaseModule) {
92
92
  value: function getAvailabilityScheduleDateList() {
93
93
  return this.store.availabilityDateList;
94
94
  }
95
+ }, {
96
+ key: "setOtherProductsIds",
97
+ value: function setOtherProductsIds(ids) {
98
+ this.store.otherProductsIds = ids;
99
+ }
100
+ }, {
101
+ key: "getOtherProductsIds",
102
+ value: function getOtherProductsIds() {
103
+ return this.store.otherProductsIds;
104
+ }
95
105
  }, {
96
106
  key: "storeChange",
97
107
  value: function storeChange() {
@@ -2,6 +2,7 @@ import dayjs from 'dayjs';
2
2
  export interface ScheduleState {
3
3
  scheduleList: ScheduleItem[];
4
4
  availabilityDateList: ScheduleAvailabilityDateItem[];
5
+ otherProductsIds: number[];
5
6
  }
6
7
  export type ScheduleAvailabilityDateItem = {
7
8
  date: string;
@@ -42,12 +42,10 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
42
42
  * 更新step
43
43
  */
44
44
  updateStep(key: string, step: IStep): void;
45
- loadProducts({ category_ids, product_ids, collection, schedule_ids, schedule_date, }: {
45
+ loadProducts({ category_ids, product_ids, collection, }: {
46
46
  category_ids?: number[];
47
47
  product_ids?: number[];
48
48
  collection?: number | string[];
49
- schedule_ids?: number[];
50
- schedule_date?: string;
51
49
  }): Promise<any>;
52
50
  loadProductByScheduleDate({ date, product_ids, category_ids, }: {
53
51
  date: string;
@@ -200,6 +198,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
200
198
  start_at: dayjs.Dayjs;
201
199
  end_at: dayjs.Dayjs;
202
200
  count: number;
201
+ left: number;
203
202
  }[];
204
203
  addProductToCart({ product, date, account, }: {
205
204
  product: ProductData;
@@ -1,10 +1,10 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
3
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
4
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
6
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
7
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
7
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
8
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
9
9
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
10
10
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -208,24 +208,23 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
208
208
  key: "loadProducts",
209
209
  value: function () {
210
210
  var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
211
- var _schedule_ids;
212
- var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, _ref$schedule_ids, schedule_ids, schedule_date, schedule_ids_data, userPlugin, customer_id, _userPlugin$get, productsData;
211
+ var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, userPlugin, customer_id, _userPlugin$get, productsData;
213
212
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
214
213
  while (1) switch (_context2.prev = _context2.next) {
215
214
  case 0:
216
- _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, schedule_date = _ref.schedule_date;
217
- // 如果 schedule_ids 为空,则需要尝试从 schedule 模块里获取
218
- if (!((_schedule_ids = schedule_ids) !== null && _schedule_ids !== void 0 && _schedule_ids.length)) {
219
- schedule_ids_data = this.store.schedule.getScheduleListByIds(schedule_ids).map(function (n) {
220
- return n.id;
221
- });
222
- if (schedule_ids_data.length) {
223
- schedule_ids = schedule_ids_data;
224
- } else if (schedule_date) {
225
- // 后端说如果 schedule_ids 如果为空,需要给[0]
226
- schedule_ids = [0];
227
- }
228
- }
215
+ _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;
216
+ // // 如果 schedule_ids 为空,则需要尝试从 schedule 模块里获取
217
+ // if (!schedule_ids?.length) {
218
+ // const schedule_ids_data = this.store.schedule
219
+ // .getScheduleListByIds(schedule_ids)
220
+ // .map((n) => n.id);
221
+ // if (schedule_ids_data.length) {
222
+ // schedule_ids = schedule_ids_data;
223
+ // } else if (schedule_date) {
224
+ // // 后端说如果 schedule_ids 如果为空,需要给[0]
225
+ // schedule_ids = [0];
226
+ // }
227
+ // }
229
228
  userPlugin = this.core.getPlugin('user');
230
229
  customer_id = undefined;
231
230
  try {
@@ -234,7 +233,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
234
233
  console.error(error);
235
234
  }
236
235
  // 如果没传schedule_date,则从
237
- _context2.next = 7;
236
+ _context2.next = 6;
238
237
  return this.request.post("/product/query", {
239
238
  open_quotation: 1,
240
239
  open_bundle: 0,
@@ -247,17 +246,17 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
247
246
  category_ids: category_ids,
248
247
  ids: product_ids,
249
248
  collection: collection,
250
- front_end_cache_id: this.cacheId,
251
- client_schedule_ids: schedule_ids,
252
- schedule_date: schedule_date
249
+ front_end_cache_id: this.cacheId
250
+ // client_schedule_ids: schedule_ids,
251
+ // schedule_date,
253
252
  }, {
254
253
  useCache: true
255
254
  });
256
- case 7:
255
+ case 6:
257
256
  productsData = _context2.sent;
258
257
  this.store.products.addProduct(productsData.data.list);
259
258
  return _context2.abrupt("return", productsData.data.list);
260
- case 10:
259
+ case 9:
261
260
  case "end":
262
261
  return _context2.stop();
263
262
  }
@@ -273,11 +272,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
273
272
  value: function () {
274
273
  var _loadProductByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref2) {
275
274
  var _product_ids;
276
- var date, product_ids, _ref2$category_ids, category_ids, scheduleList, scheduleIds, _schedule$product_ids, schedule;
275
+ var date, _ref2$product_ids, product_ids, _ref2$category_ids, category_ids, scheduleList, _schedule$product_ids, schedule, otherProductsIds, allProductIds;
277
276
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
278
277
  while (1) switch (_context3.prev = _context3.next) {
279
278
  case 0:
280
- date = _ref2.date, product_ids = _ref2.product_ids, _ref2$category_ids = _ref2.category_ids, category_ids = _ref2$category_ids === void 0 ? [] : _ref2$category_ids;
279
+ date = _ref2.date, _ref2$product_ids = _ref2.product_ids, product_ids = _ref2$product_ids === void 0 ? [] : _ref2$product_ids, _ref2$category_ids = _ref2.category_ids, category_ids = _ref2$category_ids === void 0 ? [] : _ref2$category_ids;
281
280
  scheduleList = this.store.schedule.getAvailabilityScheduleDateList(); // 缓存下这次选择的结果,如果是先选日期再选 duration 类商品,后面用得到
282
281
  this.setDateRange([{
283
282
  date: date,
@@ -290,13 +289,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
290
289
  week: '',
291
290
  weekNum: 0
292
291
  }]);
293
- scheduleIds = scheduleList.filter(function (n) {
294
- return n.date === date;
295
- }).flatMap(function (n) {
296
- return n.schedule_id;
297
- }).filter(function (n) {
298
- return n !== null && n !== undefined;
299
- }); // 如果外面没传 product_ids,尝试从对应 schedule 里拿 product_ids
292
+ // const scheduleIds = scheduleList
293
+ // .filter((n) => n.date === date)
294
+ // .flatMap((n) => n.schedule_id)
295
+ // .filter((n) => n !== null && n !== undefined);
296
+
297
+ // 如果外面没传 product_ids,尝试从对应 schedule 里拿 product_ids
300
298
  if (!((_product_ids = product_ids) !== null && _product_ids !== void 0 && _product_ids.length)) {
301
299
  schedule = scheduleList.find(function (n) {
302
300
  return n.date === date;
@@ -305,16 +303,21 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
305
303
  product_ids = schedule.product_ids;
306
304
  }
307
305
  }
308
- _context3.next = 7;
306
+ // 尝试去拿schedule 里的 other_product_ids 和 product_ids 拼在一起去重
307
+ otherProductsIds = this.store.schedule.getOtherProductsIds() || [];
308
+ allProductIds = [].concat(_toConsumableArray(product_ids), _toConsumableArray(otherProductsIds)).filter(function (n, index, self) {
309
+ return self.indexOf(n) === index;
310
+ });
311
+ _context3.next = 8;
309
312
  return this.loadProducts({
310
- schedule_ids: scheduleIds,
311
- product_ids: product_ids,
312
- category_ids: category_ids,
313
- schedule_date: date
313
+ // schedule_ids: scheduleIds,
314
+ product_ids: allProductIds,
315
+ category_ids: category_ids
316
+ // schedule_date: date,
314
317
  });
315
- case 7:
316
- return _context3.abrupt("return", _context3.sent);
317
318
  case 8:
319
+ return _context3.abrupt("return", _context3.sent);
320
+ case 9:
318
321
  case "end":
319
322
  return _context3.stop();
320
323
  }
@@ -472,7 +475,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
472
475
  key: "loadScheduleAvailableDate",
473
476
  value: function () {
474
477
  var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref3) {
475
- var _res$data$date_list;
478
+ var _res$data$date_list, _res$data$other_produ, _res$data$other_produ2;
476
479
  var startDate, endDate, custom_page_id, channel, dates, res;
477
480
  return _regeneratorRuntime().wrap(function _callee6$(_context7) {
478
481
  while (1) switch (_context7.prev = _context7.next) {
@@ -493,7 +496,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
493
496
  return _context7.abrupt("return", dates);
494
497
  case 6:
495
498
  _context7.next = 8;
496
- return this.request.get("/schedule/product/availability", {
499
+ return this.request.get("/schedule/product/availability/v2", {
497
500
  start_date: startDate,
498
501
  end_date: endDate,
499
502
  custom_page_id: custom_page_id,
@@ -502,24 +505,32 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
502
505
  case 8:
503
506
  res = _context7.sent;
504
507
  this.store.schedule.setAvailabilityScheduleDateList(res.data.date_list);
508
+ this.store.schedule.setOtherProductsIds(res.data.other_product_ids || []);
505
509
  // 如果没有schedule或者结束日期在今天之前,则所有日期均不可用
506
- if (!(!((_res$data$date_list = res.data.date_list) !== null && _res$data$date_list !== void 0 && _res$data$date_list.length) || dayjs(endDate).isBefore(dayjs(), 'day'))) {
507
- _context7.next = 12;
510
+ if (!(!((_res$data$date_list = res.data.date_list) !== null && _res$data$date_list !== void 0 && _res$data$date_list.length) && !((_res$data$other_produ = res.data.other_product_ids) !== null && _res$data$other_produ !== void 0 && _res$data$other_produ.length) || dayjs(endDate).isBefore(dayjs(), 'day'))) {
511
+ _context7.next = 13;
508
512
  break;
509
513
  }
510
514
  return _context7.abrupt("return", dates);
511
- case 12:
512
- res.data.date_list.forEach(function (n) {
513
- var index = dates.findIndex(function (m) {
514
- return m.date === n.date;
515
+ case 13:
516
+ if ((_res$data$other_produ2 = res.data.other_product_ids) !== null && _res$data$other_produ2 !== void 0 && _res$data$other_produ2.length) {
517
+ // 如果后端有返回 other_product_ids ,意味着有 duration 商品,则今天以及今天以后的日期均可用
518
+ dates.forEach(function (n) {
519
+ n.status = 'available';
515
520
  });
516
- if (index !== -1) {
517
- dates[index].status = 'available';
518
- }
519
- });
521
+ } else {
522
+ res.data.date_list.forEach(function (n) {
523
+ var index = dates.findIndex(function (m) {
524
+ return m.date === n.date;
525
+ });
526
+ if (index !== -1) {
527
+ dates[index].status = 'available';
528
+ }
529
+ });
530
+ }
520
531
  dates = disableDatesBeforeOneDay(dates);
521
532
  return _context7.abrupt("return", dates);
522
- case 15:
533
+ case 16:
523
534
  case "end":
524
535
  return _context7.stop();
525
536
  }
@@ -1255,7 +1266,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1255
1266
  var _item$_origin$resourc;
1256
1267
  var resources = (_item$_origin$resourc = item._origin.resources) === null || _item$_origin$resourc === void 0 ? void 0 : _item$_origin$resourc.filter(function (m) {
1257
1268
  // 检查当前资源是否与目标资源的任何资源匹配
1258
- return !targetCartItem._origin.resources.some(function (targetRes) {
1269
+ // 目标资源,应该只取跟当前 m.form_id 相同的资源
1270
+ var sameFormIdResources = targetCartItem._origin.resources.filter(function (n) {
1271
+ return n.form_id === m.form_id;
1272
+ });
1273
+ if (!(sameFormIdResources !== null && sameFormIdResources !== void 0 && sameFormIdResources.length)) {
1274
+ return true;
1275
+ }
1276
+ return !sameFormIdResources.some(function (targetRes) {
1259
1277
  // 如果新更新进来的资源不是单个预约,其实就不需要检测了资源重叠了,但是需要检测资源 capacity 是否足够
1260
1278
  if (targetRes.resourceType !== 'single') {
1261
1279
  var _item$_productOrigin2;
@@ -1269,10 +1287,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1269
1287
  var originResource = allOriginResources.find(function (n) {
1270
1288
  return n.id === targetRes.id;
1271
1289
  });
1272
- if (currentResourcesCapacityMap[targetRes.id] + _currentCapacity > (originResource === null || originResource === void 0 ? void 0 : originResource.capacity)) {
1290
+ if (currentResourcesCapacityMap[m.id] + _currentCapacity > (originResource === null || originResource === void 0 ? void 0 : originResource.capacity)) {
1273
1291
  return true;
1274
1292
  }
1275
- currentResourcesCapacityMap[targetRes.id] += _currentCapacity;
1293
+ currentResourcesCapacityMap[m.id] += _currentCapacity;
1276
1294
  return false;
1277
1295
  }
1278
1296
  if (item.holder_id !== (targetCartItem === null || targetCartItem === void 0 ? void 0 : targetCartItem.holder_id)) {
@@ -1950,9 +1968,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1950
1968
  var currentResourceConfig = (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.product_resource) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.resources) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.find(function (n) {
1951
1969
  return n.code === resources_code;
1952
1970
  });
1953
- var resourceBookingType = (currentResourceConfig === null || currentResourceConfig === void 0 ? void 0 : currentResourceConfig.type) || 'single';
1954
1971
  // 只有 duration 类商品需要这个操作
1955
- if (index !== 0 && recordTimeSlots && resourceBookingType === 'single' && (_item$_productOrigin5 = item._productOrigin) !== null && _item$_productOrigin5 !== void 0 && _item$_productOrigin5.duration) {
1972
+ if (index !== 0 && recordTimeSlots && (currentResourceConfig === null || currentResourceConfig === void 0 ? void 0 : currentResourceConfig.type) === 'single' && (_item$_productOrigin5 = item._productOrigin) !== null && _item$_productOrigin5 !== void 0 && _item$_productOrigin5.duration) {
1956
1973
  var _item$_productOrigin$, _item$_productOrigin6, _ref9, _item$_productOrigin7, _item$_productOrigin$2, _item$_productOrigin8, _ref10, _item$_productOrigin9;
1957
1974
  var start_at = dayjs(recordTimeSlots.end_time).add((_item$_productOrigin$ = (_item$_productOrigin6 = item._productOrigin) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.duration) === null || _item$_productOrigin6 === void 0 ? void 0 : _item$_productOrigin6.value) !== null && _item$_productOrigin$ !== void 0 ? _item$_productOrigin$ : 0, (_ref9 = (_item$_productOrigin7 = item._productOrigin) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.duration) === null || _item$_productOrigin7 === void 0 ? void 0 : _item$_productOrigin7.type) !== null && _ref9 !== void 0 ? _ref9 : 'minutes');
1958
1975
  var end_at = start_at.add((_item$_productOrigin$2 = (_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$2 !== void 0 ? _item$_productOrigin$2 : 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');
@@ -2375,6 +2392,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2375
2392
  // 用来计算资源的可使用情况,针对单个schedule 时间片
2376
2393
  var resourcesUseableMap = {};
2377
2394
  var count = 0;
2395
+ var bookingLeft = 0;
2378
2396
  // 遍历所有资源
2379
2397
  allProductResources === null || allProductResources === void 0 || allProductResources.forEach(function (m) {
2380
2398
  // 遍历所有资源的上工时间片
@@ -2416,8 +2434,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2416
2434
  // 在已经选定时间的情况下,只要canUseTime如果有一个 false 那就不可用
2417
2435
  if (!currentResourcesTimeSlotCanUsedArr.some(function (n) {
2418
2436
  return n === false;
2419
- }) && currentResourcesCount >= count) {
2420
- count = currentResourcesCount;
2437
+ })) {
2438
+ if (currentResourcesCount >= count) {
2439
+ count = currentResourcesCount;
2440
+ }
2441
+ if (!m.onlyComputed) {
2442
+ bookingLeft += 1;
2443
+ }
2421
2444
  }
2422
2445
  });
2423
2446
  var startDayJs = dayjs(item.start);
@@ -2427,7 +2450,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2427
2450
  end_time: endDayJs.format('HH:mm'),
2428
2451
  start_at: startDayJs,
2429
2452
  end_at: endDayJs,
2430
- count: count
2453
+ count: count,
2454
+ left: bookingLeft
2431
2455
  };
2432
2456
  });
2433
2457
  return formatScheduleTimeSlots;
@@ -2843,7 +2867,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2843
2867
  openResources = ((_tempProducts = tempProducts) === null || _tempProducts === void 0 || (_tempProducts = _tempProducts.product_resource) === null || _tempProducts === void 0 || (_tempProducts = _tempProducts.resources) === null || _tempProducts === void 0 ? void 0 : _tempProducts.filter(function (m) {
2844
2868
  return m.status === 1;
2845
2869
  })) || []; // res.data 返回的一定是启用商品的资源列表,不需要再过滤了
2846
- allProductResources = sortCombinedResources(res.data);
2870
+ allProductResources = sortCombinedResources(res.data); // allProductResources 需要根据商品里的资源的单个预约多个预约补充resourceType
2871
+ allProductResources.forEach(function (m) {
2872
+ var _tempProducts2;
2873
+ var resource = (_tempProducts2 = tempProducts) === null || _tempProducts2 === void 0 || (_tempProducts2 = _tempProducts2.product_resource) === null || _tempProducts2 === void 0 || (_tempProducts2 = _tempProducts2.resources) === null || _tempProducts2 === void 0 ? void 0 : _tempProducts2.find(function (n) {
2874
+ return n.id === m.form_id;
2875
+ });
2876
+ if (resource) {
2877
+ m.resourceType = resource.type;
2878
+ }
2879
+ });
2847
2880
  targetSchedules = this.store.schedule.getScheduleListByIds(tempProducts['schedule.ids']);
2848
2881
  _loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
2849
2882
  var currentDateStr, status, _checkSessionProductL, latestStartDate, earliestEndDate, scheduleByDate, minTimeMaxTime, scheduleTimeSlots, timesSlotCanUse;
@@ -2900,7 +2933,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2900
2933
  return;
2901
2934
  }
2902
2935
  var targetCanUseTimes = mTimes.some(function (childTiem) {
2903
- var _tempProducts2;
2936
+ var _tempProducts3;
2904
2937
  // 挨个去匹配某个工作时间段结合当前日程时间,资源能不能用,有多少容量能用
2905
2938
  var res = getIsUsableByTimeItem({
2906
2939
  timeSlice: {
@@ -2913,7 +2946,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2913
2946
  resource: m,
2914
2947
  currentCount: 1,
2915
2948
  resourcesUseableMap: resourcesUseableMap,
2916
- cut_off_time: (_tempProducts2 = tempProducts) === null || _tempProducts2 === void 0 ? void 0 : _tempProducts2.cut_off_time
2949
+ cut_off_time: (_tempProducts3 = tempProducts) === null || _tempProducts3 === void 0 ? void 0 : _tempProducts3.cut_off_time
2917
2950
  });
2918
2951
  if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
2919
2952
  resourcesUseableMap[m.id] = res.usable;
@@ -2952,22 +2985,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2952
2985
  }
2953
2986
  }, _loop3);
2954
2987
  });
2955
- case 22:
2988
+ case 23:
2956
2989
  if (!(dayjs(currentDate).isBefore(dayjs(endDate), 'day') || dayjs(currentDate).isSame(dayjs(endDate), 'day'))) {
2957
- _context32.next = 28;
2990
+ _context32.next = 29;
2958
2991
  break;
2959
2992
  }
2960
- return _context32.delegateYield(_loop3(), "t0", 24);
2961
- case 24:
2993
+ return _context32.delegateYield(_loop3(), "t0", 25);
2994
+ case 25:
2962
2995
  if (!_context32.t0) {
2963
- _context32.next = 26;
2996
+ _context32.next = 27;
2964
2997
  break;
2965
2998
  }
2966
- return _context32.abrupt("break", 28);
2967
- case 26:
2968
- _context32.next = 22;
2999
+ return _context32.abrupt("break", 29);
3000
+ case 27:
3001
+ _context32.next = 23;
2969
3002
  break;
2970
- case 28:
3003
+ case 29:
2971
3004
  // 最终把资源数据也加到日期内
2972
3005
  dates = handleAvailableDateByResource(res.data, dates);
2973
3006
  this.store.date.setDateList(dates);
@@ -2983,7 +3016,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2983
3016
  dateList: dates,
2984
3017
  firstAvailableDate: firstAvailableDate
2985
3018
  });
2986
- case 32:
3019
+ case 33:
2987
3020
  case "end":
2988
3021
  return _context32.stop();
2989
3022
  }
@@ -14,5 +14,7 @@ export declare class ScheduleModule extends BaseModule implements Module, Schedu
14
14
  getScheduleListByIds(ids: number[]): ScheduleItem[];
15
15
  setAvailabilityScheduleDateList(list: ScheduleAvailabilityDateItem[]): void;
16
16
  getAvailabilityScheduleDateList(): ScheduleAvailabilityDateItem[];
17
+ setOtherProductsIds(ids: number[]): void;
18
+ getOtherProductsIds(): number[];
17
19
  storeChange(): void;
18
20
  }
@@ -63,6 +63,12 @@ var ScheduleModule = class extends import_BaseModule.BaseModule {
63
63
  getAvailabilityScheduleDateList() {
64
64
  return this.store.availabilityDateList;
65
65
  }
66
+ setOtherProductsIds(ids) {
67
+ this.store.otherProductsIds = ids;
68
+ }
69
+ getOtherProductsIds() {
70
+ return this.store.otherProductsIds;
71
+ }
66
72
  storeChange() {
67
73
  if (this.openCache) {
68
74
  const store = (0, import_lodash_es.cloneDeep)(this.store);
@@ -2,6 +2,7 @@ import dayjs from 'dayjs';
2
2
  export interface ScheduleState {
3
3
  scheduleList: ScheduleItem[];
4
4
  availabilityDateList: ScheduleAvailabilityDateItem[];
5
+ otherProductsIds: number[];
5
6
  }
6
7
  export type ScheduleAvailabilityDateItem = {
7
8
  date: string;
@@ -42,12 +42,10 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
42
42
  * 更新step
43
43
  */
44
44
  updateStep(key: string, step: IStep): void;
45
- loadProducts({ category_ids, product_ids, collection, schedule_ids, schedule_date, }: {
45
+ loadProducts({ category_ids, product_ids, collection, }: {
46
46
  category_ids?: number[];
47
47
  product_ids?: number[];
48
48
  collection?: number | string[];
49
- schedule_ids?: number[];
50
- schedule_date?: string;
51
49
  }): Promise<any>;
52
50
  loadProductByScheduleDate({ date, product_ids, category_ids, }: {
53
51
  date: string;
@@ -200,6 +198,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
200
198
  start_at: dayjs.Dayjs;
201
199
  end_at: dayjs.Dayjs;
202
200
  count: number;
201
+ left: number;
203
202
  }[];
204
203
  addProductToCart({ product, date, account, }: {
205
204
  product: ProductData;
@@ -162,19 +162,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
162
162
  async loadProducts({
163
163
  category_ids = [],
164
164
  product_ids = [],
165
- collection = [],
166
- schedule_ids = [],
167
- schedule_date
165
+ collection = []
166
+ // schedule_ids = [],
167
+ // schedule_date,
168
168
  }) {
169
169
  var _a;
170
- if (!(schedule_ids == null ? void 0 : schedule_ids.length)) {
171
- const schedule_ids_data = this.store.schedule.getScheduleListByIds(schedule_ids).map((n) => n.id);
172
- if (schedule_ids_data.length) {
173
- schedule_ids = schedule_ids_data;
174
- } else if (schedule_date) {
175
- schedule_ids = [0];
176
- }
177
- }
178
170
  let userPlugin = this.core.getPlugin("user");
179
171
  let customer_id = void 0;
180
172
  try {
@@ -202,9 +194,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
202
194
  category_ids,
203
195
  ids: product_ids,
204
196
  collection,
205
- front_end_cache_id: this.cacheId,
206
- client_schedule_ids: schedule_ids,
207
- schedule_date
197
+ front_end_cache_id: this.cacheId
198
+ // client_schedule_ids: schedule_ids,
199
+ // schedule_date,
208
200
  },
209
201
  { useCache: true }
210
202
  );
@@ -213,7 +205,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
213
205
  }
214
206
  async loadProductByScheduleDate({
215
207
  date,
216
- product_ids,
208
+ product_ids = [],
217
209
  category_ids = []
218
210
  }) {
219
211
  var _a;
@@ -222,18 +214,21 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
222
214
  { date, status: "available", week: "", weekNum: 0 },
223
215
  { date, status: "available", week: "", weekNum: 0 }
224
216
  ]);
225
- const scheduleIds = scheduleList.filter((n) => n.date === date).flatMap((n) => n.schedule_id).filter((n) => n !== null && n !== void 0);
226
217
  if (!(product_ids == null ? void 0 : product_ids.length)) {
227
218
  const schedule = scheduleList.find((n) => n.date === date);
228
219
  if (schedule && ((_a = schedule.product_ids) == null ? void 0 : _a.length)) {
229
220
  product_ids = schedule.product_ids;
230
221
  }
231
222
  }
223
+ const otherProductsIds = this.store.schedule.getOtherProductsIds() || [];
224
+ const allProductIds = [...product_ids, ...otherProductsIds].filter(
225
+ (n, index, self) => self.indexOf(n) === index
226
+ );
232
227
  return await this.loadProducts({
233
- schedule_ids: scheduleIds,
234
- product_ids,
235
- category_ids,
236
- schedule_date: date
228
+ // schedule_ids: scheduleIds,
229
+ product_ids: allProductIds,
230
+ category_ids
231
+ // schedule_date: date,
237
232
  });
238
233
  }
239
234
  async updateQuotationPriceAndCart(date) {
@@ -305,7 +300,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
305
300
  custom_page_id,
306
301
  channel
307
302
  }) {
308
- var _a;
303
+ var _a, _b, _c;
309
304
  if ((0, import_dayjs.default)(startDate).isBefore((0, import_dayjs.default)(), "day")) {
310
305
  startDate = (0, import_dayjs.default)().format("YYYY-MM-DD");
311
306
  }
@@ -315,7 +310,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
315
310
  return dates;
316
311
  }
317
312
  const res = await this.request.get(
318
- `/schedule/product/availability`,
313
+ `/schedule/product/availability/v2`,
319
314
  {
320
315
  start_date: startDate,
321
316
  end_date: endDate,
@@ -324,15 +319,22 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
324
319
  }
325
320
  );
326
321
  this.store.schedule.setAvailabilityScheduleDateList(res.data.date_list);
327
- if (!((_a = res.data.date_list) == null ? void 0 : _a.length) || (0, import_dayjs.default)(endDate).isBefore((0, import_dayjs.default)(), "day")) {
322
+ this.store.schedule.setOtherProductsIds(res.data.other_product_ids || []);
323
+ if (!((_a = res.data.date_list) == null ? void 0 : _a.length) && !((_b = res.data.other_product_ids) == null ? void 0 : _b.length) || (0, import_dayjs.default)(endDate).isBefore((0, import_dayjs.default)(), "day")) {
328
324
  return dates;
329
325
  }
330
- res.data.date_list.forEach((n) => {
331
- const index = dates.findIndex((m) => m.date === n.date);
332
- if (index !== -1) {
333
- dates[index].status = "available";
334
- }
335
- });
326
+ if ((_c = res.data.other_product_ids) == null ? void 0 : _c.length) {
327
+ dates.forEach((n) => {
328
+ n.status = "available";
329
+ });
330
+ } else {
331
+ res.data.date_list.forEach((n) => {
332
+ const index = dates.findIndex((m) => m.date === n.date);
333
+ if (index !== -1) {
334
+ dates[index].status = "available";
335
+ }
336
+ });
337
+ }
336
338
  dates = (0, import_utils3.disableDatesBeforeOneDay)(dates);
337
339
  return dates;
338
340
  }
@@ -641,7 +643,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
641
643
  var _a2;
642
644
  if (item._id !== targetCartItem._id) {
643
645
  const resources = (_a2 = item._origin.resources) == null ? void 0 : _a2.filter((m) => {
644
- return !targetCartItem._origin.resources.some((targetRes) => {
646
+ const sameFormIdResources = targetCartItem._origin.resources.filter((n) => n.form_id === m.form_id);
647
+ if (!(sameFormIdResources == null ? void 0 : sameFormIdResources.length)) {
648
+ return true;
649
+ }
650
+ return !sameFormIdResources.some((targetRes) => {
645
651
  var _a3, _b, _c;
646
652
  if (targetRes.resourceType !== "single") {
647
653
  const formatCapacity = (0, import_resources.formatDefaultCapacitys)({
@@ -654,10 +660,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
654
660
  const originResource = allOriginResources.find(
655
661
  (n) => n.id === targetRes.id
656
662
  );
657
- if (currentResourcesCapacityMap[targetRes.id] + currentCapacity > (originResource == null ? void 0 : originResource.capacity)) {
663
+ if (currentResourcesCapacityMap[m.id] + currentCapacity > (originResource == null ? void 0 : originResource.capacity)) {
658
664
  return true;
659
665
  }
660
- currentResourcesCapacityMap[targetRes.id] += currentCapacity;
666
+ currentResourcesCapacityMap[m.id] += currentCapacity;
661
667
  return false;
662
668
  }
663
669
  if (item.holder_id !== (targetCartItem == null ? void 0 : targetCartItem.holder_id)) {
@@ -1272,8 +1278,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1272
1278
  const currentResourceConfig = (_d = (_c = (_b = item._productOrigin) == null ? void 0 : _b.product_resource) == null ? void 0 : _c.resources) == null ? void 0 : _d.find(
1273
1279
  (n) => n.code === resources_code
1274
1280
  );
1275
- const resourceBookingType = (currentResourceConfig == null ? void 0 : currentResourceConfig.type) || "single";
1276
- if (index !== 0 && recordTimeSlots && resourceBookingType === "single" && ((_e = item._productOrigin) == null ? void 0 : _e.duration)) {
1281
+ if (index !== 0 && recordTimeSlots && (currentResourceConfig == null ? void 0 : currentResourceConfig.type) === "single" && ((_e = item._productOrigin) == null ? void 0 : _e.duration)) {
1277
1282
  let start_at = (0, import_dayjs.default)(recordTimeSlots.end_time).add(
1278
1283
  ((_g = (_f = item._productOrigin) == null ? void 0 : _f.duration) == null ? void 0 : _g.value) ?? 0,
1279
1284
  ((_i = (_h = item._productOrigin) == null ? void 0 : _h.duration) == null ? void 0 : _i.type) ?? "minutes"
@@ -1664,6 +1669,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1664
1669
  const formatScheduleTimeSlots = scheduleTimeSlots.map((item) => {
1665
1670
  const resourcesUseableMap = {};
1666
1671
  let count = 0;
1672
+ let bookingLeft = 0;
1667
1673
  allProductResources == null ? void 0 : allProductResources.forEach((m) => {
1668
1674
  let currentResourcesCount = 0;
1669
1675
  const currentResourcesTimeSlotCanUsedArr = [];
@@ -1695,10 +1701,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1695
1701
  }
1696
1702
  currentResourcesTimeSlotCanUsedArr.push(res.usable);
1697
1703
  });
1698
- if (!currentResourcesTimeSlotCanUsedArr.some(
1699
- (n) => n === false
1700
- ) && currentResourcesCount >= count) {
1701
- count = currentResourcesCount;
1704
+ if (!currentResourcesTimeSlotCanUsedArr.some((n) => n === false)) {
1705
+ if (currentResourcesCount >= count) {
1706
+ count = currentResourcesCount;
1707
+ }
1708
+ if (!m.onlyComputed) {
1709
+ bookingLeft += 1;
1710
+ }
1702
1711
  }
1703
1712
  });
1704
1713
  const startDayJs = (0, import_dayjs.default)(item.start);
@@ -1708,7 +1717,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1708
1717
  end_time: endDayJs.format("HH:mm"),
1709
1718
  start_at: startDayJs,
1710
1719
  end_at: endDayJs,
1711
- count
1720
+ count,
1721
+ left: bookingLeft
1712
1722
  };
1713
1723
  });
1714
1724
  return formatScheduleTimeSlots;
@@ -2013,6 +2023,15 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2013
2023
  (m) => m.status === 1
2014
2024
  )) || [];
2015
2025
  const allProductResources = (0, import_resources.sortCombinedResources)(res.data);
2026
+ allProductResources.forEach((m) => {
2027
+ var _a2, _b2;
2028
+ const resource = (_b2 = (_a2 = tempProducts == null ? void 0 : tempProducts.product_resource) == null ? void 0 : _a2.resources) == null ? void 0 : _b2.find(
2029
+ (n) => n.id === m.form_id
2030
+ );
2031
+ if (resource) {
2032
+ m.resourceType = resource.type;
2033
+ }
2034
+ });
2016
2035
  const targetSchedules = this.store.schedule.getScheduleListByIds(
2017
2036
  tempProducts["schedule.ids"]
2018
2037
  );
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "3.0.33",
4
+ "version": "3.0.35",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",