@pisell/pisellos 0.10.9 → 0.10.11

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 (49) hide show
  1. package/dist/modules/OpenData/types.d.ts +1 -0
  2. package/dist/modules/Order/index.d.ts +2 -0
  3. package/dist/modules/Order/index.js +60 -47
  4. package/dist/modules/Order/types.d.ts +5 -2
  5. package/dist/modules/Order/utils.d.ts +1 -0
  6. package/dist/modules/Order/utils.js +7 -4
  7. package/dist/modules/ResourcePlanner/index.d.ts +0 -22
  8. package/dist/modules/ResourcePlanner/index.js +1 -180
  9. package/dist/modules/ResourcePlanner/localClock.d.ts +33 -0
  10. package/dist/modules/ResourcePlanner/localClock.js +183 -0
  11. package/dist/modules/ResourcePlanner/planner.d.ts +5 -14
  12. package/dist/modules/ResourcePlanner/planner.js +2019 -936
  13. package/dist/modules/ResourcePlanner/types.d.ts +346 -187
  14. package/dist/modules/ResourcePlanner/types.js +33 -1
  15. package/dist/solution/BaseSales/index.js +32 -9
  16. package/dist/solution/BookingTicket/index.js +4 -2
  17. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
  18. package/dist/solution/BookingTicket/utils/addProductDecision.js +3 -2
  19. package/dist/solution/UnifiedBookingSales/index.d.ts +110 -73
  20. package/dist/solution/UnifiedBookingSales/index.js +3349 -971
  21. package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +49 -0
  22. package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.js +430 -0
  23. package/dist/solution/UnifiedBookingSales/types.d.ts +133 -76
  24. package/dist/solution/UnifiedBookingSales/types.js +4 -9
  25. package/lib/modules/OpenData/types.d.ts +1 -0
  26. package/lib/modules/Order/index.d.ts +2 -0
  27. package/lib/modules/Order/index.js +16 -5
  28. package/lib/modules/Order/types.d.ts +5 -2
  29. package/lib/modules/Order/utils.d.ts +1 -0
  30. package/lib/modules/Order/utils.js +2 -1
  31. package/lib/modules/ResourcePlanner/index.d.ts +0 -22
  32. package/lib/modules/ResourcePlanner/index.js +0 -123
  33. package/lib/modules/ResourcePlanner/localClock.d.ts +33 -0
  34. package/lib/modules/ResourcePlanner/localClock.js +270 -0
  35. package/lib/modules/ResourcePlanner/planner.d.ts +5 -14
  36. package/lib/modules/ResourcePlanner/planner.js +1903 -798
  37. package/lib/modules/ResourcePlanner/types.d.ts +346 -187
  38. package/lib/modules/ResourcePlanner/types.js +19 -0
  39. package/lib/solution/BaseSales/index.js +38 -22
  40. package/lib/solution/BookingTicket/index.js +2 -1
  41. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
  42. package/lib/solution/BookingTicket/utils/addProductDecision.js +2 -0
  43. package/lib/solution/UnifiedBookingSales/index.d.ts +110 -73
  44. package/lib/solution/UnifiedBookingSales/index.js +2289 -374
  45. package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +49 -0
  46. package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +376 -0
  47. package/lib/solution/UnifiedBookingSales/types.d.ts +133 -76
  48. package/lib/solution/UnifiedBookingSales/types.js +3 -2
  49. package/package.json +1 -1
@@ -1,91 +1,163 @@
1
- import type { ResourcePlannerModule } from '../../modules';
2
1
  import type { OpenDataConfig } from '../../modules/OpenData';
3
- import type { ResourcePlannerAssignment, ResourcePlannerAssignableSlotResult, ResourcePlannerContextInput, ResourcePlannerProjection, ResourcePlannerQuery, ResourcePlannerSelectionPatch, ResourcePlannerSnapshot, ResourcePlannerValidationResult } from '../../modules/ResourcePlanner';
4
2
  import type { ProductListLoadProductsParams } from '../../modules/ProductList';
5
3
  import type { LoadScheduleAvailableDateParams } from '../../modules/Schedule/types';
4
+ import type { AvailabilityDateRange, AvailabilityErrorCode, AvailabilityId, AvailabilityOccupancy, AvailabilityProduct, AvailabilityProjection, AvailabilityQuery, AvailabilityRequirementSelection, AvailabilityResource, AvailabilitySelectionValidationResult, DateAvailabilityQueryResult, GetProductTimeRangesRequest, ProductAvailabilityQueryResult, ProductTimeRange, ProductTimeRangeGroup, ResourceAvailabilityGroup, ResourceAvailabilityRangeGroup, TimeAvailabilityGroup, TimeAvailabilityItem } from '../../modules/ResourcePlanner';
6
5
  import type { BookingTicketState } from '../BookingTicket/types';
7
- export declare enum UnifiedBookingSalesHooks {
8
- onPlannerContextLoaded = "unifiedBookingSales:onPlannerContextLoaded",
9
- onPlannerCommitted = "unifiedBookingSales:onPlannerCommitted"
10
- }
6
+ export type { AvailabilityAbsoluteRange, AvailabilityAssignment, AvailabilityCell, AvailabilityDateRange, AvailabilityDisplayRange, AvailabilityErrorCode, AvailabilityId, AvailabilityMode, AvailabilityOccupancy, AvailabilityProduct, AvailabilityProductKind, AvailabilityProjection, AvailabilityProjectionInput, AvailabilityProjectionMeta, AvailabilityQuery, AvailabilityQueryResult, AvailabilityRequirementGroup, AvailabilityRequirementGroupResult, AvailabilityRequirementSelection, AvailabilityResource, AvailabilityResourceOption, AvailabilityResourceType, AvailabilityResourceWindow, AvailabilityScheduleMode, AvailabilityScheduleRef, AvailabilityScheduleRule, AvailabilitySelectionValidationParams, AvailabilitySelectionValidationResult, AvailabilitySessionRange, AvailabilityStatus, DateAvailabilityGroup, DateAvailabilityItem, DateAvailabilityQuery, DateAvailabilityQueryResult, GetProductTimeRangesRequest, ProductAvailabilityGroup, ProductAvailabilityItem, ProductAvailabilityQuery, ProductAvailabilityQueryResult, ProductTimeRange, ProductTimeRangeGroup, QueryAvailabilityBaseRequest, ResourceAvailabilityGroup, ResourceAvailabilityQuery, ResourceAvailabilityQueryResult, ResourceAvailabilityRangeGroup, TimeAvailabilityGroup, TimeAvailabilityItem, TimeAvailabilityQuery, TimeAvailabilityQueryResult, } from '../../modules/ResourcePlanner';
11
7
  export interface UnifiedBookingSalesState extends BookingTicketState {
12
- resourcePlanner: ResourcePlannerModule;
8
+ }
9
+ export declare enum UnifiedBookingSalesHooks {
10
+ onAvailabilityProjectionPrepared = "unifiedBookingSales:onAvailabilityProjectionPrepared",
11
+ onAvailabilitySelectionCommitted = "unifiedBookingSales:onAvailabilitySelectionCommitted",
12
+ onAvailabilityProjectionDiagnostic = "unifiedBookingSales:onAvailabilityProjectionDiagnostic"
13
13
  }
14
14
  export interface UnifiedBookingSalesOtherParams extends Record<string, any> {
15
- /**
16
- * Persist the active order workspace in sessionStorage, partitioned by cacheId.
17
- * Disabled by default and ignored when cacheId is missing.
18
- */
19
15
  enableSessionStoragePersist?: boolean;
20
16
  }
21
- /** Explicit OpenData target used by page-level UnifiedBookingSales skins. */
22
17
  export interface UnifiedBookingSalesLoadOpenDataParams {
23
18
  businessCode: string;
24
19
  channel: string;
25
- /** Bypasses the target-scoped in-memory cache. */
26
20
  force?: boolean;
27
21
  }
28
- export interface UnifiedBookingSalesLoadPlannerContextParams extends ResourcePlannerQuery {
29
- /** ProductList request options used only when products are not supplied as raw/context data. */
30
- productLoadParams?: ProductListLoadProductsParams;
31
- /** Escape hatch for tests or callers that already own raw ProductList records. */
32
- rawProducts?: Record<string, any>[];
33
- /** Escape hatch for tests or callers that already own raw resource records. */
34
- rawResources?: Record<string, any>[];
35
- /** Fully normalized Planner context; takes precedence over API loading for supplied fields. */
36
- context?: ResourcePlannerContextInput;
37
- /** Enables the v2 resource API + schedule materialization path. */
38
- useResourceDateApi?: boolean;
39
- }
40
- export interface UnifiedBookingSalesCommitPlannerSelectionParams {
41
- /** Optional selection patch applied before validation and order mutation. */
42
- selection?: ResourcePlannerSelectionPatch;
43
- /** Directly supplies selected resource/time facts, usually from resolveAssignableSlots(). */
44
- assignments?: ResourcePlannerAssignment[];
45
- /** Defaults to false. True performs the real BaseSales / OrderModule submit after tempOrder is written. */
46
- submitAfterCommit?: boolean;
47
- }
48
22
  export interface UnifiedBookingSalesLoadProductsByScheduleDateParams extends Omit<ProductListLoadProductsParams, 'schedule_date' | 'product_ids'> {
49
- /** The chosen calendar date, used for both availability lookup and ProductList schedule_date. */
50
23
  date: string;
51
- /** Optional caller-side filter applied after the availability result produces its product pool. */
52
24
  product_ids?: number[];
53
- /** Required by the availability API; this is not the low-code page id. */
54
25
  custom_page_id?: number;
55
- /** Availability API channel, commonly pc. ProductList keeps its own sales application channel. */
56
26
  channel?: string;
57
27
  }
58
- export interface UnifiedBookingSalesStagePlannerProductsParams {
59
- /** Products the customer selected before a time/resource booking exists. */
28
+ export type UnifiedBookingSalesCatalogScope = {
29
+ type: 'schedule';
30
+ customPageId: number;
31
+ channel: string;
32
+ } | {
33
+ type: 'productList';
34
+ params: ProductListLoadProductsParams;
35
+ };
36
+ export interface UnifiedBookingSalesPrepareAvailabilityProjectionParams {
37
+ productIds?: number[];
38
+ resourceIds?: AvailabilityId[];
39
+ dateRange?: Partial<AvailabilityDateRange>;
40
+ catalogScope?: UnifiedBookingSalesCatalogScope;
41
+ rawProducts?: Record<string, any>[];
42
+ rawResources?: Record<string, any>[];
43
+ rawOccupancies?: AvailabilityOccupancy[];
44
+ editingProductLineUids?: string[];
45
+ timezone?: string;
46
+ slotStepMinutes?: number;
47
+ businessHours?: {
48
+ startTime: string;
49
+ endTime: string;
50
+ };
51
+ mode?: 'appointment' | 'scan_order' | 'venue_grid';
52
+ }
53
+ export interface AvailabilityContextRef {
54
+ contextId: string;
55
+ }
56
+ export interface ContextualProductTimeRange extends ProductTimeRange {
57
+ availabilityContextId: string;
58
+ availabilityContextVersion: number;
59
+ }
60
+ export interface ContextualProductTimeRangeGroup extends Omit<ProductTimeRangeGroup, 'ranges'> {
61
+ ranges: ContextualProductTimeRange[];
62
+ }
63
+ export type ContextualAvailabilityQuery = Omit<Extract<AvailabilityQuery, {
64
+ target: 'product';
65
+ }>, never> | Omit<Extract<AvailabilityQuery, {
66
+ target: 'date';
67
+ }>, never> | (Omit<Extract<AvailabilityQuery, {
68
+ target: 'time';
69
+ }>, 'candidates'> & {
70
+ candidates: ContextualProductTimeRange[];
71
+ }) | (Omit<Extract<AvailabilityQuery, {
72
+ target: 'resource';
73
+ }>, 'selectedRanges'> & {
74
+ selectedRanges: ContextualProductTimeRange[];
75
+ });
76
+ export type ContextualTimeAvailabilityItem = Omit<TimeAvailabilityItem, keyof ProductTimeRange> & ContextualProductTimeRange;
77
+ export interface ContextualTimeAvailabilityGroup extends Omit<TimeAvailabilityGroup, 'times'> {
78
+ times: ContextualTimeAvailabilityItem[];
79
+ }
80
+ export interface ContextualResourceAvailabilityRangeGroup extends Omit<ResourceAvailabilityRangeGroup, 'range'> {
81
+ range: ContextualProductTimeRange;
82
+ }
83
+ export interface ContextualResourceAvailabilityGroup extends Omit<ResourceAvailabilityGroup, 'ranges'> {
84
+ ranges: ContextualResourceAvailabilityRangeGroup[];
85
+ }
86
+ type ContextualAvailabilityQueryResultMeta = {
87
+ contextId: string;
88
+ contextVersion: number;
89
+ refreshed: boolean;
90
+ };
91
+ export type ContextualAvailabilityQueryResult = (ProductAvailabilityQueryResult & ContextualAvailabilityQueryResultMeta) | (DateAvailabilityQueryResult & ContextualAvailabilityQueryResultMeta) | ({
92
+ target: 'time';
93
+ evaluatedAt: string;
94
+ snapshotId: string;
95
+ data: ContextualTimeAvailabilityGroup[];
96
+ } & ContextualAvailabilityQueryResultMeta) | ({
97
+ target: 'resource';
98
+ evaluatedAt: string;
99
+ snapshotId: string;
100
+ data: ContextualResourceAvailabilityGroup[];
101
+ } & ContextualAvailabilityQueryResultMeta);
102
+ export type UnifiedBookingSalesAvailabilityCandidate = ContextualProductTimeRange;
103
+ export type UnifiedBookingSalesProductTimeRangeGroup = ContextualProductTimeRangeGroup;
104
+ export type UnifiedBookingSalesAvailabilityQueryResult = ContextualAvailabilityQueryResult;
105
+ export interface UnifiedBookingSalesAvailabilityPreparedPayload {
106
+ context: AvailabilityContextRef;
107
+ contextVersion: number;
108
+ projection: AvailabilityProjection;
109
+ refreshed: boolean;
110
+ reason?: string;
111
+ previousOrderRevision?: AvailabilityId;
112
+ }
113
+ export interface UnifiedBookingSalesAvailabilityDiagnosticPayload {
114
+ contextId: string | null;
115
+ contextVersion: number | null;
116
+ reason: string;
117
+ projection: AvailabilityProjection | null;
118
+ action: 'prepare' | 'refresh' | 'release' | 'destroy' | 'set_other_params_reset' | 'commit_lock_wait' | 'commit_lock_acquired' | 'commit_lock_released';
119
+ snapshotId?: string;
120
+ orderRevision?: AvailabilityId;
121
+ previousOrderRevision?: AvailabilityId;
122
+ registrySize: number;
123
+ projectionPoolSize: number;
124
+ }
125
+ export interface UnifiedBookingSalesStageRetailProductsParams {
60
126
  productIds: Array<number | string>;
61
127
  productLoadParams?: ProductListLoadProductsParams;
62
128
  rawProducts?: Record<string, any>[];
63
129
  }
64
- /** Ordinary retail product staging. No resource, time, or booking facts are required. */
65
- export type UnifiedBookingSalesStageRetailProductsParams = UnifiedBookingSalesStagePlannerProductsParams;
66
- /** Adds one ordinary retail product without replacing other retail lines already in the cart. */
67
130
  export interface UnifiedBookingSalesAddRetailProductParams {
68
- /** Prefer a supplied catalog record when the UI has already loaded it. */
69
131
  product?: Record<string, any>;
70
- /** Used to resolve a product from the current catalog or load it on demand. */
71
132
  productId?: number | string;
72
- /** Defaults to one. */
73
133
  quantity?: number;
74
- /** Only used when the product is not already present in the solution catalog. */
75
134
  productLoadParams?: ProductListLoadProductsParams;
76
135
  }
77
- export interface UnifiedBookingSalesCommitResult {
136
+ export interface ContextualCommitAvailabilitySelectionParams {
137
+ mode: 'add' | 'edit';
138
+ productLineUid?: string;
139
+ orderProduct: Record<string, any>;
140
+ candidate: ContextualProductTimeRange;
141
+ requirementSelections: AvailabilityRequirementSelection[];
142
+ partySize: number;
143
+ bookingCount?: number;
144
+ }
145
+ export type UnifiedBookingSalesCommitAvailabilitySelectionParams = ContextualCommitAvailabilitySelectionParams;
146
+ export interface UnifiedBookingSalesCommitAvailabilitySelectionResult {
147
+ contextId: string;
148
+ contextVersion: number;
78
149
  tempOrder: Record<string, any> | null;
79
- assignments: ResourcePlannerAssignment[];
80
- validation: ResourcePlannerValidationResult;
81
- submitResult?: unknown;
150
+ validation: AvailabilitySelectionValidationResult;
151
+ candidate: ContextualProductTimeRange;
152
+ productLineUid?: string;
153
+ bookingUid?: string;
154
+ productLineUids?: string[];
155
+ bookingUids?: string[];
82
156
  }
157
+ export type UnifiedBookingSalesAvailabilityErrorCode = AvailabilityErrorCode;
83
158
  export interface UnifiedBookingSalesApplyPlannerDiscountsParams {
84
- /** Customer whose cards/coupons should be loaded. Defaults to tempOrder.customer_id. */
85
159
  customerId?: number | string;
86
- /** Optional explicit card/coupon id. When provided, Rules applies this card instead of auto-picking another card. */
87
160
  preferredDiscountId?: number | string;
88
- /** Defaults to true: after loading eligible cards, let Rules choose the best valid combination. */
89
161
  applyBestDiscount?: boolean;
90
162
  }
91
163
  export interface UnifiedBookingSalesDiscountItem {
@@ -110,7 +182,6 @@ export interface UnifiedBookingSalesDiscountResult {
110
182
  status: 'applied' | 'loaded' | 'no_customer';
111
183
  customerId: number | null;
112
184
  preferredDiscountFound?: boolean;
113
- /** True only when the requested card is both selected and written into a planner product line. */
114
185
  preferredDiscountApplied?: boolean;
115
186
  availableDiscounts: UnifiedBookingSalesDiscountItem[];
116
187
  selectedDiscounts: UnifiedBookingSalesDiscountItem[];
@@ -119,32 +190,18 @@ export interface UnifiedBookingSalesDiscountResult {
119
190
  summaryAfter?: unknown;
120
191
  }
121
192
  export interface UnifiedBookingSalesApi {
122
- /** Loads board OpenData for a concrete business + channel target. */
123
193
  loadOpenData: (params: UnifiedBookingSalesLoadOpenDataParams) => Promise<OpenDataConfig>;
124
- /** Returns the latest OpenData payload cached by this solution instance. */
125
- getOpenData: () => OpenDataConfig | null;
126
- /** Date-first calendar availability backed by ScheduleModule. */
194
+ getOpenData: () => Promise<OpenDataConfig | null>;
127
195
  loadScheduleAvailableDate: (params: LoadScheduleAvailableDateParams) => Promise<unknown>;
128
- /** Date-first product pool derived from schedule date ids and globally sellable products. */
129
196
  loadProductsByScheduleDate: (params: UnifiedBookingSalesLoadProductsByScheduleDateParams) => Promise<unknown[]>;
130
- /** Adds product lines only; booking creation is intentionally deferred. */
131
- stagePlannerProducts: (params: UnifiedBookingSalesStagePlannerProductsParams) => Promise<Record<string, any> | null>;
132
- /** Adds ordinary product lines only. It never creates bookings or invokes ResourcePlanner. */
133
197
  stageRetailProducts: (params: UnifiedBookingSalesStageRetailProductsParams) => Promise<Record<string, any> | null>;
134
- /** Adds one ordinary retail line while preserving all existing cart lines. */
135
198
  addRetailProduct: (params: UnifiedBookingSalesAddRetailProductParams) => Promise<Record<string, any>[]>;
136
- /** Loads and normalizes all IO data needed for the pure ResourcePlanner. */
137
- loadPlannerContext: (params?: UnifiedBookingSalesLoadPlannerContextParams) => Promise<ResourcePlannerSnapshot>;
138
- /** Reads continuous availability cells and UI-oriented aggregates. */
139
- queryPlannerAvailability: (query?: ResourcePlannerQuery) => Promise<ResourcePlannerProjection>;
140
- /** Produces selectable slots and the assignments required to commit them. */
141
- resolveAssignableSlots: (query?: ResourcePlannerQuery) => ResourcePlannerAssignableSlotResult;
142
- setPlannerSelection: (patch: ResourcePlannerSelectionPatch) => ResourcePlannerSnapshot;
143
- autoAssignPlanner: (query?: ResourcePlannerQuery) => Promise<ResourcePlannerSnapshot>;
144
- validatePlannerSelection: () => ResourcePlannerValidationResult;
145
- /** Validates, writes to tempOrder, and only optionally makes a real submit request. */
146
- commitPlannerSelection: (params?: UnifiedBookingSalesCommitPlannerSelectionParams) => Promise<UnifiedBookingSalesCommitResult>;
147
- /** Loads the current customer's cards/coupons, optionally applies the best one, and reports line applications. */
199
+ prepareAvailabilityProjection: (params: UnifiedBookingSalesPrepareAvailabilityProjectionParams) => Promise<AvailabilityContextRef>;
200
+ getProductTimeRanges: (contextId: string, request?: GetProductTimeRangesRequest) => Promise<ContextualProductTimeRangeGroup[]>;
201
+ queryBookingAvailability: (contextId: string, request: ContextualAvailabilityQuery) => Promise<ContextualAvailabilityQueryResult>;
202
+ commitAvailabilitySelection: (contextId: string, params: ContextualCommitAvailabilitySelectionParams) => Promise<UnifiedBookingSalesCommitAvailabilitySelectionResult>;
203
+ releaseAvailabilityContext: (contextId: string) => void;
148
204
  applyPlannerDiscounts: (params?: UnifiedBookingSalesApplyPlannerDiscountsParams) => Promise<UnifiedBookingSalesDiscountResult>;
149
- getPlannerSnapshot: () => ResourcePlannerSnapshot;
150
205
  }
206
+ export type UnifiedBookingSalesNormalizedProduct = AvailabilityProduct;
207
+ export type UnifiedBookingSalesNormalizedResource = AvailabilityResource;
@@ -1,11 +1,6 @@
1
1
  export var UnifiedBookingSalesHooks = /*#__PURE__*/function (UnifiedBookingSalesHooks) {
2
- UnifiedBookingSalesHooks["onPlannerContextLoaded"] = "unifiedBookingSales:onPlannerContextLoaded";
3
- UnifiedBookingSalesHooks["onPlannerCommitted"] = "unifiedBookingSales:onPlannerCommitted";
2
+ UnifiedBookingSalesHooks["onAvailabilityProjectionPrepared"] = "unifiedBookingSales:onAvailabilityProjectionPrepared";
3
+ UnifiedBookingSalesHooks["onAvailabilitySelectionCommitted"] = "unifiedBookingSales:onAvailabilitySelectionCommitted";
4
+ UnifiedBookingSalesHooks["onAvailabilityProjectionDiagnostic"] = "unifiedBookingSales:onAvailabilityProjectionDiagnostic";
4
5
  return UnifiedBookingSalesHooks;
5
- }({});
6
-
7
- /** Explicit OpenData target used by page-level UnifiedBookingSales skins. */
8
-
9
- /** Ordinary retail product staging. No resource, time, or booking facts are required. */
10
-
11
- /** Adds one ordinary retail product without replacing other retail lines already in the cart. */
6
+ }({});
@@ -23,6 +23,7 @@ export interface OpenDataConfig {
23
23
  'reservation.auto_confirm'?: boolean;
24
24
  'reservation.auto_confirm_mode'?: string;
25
25
  'reservation.auto_confirm_delay_seconds'?: number;
26
+ 'reservation.time_slice'?: number | string;
26
27
  'sale.allow_item_notes'?: boolean;
27
28
  'sale.allow_order_notes'?: boolean;
28
29
  'sale.enable_item_rules'?: boolean;
@@ -60,6 +60,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
60
60
  * orderModule.updateOtherParams({ cacheId: 'cache-2', channel: 'pos' });
61
61
  */
62
62
  updateOtherParams(params: Record<string, any>): void;
63
+ /** PC/H5 属于在线店铺;其它或缺失平台统一沿用 POS 行为。 */
64
+ isOnlineStorePlatform(): boolean;
63
65
  /**
64
66
  * 记录信息日志
65
67
  */
@@ -425,6 +425,12 @@ var OrderModule = class extends import_BaseModule.BaseModule {
425
425
  this.orderHooks = this.moduleHooksOverride || ((_b = otherParams.order) == null ? void 0 : _b.hooks) || ((_c = otherParams.hooks) == null ? void 0 : _c.order);
426
426
  this.otherParams = otherParams;
427
427
  }
428
+ /** PC/H5 属于在线店铺;其它或缺失平台统一沿用 POS 行为。 */
429
+ isOnlineStorePlatform() {
430
+ var _a;
431
+ const platform = String(((_a = this.otherParams) == null ? void 0 : _a.platform) || "").trim().toLowerCase();
432
+ return platform === "pc" || platform === "h5";
433
+ }
428
434
  /**
429
435
  * 记录信息日志
430
436
  */
@@ -4148,12 +4154,16 @@ var OrderModule = class extends import_BaseModule.BaseModule {
4148
4154
  var _a, _b, _c, _d, _e;
4149
4155
  const tempOrder = this.ensureTempOrder();
4150
4156
  this.prepareVirtualSettlementTempOrder(tempOrder);
4157
+ const isOnlineStorePlatform = this.isOnlineStorePlatform();
4151
4158
  const shouldConfirmPendingVoucherPayments = (params == null ? void 0 : params.confirmPendingVoucherPayments) !== false;
4152
4159
  const hasPaymentOverride = (params == null ? void 0 : params.payments) !== void 0;
4153
- const preparedPaymentOverride = hasPaymentOverride ? this.prepareVoucherPaymentsForSubmit(
4154
- (params == null ? void 0 : params.payments) || [],
4155
- shouldConfirmPendingVoucherPayments
4156
- ) : void 0;
4160
+ let preparedPaymentOverride;
4161
+ if (hasPaymentOverride) {
4162
+ preparedPaymentOverride = isOnlineStorePlatform ? (params == null ? void 0 : params.payments) || [] : this.prepareVoucherPaymentsForSubmit(
4163
+ (params == null ? void 0 : params.payments) || [],
4164
+ shouldConfirmPendingVoucherPayments
4165
+ );
4166
+ }
4157
4167
  if (!hasPaymentOverride) {
4158
4168
  if (shouldConfirmPendingVoucherPayments) {
4159
4169
  this.confirmPendingVoucherPayments({
@@ -4178,7 +4188,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
4178
4188
  ...hasPaymentOverride ? {
4179
4189
  payments: preparedPaymentOverride || []
4180
4190
  } : {},
4181
- ...hasPaymentStatusOverride && !shouldConfirmPendingVoucherPayments ? { payment_status: params == null ? void 0 : params.paymentStatus } : {},
4191
+ ...hasPaymentStatusOverride && !isOnlineStorePlatform && !shouldConfirmPendingVoucherPayments ? { payment_status: params == null ? void 0 : params.paymentStatus } : {},
4182
4192
  ...hasSmallTicketDataFlagOverride ? { small_ticket_data_flag: params == null ? void 0 : params.smallTicketDataFlag } : {}
4183
4193
  };
4184
4194
  const enhancedPayload = (params == null ? void 0 : params.enhancePayload) ? params.enhancePayload(nextPayload, ctx) : nextPayload;
@@ -4194,6 +4204,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
4194
4204
  type: submitSnapshot.type ?? (params == null ? void 0 : params.type),
4195
4205
  summary: latestSummary,
4196
4206
  request_unique_idempotency_token: params == null ? void 0 : params.request_unique_idempotency_token,
4207
+ includePaymentStatus: !isOnlineStorePlatform,
4197
4208
  enhance: enhancePayload
4198
4209
  });
4199
4210
  console.log("[Order.runSubmitTempOrder.payload]", payload);
@@ -295,8 +295,9 @@ export interface OrderSubmitProduct extends Omit<OrderProduct, 'unique_identific
295
295
  payment_price: string;
296
296
  product_sku: OrderProductSku;
297
297
  }
298
- export interface OrderSubmitPayload extends Omit<OrderTempOrder, 'platform' | 'products' | '_extend' | 'customer' | 'discount_list' | 'created_at'> {
298
+ export interface OrderSubmitPayload extends Omit<OrderTempOrder, 'platform' | 'products' | '_extend' | 'customer' | 'discount_list' | 'created_at' | 'payment_status'> {
299
299
  platform: string;
300
+ payment_status?: string;
300
301
  created_at?: string | undefined;
301
302
  request_unique_idempotency_token?: string;
302
303
  form_record_ids?: Array<{
@@ -449,7 +450,7 @@ export interface SubmitSalesOrderParams {
449
450
  sales_channel: string;
450
451
  order_sales_channel: string;
451
452
  status: string;
452
- payment_status: string;
453
+ payment_status?: string;
453
454
  shipping_status: string;
454
455
  customer_id: number | null;
455
456
  customer_name: string;
@@ -776,6 +777,8 @@ export interface OrderModuleAPI {
776
777
  isTempOrderPersistEnabled: () => boolean;
777
778
  /** 提交 tempOrder 变更并触发 `{moduleName}:changed` 事件 */
778
779
  notifyTempOrderChanged: () => void;
780
+ /** PC/H5 为在线店铺;其它或缺失平台统一按 POS 处理。 */
781
+ isOnlineStorePlatform: () => boolean;
779
782
  submitTempOrder: <T = any>(params?: {
780
783
  cacheId?: string;
781
784
  platform?: string;
@@ -220,6 +220,7 @@ export declare function buildSubmitPayload(params: {
220
220
  type?: string;
221
221
  summary?: OrderSummary | null;
222
222
  request_unique_idempotency_token?: string;
223
+ includePaymentStatus?: boolean;
223
224
  enhance?: SubmitPayloadEnhancer;
224
225
  }): OrderSubmitPayload;
225
226
  export declare function mapPaymentItemToOrderPayment(paymentItem: OrderPaymentSource): OrderPaymentData;
@@ -1027,6 +1027,7 @@ function buildSubmitPayload(params) {
1027
1027
  total_refund_amount: _totalRefundAmount,
1028
1028
  create_date: _createDate,
1029
1029
  holder_id: _holderId,
1030
+ payment_status: _paymentStatus,
1030
1031
  ...tempOrderRest
1031
1032
  } = tempOrder;
1032
1033
  let submitType = type ?? tempOrder.type;
@@ -1054,7 +1055,7 @@ function buildSubmitPayload(params) {
1054
1055
  sales_channel: tempOrder.sales_channel || "my_pisel",
1055
1056
  order_sales_channel: channel ?? tempOrder.order_sales_channel ?? "online_store",
1056
1057
  status: tempOrder.status || "normal",
1057
- payment_status: tempOrder.payment_status || "payment_processing",
1058
+ ...params.includePaymentStatus !== false ? { payment_status: tempOrder.payment_status || "payment_processing" } : {},
1058
1059
  // shipping_status: tempOrder.shipping_status || 'unfulfilled',
1059
1060
  is_price_include_tax: tempOrder.is_price_include_tax ?? 1,
1060
1061
  currency_format: tempOrder.currency_format || "symbol_first",
@@ -1,24 +1,2 @@
1
- import { BaseModule } from '../BaseModule';
2
- import type { Module, ModuleOptions, PisellCore } from '../../types';
3
- import type { ResourcePlannerAssignmentResult, ResourcePlannerAssignableSlotResult, ResourcePlannerContextInput, ResourcePlannerProjection, ResourcePlannerQuery, ResourcePlannerSelectionPatch, ResourcePlannerSnapshot, ResourcePlannerValidationResult } from './types';
4
1
  export * from './types';
5
2
  export * from './planner';
6
- export declare enum ResourcePlannerHooks {
7
- onContextChanged = "resourcePlanner:onContextChanged",
8
- onSelectionChanged = "resourcePlanner:onSelectionChanged",
9
- onProjectionChanged = "resourcePlanner:onProjectionChanged"
10
- }
11
- export declare class ResourcePlannerModule extends BaseModule implements Module {
12
- protected defaultName: string;
13
- protected defaultVersion: string;
14
- private store;
15
- initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
16
- setContext(input: ResourcePlannerContextInput): ResourcePlannerSnapshot;
17
- mergeContext(input: ResourcePlannerContextInput): ResourcePlannerSnapshot;
18
- setSelectionPatch(patch: ResourcePlannerSelectionPatch): ResourcePlannerSnapshot;
19
- queryAvailability(query?: ResourcePlannerQuery): ResourcePlannerProjection;
20
- autoAssign(query?: ResourcePlannerQuery): ResourcePlannerAssignmentResult;
21
- resolveAssignableSlots(query?: ResourcePlannerQuery): ResourcePlannerAssignableSlotResult;
22
- validateSelection(): ResourcePlannerValidationResult;
23
- getSnapshot(): ResourcePlannerSnapshot;
24
- }
@@ -2,10 +2,6 @@ var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
5
  var __copyProps = (to, from, except, desc) => {
10
6
  if (from && typeof from === "object" || typeof from === "function") {
11
7
  for (let key of __getOwnPropNames(from))
@@ -19,130 +15,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
15
 
20
16
  // src/modules/ResourcePlanner/index.ts
21
17
  var ResourcePlanner_exports = {};
22
- __export(ResourcePlanner_exports, {
23
- ResourcePlannerHooks: () => ResourcePlannerHooks,
24
- ResourcePlannerModule: () => ResourcePlannerModule
25
- });
26
18
  module.exports = __toCommonJS(ResourcePlanner_exports);
27
- var import_BaseModule = require("../BaseModule");
28
- var import_planner = require("./planner");
29
19
  __reExport(ResourcePlanner_exports, require("./types"), module.exports);
30
20
  __reExport(ResourcePlanner_exports, require("./planner"), module.exports);
31
- var ResourcePlannerHooks = /* @__PURE__ */ ((ResourcePlannerHooks2) => {
32
- ResourcePlannerHooks2["onContextChanged"] = "resourcePlanner:onContextChanged";
33
- ResourcePlannerHooks2["onSelectionChanged"] = "resourcePlanner:onSelectionChanged";
34
- ResourcePlannerHooks2["onProjectionChanged"] = "resourcePlanner:onProjectionChanged";
35
- return ResourcePlannerHooks2;
36
- })(ResourcePlannerHooks || {});
37
- var ResourcePlannerModule = class extends import_BaseModule.BaseModule {
38
- constructor() {
39
- super(...arguments);
40
- this.defaultName = "resourcePlanner";
41
- this.defaultVersion = "1.0.0";
42
- }
43
- async initialize(core, options) {
44
- this.core = core;
45
- const initialState = options.initialState;
46
- this.store = {
47
- context: (0, import_planner.normalizePlannerContext)((initialState == null ? void 0 : initialState.context) || import_planner.DEFAULT_RESOURCE_PLANNER_CONTEXT),
48
- selection: (initialState == null ? void 0 : initialState.selection) || { ...import_planner.DEFAULT_RESOURCE_PLANNER_SELECTION },
49
- projection: (initialState == null ? void 0 : initialState.projection) || null,
50
- version: (initialState == null ? void 0 : initialState.version) || 0
51
- };
52
- }
53
- setContext(input) {
54
- this.store.context = (0, import_planner.normalizePlannerContext)(input);
55
- this.store.version += 1;
56
- this.store.projection = null;
57
- const snapshot = this.getSnapshot();
58
- void this.core.effects.emit(`${this.name}:contextChanged`, snapshot);
59
- return snapshot;
60
- }
61
- mergeContext(input) {
62
- return this.setContext({
63
- ...this.store.context,
64
- ...input,
65
- products: input.products || this.store.context.products,
66
- resources: input.resources || this.store.context.resources,
67
- externalEvents: input.externalEvents || this.store.context.externalEvents
68
- });
69
- }
70
- setSelectionPatch(patch) {
71
- const assignments = patch.assignments ? patch.replaceAssignments === false ? [...this.store.selection.assignments, ...patch.assignments] : patch.assignments : this.store.selection.assignments;
72
- this.store.selection = {
73
- ...this.store.selection,
74
- ...patch,
75
- productIds: patch.productIds || this.store.selection.productIds,
76
- resourceIds: patch.resourceIds || this.store.selection.resourceIds,
77
- assignments
78
- };
79
- this.store.version += 1;
80
- const snapshot = this.getSnapshot();
81
- void this.core.effects.emit(`${this.name}:selectionChanged`, snapshot);
82
- return snapshot;
83
- }
84
- queryAvailability(query = {}) {
85
- const mergedQuery = {
86
- mode: this.store.selection.mode,
87
- productIds: this.store.selection.productIds,
88
- date: this.store.selection.date,
89
- startTime: this.store.selection.startTime,
90
- endTime: this.store.selection.endTime,
91
- resourceIds: this.store.selection.resourceIds,
92
- ...query
93
- };
94
- const projection = (0, import_planner.queryPlannerAvailability)(this.store.context, mergedQuery);
95
- this.store.projection = projection;
96
- this.store.version += 1;
97
- void this.core.effects.emit(`${this.name}:projectionChanged`, this.getSnapshot());
98
- return projection;
99
- }
100
- autoAssign(query = {}) {
101
- const result = (0, import_planner.autoAssignResources)(this.store.context, {
102
- mode: this.store.selection.mode,
103
- productIds: this.store.selection.productIds,
104
- date: this.store.selection.date,
105
- startTime: this.store.selection.startTime,
106
- endTime: this.store.selection.endTime,
107
- resourceIds: this.store.selection.resourceIds,
108
- ...query
109
- });
110
- const resourceIds = Array.from(new Map(
111
- result.assignments.map((assignment) => [String(assignment.resourceId), assignment.resourceId])
112
- ).values());
113
- this.setSelectionPatch({
114
- assignments: result.assignments,
115
- ...resourceIds.length ? { resourceIds } : {}
116
- });
117
- return result;
118
- }
119
- resolveAssignableSlots(query = {}) {
120
- return (0, import_planner.resolveAssignableSlots)(this.store.context, {
121
- mode: this.store.selection.mode,
122
- productIds: this.store.selection.productIds,
123
- date: this.store.selection.date,
124
- startTime: this.store.selection.startTime,
125
- endTime: this.store.selection.endTime,
126
- resourceIds: this.store.selection.resourceIds,
127
- ...query
128
- });
129
- }
130
- validateSelection() {
131
- return (0, import_planner.validateAssignments)(this.store.context, this.store.selection);
132
- }
133
- getSnapshot() {
134
- return {
135
- context: this.store.context,
136
- selection: this.store.selection,
137
- projection: this.store.projection,
138
- version: this.store.version
139
- };
140
- }
141
- };
142
21
  // Annotate the CommonJS export names for ESM import in node:
143
22
  0 && (module.exports = {
144
- ResourcePlannerHooks,
145
- ResourcePlannerModule,
146
23
  ...require("./types"),
147
24
  ...require("./planner")
148
25
  });
@@ -0,0 +1,33 @@
1
+ export interface LocalDateParts {
2
+ year: number;
3
+ month: number;
4
+ day: number;
5
+ }
6
+ export interface LocalDateTimeParts extends LocalDateParts {
7
+ hour: number;
8
+ minute: number;
9
+ second: number;
10
+ }
11
+ type LocalDateInput = string | LocalDateParts;
12
+ type LocalDateTimeInput = string | number | LocalDateTimeParts;
13
+ export declare function parseLocalDate(value: string): LocalDateParts;
14
+ export declare function parseLocalDateTime(value: string): LocalDateTimeParts;
15
+ export declare function extractFixedOffsetMinutes(value: string | null | undefined): number | null;
16
+ export declare function captureRuntimeOffsetMinutes(value?: Date): number;
17
+ export declare function formatFixedOffset(offsetMinutes: number | null | undefined): string;
18
+ export declare function localDateTimeToScalar(value: LocalDateTimeParts): number;
19
+ export declare function localDateToScalar(value: Date): number;
20
+ export declare function localDateToScalarStart(value: LocalDateInput): number;
21
+ export declare function scalarToLocalDateParts(value: number): LocalDateParts;
22
+ export declare function scalarToLocalDateTimeParts(value: number): LocalDateTimeParts;
23
+ export declare function dateOrdinalFromLocalDate(value: LocalDateInput): number;
24
+ export declare function weekdayFromLocalDate(value: LocalDateInput): number;
25
+ export declare function formatLocalDate(value: LocalDateInput | number): string;
26
+ export declare function formatLocalTime(value: LocalDateTimeInput, includeSeconds?: boolean): string;
27
+ export declare function formatLocalDateTime(value: LocalDateTimeInput, fixedOffsetMinutes?: number | null): string;
28
+ export declare function addLocalMinutes(value: number, minutes: number): number;
29
+ export declare function addLocalHours(value: number, hours: number): number;
30
+ export declare function addLocalCalendarDays(value: number, days: number): number;
31
+ export declare function nextDate(value: LocalDateInput): string;
32
+ export declare function ceilLocalScalarToTenMinutes(value: number): number;
33
+ export {};