@pisell/pisellos 2.2.230 → 2.2.231

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 (33) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  2. package/dist/modules/Order/index.js +44 -29
  3. package/dist/modules/Order/types.d.ts +14 -2
  4. package/dist/modules/Order/types.js +8 -1
  5. package/dist/modules/ProductList/index.d.ts +9 -12
  6. package/dist/modules/ProductList/index.js +122 -59
  7. package/dist/modules/ProductList/types.d.ts +14 -0
  8. package/dist/server/index.d.ts +21 -0
  9. package/dist/server/index.js +154 -34
  10. package/dist/server/utils/small-ticket.js +113 -29
  11. package/dist/solution/BookingByStep/index.d.ts +1 -1
  12. package/dist/solution/BookingTicket/index.d.ts +8 -0
  13. package/dist/solution/BookingTicket/index.js +191 -154
  14. package/dist/solution/BookingTicket/types.d.ts +4 -0
  15. package/dist/solution/BookingTicket/utils/cartView.js +20 -6
  16. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +189 -0
  17. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.js +429 -0
  18. package/lib/modules/Order/index.js +18 -5
  19. package/lib/modules/Order/types.d.ts +14 -2
  20. package/lib/modules/ProductList/index.d.ts +9 -12
  21. package/lib/modules/ProductList/index.js +32 -4
  22. package/lib/modules/ProductList/types.d.ts +14 -0
  23. package/lib/server/index.d.ts +21 -0
  24. package/lib/server/index.js +107 -9
  25. package/lib/server/utils/small-ticket.js +78 -1
  26. package/lib/solution/BookingByStep/index.d.ts +1 -1
  27. package/lib/solution/BookingTicket/index.d.ts +8 -0
  28. package/lib/solution/BookingTicket/index.js +16 -0
  29. package/lib/solution/BookingTicket/types.d.ts +4 -0
  30. package/lib/solution/BookingTicket/utils/cartView.js +14 -7
  31. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +189 -0
  32. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +241 -0
  33. package/package.json +1 -1
@@ -0,0 +1,9 @@
1
+ // 导出评估器
2
+ export { PromotionEvaluator } from "./evaluator";
3
+
4
+ // 导出适配器
5
+ export { PromotionAdapter } from "./adapter";
6
+ export { default } from "./adapter";
7
+
8
+ // 导出策略配置示例常量
9
+ export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY } from "./examples";
@@ -1,8 +1,8 @@
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); }
1
2
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
3
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
4
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
4
5
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
5
- 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); }
6
6
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
7
7
  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."); }
8
8
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
@@ -821,7 +821,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
821
821
  _iterator4 = _createForOfIteratorHelper(result.giftActions.toAdd);
822
822
  _context7.prev = 48;
823
823
  _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop() {
824
- var addAction, sameStrategy, giftProducts, _iterator5, _step5, gp;
824
+ var addAction, _sameStrategy$metadat, sameStrategy, giftResult, giftProducts, giftBookings, _iterator5, _step5, _step5$value, index, gp, booking, linked;
825
825
  return _regeneratorRuntime().wrap(function _loop$(_context5) {
826
826
  while (1) switch (_context5.prev = _context5.next) {
827
827
  case 0:
@@ -834,7 +834,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
834
834
  var _p$metadata;
835
835
  return ((_p$metadata = p.metadata) === null || _p$metadata === void 0 || (_p$metadata = _p$metadata._giftInfo) === null || _p$metadata === void 0 ? void 0 : _p$metadata.strategyId) === addAction.strategyId;
836
836
  });
837
- if (!sameStrategy) {
837
+ if (!(sameStrategy && !sameStrategy.booking_uid && !((_sameStrategy$metadat = sameStrategy.metadata) !== null && _sameStrategy$metadat !== void 0 && _sameStrategy$metadat.booking_uid))) {
838
838
  _context5.next = 6;
839
839
  break;
840
840
  }
@@ -851,55 +851,70 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
851
851
  sourceProductIds: addAction.sourceProductIds
852
852
  });
853
853
  case 9:
854
- giftProducts = _context5.sent;
854
+ giftResult = _context5.sent;
855
+ giftProducts = Array.isArray(giftResult) ? giftResult : giftResult === null || giftResult === void 0 ? void 0 : giftResult.products;
856
+ giftBookings = Array.isArray(giftResult) ? [] : (giftResult === null || giftResult === void 0 ? void 0 : giftResult.bookings) || [];
855
857
  if (!(Array.isArray(giftProducts) && giftProducts.length > 0)) {
856
- _context5.next = 29;
858
+ _context5.next = 37;
857
859
  break;
858
860
  }
859
- _iterator5 = _createForOfIteratorHelper(giftProducts);
860
- _context5.prev = 12;
861
+ _iterator5 = _createForOfIteratorHelper(giftProducts.entries());
862
+ _context5.prev = 14;
861
863
  _iterator5.s();
862
- case 14:
864
+ case 16:
863
865
  if ((_step5 = _iterator5.n()).done) {
864
- _context5.next = 21;
866
+ _context5.next = 29;
865
867
  break;
866
868
  }
867
- gp = _step5.value;
869
+ _step5$value = _slicedToArray(_step5.value, 2), index = _step5$value[0], gp = _step5$value[1];
868
870
  if (gp) {
869
- _context5.next = 18;
871
+ _context5.next = 20;
870
872
  break;
871
873
  }
872
- return _context5.abrupt("continue", 19);
873
- case 18:
874
- // normalize 略过:调用方应保证返回完整 OrderProduct
874
+ return _context5.abrupt("continue", 27);
875
+ case 20:
876
+ booking = giftBookings[index];
877
+ if (!booking) {
878
+ _context5.next = 26;
879
+ break;
880
+ }
881
+ linked = _this2.createLinkedProductAndBooking({
882
+ product: gp,
883
+ booking: booking
884
+ });
885
+ result.products.push(linked.product);
886
+ tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
887
+ return _context5.abrupt("continue", 27);
888
+ case 26:
889
+ // normalize 略过:调用方应保证返回完整 OrderProduct。
875
890
  result.products.push(gp);
876
- case 19:
877
- _context5.next = 14;
878
- break;
879
- case 21:
880
- _context5.next = 26;
891
+ case 27:
892
+ _context5.next = 16;
881
893
  break;
882
- case 23:
883
- _context5.prev = 23;
884
- _context5.t0 = _context5["catch"](12);
885
- _iterator5.e(_context5.t0);
886
- case 26:
887
- _context5.prev = 26;
888
- _iterator5.f();
889
- return _context5.finish(26);
890
894
  case 29:
891
895
  _context5.next = 34;
892
896
  break;
893
897
  case 31:
894
898
  _context5.prev = 31;
899
+ _context5.t0 = _context5["catch"](14);
900
+ _iterator5.e(_context5.t0);
901
+ case 34:
902
+ _context5.prev = 34;
903
+ _iterator5.f();
904
+ return _context5.finish(34);
905
+ case 37:
906
+ _context5.next = 42;
907
+ break;
908
+ case 39:
909
+ _context5.prev = 39;
895
910
  _context5.t1 = _context5["catch"](6);
896
911
  // 用户取消 / 选择失败 → 视为放弃本次新增
897
912
  console.warn('[OrderModule] giftSelectResolver rejected, skip add gift', addAction.strategyId, _context5.t1);
898
- case 34:
913
+ case 42:
899
914
  case "end":
900
915
  return _context5.stop();
901
916
  }
902
- }, _loop, null, [[6, 31], [12, 23, 26, 29]]);
917
+ }, _loop, null, [[6, 39], [14, 31, 34, 37]]);
903
918
  });
904
919
  _iterator4.s();
905
920
  case 51:
@@ -47,6 +47,18 @@ export interface OrderGiftSelectContext {
47
47
  /** 触发此赠品的主商品 metadata.unique_identification_number 列表 */
48
48
  sourceProductIds: string[];
49
49
  }
50
+ /**
51
+ * 赠品 resolver 返回值。
52
+ *
53
+ * @example
54
+ * return { products: [giftProduct], bookings: [giftBooking] };
55
+ */
56
+ export interface OrderGiftSelectResult {
57
+ /** 完整赠品购物车行,必须带 metadata._giftInfo。 */
58
+ products: Partial<OrderProduct>[];
59
+ /** 预约赠品对应的 booking,按 products 下标一一关联。 */
60
+ bookings?: AddProductBookingInput[];
61
+ }
50
62
  /**
51
63
  * 赠品解析回调签名(SDK → OS 的返回值)。
52
64
  *
@@ -54,9 +66,9 @@ export interface OrderGiftSelectContext {
54
66
  * - 多选项:SDK 弹窗等用户确认后构造
55
67
  * - 用户取消:抛错或返回空数组(OS 视为放弃本次添加)
56
68
  *
57
- * 返回的 OrderProduct 必须是完整的购物车行(含 metadata._giftInfo 标记),OS 会直接 push 入 tempOrder.products。
69
+ * 返回数组时沿用旧协议,只写 tempOrder.products;返回对象时可同时写入预约 bookings
58
70
  */
59
- export type OrderGiftSelectResolver = (ctx: OrderGiftSelectContext) => Promise<Partial<OrderProduct>[] | null>;
71
+ export type OrderGiftSelectResolver = (ctx: OrderGiftSelectContext) => Promise<Partial<OrderProduct>[] | OrderGiftSelectResult | null>;
60
72
  /** 未满足的促销策略(购物车底部 alert 渲染源) */
61
73
  export interface OrderUnfulfilledPromotion {
62
74
  strategyId: string;
@@ -20,6 +20,13 @@ export var OrderHooks = /*#__PURE__*/function (OrderHooks) {
20
20
 
21
21
  /** 赠品解析回调 context(OS → SDK 的请求体) */
22
22
 
23
+ /**
24
+ * 赠品 resolver 返回值。
25
+ *
26
+ * @example
27
+ * return { products: [giftProduct], bookings: [giftBooking] };
28
+ */
29
+
23
30
  /**
24
31
  * 赠品解析回调签名(SDK → OS 的返回值)。
25
32
  *
@@ -27,7 +34,7 @@ export var OrderHooks = /*#__PURE__*/function (OrderHooks) {
27
34
  * - 多选项:SDK 弹窗等用户确认后构造
28
35
  * - 用户取消:抛错或返回空数组(OS 视为放弃本次添加)
29
36
  *
30
- * 返回的 OrderProduct 必须是完整的购物车行(含 metadata._giftInfo 标记),OS 会直接 push 入 tempOrder.products。
37
+ * 返回数组时沿用旧协议,只写 tempOrder.products;返回对象时可同时写入预约 bookings
31
38
  */
32
39
 
33
40
  /** 未满足的促销策略(购物车底部 alert 渲染源) */
@@ -1,5 +1,6 @@
1
1
  import { Module, PisellCore } from '../../types';
2
2
  import { BaseModule } from '../BaseModule';
3
+ import { ProductListLoadProductsParams } from './types';
3
4
  import { ProductData } from '../Product/types';
4
5
  export * from './types';
5
6
  export declare class ProductList extends BaseModule implements Module {
@@ -18,18 +19,14 @@ export declare class ProductList extends BaseModule implements Module {
18
19
  */
19
20
  updateOtherParams(params: Record<string, any>): void;
20
21
  storeChange(path?: string, value?: any): Promise<void>;
21
- loadProducts({ category_ids, product_ids, collection, menu_list_ids, customer_id: paramsCustomerId, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, }: {
22
- category_ids?: number[];
23
- product_ids?: number[];
24
- collection?: number | string[];
25
- schedule_date?: string;
26
- cacheId?: string;
27
- customer_id?: number;
28
- menu_list_ids?: number[];
29
- schedule_datetime?: string;
30
- with_count?: string[];
31
- with_schedule?: number;
32
- }, options?: {
22
+ /**
23
+ * 获取加时商品列表。
24
+ *
25
+ * @example
26
+ * const products = await productList.getAddTimeProducts({ schedule_date: '2026-06-16' });
27
+ */
28
+ getAddTimeProducts(params?: ProductListLoadProductsParams): Promise<any>;
29
+ loadProducts({ category_ids, product_ids, collection, menu_list_ids, customer_id: paramsCustomerId, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, extension_type, status, }?: ProductListLoadProductsParams, options?: {
33
30
  callback?: (result: any) => void;
34
31
  subscriberId?: string;
35
32
  }): Promise<any>;
@@ -1,4 +1,6 @@
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 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; }
3
+ 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; }
2
4
  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; }
3
5
  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
6
  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); }); }; }
@@ -17,6 +19,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
17
19
  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); }
18
20
  import { BaseModule } from "../BaseModule";
19
21
  import { cloneDeep } from 'lodash-es';
22
+ import dayjs from 'dayjs';
20
23
  export * from "./types";
21
24
  export var ProductList = /*#__PURE__*/function (_BaseModule) {
22
25
  _inherits(ProductList, _BaseModule);
@@ -92,16 +95,75 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
92
95
  }
93
96
  return storeChange;
94
97
  }()
98
+ /**
99
+ * 获取加时商品列表。
100
+ *
101
+ * @example
102
+ * const products = await productList.getAddTimeProducts({ schedule_date: '2026-06-16' });
103
+ */
104
+ }, {
105
+ key: "getAddTimeProducts",
106
+ value: (function () {
107
+ var _getAddTimeProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
108
+ var params,
109
+ _args3 = arguments;
110
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
111
+ while (1) switch (_context3.prev = _context3.next) {
112
+ case 0:
113
+ params = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {};
114
+ return _context3.abrupt("return", this.loadProducts(_objectSpread(_objectSpread({
115
+ schedule_date: dayjs().format('YYYY-MM-DD'),
116
+ status: 'published'
117
+ }, params), {}, {
118
+ extension_type: ['product_add_time']
119
+ })));
120
+ case 2:
121
+ case "end":
122
+ return _context3.stop();
123
+ }
124
+ }, _callee3, this);
125
+ }));
126
+ function getAddTimeProducts() {
127
+ return _getAddTimeProducts.apply(this, arguments);
128
+ }
129
+ return getAddTimeProducts;
130
+ }())
95
131
  }, {
96
132
  key: "loadProducts",
97
133
  value: function () {
98
- var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref, options) {
134
+ var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
99
135
  var _this$otherParams;
100
- var _ref$category_ids, category_ids, _ref$product_ids, product_ids, _ref$collection, collection, _ref$menu_list_ids, menu_list_ids, paramsCustomerId, _ref$with_count, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, userPlugin, customer_id, _userPlugin$get, productsData, sortedList;
101
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
102
- while (1) switch (_context3.prev = _context3.next) {
136
+ var _ref,
137
+ _ref$category_ids,
138
+ category_ids,
139
+ _ref$product_ids,
140
+ product_ids,
141
+ _ref$collection,
142
+ collection,
143
+ _ref$menu_list_ids,
144
+ menu_list_ids,
145
+ paramsCustomerId,
146
+ _ref$with_count,
147
+ with_count,
148
+ schedule_datetime,
149
+ schedule_date,
150
+ cacheId,
151
+ with_schedule,
152
+ extension_type,
153
+ _ref$status,
154
+ status,
155
+ options,
156
+ userPlugin,
157
+ customer_id,
158
+ _userPlugin$get,
159
+ productsData,
160
+ sortedList,
161
+ _args4 = arguments;
162
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
163
+ while (1) switch (_context4.prev = _context4.next) {
103
164
  case 0:
104
- _ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection, _ref$menu_list_ids = _ref.menu_list_ids, menu_list_ids = _ref$menu_list_ids === void 0 ? [] : _ref$menu_list_ids, paramsCustomerId = _ref.customer_id, _ref$with_count = _ref.with_count, with_count = _ref$with_count === void 0 ? [] : _ref$with_count, schedule_datetime = _ref.schedule_datetime, schedule_date = _ref.schedule_date, cacheId = _ref.cacheId, with_schedule = _ref.with_schedule;
165
+ _ref = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {}, _ref$category_ids = _ref.category_ids, category_ids = _ref$category_ids === void 0 ? [] : _ref$category_ids, _ref$product_ids = _ref.product_ids, product_ids = _ref$product_ids === void 0 ? [] : _ref$product_ids, _ref$collection = _ref.collection, collection = _ref$collection === void 0 ? [] : _ref$collection, _ref$menu_list_ids = _ref.menu_list_ids, menu_list_ids = _ref$menu_list_ids === void 0 ? [] : _ref$menu_list_ids, paramsCustomerId = _ref.customer_id, _ref$with_count = _ref.with_count, with_count = _ref$with_count === void 0 ? [] : _ref$with_count, schedule_datetime = _ref.schedule_datetime, schedule_date = _ref.schedule_date, cacheId = _ref.cacheId, with_schedule = _ref.with_schedule, extension_type = _ref.extension_type, _ref$status = _ref.status, status = _ref$status === void 0 ? 'published' : _ref$status;
166
+ options = _args4.length > 1 ? _args4[1] : undefined;
105
167
  // // 如果 schedule_ids 为空,则需要尝试从 schedule 模块里获取
106
168
  // if (!schedule_ids?.length) {
107
169
  // const schedule_ids_data = this.store.schedule
@@ -122,13 +184,13 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
122
184
  console.error(error);
123
185
  }
124
186
  // 如果没传schedule_date,则从
125
- _context3.next = 6;
187
+ _context4.next = 7;
126
188
  return this.request.post("/product/query", {
127
189
  open_quotation: 1,
128
190
  open_bundle: 0,
129
191
  exclude_extension_type: ['product_party', 'product_event', 'product_series_event', 'product_package_ticket', 'ticket', 'event_item'],
130
192
  with: ['category', 'collection', 'resourceRelation'],
131
- status: 'published',
193
+ status: status,
132
194
  num: 500,
133
195
  skip: 1,
134
196
  customer_id: customer_id,
@@ -143,15 +205,16 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
143
205
  application_code: (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel,
144
206
  is_eject: 1,
145
207
  with_schedule: with_schedule,
146
- schedule_datetime: schedule_datetime
208
+ schedule_datetime: schedule_datetime,
209
+ extension_type: extension_type
147
210
  }, {
148
211
  osServer: true,
149
212
  callback: options === null || options === void 0 ? void 0 : options.callback,
150
213
  subscriberId: options === null || options === void 0 ? void 0 : options.subscriberId,
151
214
  customToast: function customToast() {}
152
215
  });
153
- case 6:
154
- productsData = _context3.sent;
216
+ case 7:
217
+ productsData = _context4.sent;
155
218
  sortedList = (productsData.data.list || []).slice().sort(function (a, b) {
156
219
  return Number(b.sort) - Number(a.sort);
157
220
  }); // if (sortedList.length) {
@@ -162,14 +225,14 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
162
225
  // })
163
226
  // }
164
227
  this.addProduct(sortedList);
165
- return _context3.abrupt("return", sortedList);
166
- case 10:
228
+ return _context4.abrupt("return", sortedList);
229
+ case 11:
167
230
  case "end":
168
- return _context3.stop();
231
+ return _context4.stop();
169
232
  }
170
- }, _callee3, this);
233
+ }, _callee4, this);
171
234
  }));
172
- function loadProducts(_x5, _x6) {
235
+ function loadProducts() {
173
236
  return _loadProducts.apply(this, arguments);
174
237
  }
175
238
  return loadProducts;
@@ -177,13 +240,13 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
177
240
  }, {
178
241
  key: "loadProductsPrice",
179
242
  value: function () {
180
- var _loadProductsPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref2) {
243
+ var _loadProductsPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref2) {
181
244
  var _ref2$ids, ids, customer_id, schedule_date, channel, productsData;
182
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
183
- while (1) switch (_context4.prev = _context4.next) {
245
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
246
+ while (1) switch (_context5.prev = _context5.next) {
184
247
  case 0:
185
248
  _ref2$ids = _ref2.ids, ids = _ref2$ids === void 0 ? [] : _ref2$ids, customer_id = _ref2.customer_id, schedule_date = _ref2.schedule_date, channel = _ref2.channel;
186
- _context4.next = 3;
249
+ _context5.next = 3;
187
250
  return this.request.post("/product/query/price", {
188
251
  ids: ids,
189
252
  customer_id: customer_id,
@@ -193,15 +256,15 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
193
256
  useCache: true
194
257
  });
195
258
  case 3:
196
- productsData = _context4.sent;
197
- return _context4.abrupt("return", productsData.data);
259
+ productsData = _context5.sent;
260
+ return _context5.abrupt("return", productsData.data);
198
261
  case 5:
199
262
  case "end":
200
- return _context4.stop();
263
+ return _context5.stop();
201
264
  }
202
- }, _callee4, this);
265
+ }, _callee5, this);
203
266
  }));
204
- function loadProductsPrice(_x7) {
267
+ function loadProductsPrice(_x5) {
205
268
  return _loadProductsPrice.apply(this, arguments);
206
269
  }
207
270
  return loadProductsPrice;
@@ -209,19 +272,19 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
209
272
  }, {
210
273
  key: "getProducts",
211
274
  value: function () {
212
- var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
213
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
214
- while (1) switch (_context5.prev = _context5.next) {
275
+ var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
276
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
277
+ while (1) switch (_context6.prev = _context6.next) {
215
278
  case 0:
216
- _context5.next = 2;
279
+ _context6.next = 2;
217
280
  return this.core.effects.emit("".concat(this.name, ":onGetProducts"), this.store.list);
218
281
  case 2:
219
- return _context5.abrupt("return", cloneDeep(this.store.list));
282
+ return _context6.abrupt("return", cloneDeep(this.store.list));
220
283
  case 3:
221
284
  case "end":
222
- return _context5.stop();
285
+ return _context6.stop();
223
286
  }
224
- }, _callee5, this);
287
+ }, _callee6, this);
225
288
  }));
226
289
  function getProducts() {
227
290
  return _getProducts.apply(this, arguments);
@@ -231,25 +294,25 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
231
294
  }, {
232
295
  key: "getProduct",
233
296
  value: function () {
234
- var _getProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(id) {
297
+ var _getProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(id) {
235
298
  var product;
236
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
237
- while (1) switch (_context6.prev = _context6.next) {
299
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
300
+ while (1) switch (_context7.prev = _context7.next) {
238
301
  case 0:
239
- _context6.next = 2;
302
+ _context7.next = 2;
240
303
  return this.core.effects.emit("".concat(this.name, ":onGetProduct"), this.store.list);
241
304
  case 2:
242
305
  product = this.store.list.find(function (product) {
243
306
  return product.id === id;
244
307
  });
245
- return _context6.abrupt("return", product ? cloneDeep(product) : undefined);
308
+ return _context7.abrupt("return", product ? cloneDeep(product) : undefined);
246
309
  case 4:
247
310
  case "end":
248
- return _context6.stop();
311
+ return _context7.stop();
249
312
  }
250
- }, _callee6, this);
313
+ }, _callee7, this);
251
314
  }));
252
- function getProduct(_x8) {
315
+ function getProduct(_x6) {
253
316
  return _getProduct.apply(this, arguments);
254
317
  }
255
318
  return getProduct;
@@ -257,25 +320,25 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
257
320
  }, {
258
321
  key: "getProductByIds",
259
322
  value: function () {
260
- var _getProductByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(ids) {
323
+ var _getProductByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(ids) {
261
324
  var products;
262
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
263
- while (1) switch (_context7.prev = _context7.next) {
325
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
326
+ while (1) switch (_context8.prev = _context8.next) {
264
327
  case 0:
265
- _context7.next = 2;
328
+ _context8.next = 2;
266
329
  return this.core.effects.emit("".concat(this.name, ":onGetProductByIds"), this.store.list);
267
330
  case 2:
268
331
  products = this.store.list.filter(function (product) {
269
332
  return ids.includes(product.id);
270
333
  });
271
- return _context7.abrupt("return", products);
334
+ return _context8.abrupt("return", products);
272
335
  case 4:
273
336
  case "end":
274
- return _context7.stop();
337
+ return _context8.stop();
275
338
  }
276
- }, _callee7, this);
339
+ }, _callee8, this);
277
340
  }));
278
- function getProductByIds(_x9) {
341
+ function getProductByIds(_x7) {
279
342
  return _getProductByIds.apply(this, arguments);
280
343
  }
281
344
  return getProductByIds;
@@ -283,10 +346,10 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
283
346
  }, {
284
347
  key: "addProduct",
285
348
  value: function () {
286
- var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(products) {
349
+ var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(products) {
287
350
  var _this2 = this;
288
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
289
- while (1) switch (_context8.prev = _context8.next) {
351
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
352
+ while (1) switch (_context9.prev = _context9.next) {
290
353
  case 0:
291
354
  // list 需要根据 id 去重
292
355
  if (!this.store.list) {
@@ -309,11 +372,11 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
309
372
  this.core.effects.emit("".concat(this.name, ":changed"), this.store.list);
310
373
  case 4:
311
374
  case "end":
312
- return _context8.stop();
375
+ return _context9.stop();
313
376
  }
314
- }, _callee8, this);
377
+ }, _callee9, this);
315
378
  }));
316
- function addProduct(_x10) {
379
+ function addProduct(_x8) {
317
380
  return _addProduct.apply(this, arguments);
318
381
  }
319
382
  return addProduct;
@@ -321,18 +384,18 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
321
384
  }, {
322
385
  key: "selectProducts",
323
386
  value: function () {
324
- var _selectProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(products) {
325
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
326
- while (1) switch (_context9.prev = _context9.next) {
387
+ var _selectProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(products) {
388
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
389
+ while (1) switch (_context10.prev = _context10.next) {
327
390
  case 0:
328
391
  this.store.selectProducts = products;
329
392
  case 1:
330
393
  case "end":
331
- return _context9.stop();
394
+ return _context10.stop();
332
395
  }
333
- }, _callee9, this);
396
+ }, _callee10, this);
334
397
  }));
335
- function selectProducts(_x11) {
398
+ function selectProducts(_x9) {
336
399
  return _selectProducts.apply(this, arguments);
337
400
  }
338
401
  return selectProducts;
@@ -1,4 +1,18 @@
1
1
  import { ProductData } from '../Product/types';
2
+ export interface ProductListLoadProductsParams {
3
+ category_ids?: number[];
4
+ product_ids?: number[];
5
+ collection?: number | string[];
6
+ schedule_date?: string;
7
+ cacheId?: string;
8
+ customer_id?: number;
9
+ menu_list_ids?: number[];
10
+ schedule_datetime?: string;
11
+ with_count?: string[];
12
+ with_schedule?: number;
13
+ extension_type?: string[];
14
+ status?: string;
15
+ }
2
16
  export interface ProductListData {
3
17
  list: ProductData[];
4
18
  selectProducts: ProductData[];
@@ -496,6 +496,27 @@ declare class Server {
496
496
  * 从订单中展开 bookings,再按条件筛选 + 分页
497
497
  */
498
498
  private computeBookingQueryResult;
499
+ /**
500
+ * 规范商品扩展类型过滤参数。
501
+ *
502
+ * @example
503
+ * const types = this.normalizeProductExtensionTypes(['product_add_time']);
504
+ */
505
+ private normalizeProductExtensionTypes;
506
+ /**
507
+ * 请求包含 product_add_time 时,按传入 extension_type 数组配置过滤商品。
508
+ *
509
+ * @example
510
+ * const list = this.filterProductsByExtensionTypes(products, ['product_add_time']);
511
+ */
512
+ private filterProductsByExtensionTypes;
513
+ /**
514
+ * 判断本次查询是否需要跳过餐牌过滤,直接按扩展类型拉商品。
515
+ *
516
+ * @example
517
+ * const skipMenu = this.shouldQueryProductsByExtensionTypes(['product_add_time']);
518
+ */
519
+ private shouldQueryProductsByExtensionTypes;
499
520
  /**
500
521
  * 商品查询的核心计算逻辑(编排 Products、Menu、Schedule 模块)
501
522
  * 供 handleProductQuery 首次返回及 pubsub 变更推送复用