@pisell/pisellos 2.3.106 → 2.3.107

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 (70) hide show
  1. package/dist/model/strategy/adapter/promotion/index.js +0 -9
  2. package/dist/modules/Discount/index.js +4 -1
  3. package/dist/modules/Discount/types.d.ts +10 -0
  4. package/dist/modules/OpenData/index.d.ts +15 -2
  5. package/dist/modules/OpenData/index.js +307 -19
  6. package/dist/modules/OpenData/types.d.ts +55 -0
  7. package/dist/modules/OpenData/types.js +7 -1
  8. package/dist/modules/OpenData/utils.d.ts +21 -1
  9. package/dist/modules/OpenData/utils.js +138 -0
  10. package/dist/modules/Order/index.d.ts +3 -1
  11. package/dist/modules/Order/index.js +69 -16
  12. package/dist/modules/Order/types.d.ts +13 -0
  13. package/dist/modules/Order/utils.d.ts +4 -1
  14. package/dist/modules/Order/utils.js +57 -3
  15. package/dist/plugins/request.d.ts +2 -1
  16. package/dist/plugins/request.js +4 -2
  17. package/dist/server/index.d.ts +14 -0
  18. package/dist/server/index.js +1732 -1285
  19. package/dist/server/modules/order/types.d.ts +50 -0
  20. package/dist/server/modules/order/types.js +2 -0
  21. package/dist/server/utils/small-ticket.d.ts +4 -1
  22. package/dist/server/utils/small-ticket.js +461 -96
  23. package/dist/solution/BaseSales/index.d.ts +5 -1
  24. package/dist/solution/BaseSales/index.js +120 -45
  25. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +2 -0
  26. package/dist/solution/BaseSales/utils/parseSalesResponse.js +1 -1
  27. package/dist/solution/BookingByStep/index.d.ts +1 -1
  28. package/dist/solution/BookingTicket/index.d.ts +8 -3
  29. package/dist/solution/BookingTicket/index.js +558 -443
  30. package/dist/solution/Sales/index.d.ts +16 -1
  31. package/dist/solution/Sales/index.js +338 -63
  32. package/dist/solution/Sales/types.d.ts +10 -0
  33. package/dist/solution/UnifiedBookingSales/index.d.ts +5 -4
  34. package/dist/solution/UnifiedBookingSales/index.js +526 -447
  35. package/dist/solution/UnifiedBookingSales/types.d.ts +7 -1
  36. package/lib/modules/Discount/index.js +4 -1
  37. package/lib/modules/Discount/types.d.ts +10 -0
  38. package/lib/modules/OpenData/index.d.ts +15 -2
  39. package/lib/modules/OpenData/index.js +230 -3
  40. package/lib/modules/OpenData/types.d.ts +55 -0
  41. package/lib/modules/OpenData/types.js +9 -1
  42. package/lib/modules/OpenData/utils.d.ts +21 -1
  43. package/lib/modules/OpenData/utils.js +126 -0
  44. package/lib/modules/Order/index.d.ts +3 -1
  45. package/lib/modules/Order/index.js +52 -1
  46. package/lib/modules/Order/types.d.ts +13 -0
  47. package/lib/modules/Order/utils.d.ts +4 -1
  48. package/lib/modules/Order/utils.js +58 -1
  49. package/lib/plugins/request.d.ts +2 -1
  50. package/lib/plugins/request.js +3 -2
  51. package/lib/server/index.d.ts +14 -0
  52. package/lib/server/index.js +453 -105
  53. package/lib/server/modules/order/types.d.ts +50 -0
  54. package/lib/server/modules/order/types.js +1 -0
  55. package/lib/server/utils/small-ticket.d.ts +4 -1
  56. package/lib/server/utils/small-ticket.js +427 -72
  57. package/lib/solution/BaseSales/index.d.ts +5 -1
  58. package/lib/solution/BaseSales/index.js +84 -7
  59. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +2 -0
  60. package/lib/solution/BaseSales/utils/parseSalesResponse.js +1 -1
  61. package/lib/solution/BookingByStep/index.d.ts +1 -1
  62. package/lib/solution/BookingTicket/index.d.ts +8 -3
  63. package/lib/solution/BookingTicket/index.js +60 -15
  64. package/lib/solution/Sales/index.d.ts +16 -1
  65. package/lib/solution/Sales/index.js +168 -1
  66. package/lib/solution/Sales/types.d.ts +10 -0
  67. package/lib/solution/UnifiedBookingSales/index.d.ts +5 -4
  68. package/lib/solution/UnifiedBookingSales/index.js +44 -15
  69. package/lib/solution/UnifiedBookingSales/types.d.ts +7 -1
  70. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import type { Module, ModuleOptions, PisellCore } from '../../types';
2
2
  import type { ProductData } from '../../modules';
3
- import type { OpenDataConfig } from '../../modules/OpenData';
3
+ import { type InvoiceLayoutConfig, type InvoiceTemplateSettings, type OpenDataConfig } from '../../modules/OpenData';
4
4
  import type { LoadScheduleAvailableDateParams, ScheduleItem } from '../../modules/Schedule/types';
5
5
  import type { ProductListLoadProductsParams, ProductListStoreQueryParams } from '../../modules/ProductList';
6
6
  import type { AvailabilityDateRange, AvailabilityOccupancy, AvailabilityProduct, AvailabilityResource, GetProductTimeRangesRequest } from '../../modules/ResourcePlanner';
@@ -60,9 +60,6 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
60
60
  protected defaultVersion: string;
61
61
  protected store: UnifiedBookingSalesState;
62
62
  private unifiedProductCatalog;
63
- private openDataTarget;
64
- private loadOpenDataInFlight;
65
- private loadOpenDataInFlightTarget;
66
63
  private availabilityRuntimeOffsetMinutes;
67
64
  private availabilityScheduleCatalog;
68
65
  private availabilityProjectionSequence;
@@ -159,6 +156,10 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
159
156
  * 只返回优先级最高 Action 中当前商品 Target 的 dataSource,不跨商品或 Action 合并。
160
157
  */
161
158
  resolveProductAllergyRequirement(params: UnifiedBookingSalesResolveProductAllergyRequirementParams): Promise<AllergyRequirement | null>;
159
+ clearOpenDataCache(): void;
160
+ getInvoiceLayoutConfig(): Promise<InvoiceLayoutConfig>;
161
+ getInvoiceTemplateSettings(): Promise<InvoiceTemplateSettings>;
162
+ protected isInvoiceOpenDataCacheCurrent(): boolean;
162
163
  /**
163
164
  * Load a resource policy without depending on the legacy appointmentBooking solution.
164
165
  */
@@ -33,6 +33,7 @@ var _dayjs = _interopRequireDefault(require("dayjs"));
33
33
  var _lodashEs = require("lodash-es");
34
34
  var _modules = require("../../modules");
35
35
  var _utils = require("../../modules/BookingContext/utils");
36
+ var _OpenData = require("../../modules/OpenData");
36
37
  var _getDateIsInSchedule = require("../../modules/Schedule/getDateIsInSchedule");
37
38
  var _ResourcePlanner = require("../../modules/ResourcePlanner");
38
39
  var _types = require("./types");
@@ -53,7 +54,7 @@ var _localClock = require("../../modules/ResourcePlanner/localClock");
53
54
  var _platform = require("../../utils/platform");
54
55
  var _itemRule = require("../../model/strategy/adapter/itemRule");
55
56
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
56
- const OPEN_DATA_SECTION_CODES = ['sale', 'reservation', 'fulfillment', 'menu', 'workflow', 'basic', 'checkout', 'availability'];
57
+ const OPEN_DATA_SECTION_CODES = ['sale', 'reservation', 'fulfillment', 'menu', 'workflow', 'documents', 'basic', 'checkout', 'availability'];
57
58
  const OPEN_DATA_CACHE_TTL = 5 * 60 * 1000;
58
59
  function normalizePositiveInteger(value) {
59
60
  const normalized = Number(value);
@@ -1199,9 +1200,6 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
1199
1200
  defaultVersion = '1.0.0';
1200
1201
  store = {};
1201
1202
  unifiedProductCatalog = [];
1202
- openDataTarget = null;
1203
- loadOpenDataInFlight = null;
1204
- loadOpenDataInFlightTarget = null;
1205
1203
  availabilityRuntimeOffsetMinutes = null;
1206
1204
  availabilityScheduleCatalog = null;
1207
1205
  availabilityProjectionSequence = 0;
@@ -1705,6 +1703,9 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
1705
1703
  const cachedData = this.store.openData.getOpenData();
1706
1704
  const lastFetchedAt = this.store.openData.getLastFetchedAt();
1707
1705
  if (!params.force && this.openDataTarget === target && cachedData && lastFetchedAt && Date.now() - lastFetchedAt < OPEN_DATA_CACHE_TTL) {
1706
+ if (typeof this.store.openData.ensureInvoiceTemplateSettings === 'function') {
1707
+ await this.store.openData.ensureInvoiceTemplateSettings(target);
1708
+ }
1708
1709
  return cachedData;
1709
1710
  }
1710
1711
  if (this.loadOpenDataInFlight) {
@@ -1715,30 +1716,32 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
1715
1716
  return this.loadOpenData(params);
1716
1717
  }
1717
1718
  this.loadOpenDataInFlightTarget = target;
1718
- this.loadOpenDataInFlight = this.store.openData.fetchOpenData({
1719
+ const request = this.store.openData.fetchOpenData({
1719
1720
  scope: 'board',
1720
1721
  target,
1721
1722
  section_code: [...OPEN_DATA_SECTION_CODES]
1722
1723
  });
1724
+ this.loadOpenDataInFlight = request;
1723
1725
  try {
1724
- const openData = await this.loadOpenDataInFlight;
1725
- this.openDataTarget = target;
1726
- this.otherParams.openData = openData;
1727
- this.otherParams.businessCode = businessCode;
1728
- this.otherParams.channel = channel;
1726
+ const openData = await request;
1727
+ if (this.loadOpenDataInFlight === request) {
1728
+ this.openDataTarget = target;
1729
+ this.otherParams.openData = openData;
1730
+ this.otherParams.businessCode = businessCode;
1731
+ this.otherParams.channel = channel;
1732
+ }
1729
1733
  return openData;
1730
1734
  } finally {
1731
- this.loadOpenDataInFlight = null;
1732
- this.loadOpenDataInFlightTarget = null;
1735
+ if (this.loadOpenDataInFlight === request) {
1736
+ this.loadOpenDataInFlight = null;
1737
+ this.loadOpenDataInFlightTarget = null;
1738
+ }
1733
1739
  }
1734
1740
  }
1735
1741
  async getOpenData() {
1736
1742
  const businessCode = String(this.otherParams?.businessCode || '').trim();
1737
1743
  const channel = String(this.otherParams?.channel || '').trim();
1738
1744
  if (!businessCode || !channel) return null;
1739
- const target = `${businessCode}+${channel}`;
1740
- const cachedData = this.store.openData?.getOpenData() || null;
1741
- if (cachedData && this.openDataTarget === target) return cachedData;
1742
1745
  return this.loadOpenData({
1743
1746
  businessCode,
1744
1747
  channel
@@ -1836,6 +1839,32 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
1836
1839
  custom: runtimeConfig.custom
1837
1840
  });
1838
1841
  }
1842
+ clearOpenDataCache() {
1843
+ this.openDataTarget = null;
1844
+ this.loadOpenDataInFlight = null;
1845
+ this.loadOpenDataInFlightTarget = null;
1846
+ super.clearOpenDataCache();
1847
+ }
1848
+ async getInvoiceLayoutConfig() {
1849
+ const openData = await this.getOpenData();
1850
+ if (!openData || !this.store.openData) {
1851
+ return (0, _OpenData.getDefaultInvoiceLayoutConfig)();
1852
+ }
1853
+ return this.store.openData.getInvoiceLayoutConfig();
1854
+ }
1855
+ async getInvoiceTemplateSettings() {
1856
+ const openData = await this.getOpenData();
1857
+ if (!openData || !this.store.openData) {
1858
+ return (0, _OpenData.getDefaultInvoiceTemplateSettings)();
1859
+ }
1860
+ return this.store.openData.getInvoiceTemplateSettings();
1861
+ }
1862
+ isInvoiceOpenDataCacheCurrent() {
1863
+ const businessCode = String(this.otherParams?.businessCode || '').trim();
1864
+ const channel = String(this.otherParams?.channel || '').trim();
1865
+ if (!businessCode || !channel) return false;
1866
+ return this.openDataTarget === `${businessCode}+${channel}`;
1867
+ }
1839
1868
 
1840
1869
  /**
1841
1870
  * Load a resource policy without depending on the legacy appointmentBooking solution.
@@ -1,4 +1,4 @@
1
- import type { OpenDataConfig } from '../../modules/OpenData';
1
+ import type { InvoiceLayoutConfig, InvoiceTemplateSettings, OpenDataConfig } from '../../modules/OpenData';
2
2
  import type { ProductListLoadProductsParams, ProductListStoreQueryParams } from '../../modules/ProductList';
3
3
  import type { ProductData } from '../../modules/Product/types';
4
4
  import type { LoadScheduleAvailableDateParams } from '../../modules/Schedule/types';
@@ -217,7 +217,13 @@ export interface UnifiedBookingSalesDiscountResult {
217
217
  }
218
218
  export interface UnifiedBookingSalesApi {
219
219
  loadOpenData: (params: UnifiedBookingSalesLoadOpenDataParams) => Promise<OpenDataConfig>;
220
+ /** Returns the latest OpenData payload cached by this solution instance. */
220
221
  getOpenData: () => Promise<OpenDataConfig | null>;
222
+ /** Returns the normalized Documents Invoice layout for the active target. */
223
+ getInvoiceLayoutConfig: () => Promise<InvoiceLayoutConfig>;
224
+ /** Returns the Native Invoice template settings for the active target. */
225
+ getInvoiceTemplateSettings: () => Promise<InvoiceTemplateSettings>;
226
+ /** Date-first calendar availability backed by ScheduleModule. */
221
227
  loadScheduleAvailableDate: (params: LoadScheduleAvailableDateParams) => Promise<unknown>;
222
228
  loadProductsByScheduleDate: (params: UnifiedBookingSalesLoadProductsByScheduleDateParams) => Promise<unknown[]>;
223
229
  queryProducts: (params?: ProductListStoreQueryParams) => Promise<ProductData[]>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.3.106",
4
+ "version": "2.3.107",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",