@pisell/pisellos 2.3.129 → 2.3.131

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 (102) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.js +3 -1
  3. package/dist/modules/BusinessAvailability/index.d.ts +30 -0
  4. package/dist/modules/BusinessAvailability/index.js +204 -0
  5. package/dist/modules/FulfillmentTiming/index.d.ts +11 -0
  6. package/dist/modules/FulfillmentTiming/index.js +407 -0
  7. package/dist/modules/FulfillmentTiming/types.d.ts +67 -0
  8. package/dist/modules/FulfillmentTiming/types.js +1 -0
  9. package/dist/modules/OpenData/types.d.ts +8 -0
  10. package/dist/modules/Order/index.d.ts +11 -2
  11. package/dist/modules/Order/index.js +370 -253
  12. package/dist/modules/Order/pickupTiming.d.ts +46 -0
  13. package/dist/modules/Order/pickupTiming.js +53 -0
  14. package/dist/modules/Order/types.d.ts +13 -1
  15. package/dist/modules/Order/utils.js +16 -6
  16. package/dist/modules/Payment/index.js +9 -10
  17. package/dist/modules/Schedule/index.d.ts +8 -0
  18. package/dist/modules/Schedule/index.js +141 -39
  19. package/dist/modules/index.d.ts +1 -0
  20. package/dist/modules/index.js +1 -0
  21. package/dist/plugins/request.d.ts +7 -0
  22. package/dist/server/utils/small-ticket.d.ts +1 -85
  23. package/dist/server/utils/small-ticket.js +2 -2542
  24. package/dist/shared/payment/loadPaymentMethods.d.ts +9 -0
  25. package/dist/shared/payment/loadPaymentMethods.js +66 -0
  26. package/dist/shared/receipt/loadCustomerInvoiceLayout.d.ts +22 -0
  27. package/dist/shared/receipt/loadCustomerInvoiceLayout.js +142 -0
  28. package/dist/shared/receipt/small-ticket.d.ts +85 -0
  29. package/dist/shared/receipt/small-ticket.js +2576 -0
  30. package/dist/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
  31. package/dist/shared/sales/loadSalesOrderSnapshot.js +21 -0
  32. package/dist/solution/BaseSales/index.d.ts +28 -15
  33. package/dist/solution/BaseSales/index.js +1346 -1101
  34. package/dist/solution/BaseSales/pickupTiming.d.ts +43 -0
  35. package/dist/solution/BaseSales/pickupTiming.js +589 -0
  36. package/dist/solution/BaseSales/types.d.ts +11 -0
  37. package/dist/solution/BaseSales/utils/parseSalesResponse.js +3 -0
  38. package/dist/solution/BookingByStep/index.d.ts +1 -1
  39. package/dist/solution/BookingTicket/index.d.ts +2 -2
  40. package/dist/solution/BookingTicket/index.js +41 -13
  41. package/dist/solution/BookingTicket/utils/cartView.js +3 -1
  42. package/dist/solution/OrderInvoicePreview/index.d.ts +56 -0
  43. package/dist/solution/OrderInvoicePreview/index.js +269 -0
  44. package/dist/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
  45. package/dist/solution/UnifiedBookingSales/businessAvailability.js +292 -0
  46. package/dist/solution/UnifiedBookingSales/index.d.ts +24 -4
  47. package/dist/solution/UnifiedBookingSales/index.js +953 -709
  48. package/dist/solution/UnifiedBookingSales/types.d.ts +2 -0
  49. package/dist/solution/index.d.ts +1 -0
  50. package/dist/solution/index.js +2 -1
  51. package/lib/index.d.ts +2 -0
  52. package/lib/index.js +21 -1
  53. package/lib/model/strategy/adapter/promotion/index.js +46 -1
  54. package/lib/modules/BusinessAvailability/index.d.ts +30 -0
  55. package/lib/modules/BusinessAvailability/index.js +146 -0
  56. package/lib/modules/FulfillmentTiming/index.d.ts +11 -0
  57. package/lib/modules/FulfillmentTiming/index.js +359 -0
  58. package/lib/modules/FulfillmentTiming/types.d.ts +67 -0
  59. package/lib/modules/FulfillmentTiming/types.js +5 -0
  60. package/lib/modules/OpenData/types.d.ts +8 -0
  61. package/lib/modules/Order/index.d.ts +11 -2
  62. package/lib/modules/Order/index.js +101 -14
  63. package/lib/modules/Order/pickupTiming.d.ts +46 -0
  64. package/lib/modules/Order/pickupTiming.js +61 -0
  65. package/lib/modules/Order/types.d.ts +13 -1
  66. package/lib/modules/Order/utils.js +12 -4
  67. package/lib/modules/Payment/index.js +3 -4
  68. package/lib/modules/Schedule/index.d.ts +8 -0
  69. package/lib/modules/Schedule/index.js +68 -12
  70. package/lib/modules/index.d.ts +1 -0
  71. package/lib/modules/index.js +11 -0
  72. package/lib/plugins/request.d.ts +7 -0
  73. package/lib/server/utils/small-ticket.d.ts +1 -85
  74. package/lib/server/utils/small-ticket.js +9 -2305
  75. package/lib/shared/payment/loadPaymentMethods.d.ts +9 -0
  76. package/lib/shared/payment/loadPaymentMethods.js +40 -0
  77. package/lib/shared/receipt/loadCustomerInvoiceLayout.d.ts +22 -0
  78. package/lib/shared/receipt/loadCustomerInvoiceLayout.js +86 -0
  79. package/lib/shared/receipt/small-ticket.d.ts +85 -0
  80. package/lib/shared/receipt/small-ticket.js +2342 -0
  81. package/lib/shared/sales/loadSalesOrderSnapshot.d.ts +9 -0
  82. package/lib/shared/sales/loadSalesOrderSnapshot.js +22 -0
  83. package/lib/solution/BaseSales/index.d.ts +28 -15
  84. package/lib/solution/BaseSales/index.js +161 -25
  85. package/lib/solution/BaseSales/pickupTiming.d.ts +43 -0
  86. package/lib/solution/BaseSales/pickupTiming.js +269 -0
  87. package/lib/solution/BaseSales/types.d.ts +11 -0
  88. package/lib/solution/BaseSales/utils/parseSalesResponse.js +3 -0
  89. package/lib/solution/BookingByStep/index.d.ts +1 -1
  90. package/lib/solution/BookingTicket/index.d.ts +2 -2
  91. package/lib/solution/BookingTicket/index.js +37 -4
  92. package/lib/solution/BookingTicket/utils/cartView.js +3 -1
  93. package/lib/solution/OrderInvoicePreview/index.d.ts +56 -0
  94. package/lib/solution/OrderInvoicePreview/index.js +192 -0
  95. package/lib/solution/UnifiedBookingSales/businessAvailability.d.ts +27 -0
  96. package/lib/solution/UnifiedBookingSales/businessAvailability.js +138 -0
  97. package/lib/solution/UnifiedBookingSales/index.d.ts +24 -4
  98. package/lib/solution/UnifiedBookingSales/index.js +184 -46
  99. package/lib/solution/UnifiedBookingSales/types.d.ts +2 -0
  100. package/lib/solution/index.d.ts +1 -0
  101. package/lib/solution/index.js +11 -0
  102. package/package.json +1 -1
@@ -9,6 +9,7 @@ var _exportNames = {
9
9
  };
10
10
  exports.PaymentModule = void 0;
11
11
  exports.generateRequestUniqueId = generateRequestUniqueId;
12
+ var _loadPaymentMethods = require("../../shared/payment/loadPaymentMethods");
12
13
  var _BaseModule = require("../BaseModule");
13
14
  var _types = require("./types");
14
15
  Object.keys(_types).forEach(function (key) {
@@ -282,12 +283,10 @@ class PaymentModule extends _BaseModule.BaseModule {
282
283
  async getPayMethodListAsync() {
283
284
  this.logInfo('Starting getPayMethodListAsync');
284
285
  try {
285
- const response = await this.request.get('/pay/custom-payment/all', {
286
+ const payMethods = await (0, _loadPaymentMethods.loadPaymentMethods)(this.request, {
287
+ transport: 'os-server',
286
288
  filterPaymentMethods: true
287
- }, {
288
- osServer: true
289
289
  });
290
- const payMethods = response?.data || response || [];
291
290
  this.logInfo('getPayMethodListAsync completed successfully', {
292
291
  payMethods
293
292
  });
@@ -10,6 +10,10 @@ export declare class ScheduleModule extends BaseModule implements Module, Schedu
10
10
  private openCache;
11
11
  private fatherModule;
12
12
  private hasLoadedScheduleList;
13
+ private scheduleListPromise;
14
+ private scheduleListRequestVersion;
15
+ private scheduleCatalogScope;
16
+ private otherParams;
13
17
  constructor(name?: string, version?: string);
14
18
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
15
19
  /**
@@ -19,6 +23,9 @@ export declare class ScheduleModule extends BaseModule implements Module, Schedu
19
23
  * scheduleModule.updateOtherParams({ openCache: true, cacheId: 'cache-2' });
20
24
  */
21
25
  updateOtherParams(params: Record<string, any>): void;
26
+ private syncScheduleCatalogScope;
27
+ private resetScheduleCatalog;
28
+ destroy(): void;
22
29
  /**
23
30
  * 加载当前店铺下所有 schedule
24
31
  *
@@ -27,6 +34,7 @@ export declare class ScheduleModule extends BaseModule implements Module, Schedu
27
34
  loadAllSchedule(options?: {
28
35
  useCache?: boolean;
29
36
  }): Promise<void>;
37
+ private loadScheduleCatalog;
30
38
  setScheduleList(list: ScheduleItem[]): void;
31
39
  private syncScheduleMap;
32
40
  getScheduleList(): ScheduleItem[];
@@ -24,10 +24,18 @@ class ScheduleModule extends _BaseModule.BaseModule {
24
24
  openCache = false;
25
25
  fatherModule;
26
26
  hasLoadedScheduleList = false;
27
+ scheduleListPromise = null;
28
+ scheduleListRequestVersion = 0;
29
+ scheduleCatalogScope = '';
30
+ otherParams = {};
27
31
  constructor(name, version) {
28
32
  super(name, version);
29
33
  }
30
34
  async initialize(core, options) {
35
+ // The store proxies initialState, so capture its input before resets write through it.
36
+ const initialScheduleList = options.initialState?.scheduleList;
37
+ const hasInitialScheduleList = Array.isArray(initialScheduleList);
38
+ this.resetScheduleCatalog();
31
39
  this.core = core;
32
40
 
33
41
  // 获取依赖的插件
@@ -40,24 +48,18 @@ class ScheduleModule extends _BaseModule.BaseModule {
40
48
  // this.state = { ...this.state, ...options.initialState }
41
49
  // }
42
50
  this.store = options?.store;
51
+ this.updateOtherParams(options.otherParams || {});
43
52
  if (options.initialState) {
44
- this.store.scheduleList = options.initialState.scheduleList;
53
+ this.store.scheduleList = hasInitialScheduleList ? initialScheduleList : [];
45
54
  this.syncScheduleMap();
46
55
  this.store.availabilityDateList = options.initialState.availabilityDateList;
47
- this.hasLoadedScheduleList = Array.isArray(options.initialState.scheduleList);
56
+ this.hasLoadedScheduleList = hasInitialScheduleList;
48
57
  } else {
49
58
  this.store.scheduleList = [];
50
59
  this.store.map = new Map();
51
60
  this.store.availabilityDateList = [];
52
61
  this.hasLoadedScheduleList = false;
53
62
  }
54
- if (options.otherParams?.cacheId) {
55
- this.openCache = options.otherParams.openCache;
56
- this.cacheId = options.otherParams.cacheId;
57
- }
58
- if (options.otherParams?.fatherModule) {
59
- this.fatherModule = options.otherParams.fatherModule;
60
- }
61
63
  }
62
64
 
63
65
  /**
@@ -68,9 +70,34 @@ class ScheduleModule extends _BaseModule.BaseModule {
68
70
  */
69
71
  updateOtherParams(params) {
70
72
  const otherParams = params || {};
73
+ this.otherParams = {
74
+ ...otherParams
75
+ };
71
76
  this.openCache = otherParams.openCache ?? false;
72
77
  this.cacheId = otherParams.cacheId;
73
78
  this.fatherModule = otherParams.fatherModule;
79
+ this.syncScheduleCatalogScope();
80
+ }
81
+ syncScheduleCatalogScope() {
82
+ const context = this.core?.context;
83
+ const shopId = typeof context?.getData === 'function' ? context.getData('shop_id') : context?.shop_id;
84
+ const params = this.otherParams;
85
+ const scope = JSON.stringify([this.cacheId, this.fatherModule, params.businessCode ?? params.business_code, params.channel, params.platform, params.businessTimezone, shopId].map(value => String(value ?? '').trim()));
86
+ if (scope !== this.scheduleCatalogScope) {
87
+ this.resetScheduleCatalog();
88
+ this.scheduleCatalogScope = scope;
89
+ }
90
+ }
91
+ resetScheduleCatalog() {
92
+ this.scheduleListRequestVersion += 1;
93
+ this.scheduleListPromise = null;
94
+ this.hasLoadedScheduleList = false;
95
+ this.store.scheduleList = [];
96
+ this.store.map = new Map();
97
+ }
98
+ destroy() {
99
+ this.resetScheduleCatalog();
100
+ super.destroy();
74
101
  }
75
102
 
76
103
  /**
@@ -79,14 +106,40 @@ class ScheduleModule extends _BaseModule.BaseModule {
79
106
  * @memberof ScheduleModule
80
107
  */
81
108
  async loadAllSchedule(options = {}) {
82
- const scheduleList = await this.request.get(`/schedule`, {
109
+ this.syncScheduleCatalogScope();
110
+ const useCache = options.useCache ?? true;
111
+ if (useCache) {
112
+ if (this.scheduleListPromise) return this.scheduleListPromise;
113
+ if (this.hasLoadedScheduleList) return;
114
+ }
115
+ const requestVersion = ++this.scheduleListRequestVersion;
116
+ const promise = this.loadScheduleCatalog(useCache, requestVersion);
117
+ this.scheduleListPromise = promise;
118
+ try {
119
+ await promise;
120
+ } finally {
121
+ if (this.scheduleListPromise === promise) {
122
+ this.scheduleListPromise = null;
123
+ }
124
+ }
125
+ }
126
+ async loadScheduleCatalog(useCache, requestVersion) {
127
+ const response = await this.request.get(`/schedule`, {
83
128
  num: 999
84
129
  }, {
85
- useCache: options.useCache ?? true
130
+ useCache
86
131
  });
87
- this.setScheduleList(scheduleList.data?.list || []);
132
+ if (response.code !== undefined && Number(response.code) !== 200 || response.status === false || typeof response.status === 'number' && response.status >= 400 || response.success === false) {
133
+ throw new Error(response.message || 'Schedule catalog request failed');
134
+ }
135
+ this.syncScheduleCatalogScope();
136
+ // A refresh or a different runtime may have superseded this request.
137
+ if (requestVersion === this.scheduleListRequestVersion) {
138
+ this.setScheduleList(response.data?.list || []);
139
+ }
88
140
  }
89
141
  setScheduleList(list) {
142
+ this.syncScheduleCatalogScope();
90
143
  this.store.scheduleList = list;
91
144
  this.syncScheduleMap();
92
145
  this.hasLoadedScheduleList = true;
@@ -95,9 +148,11 @@ class ScheduleModule extends _BaseModule.BaseModule {
95
148
  this.store.map = new Map((this.store.scheduleList || []).map(schedule => [Number(schedule.id), schedule]));
96
149
  }
97
150
  getScheduleList() {
151
+ this.syncScheduleCatalogScope();
98
152
  return this.store.scheduleList || [];
99
153
  }
100
154
  isScheduleListLoaded() {
155
+ this.syncScheduleCatalogScope();
101
156
  return this.hasLoadedScheduleList;
102
157
  }
103
158
  async loadScheduleAvailableDate({
@@ -149,6 +204,7 @@ class ScheduleModule extends _BaseModule.BaseModule {
149
204
  return dates;
150
205
  }
151
206
  getScheduleListByIds(ids) {
207
+ this.syncScheduleCatalogScope();
152
208
  const idSet = new Set(ids.map(id => String(id)));
153
209
  if (this.store.map instanceof Map && this.store.map.size > 0) {
154
210
  return ids.map(id => this.store.map.get(Number(id))).filter(Boolean);
@@ -17,6 +17,7 @@ export * from './Schedule';
17
17
  export * from './Quotation';
18
18
  export * from './ScanOrderLogger';
19
19
  export * from './OpenData';
20
+ export * from './FulfillmentTiming';
20
21
  export * from './BookingContext';
21
22
  export * from './Holder';
22
23
  export * from './ResourcePlanner';
@@ -212,6 +212,17 @@ Object.keys(_OpenData).forEach(function (key) {
212
212
  }
213
213
  });
214
214
  });
215
+ var _FulfillmentTiming = require("./FulfillmentTiming");
216
+ Object.keys(_FulfillmentTiming).forEach(function (key) {
217
+ if (key === "default" || key === "__esModule") return;
218
+ if (key in exports && exports[key] === _FulfillmentTiming[key]) return;
219
+ Object.defineProperty(exports, key, {
220
+ enumerable: true,
221
+ get: function () {
222
+ return _FulfillmentTiming[key];
223
+ }
224
+ });
225
+ });
215
226
  var _BookingContext = require("./BookingContext");
216
227
  Object.keys(_BookingContext).forEach(function (key) {
217
228
  if (key === "default" || key === "__esModule") return;
@@ -56,6 +56,13 @@ export interface CacheProps {
56
56
  * 请求配置
57
57
  */
58
58
  export interface RequestOptions {
59
+ /** Customer-only, credential-free GET /open/document/{id} on picoding. */
60
+ publicInvoiceDocument?: boolean;
61
+ /** Route through the host's configured picoding environment. */
62
+ pisell2?: boolean;
63
+ /** Let the caller handle read-only preview failures without host navigation/toasts. */
64
+ manualErrorHandling?: boolean;
65
+ skipErrorHandler?: boolean;
59
66
  url?: string;
60
67
  method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
61
68
  headers?: Record<string, string>;
@@ -1,85 +1 @@
1
- export interface SmallTicketShopInfo {
2
- name?: string;
3
- phone?: string;
4
- address?: string;
5
- address_street?: string;
6
- address_detail?: string;
7
- city?: string;
8
- province?: string;
9
- country?: string;
10
- zip?: string;
11
- tax_number?: string;
12
- tax_title?: string;
13
- is_price_include_tax?: 0 | 1 | boolean;
14
- currency_symbol?: string;
15
- currency_code?: string;
16
- primary_locale?: string;
17
- timezone?: string;
18
- [key: string]: any;
19
- }
20
- export interface BuildSmallTicketDataParams {
21
- order: Record<string, any>;
22
- shopInfo?: SmallTicketShopInfo | null;
23
- locales?: string[];
24
- productMap?: Record<string | number, Record<string, any>>;
25
- }
26
- export interface SmallTicketItem {
27
- item: string;
28
- value: string;
29
- size?: number;
30
- align?: string;
31
- product_uid?: string | number;
32
- booking_uid?: string | number;
33
- }
34
- export interface SmallTicketProduct {
35
- product_title: string;
36
- product_quantity: number;
37
- selling_price: string;
38
- total_selling_price: string;
39
- original_price: string;
40
- base_price?: string;
41
- total_original_price: string;
42
- options_total_price?: string;
43
- package_items_total_price?: string;
44
- extension_list: any[];
45
- product_uid?: string | number;
46
- booking_uid?: string | number;
47
- product_note?: string;
48
- allergy?: string;
49
- options?: Array<{
50
- name: string;
51
- num?: number;
52
- price?: string;
53
- total_price: string;
54
- value?: string;
55
- }>;
56
- variant?: string;
57
- combinations?: any[];
58
- }
59
- export type SmallTicketAppointment = SmallTicketItem[];
60
- export interface SmallTicketLocaleData {
61
- base_data: Record<string, any>;
62
- products: SmallTicketProduct[];
63
- fees: {
64
- fees: SmallTicketItem[];
65
- countFee: Record<string, any>;
66
- };
67
- customer: SmallTicketItem[];
68
- appointment: SmallTicketAppointment;
69
- delivery?: SmallTicketItem[];
70
- resources: Array<{
71
- id: string | number;
72
- code: string;
73
- title: string;
74
- form_title: string;
75
- }>;
76
- payment_data: SmallTicketItem[][];
77
- wallets: SmallTicketItem[][];
78
- tickets: any[];
79
- source_shop: any[];
80
- refund_data: SmallTicketItem[][];
81
- expend_data: any[];
82
- }
83
- export type SmallTicketData = Record<string, SmallTicketLocaleData>;
84
- export declare function buildSmallTicketData(params: BuildSmallTicketDataParams): SmallTicketData;
85
- export declare function hasSmallTicketData(value: any): boolean;
1
+ export * from '../../shared/receipt/small-ticket';