@pisell/pisellos 2.2.321 → 2.2.323

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/modules/Order/index.d.ts +1 -1
  2. package/dist/modules/Order/utils.js +12 -1
  3. package/dist/modules/Product/index.d.ts +1 -1
  4. package/dist/modules/Product/types.d.ts +5 -0
  5. package/dist/server/index.js +3 -1
  6. package/dist/server/modules/order/types.d.ts +2 -0
  7. package/dist/server/modules/order/utils/filterOrders.js +20 -0
  8. package/dist/solution/BaseSales/index.d.ts +1 -0
  9. package/dist/solution/BaseSales/index.js +298 -209
  10. package/dist/solution/BaseSales/types.d.ts +3 -0
  11. package/dist/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
  12. package/dist/solution/BaseSales/utils/posDurationPricing.js +174 -0
  13. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
  14. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +8 -8
  15. package/dist/solution/BookingByStep/index.d.ts +3 -3
  16. package/dist/solution/BookingTicket/index.d.ts +1 -13
  17. package/dist/solution/UnifiedBookingSales/index.js +34 -16
  18. package/lib/modules/Order/index.d.ts +1 -1
  19. package/lib/modules/Order/utils.js +13 -0
  20. package/lib/modules/Product/index.d.ts +1 -1
  21. package/lib/modules/Product/types.d.ts +5 -0
  22. package/lib/server/index.js +4 -1
  23. package/lib/server/modules/order/types.d.ts +2 -0
  24. package/lib/server/modules/order/utils/filterOrders.js +18 -0
  25. package/lib/solution/BaseSales/index.d.ts +1 -0
  26. package/lib/solution/BaseSales/index.js +95 -36
  27. package/lib/solution/BaseSales/types.d.ts +3 -0
  28. package/lib/solution/BaseSales/utils/posDurationPricing.d.ts +21 -0
  29. package/lib/solution/BaseSales/utils/posDurationPricing.js +133 -0
  30. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +2 -0
  31. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -1
  32. package/lib/solution/BookingByStep/index.d.ts +3 -3
  33. package/lib/solution/BookingTicket/index.d.ts +1 -13
  34. package/lib/solution/UnifiedBookingSales/index.js +23 -1
  35. package/package.json +1 -1
@@ -348,6 +348,9 @@ export interface BaseSalesProductBookingPriceResult {
348
348
  unit_price: string;
349
349
  total_price: string;
350
350
  quantity: number;
351
+ pricing_method?: {
352
+ type: 'fixed_price' | 'duration_based';
353
+ };
351
354
  duration?: BaseSalesQuotationDurationConfig;
352
355
  quotation_shelf_id: number;
353
356
  segments: BaseSalesProductBookingPriceSegment[];
@@ -0,0 +1,21 @@
1
+ import type { BaseSalesCalculateProductBookingPriceParams, BaseSalesProductBookingPriceResult, BaseSalesQuotationDurationConfig } from '../types';
2
+ export interface PosDurationPricingPlan {
3
+ duration: BaseSalesQuotationDurationConfig;
4
+ segments: Array<{
5
+ start: string;
6
+ end: string;
7
+ }>;
8
+ }
9
+ export declare function durationPricingUnavailable(message: string): Error & {
10
+ code: string;
11
+ };
12
+ export declare function hasDurationBasedPricing(product: Record<string, any> | null | undefined): boolean;
13
+ /** Days/Flexible retain their existing quotation behavior. */
14
+ export declare function usesPosDurationPricing(product: Record<string, any> | null | undefined): boolean;
15
+ /** A hydrated catalog can already be fixed while its order/quote still contains an applied duration price. */
16
+ export declare function hasAppliedPosDurationPricing(product: Record<string, any> | null | undefined): boolean;
17
+ export declare function buildPosDurationPricingPlan(params: BaseSalesCalculateProductBookingPriceParams, product: Record<string, any>): PosDurationPricingPlan;
18
+ /** Never use a previously accumulated order price as one unit's fallback. */
19
+ export declare function resolveDurationPricingProduct(product: Record<string, any>, selected: Record<string, any>): Record<string, any>;
20
+ export declare function combinePosDurationPrices(plan: PosDurationPricingPlan, prices: BaseSalesProductBookingPriceResult[]): BaseSalesProductBookingPriceResult;
21
+ export declare function forEachPriceQueryGroup<T>(groups: T[], resolve: (group: T) => Promise<void>, concurrency: number): Promise<void>;
@@ -0,0 +1,174 @@
1
+ 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; }
2
+ 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); }
3
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
+ 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; }
6
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
9
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
+ import dayjs from 'dayjs';
11
+ import Decimal from 'decimal.js';
12
+ export function durationPricingUnavailable(message) {
13
+ return Object.assign(new Error(message), {
14
+ code: 'DURATION_PRICING_UNAVAILABLE'
15
+ });
16
+ }
17
+ export function hasDurationBasedPricing(product) {
18
+ var _product$pricing_meth;
19
+ return (product === null || product === void 0 || (_product$pricing_meth = product.pricing_method) === null || _product$pricing_meth === void 0 ? void 0 : _product$pricing_meth.type) === 'duration_based';
20
+ }
21
+
22
+ /** Days/Flexible retain their existing quotation behavior. */
23
+ export function usesPosDurationPricing(product) {
24
+ var _product$duration;
25
+ var type = String((product === null || product === void 0 || (_product$duration = product.duration) === null || _product$duration === void 0 ? void 0 : _product$duration.type) || '').trim().toLowerCase();
26
+ return hasDurationBasedPricing(product) && !['day', 'days', 'flexible'].includes(type);
27
+ }
28
+
29
+ /** A hydrated catalog can already be fixed while its order/quote still contains an applied duration price. */
30
+ export function hasAppliedPosDurationPricing(product) {
31
+ var _product$_extend, _product$_extend2;
32
+ return usesPosDurationPricing(product === null || product === void 0 || (_product$_extend = product._extend) === null || _product$_extend === void 0 ? void 0 : _product$_extend.bookingPriceQuote) || usesPosDurationPricing(product === null || product === void 0 || (_product$_extend2 = product._extend) === null || _product$_extend2 === void 0 || (_product$_extend2 = _product$_extend2.bookingPrice) === null || _product$_extend2 === void 0 ? void 0 : _product$_extend2.quote) || usesPosDurationPricing(product === null || product === void 0 ? void 0 : product.metadata);
33
+ }
34
+ function bookingDateTime(date, time) {
35
+ var dateText = typeof date === 'string' ? date.trim() : '';
36
+ var timeText = typeof time === 'string' ? time.trim() : '';
37
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(dateText) || !/^\d{2}:\d{2}(?::\d{2})?$/.test(timeText)) {
38
+ throw durationPricingUnavailable('A valid booking start and end are required for duration pricing.');
39
+ }
40
+ var text = "".concat(dateText, " ").concat(timeText.length === 5 ? "".concat(timeText, ":00") : timeText);
41
+ var value = dayjs(text);
42
+ if (!value.isValid() || value.format('YYYY-MM-DD HH:mm:ss') !== text) {
43
+ throw durationPricingUnavailable('The booking time is invalid for duration pricing.');
44
+ }
45
+ return value;
46
+ }
47
+ export function buildPosDurationPricingPlan(params, product) {
48
+ var _product$duration2, _product$duration3, _params$booking, _params$booking2, _params$booking3, _params$booking4;
49
+ var type = String(((_product$duration2 = product.duration) === null || _product$duration2 === void 0 ? void 0 : _product$duration2.type) || '').trim().toLowerCase();
50
+ var value = Number((_product$duration3 = product.duration) === null || _product$duration3 === void 0 ? void 0 : _product$duration3.value);
51
+ var minutes = ['hour', 'hours'].includes(type) ? value * 60 : value;
52
+ if (!['minute', 'minutes', 'hour', 'hours'].includes(type) || !Number.isFinite(minutes) || minutes <= 0) {
53
+ throw durationPricingUnavailable('A positive fixed billing duration is required.');
54
+ }
55
+ var start = bookingDateTime((_params$booking = params.booking) === null || _params$booking === void 0 ? void 0 : _params$booking.start_date, (_params$booking2 = params.booking) === null || _params$booking2 === void 0 ? void 0 : _params$booking2.start_time);
56
+ var end = bookingDateTime((_params$booking3 = params.booking) === null || _params$booking3 === void 0 ? void 0 : _params$booking3.end_date, (_params$booking4 = params.booking) === null || _params$booking4 === void 0 ? void 0 : _params$booking4.end_time);
57
+ var count = end.diff(start) / (minutes * 60000);
58
+ if (!Number.isInteger(count) || count < 1 || count > 10000) {
59
+ throw durationPricingUnavailable('The booking duration must be a whole multiple of its billing duration.');
60
+ }
61
+ return {
62
+ duration: {
63
+ type: 'minutes',
64
+ value: minutes
65
+ },
66
+ segments: Array.from({
67
+ length: count
68
+ }, function (_, index) {
69
+ return {
70
+ start: start.add(index * minutes, 'minute').format('YYYY-MM-DD HH:mm:ss'),
71
+ end: start.add((index + 1) * minutes, 'minute').format('YYYY-MM-DD HH:mm:ss')
72
+ };
73
+ })
74
+ };
75
+ }
76
+
77
+ /** Never use a previously accumulated order price as one unit's fallback. */
78
+ export function resolveDurationPricingProduct(product, selected) {
79
+ var _ref, _selected$product_var, _ref2, _product$product_vari, _product$_dataVariant, _ref3, _ref4, _priceSource$price;
80
+ var variantId = Number((_ref = (_selected$product_var = selected.product_variant_id) !== null && _selected$product_var !== void 0 ? _selected$product_var : selected.variant_id) !== null && _ref !== void 0 ? _ref : 0);
81
+ var authoritativeVariantId = Number((_ref2 = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : product.variant_id) !== null && _ref2 !== void 0 ? _ref2 : 0);
82
+ var variant = variantId > 0 && Array.isArray(product.variant) ? product.variant.find(function (item) {
83
+ return Number(item === null || item === void 0 ? void 0 : item.id) === variantId;
84
+ }) : undefined;
85
+ if (variantId > 0 && !variant && authoritativeVariantId !== variantId) {
86
+ throw durationPricingUnavailable('The selected SKU is missing from the authoritative price response.');
87
+ }
88
+ var appliedFields = (_product$_dataVariant = product._dataVariant) === null || _product$_dataVariant === void 0 ? void 0 : _product$_dataVariant.appliedFields;
89
+ var hasAppliedPrice = Array.isArray(appliedFields) && ['price', 'selling_price', 'original_price', 'base_price'].some(function (field) {
90
+ return appliedFields.includes(field);
91
+ });
92
+ var priceSource = variantId > 0 && authoritativeVariantId !== variantId && !hasAppliedPrice ? variant : product;
93
+ var price = (_ref3 = (_ref4 = (_priceSource$price = priceSource === null || priceSource === void 0 ? void 0 : priceSource.price) !== null && _priceSource$price !== void 0 ? _priceSource$price : priceSource === null || priceSource === void 0 ? void 0 : priceSource.selling_price) !== null && _ref4 !== void 0 ? _ref4 : priceSource === null || priceSource === void 0 ? void 0 : priceSource.base_price) !== null && _ref3 !== void 0 ? _ref3 : priceSource === null || priceSource === void 0 ? void 0 : priceSource.original_price;
94
+ if (!(typeof price === 'number' || typeof price === 'string' && price.trim() !== '') || !Number.isFinite(Number(price)) || Number(price) < 0) {
95
+ throw durationPricingUnavailable('An authoritative price is required for every billing unit.');
96
+ }
97
+ return _objectSpread(_objectSpread({}, product), {}, {
98
+ price: price
99
+ });
100
+ }
101
+ export function combinePosDurationPrices(plan, prices) {
102
+ var _prices$find;
103
+ if (prices.length !== plan.segments.length || prices.length === 0) {
104
+ throw durationPricingUnavailable('The duration price is incomplete.');
105
+ }
106
+ var unitPrice = prices.reduce(function (sum, price) {
107
+ return sum.plus(price.unit_price);
108
+ }, new Decimal(0));
109
+ return _objectSpread(_objectSpread({}, prices[0]), {}, {
110
+ pricing_method: {
111
+ type: 'duration_based'
112
+ },
113
+ duration: plan.duration,
114
+ unit_price: unitPrice.toFixed(2),
115
+ total_price: unitPrice.times(prices[0].quantity).toFixed(2),
116
+ quotation_shelf_id: ((_prices$find = prices.find(function (price) {
117
+ return price.quotation_shelf_id;
118
+ })) === null || _prices$find === void 0 ? void 0 : _prices$find.quotation_shelf_id) || 0,
119
+ segments: prices.map(function (price, index) {
120
+ return _objectSpread(_objectSpread({}, price.segments[0]), {}, {
121
+ start_datetime: plan.segments[index].start,
122
+ end_datetime: plan.segments[index].end,
123
+ time_point: plan.segments[index].start,
124
+ unit_price: price.unit_price,
125
+ total_price: price.unit_price,
126
+ quantity: 1
127
+ });
128
+ }),
129
+ // Options are composed by the caller; bundle pricing belongs to the first unit only.
130
+ product_bundle: prices[0].product_bundle
131
+ });
132
+ }
133
+ export function forEachPriceQueryGroup(_x, _x2, _x3) {
134
+ return _forEachPriceQueryGroup.apply(this, arguments);
135
+ }
136
+ function _forEachPriceQueryGroup() {
137
+ _forEachPriceQueryGroup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(groups, resolve, concurrency) {
138
+ var next;
139
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
140
+ while (1) switch (_context2.prev = _context2.next) {
141
+ case 0:
142
+ next = 0;
143
+ _context2.next = 3;
144
+ return Promise.all(Array.from({
145
+ length: Math.min(groups.length, concurrency)
146
+ }, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
147
+ var _group;
148
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
149
+ while (1) switch (_context.prev = _context.next) {
150
+ case 0:
151
+ if (!(next < groups.length)) {
152
+ _context.next = 6;
153
+ break;
154
+ }
155
+ _group = groups[next++];
156
+ _context.next = 4;
157
+ return resolve(_group);
158
+ case 4:
159
+ _context.next = 0;
160
+ break;
161
+ case 6:
162
+ case "end":
163
+ return _context.stop();
164
+ }
165
+ }, _callee);
166
+ }))));
167
+ case 3:
168
+ case "end":
169
+ return _context2.stop();
170
+ }
171
+ }, _callee2);
172
+ }));
173
+ return _forEachPriceQueryGroup.apply(this, arguments);
174
+ }
@@ -55,6 +55,8 @@ export interface TransformBaseProductToOrderProductParams {
55
55
  fallbackProductId?: number | string | null;
56
56
  sourceProduct?: ProductData | Record<string, any> | null;
57
57
  sourceItem?: ProductData | Record<string, any> | null;
58
+ /** Validated booking quote's pre-discount main price, excluding options/bundles. */
59
+ quotedSourceProductPrice?: number | string;
58
60
  }
59
61
  export type BaseProductOrderProductInput = Partial<OrderProduct> & OrderProductIdentity & {
60
62
  _origin?: Record<string, any>;
@@ -170,7 +170,7 @@ function findVariantById(origin, variantId) {
170
170
  * 注意:这里不生成 identity,缺省时由 OrderModule 自动补齐。
171
171
  */
172
172
  export function transformBaseProductToOrderProduct(params) {
173
- var _ref12, _ref13, _ref14, _payload$product_id, _ref15, _ref16, _payload$product_vari, _payload$_origin, _payload$_origin2, _payload$metadata, _sourceProduct$metada, _callbackOrigin$metad, _origin$metadata, _payload$metadata2, _payload$_extend, _sourceProduct$metada2, _sourceProduct$_exten, _callbackOrigin$metad2, _callbackOrigin$_exte, _payload$_dataVariant, _sourceProduct$_dataV, _callbackOrigin$_data, _origin$_dataVariant, _ref17, _findVariantById, _origin$production_co, _ref18, _ref19, _ref20, _ref21, _ref22, _matchedVariant$price, _payload$product_sku, _payload$_extend$weig, _payload$_extend2, _origin$_extend, _ref23, _ref24, _payload$price, _ref25, _payload$line_total, _payload$_extend3, _ref26, _ref27, _payload$product_sku$, _payload$product_sku2, _payload$bundle, _payload$quantity, _payload$_extend4, _extend, _extend2, _ref28, _ref29, _origin$base_price, _ref30, _ref31, _payload$line_total2, _payload$_extend5, _payload$_extend6, _extend3, _payload$_extend7, _payload$_extend8, _find, _resolveProductHolder, _ref32, _ref33, _payload$tax_fee, _ref34, _ref35, _payload$is_charge_ta;
173
+ var _ref12, _ref13, _ref14, _payload$product_id, _ref15, _ref16, _payload$product_vari, _payload$_origin, _payload$_origin2, _payload$metadata, _sourceProduct$metada, _callbackOrigin$metad, _origin$metadata, _payload$metadata2, _payload$_extend, _sourceProduct$metada2, _sourceProduct$_exten, _callbackOrigin$metad2, _callbackOrigin$_exte, _payload$_dataVariant, _sourceProduct$_dataV, _callbackOrigin$_data, _origin$_dataVariant, _ref17, _findVariantById, _origin$production_co, _ref18, _ref19, _ref20, _ref21, _ref22, _matchedVariant$price, _payload$product_sku, _payload$_extend$weig, _payload$_extend2, _origin$_extend, _ref23, _params$quotedSourceP, _ref24, _ref25, _payload$price, _ref26, _payload$line_total, _payload$_extend3, _ref27, _ref28, _payload$product_sku$, _payload$product_sku2, _payload$bundle, _payload$quantity, _payload$_extend4, _extend, _extend2, _ref29, _ref30, _origin$base_price, _ref31, _ref32, _payload$line_total2, _payload$_extend5, _payload$_extend6, _extend3, _payload$_extend7, _payload$_extend8, _find, _resolveProductHolder, _ref33, _ref34, _payload$tax_fee, _ref35, _ref36, _payload$is_charge_ta;
174
174
  var payload = params.payload,
175
175
  _params$fallbackProdu = params.fallbackProductId,
176
176
  fallbackProductId = _params$fallbackProdu === void 0 ? null : _params$fallbackProdu;
@@ -193,11 +193,11 @@ export function transformBaseProductToOrderProduct(params) {
193
193
  // 售价仍由 line_total - bundle 推导。
194
194
  var catalogSourcePrice = (_ref18 = (_ref19 = (_ref20 = (_ref21 = (_ref22 = (_matchedVariant$price = matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.price) !== null && _matchedVariant$price !== void 0 ? _matchedVariant$price : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.base_price) !== null && _ref22 !== void 0 ? _ref22 : origin === null || origin === void 0 ? void 0 : origin.price) !== null && _ref21 !== void 0 ? _ref21 : origin === null || origin === void 0 ? void 0 : origin.base_price) !== null && _ref20 !== void 0 ? _ref20 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _ref19 !== void 0 ? _ref19 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.selling_price) !== null && _ref18 !== void 0 ? _ref18 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.base_price;
195
195
  var weighedSourcePrice = resolveWeighedSourcePrice((_payload$product_sku = payload.product_sku) !== null && _payload$product_sku !== void 0 ? _payload$product_sku : origin.product_sku, (_payload$_extend$weig = (_payload$_extend2 = payload._extend) === null || _payload$_extend2 === void 0 ? void 0 : _payload$_extend2.weighing) !== null && _payload$_extend$weig !== void 0 ? _payload$_extend$weig : (_origin$_extend = origin._extend) === null || _origin$_extend === void 0 ? void 0 : _origin$_extend.weighing);
196
- var sourceProductPrice = toPriceString(weighedSourcePrice !== null && weighedSourcePrice !== void 0 ? weighedSourcePrice : hasPriceOverride ? (_ref23 = catalogSourcePrice !== null && catalogSourcePrice !== void 0 ? catalogSourcePrice : payload.price) !== null && _ref23 !== void 0 ? _ref23 : payload.selling_price : (_ref24 = (_payload$price = payload.price) !== null && _payload$price !== void 0 ? _payload$price : payload.selling_price) !== null && _ref24 !== void 0 ? _ref24 : catalogSourcePrice, '0.00');
197
- var explicitLineTotal = (_ref25 = (_payload$line_total = payload.line_total) !== null && _payload$line_total !== void 0 ? _payload$line_total : payload.total) !== null && _ref25 !== void 0 ? _ref25 : (_payload$_extend3 = payload._extend) === null || _payload$_extend3 === void 0 ? void 0 : _payload$_extend3.total;
196
+ var sourceProductPrice = toPriceString((_ref23 = (_params$quotedSourceP = params.quotedSourceProductPrice) !== null && _params$quotedSourceP !== void 0 ? _params$quotedSourceP : weighedSourcePrice) !== null && _ref23 !== void 0 ? _ref23 : hasPriceOverride ? (_ref24 = catalogSourcePrice !== null && catalogSourcePrice !== void 0 ? catalogSourcePrice : payload.price) !== null && _ref24 !== void 0 ? _ref24 : payload.selling_price : (_ref25 = (_payload$price = payload.price) !== null && _payload$price !== void 0 ? _payload$price : payload.selling_price) !== null && _ref25 !== void 0 ? _ref25 : catalogSourcePrice, '0.00');
197
+ var explicitLineTotal = (_ref26 = (_payload$line_total = payload.line_total) !== null && _payload$line_total !== void 0 ? _payload$line_total : payload.total) !== null && _ref26 !== void 0 ? _ref26 : (_payload$_extend3 = payload._extend) === null || _payload$_extend3 === void 0 ? void 0 : _payload$_extend3.total;
198
198
  var hasExplicitLineTotal = Number.isFinite(Number(explicitLineTotal));
199
199
  var lineCompositeTotal = toPriceString(explicitLineTotal, sourceProductPrice);
200
- var productOptionItem = normalizeProductSkuOptions(normalizeOptionItems((_ref26 = (_ref27 = (_payload$product_sku$ = (_payload$product_sku2 = payload.product_sku) === null || _payload$product_sku2 === void 0 ? void 0 : _payload$product_sku2.option) !== null && _payload$product_sku$ !== void 0 ? _payload$product_sku$ : payload.option) !== null && _ref27 !== void 0 ? _ref27 : payload.options) !== null && _ref26 !== void 0 ? _ref26 : payload.product_option_item, hasPriceOverride || weighedSourcePrice !== undefined));
200
+ var productOptionItem = normalizeProductSkuOptions(normalizeOptionItems((_ref27 = (_ref28 = (_payload$product_sku$ = (_payload$product_sku2 = payload.product_sku) === null || _payload$product_sku2 === void 0 ? void 0 : _payload$product_sku2.option) !== null && _payload$product_sku$ !== void 0 ? _payload$product_sku$ : payload.option) !== null && _ref28 !== void 0 ? _ref28 : payload.options) !== null && _ref27 !== void 0 ? _ref27 : payload.product_option_item, hasPriceOverride || weighedSourcePrice !== undefined));
201
201
  var productBundle = normalizeBundleItems((_payload$bundle = payload.bundle) !== null && _payload$bundle !== void 0 ? _payload$bundle : payload.product_bundle, hasPriceOverride, hasPriceOverride && weighedSourcePrice !== undefined);
202
202
  // `payload.unique` 是业务侧商品/票务标识,可能在连续加同一商品时重复;
203
203
  // 行级唯一值只接受显式协议字段,缺省交给 OrderModule 生成。
@@ -212,10 +212,10 @@ export function transformBaseProductToOrderProduct(params) {
212
212
  extendOriginTotal: (_payload$_extend4 = payload._extend) === null || _payload$_extend4 === void 0 ? void 0 : _payload$_extend4.origin_total,
213
213
  originExtendOriginTotal: origin === null || origin === void 0 || (_extend = origin._extend) === null || _extend === void 0 ? void 0 : _extend.origin_total,
214
214
  sourceExtendOriginTotal: sourceProduct === null || sourceProduct === void 0 || (_extend2 = sourceProduct._extend) === null || _extend2 === void 0 ? void 0 : _extend2.origin_total,
215
- catalogUnitPrice: (_ref28 = (_ref29 = (_origin$base_price = origin === null || origin === void 0 ? void 0 : origin.base_price) !== null && _origin$base_price !== void 0 ? _origin$base_price : origin === null || origin === void 0 ? void 0 : origin.price) !== null && _ref29 !== void 0 ? _ref29 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.base_price) !== null && _ref28 !== void 0 ? _ref28 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price,
215
+ catalogUnitPrice: (_ref29 = (_ref30 = (_origin$base_price = origin === null || origin === void 0 ? void 0 : origin.base_price) !== null && _origin$base_price !== void 0 ? _origin$base_price : origin === null || origin === void 0 ? void 0 : origin.price) !== null && _ref30 !== void 0 ? _ref30 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.base_price) !== null && _ref29 !== void 0 ? _ref29 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price,
216
216
  quantity: resolvedQuantity
217
217
  });
218
- var sellingTotal = Number((_ref30 = (_ref31 = (_payload$line_total2 = payload.line_total) !== null && _payload$line_total2 !== void 0 ? _payload$line_total2 : payload.total) !== null && _ref31 !== void 0 ? _ref31 : (_payload$_extend5 = payload._extend) === null || _payload$_extend5 === void 0 ? void 0 : _payload$_extend5.total) !== null && _ref30 !== void 0 ? _ref30 : lineCompositeTotal);
218
+ var sellingTotal = Number((_ref31 = (_ref32 = (_payload$line_total2 = payload.line_total) !== null && _payload$line_total2 !== void 0 ? _payload$line_total2 : payload.total) !== null && _ref32 !== void 0 ? _ref32 : (_payload$_extend5 = payload._extend) === null || _payload$_extend5 === void 0 ? void 0 : _payload$_extend5.total) !== null && _ref31 !== void 0 ? _ref31 : lineCompositeTotal);
219
219
  var discountReason = resolveManualDiscountReasonFromSources({
220
220
  discountReason: payload.discount_reason,
221
221
  extendDiscountReason: (_payload$_extend6 = payload._extend) === null || _payload$_extend6 === void 0 ? void 0 : _payload$_extend6.discount_reason,
@@ -297,8 +297,8 @@ export function transformBaseProductToOrderProduct(params) {
297
297
  // 折后行价由 normalizeOrderProduct 按 main + bundle 合成;手动改价时 bundle 已为分摊后单价
298
298
  selling_price: lineCompositeTotal,
299
299
  original_price: lineOriginalPrice,
300
- tax_fee: toPriceString((_ref32 = (_ref33 = (_payload$tax_fee = payload.tax_fee) !== null && _payload$tax_fee !== void 0 ? _payload$tax_fee : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.tax_fee) !== null && _ref33 !== void 0 ? _ref33 : origin === null || origin === void 0 ? void 0 : origin.tax_fee) !== null && _ref32 !== void 0 ? _ref32 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.tax_fee, '0.00'),
301
- is_charge_tax: toNumber((_ref34 = (_ref35 = (_payload$is_charge_ta = payload.is_charge_tax) !== null && _payload$is_charge_ta !== void 0 ? _payload$is_charge_ta : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.is_charge_tax) !== null && _ref35 !== void 0 ? _ref35 : origin === null || origin === void 0 ? void 0 : origin.is_charge_tax) !== null && _ref34 !== void 0 ? _ref34 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.is_charge_tax, 0),
300
+ tax_fee: toPriceString((_ref33 = (_ref34 = (_payload$tax_fee = payload.tax_fee) !== null && _payload$tax_fee !== void 0 ? _payload$tax_fee : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.tax_fee) !== null && _ref34 !== void 0 ? _ref34 : origin === null || origin === void 0 ? void 0 : origin.tax_fee) !== null && _ref33 !== void 0 ? _ref33 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.tax_fee, '0.00'),
301
+ is_charge_tax: toNumber((_ref35 = (_ref36 = (_payload$is_charge_ta = payload.is_charge_tax) !== null && _payload$is_charge_ta !== void 0 ? _payload$is_charge_ta : matchedVariant === null || matchedVariant === void 0 ? void 0 : matchedVariant.is_charge_tax) !== null && _ref36 !== void 0 ? _ref36 : origin === null || origin === void 0 ? void 0 : origin.is_charge_tax) !== null && _ref35 !== void 0 ? _ref35 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.is_charge_tax, 0),
302
302
  metadata: metadata
303
303
  }, holderRelations !== undefined && !isBookingProduct(origin) && !isBookingProduct(payload) ? {
304
304
  _extend: {
@@ -328,7 +328,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
328
328
  date: string;
329
329
  status: string;
330
330
  week: string;
331
- weekNum: 0 | 1 | 2 | 5 | 4 | 3 | 6;
331
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
332
332
  }[]>;
333
333
  submitTimeSlot(timeSlots: TimeSliceItem): void;
334
334
  private getScheduleDataByIds;
@@ -347,7 +347,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
347
347
  count: number;
348
348
  left: number;
349
349
  summaryCount: number;
350
- status: "sold_out" | "lots_of_space" | "filling_up_fast";
350
+ status: "lots_of_space" | "filling_up_fast" | "sold_out";
351
351
  }[];
352
352
  /**
353
353
  * 找到多个资源的公共可用时间段
@@ -375,7 +375,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
375
375
  };
376
376
  setOtherData(key: string, value: any): void;
377
377
  getOtherData(key: string): any;
378
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
378
+ getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
379
379
  /**
380
380
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
381
381
  *
@@ -485,19 +485,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
485
485
  * 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
486
486
  * 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
487
487
  */
488
- decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): {
489
- action: "reloadCatalog";
490
- } | {
491
- action: "add";
492
- cacheItem: any;
493
- } | {
494
- action: "requiresDetail";
495
- payload: AddProductRequiresDetailPayload;
496
- } | {
497
- action: "requiresBookingEdit";
498
- cacheItem: any;
499
- payload: import("./utils/addProductDecision").AddProductRequiresBookingEditPayload;
500
- };
488
+ decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
501
489
  /** 规格弹窗 callback 后的第二段决策。 */
502
490
  decideAfterDetail(cacheItem: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
503
491
  /**
@@ -3579,10 +3579,21 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3579
3579
  }, {
3580
3580
  key: "buildUnifiedOrderProduct",
3581
3581
  value: function buildUnifiedOrderProduct(sourceProduct, ownershipKey, product) {
3582
- var _ref40, _sourceProduct$_exten, _sourceProduct$_exten2, _sourceProduct$metada, _sourceProduct$id, _ref41, _sourceProduct$produc, _ref42, _ref43, _sourceProduct$quanti, _sourceProduct$price, _ref44, _ref45, _sourceProduct$sellin;
3582
+ var _sourceProduct$_exten, _this$otherParams26, _bookingQuote$pricing, _ref40, _sourceProduct$_exten2, _sourceProduct$_exten3, _sourceProduct$metada, _sourceProduct$id, _ref41, _sourceProduct$produc, _ref42, _ref43, _sourceProduct$quanti, _sourceProduct$price, _ref44, _ref45, _sourceProduct$sellin;
3583
3583
  var normalizedProductRaw = (product === null || product === void 0 ? void 0 : product.raw) || {};
3584
- var quotationShelfId = (_ref40 = (_sourceProduct$_exten = (_sourceProduct$_exten2 = sourceProduct._extend) === null || _sourceProduct$_exten2 === void 0 ? void 0 : _sourceProduct$_exten2.quotation_shelf_id) !== null && _sourceProduct$_exten !== void 0 ? _sourceProduct$_exten : sourceProduct.quotation_shelf_id) !== null && _ref40 !== void 0 ? _ref40 : (_sourceProduct$metada = sourceProduct.metadata) === null || _sourceProduct$metada === void 0 ? void 0 : _sourceProduct$metada.quotation_shelf_id;
3585
- var orderProduct = this.transformBaseProductToOrderProduct({
3584
+ var bookingQuote = (_sourceProduct$_exten = sourceProduct._extend) === null || _sourceProduct$_exten === void 0 ? void 0 : _sourceProduct$_exten.bookingPriceQuote;
3585
+ var isPos = normalizeRuntimePlatform((_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.platform) === 'pos';
3586
+ var quoteMethod = isPos ? bookingQuote === null || bookingQuote === void 0 || (_bookingQuote$pricing = bookingQuote.pricing_method) === null || _bookingQuote$pricing === void 0 ? void 0 : _bookingQuote$pricing.type : undefined;
3587
+ var hasDurationQuote = quoteMethod === 'duration_based';
3588
+ var quoteSourcePrice = bookingQuote === null || bookingQuote === void 0 ? void 0 : bookingQuote.sourceUnitPrice;
3589
+ var quoteDuration = bookingQuote === null || bookingQuote === void 0 ? void 0 : bookingQuote.duration;
3590
+ if (hasDurationQuote && (quoteSourcePrice === undefined || quoteSourcePrice === null || quoteSourcePrice === '' || !Number.isFinite(Number(quoteSourcePrice)) || Number(quoteSourcePrice) < 0 || (quoteDuration === null || quoteDuration === void 0 ? void 0 : quoteDuration.type) !== 'minutes' || !Number.isFinite(Number(quoteDuration.value)) || Number(quoteDuration.value) <= 0)) {
3591
+ throw Object.assign(new Error('按时长计价结果无效,请重新选择预约时间。'), {
3592
+ code: 'DURATION_PRICING_UNAVAILABLE'
3593
+ });
3594
+ }
3595
+ var quotationShelfId = (_ref40 = (_sourceProduct$_exten2 = (_sourceProduct$_exten3 = sourceProduct._extend) === null || _sourceProduct$_exten3 === void 0 ? void 0 : _sourceProduct$_exten3.quotation_shelf_id) !== null && _sourceProduct$_exten2 !== void 0 ? _sourceProduct$_exten2 : sourceProduct.quotation_shelf_id) !== null && _ref40 !== void 0 ? _ref40 : (_sourceProduct$metada = sourceProduct.metadata) === null || _sourceProduct$metada === void 0 ? void 0 : _sourceProduct$metada.quotation_shelf_id;
3596
+ var orderProduct = this.transformBaseProductToOrderProduct(_objectSpread({
3586
3597
  payload: _objectSpread(_objectSpread({}, sourceProduct), {}, {
3587
3598
  id: (_sourceProduct$id = sourceProduct.id) !== null && _sourceProduct$id !== void 0 ? _sourceProduct$id : product === null || product === void 0 ? void 0 : product.id,
3588
3599
  product_id: (_ref41 = (_sourceProduct$produc = sourceProduct.product_id) !== null && _sourceProduct$produc !== void 0 ? _sourceProduct$produc : sourceProduct.id) !== null && _ref41 !== void 0 ? _ref41 : product === null || product === void 0 ? void 0 : product.id,
@@ -3592,11 +3603,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3592
3603
  metadata: _objectSpread(_objectSpread({}, sourceProduct.metadata || {}), {}, _defineProperty({}, ownershipKey, true))
3593
3604
  }),
3594
3605
  sourceProduct: sourceProduct
3595
- });
3606
+ }, hasDurationQuote ? {
3607
+ quotedSourceProductPrice: quoteSourcePrice
3608
+ } : {}));
3596
3609
  if (orderProduct && _typeof(orderProduct) === 'object') {
3597
3610
  // BaseSales may rebuild metadata from its price source. Stamp ownership and the selected
3598
3611
  // quotation shelf after that transform so neither booking adds nor edits lose quote identity.
3599
- orderProduct.metadata = _objectSpread(_objectSpread({}, orderProduct.metadata || {}), {}, _defineProperty({}, ownershipKey, true), quotationShelfId !== undefined ? {
3612
+ orderProduct.metadata = _objectSpread(_objectSpread(_objectSpread({}, orderProduct.metadata || {}), {}, _defineProperty({}, ownershipKey, true), hasDurationQuote || quoteMethod === 'fixed_price' ? {
3613
+ pricing_method: {
3614
+ type: quoteMethod
3615
+ },
3616
+ duration: hasDurationQuote ? _objectSpread({}, quoteDuration) : undefined
3617
+ } : {}), quotationShelfId !== undefined ? {
3600
3618
  quotation_shelf_id: quotationShelfId
3601
3619
  } : {});
3602
3620
  }
@@ -5161,7 +5179,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5161
5179
  value: (function () {
5162
5180
  var _getProductTimeRanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(contextId) {
5163
5181
  var _this$otherParams$pla2,
5164
- _this$otherParams26,
5182
+ _this$otherParams27,
5165
5183
  _context$prepareParam,
5166
5184
  _extractFixedOffsetMi,
5167
5185
  _this13 = this;
@@ -5191,7 +5209,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5191
5209
  context = _yield$this$ensureAva.context;
5192
5210
  projectionEntry = _yield$this$ensureAva.projectionEntry;
5193
5211
  contextVersion = context.activeVersion;
5194
- isPosAvailabilityRequest = String((_this$otherParams$pla2 = (_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26.platform) !== null && _this$otherParams$pla2 !== void 0 ? _this$otherParams$pla2 : '').trim().toLowerCase() === 'pos';
5212
+ isPosAvailabilityRequest = String((_this$otherParams$pla2 = (_this$otherParams27 = this.otherParams) === null || _this$otherParams27 === void 0 ? void 0 : _this$otherParams27.platform) !== null && _this$otherParams$pla2 !== void 0 ? _this$otherParams$pla2 : '').trim().toLowerCase() === 'pos';
5195
5213
  isEditingContext = Boolean((_context$prepareParam = context.prepareParams.editingProductLineUids) === null || _context$prepareParam === void 0 ? void 0 : _context$prepareParam.length);
5196
5214
  editingOffset = (_extractFixedOffsetMi = extractFixedOffsetMinutes(projectionEntry.projection.meta.now)) !== null && _extractFixedOffsetMi !== void 0 ? _extractFixedOffsetMi : this.getAvailabilityRuntimeOffsetMinutes(); // This new editing input represents an absolute instant. Normalize it once
5197
5215
  // to the projection's fixed business clock before the wall-clock planner.
@@ -5259,7 +5277,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5259
5277
  key: "queryBookingAvailability",
5260
5278
  value: (function () {
5261
5279
  var _queryBookingAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(contextId, request) {
5262
- var _this$otherParams$pla3, _this$otherParams27, _context$prepareParam2;
5280
+ var _this$otherParams$pla3, _this$otherParams28, _context$prepareParam2;
5263
5281
  var _yield$this$ensureAva2, context, projectionEntry, refreshed, isPosAvailabilityRequest, queryRequest, result, contextVersion, contextualResult;
5264
5282
  return _regeneratorRuntime().wrap(function _callee49$(_context49) {
5265
5283
  while (1) switch (_context49.prev = _context49.next) {
@@ -5272,7 +5290,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5272
5290
  projectionEntry = _yield$this$ensureAva2.projectionEntry;
5273
5291
  refreshed = _yield$this$ensureAva2.refreshed;
5274
5292
  this.assertContextualQueryFreshness(context, request);
5275
- isPosAvailabilityRequest = String((_this$otherParams$pla3 = (_this$otherParams27 = this.otherParams) === null || _this$otherParams27 === void 0 ? void 0 : _this$otherParams27.platform) !== null && _this$otherParams$pla3 !== void 0 ? _this$otherParams$pla3 : '').trim().toLowerCase() === 'pos';
5293
+ isPosAvailabilityRequest = String((_this$otherParams$pla3 = (_this$otherParams28 = this.otherParams) === null || _this$otherParams28 === void 0 ? void 0 : _this$otherParams28.platform) !== null && _this$otherParams$pla3 !== void 0 ? _this$otherParams$pla3 : '').trim().toLowerCase() === 'pos';
5276
5294
  queryRequest = request.target === 'date' || request.target === 'product' ? _objectSpread(_objectSpread({}, request), {}, {
5277
5295
  dateRange: request.dateRange || this.getAvailabilityBusinessDateRange(projectionEntry.projection)
5278
5296
  }) : request;
@@ -5389,14 +5407,14 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5389
5407
  value: function () {
5390
5408
  var _removeBookingProductsOutsideStartDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(startDate) {
5391
5409
  var _this$getTempOrder4,
5392
- _this$otherParams28,
5410
+ _this$otherParams29,
5393
5411
  _this14 = this;
5394
5412
  var products, targetDate, identities;
5395
5413
  return _regeneratorRuntime().wrap(function _callee50$(_context50) {
5396
5414
  while (1) switch (_context50.prev = _context50.next) {
5397
5415
  case 0:
5398
5416
  products = ((_this$getTempOrder4 = this.getTempOrder()) === null || _this$getTempOrder4 === void 0 ? void 0 : _this$getTempOrder4.products) || [];
5399
- if (!(((_this$otherParams28 = this.otherParams) === null || _this$otherParams28 === void 0 ? void 0 : _this$otherParams28.enforceSingleBookingStartDate) !== true)) {
5417
+ if (!(((_this$otherParams29 = this.otherParams) === null || _this$otherParams29 === void 0 ? void 0 : _this$otherParams29.enforceSingleBookingStartDate) !== true)) {
5400
5418
  _context50.next = 3;
5401
5419
  break;
5402
5420
  }
@@ -5436,12 +5454,12 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5436
5454
  value: (function () {
5437
5455
  var _commitAvailabilitySelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(contextId, params) {
5438
5456
  var _this$otherParams$pla4,
5439
- _this$otherParams29,
5457
+ _this$otherParams30,
5440
5458
  _params$availabilityC,
5441
5459
  _this$store$order11,
5442
5460
  _this$store$order11$e,
5443
5461
  _this15 = this;
5444
- var normalizedContextId, isRememberedSelection, hasCommitGuard, rememberedOrder, getRememberedCommitIdentity, rememberedCommitIdentity, availabilityCommitTargetGuard, guardedCommitPublished, _params$bookingCount, _ref55, _params$orderProduct$, _params$orderProduct, _params$orderProduct2, _params$orderProduct3, _params$orderProduct$2, _params$orderProduct4, _params$orderProduct5, _editingLine$product_, _this$otherParams$pla5, _this$otherParams30, _baseProjection$meta$, _refreshedProjection$, _baseProjection$meta$2, _this$otherParams$pla6, _this$otherParams31, _ref56, _params$orderProduct$3, _params$orderProduct6, _existingBooking$meta, _ref57, _ref58, _params$orderProduct$4, _params$orderProduct7, _params$orderProduct8, _existingBooking$meta2, _existingBooking$hold, _params$orderProduct9, _nextContext$activeVe, bookingCount, orderProductQuantity, partySize, _yield$this$ensureAva3, context, projectionEntry, refreshed, boundEditingUids, orderProductId, editingLine, _editingLine$product_2, baseProjection, selectedProduct, commitWriteGuard, prepareParams, fallbackResources, commitSnapshot, refreshedProjection, _baseProjection$meta$3, latestContext, candidateDurationMinutes, candidateStartTime, allowPosAvailabilityOverride, candidateBusinessDate, refreshedRanges, refreshedCandidateBase, product, validation, forced, capacityConflict, revalidationEntry, revalidatedContext, refreshedCandidate, availabilityCommitGuard, existingBooking, existingBookingUid, booking, legacyBooking, legacyResources, selectedResources, resourceKeys, transformed, productLineUid, bookingUid, productLineUids, bookingUids, _transformed$product_, _transformed$product_2, _transformed$product_3, _ref59, _transformed$product_4, _this$getTempOrder5, _this$getTempOrder6, _params$salesNotes, _params$salesNotes2, _ref60, beforeProductLineUids, beforeBookingUids, products, addedLines, addedBookings, targetStillCurrent, nextContext, result, emit, release;
5462
+ var normalizedContextId, isRememberedSelection, hasCommitGuard, rememberedOrder, getRememberedCommitIdentity, rememberedCommitIdentity, availabilityCommitTargetGuard, guardedCommitPublished, _params$bookingCount, _ref55, _params$orderProduct$, _params$orderProduct, _params$orderProduct2, _params$orderProduct3, _params$orderProduct$2, _params$orderProduct4, _params$orderProduct5, _editingLine$product_, _this$otherParams$pla5, _this$otherParams31, _baseProjection$meta$, _refreshedProjection$, _baseProjection$meta$2, _this$otherParams$pla6, _this$otherParams32, _ref56, _params$orderProduct$3, _params$orderProduct6, _existingBooking$meta, _ref57, _ref58, _params$orderProduct$4, _params$orderProduct7, _params$orderProduct8, _existingBooking$meta2, _existingBooking$hold, _params$orderProduct9, _nextContext$activeVe, bookingCount, orderProductQuantity, partySize, _yield$this$ensureAva3, context, projectionEntry, refreshed, boundEditingUids, orderProductId, editingLine, _editingLine$product_2, baseProjection, selectedProduct, commitWriteGuard, prepareParams, fallbackResources, commitSnapshot, refreshedProjection, _baseProjection$meta$3, latestContext, candidateDurationMinutes, candidateStartTime, allowPosAvailabilityOverride, candidateBusinessDate, refreshedRanges, refreshedCandidateBase, product, validation, forced, capacityConflict, revalidationEntry, revalidatedContext, refreshedCandidate, availabilityCommitGuard, existingBooking, existingBookingUid, booking, legacyBooking, legacyResources, selectedResources, resourceKeys, transformed, productLineUid, bookingUid, productLineUids, bookingUids, _transformed$product_, _transformed$product_2, _transformed$product_3, _ref59, _transformed$product_4, _this$getTempOrder5, _this$getTempOrder6, _params$salesNotes, _params$salesNotes2, _ref60, beforeProductLineUids, beforeBookingUids, products, addedLines, addedBookings, targetStillCurrent, nextContext, result, emit, release;
5445
5463
  return _regeneratorRuntime().wrap(function _callee51$(_context51) {
5446
5464
  while (1) switch (_context51.prev = _context51.next) {
5447
5465
  case 0:
@@ -5455,7 +5473,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5455
5473
  });
5456
5474
  case 3:
5457
5475
  isRememberedSelection = params.selectionIntent === 'remembered';
5458
- if (!(isRememberedSelection && (String((_this$otherParams$pla4 = (_this$otherParams29 = this.otherParams) === null || _this$otherParams29 === void 0 ? void 0 : _this$otherParams29.platform) !== null && _this$otherParams$pla4 !== void 0 ? _this$otherParams$pla4 : '').trim().toLowerCase() !== 'pos' || params.mode !== 'add'))) {
5476
+ if (!(isRememberedSelection && (String((_this$otherParams$pla4 = (_this$otherParams30 = this.otherParams) === null || _this$otherParams30 === void 0 ? void 0 : _this$otherParams30.platform) !== null && _this$otherParams$pla4 !== void 0 ? _this$otherParams$pla4 : '').trim().toLowerCase() !== 'pos' || params.mode !== 'add'))) {
5459
5477
  _context51.next = 6;
5460
5478
  break;
5461
5479
  }
@@ -5644,7 +5662,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5644
5662
  selectedProduct = baseProjection.products.find(function (item) {
5645
5663
  return sameAvailabilityId(item.id, params.candidate.productId);
5646
5664
  });
5647
- if (!(isRememberedSelection && (String((_this$otherParams$pla5 = (_this$otherParams30 = this.otherParams) === null || _this$otherParams30 === void 0 ? void 0 : _this$otherParams30.platform) !== null && _this$otherParams$pla5 !== void 0 ? _this$otherParams$pla5 : '').trim().toLowerCase() !== 'pos' || params.mode !== 'add' || (selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.kind) !== 'duration'))) {
5665
+ if (!(isRememberedSelection && (String((_this$otherParams$pla5 = (_this$otherParams31 = this.otherParams) === null || _this$otherParams31 === void 0 ? void 0 : _this$otherParams31.platform) !== null && _this$otherParams$pla5 !== void 0 ? _this$otherParams$pla5 : '').trim().toLowerCase() !== 'pos' || params.mode !== 'add' || (selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.kind) !== 'duration'))) {
5648
5666
  _context51.next = 67;
5649
5667
  break;
5650
5668
  }
@@ -5707,7 +5725,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
5707
5725
  this.assertAvailabilityCommitWriteCAS(commitWriteGuard);
5708
5726
  candidateDurationMinutes = getCandidateDurationMinutes(params.candidate);
5709
5727
  candidateStartTime = getCandidateStartTime(params.candidate);
5710
- allowPosAvailabilityOverride = String((_this$otherParams$pla6 = (_this$otherParams31 = this.otherParams) === null || _this$otherParams31 === void 0 ? void 0 : _this$otherParams31.platform) !== null && _this$otherParams$pla6 !== void 0 ? _this$otherParams$pla6 : '').trim().toLowerCase() === 'pos' && !isRememberedSelection;
5728
+ allowPosAvailabilityOverride = String((_this$otherParams$pla6 = (_this$otherParams32 = this.otherParams) === null || _this$otherParams32 === void 0 ? void 0 : _this$otherParams32.platform) !== null && _this$otherParams$pla6 !== void 0 ? _this$otherParams$pla6 : '').trim().toLowerCase() === 'pos' && !isRememberedSelection;
5711
5729
  candidateBusinessDate = params.candidate.businessDate || ((selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.kind) === 'duration' && this.usesDurationTimeGrid(refreshedProjection) ? getDurationBusinessDate(refreshedProjection, params.candidate.startAt) : params.candidate.startAt.slice(0, 10));
5712
5730
  refreshedRanges = getProjectionProductTimeRanges(refreshedProjection, _objectSpread({
5713
5731
  productIds: [params.candidate.productId],
@@ -595,7 +595,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
595
595
  generateIdempotencyToken(): string;
596
596
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
597
597
  createOrder(params: CommitOrderParams['query']): {
598
- type: "virtual" | "appointment_booking";
598
+ type: "appointment_booking" | "virtual";
599
599
  platform: string;
600
600
  sales_channel: string;
601
601
  order_sales_channel: string;
@@ -1274,6 +1274,19 @@ function normalizeSubmitProduct(product, formatOptions = {}) {
1274
1274
  cleanMetadata[key] = rawMetadata[key];
1275
1275
  }
1276
1276
  }
1277
+ // Persist only an applied pricing snapshot, so reopening a saved order can
1278
+ // compare it with the latest catalog without reinterpreting legacy duration.
1279
+ const pricingMethod = rawMetadata.pricing_method?.type;
1280
+ if (pricingMethod === 'duration_based' || pricingMethod === 'fixed_price') {
1281
+ cleanMetadata.pricing_method = {
1282
+ type: pricingMethod
1283
+ };
1284
+ if (pricingMethod === 'duration_based' && rawMetadata.duration) {
1285
+ cleanMetadata.duration = {
1286
+ ...rawMetadata.duration
1287
+ };
1288
+ }
1289
+ }
1277
1290
  cleanMetadata.product_discount_difference = rawMetadata.product_discount_difference ?? '';
1278
1291
  if (rawMetadata.price_breakdown) {
1279
1292
  cleanMetadata.price_breakdown = rawMetadata.price_breakdown;
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "duration" | "session" | "normal";
53
53
  }
@@ -42,6 +42,9 @@ export interface ProductSettlementOption extends Record<string, any> {
42
42
  available: boolean;
43
43
  disabled_reason?: string;
44
44
  }
45
+ export interface ProductPricingMethod {
46
+ type: 'fixed_price' | 'duration_based';
47
+ }
45
48
  /**
46
49
  * 商品基本信息接口
47
50
  */
@@ -74,6 +77,8 @@ export interface ProductData {
74
77
  sum_stock: number;
75
78
  /** 商品价格 */
76
79
  price: string;
80
+ /** POS booking pricing; missing configuration retains existing fixed pricing. */
81
+ pricing_method?: ProductPricingMethod;
77
82
  /** 当前上下文解析出的可选结算货币 */
78
83
  available_settlement_options?: ProductSettlementOption[];
79
84
  /** 商品原价 */
@@ -2475,7 +2475,10 @@ class Server {
2475
2475
  };
2476
2476
  }
2477
2477
  try {
2478
- const response = await this.app.request.post('/shop/order/v2/list', data, {
2478
+ const response = await this.app.request.post('/shop/order/v2/list', {
2479
+ ...data,
2480
+ with: [...new Set([...(Array.isArray(data.with) ? data.with : []), 'buzzer'])]
2481
+ }, {
2479
2482
  isShopApi: true
2480
2483
  });
2481
2484
  const payload = response?.data ?? response;
@@ -519,6 +519,8 @@ export interface OrderFilters {
519
519
  max_total_amount?: number;
520
520
  tag_ids?: (string | number)[];
521
521
  shipping_type?: string[];
522
+ /** 交付方式,精确匹配 metadata.shop_service_data.service_type;多选之间为 OR */
523
+ service_type?: string[];
522
524
  delivery_zone_name?: string;
523
525
  location_id?: string | number;
524
526
  shipping_order_number?: string;
@@ -247,6 +247,24 @@ function filterOrders(orders, filters) {
247
247
  }
248
248
  }
249
249
 
250
+ // service_type - 交付方式(同组多选 OR,与其他条件 AND)
251
+ if (Array.isArray(safeFilters.service_type) && safeFilters.service_type.length > 0) {
252
+ const shopServiceData = order.metadata?.shop_service_data;
253
+ const serviceType = shopServiceData && typeof shopServiceData === 'object' ? shopServiceData.service_type : undefined;
254
+ if (typeof serviceType !== 'string' || !safeFilters.service_type.includes(serviceType)) {
255
+ rejected.push({
256
+ order_id: order.order_id,
257
+ order_number: order.order_number,
258
+ reason: {
259
+ field: 'service_type',
260
+ actual: serviceType,
261
+ expected: safeFilters.service_type
262
+ }
263
+ });
264
+ return false;
265
+ }
266
+ }
267
+
250
268
  // delivery_zone_name - 配送区域(模糊匹配)
251
269
  if (safeFilters.delivery_zone_name !== undefined && safeFilters.delivery_zone_name !== null && safeFilters.delivery_zone_name !== '') {
252
270
  if (!order.delivery_zone_name || !order.delivery_zone_name.toLowerCase().includes(safeFilters.delivery_zone_name.toLowerCase())) {