@pisell/pisellos 2.3.170 → 2.3.172

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 (82) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +1 -0
  3. package/dist/inventory/index.d.ts +92 -0
  4. package/dist/inventory/index.js +509 -0
  5. package/dist/model/strategy/adapter/promotion/evaluator.js +5 -4
  6. package/dist/modules/Discount/index.js +1 -0
  7. package/dist/modules/Discount/types.d.ts +4 -0
  8. package/dist/modules/Order/index.d.ts +25 -3
  9. package/dist/modules/Order/index.js +1791 -1318
  10. package/dist/modules/Order/types.d.ts +7 -0
  11. package/dist/modules/Order/utils/discountProductLineIdentity.js +2 -2
  12. package/dist/modules/Order/utils/productVoucherGroups.d.ts +15 -0
  13. package/dist/modules/Order/utils/productVoucherGroups.js +115 -0
  14. package/dist/modules/Payment/walletpass.js +32 -6
  15. package/dist/modules/Product/index.d.ts +1 -1
  16. package/dist/modules/ProductList/index.js +33 -12
  17. package/dist/modules/Rules/index.d.ts +5 -10
  18. package/dist/modules/Rules/index.js +197 -107
  19. package/dist/modules/Rules/promotionSelection.d.ts +14 -0
  20. package/dist/modules/Rules/promotionSelection.js +390 -0
  21. package/dist/modules/Rules/types.d.ts +9 -0
  22. package/dist/server/modules/order/index.d.ts +6 -0
  23. package/dist/server/modules/order/index.js +782 -447
  24. package/dist/solution/BaseSales/index.d.ts +16 -1
  25. package/dist/solution/BaseSales/index.js +1545 -1339
  26. package/dist/solution/BaseSales/utils/cartPromotion.js +5 -2
  27. package/dist/solution/BookingByStep/index.d.ts +2 -2
  28. package/dist/solution/BookingTicket/index.js +200 -108
  29. package/dist/solution/BookingTicket/types.d.ts +14 -2
  30. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +1 -1
  31. package/dist/solution/BookingTicket/utils/addProductDecision.js +4 -3
  32. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +94 -58
  33. package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +10 -0
  34. package/dist/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +117 -0
  35. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +1 -0
  36. package/dist/solution/BookingTicket/utils/scan/handleScan.js +2 -1
  37. package/dist/solution/UnifiedBookingSales/index.d.ts +1 -1
  38. package/dist/solution/UnifiedBookingSales/index.js +69 -49
  39. package/dist/utils/platform.d.ts +2 -0
  40. package/dist/utils/platform.js +6 -0
  41. package/lib/index.d.ts +1 -0
  42. package/lib/index.js +12 -0
  43. package/lib/inventory/index.d.ts +92 -0
  44. package/lib/inventory/index.js +287 -0
  45. package/lib/model/strategy/adapter/promotion/evaluator.js +5 -4
  46. package/lib/model/strategy/adapter/promotion/index.js +1 -46
  47. package/lib/modules/Discount/index.js +1 -0
  48. package/lib/modules/Discount/types.d.ts +4 -0
  49. package/lib/modules/Order/index.d.ts +25 -3
  50. package/lib/modules/Order/index.js +203 -38
  51. package/lib/modules/Order/types.d.ts +7 -0
  52. package/lib/modules/Order/utils/discountProductLineIdentity.js +1 -1
  53. package/lib/modules/Order/utils/productVoucherGroups.d.ts +15 -0
  54. package/lib/modules/Order/utils/productVoucherGroups.js +64 -0
  55. package/lib/modules/Payment/walletpass.js +23 -1
  56. package/lib/modules/Product/index.d.ts +1 -1
  57. package/lib/modules/ProductList/index.js +15 -0
  58. package/lib/modules/Rules/index.d.ts +5 -10
  59. package/lib/modules/Rules/index.js +68 -22
  60. package/lib/modules/Rules/promotionSelection.d.ts +14 -0
  61. package/lib/modules/Rules/promotionSelection.js +230 -0
  62. package/lib/modules/Rules/types.d.ts +9 -0
  63. package/lib/server/modules/order/index.d.ts +6 -0
  64. package/lib/server/modules/order/index.js +226 -29
  65. package/lib/solution/BaseSales/index.d.ts +16 -1
  66. package/lib/solution/BaseSales/index.js +108 -14
  67. package/lib/solution/BaseSales/utils/cartPromotion.js +5 -2
  68. package/lib/solution/BookingByStep/index.d.ts +2 -2
  69. package/lib/solution/BookingTicket/index.js +38 -2
  70. package/lib/solution/BookingTicket/types.d.ts +14 -2
  71. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +1 -1
  72. package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -3
  73. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +14 -2
  74. package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.d.ts +10 -0
  75. package/lib/solution/BookingTicket/utils/scan/applyProductVoucherCollectionScan.js +71 -0
  76. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +1 -0
  77. package/lib/solution/BookingTicket/utils/scan/handleScan.js +2 -1
  78. package/lib/solution/UnifiedBookingSales/index.d.ts +1 -1
  79. package/lib/solution/UnifiedBookingSales/index.js +14 -3
  80. package/lib/utils/platform.d.ts +2 -0
  81. package/lib/utils/platform.js +7 -0
  82. package/package.json +1 -1
@@ -328,7 +328,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
328
328
  date: string;
329
329
  status: string;
330
330
  week: string;
331
- weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
331
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
332
332
  }[]>;
333
333
  submitTimeSlot(timeSlots: TimeSliceItem): void;
334
334
  private getScheduleDataByIds;
@@ -375,7 +375,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
375
375
  };
376
376
  setOtherData(key: string, value: any): void;
377
377
  getOtherData(key: string): any;
378
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
378
+ getProductTypeById(id: number): Promise<"duration" | "normal" | "session">;
379
379
  /**
380
380
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
381
381
  *
@@ -30,6 +30,7 @@ var _handleScan = require("./utils/scan/handleScan");
30
30
  var _scanCache = _interopRequireDefault(require("./utils/scan/scanCache"));
31
31
  var _formatGlobalScan = require("./utils/scan/formatGlobalScan");
32
32
  var _applyGlobalScan = require("./utils/scan/applyGlobalScan");
33
+ var _applyProductVoucherCollectionScan = require("./utils/scan/applyProductVoucherCollectionScan");
33
34
  var _cartView = require("./utils/cartView");
34
35
  var _addProductDecision = require("./utils/addProductDecision");
35
36
  var _buildCacheItemFromOrderLine = require("../../modules/BookingContext/utils/buildCacheItemFromOrderLine");
@@ -1845,6 +1846,20 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
1845
1846
  return bridge.openBookingEdit(payload);
1846
1847
  } : undefined
1847
1848
  } : undefined;
1849
+ if (guardedBridge?.scanScope === 'product-voucher') {
1850
+ if (!guardedBridge.applyPromotionCode) return {
1851
+ status: 'failed',
1852
+ reason: 'no_bridge'
1853
+ };
1854
+ const promotion = await guardedBridge.applyPromotionCode(trimmed);
1855
+ return promotion.isAccepted ?? promotion.isAvailable ? {
1856
+ status: 'success',
1857
+ kind: 'promotion'
1858
+ } : {
1859
+ status: 'failed',
1860
+ reason: 'not_found'
1861
+ };
1862
+ }
1848
1863
  const localSearch = v => this.store.products.findProductsByCodeOrBarcode(v);
1849
1864
  const scanCallback = (0, _handleScan.handleGlobalScan)(this.request, localSearch, this.getSubmitOrderSalesChannel());
1850
1865
  const raw = await scanCallback({
@@ -1859,7 +1874,7 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
1859
1874
  reason: 'not_found'
1860
1875
  };
1861
1876
  }
1862
- const result = await (0, _applyGlobalScan.applyGlobalScan)({
1877
+ const host = {
1863
1878
  setOrderCustomer: customer => {
1864
1879
  beforeScanCommit();
1865
1880
  this.setOrderCustomer(customer);
@@ -1880,10 +1895,31 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
1880
1895
  beforeScanCommit();
1881
1896
  return this.scanWalletAsset(scanCode);
1882
1897
  }
1883
- }, formatted, guardedBridge);
1898
+ };
1899
+ const result = guardedBridge?.scanScope === 'product-voucher-collection' ? await (0, _applyProductVoucherCollectionScan.applyProductVoucherCollectionScan)({
1900
+ ...host,
1901
+ waitForCustomerDiscounts: () => this.orderCustomerDiscountRefreshInFlight || Promise.resolve(),
1902
+ loadCustomerDiscounts: async () => {
1903
+ beforeScanCommit();
1904
+ const customerId = Number(this.getOrderCustomer()?.customer_id || 0);
1905
+ if (customerId <= 1) return [];
1906
+ await this.refreshDiscountConfigAfterOrderCustomerChange(customerId);
1907
+ beforeScanCommit();
1908
+ return this.getDiscountList();
1909
+ }
1910
+ }, formatted, guardedBridge) : await (0, _applyGlobalScan.applyGlobalScan)(host, formatted, guardedBridge);
1884
1911
  bridge?.refresh?.();
1885
1912
  return result;
1886
1913
  } catch (error) {
1914
+ if (bridge?.scanScope === 'product-voucher-collection') {
1915
+ if (bridge.isCurrent?.() === false) return {
1916
+ status: 'cancelled'
1917
+ };
1918
+ return {
1919
+ status: 'failed',
1920
+ reason: 'entry_resolution_failed'
1921
+ };
1922
+ }
1887
1923
  console.error('[BookingTicket] handleGlobalScanCode failed', error);
1888
1924
  bridge?.onNotify?.('fail', 'pisell2.text.scan-global-failed');
1889
1925
  return {
@@ -208,6 +208,10 @@ export interface AddAddTimeProductsToBookingInput {
208
208
  }
209
209
  /** 扫码宿主桥接:SalesSdk 在 pubsub 订阅回调里注入,OS 需要 UI 时直接调用 */
210
210
  export interface GlobalScanHostBridge {
211
+ /** product-voucher handles voucher codes only; product-voucher-collection also resolves wallet customer vouchers. */
212
+ scanScope?: 'all' | 'product-voucher' | 'product-voucher-collection';
213
+ /** A one-shot entry may outlive its page while requests are in flight. */
214
+ isCurrent?: () => boolean;
211
215
  openProductDetail?: (payload: Record<string, any>) => Promise<any | null>;
212
216
  openBookingEdit?: (payload: Record<string, any>) => Promise<any | null>;
213
217
  confirmDetail?: (input: {
@@ -232,11 +236,13 @@ export interface GlobalScanHostBridge {
232
236
  */
233
237
  applyPromotionCode?: (code: string, customerId?: number, options?: {
234
238
  suppressFailureNotification?: boolean;
239
+ productVouchersOnly?: boolean;
235
240
  }) => Promise<{
236
241
  isAvailable?: boolean;
237
242
  isAccepted?: boolean;
238
243
  type?: string;
239
244
  unavailableReason?: string;
245
+ scannedDiscountList?: Record<string, any>[];
240
246
  }>;
241
247
  /** 当前订单已有其他客户时,由宿主复用客户组件完成确认及切换。 */
242
248
  requestCustomerSwitch?: (customer: ICustomer) => Promise<boolean | null>;
@@ -244,7 +250,7 @@ export interface GlobalScanHostBridge {
244
250
  refresh?: () => void;
245
251
  }
246
252
  /** handleGlobalScanCode 结构化返回 */
247
- export type GlobalScanHandleResult = {
253
+ export type GlobalScanHandleResult = ({
248
254
  status: 'success';
249
255
  kind: 'customer' | 'products' | 'promotion';
250
256
  meta?: {
@@ -257,5 +263,11 @@ export type GlobalScanHandleResult = {
257
263
  status: 'cancelled';
258
264
  } | {
259
265
  status: 'failed';
260
- reason: 'empty_code' | 'not_found' | 'invalid_data' | 'no_bridge';
266
+ reason: 'empty_code' | 'not_found' | 'invalid_data' | 'no_bridge' | 'entry_resolution_failed';
267
+ }) & {
268
+ /** product-voucher-collection returns voucher candidates; the caller decides how to use them. */
269
+ redemption?: {
270
+ source: 'wallet' | 'scan';
271
+ vouchers: Record<string, any>[];
272
+ };
261
273
  };
@@ -5,7 +5,7 @@ import type { OrderProduct, OrderProductIdentity, AddProductBookingInput } from
5
5
  * cart.addProduct 两阶段决策(与 ticketBooking `handleSelectProduct` 对齐):
6
6
  *
7
7
  * 1. `requiresDetail`:规格 / SKU / 套餐 / Session / 称重弹窗(门禁:`isOpenDetailModal` / `cartDetailValue` / `open_sold_weight`)
8
- * 2. `requiresBookingEdit`:资源 / 时间编辑抽屉(kiosk 强制进入;其他渠道由 `getIsAutoClose` 决定)
8
+ * 2. `requiresBookingEdit`:资源 / 时间编辑抽屉(自助终端强制进入;其他渠道由 `getIsAutoClose` 决定)
9
9
  * 3. `add`:两关均通过,直接 transform + 加车
10
10
  */
11
11
  export type AddProductDecision = {
@@ -17,12 +17,13 @@ var _dayjs = _interopRequireDefault(require("dayjs"));
17
17
  var _BookingContext = require("../../../modules/BookingContext");
18
18
  var _transformBaseProductToOrderProduct = require("../../BaseSales/utils/transformBaseProductToOrderProduct");
19
19
  var _weighingProductSku = require("./weighingProductSku");
20
+ var _platform = require("../../../utils/platform");
20
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
22
  /**
22
23
  * cart.addProduct 两阶段决策(与 ticketBooking `handleSelectProduct` 对齐):
23
24
  *
24
25
  * 1. `requiresDetail`:规格 / SKU / 套餐 / Session / 称重弹窗(门禁:`isOpenDetailModal` / `cartDetailValue` / `open_sold_weight`)
25
- * 2. `requiresBookingEdit`:资源 / 时间编辑抽屉(kiosk 强制进入;其他渠道由 `getIsAutoClose` 决定)
26
+ * 2. `requiresBookingEdit`:资源 / 时间编辑抽屉(自助终端强制进入;其他渠道由 `getIsAutoClose` 决定)
26
27
  * 3. `add`:两关均通过,直接 transform + 加车
27
28
  */
28
29
 
@@ -39,11 +40,11 @@ function needsSpecDetailModal(item) {
39
40
  }
40
41
 
41
42
  /**
42
- * 第二段:预约商品是否仍需打开资源 / 时间编辑(kiosk 强制打开,其他渠道与 info2 `cacheItem.autoClose` 等价)。
43
+ * 第二段:预约商品是否仍需打开资源 / 时间编辑(自助终端强制打开,其他渠道与 info2 `cacheItem.autoClose` 等价)。
43
44
  */
44
45
  function needsBookingEdit(cacheItem, ctx) {
45
46
  if (isNormalBookingProduct(cacheItem)) return false;
46
- if (ctx?.channel === 'kiosk') return true;
47
+ if ((0, _platform.isSelfServicePlatform)(ctx?.channel)) return true;
47
48
  const isAutoAllocationOn = ctx?.isAutoAllocationOn || (() => true);
48
49
  return !(0, _BookingContext.getIsAutoClose)(cacheItem, isAutoAllocationOn);
49
50
  }
@@ -289,6 +289,18 @@ async function applyGlobalScan(host, formatted, bridge) {
289
289
  // batch-search 可能返回来源门店客户;先映射到当前门店,确保 Wallet
290
290
  // 支付资产查询使用本店客户上下文。
291
291
  const bindResult = await bindWalletPassCustomer();
292
+ // Voucher collection prioritizes goods coupons resolved from the wristband/order.
293
+ // Only this opt-in flow checks them before selecting a payment wallet asset.
294
+ const collectionPromotion = bridge?.scanScope === 'product-voucher-collection' && bridge.applyPromotionCode ? await bridge.applyPromotionCode(scanCode, getRealCustomerId(activeCustomer), {
295
+ suppressFailureNotification: true,
296
+ productVouchersOnly: true
297
+ }) : undefined;
298
+ if (collectionPromotion?.isAccepted ?? collectionPromotion?.isAvailable) {
299
+ return {
300
+ status: 'success',
301
+ kind: 'promotion'
302
+ };
303
+ }
292
304
  const walletSelection = await trySelectWalletAsset();
293
305
  if (walletSelection) return walletSelection;
294
306
  if (!bridge?.applyPromotionCode) {
@@ -298,9 +310,9 @@ async function applyGlobalScan(host, formatted, bridge) {
298
310
  };
299
311
  }
300
312
  const promotionCustomerId = getRealCustomerId(activeCustomer);
301
- const promotionResult = bindResult.customerBound ? await bridge.applyPromotionCode(scanCode, promotionCustomerId, {
313
+ const promotionResult = collectionPromotion ?? (bindResult.customerBound ? await bridge.applyPromotionCode(scanCode, promotionCustomerId, {
302
314
  suppressFailureNotification: true
303
- }) : await bridge.applyPromotionCode(scanCode, promotionCustomerId);
315
+ }) : await bridge.applyPromotionCode(scanCode, promotionCustomerId));
304
316
  if (promotionResult?.isAccepted ?? promotionResult?.isAvailable) {
305
317
  return {
306
318
  status: 'success',
@@ -0,0 +1,10 @@
1
+ import type { GlobalScanHandleResult, GlobalScanHostBridge } from '../../types';
2
+ import { type GlobalScanApplyHost } from './applyGlobalScan';
3
+ import type { GlobalScanFormattedResult } from './formatGlobalScan';
4
+ export interface ProductVoucherCollectionScanHost extends GlobalScanApplyHost {
5
+ waitForCustomerDiscounts(): Promise<void>;
6
+ loadCustomerDiscounts(): Promise<Record<string, any>[]>;
7
+ }
8
+ /** Collect voucher candidates after customer binding and coupon loading finish.
9
+ * Never expand a wristband's result to other orders of the same customer. */
10
+ export declare function applyProductVoucherCollectionScan(host: ProductVoucherCollectionScanHost, formatted: GlobalScanFormattedResult, bridge: GlobalScanHostBridge): Promise<GlobalScanHandleResult>;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.applyProductVoucherCollectionScan = applyProductVoucherCollectionScan;
7
+ var _applyGlobalScan = require("./applyGlobalScan");
8
+ /** Collect voucher candidates after customer binding and coupon loading finish.
9
+ * Never expand a wristband's result to other orders of the same customer. */
10
+ async function applyProductVoucherCollectionScan(host, formatted, bridge) {
11
+ const assertCurrent = () => {
12
+ if (bridge.isCurrent?.() === false) {
13
+ throw new DOMException('Scan session ended', 'AbortError');
14
+ }
15
+ };
16
+ let vouchers = [];
17
+ assertCurrent();
18
+ const result = await (0, _applyGlobalScan.applyGlobalScan)({
19
+ ...host,
20
+ setOrderCustomer: customer => {
21
+ assertCurrent();
22
+ host.setOrderCustomer(customer);
23
+ },
24
+ addProductToOrder: (product, booking) => {
25
+ assertCurrent();
26
+ return host.addProductToOrder(product, booking);
27
+ }
28
+ }, formatted, {
29
+ ...bridge,
30
+ applyPromotionCode: bridge.applyPromotionCode && (async (code, customerId, options) => {
31
+ // Customer binding starts prepare/config in the background. Let it finish
32
+ // before adding scanned coupons so its response cannot overwrite them.
33
+ await host.waitForCustomerDiscounts();
34
+ assertCurrent();
35
+ const promotion = await bridge.applyPromotionCode(code, customerId, {
36
+ ...options,
37
+ productVouchersOnly: true,
38
+ suppressFailureNotification: true
39
+ });
40
+ assertCurrent();
41
+ // An empty successful search is different from a swallowed request error.
42
+ if (!Array.isArray(promotion.scannedDiscountList)) {
43
+ throw new Error('Could not resolve scanned vouchers');
44
+ }
45
+ vouchers = promotion.scannedDiscountList;
46
+ return promotion;
47
+ })
48
+ });
49
+ assertCurrent();
50
+ if (formatted.searchType === 'wallet' && result.status === 'success') {
51
+ vouchers = await host.loadCustomerDiscounts();
52
+ assertCurrent();
53
+ return {
54
+ ...result,
55
+ redemption: {
56
+ source: 'wallet',
57
+ vouchers
58
+ }
59
+ };
60
+ }
61
+ if (formatted.searchType === 'walletPass') {
62
+ return {
63
+ ...result,
64
+ redemption: {
65
+ source: 'scan',
66
+ vouchers
67
+ }
68
+ };
69
+ }
70
+ return result;
71
+ }
@@ -10,6 +10,7 @@ exports.searchWalletPass = exports.searchWallet = exports.searchProduct = export
10
10
  const searchWalletPass = async (request, code) => {
11
11
  const params = {
12
12
  code,
13
+ resolve_ticket_order: 1,
13
14
  translate_flag: 1,
14
15
  // 翻译识别码名称 0:不翻译 1:翻译
15
16
  relation_product: 1,
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.handleUniversalScan = exports.handleGlobalScan = exports.handleCustomerScan = void 0;
7
7
  var _cloudSearch = require("./cloudSearch");
8
8
  var _scanCache = _interopRequireDefault(require("./scanCache"));
9
+ var _platform = require("../../../../utils/platform");
9
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
11
  /**
11
12
  * Promise.any 的替代实现
@@ -107,7 +108,7 @@ const handleGlobalScan = (request, localSearch, channel) => {
107
108
  if (value.startsWith('WL')) {
108
109
  requestList = [(0, _cloudSearch.searchWallet)(request, value)];
109
110
  } else {
110
- requestList = [...(channel === 'kiosk' ? [] : [(0, _cloudSearch.searchOrder)(request, value)]), (0, _cloudSearch.searchWalletPass)(request, value), (0, _cloudSearch.searchWallet)(request, value), (0, _cloudSearch.searchProduct)(request, value)];
111
+ requestList = [...((0, _platform.isSelfServicePlatform)(channel) ? [] : [(0, _cloudSearch.searchOrder)(request, value)]), (0, _cloudSearch.searchWalletPass)(request, value), (0, _cloudSearch.searchWallet)(request, value), (0, _cloudSearch.searchProduct)(request, value)];
111
112
  }
112
113
  return requestList;
113
114
  };
@@ -156,7 +156,7 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
156
156
  /** 在 Kiosk 拉起支付设备前补齐订单号,同一订单重试复用已分配的号码。 */
157
157
  ensureLocalOrderNumbersForCheckout(): Promise<void>;
158
158
  /**
159
- * PC/H5/Kiosk 结账默认直接等待云端 checkout;POS/WebPOS 仍保持本地待同步。
159
+ * PC/H5 及自助终端结账默认直接等待云端 checkout;POS/WebPOS 仍保持本地待同步。
160
160
  * 显式传 checkoutSyncTaskEnabled: true 时仍可回退到本地同步模式。
161
161
  */
162
162
  protected shouldUseCheckoutSyncTask(): boolean;
@@ -1546,6 +1546,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
1546
1546
  cover = false
1547
1547
  } = {}) {
1548
1548
  const previousScope = this.getAvailabilityScopeDescriptor(this.otherParams || {});
1549
+ const previousCatalogScope = this.otherParams?.catalogScopeKey;
1549
1550
  const previousItemRuleConfig = this.otherParams?.itemRule;
1550
1551
  const explicitlySetsOpenData = Object.prototype.hasOwnProperty.call(params, 'openData');
1551
1552
  const nextParams = cover ? params : {
@@ -1558,6 +1559,10 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
1558
1559
  await super.setOtherParams(params, {
1559
1560
  cover
1560
1561
  });
1562
+ if (previousCatalogScope !== this.otherParams?.catalogScopeKey && (previousCatalogScope || this.otherParams?.catalogScopeKey)) {
1563
+ this.unifiedProductCatalog = [];
1564
+ await this.core.effects.emit(`${this.name}:onProductsLoaded`, []);
1565
+ }
1561
1566
  const nextScope = this.getAvailabilityScopeDescriptor(this.otherParams || {});
1562
1567
  if (explicitlySetsOpenData) {
1563
1568
  this.openDataTarget = this.otherParams?.openData && nextScope.businessCode && nextScope.channel ? `${nextScope.businessCode}+${nextScope.channel}` : null;
@@ -1812,14 +1817,14 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
1812
1817
  }
1813
1818
 
1814
1819
  /**
1815
- * PC/H5/Kiosk 结账默认直接等待云端 checkout;POS/WebPOS 仍保持本地待同步。
1820
+ * PC/H5 及自助终端结账默认直接等待云端 checkout;POS/WebPOS 仍保持本地待同步。
1816
1821
  * 显式传 checkoutSyncTaskEnabled: true 时仍可回退到本地同步模式。
1817
1822
  */
1818
1823
  shouldUseCheckoutSyncTask() {
1819
1824
  const configured = this.otherParams?.checkoutSyncTaskEnabled;
1820
1825
  if (configured === true) return true;
1821
1826
  const platform = (0, _platform.normalizeRuntimePlatform)(this.otherParams?.platform);
1822
- return !(0, _platform.isCustomerUserPlatform)(platform) && platform !== 'kiosk';
1827
+ return !(0, _platform.isCustomerUserPlatform)(platform) && !(0, _platform.isSelfServicePlatform)(platform);
1823
1828
  }
1824
1829
 
1825
1830
  /** UnifiedBookingSales 的真实结账默认请求收据数据,供云端确认后再本地打印。 */
@@ -2176,7 +2181,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
2176
2181
  throw new Error('[UnifiedBookingSales] getProtocol 需要 policyId');
2177
2182
  }
2178
2183
  let policyUrl = 'shop-policy';
2179
- if (this.otherParams.platform === 'kiosk' || this.otherParams.platform === 'pos' || this.otherParams.platform === 'shop') {
2184
+ if ((0, _platform.isSelfServicePlatform)(this.otherParams.platform) || this.otherParams.platform === 'pos' || this.otherParams.platform === 'shop') {
2180
2185
  policyUrl = 'policy';
2181
2186
  }
2182
2187
  return this.request.get(`/${policyUrl}/${encodeURIComponent(normalizedPolicyId)}`);
@@ -2188,6 +2193,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
2188
2193
  */
2189
2194
  async loadProducts(params = {}, options) {
2190
2195
  if (!this.store.products) throw new Error('[UnifiedBookingSales] products 模块未初始化');
2196
+ const catalogScope = this.otherParams.catalogScopeKey;
2191
2197
  const schedule_date = params.schedule_date || (0, _dayjs.default)().format('YYYY-MM-DD');
2192
2198
  const schedule_datetime = params.schedule_datetime || `${schedule_date} ${(0, _dayjs.default)().format('HH:mm:ss')}`;
2193
2199
  const result = await this.store.products.loadProducts({
@@ -2198,6 +2204,11 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
2198
2204
  schedule_datetime,
2199
2205
  cacheId: this.cacheId
2200
2206
  }, options);
2207
+ if (catalogScope !== this.otherParams.catalogScopeKey) {
2208
+ throw Object.assign(new Error('Product scope changed'), {
2209
+ name: 'AbortError'
2210
+ });
2211
+ }
2201
2212
  this.unifiedProductCatalog = Array.isArray(result) ? [...result] : [];
2202
2213
  await this.core.effects.emit(`${this.name}:onProductsLoaded`, result);
2203
2214
  return result;
@@ -6,3 +6,5 @@ export declare function normalizeRuntimePlatform(platform: unknown): string;
6
6
  * PC and H5 are authenticated-customer clients rather than staff terminals.
7
7
  */
8
8
  export declare function isCustomerUserPlatform(platform: unknown): boolean;
9
+ /** Kiosk and vending retain distinct channels but share self-service checkout behavior. */
10
+ export declare function isSelfServicePlatform(platform: unknown): boolean;
@@ -4,8 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.isCustomerUserPlatform = isCustomerUserPlatform;
7
+ exports.isSelfServicePlatform = isSelfServicePlatform;
7
8
  exports.normalizeRuntimePlatform = normalizeRuntimePlatform;
8
9
  const CUSTOMER_USER_PLATFORMS = new Set(['pc', 'h5']);
10
+ const SELF_SERVICE_PLATFORMS = new Set(['kiosk', 'vending']);
9
11
 
10
12
  /**
11
13
  * Normalize the runtime platform passed through solution/module otherParams.
@@ -19,4 +21,9 @@ function normalizeRuntimePlatform(platform) {
19
21
  */
20
22
  function isCustomerUserPlatform(platform) {
21
23
  return CUSTOMER_USER_PLATFORMS.has(normalizeRuntimePlatform(platform));
24
+ }
25
+
26
+ /** Kiosk and vending retain distinct channels but share self-service checkout behavior. */
27
+ function isSelfServicePlatform(platform) {
28
+ return SELF_SERVICE_PLATFORMS.has(normalizeRuntimePlatform(platform));
22
29
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.170",
4
+ "version": "2.3.172",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",