@pisell/pisellos 2.3.109 → 2.3.111

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 (30) hide show
  1. package/dist/modules/OpenData/index.d.ts +1 -1
  2. package/dist/modules/OpenData/index.js +19 -11
  3. package/dist/modules/Order/index.d.ts +1 -0
  4. package/dist/modules/Order/index.js +22 -21
  5. package/dist/modules/Payment/cashRecommendationAlgorithm.d.ts +4 -5
  6. package/dist/modules/Payment/cashRecommendationAlgorithm.js +17 -367
  7. package/dist/server/index.js +4 -5
  8. package/dist/server/utils/small-ticket.d.ts +8 -5
  9. package/dist/server/utils/small-ticket.js +678 -140
  10. package/dist/solution/BookingByStep/index.d.ts +1 -1
  11. package/dist/solution/BookingTicket/index.d.ts +6 -0
  12. package/dist/solution/BookingTicket/index.js +548 -485
  13. package/dist/utils/os-private-payload.d.ts +5 -0
  14. package/dist/utils/os-private-payload.js +17 -0
  15. package/lib/model/strategy/adapter/promotion/index.js +1 -46
  16. package/lib/modules/OpenData/index.d.ts +1 -1
  17. package/lib/modules/OpenData/index.js +9 -1
  18. package/lib/modules/Order/index.d.ts +1 -0
  19. package/lib/modules/Order/index.js +15 -18
  20. package/lib/modules/Payment/cashRecommendationAlgorithm.d.ts +4 -5
  21. package/lib/modules/Payment/cashRecommendationAlgorithm.js +9 -354
  22. package/lib/server/index.js +4 -5
  23. package/lib/server/utils/small-ticket.d.ts +8 -5
  24. package/lib/server/utils/small-ticket.js +524 -65
  25. package/lib/solution/BookingByStep/index.d.ts +1 -1
  26. package/lib/solution/BookingTicket/index.d.ts +6 -0
  27. package/lib/solution/BookingTicket/index.js +32 -3
  28. package/lib/utils/os-private-payload.d.ts +5 -0
  29. package/lib/utils/os-private-payload.js +22 -0
  30. package/package.json +1 -1
@@ -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 | 5 | 3 | 1 | 2 | 4 | 6;
329
+ weekNum: 0 | 2 | 1 | 6 | 4 | 5 | 3;
330
330
  }[]>;
331
331
  submitTimeSlot(timeSlots: TimeSliceItem): void;
332
332
  private getScheduleDataByIds;
@@ -45,6 +45,12 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
45
45
  */
46
46
  protected createSubModule(moduleName: string): Module | null;
47
47
  initialize(core: PisellCore, options?: ModuleOptions): Promise<void>;
48
+ private getInjectedOpenDataConfig;
49
+ /**
50
+ * 在解决方案对外 ready 前准备 Invoice Document;失败只降级模板,不阻断销售。
51
+ * 已由页面取得的 OpenData 直接交给模块接管,没有注入数据时再走 target-scoped 加载。
52
+ */
53
+ private prepareInvoiceTemplateAtSolutionReady;
48
54
  protected getBookingTicketBusinessCode(): string | null;
49
55
  private getIdGeneratorPlugin;
50
56
  private loadOpenDataConfig;
@@ -193,10 +193,37 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
193
193
  throw new Error('bookingTicket解决方案需要 request 插件支持');
194
194
  }
195
195
  this.platform = this.otherParams?.platform;
196
+ await this.prepareInvoiceTemplateAtSolutionReady(this.getInjectedOpenDataConfig());
196
197
  await this.configureIdGeneratorFromOpenData();
197
198
  }
199
+ getInjectedOpenDataConfig() {
200
+ const openData = this.otherParams?.openData;
201
+ return openData && typeof openData === 'object' && !Array.isArray(openData) ? openData : undefined;
202
+ }
203
+
204
+ /**
205
+ * 在解决方案对外 ready 前准备 Invoice Document;失败只降级模板,不阻断销售。
206
+ * 已由页面取得的 OpenData 直接交给模块接管,没有注入数据时再走 target-scoped 加载。
207
+ */
208
+ async prepareInvoiceTemplateAtSolutionReady(injectedOpenData) {
209
+ const businessCode = this.getBookingTicketBusinessCode();
210
+ if (!businessCode || !this.store.openData) return;
211
+ const channel = this.getSubmitOrderSalesChannel();
212
+ const target = `${businessCode}+${channel}`;
213
+ try {
214
+ if (injectedOpenData && typeof this.store.openData.ensureInvoiceTemplateSettings === 'function') {
215
+ this.openDataTarget = target;
216
+ await this.store.openData.ensureInvoiceTemplateSettings(target, injectedOpenData);
217
+ this.otherParams.openData = injectedOpenData;
218
+ return;
219
+ }
220
+ await this.loadOpenDataConfig();
221
+ } catch (error) {
222
+ console.warn('[BookingTicket] Invoice 模板预加载失败,使用默认配置', error);
223
+ }
224
+ }
198
225
  getBookingTicketBusinessCode() {
199
- const candidates = [this.otherParams?.businessCode, this.otherParams?.business_code, this.getOrderHeader()?.business_code, this.store.order?.getTempOrder()?.business_code, this.getSalesOrder()?.raw?.business_code];
226
+ const candidates = [this.otherParams?.businessCode, this.otherParams?.business_code, this.getOrderHeader()?.business_code, typeof this.store.order?.getTempOrder === 'function' ? this.store.order.getTempOrder()?.business_code : undefined, this.getSalesOrder()?.raw?.business_code];
200
227
  for (const candidate of candidates) {
201
228
  if (candidate === undefined || candidate === null) continue;
202
229
  const normalized = String(candidate).trim();
@@ -1784,10 +1811,12 @@ class BookingTicketImpl extends _BaseSales.BaseSalesImpl {
1784
1811
  await super.setOtherParams(params, {
1785
1812
  cover
1786
1813
  });
1814
+ const invoiceContextChanged = params?.businessCode !== undefined || params?.business_code !== undefined || params?.channel !== undefined || params?.platform !== undefined || Object.prototype.hasOwnProperty.call(params, 'openData');
1815
+ if (invoiceContextChanged) {
1816
+ await this.prepareInvoiceTemplateAtSolutionReady(Object.prototype.hasOwnProperty.call(params, 'openData') ? this.getInjectedOpenDataConfig() : undefined);
1817
+ }
1787
1818
  if (params?.businessCode !== undefined || params?.business_code !== undefined) {
1788
1819
  await this.configureIdGeneratorFromOpenData();
1789
- } else if (params?.channel !== undefined) {
1790
- await this.loadOpenDataConfig();
1791
1820
  }
1792
1821
  }
1793
1822
  getDeviceTaskPlugin() {
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Remove top-level fields reserved for communication with the PisellOS proxy.
3
+ * Nested business payloads are intentionally left untouched.
4
+ */
5
+ export declare function stripOsPrivatePayloadFields<T>(data: T): T;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.stripOsPrivatePayloadFields = stripOsPrivatePayloadFields;
7
+ var _lodashEs = require("lodash-es");
8
+ const OS_PRIVATE_FIELD_PREFIX = '_os_';
9
+
10
+ /**
11
+ * Remove top-level fields reserved for communication with the PisellOS proxy.
12
+ * Nested business payloads are intentionally left untouched.
13
+ */
14
+ function stripOsPrivatePayloadFields(data) {
15
+ const next = (0, _lodashEs.cloneDeep)(data);
16
+ if (!next || typeof next !== 'object' || Array.isArray(next)) return next;
17
+ const record = next;
18
+ Object.keys(record).forEach(key => {
19
+ if (key.startsWith(OS_PRIVATE_FIELD_PREFIX)) delete record[key];
20
+ });
21
+ return next;
22
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.109",
4
+ "version": "2.3.111",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",