@pisell/pisellos 2.2.324 → 2.2.325

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.
@@ -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 | 5 | 4 | 6;
345
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
346
346
  }[]>;
347
347
  submitTimeSlot(timeSlots: TimeSliceItem): void;
348
348
  private getScheduleDataByIds;
@@ -1 +1,46 @@
1
- "use strict";
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _examples.BUY_X_GET_Y_FREE_STRATEGY;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _examples.ITEM_REWARD_STRATEGY;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "PromotionAdapter", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _adapter.PromotionAdapter;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "PromotionEvaluator", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _evaluator.PromotionEvaluator;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "default", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _adapter.default;
40
+ }
41
+ });
42
+ var _evaluator = require("./evaluator");
43
+ var _adapter = _interopRequireWildcard(require("./adapter"));
44
+ var _examples = require("./examples");
45
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
46
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -640,7 +640,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
640
640
  generateIdempotencyToken(): string;
641
641
  syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
642
642
  createOrder(params: CommitOrderParams['query']): {
643
- type: "appointment_booking" | "virtual";
643
+ type: "virtual" | "appointment_booking";
644
644
  platform: string;
645
645
  sales_channel: string;
646
646
  order_sales_channel: string;
@@ -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(): "duration" | "session" | "normal";
52
+ getProductType(): "normal" | "duration" | "session";
53
53
  }
@@ -65,6 +65,7 @@ declare class Server {
65
65
  private deviceTaskActionsRegistered;
66
66
  private localPaymentUpdateQueues;
67
67
  private paymentIdentityRefreshes;
68
+ private receiptFulfillmentConfigInFlight;
68
69
  private floorPlanQuerySubscribers;
69
70
  private moduleRegistry;
70
71
  constructor(core: PisellCore);
@@ -525,6 +526,8 @@ declare class Server {
525
526
  private extractInvoiceTemplateSettings;
526
527
  private applyCheckoutFulfillmentBuzzer;
527
528
  private buildCheckoutResourceIdentifierBuzzer;
529
+ /** Refresh derived references on receipt copies; manual references and stored orders stay intact. */
530
+ private withCurrentReceiptResourceReference;
528
531
  private getCheckoutResourceIdentifier;
529
532
  private stringifyCheckoutResourceIdentifier;
530
533
  private normalizeCheckoutSubmitData;
@@ -125,6 +125,7 @@ class Server {
125
125
  deviceTaskActionsRegistered = false;
126
126
  localPaymentUpdateQueues = new Map();
127
127
  paymentIdentityRefreshes = new Map();
128
+ receiptFulfillmentConfigInFlight = new Map();
128
129
  floorPlanQuerySubscribers = new Map();
129
130
 
130
131
  // 模块注册表 - 定义所有可用的模块配置
@@ -3711,6 +3712,69 @@ class Server {
3711
3712
  });
3712
3713
  return values.join(',');
3713
3714
  }
3715
+
3716
+ /** Refresh derived references on receipt copies; manual references and stored orders stay intact. */
3717
+ async withCurrentReceiptResourceReference(order) {
3718
+ const resourceReference = this.buildCheckoutResourceIdentifierBuzzer(order.bookings);
3719
+ if (!resourceReference || resourceReference === String(order.buzzer ?? '')) return order;
3720
+ const businessCode = String(order.business_code || '').trim();
3721
+ const channel = String(order.order_sales_channel || '').trim();
3722
+ const shopId = this.getAppData('shop_id');
3723
+ const tenantId = this.getAppData('tenant_id');
3724
+ if (!businessCode || !channel || !shopId || !this.app?.request?.post) return order;
3725
+
3726
+ // A receipt can be printed outside a Sales instance. Read the order's own
3727
+ // business/channel settings rather than borrowing the currently open page.
3728
+ const key = JSON.stringify([String(shopId), String(tenantId ?? ''), businessCode, channel]);
3729
+ let inFlight = this.receiptFulfillmentConfigInFlight.get(key);
3730
+ if (!inFlight) {
3731
+ inFlight = (async () => {
3732
+ const response = await this.app.request.post(`/open/my-pisell/${shopId}/setting`, {
3733
+ scope: 'board',
3734
+ target: `${businessCode}+${channel}`,
3735
+ section_code: ['fulfillment']
3736
+ }, {
3737
+ pisell2: true,
3738
+ isPisell2: true,
3739
+ prefix: false,
3740
+ customToast: () => {},
3741
+ ...(tenantId ? {
3742
+ headers: {
3743
+ 'Tenant-Id': String(tenantId)
3744
+ }
3745
+ } : {})
3746
+ });
3747
+ if (response?.status === false || response?.code != null && Number(response.code) !== 200) {
3748
+ throw new Error('Receipt fulfillment settings are unavailable');
3749
+ }
3750
+ return response?.data?.['fulfillment.fulfillment_ref_mode'];
3751
+ })();
3752
+ this.receiptFulfillmentConfigInFlight.set(key, inFlight);
3753
+ }
3754
+ try {
3755
+ const mode = await inFlight;
3756
+ if (mode !== 'resource_identifier' || String(this.getAppData('shop_id')) !== String(shopId) || String(this.getAppData('tenant_id') ?? '') !== String(tenantId ?? '')) return order;
3757
+ return {
3758
+ ...order,
3759
+ buzzer: resourceReference
3760
+ };
3761
+ } catch (error) {
3762
+ // Offline/manual printing still works. Without a confirmed policy, do not
3763
+ // mistake a manually entered pickup reference for an obsolete table name.
3764
+ this.logWarning('withCurrentReceiptResourceReference: 配置不可用,保留原取单号', {
3765
+ order_id: order.order_id,
3766
+ target: `${businessCode}+${channel}`,
3767
+ error: error instanceof Error ? error.message : String(error)
3768
+ });
3769
+ return order;
3770
+ } finally {
3771
+ // Only coalesce concurrent outputs; settings changes and failures must be
3772
+ // re-read on the next receipt instead of becoming a permanent cache.
3773
+ if (this.receiptFulfillmentConfigInFlight.get(key) === inFlight) {
3774
+ this.receiptFulfillmentConfigInFlight.delete(key);
3775
+ }
3776
+ }
3777
+ }
3714
3778
  getCheckoutResourceIdentifier(resource, fallbackName) {
3715
3779
  if (!resource || typeof resource !== 'object') return '';
3716
3780
  const candidates = [resource.main_field, resource.name, resource.title, resource.metadata?.resource_name, resource.metadata?.name, fallbackName, resource.relation_id, resource.id];
@@ -3979,7 +4043,8 @@ class Server {
3979
4043
  const printableOrder = await this.withLocalSmallTicketData(params.order, {
3980
4044
  requireFullyPaid: params.requireFullyPaid,
3981
4045
  invoiceTemplateSettings: params.invoiceTemplateSettings,
3982
- applyTemplateVisibility: true
4046
+ applyTemplateVisibility: true,
4047
+ refreshResourceReference: true
3983
4048
  });
3984
4049
  if (!(0, _smallTicket.hasSmallTicketData)(printableOrder.payment_info?.small_ticket_data)) {
3985
4050
  return {
@@ -4217,7 +4282,8 @@ class Server {
4217
4282
  locales: this.normalizeRequestedReceiptLocales(input.locales),
4218
4283
  invoiceTemplateSettings: input.template_settings === undefined ? undefined : this.normalizePrintInvoiceTemplateSettings(input.template_settings),
4219
4284
  applyTemplateVisibility: true,
4220
- includeReceiptKeys: input.template_settings !== undefined
4285
+ includeReceiptKeys: input.template_settings !== undefined,
4286
+ refreshResourceReference: true
4221
4287
  });
4222
4288
  const smallTicketData = rebuiltOrder.payment_info?.small_ticket_data;
4223
4289
  if (!(0, _smallTicket.hasSmallTicketData)(smallTicketData)) {
@@ -5139,7 +5205,8 @@ class Server {
5139
5205
  collapsed_duplicate_counts: collapsedDuplicateCounts
5140
5206
  });
5141
5207
  }
5142
- const enrichedOrder = await this.enrichPaymentNamesByCode(normalizedOrder);
5208
+ const receiptOrder = options?.refreshResourceReference ? await this.withCurrentReceiptResourceReference(normalizedOrder) : normalizedOrder;
5209
+ const enrichedOrder = await this.enrichPaymentNamesByCode(receiptOrder);
5143
5210
  const productMap = options?.productMap ?? (await this.buildSmallTicketProductMap(enrichedOrder));
5144
5211
  const smallTicketData = (0, _smallTicket.buildSmallTicketData)({
5145
5212
  order: enrichedOrder,
@@ -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 | 5 | 4 | 6;
345
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
346
346
  }[]>;
347
347
  submitTimeSlot(timeSlots: TimeSliceItem): void;
348
348
  private getScheduleDataByIds;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.324",
4
+ "version": "2.2.325",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",