@pisell/pisellos 2.0.26 → 2.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/Cart/utils.js +6 -0
- package/dist/modules/Schedule/index.d.ts +2 -0
- package/dist/modules/Schedule/index.js +10 -0
- package/dist/modules/Schedule/types.d.ts +1 -0
- package/dist/solution/BookingByStep/index.d.ts +3 -4
- package/dist/solution/BookingByStep/index.js +72 -57
- package/dist/solution/BookingByStep/utils/timeslots.js +59 -75
- package/lib/modules/Cart/utils.js +5 -0
- package/lib/modules/Schedule/index.d.ts +2 -0
- package/lib/modules/Schedule/index.js +6 -0
- package/lib/modules/Schedule/types.d.ts +1 -0
- package/lib/solution/BookingByStep/index.d.ts +3 -4
- package/lib/solution/BookingByStep/index.js +40 -36
- package/lib/solution/BookingByStep/utils/timeslots.js +21 -32
- package/package.json +1 -1
|
@@ -207,6 +207,12 @@ export var formatDiscountToCartItemOrigin = function formatDiscountToCartItemOri
|
|
|
207
207
|
origin.product = {};
|
|
208
208
|
}
|
|
209
209
|
origin.product.discount_list = discounts;
|
|
210
|
+
} else {
|
|
211
|
+
// 如果折扣为空,则清空折扣列表
|
|
212
|
+
if (!origin.product) {
|
|
213
|
+
origin.product = {};
|
|
214
|
+
}
|
|
215
|
+
origin.product.discount_list = [];
|
|
210
216
|
}
|
|
211
217
|
return origin;
|
|
212
218
|
};
|
|
@@ -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() {
|
|
@@ -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,
|
|
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;
|
|
@@ -211,7 +210,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
211
210
|
}): void;
|
|
212
211
|
setOtherData(key: string, value: any): void;
|
|
213
212
|
getOtherData(key: string): any;
|
|
214
|
-
getProductTypeById(id: number): Promise<"
|
|
213
|
+
getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
|
|
215
214
|
/**
|
|
216
215
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
217
216
|
*
|
|
@@ -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
|
|
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
|
|
217
|
-
// 如果 schedule_ids 为空,则需要尝试从 schedule 模块里获取
|
|
218
|
-
if (!
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
|
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
|
|
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,
|
|
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
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
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
|
-
|
|
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:
|
|
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 =
|
|
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
|
|
512
|
-
res.data.
|
|
513
|
-
|
|
514
|
-
|
|
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
|
-
|
|
517
|
-
|
|
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
|
|
533
|
+
case 16:
|
|
523
534
|
case "end":
|
|
524
535
|
return _context7.stop();
|
|
525
536
|
}
|
|
@@ -1950,9 +1961,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1950
1961
|
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
1962
|
return n.code === resources_code;
|
|
1952
1963
|
});
|
|
1953
|
-
var resourceBookingType = (currentResourceConfig === null || currentResourceConfig === void 0 ? void 0 : currentResourceConfig.type) || 'single';
|
|
1954
1964
|
// 只有 duration 类商品需要这个操作
|
|
1955
|
-
if (index !== 0 && recordTimeSlots &&
|
|
1965
|
+
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
1966
|
var _item$_productOrigin$, _item$_productOrigin6, _ref9, _item$_productOrigin7, _item$_productOrigin$2, _item$_productOrigin8, _ref10, _item$_productOrigin9;
|
|
1957
1967
|
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
1968
|
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 +2385,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2375
2385
|
// 用来计算资源的可使用情况,针对单个schedule 时间片
|
|
2376
2386
|
var resourcesUseableMap = {};
|
|
2377
2387
|
var count = 0;
|
|
2388
|
+
var bookingLeft = 0;
|
|
2378
2389
|
// 遍历所有资源
|
|
2379
2390
|
allProductResources === null || allProductResources === void 0 || allProductResources.forEach(function (m) {
|
|
2380
2391
|
// 遍历所有资源的上工时间片
|
|
@@ -2416,8 +2427,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2416
2427
|
// 在已经选定时间的情况下,只要canUseTime如果有一个 false 那就不可用
|
|
2417
2428
|
if (!currentResourcesTimeSlotCanUsedArr.some(function (n) {
|
|
2418
2429
|
return n === false;
|
|
2419
|
-
})
|
|
2420
|
-
count
|
|
2430
|
+
})) {
|
|
2431
|
+
if (currentResourcesCount >= count) {
|
|
2432
|
+
count = currentResourcesCount;
|
|
2433
|
+
}
|
|
2434
|
+
bookingLeft += 1;
|
|
2421
2435
|
}
|
|
2422
2436
|
});
|
|
2423
2437
|
var startDayJs = dayjs(item.start);
|
|
@@ -2427,7 +2441,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2427
2441
|
end_time: endDayJs.format('HH:mm'),
|
|
2428
2442
|
start_at: startDayJs,
|
|
2429
2443
|
end_at: endDayJs,
|
|
2430
|
-
count: count
|
|
2444
|
+
count: count,
|
|
2445
|
+
left: bookingLeft
|
|
2431
2446
|
};
|
|
2432
2447
|
});
|
|
2433
2448
|
return formatScheduleTimeSlots;
|
|
@@ -19,79 +19,63 @@ export function calculateResourceAvailableTime(_ref) {
|
|
|
19
19
|
return dayjs(time.start_at).isSame(dayjs(timeSlots.start_at), 'day');
|
|
20
20
|
});
|
|
21
21
|
if (matchingTimes.length === 0) return 0;
|
|
22
|
-
|
|
22
|
+
|
|
23
|
+
// 计算所有时间段与目标时间槽的重叠部分
|
|
24
|
+
var overlaps = [];
|
|
23
25
|
var _iterator = _createForOfIteratorHelper(matchingTimes),
|
|
24
26
|
_step;
|
|
25
27
|
try {
|
|
26
28
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
27
|
-
var _time$event_list;
|
|
28
29
|
var time = _step.value;
|
|
29
30
|
// 计算实际重叠的时间段
|
|
30
31
|
var overlapStart = dayjs(time.start_at).isAfter(dayjs(timeSlots.start_at)) ? dayjs(time.start_at) : dayjs(timeSlots.start_at);
|
|
31
32
|
var overlapEnd = dayjs(time.end_at).isBefore(dayjs(timeSlots.end_at)) ? dayjs(time.end_at) : dayjs(timeSlots.end_at);
|
|
32
33
|
|
|
33
|
-
//
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// 处理时间段内的每个预约事件
|
|
40
|
-
var currentTime = overlapStart;
|
|
41
|
-
var _iterator2 = _createForOfIteratorHelper(time.event_list),
|
|
42
|
-
_step2;
|
|
43
|
-
try {
|
|
44
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
45
|
-
var event = _step2.value;
|
|
46
|
-
var eventStart = dayjs(event.start_at);
|
|
47
|
-
var eventEnd = dayjs(event.end_at);
|
|
48
|
-
|
|
49
|
-
// 如果事件在当前时间之前,跳过
|
|
50
|
-
if (eventEnd.isBefore(currentTime)) continue;
|
|
51
|
-
|
|
52
|
-
// 如果事件开始时间在重叠结束时间之后,可以添加剩余时间
|
|
53
|
-
if (eventStart.isAfter(overlapEnd)) {
|
|
54
|
-
totalAvailableMinutes += overlapEnd.diff(currentTime, 'minute');
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// 如果事件开始时间在当前时间之后,添加事件开始前的时间
|
|
59
|
-
if (eventStart.isAfter(currentTime)) {
|
|
60
|
-
totalAvailableMinutes += eventStart.diff(currentTime, 'minute');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// 对于单个预约类型,整个事件时间都是不可用的
|
|
64
|
-
if (resource.resourceType === 'single') {
|
|
65
|
-
currentTime = eventEnd;
|
|
66
|
-
continue;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// 对于多个预约类型,检查容量
|
|
70
|
-
if (resource.resourceType === 'multiple') {
|
|
71
|
-
var remainingCapacity = (resource.capacity || 0) - (event.pax || 0);
|
|
72
|
-
if (remainingCapacity >= currentCapacity) {
|
|
73
|
-
// 如果剩余容量足够,这个时间段仍然是可用的
|
|
74
|
-
totalAvailableMinutes += eventEnd.diff(eventStart, 'minute');
|
|
75
|
-
}
|
|
76
|
-
currentTime = eventEnd;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// 添加最后一个事件之后的剩余时间
|
|
81
|
-
} catch (err) {
|
|
82
|
-
_iterator2.e(err);
|
|
83
|
-
} finally {
|
|
84
|
-
_iterator2.f();
|
|
85
|
-
}
|
|
86
|
-
if (currentTime.isBefore(overlapEnd)) {
|
|
87
|
-
totalAvailableMinutes += overlapEnd.diff(currentTime, 'minute');
|
|
34
|
+
// 只有当重叠时间段有效时才添加
|
|
35
|
+
if (overlapStart.isBefore(overlapEnd)) {
|
|
36
|
+
overlaps.push({
|
|
37
|
+
start: overlapStart,
|
|
38
|
+
end: overlapEnd
|
|
39
|
+
});
|
|
88
40
|
}
|
|
89
41
|
}
|
|
42
|
+
|
|
43
|
+
// 合并重叠的时间段,计算并集
|
|
90
44
|
} catch (err) {
|
|
91
45
|
_iterator.e(err);
|
|
92
46
|
} finally {
|
|
93
47
|
_iterator.f();
|
|
94
48
|
}
|
|
49
|
+
if (overlaps.length === 0) return 0;
|
|
50
|
+
|
|
51
|
+
// 按开始时间排序
|
|
52
|
+
overlaps.sort(function (a, b) {
|
|
53
|
+
return a.start.diff(b.start);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// 合并重叠的时间段
|
|
57
|
+
var merged = [];
|
|
58
|
+
var current = overlaps[0];
|
|
59
|
+
for (var i = 1; i < overlaps.length; i++) {
|
|
60
|
+
var next = overlaps[i];
|
|
61
|
+
|
|
62
|
+
// 如果当前时间段与下一个时间段重叠或相邻,则合并
|
|
63
|
+
if (current.end.isSameOrAfter(next.start)) {
|
|
64
|
+
current.end = current.end.isAfter(next.end) ? current.end : next.end;
|
|
65
|
+
} else {
|
|
66
|
+
// 不重叠,添加当前时间段到结果中,开始处理下一个
|
|
67
|
+
merged.push(current);
|
|
68
|
+
current = next;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
merged.push(current);
|
|
72
|
+
|
|
73
|
+
// 计算所有合并后时间段的总时长
|
|
74
|
+
var totalAvailableMinutes = 0;
|
|
75
|
+
for (var _i = 0, _merged = merged; _i < _merged.length; _i++) {
|
|
76
|
+
var segment = _merged[_i];
|
|
77
|
+
totalAvailableMinutes += segment.end.diff(segment.start, 'minute');
|
|
78
|
+
}
|
|
95
79
|
return totalAvailableMinutes;
|
|
96
80
|
}
|
|
97
81
|
|
|
@@ -113,11 +97,11 @@ export function findFastestAvailableResource(_ref2) {
|
|
|
113
97
|
var fastestResources = [];
|
|
114
98
|
|
|
115
99
|
// 遍历所有资源,找到最快可用的时间点
|
|
116
|
-
var
|
|
117
|
-
|
|
100
|
+
var _iterator2 = _createForOfIteratorHelper(resources),
|
|
101
|
+
_step2;
|
|
118
102
|
try {
|
|
119
|
-
for (
|
|
120
|
-
var _resource =
|
|
103
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
104
|
+
var _resource = _step2.value;
|
|
121
105
|
// 获取资源当天的时间段
|
|
122
106
|
var todayTimes = _resource.times.filter(function (time) {
|
|
123
107
|
return dayjs(time.start_at).isSame(currentTime, 'day');
|
|
@@ -130,11 +114,11 @@ export function findFastestAvailableResource(_ref2) {
|
|
|
130
114
|
});
|
|
131
115
|
|
|
132
116
|
// 找到第一个可用的时间段
|
|
133
|
-
var
|
|
134
|
-
|
|
117
|
+
var _iterator3 = _createForOfIteratorHelper(todayTimes),
|
|
118
|
+
_step3;
|
|
135
119
|
try {
|
|
136
120
|
var _loop = function _loop() {
|
|
137
|
-
var time =
|
|
121
|
+
var time = _step3.value;
|
|
138
122
|
var startTime = dayjs(time.start_at);
|
|
139
123
|
|
|
140
124
|
// 如果开始时间在当前时间之前,跳过
|
|
@@ -142,9 +126,9 @@ export function findFastestAvailableResource(_ref2) {
|
|
|
142
126
|
|
|
143
127
|
// 检查这个时间段是否可用
|
|
144
128
|
if (_resource.resourceType === 'single') {
|
|
145
|
-
var _time$
|
|
129
|
+
var _time$event_list;
|
|
146
130
|
// 单个预约类型:检查是否有预约
|
|
147
|
-
var hasBooking = (_time$
|
|
131
|
+
var hasBooking = (_time$event_list = time.event_list) === null || _time$event_list === void 0 ? void 0 : _time$event_list.some(function (event) {
|
|
148
132
|
return dayjs(event.start_at).isSame(startTime);
|
|
149
133
|
});
|
|
150
134
|
if (!hasBooking) {
|
|
@@ -158,10 +142,10 @@ export function findFastestAvailableResource(_ref2) {
|
|
|
158
142
|
return 1; // break
|
|
159
143
|
}
|
|
160
144
|
} else {
|
|
161
|
-
var _time$
|
|
145
|
+
var _time$event_list2;
|
|
162
146
|
// 多个预约类型:检查容量
|
|
163
147
|
var totalCapacity = _resource.capacity || 0;
|
|
164
|
-
var usedCapacity = ((_time$
|
|
148
|
+
var usedCapacity = ((_time$event_list2 = time.event_list) === null || _time$event_list2 === void 0 ? void 0 : _time$event_list2.reduce(function (sum, event) {
|
|
165
149
|
return dayjs(event.start_at).isSame(startTime) ? sum + (event.pax || 0) : sum;
|
|
166
150
|
}, 0)) || 0;
|
|
167
151
|
var remainingCapacity = totalCapacity - usedCapacity;
|
|
@@ -178,23 +162,23 @@ export function findFastestAvailableResource(_ref2) {
|
|
|
178
162
|
}
|
|
179
163
|
},
|
|
180
164
|
_ret;
|
|
181
|
-
for (
|
|
165
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
182
166
|
_ret = _loop();
|
|
183
167
|
if (_ret === 0) continue;
|
|
184
168
|
if (_ret === 1) break;
|
|
185
169
|
}
|
|
186
170
|
} catch (err) {
|
|
187
|
-
|
|
171
|
+
_iterator3.e(err);
|
|
188
172
|
} finally {
|
|
189
|
-
|
|
173
|
+
_iterator3.f();
|
|
190
174
|
}
|
|
191
175
|
}
|
|
192
176
|
|
|
193
177
|
// 如果没有找到可用资源,返回null
|
|
194
178
|
} catch (err) {
|
|
195
|
-
|
|
179
|
+
_iterator2.e(err);
|
|
196
180
|
} finally {
|
|
197
|
-
|
|
181
|
+
_iterator2.f();
|
|
198
182
|
}
|
|
199
183
|
if (!fastestTime || fastestResources.length === 0) return null;
|
|
200
184
|
|
|
@@ -204,8 +188,8 @@ export function findFastestAvailableResource(_ref2) {
|
|
|
204
188
|
// 如果有多个最快可用的资源,比较它们的空闲时间
|
|
205
189
|
var maxIdleTime = 0;
|
|
206
190
|
var selectedResource = null;
|
|
207
|
-
for (var
|
|
208
|
-
var resource = _fastestResources[
|
|
191
|
+
for (var _i2 = 0, _fastestResources = fastestResources; _i2 < _fastestResources.length; _i2++) {
|
|
192
|
+
var resource = _fastestResources[_i2];
|
|
209
193
|
var idleTime = calculateResourceAvailableTime({
|
|
210
194
|
resource: resource,
|
|
211
195
|
timeSlots: {
|
|
@@ -204,6 +204,11 @@ var formatDiscountToCartItemOrigin = (params) => {
|
|
|
204
204
|
origin.product = {};
|
|
205
205
|
}
|
|
206
206
|
origin.product.discount_list = discounts;
|
|
207
|
+
} else {
|
|
208
|
+
if (!origin.product) {
|
|
209
|
+
origin.product = {};
|
|
210
|
+
}
|
|
211
|
+
origin.product.discount_list = [];
|
|
207
212
|
}
|
|
208
213
|
return origin;
|
|
209
214
|
};
|
|
@@ -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);
|
|
@@ -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,
|
|
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;
|
|
@@ -211,7 +210,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
211
210
|
}): void;
|
|
212
211
|
setOtherData(key: string, value: any): void;
|
|
213
212
|
getOtherData(key: string): any;
|
|
214
|
-
getProductTypeById(id: number): Promise<"
|
|
213
|
+
getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
|
|
215
214
|
/**
|
|
216
215
|
* 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
|
|
217
216
|
*
|
|
@@ -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
|
-
|
|
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.
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
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
|
}
|
|
@@ -1272,8 +1274,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1272
1274
|
const currentResourceConfig = (_d = (_c = (_b = item._productOrigin) == null ? void 0 : _b.product_resource) == null ? void 0 : _c.resources) == null ? void 0 : _d.find(
|
|
1273
1275
|
(n) => n.code === resources_code
|
|
1274
1276
|
);
|
|
1275
|
-
|
|
1276
|
-
if (index !== 0 && recordTimeSlots && resourceBookingType === "single" && ((_e = item._productOrigin) == null ? void 0 : _e.duration)) {
|
|
1277
|
+
if (index !== 0 && recordTimeSlots && (currentResourceConfig == null ? void 0 : currentResourceConfig.type) === "single" && ((_e = item._productOrigin) == null ? void 0 : _e.duration)) {
|
|
1277
1278
|
let start_at = (0, import_dayjs.default)(recordTimeSlots.end_time).add(
|
|
1278
1279
|
((_g = (_f = item._productOrigin) == null ? void 0 : _f.duration) == null ? void 0 : _g.value) ?? 0,
|
|
1279
1280
|
((_i = (_h = item._productOrigin) == null ? void 0 : _h.duration) == null ? void 0 : _i.type) ?? "minutes"
|
|
@@ -1664,6 +1665,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1664
1665
|
const formatScheduleTimeSlots = scheduleTimeSlots.map((item) => {
|
|
1665
1666
|
const resourcesUseableMap = {};
|
|
1666
1667
|
let count = 0;
|
|
1668
|
+
let bookingLeft = 0;
|
|
1667
1669
|
allProductResources == null ? void 0 : allProductResources.forEach((m) => {
|
|
1668
1670
|
let currentResourcesCount = 0;
|
|
1669
1671
|
const currentResourcesTimeSlotCanUsedArr = [];
|
|
@@ -1695,10 +1697,11 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1695
1697
|
}
|
|
1696
1698
|
currentResourcesTimeSlotCanUsedArr.push(res.usable);
|
|
1697
1699
|
});
|
|
1698
|
-
if (!currentResourcesTimeSlotCanUsedArr.some(
|
|
1699
|
-
(
|
|
1700
|
-
|
|
1701
|
-
|
|
1700
|
+
if (!currentResourcesTimeSlotCanUsedArr.some((n) => n === false)) {
|
|
1701
|
+
if (currentResourcesCount >= count) {
|
|
1702
|
+
count = currentResourcesCount;
|
|
1703
|
+
}
|
|
1704
|
+
bookingLeft += 1;
|
|
1702
1705
|
}
|
|
1703
1706
|
});
|
|
1704
1707
|
const startDayJs = (0, import_dayjs.default)(item.start);
|
|
@@ -1708,7 +1711,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
1708
1711
|
end_time: endDayJs.format("HH:mm"),
|
|
1709
1712
|
start_at: startDayJs,
|
|
1710
1713
|
end_at: endDayJs,
|
|
1711
|
-
count
|
|
1714
|
+
count,
|
|
1715
|
+
left: bookingLeft
|
|
1712
1716
|
};
|
|
1713
1717
|
});
|
|
1714
1718
|
return formatScheduleTimeSlots;
|
|
@@ -39,49 +39,38 @@ function calculateResourceAvailableTime({
|
|
|
39
39
|
timeSlots,
|
|
40
40
|
currentCapacity = 1
|
|
41
41
|
}) {
|
|
42
|
-
var _a;
|
|
43
42
|
const matchingTimes = resource.times.filter((time) => {
|
|
44
43
|
return (0, import_dayjs.default)(time.start_at).isSame((0, import_dayjs.default)(timeSlots.start_at), "day");
|
|
45
44
|
});
|
|
46
45
|
if (matchingTimes.length === 0)
|
|
47
46
|
return 0;
|
|
48
|
-
|
|
47
|
+
const overlaps = [];
|
|
49
48
|
for (const time of matchingTimes) {
|
|
50
49
|
const overlapStart = (0, import_dayjs.default)(time.start_at).isAfter((0, import_dayjs.default)(timeSlots.start_at)) ? (0, import_dayjs.default)(time.start_at) : (0, import_dayjs.default)(timeSlots.start_at);
|
|
51
50
|
const overlapEnd = (0, import_dayjs.default)(time.end_at).isBefore((0, import_dayjs.default)(timeSlots.end_at)) ? (0, import_dayjs.default)(time.end_at) : (0, import_dayjs.default)(timeSlots.end_at);
|
|
52
|
-
if (
|
|
53
|
-
|
|
54
|
-
continue;
|
|
51
|
+
if (overlapStart.isBefore(overlapEnd)) {
|
|
52
|
+
overlaps.push({ start: overlapStart, end: overlapEnd });
|
|
55
53
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (resource.resourceType === "single") {
|
|
70
|
-
currentTime = eventEnd;
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
if (resource.resourceType === "multiple") {
|
|
74
|
-
const remainingCapacity = (resource.capacity || 0) - (event.pax || 0);
|
|
75
|
-
if (remainingCapacity >= currentCapacity) {
|
|
76
|
-
totalAvailableMinutes += eventEnd.diff(eventStart, "minute");
|
|
77
|
-
}
|
|
78
|
-
currentTime = eventEnd;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (currentTime.isBefore(overlapEnd)) {
|
|
82
|
-
totalAvailableMinutes += overlapEnd.diff(currentTime, "minute");
|
|
54
|
+
}
|
|
55
|
+
if (overlaps.length === 0)
|
|
56
|
+
return 0;
|
|
57
|
+
overlaps.sort((a, b) => a.start.diff(b.start));
|
|
58
|
+
const merged = [];
|
|
59
|
+
let current = overlaps[0];
|
|
60
|
+
for (let i = 1; i < overlaps.length; i++) {
|
|
61
|
+
const next = overlaps[i];
|
|
62
|
+
if (current.end.isSameOrAfter(next.start)) {
|
|
63
|
+
current.end = current.end.isAfter(next.end) ? current.end : next.end;
|
|
64
|
+
} else {
|
|
65
|
+
merged.push(current);
|
|
66
|
+
current = next;
|
|
83
67
|
}
|
|
84
68
|
}
|
|
69
|
+
merged.push(current);
|
|
70
|
+
let totalAvailableMinutes = 0;
|
|
71
|
+
for (const segment of merged) {
|
|
72
|
+
totalAvailableMinutes += segment.end.diff(segment.start, "minute");
|
|
73
|
+
}
|
|
85
74
|
return totalAvailableMinutes;
|
|
86
75
|
}
|
|
87
76
|
function findFastestAvailableResource({
|