@pisell/pisellos 0.10.12 → 0.10.14
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.
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/ResourcePlanner/planner.js +4 -1
- package/dist/modules/ResourcePlanner/types.d.ts +1 -0
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/UnifiedBookingSales/index.d.ts +5 -1
- package/dist/solution/UnifiedBookingSales/index.js +459 -415
- package/dist/solution/UnifiedBookingSales/types.d.ts +10 -0
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/ResourcePlanner/planner.js +3 -1
- package/lib/modules/ResourcePlanner/types.d.ts +1 -0
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/UnifiedBookingSales/index.d.ts +5 -1
- package/lib/solution/UnifiedBookingSales/index.js +28 -7
- package/lib/solution/UnifiedBookingSales/types.d.ts +10 -0
- package/package.json +1 -1
|
@@ -6,6 +6,16 @@ import type { BookingTicketState } from '../BookingTicket/types';
|
|
|
6
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';
|
|
7
7
|
export interface UnifiedBookingSalesState extends BookingTicketState {
|
|
8
8
|
}
|
|
9
|
+
export interface UnifiedBookingSalesPolicy {
|
|
10
|
+
id?: AvailabilityId;
|
|
11
|
+
title?: unknown;
|
|
12
|
+
content?: string;
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
}
|
|
15
|
+
export interface UnifiedBookingSalesPolicyResponse {
|
|
16
|
+
data?: UnifiedBookingSalesPolicy;
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
}
|
|
9
19
|
export declare enum UnifiedBookingSalesHooks {
|
|
10
20
|
onAvailabilityProjectionPrepared = "unifiedBookingSales:onAvailabilityProjectionPrepared",
|
|
11
21
|
onAvailabilitySelectionCommitted = "unifiedBookingSales:onAvailabilitySelectionCommitted",
|
|
@@ -526,7 +526,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
526
526
|
generateIdempotencyToken(): string;
|
|
527
527
|
syncPaymentsToOrder<T = any>(params: SyncPaymentsToOrderParams): Promise<SyncPaymentsToOrderResult<T>>;
|
|
528
528
|
createOrder(params: CommitOrderParams['query']): {
|
|
529
|
-
type: "
|
|
529
|
+
type: "appointment_booking" | "virtual";
|
|
530
530
|
platform: string;
|
|
531
531
|
sales_channel: string;
|
|
532
532
|
order_sales_channel: string;
|
|
@@ -1473,7 +1473,7 @@ function evaluateCandidate(projection, candidate, request) {
|
|
|
1473
1473
|
const selection = selectionsByGroupKey.get(requirementGroup.id) || selectionsByGroupKey.get(String(requirementGroup.formId ?? ""));
|
|
1474
1474
|
const matchedResources = (((_a2 = request.groupResourceIndex) == null ? void 0 : _a2.get([String(product.id), requirementGroup.id].join(":"))) || projection.resources.filter((resource) => matchesRequirementGroup(requirementGroup, resource, product, partySize)).filter((resource) => !evaluationContext.resourceIdSet || evaluationContext.resourceIdSet.has(String(resource.id)))).filter((resource) => !selection || selection.resourceIds.some((resourceId) => sameId(resourceId, resource.id)));
|
|
1475
1475
|
const options = matchedResources.map((resource) => {
|
|
1476
|
-
var _a3;
|
|
1476
|
+
var _a3, _b2, _c;
|
|
1477
1477
|
const matchedCell = aggregateMatchedCells(
|
|
1478
1478
|
product.id,
|
|
1479
1479
|
requirementGroup.id,
|
|
@@ -1487,6 +1487,7 @@ function evaluateCandidate(projection, candidate, request) {
|
|
|
1487
1487
|
resourceId: resource.id,
|
|
1488
1488
|
resourceName: resource.name,
|
|
1489
1489
|
resourceFormId: resource.formId,
|
|
1490
|
+
policyId: (_b2 = resource.raw) == null ? void 0 : _b2.policy_id,
|
|
1490
1491
|
resourceType: resource.resourceType,
|
|
1491
1492
|
status: isPast2 ? "past" : "unavailable",
|
|
1492
1493
|
maxPartySize: 0,
|
|
@@ -1513,6 +1514,7 @@ function evaluateCandidate(projection, candidate, request) {
|
|
|
1513
1514
|
resourceId: resource.id,
|
|
1514
1515
|
resourceName: resource.name,
|
|
1515
1516
|
resourceFormId: resource.formId,
|
|
1517
|
+
policyId: (_c = resource.raw) == null ? void 0 : _c.policy_id,
|
|
1516
1518
|
resourceType: resource.resourceType,
|
|
1517
1519
|
status: status2,
|
|
1518
1520
|
remainingCapacity,
|
|
@@ -258,6 +258,7 @@ export interface AvailabilityResourceOption {
|
|
|
258
258
|
resourceId: AvailabilityId;
|
|
259
259
|
resourceName?: string;
|
|
260
260
|
resourceFormId?: AvailabilityId;
|
|
261
|
+
policyId?: AvailabilityId;
|
|
261
262
|
resourceType: AvailabilityResourceType;
|
|
262
263
|
status: AvailabilityStatus;
|
|
263
264
|
remainingCapacity?: number;
|
|
@@ -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 |
|
|
329
|
+
weekNum: 0 | 1 | 2 | 5 | 4 | 3 | 6;
|
|
330
330
|
}[]>;
|
|
331
331
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
332
332
|
private getScheduleDataByIds;
|
|
@@ -345,7 +345,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
345
345
|
count: number;
|
|
346
346
|
left: number;
|
|
347
347
|
summaryCount: number;
|
|
348
|
-
status: "
|
|
348
|
+
status: "sold_out" | "lots_of_space" | "filling_up_fast";
|
|
349
349
|
}[];
|
|
350
350
|
/**
|
|
351
351
|
* 找到多个资源的公共可用时间段
|
|
@@ -4,7 +4,7 @@ import type { OpenDataConfig } from '../../modules/OpenData';
|
|
|
4
4
|
import type { LoadScheduleAvailableDateParams, ScheduleItem } from '../../modules/Schedule/types';
|
|
5
5
|
import type { ProductListLoadProductsParams } from '../../modules/ProductList';
|
|
6
6
|
import type { AvailabilityDateRange, AvailabilityOccupancy, AvailabilityProduct, AvailabilityResource, GetProductTimeRangesRequest } from '../../modules/ResourcePlanner';
|
|
7
|
-
import type { AvailabilityContextRef, ContextualAvailabilityQuery, ContextualAvailabilityQueryResult, ContextualCommitAvailabilitySelectionParams, ContextualProductTimeRangeGroup, UnifiedBookingSalesAddRetailProductParams, UnifiedBookingSalesApplyPlannerDiscountsParams, UnifiedBookingSalesCommitAvailabilitySelectionResult, UnifiedBookingSalesDiscountResult, UnifiedBookingSalesLoadProductsByScheduleDateParams, UnifiedBookingSalesLoadOpenDataParams, UnifiedBookingSalesPrepareAvailabilityProjectionParams, UnifiedBookingSalesStageRetailProductsParams, UnifiedBookingSalesState } from './types';
|
|
7
|
+
import type { AvailabilityContextRef, ContextualAvailabilityQuery, ContextualAvailabilityQueryResult, ContextualCommitAvailabilitySelectionParams, ContextualProductTimeRangeGroup, UnifiedBookingSalesAddRetailProductParams, UnifiedBookingSalesApplyPlannerDiscountsParams, UnifiedBookingSalesCommitAvailabilitySelectionResult, UnifiedBookingSalesDiscountResult, UnifiedBookingSalesLoadProductsByScheduleDateParams, UnifiedBookingSalesLoadOpenDataParams, UnifiedBookingSalesPrepareAvailabilityProjectionParams, UnifiedBookingSalesPolicyResponse, UnifiedBookingSalesStageRetailProductsParams, UnifiedBookingSalesState } from './types';
|
|
8
8
|
import { BookingTicket } from '../BookingTicket';
|
|
9
9
|
export * from './types';
|
|
10
10
|
export { AvailabilityError } from '../../modules/ResourcePlanner';
|
|
@@ -147,6 +147,10 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
147
147
|
*/
|
|
148
148
|
loadOpenData(params: UnifiedBookingSalesLoadOpenDataParams): Promise<OpenDataConfig>;
|
|
149
149
|
getOpenData(): Promise<OpenDataConfig | null>;
|
|
150
|
+
/**
|
|
151
|
+
* Load a resource policy without depending on the legacy appointmentBooking solution.
|
|
152
|
+
*/
|
|
153
|
+
getProtocol(policyId: string | number): Promise<UnifiedBookingSalesPolicyResponse>;
|
|
150
154
|
/**
|
|
151
155
|
* Loads the product catalog used by both UI and Planner. Schedule data is requested with each
|
|
152
156
|
* product because session products carry their fixed intervals there.
|
|
@@ -933,7 +933,9 @@ function buildBookingFromAvailabilitySelection(params) {
|
|
|
933
933
|
candidate,
|
|
934
934
|
product,
|
|
935
935
|
resources = [],
|
|
936
|
-
bookingUid
|
|
936
|
+
bookingUid,
|
|
937
|
+
holder,
|
|
938
|
+
holderIds
|
|
937
939
|
} = params;
|
|
938
940
|
const bookingStartAt = candidate.bookingStartAt || candidate.startAt;
|
|
939
941
|
const bookingEndAt = candidate.bookingEndAt || candidate.endAt;
|
|
@@ -948,6 +950,8 @@ function buildBookingFromAvailabilitySelection(params) {
|
|
|
948
950
|
scheduleRefs: candidate.scheduleRefs
|
|
949
951
|
});
|
|
950
952
|
}
|
|
953
|
+
const normalizedHolder = holder && typeof holder === "object" ? (0, import_lodash_es.cloneDeep)(holder) : void 0;
|
|
954
|
+
const normalizedHolderIds = Array.isArray(holderIds) ? (0, import_lodash_es.cloneDeep)(holderIds) : holderIds;
|
|
951
955
|
return {
|
|
952
956
|
start_date: bookingStartAt.slice(0, 10),
|
|
953
957
|
start_time: bookingStartAt.slice(11, 16),
|
|
@@ -956,6 +960,7 @@ function buildBookingFromAvailabilitySelection(params) {
|
|
|
956
960
|
duration: Math.max(1, Math.trunc((endScalar - startScalar) / (60 * 1e3))),
|
|
957
961
|
like_status: "common",
|
|
958
962
|
schedule_id: scheduleId ?? 0,
|
|
963
|
+
...normalizedHolder ? { holder: normalizedHolder } : {},
|
|
959
964
|
resources: assignments.map((assignment) => {
|
|
960
965
|
const matchedResource = resources.find((resource) => sameAvailabilityId(resource.id, assignment.resourceId));
|
|
961
966
|
const resourceName = String((matchedResource == null ? void 0 : matchedResource.name) || "").trim();
|
|
@@ -979,7 +984,9 @@ function buildBookingFromAvailabilitySelection(params) {
|
|
|
979
984
|
availability_slice_end_at: candidate.endAt,
|
|
980
985
|
availability_schedule_refs: candidate.scheduleRefs,
|
|
981
986
|
...timeSlotId == null ? {} : { time_slot_id: timeSlotId },
|
|
982
|
-
product_kind: product.kind
|
|
987
|
+
product_kind: product.kind,
|
|
988
|
+
...normalizedHolderIds === void 0 ? {} : { holder_id: normalizedHolderIds },
|
|
989
|
+
...normalizedHolder ? { holder: (0, import_lodash_es.cloneDeep)(normalizedHolder) } : {}
|
|
983
990
|
}
|
|
984
991
|
};
|
|
985
992
|
}
|
|
@@ -1557,6 +1564,18 @@ var UnifiedBookingSalesImpl = class extends import_BookingTicket.BookingTicket {
|
|
|
1557
1564
|
return cachedData;
|
|
1558
1565
|
return this.loadOpenData({ businessCode, channel });
|
|
1559
1566
|
}
|
|
1567
|
+
/**
|
|
1568
|
+
* Load a resource policy without depending on the legacy appointmentBooking solution.
|
|
1569
|
+
*/
|
|
1570
|
+
async getProtocol(policyId) {
|
|
1571
|
+
const normalizedPolicyId = String(policyId ?? "").trim();
|
|
1572
|
+
if (!normalizedPolicyId) {
|
|
1573
|
+
throw new Error("[UnifiedBookingSales] getProtocol 需要 policyId");
|
|
1574
|
+
}
|
|
1575
|
+
return this.request.get(
|
|
1576
|
+
`/shop-policy/${encodeURIComponent(normalizedPolicyId)}`
|
|
1577
|
+
);
|
|
1578
|
+
}
|
|
1560
1579
|
/**
|
|
1561
1580
|
* Loads the product catalog used by both UI and Planner. Schedule data is requested with each
|
|
1562
1581
|
* product because session products carry their fixed intervals there.
|
|
@@ -2804,7 +2823,7 @@ var UnifiedBookingSalesImpl = class extends import_BookingTicket.BookingTicket {
|
|
|
2804
2823
|
}
|
|
2805
2824
|
/** Revalidates against the latest landed occupancy cache, then mutates exactly one product line. */
|
|
2806
2825
|
async commitAvailabilitySelection(contextId, params) {
|
|
2807
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
2826
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
2808
2827
|
const normalizedContextId = String(contextId || "").trim();
|
|
2809
2828
|
if (!normalizedContextId) {
|
|
2810
2829
|
throw new import_ResourcePlanner.AvailabilityError("INVALID_TARGET_FILTER", "commitAvailabilitySelection 缺少 contextId", {
|
|
@@ -3074,7 +3093,9 @@ var UnifiedBookingSalesImpl = class extends import_BookingTicket.BookingTicket {
|
|
|
3074
3093
|
candidate: refreshedCandidate,
|
|
3075
3094
|
product,
|
|
3076
3095
|
resources: refreshedProjection.resources,
|
|
3077
|
-
bookingUid: existingBookingUid || void 0
|
|
3096
|
+
bookingUid: existingBookingUid || void 0,
|
|
3097
|
+
holder: ((_h = (_g = params.orderProduct) == null ? void 0 : _g._extend) == null ? void 0 : _h.holder) ?? (existingBooking == null ? void 0 : existingBooking.holder) ?? ((_i = existingBooking == null ? void 0 : existingBooking.metadata) == null ? void 0 : _i.holder),
|
|
3098
|
+
holderIds: ((_k = (_j = params.orderProduct) == null ? void 0 : _j._extend) == null ? void 0 : _k.holder_id) ?? ((_n = (_m = (_l = params.orderProduct) == null ? void 0 : _l._extend) == null ? void 0 : _m.holder) == null ? void 0 : _n.form_record) ?? ((_o = existingBooking == null ? void 0 : existingBooking.metadata) == null ? void 0 : _o.holder_id) ?? ((_p = existingBooking == null ? void 0 : existingBooking.holder) == null ? void 0 : _p.form_record)
|
|
3078
3099
|
});
|
|
3079
3100
|
const transformed = this.buildUnifiedOrderProduct({
|
|
3080
3101
|
...params.orderProduct,
|
|
@@ -3121,10 +3142,10 @@ var UnifiedBookingSalesImpl = class extends import_BookingTicket.BookingTicket {
|
|
|
3121
3142
|
bookingUids = [bookingUid];
|
|
3122
3143
|
} else {
|
|
3123
3144
|
const beforeProductLineUids = new Set(
|
|
3124
|
-
(((
|
|
3145
|
+
(((_q = this.getTempOrder()) == null ? void 0 : _q.products) || []).map((line) => getProductLineUid(line)).filter(Boolean)
|
|
3125
3146
|
);
|
|
3126
3147
|
const beforeBookingUids = new Set(
|
|
3127
|
-
(((
|
|
3148
|
+
(((_r = this.getTempOrder()) == null ? void 0 : _r.bookings) || []).map((item) => getBookingUid(item)).filter(Boolean)
|
|
3128
3149
|
);
|
|
3129
3150
|
const products = await this.addProductToOrder(transformed, booking);
|
|
3130
3151
|
const addedLines = products.filter((line) => {
|
|
@@ -3132,7 +3153,7 @@ var UnifiedBookingSalesImpl = class extends import_BookingTicket.BookingTicket {
|
|
|
3132
3153
|
return sameAvailabilityId(line.product_id ?? line.id, refreshedCandidate.productId) && ((_a2 = line.metadata) == null ? void 0 : _a2.availability_candidate_key) === refreshedCandidate.key && !beforeProductLineUids.has(getProductLineUid(line));
|
|
3133
3154
|
});
|
|
3134
3155
|
productLineUids = addedLines.map((line) => getProductLineUid(line)).filter(Boolean);
|
|
3135
|
-
const addedBookings = (((
|
|
3156
|
+
const addedBookings = (((_s = this.getTempOrder()) == null ? void 0 : _s.bookings) || []).filter((item) => {
|
|
3136
3157
|
var _a2;
|
|
3137
3158
|
return ((_a2 = item.metadata) == null ? void 0 : _a2.availability_candidate_key) === refreshedCandidate.key && !beforeBookingUids.has(getBookingUid(item));
|
|
3138
3159
|
});
|
|
@@ -6,6 +6,16 @@ import type { BookingTicketState } from '../BookingTicket/types';
|
|
|
6
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';
|
|
7
7
|
export interface UnifiedBookingSalesState extends BookingTicketState {
|
|
8
8
|
}
|
|
9
|
+
export interface UnifiedBookingSalesPolicy {
|
|
10
|
+
id?: AvailabilityId;
|
|
11
|
+
title?: unknown;
|
|
12
|
+
content?: string;
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
}
|
|
15
|
+
export interface UnifiedBookingSalesPolicyResponse {
|
|
16
|
+
data?: UnifiedBookingSalesPolicy;
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
}
|
|
9
19
|
export declare enum UnifiedBookingSalesHooks {
|
|
10
20
|
onAvailabilityProjectionPrepared = "unifiedBookingSales:onAvailabilityProjectionPrepared",
|
|
11
21
|
onAvailabilitySelectionCommitted = "unifiedBookingSales:onAvailabilitySelectionCommitted",
|