@pisell/pisellos 2.2.325 → 2.2.327

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 (44) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  2. package/dist/model/strategy/adapter/walletPass/locales.js +9 -0
  3. package/dist/modules/OpenData/index.d.ts +8 -1
  4. package/dist/modules/OpenData/index.js +276 -95
  5. package/dist/modules/Payment/utils.d.ts +2 -0
  6. package/dist/modules/Payment/utils.js +6 -6
  7. package/dist/modules/Payment/walletpass.d.ts +2 -0
  8. package/dist/modules/Payment/walletpass.js +75 -34
  9. package/dist/server/index.d.ts +3 -0
  10. package/dist/server/index.js +883 -611
  11. package/dist/server/modules/order/index.d.ts +1 -0
  12. package/dist/server/modules/order/index.js +51 -51
  13. package/dist/server/modules/products/index.d.ts +6 -2
  14. package/dist/server/modules/products/index.js +476 -400
  15. package/dist/solution/BookingByStep/index.d.ts +1 -1
  16. package/dist/solution/BookingTicket/index.js +6 -5
  17. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +1 -1
  18. package/dist/solution/Sales/index.d.ts +2 -5
  19. package/dist/solution/Sales/index.js +117 -143
  20. package/dist/solution/Sales/types.d.ts +6 -0
  21. package/dist/solution/Sales/types.js +2 -0
  22. package/dist/solution/UnifiedBookingSales/index.js +34 -23
  23. package/lib/model/strategy/adapter/walletPass/locales.js +9 -0
  24. package/lib/modules/OpenData/index.d.ts +8 -1
  25. package/lib/modules/OpenData/index.js +123 -21
  26. package/lib/modules/Payment/utils.d.ts +2 -0
  27. package/lib/modules/Payment/utils.js +7 -7
  28. package/lib/modules/Payment/walletpass.d.ts +2 -0
  29. package/lib/modules/Payment/walletpass.js +42 -11
  30. package/lib/server/index.d.ts +3 -0
  31. package/lib/server/index.js +164 -22
  32. package/lib/server/modules/order/index.d.ts +1 -0
  33. package/lib/server/modules/order/index.js +4 -3
  34. package/lib/server/modules/products/index.d.ts +6 -2
  35. package/lib/server/modules/products/index.js +40 -7
  36. package/lib/solution/BookingByStep/index.d.ts +1 -1
  37. package/lib/solution/BookingTicket/index.js +2 -1
  38. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +1 -1
  39. package/lib/solution/Sales/index.d.ts +2 -5
  40. package/lib/solution/Sales/index.js +32 -66
  41. package/lib/solution/Sales/types.d.ts +6 -0
  42. package/lib/solution/Sales/types.js +1 -0
  43. package/lib/solution/UnifiedBookingSales/index.js +3 -2
  44. package/package.json +1 -1
@@ -109,6 +109,7 @@ export declare class OrderModule extends BaseModule implements Module {
109
109
  getLocalOrderForPaymentReadiness(lookup: OrderId): Promise<OrderData | null>;
110
110
  getLocalOrderByLookup(lookup: OrderId, options?: {
111
111
  operationId?: string;
112
+ exactOrderId?: boolean;
112
113
  }): Promise<OrderData | null>;
113
114
  getLocalPayment(params: {
114
115
  saleId: OrderId;
@@ -678,6 +678,7 @@ class OrderModule extends _BaseModule.BaseModule {
678
678
  }
679
679
  async getLocalOrderByLookup(lookup, options = {}) {
680
680
  const key = this.getIdKey(lookup);
681
+ const matches = order => options.exactOrderId ? order.order_id != null && this.getIdKey(order.order_id) === key : this.isOrderLookupMatch(order, key);
681
682
  const logContext = {
682
683
  operation_id: options.operationId,
683
684
  lookup: key,
@@ -687,7 +688,7 @@ class OrderModule extends _BaseModule.BaseModule {
687
688
  this.logInfo('getLocalOrderByLookup-localPayment-开始', logContext);
688
689
  }
689
690
  const memoryOrderById = this.store.map.get(key);
690
- if (memoryOrderById) {
691
+ if (memoryOrderById && (!options.exactOrderId || matches(memoryOrderById))) {
691
692
  if (options.operationId) {
692
693
  this.logInfo('getLocalOrderByLookup-localPayment-命中内存映射', {
693
694
  ...logContext,
@@ -696,7 +697,7 @@ class OrderModule extends _BaseModule.BaseModule {
696
697
  }
697
698
  return memoryOrderById;
698
699
  }
699
- const memoryOrder = this.store.list.find(order => this.isOrderLookupMatch(order, key));
700
+ const memoryOrder = this.store.list.find(matches);
700
701
  if (memoryOrder) {
701
702
  if (options.operationId) {
702
703
  this.logInfo('getLocalOrderByLookup-localPayment-命中内存列表', {
@@ -710,7 +711,7 @@ class OrderModule extends _BaseModule.BaseModule {
710
711
  this.logInfo('getLocalOrderByLookup-localPayment-开始读取SQLite', logContext);
711
712
  }
712
713
  const orders = await this.loadOrdersFromSQLite();
713
- const localOrder = orders.find(order => this.isOrderLookupMatch(order, key));
714
+ const localOrder = orders.find(matches);
714
715
  if (!localOrder) {
715
716
  if (options.operationId) {
716
717
  this.logWarning('getLocalOrderByLookup-localPayment-SQLite未命中', {
@@ -35,8 +35,10 @@ export declare class ProductsModule extends BaseModule implements Module {
35
35
  private syncTimer?;
36
36
  /** 最近一次 SSE 全量拉取完成时间 */
37
37
  private lastServerFullFetchAtMs;
38
- /** 最近一次 preload 完成时间(含 IndexDB 命中) */
38
+ /** 最近一次 preload 完成时间(含 IndexDB 命中,仅用于日志) */
39
39
  private lastPreloadCompletedAtMs;
40
+ private serverFullFetchPromise?;
41
+ private silentRefreshPromise?;
40
42
  /** IndexDB 写入串行队列,避免快照与 patch 并发交错 */
41
43
  private productIndexDBSaveQueue;
42
44
  /** 最近一次智能定价评估提取的 schedule 变价时间点(HH:mm),供 Server 订阅定时刷新使用 */
@@ -206,7 +208,8 @@ export declare class ProductsModule extends BaseModule implements Module {
206
208
  */
207
209
  loadProductsByServer(options?: {
208
210
  trigger?: string;
209
- }): Promise<any>;
211
+ }): Promise<ProductData[]>;
212
+ private fetchAndPersistProductsByServer;
210
213
  /**
211
214
  * 纯请求方法:通过 HTTP 接口获取商品列表(无副作用,不触发事件、不写 IndexDB)
212
215
  * @param params 查询参数
@@ -358,6 +361,7 @@ export declare class ProductsModule extends BaseModule implements Module {
358
361
  silentRefresh(options?: {
359
362
  trigger?: string;
360
363
  }): Promise<ProductData[]>;
364
+ private runSilentRefresh;
361
365
  /**
362
366
  * 销毁同步资源(取消 pubsub 订阅、清除定时器)
363
367
  */
@@ -16,7 +16,7 @@ var _replication = require("./replication");
16
16
  const INDEXDB_STORE_NAME = 'products';
17
17
  /** 商品同步防抖时间(毫秒) */
18
18
  const PRODUCT_SYNC_DEBOUNCE_MS = 10_000;
19
- /** silentRefresh 最小间隔,避免 preload 后立即全量重拉 */
19
+ /** silentRefresh 最小间隔,仅从成功的服务器全量刷新计时 */
20
20
  const PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS = 30_000;
21
21
 
22
22
  /**
@@ -63,8 +63,10 @@ class ProductsModule extends _BaseModule.BaseModule {
63
63
  syncTimer;
64
64
  /** 最近一次 SSE 全量拉取完成时间 */
65
65
  lastServerFullFetchAtMs = 0;
66
- /** 最近一次 preload 完成时间(含 IndexDB 命中) */
66
+ /** 最近一次 preload 完成时间(含 IndexDB 命中,仅用于日志) */
67
67
  lastPreloadCompletedAtMs = 0;
68
+ serverFullFetchPromise;
69
+ silentRefreshPromise;
68
70
  /** IndexDB 写入串行队列,避免快照与 patch 并发交错 */
69
71
  productIndexDBSaveQueue = Promise.resolve();
70
72
 
@@ -961,11 +963,20 @@ class ProductsModule extends _BaseModule.BaseModule {
961
963
  */
962
964
  async loadProductsByServer(options = {}) {
963
965
  if (this.isMemoryReplica()) return this.refreshFromReplica(options.trigger || 'loadProductsByServer');
966
+ if (this.serverFullFetchPromise) return this.serverFullFetchPromise;
967
+ const fetchPromise = this.fetchAndPersistProductsByServer(options.trigger || 'unknown');
968
+ this.serverFullFetchPromise = fetchPromise;
969
+ try {
970
+ return await fetchPromise;
971
+ } finally {
972
+ if (this.serverFullFetchPromise === fetchPromise) this.serverFullFetchPromise = undefined;
973
+ }
974
+ }
975
+ async fetchAndPersistProductsByServer(trigger) {
964
976
  if (!this.productDataSource) {
965
977
  this.logWarning('loadProductsByServer: ProductDataSource 不可用');
966
978
  return [];
967
979
  }
968
- const trigger = options.trigger || 'unknown';
969
980
  this.logInfo('开始通过 DataSource SSE 加载商品列表', {
970
981
  trigger
971
982
  });
@@ -1415,6 +1426,8 @@ class ProductsModule extends _BaseModule.BaseModule {
1415
1426
  await this.refreshFromReplica('preload');
1416
1427
  return;
1417
1428
  }
1429
+ const productsBeforePreload = this.store.list;
1430
+ const fullFetchBeforePreload = this.lastServerFullFetchAtMs;
1418
1431
  const tTotal = performance.now();
1419
1432
  this.logInfo('开始预加载数据');
1420
1433
  try {
@@ -1423,6 +1436,11 @@ class ProductsModule extends _BaseModule.BaseModule {
1423
1436
  (0, _product.perfMark)('preload.loadFromIndexDB', performance.now() - tIndexDB, {
1424
1437
  count: cachedData?.length ?? 0
1425
1438
  });
1439
+
1440
+ // PIN 刷新若先完成,不用随后读出的旧缓存覆盖服务器列表。
1441
+ if (this.lastServerFullFetchAtMs !== fullFetchBeforePreload && this.store.list !== productsBeforePreload) {
1442
+ return;
1443
+ }
1426
1444
  if (cachedData && cachedData.length > 0) {
1427
1445
  // IndexDB 反序列化的数据已经是全新的,无需 cloneDeep
1428
1446
  this.store.list = cachedData;
@@ -1915,13 +1933,18 @@ class ProductsModule extends _BaseModule.BaseModule {
1915
1933
  * @returns 刷新后的商品列表
1916
1934
  */
1917
1935
  async silentRefresh(options = {}) {
1918
- if (this.isMemoryReplica()) return this.refreshFromReplica(options.trigger || 'background');
1919
- const t0 = performance.now();
1920
- const now = Date.now();
1921
1936
  const trigger = options.trigger || 'background';
1937
+ if (this.isMemoryReplica()) return this.refreshFromReplica(trigger);
1938
+ if (this.silentRefreshPromise) {
1939
+ this.logInfo('silentRefresh 复用进行中的全量刷新', {
1940
+ trigger
1941
+ });
1942
+ return this.silentRefreshPromise;
1943
+ }
1944
+ const now = Date.now();
1922
1945
  const elapsedSincePreloadMs = now - this.lastPreloadCompletedAtMs;
1923
1946
  const elapsedSinceFullFetchMs = now - this.lastServerFullFetchAtMs;
1924
- if (this.lastPreloadCompletedAtMs > 0 && elapsedSincePreloadMs < PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS || this.lastServerFullFetchAtMs > 0 && elapsedSinceFullFetchMs < PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS) {
1947
+ if (!this.serverFullFetchPromise && this.lastServerFullFetchAtMs > 0 && elapsedSinceFullFetchMs < PRODUCT_SILENT_REFRESH_MIN_INTERVAL_MS) {
1925
1948
  this.logInfo('silentRefresh 跳过全量 SSE', {
1926
1949
  trigger,
1927
1950
  reason: 'within_min_interval',
@@ -1938,6 +1961,16 @@ class ProductsModule extends _BaseModule.BaseModule {
1938
1961
  elapsedSinceFullFetchMs,
1939
1962
  productCount: this.store.list.length
1940
1963
  });
1964
+ const refreshPromise = this.runSilentRefresh(trigger);
1965
+ this.silentRefreshPromise = refreshPromise;
1966
+ try {
1967
+ return await refreshPromise;
1968
+ } finally {
1969
+ if (this.silentRefreshPromise === refreshPromise) this.silentRefreshPromise = undefined;
1970
+ }
1971
+ }
1972
+ async runSilentRefresh(trigger) {
1973
+ const t0 = performance.now();
1941
1974
  try {
1942
1975
  const products = await this.loadProductsByServer({
1943
1976
  trigger
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
342
342
  date: string;
343
343
  status: string;
344
344
  week: string;
345
- weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
345
+ weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
346
346
  }[]>;
347
347
  submitTimeSlot(timeSlots: TimeSliceItem): void;
348
348
  private getScheduleDataByIds;
@@ -384,6 +384,7 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
384
384
  await idGenerator.configure({
385
385
  biz: businessCode,
386
386
  config: {
387
+ enableShortNumber: openDataConfig?.['sale.enable_short_number'] !== false,
387
388
  prefix,
388
389
  deviceCode: deviceId,
389
390
  padReceiptSequence: openDataConfig?.['sale.pad_with_leading_zeros'] === true,
@@ -2076,7 +2077,7 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
2076
2077
  if (invoiceContextChanged) {
2077
2078
  await this.prepareInvoiceTemplateAtSolutionReady(Object.prototype.hasOwnProperty.call(params, 'openData') ? this.getInjectedOpenDataConfig() : undefined);
2078
2079
  }
2079
- if (params?.businessCode !== undefined || params?.business_code !== undefined) {
2080
+ if (params?.businessCode !== undefined || params?.business_code !== undefined || Object.prototype.hasOwnProperty.call(params ?? {}, 'openData')) {
2080
2081
  await this.configureIdGeneratorFromOpenData();
2081
2082
  }
2082
2083
  }
@@ -278,7 +278,7 @@ async function applyGlobalScan(host, formatted, bridge) {
278
278
  }
279
279
  // 已识别为 Wallet 支付资产但当前不可用:保留禁用展示,不回退优惠码。
280
280
  if (!bindResult.resolveFailed) {
281
- bridge?.onNotify?.('fail', 'pisell2.text.goodpass.code-invalid-cart');
281
+ bridge?.onNotify?.('fail', walletResult.asset.reasonCode === 'empty_cart' ? 'pisell2.sale-detail.promotion-panel.add-items-first' : 'pisell2.text.goodpass.code-invalid-cart');
282
282
  }
283
283
  return {
284
284
  status: 'failed',
@@ -2,7 +2,7 @@ import dayjs from 'dayjs';
2
2
  import { Module, ModuleOptions, PisellCore } from '../../types';
3
3
  import { BaseModule } from '../../modules/BaseModule';
4
4
  import type { RequestPlugin } from '../../plugins/request';
5
- import { SalesState, SalesModuleAPI, Reservation, SalesResourceBookingItem, SalesResourceBookingItemWithGroups, SalesTimelineHighlights, ChangeBookingStatusParams, GetResourceBookingItemParams, SalesPrintLocalOrderReceiptOptions } from './types';
5
+ import { SalesState, SalesModuleAPI, Reservation, SalesResourceBookingItem, SalesResourceBookingItemWithGroups, SalesTimelineHighlights, ChangeBookingStatusParams, GetResourceBookingItemParams, SalesPrintLocalOrderReceiptOptions, CloudOrderInvoiceRequest } from './types';
6
6
  import type { BookingData } from '../../server/modules/order/types';
7
7
  export * from './types';
8
8
  /**
@@ -27,9 +27,6 @@ export declare class SalesImpl extends BaseModule implements Module, SalesModule
27
27
  protected request: RequestPlugin;
28
28
  private logger;
29
29
  private invoiceOpenDataModule;
30
- private invoiceOpenDataTarget;
31
- private invoiceOpenDataInFlight;
32
- private invoiceOpenDataInFlightTarget;
33
30
  constructor(name?: string, version?: string);
34
31
  initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
35
32
  /** 获取当前 store 快照 */
@@ -51,10 +48,10 @@ export declare class SalesImpl extends BaseModule implements Module, SalesModule
51
48
  * Legacy Sales 的系统上下文没有可打印的 system target,因此统一回退 pos。
52
49
  */
53
50
  private getInvoiceSalesChannel;
54
- private loadInvoiceOpenData;
55
51
  private logInvoiceOpenDataFallback;
56
52
  private resolveInvoiceConfigs;
57
53
  printLocalOrderReceipt<T = any>(lookup: string | number, options: SalesPrintLocalOrderReceiptOptions): Promise<T>;
54
+ printCloudOrderInvoice(input: CloudOrderInvoiceRequest): Promise<void>;
58
55
  /** 清除独立 Documents 缓存;下一次打印会按当前 target 重新获取。 */
59
56
  clearOpenDataCache(): void;
60
57
  destroy(): Promise<void>;
@@ -26,9 +26,6 @@ Object.keys(_types).forEach(function (key) {
26
26
  var _OpenData = require("../../modules/OpenData");
27
27
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
28
  const UNPAID_PAYMENT_STATUSES = new Set(['unpaid', 'partially_paid', 'payment_processing']);
29
- const INVOICE_OPEN_DATA_SECTION_CODES = ['documents'];
30
- const INVOICE_OPEN_DATA_CACHE_TTL = 5 * 60 * 1000;
31
-
32
29
  /**
33
30
  * Sales 解决方案基础骨架
34
31
  *
@@ -51,9 +48,6 @@ class SalesImpl extends _BaseModule.BaseModule {
51
48
  request;
52
49
  logger; // LoggerManager 实例
53
50
  invoiceOpenDataModule = null;
54
- invoiceOpenDataTarget = null;
55
- invoiceOpenDataInFlight = null;
56
- invoiceOpenDataInFlightTarget = null;
57
51
  constructor(name, version) {
58
52
  super(name, version);
59
53
  }
@@ -86,9 +80,6 @@ class SalesImpl extends _BaseModule.BaseModule {
86
80
  // 在这里补充从 Server/Order 读取 currentDay 原始数据并转换为预约列表。
87
81
 
88
82
  this.logger = appPlugin?.getApp().logger;
89
- this.invoiceOpenDataTarget = null;
90
- this.invoiceOpenDataInFlight = null;
91
- this.invoiceOpenDataInFlightTarget = null;
92
83
  this.invoiceOpenDataModule = new _OpenData.OpenDataModule(`${this.name}_invoiceOpenData`);
93
84
  this.core.registerModule(this.invoiceOpenDataModule, {
94
85
  initialState: {},
@@ -175,51 +166,6 @@ class SalesImpl extends _BaseModule.BaseModule {
175
166
  const normalized = String(channel ?? contextChannel ?? '').trim();
176
167
  return !normalized || normalized === 'system' ? 'pos' : normalized;
177
168
  }
178
- async loadInvoiceOpenData(businessCode, channel) {
179
- if (!this.invoiceOpenDataModule) {
180
- throw new Error('Sales Invoice OpenData 模块未初始化');
181
- }
182
- const target = `${businessCode}+${channel}`;
183
- const cachedData = this.invoiceOpenDataModule.getOpenData();
184
- const lastFetchedAt = this.invoiceOpenDataModule.getLastFetchedAt();
185
- if (cachedData && this.invoiceOpenDataTarget === target && typeof lastFetchedAt === 'number' && Date.now() - lastFetchedAt < INVOICE_OPEN_DATA_CACHE_TTL) {
186
- if (typeof this.invoiceOpenDataModule.ensureInvoiceTemplateSettings === 'function') {
187
- await this.invoiceOpenDataModule.ensureInvoiceTemplateSettings(target);
188
- }
189
- return cachedData;
190
- }
191
- if (this.invoiceOpenDataInFlight) {
192
- if (this.invoiceOpenDataInFlightTarget === target) {
193
- return this.invoiceOpenDataInFlight;
194
- }
195
- try {
196
- await this.invoiceOpenDataInFlight;
197
- } catch {
198
- // 另一 target 的失败不应阻断当前 target 获取自己的 Documents 配置。
199
- }
200
- return this.loadInvoiceOpenData(businessCode, channel);
201
- }
202
- const request = this.invoiceOpenDataModule.fetchOpenData({
203
- scope: 'board',
204
- target,
205
- section_code: [...INVOICE_OPEN_DATA_SECTION_CODES]
206
- });
207
- this.invoiceOpenDataInFlight = request;
208
- this.invoiceOpenDataInFlightTarget = target;
209
- try {
210
- const openData = await request;
211
- // clearOpenDataCache() 或后续请求接管后,旧响应不得复活 target 归属。
212
- if (this.invoiceOpenDataInFlight === request) {
213
- this.invoiceOpenDataTarget = target;
214
- }
215
- return openData;
216
- } finally {
217
- if (this.invoiceOpenDataInFlight === request) {
218
- this.invoiceOpenDataInFlight = null;
219
- this.invoiceOpenDataInFlightTarget = null;
220
- }
221
- }
222
- }
223
169
  logInvoiceOpenDataFallback(error) {
224
170
  const message = error instanceof Error ? error.message : String(error);
225
171
  if (this.logger?.addLog) {
@@ -236,16 +182,11 @@ class SalesImpl extends _BaseModule.BaseModule {
236
182
  }
237
183
  async resolveInvoiceConfigs(businessCode, channel) {
238
184
  try {
239
- await this.loadInvoiceOpenData(businessCode, channel);
240
- if (this.invoiceOpenDataTarget !== `${businessCode}+${channel}`) {
241
- return {
242
- invoice: (0, _OpenData.getDefaultInvoiceLayoutConfig)(),
243
- templateSettings: (0, _OpenData.getDefaultInvoiceTemplateSettings)()
244
- };
245
- }
185
+ if (!this.invoiceOpenDataModule) throw new Error('Sales Invoice OpenData 模块未初始化');
186
+ const templateSettings = await this.invoiceOpenDataModule.loadPrintInvoiceTemplate(`${businessCode}+${channel}`, 'manual');
246
187
  return {
247
- invoice: this.invoiceOpenDataModule?.getInvoiceLayoutConfig() ?? (0, _OpenData.getDefaultInvoiceLayoutConfig)(),
248
- templateSettings: this.invoiceOpenDataModule?.getInvoiceTemplateSettings() ?? (0, _OpenData.getDefaultInvoiceTemplateSettings)()
188
+ invoice: (0, _OpenData.normalizeInvoiceLayoutFromTemplateSettings)(templateSettings),
189
+ templateSettings
249
190
  };
250
191
  } catch (error) {
251
192
  this.logInvoiceOpenDataFallback(error);
@@ -287,12 +228,37 @@ class SalesImpl extends _BaseModule.BaseModule {
287
228
  customToast: () => {}
288
229
  });
289
230
  }
231
+ async printCloudOrderInvoice(input) {
232
+ const orderId = input?.order_id;
233
+ const channel = typeof input?.channel === 'string' ? input.channel.trim() : '';
234
+ if (!channel) throw new Error('Cloud Invoice requires a channel');
235
+ const openData = this.invoiceOpenDataModule;
236
+ if (!openData) throw new Error('Cloud Invoice is not initialized');
237
+ const requestOptions = {
238
+ osServer: true,
239
+ customToast: () => {}
240
+ };
241
+ const lookup = await this.request.post('/shop/local/cloud-order-invoice/lookup', {
242
+ order_id: orderId
243
+ }, requestOptions);
244
+ if (lookup?.status !== true || lookup.code !== 200) {
245
+ throw new Error(lookup?.message || 'Cloud Invoice order lookup failed');
246
+ }
247
+ const businessCode = lookup.data?.business_code?.trim();
248
+ if (!businessCode) throw new Error('Cloud Invoice order has no business_code');
249
+ const settings = await openData.loadCloudInvoiceTemplate(`${businessCode}+${channel}`);
250
+ const result = await this.request.post('/shop/local/cloud-order-invoice/submit', {
251
+ order_id: orderId,
252
+ business_code: businessCode,
253
+ template_settings: settings
254
+ }, requestOptions);
255
+ if (result?.status !== true || result.code !== 200) {
256
+ throw new Error(result?.message || 'Cloud Invoice dispatch failed');
257
+ }
258
+ }
290
259
 
291
260
  /** 清除独立 Documents 缓存;下一次打印会按当前 target 重新获取。 */
292
261
  clearOpenDataCache() {
293
- this.invoiceOpenDataInFlight = null;
294
- this.invoiceOpenDataInFlightTarget = null;
295
- this.invoiceOpenDataTarget = null;
296
262
  this.invoiceOpenDataModule?.clearCache();
297
263
  }
298
264
 
@@ -56,6 +56,11 @@ export interface SalesPrintLocalOrderReceiptOptions {
56
56
  /** 当前销售入口;缺失或为 system 时按 pos 处理。 */
57
57
  channel?: string;
58
58
  }
59
+ /** Native cloud-order notification. */
60
+ export interface CloudOrderInvoiceRequest {
61
+ order_id: string | number;
62
+ channel: string;
63
+ }
59
64
  /**
60
65
  * Sales 解决方案状态
61
66
  *
@@ -90,6 +95,7 @@ export interface SalesModuleAPI {
90
95
  changeBookingStatus: (params: ChangeBookingStatusParams) => Promise<any>;
91
96
  /** 按本地订单标识打印小票;本地未命中时由 OS Server 负责远端兜底。 */
92
97
  printLocalOrderReceipt: <T = any>(lookup: string | number, options: SalesPrintLocalOrderReceiptOptions) => Promise<T>;
98
+ printCloudOrderInvoice: (request: CloudOrderInvoiceRequest) => Promise<void>;
93
99
  /** 清除 Legacy Sales 独立维护的 Documents OpenData 缓存。 */
94
100
  clearOpenDataCache: () => void;
95
101
  /** 获取资源维度的预约占用列表 */
@@ -18,6 +18,7 @@ let SalesHooks = exports.SalesHooks = /*#__PURE__*/function (SalesHooks) {
18
18
  * 将 Server/Order 原始数据转换为真正的 Reservation DTO,
19
19
  * 当前不要直接把 OrderData 当作最终 UI 数据结构。
20
20
  */
21
+ /** Native cloud-order notification. */
21
22
  /**
22
23
  * Sales 解决方案状态
23
24
  *
@@ -1956,7 +1956,8 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
1956
1956
  const biz = this.getBookingTicketBusinessCode();
1957
1957
  if (!biz) throw new Error('当前订单缺少业务类型,无法生成订单编号');
1958
1958
  const idGenerator = this.appPlugin?.getApp?.()?.getPlugin?.('idGenerator');
1959
- if (!tempOrder.shop_order_number && typeof idGenerator?.generateShopOrderNumber !== 'function' || !tempOrder.shop_full_order_number && typeof idGenerator?.generateReceiptId !== 'function') {
1959
+ const useLongNumber = idGenerator?.getConfig?.(biz)?.enableShortNumber === false;
1960
+ if (!tempOrder.shop_order_number && typeof idGenerator?.generateShopOrderNumber !== 'function' || !tempOrder.shop_full_order_number && !useLongNumber && typeof idGenerator?.generateReceiptId !== 'function') {
1960
1961
  throw new Error('订单编号生成器不可用,请重启应用后重试');
1961
1962
  }
1962
1963
  try {
@@ -1966,7 +1967,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
1966
1967
  });
1967
1968
  }
1968
1969
  if (!tempOrder.shop_full_order_number) {
1969
- tempOrder.shop_full_order_number = await idGenerator.generateReceiptId({
1970
+ tempOrder.shop_full_order_number = useLongNumber ? tempOrder.shop_order_number : await idGenerator.generateReceiptId({
1970
1971
  biz
1971
1972
  });
1972
1973
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.325",
4
+ "version": "2.2.327",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",