@pisell/pisellos 2.3.151 → 2.3.153
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/solution/BaseSales/index.js +13 -2
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/UnifiedBookingSales/index.d.ts +1 -0
- package/dist/solution/UnifiedBookingSales/index.js +164 -97
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/solution/BaseSales/index.js +5 -0
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/UnifiedBookingSales/index.d.ts +1 -0
- package/lib/solution/UnifiedBookingSales/index.js +36 -1
- package/package.json +1 -1
|
@@ -2698,7 +2698,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2698
2698
|
key: "setServiceType",
|
|
2699
2699
|
value: function () {
|
|
2700
2700
|
var _setServiceType = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(serviceType) {
|
|
2701
|
-
var serviceData;
|
|
2701
|
+
var serviceData, tempOrder;
|
|
2702
2702
|
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
2703
2703
|
while (1) switch (_context22.prev = _context22.next) {
|
|
2704
2704
|
case 0:
|
|
@@ -2712,8 +2712,19 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2712
2712
|
_context22.next = 5;
|
|
2713
2713
|
return this.getFulfillmentItemRulesController().apply(serviceType);
|
|
2714
2714
|
case 5:
|
|
2715
|
+
// 费用规则可能增删商品;即使没有普通促销,也要同步页面的购物车和金额快照。
|
|
2716
|
+
tempOrder = this.getTempOrder();
|
|
2717
|
+
if (!tempOrder) {
|
|
2718
|
+
_context22.next = 9;
|
|
2719
|
+
break;
|
|
2720
|
+
}
|
|
2721
|
+
_context22.next = 9;
|
|
2722
|
+
return this.effectsEmit('onTempOrderReplaced', {
|
|
2723
|
+
tempOrder: tempOrder
|
|
2724
|
+
});
|
|
2725
|
+
case 9:
|
|
2715
2726
|
return _context22.abrupt("return", serviceData);
|
|
2716
|
-
case
|
|
2727
|
+
case 10:
|
|
2717
2728
|
case "end":
|
|
2718
2729
|
return _context22.stop();
|
|
2719
2730
|
}
|
|
@@ -347,7 +347,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
347
347
|
* 获取当前的客户搜索条件
|
|
348
348
|
* @returns 当前搜索条件
|
|
349
349
|
*/
|
|
350
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
350
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
351
351
|
/**
|
|
352
352
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
353
353
|
* @returns 客户状态
|
|
@@ -276,6 +276,7 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
276
276
|
private assertAvailabilityCommitWriteCAS;
|
|
277
277
|
private findProductLineByUid;
|
|
278
278
|
private findLinkedBooking;
|
|
279
|
+
removeBookingProductsOutsideStartDate(startDate: unknown): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
279
280
|
/** Revalidates against the latest landed occupancy cache, then mutates exactly one product line. */
|
|
280
281
|
commitAvailabilitySelection(contextId: string, params: ContextualCommitAvailabilitySelectionParams): Promise<UnifiedBookingSalesCommitAvailabilitySelectionResult>;
|
|
281
282
|
}
|
|
@@ -36,6 +36,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
36
36
|
import dayjs from 'dayjs';
|
|
37
37
|
import { cloneDeep } from 'lodash-es';
|
|
38
38
|
import { OpenDataModule } from "../../modules";
|
|
39
|
+
import { isFulfillmentTimingBooking } from "../../modules/Order/pickupTiming";
|
|
39
40
|
import { isProductFlexibleDuration } from "../../modules/BookingContext/utils";
|
|
40
41
|
import { cacheItemToBookingInput } from "../../modules/BookingContext/utils/cacheItemToBookingInput";
|
|
41
42
|
import { getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings } from "../../modules/OpenData";
|
|
@@ -940,6 +941,20 @@ function getProductLineUid(product) {
|
|
|
940
941
|
var _ref18, _product$metadata$uni, _product$metadata2;
|
|
941
942
|
return String((_ref18 = (_product$metadata$uni = product === null || product === void 0 || (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.unique_identification_number) !== null && _product$metadata$uni !== void 0 ? _product$metadata$uni : product === null || product === void 0 ? void 0 : product.unique_identification_number) !== null && _ref18 !== void 0 ? _ref18 : '');
|
|
942
943
|
}
|
|
944
|
+
function getVisibleCalendarDate(value) {
|
|
945
|
+
if (typeof value !== 'string') return null;
|
|
946
|
+
var raw = value.trim();
|
|
947
|
+
try {
|
|
948
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(raw)) {
|
|
949
|
+
parseLocalDate(raw);
|
|
950
|
+
} else {
|
|
951
|
+
parseLocalDateTime(raw);
|
|
952
|
+
}
|
|
953
|
+
return raw.slice(0, 10);
|
|
954
|
+
} catch (_error) {
|
|
955
|
+
return null;
|
|
956
|
+
}
|
|
957
|
+
}
|
|
943
958
|
export function buildAvailabilityLineIdentity(product) {
|
|
944
959
|
var _product$product_vari;
|
|
945
960
|
return {
|
|
@@ -5144,25 +5159,70 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5144
5159
|
return bookingUid && getBookingUid(booking) === bookingUid || productUid && String((_booking$product_uid3 = booking.product_uid) !== null && _booking$product_uid3 !== void 0 ? _booking$product_uid3 : '') === productUid;
|
|
5145
5160
|
});
|
|
5146
5161
|
}
|
|
5147
|
-
|
|
5148
|
-
|
|
5162
|
+
}, {
|
|
5163
|
+
key: "removeBookingProductsOutsideStartDate",
|
|
5164
|
+
value: function () {
|
|
5165
|
+
var _removeBookingProductsOutsideStartDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(startDate) {
|
|
5166
|
+
var _this$getTempOrder4,
|
|
5167
|
+
_this$otherParams27,
|
|
5168
|
+
_this14 = this;
|
|
5169
|
+
var products, targetDate, identities;
|
|
5170
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context48) {
|
|
5171
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
5172
|
+
case 0:
|
|
5173
|
+
products = ((_this$getTempOrder4 = this.getTempOrder()) === null || _this$getTempOrder4 === void 0 ? void 0 : _this$getTempOrder4.products) || [];
|
|
5174
|
+
if (!(((_this$otherParams27 = this.otherParams) === null || _this$otherParams27 === void 0 ? void 0 : _this$otherParams27.enforceSingleBookingStartDate) !== true)) {
|
|
5175
|
+
_context48.next = 3;
|
|
5176
|
+
break;
|
|
5177
|
+
}
|
|
5178
|
+
return _context48.abrupt("return", products);
|
|
5179
|
+
case 3:
|
|
5180
|
+
targetDate = getVisibleCalendarDate(startDate);
|
|
5181
|
+
if (targetDate) {
|
|
5182
|
+
_context48.next = 6;
|
|
5183
|
+
break;
|
|
5184
|
+
}
|
|
5185
|
+
return _context48.abrupt("return", products);
|
|
5186
|
+
case 6:
|
|
5187
|
+
identities = products.flatMap(function (product) {
|
|
5188
|
+
var _product$metadata7;
|
|
5189
|
+
if (!getProductLineUid(product) || (product === null || product === void 0 || (_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.product_add_schedule_time) != null) {
|
|
5190
|
+
return [];
|
|
5191
|
+
}
|
|
5192
|
+
var booking = _this14.findLinkedBooking(product);
|
|
5193
|
+
if (!booking || isFulfillmentTimingBooking(booking)) return [];
|
|
5194
|
+
var bookingDate = getVisibleCalendarDate(booking.start_date);
|
|
5195
|
+
return bookingDate && bookingDate !== targetDate ? [buildAvailabilityLineIdentity(product)] : [];
|
|
5196
|
+
});
|
|
5197
|
+
return _context48.abrupt("return", identities.length ? this.removeProductsFromOrder(identities) : products);
|
|
5198
|
+
case 8:
|
|
5199
|
+
case "end":
|
|
5200
|
+
return _context48.stop();
|
|
5201
|
+
}
|
|
5202
|
+
}, _callee48, this);
|
|
5203
|
+
}));
|
|
5204
|
+
function removeBookingProductsOutsideStartDate(_x36) {
|
|
5205
|
+
return _removeBookingProductsOutsideStartDate.apply(this, arguments);
|
|
5206
|
+
}
|
|
5207
|
+
return removeBookingProductsOutsideStartDate;
|
|
5208
|
+
}() /** Revalidates against the latest landed occupancy cache, then mutates exactly one product line. */
|
|
5149
5209
|
}, {
|
|
5150
5210
|
key: "commitAvailabilitySelection",
|
|
5151
5211
|
value: (function () {
|
|
5152
|
-
var _commitAvailabilitySelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5212
|
+
var _commitAvailabilitySelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(contextId, params) {
|
|
5153
5213
|
var _this$otherParams$pla4,
|
|
5154
|
-
_this$
|
|
5214
|
+
_this$otherParams28,
|
|
5155
5215
|
_params$availabilityC,
|
|
5156
5216
|
_this$store$order11,
|
|
5157
5217
|
_this$store$order11$e,
|
|
5158
|
-
|
|
5159
|
-
var normalizedContextId, isRememberedSelection, hasCommitGuard, rememberedOrder, getRememberedCommitIdentity, rememberedCommitIdentity, availabilityCommitTargetGuard, guardedCommitPublished, _params$bookingCount, _ref55, _params$orderProduct$, _params$orderProduct, _params$orderProduct2, _params$orderProduct3, _params$orderProduct$2, _params$orderProduct4, _params$orderProduct5, _editingLine$product_, _this$otherParams$pla5, _this$
|
|
5160
|
-
return _regeneratorRuntime().wrap(function
|
|
5161
|
-
while (1) switch (
|
|
5218
|
+
_this15 = this;
|
|
5219
|
+
var normalizedContextId, isRememberedSelection, hasCommitGuard, rememberedOrder, getRememberedCommitIdentity, rememberedCommitIdentity, availabilityCommitTargetGuard, guardedCommitPublished, _params$bookingCount, _ref55, _params$orderProduct$, _params$orderProduct, _params$orderProduct2, _params$orderProduct3, _params$orderProduct$2, _params$orderProduct4, _params$orderProduct5, _editingLine$product_, _this$otherParams$pla5, _this$otherParams29, _baseProjection$meta$, _refreshedProjection$, _baseProjection$meta$2, _this$otherParams$pla6, _this$otherParams30, _ref56, _params$orderProduct$3, _params$orderProduct6, _existingBooking$meta, _ref57, _ref58, _params$orderProduct$4, _params$orderProduct7, _params$orderProduct8, _existingBooking$meta2, _existingBooking$hold, _params$orderProduct9, _nextContext$activeVe, bookingCount, orderProductQuantity, partySize, _yield$this$ensureAva3, context, projectionEntry, refreshed, boundEditingUids, orderProductId, editingLine, _editingLine$product_2, baseProjection, selectedProduct, commitWriteGuard, prepareParams, fallbackResources, commitSnapshot, refreshedProjection, _baseProjection$meta$3, latestContext, candidateDurationMinutes, candidateStartTime, allowPosAvailabilityOverride, candidateBusinessDate, refreshedRanges, refreshedCandidateBase, product, validation, forced, capacityConflict, revalidationEntry, revalidatedContext, refreshedCandidate, availabilityCommitGuard, existingBooking, existingBookingUid, booking, legacyBooking, legacyResources, selectedResources, resourceKeys, transformed, productLineUid, bookingUid, productLineUids, bookingUids, _transformed$product_, _transformed$product_2, _transformed$product_3, _ref59, _transformed$product_4, _this$getTempOrder5, _this$getTempOrder6, _params$salesNotes, _params$salesNotes2, _ref60, beforeProductLineUids, beforeBookingUids, products, addedLines, addedBookings, targetStillCurrent, nextContext, result, emit, release;
|
|
5220
|
+
return _regeneratorRuntime().wrap(function _callee49$(_context49) {
|
|
5221
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
5162
5222
|
case 0:
|
|
5163
5223
|
normalizedContextId = String(contextId || '').trim();
|
|
5164
5224
|
if (normalizedContextId) {
|
|
5165
|
-
|
|
5225
|
+
_context49.next = 3;
|
|
5166
5226
|
break;
|
|
5167
5227
|
}
|
|
5168
5228
|
throw new AvailabilityError('INVALID_TARGET_FILTER', 'commitAvailabilitySelection 缺少 contextId', {
|
|
@@ -5170,8 +5230,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5170
5230
|
});
|
|
5171
5231
|
case 3:
|
|
5172
5232
|
isRememberedSelection = params.selectionIntent === 'remembered';
|
|
5173
|
-
if (!(isRememberedSelection && (String((_this$otherParams$pla4 = (_this$
|
|
5174
|
-
|
|
5233
|
+
if (!(isRememberedSelection && (String((_this$otherParams$pla4 = (_this$otherParams28 = this.otherParams) === null || _this$otherParams28 === void 0 ? void 0 : _this$otherParams28.platform) !== null && _this$otherParams$pla4 !== void 0 ? _this$otherParams$pla4 : '').trim().toLowerCase() !== 'pos' || params.mode !== 'add'))) {
|
|
5234
|
+
_context49.next = 6;
|
|
5175
5235
|
break;
|
|
5176
5236
|
}
|
|
5177
5237
|
throw new AvailabilityError('INVALID_TARGET_FILTER', '记忆时间自动提交仅支持 POS 新增 duration 商品');
|
|
@@ -5182,27 +5242,27 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5182
5242
|
if (hasCommitGuard) (_this$store$order11 = this.store.order) === null || _this$store$order11 === void 0 || (_this$store$order11$e = _this$store$order11.ensureTempOrder) === null || _this$store$order11$e === void 0 || _this$store$order11$e.call(_this$store$order11);
|
|
5183
5243
|
rememberedOrder = hasCommitGuard ? this.getTempOrder() : null;
|
|
5184
5244
|
getRememberedCommitIdentity = function getRememberedCommitIdentity() {
|
|
5185
|
-
var
|
|
5245
|
+
var _this15$otherParams$s, _this15$otherParams, _this15$otherParams2, _this15$core, _this15$getTempOrder, _this15$getTempOrder2;
|
|
5186
5246
|
return JSON.stringify(stableValue({
|
|
5187
|
-
scope:
|
|
5188
|
-
shopId: (
|
|
5189
|
-
contextShopId: (
|
|
5190
|
-
orderId: (
|
|
5191
|
-
externalSaleNumber: (
|
|
5247
|
+
scope: _this15.getAvailabilityScopeDescriptor(),
|
|
5248
|
+
shopId: (_this15$otherParams$s = (_this15$otherParams = _this15.otherParams) === null || _this15$otherParams === void 0 ? void 0 : _this15$otherParams.shop_id) !== null && _this15$otherParams$s !== void 0 ? _this15$otherParams$s : (_this15$otherParams2 = _this15.otherParams) === null || _this15$otherParams2 === void 0 ? void 0 : _this15$otherParams2.shopId,
|
|
5249
|
+
contextShopId: (_this15$core = _this15.core) === null || _this15$core === void 0 || (_this15$core = _this15$core.context) === null || _this15$core === void 0 ? void 0 : _this15$core.shop_id,
|
|
5250
|
+
orderId: (_this15$getTempOrder = _this15.getTempOrder()) === null || _this15$getTempOrder === void 0 ? void 0 : _this15$getTempOrder.order_id,
|
|
5251
|
+
externalSaleNumber: (_this15$getTempOrder2 = _this15.getTempOrder()) === null || _this15$getTempOrder2 === void 0 ? void 0 : _this15$getTempOrder2.external_sale_number
|
|
5192
5252
|
}));
|
|
5193
5253
|
};
|
|
5194
5254
|
rememberedCommitIdentity = hasCommitGuard ? getRememberedCommitIdentity() : '';
|
|
5195
5255
|
availabilityCommitTargetGuard = function availabilityCommitTargetGuard() {
|
|
5196
|
-
return
|
|
5256
|
+
return _this15.getTempOrder() === rememberedOrder && getRememberedCommitIdentity() === rememberedCommitIdentity;
|
|
5197
5257
|
};
|
|
5198
5258
|
guardedCommitPublished = false;
|
|
5199
|
-
|
|
5259
|
+
_context49.next = 16;
|
|
5200
5260
|
return this.tryAcquireAvailabilityCommitLock(normalizedContextId);
|
|
5201
5261
|
case 16:
|
|
5202
|
-
|
|
5262
|
+
_context49.prev = 16;
|
|
5203
5263
|
bookingCount = Number((_params$bookingCount = params.bookingCount) !== null && _params$bookingCount !== void 0 ? _params$bookingCount : 1);
|
|
5204
5264
|
if (!(!Number.isInteger(bookingCount) || bookingCount <= 0)) {
|
|
5205
|
-
|
|
5265
|
+
_context49.next = 20;
|
|
5206
5266
|
break;
|
|
5207
5267
|
}
|
|
5208
5268
|
throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', 'bookingCount 必须是正整数', {
|
|
@@ -5210,7 +5270,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5210
5270
|
});
|
|
5211
5271
|
case 20:
|
|
5212
5272
|
if (!(params.mode === 'edit' && bookingCount !== 1)) {
|
|
5213
|
-
|
|
5273
|
+
_context49.next = 22;
|
|
5214
5274
|
break;
|
|
5215
5275
|
}
|
|
5216
5276
|
throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', '编辑预约商品时 bookingCount 必须为 1', {
|
|
@@ -5219,7 +5279,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5219
5279
|
case 22:
|
|
5220
5280
|
orderProductQuantity = (_ref55 = (_params$orderProduct$ = (_params$orderProduct = params.orderProduct) === null || _params$orderProduct === void 0 ? void 0 : _params$orderProduct.num) !== null && _params$orderProduct$ !== void 0 ? _params$orderProduct$ : (_params$orderProduct2 = params.orderProduct) === null || _params$orderProduct2 === void 0 ? void 0 : _params$orderProduct2.quantity) !== null && _ref55 !== void 0 ? _ref55 : (_params$orderProduct3 = params.orderProduct) === null || _params$orderProduct3 === void 0 || (_params$orderProduct3 = _params$orderProduct3._extend) === null || _params$orderProduct3 === void 0 ? void 0 : _params$orderProduct3.quantity;
|
|
5221
5281
|
if (!(orderProductQuantity !== undefined && orderProductQuantity !== null && Number(orderProductQuantity) !== bookingCount)) {
|
|
5222
|
-
|
|
5282
|
+
_context49.next = 25;
|
|
5223
5283
|
break;
|
|
5224
5284
|
}
|
|
5225
5285
|
throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', 'orderProduct 数量与 bookingCount 不一致', {
|
|
@@ -5229,22 +5289,22 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5229
5289
|
case 25:
|
|
5230
5290
|
partySize = Number(params.partySize);
|
|
5231
5291
|
if (!(!Number.isInteger(partySize) || partySize <= 0)) {
|
|
5232
|
-
|
|
5292
|
+
_context49.next = 28;
|
|
5233
5293
|
break;
|
|
5234
5294
|
}
|
|
5235
5295
|
throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', 'partySize 必须是正整数', {
|
|
5236
5296
|
partySize: params.partySize
|
|
5237
5297
|
});
|
|
5238
5298
|
case 28:
|
|
5239
|
-
|
|
5299
|
+
_context49.next = 30;
|
|
5240
5300
|
return this.ensureAvailabilityContextProjection(normalizedContextId, 'commit_precheck');
|
|
5241
5301
|
case 30:
|
|
5242
|
-
_yield$this$ensureAva3 =
|
|
5302
|
+
_yield$this$ensureAva3 = _context49.sent;
|
|
5243
5303
|
context = _yield$this$ensureAva3.context;
|
|
5244
5304
|
projectionEntry = _yield$this$ensureAva3.projectionEntry;
|
|
5245
5305
|
refreshed = _yield$this$ensureAva3.refreshed;
|
|
5246
5306
|
if (!refreshed) {
|
|
5247
|
-
|
|
5307
|
+
_context49.next = 36;
|
|
5248
5308
|
break;
|
|
5249
5309
|
}
|
|
5250
5310
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'availability context 已刷新,请重新获取候选', {
|
|
@@ -5255,11 +5315,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5255
5315
|
case 36:
|
|
5256
5316
|
boundEditingUids = context.prepareParams.editingProductLineUids || [];
|
|
5257
5317
|
if (!(params.mode === 'edit')) {
|
|
5258
|
-
|
|
5318
|
+
_context49.next = 42;
|
|
5259
5319
|
break;
|
|
5260
5320
|
}
|
|
5261
5321
|
if (!(!params.productLineUid || !boundEditingUids.includes(String(params.productLineUid)))) {
|
|
5262
|
-
|
|
5322
|
+
_context49.next = 40;
|
|
5263
5323
|
break;
|
|
5264
5324
|
}
|
|
5265
5325
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'edit context 与当前商品行不匹配,请重新 prepare 编辑上下文', {
|
|
@@ -5268,11 +5328,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5268
5328
|
editingProductLineUids: boundEditingUids
|
|
5269
5329
|
});
|
|
5270
5330
|
case 40:
|
|
5271
|
-
|
|
5331
|
+
_context49.next = 44;
|
|
5272
5332
|
break;
|
|
5273
5333
|
case 42:
|
|
5274
5334
|
if (!(boundEditingUids.length > 0)) {
|
|
5275
|
-
|
|
5335
|
+
_context49.next = 44;
|
|
5276
5336
|
break;
|
|
5277
5337
|
}
|
|
5278
5338
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'edit context 不能用于 add,请重新 prepare 新增上下文', {
|
|
@@ -5281,7 +5341,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5281
5341
|
});
|
|
5282
5342
|
case 44:
|
|
5283
5343
|
if (!(projectionEntry.contextVersion !== context.activeVersion)) {
|
|
5284
|
-
|
|
5344
|
+
_context49.next = 46;
|
|
5285
5345
|
break;
|
|
5286
5346
|
}
|
|
5287
5347
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'availability context 已刷新,请重新获取候选', {
|
|
@@ -5291,7 +5351,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5291
5351
|
});
|
|
5292
5352
|
case 46:
|
|
5293
5353
|
if (!(projectionEntry.orderRevision !== this.getCurrentOrderRevision())) {
|
|
5294
|
-
|
|
5354
|
+
_context49.next = 48;
|
|
5295
5355
|
break;
|
|
5296
5356
|
}
|
|
5297
5357
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '购物车已变化,请重新获取候选', {
|
|
@@ -5302,7 +5362,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5302
5362
|
});
|
|
5303
5363
|
case 48:
|
|
5304
5364
|
if (!(projectionEntry.contextVersion !== params.candidate.availabilityContextVersion)) {
|
|
5305
|
-
|
|
5365
|
+
_context49.next = 50;
|
|
5306
5366
|
break;
|
|
5307
5367
|
}
|
|
5308
5368
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '候选已过期,请重新获取最新时间段', {
|
|
@@ -5314,7 +5374,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5314
5374
|
this.assertAvailabilityCandidateFreshness(context, params.candidate);
|
|
5315
5375
|
orderProductId = (_params$orderProduct$2 = (_params$orderProduct4 = params.orderProduct) === null || _params$orderProduct4 === void 0 ? void 0 : _params$orderProduct4.product_id) !== null && _params$orderProduct$2 !== void 0 ? _params$orderProduct$2 : (_params$orderProduct5 = params.orderProduct) === null || _params$orderProduct5 === void 0 ? void 0 : _params$orderProduct5.id;
|
|
5316
5376
|
if (sameAvailabilityId(orderProductId, params.candidate.productId)) {
|
|
5317
|
-
|
|
5377
|
+
_context49.next = 54;
|
|
5318
5378
|
break;
|
|
5319
5379
|
}
|
|
5320
5380
|
throw new AvailabilityError('INVALID_TARGET_FILTER', 'orderProduct 与 candidate 商品不一致', {
|
|
@@ -5323,14 +5383,14 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5323
5383
|
});
|
|
5324
5384
|
case 54:
|
|
5325
5385
|
if (!(params.mode === 'edit' && !params.productLineUid)) {
|
|
5326
|
-
|
|
5386
|
+
_context49.next = 56;
|
|
5327
5387
|
break;
|
|
5328
5388
|
}
|
|
5329
5389
|
throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', 'edit 模式必须提供 productLineUid');
|
|
5330
5390
|
case 56:
|
|
5331
5391
|
editingLine = params.mode === 'edit' ? this.findProductLineByUid(String(params.productLineUid)) : undefined;
|
|
5332
5392
|
if (!(params.mode === 'edit' && !editingLine)) {
|
|
5333
|
-
|
|
5393
|
+
_context49.next = 59;
|
|
5334
5394
|
break;
|
|
5335
5395
|
}
|
|
5336
5396
|
throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', '找不到要编辑的预约商品行', {
|
|
@@ -5338,7 +5398,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5338
5398
|
});
|
|
5339
5399
|
case 59:
|
|
5340
5400
|
if (!(editingLine && !sameAvailabilityId((_editingLine$product_ = editingLine.product_id) !== null && _editingLine$product_ !== void 0 ? _editingLine$product_ : editingLine.id, params.candidate.productId))) {
|
|
5341
|
-
|
|
5401
|
+
_context49.next = 61;
|
|
5342
5402
|
break;
|
|
5343
5403
|
}
|
|
5344
5404
|
throw new AvailabilityError('INVALID_TARGET_FILTER', '编辑商品行与 candidate 商品不一致', {
|
|
@@ -5348,7 +5408,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5348
5408
|
});
|
|
5349
5409
|
case 61:
|
|
5350
5410
|
if (Array.isArray(params.requirementSelections)) {
|
|
5351
|
-
|
|
5411
|
+
_context49.next = 63;
|
|
5352
5412
|
break;
|
|
5353
5413
|
}
|
|
5354
5414
|
throw new AvailabilityError('INVALID_TARGET_FILTER', 'requirementSelections 必须是数组', {
|
|
@@ -5359,8 +5419,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5359
5419
|
selectedProduct = baseProjection.products.find(function (item) {
|
|
5360
5420
|
return sameAvailabilityId(item.id, params.candidate.productId);
|
|
5361
5421
|
});
|
|
5362
|
-
if (!(isRememberedSelection && (String((_this$otherParams$pla5 = (_this$
|
|
5363
|
-
|
|
5422
|
+
if (!(isRememberedSelection && (String((_this$otherParams$pla5 = (_this$otherParams29 = this.otherParams) === null || _this$otherParams29 === void 0 ? void 0 : _this$otherParams29.platform) !== null && _this$otherParams$pla5 !== void 0 ? _this$otherParams$pla5 : '').trim().toLowerCase() !== 'pos' || params.mode !== 'add' || (selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.kind) !== 'duration'))) {
|
|
5423
|
+
_context49.next = 67;
|
|
5364
5424
|
break;
|
|
5365
5425
|
}
|
|
5366
5426
|
throw new AvailabilityError('INVALID_TARGET_FILTER', '记忆时间自动提交仅支持 POS 新增 duration 商品');
|
|
@@ -5374,7 +5434,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5374
5434
|
};
|
|
5375
5435
|
prepareParams = baseProjection.meta.prepareParams;
|
|
5376
5436
|
if (prepareParams) {
|
|
5377
|
-
|
|
5437
|
+
_context49.next = 71;
|
|
5378
5438
|
break;
|
|
5379
5439
|
}
|
|
5380
5440
|
throw new AvailabilityError('REVALIDATION_FAILED', 'projection 缺少 prepareParams,无法执行缓存重校验');
|
|
@@ -5386,7 +5446,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5386
5446
|
})),
|
|
5387
5447
|
includesInjectedRawOccupancies: true
|
|
5388
5448
|
};
|
|
5389
|
-
|
|
5449
|
+
_context49.next = 74;
|
|
5390
5450
|
return this.buildAvailabilityProjectionSnapshot(_objectSpread(_objectSpread({}, this.cloneAvailabilityPrepareParams(prepareParams)), {}, {
|
|
5391
5451
|
editingProductLineUids: params.mode === 'edit' && params.productLineUid ? [params.productLineUid] : []
|
|
5392
5452
|
}), {
|
|
@@ -5395,13 +5455,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5395
5455
|
durationCandidateAnchorAt: this.getAvailabilityDurationCandidateAnchorAt(baseProjection) || context.durationCandidateAnchorAt
|
|
5396
5456
|
});
|
|
5397
5457
|
case 74:
|
|
5398
|
-
commitSnapshot =
|
|
5458
|
+
commitSnapshot = _context49.sent;
|
|
5399
5459
|
refreshedProjection = commitSnapshot.projection;
|
|
5400
5460
|
if (!(String((_refreshedProjection$ = refreshedProjection.meta.orderRevision) !== null && _refreshedProjection$ !== void 0 ? _refreshedProjection$ : '') !== String((_baseProjection$meta$2 = baseProjection.meta.orderRevision) !== null && _baseProjection$meta$2 !== void 0 ? _baseProjection$meta$2 : ''))) {
|
|
5401
|
-
|
|
5461
|
+
_context49.next = 81;
|
|
5402
5462
|
break;
|
|
5403
5463
|
}
|
|
5404
|
-
|
|
5464
|
+
_context49.next = 79;
|
|
5405
5465
|
return this.refreshAvailabilityContextProjection({
|
|
5406
5466
|
contextId: normalizedContextId,
|
|
5407
5467
|
reason: 'commit_order_revision_changed',
|
|
@@ -5422,7 +5482,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5422
5482
|
this.assertAvailabilityCommitWriteCAS(commitWriteGuard);
|
|
5423
5483
|
candidateDurationMinutes = getCandidateDurationMinutes(params.candidate);
|
|
5424
5484
|
candidateStartTime = getCandidateStartTime(params.candidate);
|
|
5425
|
-
allowPosAvailabilityOverride = String((_this$otherParams$pla6 = (_this$
|
|
5485
|
+
allowPosAvailabilityOverride = String((_this$otherParams$pla6 = (_this$otherParams30 = this.otherParams) === null || _this$otherParams30 === void 0 ? void 0 : _this$otherParams30.platform) !== null && _this$otherParams$pla6 !== void 0 ? _this$otherParams$pla6 : '').trim().toLowerCase() === 'pos' && !isRememberedSelection;
|
|
5426
5486
|
candidateBusinessDate = params.candidate.businessDate || ((selectedProduct === null || selectedProduct === void 0 ? void 0 : selectedProduct.kind) === 'duration' && this.usesDurationTimeGrid(refreshedProjection) ? getDurationBusinessDate(refreshedProjection, params.candidate.startAt) : params.candidate.startAt.slice(0, 10));
|
|
5427
5487
|
refreshedRanges = getProjectionProductTimeRanges(refreshedProjection, _objectSpread({
|
|
5428
5488
|
productIds: [params.candidate.productId],
|
|
@@ -5456,7 +5516,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5456
5516
|
return candidate.startAt === params.candidate.startAt && candidate.endAt === params.candidate.endAt && candidate.bookingStartAt === params.candidate.bookingStartAt && candidate.bookingEndAt === params.candidate.bookingEndAt;
|
|
5457
5517
|
});
|
|
5458
5518
|
if (refreshedCandidateBase) {
|
|
5459
|
-
|
|
5519
|
+
_context49.next = 90;
|
|
5460
5520
|
break;
|
|
5461
5521
|
}
|
|
5462
5522
|
throw new AvailabilityError('REVALIDATION_FAILED', '缓存重校验后候选时间已不在商品配置中', {
|
|
@@ -5469,7 +5529,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5469
5529
|
return sameAvailabilityId(item.id, refreshedCandidateBase.productId);
|
|
5470
5530
|
});
|
|
5471
5531
|
if (product) {
|
|
5472
|
-
|
|
5532
|
+
_context49.next = 93;
|
|
5473
5533
|
break;
|
|
5474
5534
|
}
|
|
5475
5535
|
throw new AvailabilityError('REVALIDATION_FAILED', '缓存重校验后商品不在 projection 中', {
|
|
@@ -5508,7 +5568,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5508
5568
|
});
|
|
5509
5569
|
}
|
|
5510
5570
|
if (validation.ok) {
|
|
5511
|
-
|
|
5571
|
+
_context49.next = 98;
|
|
5512
5572
|
break;
|
|
5513
5573
|
}
|
|
5514
5574
|
capacityConflict = validation.conflicts.find(function (conflict) {
|
|
@@ -5531,7 +5591,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5531
5591
|
incrementVersion: true
|
|
5532
5592
|
});
|
|
5533
5593
|
revalidatedContext = this.getAvailabilityContextEntry(normalizedContextId);
|
|
5534
|
-
|
|
5594
|
+
_context49.next = 102;
|
|
5535
5595
|
return this.emitAvailabilityDiagnostic({
|
|
5536
5596
|
action: 'refresh',
|
|
5537
5597
|
contextId: normalizedContextId,
|
|
@@ -5555,9 +5615,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5555
5615
|
availabilityCommitGuard = hasCommitGuard ? function () {
|
|
5556
5616
|
var _params$availabilityC2;
|
|
5557
5617
|
(_params$availabilityC2 = params.availabilityCommitGuard) === null || _params$availabilityC2 === void 0 || _params$availabilityC2.call(params);
|
|
5558
|
-
|
|
5618
|
+
_this15.assertAvailabilityCommitWriteCAS(commitWriteGuard);
|
|
5559
5619
|
if (!availabilityCommitTargetGuard()) {
|
|
5560
|
-
throw
|
|
5620
|
+
throw _this15.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '记忆时间加购期间订单或业务已变化');
|
|
5561
5621
|
}
|
|
5562
5622
|
if (!isRememberedSelection) return;
|
|
5563
5623
|
var currentValidation = validateAvailabilitySelection(refreshedProjection, {
|
|
@@ -5578,7 +5638,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5578
5638
|
existingBooking = editingLine ? this.findLinkedBooking(editingLine) : undefined;
|
|
5579
5639
|
existingBookingUid = existingBooking ? getBookingUid(existingBooking) : '';
|
|
5580
5640
|
if (!(params.mode === 'edit' && !existingBookingUid)) {
|
|
5581
|
-
|
|
5641
|
+
_context49.next = 109;
|
|
5582
5642
|
break;
|
|
5583
5643
|
}
|
|
5584
5644
|
throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', '编辑商品行缺少关联 booking', {
|
|
@@ -5596,7 +5656,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5596
5656
|
holderIds: (_ref57 = (_ref58 = (_params$orderProduct$4 = (_params$orderProduct7 = params.orderProduct) === null || _params$orderProduct7 === void 0 || (_params$orderProduct7 = _params$orderProduct7._extend) === null || _params$orderProduct7 === void 0 ? void 0 : _params$orderProduct7.holder_id) !== null && _params$orderProduct$4 !== void 0 ? _params$orderProduct$4 : (_params$orderProduct8 = params.orderProduct) === null || _params$orderProduct8 === void 0 || (_params$orderProduct8 = _params$orderProduct8._extend) === null || _params$orderProduct8 === void 0 || (_params$orderProduct8 = _params$orderProduct8.holder) === null || _params$orderProduct8 === void 0 ? void 0 : _params$orderProduct8.form_record) !== null && _ref58 !== void 0 ? _ref58 : existingBooking === null || existingBooking === void 0 || (_existingBooking$meta2 = existingBooking.metadata) === null || _existingBooking$meta2 === void 0 ? void 0 : _existingBooking$meta2.holder_id) !== null && _ref57 !== void 0 ? _ref57 : existingBooking === null || existingBooking === void 0 || (_existingBooking$hold = existingBooking.holder) === null || _existingBooking$hold === void 0 ? void 0 : _existingBooking$hold.form_record
|
|
5597
5657
|
});
|
|
5598
5658
|
if (!(isRememberedSelection && (_params$orderProduct9 = params.orderProduct) !== null && _params$orderProduct9 !== void 0 && (_params$orderProduct9 = _params$orderProduct9._extend) !== null && _params$orderProduct9 !== void 0 && _params$orderProduct9.resource)) {
|
|
5599
|
-
|
|
5659
|
+
_context49.next = 119;
|
|
5600
5660
|
break;
|
|
5601
5661
|
}
|
|
5602
5662
|
// AutoClose 与编辑共用旧资源协议。仅复用其结构,实际资源及每份容量
|
|
@@ -5616,7 +5676,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5616
5676
|
return sameAvailabilityId(selected.form_id, resource.form_id);
|
|
5617
5677
|
});
|
|
5618
5678
|
}))) {
|
|
5619
|
-
|
|
5679
|
+
_context49.next = 118;
|
|
5620
5680
|
break;
|
|
5621
5681
|
}
|
|
5622
5682
|
throw new AvailabilityError('REVALIDATION_FAILED', '记忆时间的资源与本次校验结果不一致');
|
|
@@ -5633,7 +5693,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5633
5693
|
quantity: bookingCount
|
|
5634
5694
|
}), 'unified_booking_sales', product);
|
|
5635
5695
|
if (transformed) {
|
|
5636
|
-
|
|
5696
|
+
_context49.next = 122;
|
|
5637
5697
|
break;
|
|
5638
5698
|
}
|
|
5639
5699
|
throw new AvailabilityError('INVALID_TARGET_FILTER', 'orderProduct 无法转换为订单行', {
|
|
@@ -5652,7 +5712,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5652
5712
|
productLineUids = [];
|
|
5653
5713
|
bookingUids = [];
|
|
5654
5714
|
if (!(params.mode === 'edit' && editingLine && params.productLineUid)) {
|
|
5655
|
-
|
|
5715
|
+
_context49.next = 143;
|
|
5656
5716
|
break;
|
|
5657
5717
|
}
|
|
5658
5718
|
transformed.product_sku = (_transformed$product_ = transformed.product_sku) !== null && _transformed$product_ !== void 0 ? _transformed$product_ : editingLine.product_sku;
|
|
@@ -5662,7 +5722,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5662
5722
|
unique_identification_number: params.productLineUid,
|
|
5663
5723
|
booking_uid: existingBookingUid
|
|
5664
5724
|
});
|
|
5665
|
-
|
|
5725
|
+
_context49.next = 135;
|
|
5666
5726
|
return this.updateOrderProduct(_objectSpread(_objectSpread({
|
|
5667
5727
|
product_id: (_transformed$product_3 = transformed.product_id) !== null && _transformed$product_3 !== void 0 ? _transformed$product_3 : editingLine.product_id,
|
|
5668
5728
|
product_variant_id: (_ref59 = (_transformed$product_4 = transformed.product_variant_id) !== null && _transformed$product_4 !== void 0 ? _transformed$product_4 : editingLine.product_variant_id) !== null && _ref59 !== void 0 ? _ref59 : 0,
|
|
@@ -5675,29 +5735,36 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5675
5735
|
allow_booking_discount_reapply: params.allowBookingDiscountReapply
|
|
5676
5736
|
} : {}));
|
|
5677
5737
|
case 135:
|
|
5738
|
+
_context49.next = 137;
|
|
5739
|
+
return this.removeBookingProductsOutsideStartDate(booking.start_date);
|
|
5740
|
+
case 137:
|
|
5678
5741
|
productLineUid = params.productLineUid;
|
|
5679
5742
|
bookingUid = existingBookingUid;
|
|
5680
5743
|
productLineUids = [productLineUid];
|
|
5681
5744
|
bookingUids = [bookingUid];
|
|
5682
|
-
|
|
5745
|
+
_context49.next = 160;
|
|
5683
5746
|
break;
|
|
5684
|
-
case
|
|
5685
|
-
beforeProductLineUids = new Set((((_this$
|
|
5747
|
+
case 143:
|
|
5748
|
+
beforeProductLineUids = new Set((((_this$getTempOrder5 = this.getTempOrder()) === null || _this$getTempOrder5 === void 0 ? void 0 : _this$getTempOrder5.products) || []).map(function (line) {
|
|
5686
5749
|
return getProductLineUid(line);
|
|
5687
5750
|
}).filter(Boolean));
|
|
5688
|
-
beforeBookingUids = new Set((((_this$
|
|
5751
|
+
beforeBookingUids = new Set((((_this$getTempOrder6 = this.getTempOrder()) === null || _this$getTempOrder6 === void 0 ? void 0 : _this$getTempOrder6.bookings) || []).map(function (item) {
|
|
5689
5752
|
return getBookingUid(item);
|
|
5690
5753
|
}).filter(Boolean));
|
|
5691
5754
|
availabilityCommitGuard === null || availabilityCommitGuard === void 0 || availabilityCommitGuard();
|
|
5692
|
-
|
|
5755
|
+
_context49.next = 148;
|
|
5693
5756
|
return this.addProductToOrder(transformed, booking, (_params$salesNotes = params.salesNotes) !== null && _params$salesNotes !== void 0 && _params$salesNotes.length || availabilityCommitGuard ? _objectSpread(_objectSpread({}, (_params$salesNotes2 = params.salesNotes) !== null && _params$salesNotes2 !== void 0 && _params$salesNotes2.length ? {
|
|
5694
5757
|
salesNotes: params.salesNotes
|
|
5695
5758
|
} : {}), availabilityCommitGuard ? {
|
|
5696
5759
|
availabilityCommitGuard: availabilityCommitGuard,
|
|
5697
5760
|
availabilityCommitTargetGuard: availabilityCommitTargetGuard
|
|
5698
5761
|
} : {}) : undefined);
|
|
5699
|
-
case
|
|
5700
|
-
products =
|
|
5762
|
+
case 148:
|
|
5763
|
+
products = _context49.sent;
|
|
5764
|
+
_context49.next = 151;
|
|
5765
|
+
return this.removeBookingProductsOutsideStartDate(booking.start_date);
|
|
5766
|
+
case 151:
|
|
5767
|
+
products = _context49.sent;
|
|
5701
5768
|
guardedCommitPublished = hasCommitGuard;
|
|
5702
5769
|
addedLines = products.filter(function (line) {
|
|
5703
5770
|
var _line$product_id, _line$metadata;
|
|
@@ -5721,7 +5788,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5721
5788
|
}
|
|
5722
5789
|
productLineUid = productLineUids[productLineUids.length - 1] || '';
|
|
5723
5790
|
bookingUid = bookingUids[bookingUids.length - 1] || '';
|
|
5724
|
-
case
|
|
5791
|
+
case 160:
|
|
5725
5792
|
targetStillCurrent = !hasCommitGuard || availabilityCommitTargetGuard();
|
|
5726
5793
|
if (targetStillCurrent) this.invalidateAvailabilityContextsAfterCommit();else this.removeAvailabilityContext(normalizedContextId);
|
|
5727
5794
|
nextContext = hasCommitGuard ? this.availabilityContextRegistry.get(normalizedContextId) : this.getAvailabilityContextEntry(normalizedContextId);
|
|
@@ -5737,60 +5804,60 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5737
5804
|
bookingUids: bookingUids
|
|
5738
5805
|
};
|
|
5739
5806
|
if (!targetStillCurrent) {
|
|
5740
|
-
|
|
5807
|
+
_context49.next = 178;
|
|
5741
5808
|
break;
|
|
5742
5809
|
}
|
|
5743
5810
|
// A notification failure after publication must not invite a duplicate add.
|
|
5744
5811
|
emit = function emit() {
|
|
5745
|
-
return
|
|
5812
|
+
return _this15.core.effects.emit("".concat(_this15.name, ":").concat(UnifiedBookingSalesHooks.onAvailabilitySelectionCommitted), result);
|
|
5746
5813
|
};
|
|
5747
5814
|
if (!guardedCommitPublished) {
|
|
5748
|
-
|
|
5815
|
+
_context49.next = 176;
|
|
5749
5816
|
break;
|
|
5750
5817
|
}
|
|
5751
|
-
|
|
5752
|
-
|
|
5818
|
+
_context49.prev = 167;
|
|
5819
|
+
_context49.next = 170;
|
|
5753
5820
|
return emit();
|
|
5754
|
-
case
|
|
5755
|
-
|
|
5821
|
+
case 170:
|
|
5822
|
+
_context49.next = 174;
|
|
5756
5823
|
break;
|
|
5757
|
-
case
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
case
|
|
5761
|
-
|
|
5824
|
+
case 172:
|
|
5825
|
+
_context49.prev = 172;
|
|
5826
|
+
_context49.t0 = _context49["catch"](167);
|
|
5827
|
+
case 174:
|
|
5828
|
+
_context49.next = 178;
|
|
5762
5829
|
break;
|
|
5763
|
-
case
|
|
5764
|
-
|
|
5830
|
+
case 176:
|
|
5831
|
+
_context49.next = 178;
|
|
5765
5832
|
return emit();
|
|
5766
|
-
case
|
|
5767
|
-
return
|
|
5768
|
-
case
|
|
5769
|
-
|
|
5833
|
+
case 178:
|
|
5834
|
+
return _context49.abrupt("return", result);
|
|
5835
|
+
case 179:
|
|
5836
|
+
_context49.prev = 179;
|
|
5770
5837
|
release = this.releaseAvailabilityCommitLock(normalizedContextId);
|
|
5771
5838
|
if (!guardedCommitPublished) {
|
|
5772
|
-
|
|
5839
|
+
_context49.next = 186;
|
|
5773
5840
|
break;
|
|
5774
5841
|
}
|
|
5775
|
-
|
|
5842
|
+
_context49.next = 184;
|
|
5776
5843
|
return release.catch(function () {
|
|
5777
5844
|
return undefined;
|
|
5778
5845
|
});
|
|
5779
|
-
case
|
|
5780
|
-
|
|
5846
|
+
case 184:
|
|
5847
|
+
_context49.next = 188;
|
|
5781
5848
|
break;
|
|
5782
|
-
case
|
|
5783
|
-
|
|
5849
|
+
case 186:
|
|
5850
|
+
_context49.next = 188;
|
|
5784
5851
|
return release;
|
|
5785
|
-
case
|
|
5786
|
-
return
|
|
5787
|
-
case
|
|
5852
|
+
case 188:
|
|
5853
|
+
return _context49.finish(179);
|
|
5854
|
+
case 189:
|
|
5788
5855
|
case "end":
|
|
5789
|
-
return
|
|
5856
|
+
return _context49.stop();
|
|
5790
5857
|
}
|
|
5791
|
-
},
|
|
5858
|
+
}, _callee49, this, [[16,, 179, 189], [167, 172]]);
|
|
5792
5859
|
}));
|
|
5793
|
-
function commitAvailabilitySelection(
|
|
5860
|
+
function commitAvailabilitySelection(_x37, _x38) {
|
|
5794
5861
|
return _commitAvailabilitySelection.apply(this, arguments);
|
|
5795
5862
|
}
|
|
5796
5863
|
return commitAvailabilitySelection;
|
|
@@ -1,46 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _examples.BUY_X_GET_Y_FREE_STRATEGY;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _examples.ITEM_REWARD_STRATEGY;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "PromotionAdapter", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _adapter.PromotionAdapter;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "PromotionEvaluator", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _evaluator.PromotionEvaluator;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(exports, "default", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () {
|
|
39
|
-
return _adapter.default;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
var _evaluator = require("./evaluator");
|
|
43
|
-
var _adapter = _interopRequireWildcard(require("./adapter"));
|
|
44
|
-
var _examples = require("./examples");
|
|
45
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
46
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
1
|
+
"use strict";
|
|
@@ -1812,6 +1812,11 @@ class BaseSalesImpl extends _BaseModule.BaseModule {
|
|
|
1812
1812
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
1813
1813
|
const serviceData = this.store.order.updateTempOrderServiceType(serviceType);
|
|
1814
1814
|
await this.getFulfillmentItemRulesController().apply(serviceType);
|
|
1815
|
+
// 费用规则可能增删商品;即使没有普通促销,也要同步页面的购物车和金额快照。
|
|
1816
|
+
const tempOrder = this.getTempOrder();
|
|
1817
|
+
if (tempOrder) await this.effectsEmit('onTempOrderReplaced', {
|
|
1818
|
+
tempOrder
|
|
1819
|
+
});
|
|
1815
1820
|
return serviceData;
|
|
1816
1821
|
}
|
|
1817
1822
|
getPickupTimingBooking() {
|
|
@@ -347,7 +347,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
347
347
|
* 获取当前的客户搜索条件
|
|
348
348
|
* @returns 当前搜索条件
|
|
349
349
|
*/
|
|
350
|
-
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "
|
|
350
|
+
getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
|
|
351
351
|
/**
|
|
352
352
|
* 获取客户列表状态(包含滚动加载相关状态)
|
|
353
353
|
* @returns 客户状态
|
|
@@ -276,6 +276,7 @@ export declare class UnifiedBookingSalesImpl extends BookingTicket {
|
|
|
276
276
|
private assertAvailabilityCommitWriteCAS;
|
|
277
277
|
private findProductLineByUid;
|
|
278
278
|
private findLinkedBooking;
|
|
279
|
+
removeBookingProductsOutsideStartDate(startDate: unknown): Promise<import("../../modules/Order/types").OrderProduct[]>;
|
|
279
280
|
/** Revalidates against the latest landed occupancy cache, then mutates exactly one product line. */
|
|
280
281
|
commitAvailabilitySelection(contextId: string, params: ContextualCommitAvailabilitySelectionParams): Promise<UnifiedBookingSalesCommitAvailabilitySelectionResult>;
|
|
281
282
|
}
|
|
@@ -32,6 +32,7 @@ exports.normalizeProductForAvailability = normalizeProductForAvailability;
|
|
|
32
32
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
33
33
|
var _lodashEs = require("lodash-es");
|
|
34
34
|
var _modules = require("../../modules");
|
|
35
|
+
var _pickupTiming = require("../../modules/Order/pickupTiming");
|
|
35
36
|
var _utils = require("../../modules/BookingContext/utils");
|
|
36
37
|
var _cacheItemToBookingInput = require("../../modules/BookingContext/utils/cacheItemToBookingInput");
|
|
37
38
|
var _OpenData = require("../../modules/OpenData");
|
|
@@ -866,6 +867,20 @@ function collectAvailabilityResourceIds(products, explicitResourceIds = []) {
|
|
|
866
867
|
function getProductLineUid(product) {
|
|
867
868
|
return String(product?.metadata?.unique_identification_number ?? product?.unique_identification_number ?? '');
|
|
868
869
|
}
|
|
870
|
+
function getVisibleCalendarDate(value) {
|
|
871
|
+
if (typeof value !== 'string') return null;
|
|
872
|
+
const raw = value.trim();
|
|
873
|
+
try {
|
|
874
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(raw)) {
|
|
875
|
+
(0, _localClock.parseLocalDate)(raw);
|
|
876
|
+
} else {
|
|
877
|
+
(0, _localClock.parseLocalDateTime)(raw);
|
|
878
|
+
}
|
|
879
|
+
return raw.slice(0, 10);
|
|
880
|
+
} catch (_error) {
|
|
881
|
+
return null;
|
|
882
|
+
}
|
|
883
|
+
}
|
|
869
884
|
function buildAvailabilityLineIdentity(product) {
|
|
870
885
|
return {
|
|
871
886
|
product_id: product.product_id,
|
|
@@ -3351,6 +3366,24 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
3351
3366
|
const bookingUid = String(product.booking_uid ?? product.metadata?.booking_uid ?? '');
|
|
3352
3367
|
return (this.getTempOrder()?.bookings || []).find(booking => bookingUid && getBookingUid(booking) === bookingUid || productUid && String(booking.product_uid ?? '') === productUid);
|
|
3353
3368
|
}
|
|
3369
|
+
async removeBookingProductsOutsideStartDate(startDate) {
|
|
3370
|
+
const products = this.getTempOrder()?.products || [];
|
|
3371
|
+
if (this.otherParams?.enforceSingleBookingStartDate !== true) {
|
|
3372
|
+
return products;
|
|
3373
|
+
}
|
|
3374
|
+
const targetDate = getVisibleCalendarDate(startDate);
|
|
3375
|
+
if (!targetDate) return products;
|
|
3376
|
+
const identities = products.flatMap(product => {
|
|
3377
|
+
if (!getProductLineUid(product) || product?.metadata?.product_add_schedule_time != null) {
|
|
3378
|
+
return [];
|
|
3379
|
+
}
|
|
3380
|
+
const booking = this.findLinkedBooking(product);
|
|
3381
|
+
if (!booking || (0, _pickupTiming.isFulfillmentTimingBooking)(booking)) return [];
|
|
3382
|
+
const bookingDate = getVisibleCalendarDate(booking.start_date);
|
|
3383
|
+
return bookingDate && bookingDate !== targetDate ? [buildAvailabilityLineIdentity(product)] : [];
|
|
3384
|
+
});
|
|
3385
|
+
return identities.length ? this.removeProductsFromOrder(identities) : products;
|
|
3386
|
+
}
|
|
3354
3387
|
|
|
3355
3388
|
/** Revalidates against the latest landed occupancy cache, then mutates exactly one product line. */
|
|
3356
3389
|
async commitAvailabilitySelection(contextId, params) {
|
|
@@ -3761,6 +3794,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
3761
3794
|
allow_booking_discount_reapply: params.allowBookingDiscountReapply
|
|
3762
3795
|
} : {})
|
|
3763
3796
|
});
|
|
3797
|
+
await this.removeBookingProductsOutsideStartDate(booking.start_date);
|
|
3764
3798
|
productLineUid = params.productLineUid;
|
|
3765
3799
|
bookingUid = existingBookingUid;
|
|
3766
3800
|
productLineUids = [productLineUid];
|
|
@@ -3769,7 +3803,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
3769
3803
|
const beforeProductLineUids = new Set((this.getTempOrder()?.products || []).map(line => getProductLineUid(line)).filter(Boolean));
|
|
3770
3804
|
const beforeBookingUids = new Set((this.getTempOrder()?.bookings || []).map(item => getBookingUid(item)).filter(Boolean));
|
|
3771
3805
|
availabilityCommitGuard?.();
|
|
3772
|
-
|
|
3806
|
+
let products = await this.addProductToOrder(transformed, booking, params.salesNotes?.length || availabilityCommitGuard ? {
|
|
3773
3807
|
...(params.salesNotes?.length ? {
|
|
3774
3808
|
salesNotes: params.salesNotes
|
|
3775
3809
|
} : {}),
|
|
@@ -3778,6 +3812,7 @@ class UnifiedBookingSalesImpl extends _BookingTicket.BookingTicket {
|
|
|
3778
3812
|
availabilityCommitTargetGuard
|
|
3779
3813
|
} : {})
|
|
3780
3814
|
} : undefined);
|
|
3815
|
+
products = await this.removeBookingProductsOutsideStartDate(booking.start_date);
|
|
3781
3816
|
guardedCommitPublished = hasCommitGuard;
|
|
3782
3817
|
const addedLines = products.filter(line => sameAvailabilityId(line.product_id ?? line.id, refreshedCandidate.productId) && line.metadata?.availability_candidate_key === refreshedCandidate.key && !beforeProductLineUids.has(getProductLineUid(line)));
|
|
3783
3818
|
productLineUids = addedLines.map(line => getProductLineUid(line)).filter(Boolean);
|