@pisell/pisellos 2.3.78 → 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 () {
@@ -131,8 +189,9 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
131
189
  }, {
132
190
  key: "loadProducts",
133
191
  value: function () {
134
- var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
135
- var _this$otherParams;
192
+ var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
193
+ var _this$otherParams3,
194
+ _this2 = this;
136
195
  var _ref,
137
196
  _ref$category_ids,
138
197
  category_ids,
@@ -161,14 +220,18 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
161
220
  rawApplicationCode,
162
221
  mappedApplicationCode,
163
222
  queryPayload,
223
+ handledByOsServer,
224
+ originalCallback,
225
+ subscriptionCallback,
164
226
  productsData,
227
+ resolvedList,
165
228
  sortedList,
166
- _args4 = arguments;
167
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
168
- while (1) switch (_context4.prev = _context4.next) {
229
+ _args5 = arguments;
230
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
231
+ while (1) switch (_context5.prev = _context5.next) {
169
232
  case 0:
170
- _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, strategy_context = _ref.strategy_context;
171
- options = _args4.length > 1 ? _args4[1] : undefined;
233
+ _ref = _args5.length > 0 && _args5[0] !== undefined ? _args5[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, strategy_context = _ref.strategy_context;
234
+ options = _args5.length > 1 ? _args5[1] : undefined;
172
235
  // // 如果 schedule_ids 为空,则需要尝试从 schedule 模块里获取
173
236
  // if (!schedule_ids?.length) {
174
237
  // const schedule_ids_data = this.store.schedule
@@ -196,7 +259,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
196
259
  scan_to_order_2: 'mobile_order',
197
260
  scan_to_order_3: 'scantoorder3'
198
261
  };
199
- 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;
200
263
  mappedApplicationCode = typeof rawApplicationCode === 'string' ? channelMap[rawApplicationCode] || rawApplicationCode : rawApplicationCode;
201
264
  queryPayload = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
202
265
  open_quotation: 1,
@@ -228,16 +291,53 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
228
291
  extension_type: extension_type,
229
292
  strategy_context: strategy_context
230
293
  });
231
- _context4.next = 11;
294
+ handledByOsServer = this.isProductQueryHandledByOsServer();
295
+ originalCallback = options === null || options === void 0 ? void 0 : options.callback;
296
+ subscriptionCallback = typeof originalCallback === 'function' ? ( /*#__PURE__*/function () {
297
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(result) {
298
+ var _result$data;
299
+ var callbackList, products;
300
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
301
+ while (1) switch (_context4.prev = _context4.next) {
302
+ case 0:
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
+ }
308
+ originalCallback(result);
309
+ return _context4.abrupt("return");
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:
321
+ case "end":
322
+ return _context4.stop();
323
+ }
324
+ }, _callee4);
325
+ }));
326
+ return function (_x5) {
327
+ return _ref2.apply(this, arguments);
328
+ };
329
+ }()) : undefined;
330
+ _context5.next = 14;
232
331
  return this.request.post("/product/query", queryPayload, {
233
332
  osServer: true,
234
- callback: options === null || options === void 0 ? void 0 : options.callback,
333
+ callback: subscriptionCallback,
235
334
  subscriberId: options === null || options === void 0 ? void 0 : options.subscriberId,
236
335
  customToast: function customToast() {}
237
336
  });
238
- case 11:
239
- productsData = _context4.sent;
240
- sortedList = (productsData.data.list || []).slice().sort(function (a, b) {
337
+ case 14:
338
+ productsData = _context5.sent;
339
+ resolvedList = this.resolveClientDataVariants(productsData.data.list || [], queryPayload, handledByOsServer);
340
+ sortedList = resolvedList.slice().sort(function (a, b) {
241
341
  return Number(b.sort) - Number(a.sort);
242
342
  }); // if (sortedList.length) {
243
343
  // sortedList.forEach((n: any) => {
@@ -247,12 +347,12 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
247
347
  // })
248
348
  // }
249
349
  this.addProduct(sortedList);
250
- return _context4.abrupt("return", sortedList);
251
- case 15:
350
+ return _context5.abrupt("return", sortedList);
351
+ case 19:
252
352
  case "end":
253
- return _context4.stop();
353
+ return _context5.stop();
254
354
  }
255
- }, _callee4, this);
355
+ }, _callee5, this);
256
356
  }));
257
357
  function loadProducts() {
258
358
  return _loadProducts.apply(this, arguments);
@@ -262,13 +362,13 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
262
362
  }, {
263
363
  key: "loadProductsPrice",
264
364
  value: function () {
265
- var _loadProductsPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref2) {
266
- var _ref2$ids, ids, customer_id, schedule_date, channel, productsData;
267
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
268
- while (1) switch (_context5.prev = _context5.next) {
365
+ var _loadProductsPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref3) {
366
+ var _ref3$ids, ids, customer_id, schedule_date, channel, productsData;
367
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
368
+ while (1) switch (_context6.prev = _context6.next) {
269
369
  case 0:
270
- _ref2$ids = _ref2.ids, ids = _ref2$ids === void 0 ? [] : _ref2$ids, customer_id = _ref2.customer_id, schedule_date = _ref2.schedule_date, channel = _ref2.channel;
271
- _context5.next = 3;
370
+ _ref3$ids = _ref3.ids, ids = _ref3$ids === void 0 ? [] : _ref3$ids, customer_id = _ref3.customer_id, schedule_date = _ref3.schedule_date, channel = _ref3.channel;
371
+ _context6.next = 3;
272
372
  return this.request.post("/product/query/price", {
273
373
  ids: ids,
274
374
  customer_id: customer_id,
@@ -278,15 +378,15 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
278
378
  useCache: true
279
379
  });
280
380
  case 3:
281
- productsData = _context5.sent;
282
- return _context5.abrupt("return", productsData.data);
381
+ productsData = _context6.sent;
382
+ return _context6.abrupt("return", productsData.data);
283
383
  case 5:
284
384
  case "end":
285
- return _context5.stop();
385
+ return _context6.stop();
286
386
  }
287
- }, _callee5, this);
387
+ }, _callee6, this);
288
388
  }));
289
- function loadProductsPrice(_x5) {
389
+ function loadProductsPrice(_x6) {
290
390
  return _loadProductsPrice.apply(this, arguments);
291
391
  }
292
392
  return loadProductsPrice;
@@ -294,19 +394,19 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
294
394
  }, {
295
395
  key: "getProducts",
296
396
  value: function () {
297
- var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
298
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
299
- while (1) switch (_context6.prev = _context6.next) {
397
+ var _getProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
398
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
399
+ while (1) switch (_context7.prev = _context7.next) {
300
400
  case 0:
301
- _context6.next = 2;
401
+ _context7.next = 2;
302
402
  return this.core.effects.emit("".concat(this.name, ":onGetProducts"), this.store.list);
303
403
  case 2:
304
- return _context6.abrupt("return", cloneDeep(this.store.list));
404
+ return _context7.abrupt("return", cloneDeep(this.store.list));
305
405
  case 3:
306
406
  case "end":
307
- return _context6.stop();
407
+ return _context7.stop();
308
408
  }
309
- }, _callee6, this);
409
+ }, _callee7, this);
310
410
  }));
311
411
  function getProducts() {
312
412
  return _getProducts.apply(this, arguments);
@@ -316,25 +416,25 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
316
416
  }, {
317
417
  key: "getProduct",
318
418
  value: function () {
319
- var _getProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(id) {
419
+ var _getProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(id) {
320
420
  var product;
321
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
322
- while (1) switch (_context7.prev = _context7.next) {
421
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
422
+ while (1) switch (_context8.prev = _context8.next) {
323
423
  case 0:
324
- _context7.next = 2;
424
+ _context8.next = 2;
325
425
  return this.core.effects.emit("".concat(this.name, ":onGetProduct"), this.store.list);
326
426
  case 2:
327
427
  product = this.store.list.find(function (product) {
328
428
  return product.id === id;
329
429
  });
330
- return _context7.abrupt("return", product ? cloneDeep(product) : undefined);
430
+ return _context8.abrupt("return", product ? cloneDeep(product) : undefined);
331
431
  case 4:
332
432
  case "end":
333
- return _context7.stop();
433
+ return _context8.stop();
334
434
  }
335
- }, _callee7, this);
435
+ }, _callee8, this);
336
436
  }));
337
- function getProduct(_x6) {
437
+ function getProduct(_x7) {
338
438
  return _getProduct.apply(this, arguments);
339
439
  }
340
440
  return getProduct;
@@ -342,25 +442,25 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
342
442
  }, {
343
443
  key: "getProductByIds",
344
444
  value: function () {
345
- var _getProductByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(ids) {
445
+ var _getProductByIds = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(ids) {
346
446
  var products;
347
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
348
- while (1) switch (_context8.prev = _context8.next) {
447
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
448
+ while (1) switch (_context9.prev = _context9.next) {
349
449
  case 0:
350
- _context8.next = 2;
450
+ _context9.next = 2;
351
451
  return this.core.effects.emit("".concat(this.name, ":onGetProductByIds"), this.store.list);
352
452
  case 2:
353
453
  products = this.store.list.filter(function (product) {
354
454
  return ids.includes(product.id);
355
455
  });
356
- return _context8.abrupt("return", products);
456
+ return _context9.abrupt("return", products);
357
457
  case 4:
358
458
  case "end":
359
- return _context8.stop();
459
+ return _context9.stop();
360
460
  }
361
- }, _callee8, this);
461
+ }, _callee9, this);
362
462
  }));
363
- function getProductByIds(_x7) {
463
+ function getProductByIds(_x8) {
364
464
  return _getProductByIds.apply(this, arguments);
365
465
  }
366
466
  return getProductByIds;
@@ -368,23 +468,23 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
368
468
  }, {
369
469
  key: "addProduct",
370
470
  value: function () {
371
- var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(products) {
372
- var _this2 = this;
373
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
374
- while (1) switch (_context9.prev = _context9.next) {
471
+ var _addProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(products) {
472
+ var _this3 = this;
473
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
474
+ while (1) switch (_context10.prev = _context10.next) {
375
475
  case 0:
376
476
  // list 需要根据 id 去重
377
477
  if (!this.store.list) {
378
478
  this.store.list = [];
379
479
  }
380
480
  products.forEach(function (n) {
381
- var index = _this2.store.list.findIndex(function (m) {
481
+ var index = _this3.store.list.findIndex(function (m) {
382
482
  return m.id === n.id;
383
483
  });
384
484
  if (index === -1) {
385
- _this2.store.list.push(n);
485
+ _this3.store.list.push(n);
386
486
  } else {
387
- _this2.store.list[index] = n;
487
+ _this3.store.list[index] = n;
388
488
  }
389
489
  });
390
490
  // 根据 sort 值做降序排序(数字越大越靠前)
@@ -394,11 +494,11 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
394
494
  this.core.effects.emit("".concat(this.name, ":changed"), this.store.list);
395
495
  case 4:
396
496
  case "end":
397
- return _context9.stop();
497
+ return _context10.stop();
398
498
  }
399
- }, _callee9, this);
499
+ }, _callee10, this);
400
500
  }));
401
- function addProduct(_x8) {
501
+ function addProduct(_x9) {
402
502
  return _addProduct.apply(this, arguments);
403
503
  }
404
504
  return addProduct;
@@ -406,18 +506,18 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
406
506
  }, {
407
507
  key: "selectProducts",
408
508
  value: function () {
409
- var _selectProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(products) {
410
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
411
- while (1) switch (_context10.prev = _context10.next) {
509
+ var _selectProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(products) {
510
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
511
+ while (1) switch (_context11.prev = _context11.next) {
412
512
  case 0:
413
513
  this.store.selectProducts = products;
414
514
  case 1:
415
515
  case "end":
416
- return _context10.stop();
516
+ return _context11.stop();
417
517
  }
418
- }, _callee10, this);
518
+ }, _callee11, this);
419
519
  }));
420
- function selectProducts(_x9) {
520
+ function selectProducts(_x10) {
421
521
  return _selectProducts.apply(this, arguments);
422
522
  }
423
523
  return selectProducts;
@@ -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 | 4 | 3 | 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
  *
@@ -334,7 +334,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
334
334
  * 获取当前的客户搜索条件
335
335
  * @returns 当前搜索条件
336
336
  */
337
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
337
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
338
338
  /**
339
339
  * 获取客户列表状态(包含滚动加载相关状态)
340
340
  * @returns 客户状态
@@ -453,7 +453,19 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
453
453
  * 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
454
454
  * 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
455
455
  */
456
- decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
456
+ decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): {
457
+ action: "reloadCatalog";
458
+ } | {
459
+ action: "add";
460
+ cacheItem: any;
461
+ } | {
462
+ action: "requiresDetail";
463
+ payload: AddProductRequiresDetailPayload;
464
+ } | {
465
+ action: "requiresBookingEdit";
466
+ cacheItem: any;
467
+ payload: import("./utils/addProductDecision").AddProductRequiresBookingEditPayload;
468
+ };
457
469
  /** 规格弹窗 callback 后的第二段决策。 */
458
470
  decideAfterDetail(cacheItem: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
459
471
  /**