@pisell/pisellos 2.3.214 → 2.3.216

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.
@@ -304,6 +304,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
304
304
  ensureTempOrder(): OrderTempOrder;
305
305
  restoreOrder(): OrderTempOrder;
306
306
  getTempOrder(): OrderTempOrder | null;
307
+ /** 真实支付前固定本地创建时间;重试、恢复及后续付款沿用同一时间,不触发提交。 */
308
+ ensureOrderCreatedAt(): string;
307
309
  replaceTempOrder(tempOrder: OrderTempOrder, options?: ReplaceTempOrderOptions): Promise<OrderTempOrder>;
308
310
  getOrderIdentity(): OrderIdentitySnapshot | null;
309
311
  getOrderSyncState(): OrderSyncState;
@@ -3448,6 +3448,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
3448
3448
  value: function getTempOrder() {
3449
3449
  return this.orderReplacement ? this.orderReplacement.state.tempOrder : this.store.tempOrder;
3450
3450
  }
3451
+
3452
+ /** 真实支付前固定本地创建时间;重试、恢复及后续付款沿用同一时间,不触发提交。 */
3453
+ }, {
3454
+ key: "ensureOrderCreatedAt",
3455
+ value: function ensureOrderCreatedAt() {
3456
+ var tempOrder = this.ensureTempOrder();
3457
+ if (!tempOrder.created_at) {
3458
+ tempOrder.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
3459
+ this.persistTempOrder();
3460
+ }
3461
+ return tempOrder.created_at;
3462
+ }
3451
3463
  }, {
3452
3464
  key: "replaceTempOrder",
3453
3465
  value: function () {
@@ -974,6 +974,8 @@ export interface OrderModuleAPI {
974
974
  removeProductsFromOrder: (identities: OrderProductIdentity[], options?: RemoveProductsFromOrderOptions) => Promise<OrderProduct[]>;
975
975
  /** 在显式开启时保存当前 tempOrder 的 sessionStorage 会话快照。 */
976
976
  persistTempOrder: () => void;
977
+ /** 仅在缺失时固定本地订单创建时间,不触发云端提交。 */
978
+ ensureOrderCreatedAt: () => string;
977
979
  /**
978
980
  * 删除当前 cacheId 的 tempOrder 会话快照,并阻止当前模块实例再次写入。
979
981
  * 新模块实例初始化时会按 otherParams 重新启用持久化。
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "session" | "duration";
52
+ getProductType(): "normal" | "duration" | "session";
53
53
  }
@@ -416,7 +416,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
416
416
  key: "loadVenueCatalogPool",
417
417
  value: (function () {
418
418
  var _loadVenueCatalogPool = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
419
- var _this$otherParams5, _params$product_ids, _params$category_ids, _params$extension_typ, _ref4, _data$total;
419
+ var _this$otherParams5, _params$product_ids, _params$category_ids, _params$extension_typ, _ref4, _ref5, _data$total;
420
420
  var params,
421
421
  channelMap,
422
422
  channel,
@@ -467,6 +467,9 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
467
467
  } : {}), {}, {
468
468
  front_end_cache_id: params.cacheId
469
469
  }), {
470
+ // Core dispatches Kiosk to its local product query; PC/H5 without that
471
+ // route keep using HTTP. open_quotation: 0 preserves the raw venue pool.
472
+ osServer: true,
470
473
  useCache: false,
471
474
  customToast: function customToast() {}
472
475
  });
@@ -481,7 +484,7 @@ export var ProductList = /*#__PURE__*/function (_BaseModule) {
481
484
  code: 'VENUE_CATALOG_LOAD_FAILED'
482
485
  });
483
486
  case 9:
484
- total = (_ref4 = (_data$total = data.total) !== null && _data$total !== void 0 ? _data$total : data.total_count) !== null && _ref4 !== void 0 ? _ref4 : data.total_num;
487
+ total = (_ref4 = (_ref5 = (_data$total = data.total) !== null && _data$total !== void 0 ? _data$total : data.total_count) !== null && _ref5 !== void 0 ? _ref5 : data.total_num) !== null && _ref4 !== void 0 ? _ref4 : data.count;
485
488
  if (!(total != null && Number.isFinite(Number(total)) && Number(total) > data.list.length || total == null && data.list.length >= 500)) {
486
489
  _context7.next = 12;
487
490
  break;
@@ -11,6 +11,7 @@ export declare class SalesSummaryModule extends BaseModule implements Module, Sa
11
11
  private surchargeListModuleName;
12
12
  private otherParams;
13
13
  private surchargeListChannel;
14
+ private surchargeLoads;
14
15
  constructor(name?: string, version?: string);
15
16
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
16
17
  /**
@@ -22,6 +23,8 @@ export declare class SalesSummaryModule extends BaseModule implements Module, Sa
22
23
  updateOtherParams(params: Record<string, any>): Promise<void>;
23
24
  private resolveChannel;
24
25
  getSurchargeList(channel?: string): Promise<void>;
26
+ private loadSurcharges;
27
+ private fetchSurcharges;
25
28
  private getAppData;
26
29
  private getTaxConfig;
27
30
  getSummary(params: {
@@ -46,6 +46,7 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
46
46
  _defineProperty(_assertThisInitialized(_this), "surchargeListModuleName", 'surchargeList');
47
47
  _defineProperty(_assertThisInitialized(_this), "otherParams", {});
48
48
  _defineProperty(_assertThisInitialized(_this), "surchargeListChannel", DEFAULT_SURCHARGE_CHANNEL);
49
+ _defineProperty(_assertThisInitialized(_this), "surchargeLoads", new Map());
49
50
  return _this;
50
51
  }
51
52
  _createClass(SalesSummaryModule, [{
@@ -61,6 +62,7 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
61
62
  this.appPlugin = this.core.getPlugin('app');
62
63
  this.request = this.core.getPlugin('request');
63
64
  this.otherParams = options.otherParams || {};
65
+ this.surchargeLoads = new Map();
64
66
  this.store.surchargeList = ((_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.surchargeList) || [];
65
67
  this.store.summary = ((_options$initialState2 = options.initialState) === null || _options$initialState2 === void 0 ? void 0 : _options$initialState2.summary) || createEmptySalesSummary();
66
68
  this.surchargeListModuleName = ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.surchargeListModuleName) || 'surchargeList';
@@ -69,14 +71,14 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
69
71
  // throw new Error('SalesSummaryModule 需要 app 插件支持');
70
72
  // }
71
73
  if (this.request) {
72
- _context.next = 10;
74
+ _context.next = 11;
73
75
  break;
74
76
  }
75
77
  throw new Error('SalesSummaryModule 需要 request 插件支持');
76
- case 10:
77
- _context.next = 12;
78
+ case 11:
79
+ _context.next = 13;
78
80
  return this.getSurchargeList();
79
- case 12:
81
+ case 13:
80
82
  case "end":
81
83
  return _context.stop();
82
84
  }
@@ -97,23 +99,25 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
97
99
  key: "updateOtherParams",
98
100
  value: (function () {
99
101
  var _updateOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
100
- var previousChannel, nextSurchargeListModuleName, nextChannel, shouldReload;
102
+ var _params$shopId, _this$otherParams$sho, _params$tenantId, _this$otherParams$ten;
103
+ var previousChannel, nextSurchargeListModuleName, nextChannel, sourceChanged;
101
104
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
102
105
  while (1) switch (_context2.prev = _context2.next) {
103
106
  case 0:
104
107
  previousChannel = this.resolveChannel();
105
108
  nextSurchargeListModuleName = (params === null || params === void 0 ? void 0 : params.surchargeListModuleName) || 'surchargeList';
106
109
  nextChannel = this.resolveChannel(params);
107
- shouldReload = nextSurchargeListModuleName !== this.surchargeListModuleName || nextChannel !== previousChannel;
110
+ sourceChanged = nextSurchargeListModuleName !== this.surchargeListModuleName || ((_params$shopId = params === null || params === void 0 ? void 0 : params.shopId) !== null && _params$shopId !== void 0 ? _params$shopId : params === null || params === void 0 ? void 0 : params.shop_id) !== ((_this$otherParams$sho = this.otherParams.shopId) !== null && _this$otherParams$sho !== void 0 ? _this$otherParams$sho : this.otherParams.shop_id) || ((_params$tenantId = params === null || params === void 0 ? void 0 : params.tenantId) !== null && _params$tenantId !== void 0 ? _params$tenantId : params === null || params === void 0 ? void 0 : params.tenant_id) !== ((_this$otherParams$ten = this.otherParams.tenantId) !== null && _this$otherParams$ten !== void 0 ? _this$otherParams$ten : this.otherParams.tenant_id);
108
111
  this.otherParams = params || {};
109
112
  this.surchargeListModuleName = nextSurchargeListModuleName;
110
- if (!shouldReload) {
111
- _context2.next = 9;
113
+ if (sourceChanged) this.surchargeLoads = new Map();
114
+ if (!(sourceChanged || nextChannel !== previousChannel)) {
115
+ _context2.next = 10;
112
116
  break;
113
117
  }
114
- _context2.next = 9;
118
+ _context2.next = 10;
115
119
  return this.getSurchargeList(nextChannel);
116
- case 9:
120
+ case 10:
117
121
  case "end":
118
122
  return _context2.stop();
119
123
  }
@@ -135,57 +139,91 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
135
139
  value: function () {
136
140
  var _getSurchargeList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
137
141
  var channel,
138
- surchargeListModule,
139
- surchargeList,
140
142
  _args3 = arguments;
141
143
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
142
144
  while (1) switch (_context3.prev = _context3.next) {
143
145
  case 0:
144
146
  channel = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : this.resolveChannel();
145
- _context3.prev = 1;
147
+ _context3.next = 3;
148
+ return this.loadSurcharges(channel);
149
+ case 3:
150
+ case "end":
151
+ return _context3.stop();
152
+ }
153
+ }, _callee3, this);
154
+ }));
155
+ function getSurchargeList() {
156
+ return _getSurchargeList.apply(this, arguments);
157
+ }
158
+ return getSurchargeList;
159
+ }()
160
+ }, {
161
+ key: "loadSurcharges",
162
+ value: function loadSurcharges(channel) {
163
+ var _this2 = this;
164
+ this.surchargeListChannel = channel;
165
+ var loads = this.surchargeLoads;
166
+ var pending = loads.get(channel);
167
+ if (pending) return pending;
168
+
169
+ // The core exposes the summary module while initialization is still pending.
170
+ // All calculations for this channel must wait for the same configuration, even when it is empty.
171
+ var load = this.fetchSurcharges(channel).then(function (list) {
172
+ loads.delete(channel);
173
+ if (loads === _this2.surchargeLoads && channel === _this2.surchargeListChannel) {
174
+ _this2.store.surchargeList = list;
175
+ }
176
+ return list;
177
+ });
178
+ loads.set(channel, load);
179
+ return load;
180
+ }
181
+ }, {
182
+ key: "fetchSurcharges",
183
+ value: function () {
184
+ var _fetchSurcharges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(channel) {
185
+ var surchargeListModule, surchargeList;
186
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
187
+ while (1) switch (_context4.prev = _context4.next) {
188
+ case 0:
189
+ _context4.prev = 0;
146
190
  surchargeListModule = this.core.getModule(this.surchargeListModuleName);
147
191
  if (!(surchargeListModule !== null && surchargeListModule !== void 0 && surchargeListModule.getSurchargeList)) {
148
- _context3.next = 9;
192
+ _context4.next = 6;
149
193
  break;
150
194
  }
151
- _context3.next = 6;
195
+ _context4.next = 5;
152
196
  return surchargeListModule.getSurchargeList({
153
197
  channel: channel
154
198
  });
199
+ case 5:
200
+ return _context4.abrupt("return", _context4.sent);
155
201
  case 6:
156
- this.store.surchargeList = _context3.sent;
157
- this.surchargeListChannel = channel;
158
- return _context3.abrupt("return");
159
- case 9:
160
- _context3.next = 11;
202
+ _context4.next = 8;
161
203
  return this.request.get('/order/custom-surcharge/available/v2', {
162
204
  channel: channel,
163
205
  is_assemble_product_data: 1,
164
206
  is_assemble_schedule_data: 1,
165
207
  with: ['relationSchedule']
166
208
  });
167
- case 11:
168
- surchargeList = _context3.sent;
169
- this.store.surchargeList = (surchargeList === null || surchargeList === void 0 ? void 0 : surchargeList.data) || [];
170
- this.surchargeListChannel = channel;
171
- _context3.next = 21;
172
- break;
209
+ case 8:
210
+ surchargeList = _context4.sent;
211
+ return _context4.abrupt("return", (surchargeList === null || surchargeList === void 0 ? void 0 : surchargeList.data) || []);
212
+ case 12:
213
+ _context4.prev = 12;
214
+ _context4.t0 = _context4["catch"](0);
215
+ console.warn('[SalesSummaryModule] 加载附加费配置失败', _context4.t0);
216
+ return _context4.abrupt("return", []);
173
217
  case 16:
174
- _context3.prev = 16;
175
- _context3.t0 = _context3["catch"](1);
176
- console.warn('[SalesSummaryModule] 加载附加费配置失败', _context3.t0);
177
- this.store.surchargeList = [];
178
- this.surchargeListChannel = channel;
179
- case 21:
180
218
  case "end":
181
- return _context3.stop();
219
+ return _context4.stop();
182
220
  }
183
- }, _callee3, this, [[1, 16]]);
221
+ }, _callee4, this, [[0, 12]]);
184
222
  }));
185
- function getSurchargeList() {
186
- return _getSurchargeList.apply(this, arguments);
223
+ function fetchSurcharges(_x4) {
224
+ return _fetchSurcharges.apply(this, arguments);
187
225
  }
188
- return getSurchargeList;
226
+ return fetchSurcharges;
189
227
  }()
190
228
  }, {
191
229
  key: "getAppData",
@@ -211,28 +249,36 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
211
249
  }, {
212
250
  key: "getSummary",
213
251
  value: function () {
214
- var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
215
- var _this$otherParams2, _this$store$surcharge, _ref;
216
- var _params$products, products, isPriceIncludeTax, taxRate, shopDiscount, channel, _params$virtualSettle, virtualSettlementMode, summaryChannel, taxConfig, fatherModuleName, scheduleModuleName, summarySchedule, needScheduleIds, scheduleList, scheduleById, _iterator, _step, item, summary, summaryWithTaxMeta;
217
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
218
- while (1) switch (_context4.prev = _context4.next) {
252
+ var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params) {
253
+ var _this$otherParams2, _surchargeList$map, _ref;
254
+ var _params$products, products, isPriceIncludeTax, taxRate, shopDiscount, channel, _params$virtualSettle, virtualSettlementMode, summaryChannel, loads, surchargeList, taxConfig, fatherModuleName, scheduleModuleName, summarySchedule, needScheduleIds, scheduleList, scheduleById, _iterator, _step, item, summary, summaryWithTaxMeta;
255
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
256
+ while (1) switch (_context5.prev = _context5.next) {
219
257
  case 0:
220
258
  _params$products = params.products, products = _params$products === void 0 ? [] : _params$products, isPriceIncludeTax = params.isPriceIncludeTax, taxRate = params.taxRate, shopDiscount = params.shopDiscount, channel = params.channel, _params$virtualSettle = params.virtualSettlementMode, virtualSettlementMode = _params$virtualSettle === void 0 ? false : _params$virtualSettle;
221
259
  summaryChannel = channel || this.resolveChannel();
222
- if (!(summaryChannel !== this.surchargeListChannel)) {
223
- _context4.next = 5;
260
+ loads = this.surchargeLoads;
261
+ if (!(loads.has(summaryChannel) || summaryChannel !== this.surchargeListChannel)) {
262
+ _context5.next = 9;
224
263
  break;
225
264
  }
226
- _context4.next = 5;
227
- return this.getSurchargeList(summaryChannel);
228
- case 5:
265
+ _context5.next = 6;
266
+ return this.loadSurcharges(summaryChannel);
267
+ case 6:
268
+ _context5.t0 = _context5.sent;
269
+ _context5.next = 10;
270
+ break;
271
+ case 9:
272
+ _context5.t0 = this.store.surchargeList;
273
+ case 10:
274
+ surchargeList = _context5.t0;
229
275
  taxConfig = this.getTaxConfig();
230
276
  fatherModuleName = ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.fatherModule) || this.name.replace(/_salesSummary$/, '');
231
277
  scheduleModuleName = "".concat(fatherModuleName, "_schedule");
232
278
  summarySchedule = this.core.getModule(scheduleModuleName);
233
- needScheduleIds = (((_this$store$surcharge = this.store.surchargeList) === null || _this$store$surcharge === void 0 || (_this$store$surcharge = _this$store$surcharge.map(function (item) {
279
+ needScheduleIds = ((surchargeList === null || surchargeList === void 0 || (_surchargeList$map = surchargeList.map(function (item) {
234
280
  return item.available_schedule_ids;
235
- })) === null || _this$store$surcharge === void 0 ? void 0 : _this$store$surcharge.flat()) || []).filter(function (id) {
281
+ })) === null || _surchargeList$map === void 0 ? void 0 : _surchargeList$map.flat()) || []).filter(function (id) {
236
282
  return id !== undefined && id !== null && id !== '';
237
283
  });
238
284
  scheduleList = needScheduleIds.length > 0 ? summarySchedule === null || summarySchedule === void 0 ? void 0 : summarySchedule.getScheduleListByIds(needScheduleIds) : [];
@@ -254,7 +300,7 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
254
300
  products: products,
255
301
  isPriceIncludeTax: (_ref = isPriceIncludeTax !== null && isPriceIncludeTax !== void 0 ? isPriceIncludeTax : taxConfig.isPriceIncludeTax) !== null && _ref !== void 0 ? _ref : 1,
256
302
  taxRate: taxRate !== null && taxRate !== void 0 ? taxRate : taxConfig.taxRate,
257
- surchargeList: this.store.surchargeList,
303
+ surchargeList: surchargeList,
258
304
  scheduleById: scheduleById,
259
305
  isInScheduleByDate: ScheduleModule.isInScheduleByDate,
260
306
  shopDiscount: shopDiscount,
@@ -265,15 +311,17 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
265
311
  tax_rate: taxRate !== null && taxRate !== void 0 ? taxRate : taxConfig.taxRate,
266
312
  tax_country_code: taxConfig.taxCountryCode || ''
267
313
  });
268
- this.store.summary = summaryWithTaxMeta;
269
- return _context4.abrupt("return", summaryWithTaxMeta);
270
- case 17:
314
+ if (loads === this.surchargeLoads && summaryChannel === this.surchargeListChannel) {
315
+ this.store.summary = summaryWithTaxMeta;
316
+ }
317
+ return _context5.abrupt("return", summaryWithTaxMeta);
318
+ case 23:
271
319
  case "end":
272
- return _context4.stop();
320
+ return _context5.stop();
273
321
  }
274
- }, _callee4, this);
322
+ }, _callee5, this);
275
323
  }));
276
- function getSummary(_x4) {
324
+ function getSummary(_x5) {
277
325
  return _getSummary.apply(this, arguments);
278
326
  }
279
327
  return getSummary;
@@ -289,6 +289,7 @@ declare class Server {
289
289
  * 存储订阅者信息,便于数据变更时推送最新结果
290
290
  */
291
291
  private handleProductQuery;
292
+ private queryRawKioskProductPool;
292
293
  /**
293
294
  * ProductList callers such as standalone retail pages do not always have a selected schedule.
294
295
  * In that case query against the current local time so menu availability can still be evaluated.