@pisell/pisellos 2.2.306 → 2.2.308
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/modules/ResourcePlanner/planner.js +10 -8
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/Sales/index.d.ts +2 -0
- package/dist/solution/Sales/index.js +15 -1
- package/dist/solution/UnifiedBookingSales/index.js +3 -4
- package/lib/modules/ResourcePlanner/planner.js +10 -8
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/Sales/index.d.ts +2 -0
- package/lib/solution/Sales/index.js +10 -1
- package/lib/solution/UnifiedBookingSales/index.js +3 -4
- package/package.json +1 -1
|
@@ -436,7 +436,7 @@ function normalizeOccupancy(occupancy, coverage, timezoneName, fixedOffsetMinute
|
|
|
436
436
|
}
|
|
437
437
|
function normalizeRequirementGroup(product, requirementGroup) {
|
|
438
438
|
var _requirementGroup$for;
|
|
439
|
-
var resourceType = 'single';
|
|
439
|
+
var resourceType = requirementGroup.resourceType === 'multiple' || requirementGroup.resourceType === 'capacity' ? requirementGroup.resourceType : 'single';
|
|
440
440
|
var required = requirementGroup.required !== false;
|
|
441
441
|
var min = required ? 1 : 0;
|
|
442
442
|
return _objectSpread(_objectSpread({}, requirementGroup), {}, {
|
|
@@ -482,7 +482,7 @@ function normalizeProducts(products) {
|
|
|
482
482
|
function normalizeResources(resources) {
|
|
483
483
|
return resources.map(function (resource) {
|
|
484
484
|
return _objectSpread(_objectSpread({}, resource), {}, {
|
|
485
|
-
resourceType: 'single',
|
|
485
|
+
resourceType: resource.resourceType === 'multiple' || resource.resourceType === 'capacity' ? resource.resourceType : 'single',
|
|
486
486
|
capacity: Math.max(1, Number(resource.capacity || 1) || 1),
|
|
487
487
|
windows: (resource.windows || []).map(function (window) {
|
|
488
488
|
return _objectSpread({}, window);
|
|
@@ -637,7 +637,8 @@ function buildCells(projection) {
|
|
|
637
637
|
var usedCapacity = segmentOccupancies.reduce(function (sum, occupancy) {
|
|
638
638
|
return sum + Math.max(1, Number(occupancy.pax || 1) || 1);
|
|
639
639
|
}, 0);
|
|
640
|
-
|
|
640
|
+
// 预约模式来自商品资源组;v2 资源记录可能不包含 type。
|
|
641
|
+
var remainingCapacity = requirementGroup.resourceType === 'single' && segmentOccupancies.length > 0 ? 0 : Math.max(0, resource.capacity - usedCapacity);
|
|
641
642
|
var requiredCapacity = resolveRequiredCapacity(requirementGroup, product);
|
|
642
643
|
var reasonCodes = Array.from(new Set(segmentOccupancies.flatMap(function (occupancy) {
|
|
643
644
|
var source = occupancy.source || 'remote';
|
|
@@ -671,7 +672,7 @@ function buildCells(projection) {
|
|
|
671
672
|
requirementFormId: requirementGroup.formId,
|
|
672
673
|
resourceId: resource.id,
|
|
673
674
|
resourceName: resource.name,
|
|
674
|
-
resourceType:
|
|
675
|
+
resourceType: requirementGroup.resourceType,
|
|
675
676
|
startAt: formatDateTime(start, timezoneName, fixedOffsetMinutes),
|
|
676
677
|
endAt: formatDateTime(end, timezoneName, fixedOffsetMinutes),
|
|
677
678
|
date: formatDate(start, timezoneName),
|
|
@@ -679,7 +680,7 @@ function buildCells(projection) {
|
|
|
679
680
|
endTime: formatTime(end, timezoneName),
|
|
680
681
|
timezone: projection.meta.timezone,
|
|
681
682
|
status: status,
|
|
682
|
-
//
|
|
683
|
+
// capacity 表示人数;single 被占用时不再贡献可用容量。
|
|
683
684
|
remainingCapacity: remainingCapacity,
|
|
684
685
|
maxCapacity: resource.capacity,
|
|
685
686
|
reasonCodes: Array.from(new Set(reasonCodes)),
|
|
@@ -1739,7 +1740,7 @@ function evaluateCandidate(projection, candidate, request) {
|
|
|
1739
1740
|
resourceName: resource.name,
|
|
1740
1741
|
resourceFormId: resource.formId,
|
|
1741
1742
|
policyId: (_resource$raw = resource.raw) === null || _resource$raw === void 0 ? void 0 : _resource$raw.policy_id,
|
|
1742
|
-
resourceType:
|
|
1743
|
+
resourceType: requirementGroup.resourceType,
|
|
1743
1744
|
status: _isPast ? 'past' : 'unavailable',
|
|
1744
1745
|
maxPartySize: 0,
|
|
1745
1746
|
reasonCodes: _isPast ? ['past'] : [].concat(_toConsumableArray(isExcludedScheduleDate ? ['schedule_excluded_date'] : []), ['outside_resource_window'])
|
|
@@ -1763,7 +1764,7 @@ function evaluateCandidate(projection, candidate, request) {
|
|
|
1763
1764
|
resourceName: resource.name,
|
|
1764
1765
|
resourceFormId: resource.formId,
|
|
1765
1766
|
policyId: (_resource$raw2 = resource.raw) === null || _resource$raw2 === void 0 ? void 0 : _resource$raw2.policy_id,
|
|
1766
|
-
resourceType:
|
|
1767
|
+
resourceType: requirementGroup.resourceType,
|
|
1767
1768
|
status: status,
|
|
1768
1769
|
remainingCapacity: remainingCapacity,
|
|
1769
1770
|
maxCapacity: maxCapacity,
|
|
@@ -2330,7 +2331,8 @@ export function validateAvailabilitySelection(projection, params) {
|
|
|
2330
2331
|
var remainingCapacity = matchedCell === null || matchedCell === void 0 ? void 0 : matchedCell.remainingCapacity;
|
|
2331
2332
|
if (option && (option.status === 'available' || option.status === 'limited') && remainingCapacity !== undefined) {
|
|
2332
2333
|
var capacityPerBooking = normalizedPartySize !== null && normalizedPartySize !== void 0 ? normalizedPartySize : 1;
|
|
2333
|
-
var
|
|
2334
|
+
var capacityQuantity = Math.max(0, Math.floor(remainingCapacity / capacityPerBooking));
|
|
2335
|
+
var availableQuantity = matchedGroup.resourceType === 'single' ? Math.min(1, capacityQuantity) : capacityQuantity;
|
|
2334
2336
|
if (normalizedBookingCount > availableQuantity) {
|
|
2335
2337
|
conflicts.push({
|
|
2336
2338
|
code: 'resource_capacity_exceeded',
|
|
@@ -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 | 2 | 1 | 6 | 4 | 5 | 3;
|
|
330
330
|
}[]>;
|
|
331
331
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
332
332
|
private getScheduleDataByIds;
|
|
@@ -339,7 +339,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
339
339
|
* 获取当前的客户搜索条件
|
|
340
340
|
* @returns 当前搜索条件
|
|
341
341
|
*/
|
|
342
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
342
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
343
343
|
/**
|
|
344
344
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
345
345
|
* @returns 客户状态
|
|
@@ -105,6 +105,8 @@ export declare class SalesImpl extends BaseModule implements Module, SalesModule
|
|
|
105
105
|
private groupBookingsByResource;
|
|
106
106
|
private isBookingMatchedResource;
|
|
107
107
|
private sortMatchedBookings;
|
|
108
|
+
/** 已完成:按订单创建时间降序,避免实时追加和重新加载导致显示顺序不同。 */
|
|
109
|
+
private sortCompletedBookings;
|
|
108
110
|
/** Unpaid:与 Current 重合的订单沿用 Current 顺序,其余欠款订单按开始时间降序追加。 */
|
|
109
111
|
private sortUnpaidBookings;
|
|
110
112
|
/**
|
|
@@ -760,6 +760,20 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
760
760
|
});
|
|
761
761
|
}
|
|
762
762
|
|
|
763
|
+
/** 已完成:按订单创建时间降序,避免实时追加和重新加载导致显示顺序不同。 */
|
|
764
|
+
}, {
|
|
765
|
+
key: "sortCompletedBookings",
|
|
766
|
+
value: function sortCompletedBookings(bookings) {
|
|
767
|
+
var createdAt = function createdAt(booking) {
|
|
768
|
+
var _booking$order3;
|
|
769
|
+
var timestamp = dayjs(((_booking$order3 = booking.order) === null || _booking$order3 === void 0 ? void 0 : _booking$order3.created_at) || '').valueOf();
|
|
770
|
+
return Number.isFinite(timestamp) ? timestamp : 0;
|
|
771
|
+
};
|
|
772
|
+
return _toConsumableArray(bookings).sort(function (left, right) {
|
|
773
|
+
return createdAt(right) - createdAt(left);
|
|
774
|
+
});
|
|
775
|
+
}
|
|
776
|
+
|
|
763
777
|
/** Unpaid:与 Current 重合的订单沿用 Current 顺序,其余欠款订单按开始时间降序追加。 */
|
|
764
778
|
}, {
|
|
765
779
|
key: "sortUnpaidBookings",
|
|
@@ -1260,7 +1274,7 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1260
1274
|
bookings = this.pickBookingsForCurrentPoint(current, this.normalizeResourceBookings(current, deviceCurrent, matchedBookingList), {
|
|
1261
1275
|
includeAllFuture: true
|
|
1262
1276
|
});
|
|
1263
|
-
completedBookings = completedBookingList.map(function (booking) {
|
|
1277
|
+
completedBookings = this.sortCompletedBookings(completedBookingList).map(function (booking) {
|
|
1264
1278
|
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
1265
1279
|
status: 'compelete',
|
|
1266
1280
|
isTimeout: false,
|
|
@@ -304,10 +304,9 @@ function assertAvailabilityCatalogProductIds(productIds, context) {
|
|
|
304
304
|
});
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
|
-
function normalizeResourceType(
|
|
308
|
-
//
|
|
309
|
-
|
|
310
|
-
return 'single';
|
|
307
|
+
function normalizeResourceType(value) {
|
|
308
|
+
// 预约是否独占与每组选择几个资源是两个独立配置。
|
|
309
|
+
return value === 'multiple' || value === 'capacity' ? value : 'single';
|
|
311
310
|
}
|
|
312
311
|
function resolveProductKind(product) {
|
|
313
312
|
var _product$cartDetailVa, _product$_extend;
|
|
@@ -412,7 +412,7 @@ function normalizeOccupancy(occupancy, coverage, timezoneName, fixedOffsetMinute
|
|
|
412
412
|
};
|
|
413
413
|
}
|
|
414
414
|
function normalizeRequirementGroup(product, requirementGroup) {
|
|
415
|
-
const resourceType = 'single';
|
|
415
|
+
const resourceType = requirementGroup.resourceType === 'multiple' || requirementGroup.resourceType === 'capacity' ? requirementGroup.resourceType : 'single';
|
|
416
416
|
const required = requirementGroup.required !== false;
|
|
417
417
|
const min = required ? 1 : 0;
|
|
418
418
|
return {
|
|
@@ -457,7 +457,7 @@ function normalizeProducts(products) {
|
|
|
457
457
|
function normalizeResources(resources) {
|
|
458
458
|
return resources.map(resource => ({
|
|
459
459
|
...resource,
|
|
460
|
-
resourceType: 'single',
|
|
460
|
+
resourceType: resource.resourceType === 'multiple' || resource.resourceType === 'capacity' ? resource.resourceType : 'single',
|
|
461
461
|
capacity: Math.max(1, Number(resource.capacity || 1) || 1),
|
|
462
462
|
windows: (resource.windows || []).map(window => ({
|
|
463
463
|
...window
|
|
@@ -573,7 +573,8 @@ function buildCells(projection) {
|
|
|
573
573
|
occupancy
|
|
574
574
|
}) => occupancy) : [];
|
|
575
575
|
const usedCapacity = segmentOccupancies.reduce((sum, occupancy) => sum + Math.max(1, Number(occupancy.pax || 1) || 1), 0);
|
|
576
|
-
|
|
576
|
+
// 预约模式来自商品资源组;v2 资源记录可能不包含 type。
|
|
577
|
+
const remainingCapacity = requirementGroup.resourceType === 'single' && segmentOccupancies.length > 0 ? 0 : Math.max(0, resource.capacity - usedCapacity);
|
|
577
578
|
const requiredCapacity = resolveRequiredCapacity(requirementGroup, product);
|
|
578
579
|
const reasonCodes = Array.from(new Set(segmentOccupancies.flatMap(occupancy => {
|
|
579
580
|
const source = occupancy.source || 'remote';
|
|
@@ -607,7 +608,7 @@ function buildCells(projection) {
|
|
|
607
608
|
requirementFormId: requirementGroup.formId,
|
|
608
609
|
resourceId: resource.id,
|
|
609
610
|
resourceName: resource.name,
|
|
610
|
-
resourceType:
|
|
611
|
+
resourceType: requirementGroup.resourceType,
|
|
611
612
|
startAt: formatDateTime(start, timezoneName, fixedOffsetMinutes),
|
|
612
613
|
endAt: formatDateTime(end, timezoneName, fixedOffsetMinutes),
|
|
613
614
|
date: formatDate(start, timezoneName),
|
|
@@ -615,7 +616,7 @@ function buildCells(projection) {
|
|
|
615
616
|
endTime: formatTime(end, timezoneName),
|
|
616
617
|
timezone: projection.meta.timezone,
|
|
617
618
|
status,
|
|
618
|
-
//
|
|
619
|
+
// capacity 表示人数;single 被占用时不再贡献可用容量。
|
|
619
620
|
remainingCapacity,
|
|
620
621
|
maxCapacity: resource.capacity,
|
|
621
622
|
reasonCodes: Array.from(new Set(reasonCodes)),
|
|
@@ -1500,7 +1501,7 @@ function evaluateCandidate(projection, candidate, request) {
|
|
|
1500
1501
|
resourceName: resource.name,
|
|
1501
1502
|
resourceFormId: resource.formId,
|
|
1502
1503
|
policyId: resource.raw?.policy_id,
|
|
1503
|
-
resourceType:
|
|
1504
|
+
resourceType: requirementGroup.resourceType,
|
|
1504
1505
|
status: isPast ? 'past' : 'unavailable',
|
|
1505
1506
|
maxPartySize: 0,
|
|
1506
1507
|
reasonCodes: isPast ? ['past'] : [...(isExcludedScheduleDate ? ['schedule_excluded_date'] : []), 'outside_resource_window']
|
|
@@ -1524,7 +1525,7 @@ function evaluateCandidate(projection, candidate, request) {
|
|
|
1524
1525
|
resourceName: resource.name,
|
|
1525
1526
|
resourceFormId: resource.formId,
|
|
1526
1527
|
policyId: resource.raw?.policy_id,
|
|
1527
|
-
resourceType:
|
|
1528
|
+
resourceType: requirementGroup.resourceType,
|
|
1528
1529
|
status,
|
|
1529
1530
|
remainingCapacity,
|
|
1530
1531
|
maxCapacity,
|
|
@@ -2008,7 +2009,8 @@ function validateAvailabilitySelection(projection, params, runtimeOptions = {})
|
|
|
2008
2009
|
const remainingCapacity = matchedCell?.remainingCapacity;
|
|
2009
2010
|
if (option && (option.status === 'available' || option.status === 'limited') && remainingCapacity !== undefined) {
|
|
2010
2011
|
const capacityPerBooking = normalizedPartySize ?? 1;
|
|
2011
|
-
const
|
|
2012
|
+
const capacityQuantity = Math.max(0, Math.floor(remainingCapacity / capacityPerBooking));
|
|
2013
|
+
const availableQuantity = matchedGroup.resourceType === 'single' ? Math.min(1, capacityQuantity) : capacityQuantity;
|
|
2012
2014
|
if (normalizedBookingCount > availableQuantity) {
|
|
2013
2015
|
conflicts.push({
|
|
2014
2016
|
code: 'resource_capacity_exceeded',
|
|
@@ -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 | 2 | 1 | 6 | 4 | 5 | 3;
|
|
330
330
|
}[]>;
|
|
331
331
|
submitTimeSlot(timeSlots: TimeSliceItem): void;
|
|
332
332
|
private getScheduleDataByIds;
|
|
@@ -339,7 +339,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
339
339
|
* 获取当前的客户搜索条件
|
|
340
340
|
* @returns 当前搜索条件
|
|
341
341
|
*/
|
|
342
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
342
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
343
343
|
/**
|
|
344
344
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
345
345
|
* @returns 客户状态
|
|
@@ -105,6 +105,8 @@ export declare class SalesImpl extends BaseModule implements Module, SalesModule
|
|
|
105
105
|
private groupBookingsByResource;
|
|
106
106
|
private isBookingMatchedResource;
|
|
107
107
|
private sortMatchedBookings;
|
|
108
|
+
/** 已完成:按订单创建时间降序,避免实时追加和重新加载导致显示顺序不同。 */
|
|
109
|
+
private sortCompletedBookings;
|
|
108
110
|
/** Unpaid:与 Current 重合的订单沿用 Current 顺序,其余欠款订单按开始时间降序追加。 */
|
|
109
111
|
private sortUnpaidBookings;
|
|
110
112
|
/**
|
|
@@ -507,6 +507,15 @@ class SalesImpl extends _BaseModule.BaseModule {
|
|
|
507
507
|
});
|
|
508
508
|
}
|
|
509
509
|
|
|
510
|
+
/** 已完成:按订单创建时间降序,避免实时追加和重新加载导致显示顺序不同。 */
|
|
511
|
+
sortCompletedBookings(bookings) {
|
|
512
|
+
const createdAt = booking => {
|
|
513
|
+
const timestamp = (0, _dayjs.default)(booking.order?.created_at || '').valueOf();
|
|
514
|
+
return Number.isFinite(timestamp) ? timestamp : 0;
|
|
515
|
+
};
|
|
516
|
+
return [...bookings].sort((left, right) => createdAt(right) - createdAt(left));
|
|
517
|
+
}
|
|
518
|
+
|
|
510
519
|
/** Unpaid:与 Current 重合的订单沿用 Current 顺序,其余欠款订单按开始时间降序追加。 */
|
|
511
520
|
sortUnpaidBookings(bookings, currentBookings) {
|
|
512
521
|
const currentOrderIndexes = new Map(currentBookings.map((booking, index) => [String(booking.order.order_id), index]));
|
|
@@ -881,7 +890,7 @@ class SalesImpl extends _BaseModule.BaseModule {
|
|
|
881
890
|
const bookings = this.pickBookingsForCurrentPoint(current, this.normalizeResourceBookings(current, deviceCurrent, matchedBookingList), {
|
|
882
891
|
includeAllFuture: true
|
|
883
892
|
});
|
|
884
|
-
const completedBookings = completedBookingList.map(booking => {
|
|
893
|
+
const completedBookings = this.sortCompletedBookings(completedBookingList).map(booking => {
|
|
885
894
|
return {
|
|
886
895
|
...booking,
|
|
887
896
|
status: 'compelete',
|
|
@@ -283,10 +283,9 @@ function assertAvailabilityCatalogProductIds(productIds, context) {
|
|
|
283
283
|
});
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
|
-
function normalizeResourceType(
|
|
287
|
-
//
|
|
288
|
-
|
|
289
|
-
return 'single';
|
|
286
|
+
function normalizeResourceType(value) {
|
|
287
|
+
// 预约是否独占与每组选择几个资源是两个独立配置。
|
|
288
|
+
return value === 'multiple' || value === 'capacity' ? value : 'single';
|
|
290
289
|
}
|
|
291
290
|
function resolveProductKind(product) {
|
|
292
291
|
if (product.duration || product.service_duration) return 'duration';
|