@pisell/pisellos 2.3.79 → 2.3.80

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.
@@ -18,6 +18,19 @@ export declare class ProductList extends BaseModule implements Module {
18
18
  * productList.updateOtherParams({ channel: 'pos' });
19
19
  */
20
20
  updateOtherParams(params: Record<string, any>): void;
21
+ /**
22
+ * 判断当前商品查询是否会被本地 OS Server 接管。
23
+ *
24
+ * 不能只看请求参数中的 osServer=true:H5 RequestPlugin 会透传该参数,但仍然直接请求远端接口。
25
+ * 这里按 RequestPlugin 实际使用的 baseUrl 检查已注册路由,避免 OS Server 与客户端重复执行
26
+ * Data Variant 评估。
27
+ */
28
+ private isProductQueryHandledByOsServer;
29
+ /**
30
+ * 未启用商品 OS 路由时,在客户端补做 Data Variant 解析。
31
+ * OS Server 已接管时直接信任服务端结果,确保同一批商品只评估一次。
32
+ */
33
+ private resolveClientDataVariants;
21
34
  storeChange(path?: string, value?: any): Promise<void>;
22
35
  /**
23
36
  * 获取加时商品列表。
@@ -25,11 +38,11 @@ export declare class ProductList extends BaseModule implements Module {
25
38
  * @example
26
39
  * const products = await productList.getAddTimeProducts({ schedule_date: '2026-06-16' });
27
40
  */
28
- getAddTimeProducts(params?: ProductListLoadProductsParams): Promise<any>;
41
+ getAddTimeProducts(params?: ProductListLoadProductsParams): Promise<ProductData[]>;
29
42
  loadProducts({ category_ids, product_ids, collection, menu_list_ids, customer_id: paramsCustomerId, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, extension_type, status, strategy_context, }?: ProductListLoadProductsParams, options?: {
30
43
  callback?: (result: any) => void;
31
44
  subscriberId?: string;
32
- }): Promise<any>;
45
+ }): Promise<ProductData[]>;
33
46
  loadProductsPrice({ ids, customer_id, schedule_date, channel, }: {
34
47
  ids?: number[];
35
48
  customer_id?: number;
@@ -1,6 +1,6 @@
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
1
  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
2
  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; }
3
+ 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); }
4
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; }
5
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); } }
6
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); }); }; }
@@ -78,6 +78,64 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
78
78
  value: function updateOtherParams(params) {
79
79
  this.otherParams = params || {};
80
80
  }
81
+
82
+ /**
83
+ * 判断当前商品查询是否会被本地 OS Server 接管。
84
+ *
85
+ * 不能只看请求参数中的 osServer=true:H5 RequestPlugin 会透传该参数,但仍然直接请求远端接口。
86
+ * 这里按 RequestPlugin 实际使用的 baseUrl 检查已注册路由,避免 OS Server 与客户端重复执行
87
+ * Data Variant 评估。
88
+ */
89
+ }, {
90
+ key: "isProductQueryHandledByOsServer",
91
+ value: function isProductQueryHandledByOsServer() {
92
+ var _this$core, _this$request;
93
+ var server = (_this$core = this.core) === null || _this$core === void 0 ? void 0 : _this$core.server;
94
+ if (!server || typeof server.hasRoute !== 'function') return false;
95
+ var requestBaseUrl = String(((_this$request = this.request) === null || _this$request === void 0 ? void 0 : _this$request.baseUrl) || '/shop').replace(/\/+$/, '');
96
+ var routePath = "".concat(requestBaseUrl, "/product/query");
97
+ return server.hasRoute('post', routePath) === true;
98
+ }
99
+
100
+ /**
101
+ * 未启用商品 OS 路由时,在客户端补做 Data Variant 解析。
102
+ * OS Server 已接管时直接信任服务端结果,确保同一批商品只评估一次。
103
+ */
104
+ }, {
105
+ key: "resolveClientDataVariants",
106
+ value: function resolveClientDataVariants(products, queryPayload, handledByOsServer) {
107
+ var _this$core2, _this$otherParams, _scheduleModule$getSc, _this$core3, _this$core4, _this$otherParams2, _strategyContext$busi;
108
+ if (handledByOsServer || products.length === 0) return products;
109
+ var evaluator = (_this$core2 = this.core) === null || _this$core2 === void 0 || (_this$core2 = _this$core2.context) === null || _this$core2 === void 0 ? void 0 : _this$core2.dataVariantEvaluator;
110
+ if (!evaluator || typeof evaluator.resolveProducts !== 'function') {
111
+ return products;
112
+ }
113
+ var strategyContext = queryPayload.strategy_context && _typeof(queryPayload.strategy_context) === 'object' ? queryPayload.strategy_context : {};
114
+ var fatherModule = String(((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.fatherModule) || '').trim();
115
+ var scheduleModule = (fatherModule ? this.core.getModule("".concat(fatherModule, "_schedule")) : null) || this.core.getModule('schedule');
116
+ var scheduleList = scheduleModule === null || scheduleModule === void 0 || (_scheduleModule$getSc = scheduleModule.getScheduleList) === null || _scheduleModule$getSc === void 0 ? void 0 : _scheduleModule$getSc.call(scheduleModule);
117
+ var contextScheduleList = (_this$core3 = this.core) === null || _this$core3 === void 0 || (_this$core3 = _this$core3.context) === null || _this$core3 === void 0 ? void 0 : _this$core3.scheduleList;
118
+ var contextMenuList = (_this$core4 = this.core) === null || _this$core4 === void 0 || (_this$core4 = _this$core4.context) === null || _this$core4 === void 0 ? void 0 : _this$core4.menuList;
119
+ var businessData = {
120
+ products: products,
121
+ scheduleDateTime: queryPayload.schedule_datetime || queryPayload.schedule_date,
122
+ scheduleList: Array.isArray(scheduleList) ? scheduleList : Array.isArray(contextScheduleList) ? contextScheduleList : [],
123
+ menuList: Array.isArray((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.menuList) ? this.otherParams.menuList : Array.isArray(contextMenuList) ? contextMenuList : [],
124
+ customerId: queryPayload.customer_id,
125
+ channel: strategyContext.channel,
126
+ orderType: strategyContext.orderType || strategyContext.order_type,
127
+ businessCode: (_strategyContext$busi = strategyContext.business_code) !== null && _strategyContext$busi !== void 0 ? _strategyContext$busi : strategyContext.businessCode,
128
+ availableWalletIds: strategyContext.available_wallet_ids,
129
+ custom: strategyContext
130
+ };
131
+ try {
132
+ var _result = evaluator.resolveProducts(businessData);
133
+ return Array.isArray(_result === null || _result === void 0 ? void 0 : _result.products) ? _result.products : products;
134
+ } catch (error) {
135
+ console.error('[ProductList] Data Variant 客户端解析失败', error);
136
+ return products;
137
+ }
138
+ }
81
139
  }, {
82
140
  key: "storeChange",
83
141
  value: function () {
@@ -132,7 +190,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
132
190
  key: "loadProducts",
133
191
  value: function () {
134
192
  var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
135
- var _this$otherParams,
193
+ var _this$otherParams3,
136
194
  _this2 = this;
137
195
  var _ref,
138
196
  _ref$category_ids,
@@ -162,9 +220,11 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
162
220
  rawApplicationCode,
163
221
  mappedApplicationCode,
164
222
  queryPayload,
223
+ handledByOsServer,
165
224
  originalCallback,
166
225
  subscriptionCallback,
167
226
  productsData,
227
+ resolvedList,
168
228
  sortedList,
169
229
  _args5 = arguments;
170
230
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
@@ -199,7 +259,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
199
259
  scan_to_order_2: 'mobile_order',
200
260
  scan_to_order_3: 'scantoorder3'
201
261
  };
202
- rawApplicationCode = (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel;
262
+ rawApplicationCode = (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.channel;
203
263
  mappedApplicationCode = typeof rawApplicationCode === 'string' ? channelMap[rawApplicationCode] || rawApplicationCode : rawApplicationCode;
204
264
  queryPayload = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
205
265
  open_quotation: 1,
@@ -231,20 +291,33 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
231
291
  extension_type: extension_type,
232
292
  strategy_context: strategy_context
233
293
  });
294
+ handledByOsServer = this.isProductQueryHandledByOsServer();
234
295
  originalCallback = options === null || options === void 0 ? void 0 : options.callback;
235
- subscriptionCallback = originalCallback ? ( /*#__PURE__*/function () {
296
+ subscriptionCallback = typeof originalCallback === 'function' ? ( /*#__PURE__*/function () {
236
297
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(result) {
237
298
  var _result$data;
238
- var products;
299
+ var callbackList, products;
239
300
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
240
301
  while (1) switch (_context4.prev = _context4.next) {
241
302
  case 0:
242
- products = Array.isArray(result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.list) ? result.data.list : [];
243
- _context4.next = 3;
244
- return _this2.addProduct(products);
245
- case 3:
303
+ callbackList = result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.list;
304
+ if (Array.isArray(callbackList)) {
305
+ _context4.next = 4;
306
+ break;
307
+ }
246
308
  originalCallback(result);
309
+ return _context4.abrupt("return");
247
310
  case 4:
311
+ products = _this2.resolveClientDataVariants(callbackList, queryPayload, handledByOsServer);
312
+ _context4.next = 7;
313
+ return _this2.addProduct(products);
314
+ case 7:
315
+ originalCallback(handledByOsServer ? result : _objectSpread(_objectSpread({}, result), {}, {
316
+ data: _objectSpread(_objectSpread({}, result.data), {}, {
317
+ list: products
318
+ })
319
+ }));
320
+ case 8:
248
321
  case "end":
249
322
  return _context4.stop();
250
323
  }
@@ -254,16 +327,17 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
254
327
  return _ref2.apply(this, arguments);
255
328
  };
256
329
  }()) : undefined;
257
- _context5.next = 13;
330
+ _context5.next = 14;
258
331
  return this.request.post("/product/query", queryPayload, {
259
332
  osServer: true,
260
333
  callback: subscriptionCallback,
261
334
  subscriberId: options === null || options === void 0 ? void 0 : options.subscriberId,
262
335
  customToast: function customToast() {}
263
336
  });
264
- case 13:
337
+ case 14:
265
338
  productsData = _context5.sent;
266
- sortedList = (productsData.data.list || []).slice().sort(function (a, b) {
339
+ resolvedList = this.resolveClientDataVariants(productsData.data.list || [], queryPayload, handledByOsServer);
340
+ sortedList = resolvedList.slice().sort(function (a, b) {
267
341
  return Number(b.sort) - Number(a.sort);
268
342
  }); // if (sortedList.length) {
269
343
  // sortedList.forEach((n: any) => {
@@ -274,7 +348,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
274
348
  // }
275
349
  this.addProduct(sortedList);
276
350
  return _context5.abrupt("return", sortedList);
277
- case 17:
351
+ case 19:
278
352
  case "end":
279
353
  return _context5.stop();
280
354
  }
@@ -495,7 +495,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
495
495
  getUnfulfilledPromotions(): OrderUnfulfilledPromotion[];
496
496
  /** 最近一次促销计算输出的赠品操作 diff。 */
497
497
  getLastGiftActions(): OrderLastGiftActions | null;
498
- getProductList(): Promise<any>;
498
+ getProductList(): Promise<import("../..").ProductData[] | undefined>;
499
499
  getOtherParams(): Record<string, any>;
500
500
  setOtherParams(params: Record<string, any>, { cover }?: {
501
501
  cover?: boolean;
@@ -67,7 +67,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
67
67
  product_ids?: number[];
68
68
  collection?: number | string[];
69
69
  schedule_date?: string;
70
- }): Promise<any>;
70
+ }): Promise<ProductData[]>;
71
71
  /**
72
72
  * 通过 schedule 来读取商品,适用于 session 类商品
73
73
  *
@@ -87,7 +87,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
87
87
  date: string;
88
88
  product_ids?: number[];
89
89
  category_ids?: number[];
90
- }): Promise<any>;
90
+ }): Promise<ProductData[]>;
91
91
  /**
92
92
  * 更新完商品数据、切换日期、或者在较后的流程里登录了,检测当前购物车里是否有商品,如果有,则需要更新购物车里的商品价格
93
93
  *
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 1 | 2 | 5 | 3 | 4 | 6;
329
+ weekNum: 0 | 1 | 5 | 2 | 3 | 4 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -345,7 +345,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
345
345
  count: number;
346
346
  left: number;
347
347
  summaryCount: number;
348
- status: "sold_out" | "lots_of_space" | "filling_up_fast";
348
+ status: "lots_of_space" | "filling_up_fast" | "sold_out";
349
349
  }[];
350
350
  /**
351
351
  * 找到多个资源的公共可用时间段
@@ -128,7 +128,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
128
128
  loadProducts(params?: ILoadProductsParams, options?: {
129
129
  callback?: (result: any) => void;
130
130
  subscriberId?: string;
131
- }): Promise<any>;
131
+ }): Promise<ProductData[]>;
132
132
  /**
133
133
  * 获取加时商品列表。
134
134
  *
@@ -18,6 +18,19 @@ export declare class ProductList extends BaseModule implements Module {
18
18
  * productList.updateOtherParams({ channel: 'pos' });
19
19
  */
20
20
  updateOtherParams(params: Record<string, any>): void;
21
+ /**
22
+ * 判断当前商品查询是否会被本地 OS Server 接管。
23
+ *
24
+ * 不能只看请求参数中的 osServer=true:H5 RequestPlugin 会透传该参数,但仍然直接请求远端接口。
25
+ * 这里按 RequestPlugin 实际使用的 baseUrl 检查已注册路由,避免 OS Server 与客户端重复执行
26
+ * Data Variant 评估。
27
+ */
28
+ private isProductQueryHandledByOsServer;
29
+ /**
30
+ * 未启用商品 OS 路由时,在客户端补做 Data Variant 解析。
31
+ * OS Server 已接管时直接信任服务端结果,确保同一批商品只评估一次。
32
+ */
33
+ private resolveClientDataVariants;
21
34
  storeChange(path?: string, value?: any): Promise<void>;
22
35
  /**
23
36
  * 获取加时商品列表。
@@ -25,11 +38,11 @@ export declare class ProductList extends BaseModule implements Module {
25
38
  * @example
26
39
  * const products = await productList.getAddTimeProducts({ schedule_date: '2026-06-16' });
27
40
  */
28
- getAddTimeProducts(params?: ProductListLoadProductsParams): Promise<any>;
41
+ getAddTimeProducts(params?: ProductListLoadProductsParams): Promise<ProductData[]>;
29
42
  loadProducts({ category_ids, product_ids, collection, menu_list_ids, customer_id: paramsCustomerId, with_count, schedule_datetime, schedule_date, cacheId, with_schedule, extension_type, status, strategy_context, }?: ProductListLoadProductsParams, options?: {
30
43
  callback?: (result: any) => void;
31
44
  subscriberId?: string;
32
- }): Promise<any>;
45
+ }): Promise<ProductData[]>;
33
46
  loadProductsPrice({ ids, customer_id, schedule_date, channel, }: {
34
47
  ids?: number[];
35
48
  customer_id?: number;
@@ -55,6 +55,58 @@ class ProductList extends _BaseModule.BaseModule {
55
55
  updateOtherParams(params) {
56
56
  this.otherParams = params || {};
57
57
  }
58
+
59
+ /**
60
+ * 判断当前商品查询是否会被本地 OS Server 接管。
61
+ *
62
+ * 不能只看请求参数中的 osServer=true:H5 RequestPlugin 会透传该参数,但仍然直接请求远端接口。
63
+ * 这里按 RequestPlugin 实际使用的 baseUrl 检查已注册路由,避免 OS Server 与客户端重复执行
64
+ * Data Variant 评估。
65
+ */
66
+ isProductQueryHandledByOsServer() {
67
+ const server = this.core?.server;
68
+ if (!server || typeof server.hasRoute !== 'function') return false;
69
+ const requestBaseUrl = String(this.request?.baseUrl || '/shop').replace(/\/+$/, '');
70
+ const routePath = `${requestBaseUrl}/product/query`;
71
+ return server.hasRoute('post', routePath) === true;
72
+ }
73
+
74
+ /**
75
+ * 未启用商品 OS 路由时,在客户端补做 Data Variant 解析。
76
+ * OS Server 已接管时直接信任服务端结果,确保同一批商品只评估一次。
77
+ */
78
+ resolveClientDataVariants(products, queryPayload, handledByOsServer) {
79
+ if (handledByOsServer || products.length === 0) return products;
80
+ const evaluator = this.core?.context?.dataVariantEvaluator;
81
+ if (!evaluator || typeof evaluator.resolveProducts !== 'function') {
82
+ return products;
83
+ }
84
+ const strategyContext = queryPayload.strategy_context && typeof queryPayload.strategy_context === 'object' ? queryPayload.strategy_context : {};
85
+ const fatherModule = String(this.otherParams?.fatherModule || '').trim();
86
+ const scheduleModule = (fatherModule ? this.core.getModule(`${fatherModule}_schedule`) : null) || this.core.getModule('schedule');
87
+ const scheduleList = scheduleModule?.getScheduleList?.();
88
+ const contextScheduleList = this.core?.context?.scheduleList;
89
+ const contextMenuList = this.core?.context?.menuList;
90
+ const businessData = {
91
+ products,
92
+ scheduleDateTime: queryPayload.schedule_datetime || queryPayload.schedule_date,
93
+ scheduleList: Array.isArray(scheduleList) ? scheduleList : Array.isArray(contextScheduleList) ? contextScheduleList : [],
94
+ menuList: Array.isArray(this.otherParams?.menuList) ? this.otherParams.menuList : Array.isArray(contextMenuList) ? contextMenuList : [],
95
+ customerId: queryPayload.customer_id,
96
+ channel: strategyContext.channel,
97
+ orderType: strategyContext.orderType || strategyContext.order_type,
98
+ businessCode: strategyContext.business_code ?? strategyContext.businessCode,
99
+ availableWalletIds: strategyContext.available_wallet_ids,
100
+ custom: strategyContext
101
+ };
102
+ try {
103
+ const result = evaluator.resolveProducts(businessData);
104
+ return Array.isArray(result?.products) ? result.products : products;
105
+ } catch (error) {
106
+ console.error('[ProductList] Data Variant 客户端解析失败', error);
107
+ return products;
108
+ }
109
+ }
58
110
  async storeChange(path, value) {
59
111
  // No longer needed - products are stored as plain objects instead of Product instances
60
112
  }
@@ -149,11 +201,23 @@ class ProductList extends _BaseModule.BaseModule {
149
201
  extension_type,
150
202
  strategy_context
151
203
  };
204
+ const handledByOsServer = this.isProductQueryHandledByOsServer();
152
205
  const originalCallback = options?.callback;
153
- const subscriptionCallback = originalCallback ? async result => {
154
- const products = Array.isArray(result?.data?.list) ? result.data.list : [];
206
+ const subscriptionCallback = typeof originalCallback === 'function' ? async result => {
207
+ const callbackList = result?.data?.list;
208
+ if (!Array.isArray(callbackList)) {
209
+ originalCallback(result);
210
+ return;
211
+ }
212
+ const products = this.resolveClientDataVariants(callbackList, queryPayload, handledByOsServer);
155
213
  await this.addProduct(products);
156
- originalCallback(result);
214
+ originalCallback(handledByOsServer ? result : {
215
+ ...result,
216
+ data: {
217
+ ...result.data,
218
+ list: products
219
+ }
220
+ });
157
221
  } : undefined;
158
222
  const productsData = await this.request.post(`/product/query`, queryPayload, {
159
223
  osServer: true,
@@ -161,7 +225,8 @@ class ProductList extends _BaseModule.BaseModule {
161
225
  subscriberId: options?.subscriberId,
162
226
  customToast: () => {}
163
227
  });
164
- const sortedList = (productsData.data.list || []).slice().sort((a, b) => Number(b.sort) - Number(a.sort));
228
+ const resolvedList = this.resolveClientDataVariants(productsData.data.list || [], queryPayload, handledByOsServer);
229
+ const sortedList = resolvedList.slice().sort((a, b) => Number(b.sort) - Number(a.sort));
165
230
  // if (sortedList.length) {
166
231
  // sortedList.forEach((n: any) => {
167
232
  // if (n.is_eject !== 1 && n['schedule.ids'] && n['schedule.ids'].length) {
@@ -495,7 +495,7 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
495
495
  getUnfulfilledPromotions(): OrderUnfulfilledPromotion[];
496
496
  /** 最近一次促销计算输出的赠品操作 diff。 */
497
497
  getLastGiftActions(): OrderLastGiftActions | null;
498
- getProductList(): Promise<any>;
498
+ getProductList(): Promise<import("../..").ProductData[] | undefined>;
499
499
  getOtherParams(): Record<string, any>;
500
500
  setOtherParams(params: Record<string, any>, { cover }?: {
501
501
  cover?: boolean;
@@ -67,7 +67,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
67
67
  product_ids?: number[];
68
68
  collection?: number | string[];
69
69
  schedule_date?: string;
70
- }): Promise<any>;
70
+ }): Promise<ProductData[]>;
71
71
  /**
72
72
  * 通过 schedule 来读取商品,适用于 session 类商品
73
73
  *
@@ -87,7 +87,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
87
87
  date: string;
88
88
  product_ids?: number[];
89
89
  category_ids?: number[];
90
- }): Promise<any>;
90
+ }): Promise<ProductData[]>;
91
91
  /**
92
92
  * 更新完商品数据、切换日期、或者在较后的流程里登录了,检测当前购物车里是否有商品,如果有,则需要更新购物车里的商品价格
93
93
  *
@@ -326,7 +326,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
326
326
  date: string;
327
327
  status: string;
328
328
  week: string;
329
- weekNum: 0 | 1 | 2 | 5 | 3 | 4 | 6;
329
+ weekNum: 0 | 1 | 5 | 2 | 3 | 4 | 6;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -345,7 +345,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
345
345
  count: number;
346
346
  left: number;
347
347
  summaryCount: number;
348
- status: "sold_out" | "lots_of_space" | "filling_up_fast";
348
+ status: "lots_of_space" | "filling_up_fast" | "sold_out";
349
349
  }[];
350
350
  /**
351
351
  * 找到多个资源的公共可用时间段
@@ -128,7 +128,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
128
128
  loadProducts(params?: ILoadProductsParams, options?: {
129
129
  callback?: (result: any) => void;
130
130
  subscriberId?: string;
131
- }): Promise<any>;
131
+ }): Promise<ProductData[]>;
132
132
  /**
133
133
  * 获取加时商品列表。
134
134
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.79",
4
+ "version": "2.3.80",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",