@pisell/pisellos 0.10.57 → 0.10.58
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 +9 -0
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Order/utils.d.ts +5 -3
- package/dist/modules/Order/utils.js +32 -11
- package/dist/modules/ProductList/index.d.ts +3 -1
- package/dist/modules/ProductList/index.js +187 -92
- package/dist/modules/ProductList/types.d.ts +8 -0
- package/dist/modules/ProductList/types.js +2 -0
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/UnifiedBookingSales/index.d.ts +7 -1
- package/dist/solution/UnifiedBookingSales/index.js +548 -388
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/utils.d.ts +5 -3
- package/lib/modules/Order/utils.js +29 -10
- package/lib/modules/ProductList/index.d.ts +3 -1
- package/lib/modules/ProductList/index.js +31 -5
- package/lib/modules/ProductList/types.d.ts +8 -0
- package/lib/modules/ProductList/types.js +1 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/UnifiedBookingSales/index.d.ts +7 -1
- package/lib/solution/UnifiedBookingSales/index.js +80 -1
- package/package.json +1 -1
|
@@ -34,7 +34,7 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
|
|
|
34
34
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
35
35
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
36
36
|
import dayjs from 'dayjs';
|
|
37
|
-
import { cloneDeep } from 'lodash-es';
|
|
37
|
+
import { cloneDeep, isEqual } from 'lodash-es';
|
|
38
38
|
import { OpenDataModule } from "../../modules";
|
|
39
39
|
import { isProductFlexibleDuration } from "../../modules/BookingContext/utils";
|
|
40
40
|
import { getDefaultInvoiceLayoutConfig, getDefaultInvoiceTemplateSettings } from "../../modules/OpenData";
|
|
@@ -2852,6 +2852,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2852
2852
|
key: "loadProducts",
|
|
2853
2853
|
value: (function () {
|
|
2854
2854
|
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
2855
|
+
var _this7 = this;
|
|
2855
2856
|
var params,
|
|
2856
2857
|
options,
|
|
2857
2858
|
schedule_date,
|
|
@@ -2879,7 +2880,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
2879
2880
|
schedule_date: schedule_date,
|
|
2880
2881
|
schedule_datetime: schedule_datetime,
|
|
2881
2882
|
cacheId: this.cacheId
|
|
2882
|
-
}), options)
|
|
2883
|
+
}), options !== null && options !== void 0 && options.callback && typeof this.otherParams.enrichProducts === 'function' ? _objectSpread(_objectSpread({}, options), {}, {
|
|
2884
|
+
callback: function callback(response) {
|
|
2885
|
+
var _response$data2, _options$callback;
|
|
2886
|
+
var updates = response === null || response === void 0 || (_response$data2 = response.data) === null || _response$data2 === void 0 ? void 0 : _response$data2.list;
|
|
2887
|
+
if (Array.isArray(updates)) {
|
|
2888
|
+
// Subscription responses are the current query's complete visible list.
|
|
2889
|
+
_this7.unifiedProductCatalog = _toConsumableArray(updates);
|
|
2890
|
+
}
|
|
2891
|
+
(_options$callback = options.callback) === null || _options$callback === void 0 || _options$callback.call(options, response);
|
|
2892
|
+
}
|
|
2893
|
+
}) : options);
|
|
2883
2894
|
case 8:
|
|
2884
2895
|
result = _context24.sent;
|
|
2885
2896
|
this.unifiedProductCatalog = Array.isArray(result) ? _toConsumableArray(result) : [];
|
|
@@ -3090,6 +3101,155 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3090
3101
|
};
|
|
3091
3102
|
}
|
|
3092
3103
|
|
|
3104
|
+
/** Detail reads share the catalog adapter, including when basic detail is cached. */
|
|
3105
|
+
}, {
|
|
3106
|
+
key: "enrichProducts",
|
|
3107
|
+
value: (function () {
|
|
3108
|
+
var _enrichProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(products, context) {
|
|
3109
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
3110
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
3111
|
+
case 0:
|
|
3112
|
+
if (this.store.products) {
|
|
3113
|
+
_context28.next = 2;
|
|
3114
|
+
break;
|
|
3115
|
+
}
|
|
3116
|
+
throw new Error('Products module is not ready');
|
|
3117
|
+
case 2:
|
|
3118
|
+
return _context28.abrupt("return", this.store.products.enrichProducts(products, context));
|
|
3119
|
+
case 3:
|
|
3120
|
+
case "end":
|
|
3121
|
+
return _context28.stop();
|
|
3122
|
+
}
|
|
3123
|
+
}, _callee28, this);
|
|
3124
|
+
}));
|
|
3125
|
+
function enrichProducts(_x15, _x16) {
|
|
3126
|
+
return _enrichProducts.apply(this, arguments);
|
|
3127
|
+
}
|
|
3128
|
+
return enrichProducts;
|
|
3129
|
+
}() /** Apply only enrichment changes, never the cart's selection/price snapshot. */)
|
|
3130
|
+
}, {
|
|
3131
|
+
key: "applyProductEnrichment",
|
|
3132
|
+
value: (function () {
|
|
3133
|
+
var _applyProductEnrichment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(before, after) {
|
|
3134
|
+
var _before$id, _after$id, _this$store$products, _context$signal;
|
|
3135
|
+
var context,
|
|
3136
|
+
id,
|
|
3137
|
+
patch,
|
|
3138
|
+
cached,
|
|
3139
|
+
applyPatch,
|
|
3140
|
+
catalogUpdates,
|
|
3141
|
+
updates,
|
|
3142
|
+
_this$store$products2,
|
|
3143
|
+
_context$signal2,
|
|
3144
|
+
_args29 = arguments;
|
|
3145
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
3146
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
3147
|
+
case 0:
|
|
3148
|
+
context = _args29.length > 2 && _args29[2] !== undefined ? _args29[2] : {};
|
|
3149
|
+
id = String((_before$id = before.id) !== null && _before$id !== void 0 ? _before$id : before.product_id);
|
|
3150
|
+
if (!(id !== String((_after$id = after.id) !== null && _after$id !== void 0 ? _after$id : after.product_id))) {
|
|
3151
|
+
_context29.next = 4;
|
|
3152
|
+
break;
|
|
3153
|
+
}
|
|
3154
|
+
throw new Error('Product enrichment changed product identity');
|
|
3155
|
+
case 4:
|
|
3156
|
+
patch = {};
|
|
3157
|
+
Object.keys(after).forEach(function (key) {
|
|
3158
|
+
if (['id', 'product_id', '_extend'].includes(key)) return;
|
|
3159
|
+
if (!isEqual(before[key], after[key])) patch[key] = cloneDeep(after[key]);
|
|
3160
|
+
});
|
|
3161
|
+
if (Object.keys(patch).length) {
|
|
3162
|
+
_context29.next = 8;
|
|
3163
|
+
break;
|
|
3164
|
+
}
|
|
3165
|
+
return _context29.abrupt("return");
|
|
3166
|
+
case 8:
|
|
3167
|
+
_context29.next = 10;
|
|
3168
|
+
return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.queryProducts({
|
|
3169
|
+
includeIds: [id]
|
|
3170
|
+
});
|
|
3171
|
+
case 10:
|
|
3172
|
+
_context29.t0 = _context29.sent;
|
|
3173
|
+
if (_context29.t0) {
|
|
3174
|
+
_context29.next = 13;
|
|
3175
|
+
break;
|
|
3176
|
+
}
|
|
3177
|
+
_context29.t0 = [];
|
|
3178
|
+
case 13:
|
|
3179
|
+
cached = _context29.t0;
|
|
3180
|
+
if (!((_context$signal = context.signal) !== null && _context$signal !== void 0 && _context$signal.aborted)) {
|
|
3181
|
+
_context29.next = 16;
|
|
3182
|
+
break;
|
|
3183
|
+
}
|
|
3184
|
+
return _context29.abrupt("return");
|
|
3185
|
+
case 16:
|
|
3186
|
+
applyPatch = function applyPatch(product) {
|
|
3187
|
+
var next = _objectSpread(_objectSpread({}, product), patch);
|
|
3188
|
+
// A detail can contain only the selected variants; keep the catalog's other SKUs
|
|
3189
|
+
// and update only fields that the adapter actually changed.
|
|
3190
|
+
if (Array.isArray(patch.variant) && Array.isArray(product.variant)) {
|
|
3191
|
+
var variantId = function variantId(variant) {
|
|
3192
|
+
var _variant$id;
|
|
3193
|
+
var value = (_variant$id = variant === null || variant === void 0 ? void 0 : variant.id) !== null && _variant$id !== void 0 ? _variant$id : variant === null || variant === void 0 ? void 0 : variant.product_variant_id;
|
|
3194
|
+
return value == null ? null : String(value);
|
|
3195
|
+
};
|
|
3196
|
+
next.variant = product.variant.map(function (variant) {
|
|
3197
|
+
var _before$variant, _after$variant;
|
|
3198
|
+
if (variantId(variant) === null) return variant;
|
|
3199
|
+
var previous = (_before$variant = before.variant) === null || _before$variant === void 0 ? void 0 : _before$variant.find(function (item) {
|
|
3200
|
+
return variantId(item) === variantId(variant);
|
|
3201
|
+
});
|
|
3202
|
+
var enriched = (_after$variant = after.variant) === null || _after$variant === void 0 ? void 0 : _after$variant.find(function (item) {
|
|
3203
|
+
return variantId(item) === variantId(variant);
|
|
3204
|
+
});
|
|
3205
|
+
if (!previous || !enriched) return variant;
|
|
3206
|
+
var variantPatch = {};
|
|
3207
|
+
Object.keys(enriched).forEach(function (key) {
|
|
3208
|
+
if (key !== 'id' && key !== 'product_variant_id' && !isEqual(previous[key], enriched[key])) {
|
|
3209
|
+
variantPatch[key] = cloneDeep(enriched[key]);
|
|
3210
|
+
}
|
|
3211
|
+
});
|
|
3212
|
+
return _objectSpread(_objectSpread({}, variant), variantPatch);
|
|
3213
|
+
});
|
|
3214
|
+
}
|
|
3215
|
+
return next;
|
|
3216
|
+
};
|
|
3217
|
+
catalogUpdates = [];
|
|
3218
|
+
this.unifiedProductCatalog = this.unifiedProductCatalog.map(function (product) {
|
|
3219
|
+
var _product$id;
|
|
3220
|
+
if (String((_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : product.product_id) !== id) return product;
|
|
3221
|
+
var next = applyPatch(product);
|
|
3222
|
+
catalogUpdates.push(next);
|
|
3223
|
+
return next;
|
|
3224
|
+
});
|
|
3225
|
+
// A cart product may no longer be in the visible menu but still have a shared cache entry.
|
|
3226
|
+
updates = cached.length ? cached.map(applyPatch) : catalogUpdates;
|
|
3227
|
+
if (!updates.length) {
|
|
3228
|
+
_context29.next = 27;
|
|
3229
|
+
break;
|
|
3230
|
+
}
|
|
3231
|
+
_context29.next = 23;
|
|
3232
|
+
return (_this$store$products2 = this.store.products) === null || _this$store$products2 === void 0 ? void 0 : _this$store$products2.addProduct(updates);
|
|
3233
|
+
case 23:
|
|
3234
|
+
if (!((_context$signal2 = context.signal) !== null && _context$signal2 !== void 0 && _context$signal2.aborted)) {
|
|
3235
|
+
_context29.next = 25;
|
|
3236
|
+
break;
|
|
3237
|
+
}
|
|
3238
|
+
return _context29.abrupt("return");
|
|
3239
|
+
case 25:
|
|
3240
|
+
_context29.next = 27;
|
|
3241
|
+
return this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), this.getProductCatalog().products);
|
|
3242
|
+
case 27:
|
|
3243
|
+
case "end":
|
|
3244
|
+
return _context29.stop();
|
|
3245
|
+
}
|
|
3246
|
+
}, _callee29, this);
|
|
3247
|
+
}));
|
|
3248
|
+
function applyProductEnrichment(_x17, _x18) {
|
|
3249
|
+
return _applyProductEnrichment.apply(this, arguments);
|
|
3250
|
+
}
|
|
3251
|
+
return applyProductEnrichment;
|
|
3252
|
+
}()
|
|
3093
3253
|
/**
|
|
3094
3254
|
* Read-only compatibility view for salesSdk skins. It reconnects a booking to its product but
|
|
3095
3255
|
* must not be used to mutate tempOrder; all writes go through BaseSales / planner APIs.
|
|
@@ -3121,16 +3281,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3121
3281
|
// }),
|
|
3122
3282
|
// };
|
|
3123
3283
|
// }
|
|
3124
|
-
|
|
3125
3284
|
/**
|
|
3126
3285
|
* Loads the current customer's product coupons and discount cards after planner lines exist,
|
|
3127
3286
|
* then optionally lets the existing Rules engine select the best valid combination. This is a
|
|
3128
3287
|
* diagnostic boundary for new booking skins: no pricing logic is duplicated in the planner.
|
|
3129
3288
|
*/
|
|
3289
|
+
)
|
|
3130
3290
|
}, {
|
|
3131
3291
|
key: "applyPlannerDiscounts",
|
|
3132
3292
|
value: (function () {
|
|
3133
|
-
var _applyPlannerDiscounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3293
|
+
var _applyPlannerDiscounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
3134
3294
|
var _params$customerId;
|
|
3135
3295
|
var params,
|
|
3136
3296
|
tempOrder,
|
|
@@ -3147,24 +3307,24 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3147
3307
|
discount,
|
|
3148
3308
|
discountId,
|
|
3149
3309
|
nextTempOrder,
|
|
3150
|
-
|
|
3151
|
-
return _regeneratorRuntime().wrap(function
|
|
3152
|
-
while (1) switch (
|
|
3310
|
+
_args30 = arguments;
|
|
3311
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
3312
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
3153
3313
|
case 0:
|
|
3154
|
-
params =
|
|
3314
|
+
params = _args30.length > 0 && _args30[0] !== undefined ? _args30[0] : {};
|
|
3155
3315
|
tempOrder = this.getTempOrder();
|
|
3156
3316
|
requestedCustomerId = (_params$customerId = params.customerId) !== null && _params$customerId !== void 0 ? _params$customerId : tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.customer_id;
|
|
3157
3317
|
parsedCustomerId = Number(requestedCustomerId);
|
|
3158
3318
|
customerId = Number.isFinite(parsedCustomerId) && parsedCustomerId > 1 ? parsedCustomerId : null;
|
|
3159
|
-
|
|
3319
|
+
_context30.next = 7;
|
|
3160
3320
|
return this.getSummary();
|
|
3161
3321
|
case 7:
|
|
3162
|
-
summaryBefore =
|
|
3322
|
+
summaryBefore = _context30.sent;
|
|
3163
3323
|
if (customerId) {
|
|
3164
|
-
|
|
3324
|
+
_context30.next = 10;
|
|
3165
3325
|
break;
|
|
3166
3326
|
}
|
|
3167
|
-
return
|
|
3327
|
+
return _context30.abrupt("return", buildPlannerDiscountResult({
|
|
3168
3328
|
customerId: null,
|
|
3169
3329
|
discountList: this.getDiscountList(),
|
|
3170
3330
|
products: (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || [],
|
|
@@ -3173,7 +3333,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3173
3333
|
status: 'no_customer'
|
|
3174
3334
|
}));
|
|
3175
3335
|
case 10:
|
|
3176
|
-
|
|
3336
|
+
_context30.next = 12;
|
|
3177
3337
|
return this.loadDiscountConfig({
|
|
3178
3338
|
customerId: customerId,
|
|
3179
3339
|
action: 'create'
|
|
@@ -3185,7 +3345,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3185
3345
|
return String((_resolvePlannerDiscou = resolvePlannerDiscountId(discount)) !== null && _resolvePlannerDiscou !== void 0 ? _resolvePlannerDiscou : '') === String(preferredDiscountId);
|
|
3186
3346
|
});
|
|
3187
3347
|
if (!preferredDiscount) {
|
|
3188
|
-
|
|
3348
|
+
_context30.next = 40;
|
|
3189
3349
|
break;
|
|
3190
3350
|
}
|
|
3191
3351
|
// A requested card is an explicit UI choice, not a best-effort preference. Clear prior
|
|
@@ -3197,98 +3357,98 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3197
3357
|
return discount.isSelected === true && String((_resolvePlannerDiscou2 = resolvePlannerDiscountId(discount)) !== null && _resolvePlannerDiscou2 !== void 0 ? _resolvePlannerDiscou2 : '') !== String(preferredId);
|
|
3198
3358
|
});
|
|
3199
3359
|
_iterator2 = _createForOfIteratorHelper(selectedOtherDiscounts);
|
|
3200
|
-
|
|
3360
|
+
_context30.prev = 18;
|
|
3201
3361
|
_iterator2.s();
|
|
3202
3362
|
case 20:
|
|
3203
3363
|
if ((_step2 = _iterator2.n()).done) {
|
|
3204
|
-
|
|
3364
|
+
_context30.next = 28;
|
|
3205
3365
|
break;
|
|
3206
3366
|
}
|
|
3207
3367
|
discount = _step2.value;
|
|
3208
3368
|
discountId = Number(resolvePlannerDiscountId(discount));
|
|
3209
3369
|
if (!Number.isFinite(discountId)) {
|
|
3210
|
-
|
|
3370
|
+
_context30.next = 26;
|
|
3211
3371
|
break;
|
|
3212
3372
|
}
|
|
3213
|
-
|
|
3373
|
+
_context30.next = 26;
|
|
3214
3374
|
return this.setDiscountSelected({
|
|
3215
3375
|
discountId: discountId,
|
|
3216
3376
|
isSelected: false
|
|
3217
3377
|
});
|
|
3218
3378
|
case 26:
|
|
3219
|
-
|
|
3379
|
+
_context30.next = 20;
|
|
3220
3380
|
break;
|
|
3221
3381
|
case 28:
|
|
3222
|
-
|
|
3382
|
+
_context30.next = 33;
|
|
3223
3383
|
break;
|
|
3224
3384
|
case 30:
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
_iterator2.e(
|
|
3385
|
+
_context30.prev = 30;
|
|
3386
|
+
_context30.t0 = _context30["catch"](18);
|
|
3387
|
+
_iterator2.e(_context30.t0);
|
|
3228
3388
|
case 33:
|
|
3229
|
-
|
|
3389
|
+
_context30.prev = 33;
|
|
3230
3390
|
_iterator2.f();
|
|
3231
|
-
return
|
|
3391
|
+
return _context30.finish(33);
|
|
3232
3392
|
case 36:
|
|
3233
|
-
|
|
3393
|
+
_context30.next = 38;
|
|
3234
3394
|
return this.setDiscountSelected({
|
|
3235
3395
|
discountId: Number(preferredId),
|
|
3236
3396
|
isSelected: true
|
|
3237
3397
|
});
|
|
3238
3398
|
case 38:
|
|
3239
|
-
|
|
3399
|
+
_context30.next = 49;
|
|
3240
3400
|
break;
|
|
3241
3401
|
case 40:
|
|
3242
3402
|
if (!(preferredDiscountId === undefined || preferredDiscountId === null)) {
|
|
3243
|
-
|
|
3403
|
+
_context30.next = 46;
|
|
3244
3404
|
break;
|
|
3245
3405
|
}
|
|
3246
3406
|
if (!(params.applyBestDiscount !== false)) {
|
|
3247
|
-
|
|
3407
|
+
_context30.next = 44;
|
|
3248
3408
|
break;
|
|
3249
3409
|
}
|
|
3250
|
-
|
|
3410
|
+
_context30.next = 44;
|
|
3251
3411
|
return this.bestDiscount();
|
|
3252
3412
|
case 44:
|
|
3253
|
-
|
|
3413
|
+
_context30.next = 49;
|
|
3254
3414
|
break;
|
|
3255
3415
|
case 46:
|
|
3256
3416
|
if (!(params.applyBestDiscount !== false)) {
|
|
3257
|
-
|
|
3417
|
+
_context30.next = 49;
|
|
3258
3418
|
break;
|
|
3259
3419
|
}
|
|
3260
|
-
|
|
3420
|
+
_context30.next = 49;
|
|
3261
3421
|
return this.bestDiscount();
|
|
3262
3422
|
case 49:
|
|
3263
3423
|
nextTempOrder = this.getTempOrder();
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3424
|
+
_context30.t1 = buildPlannerDiscountResult;
|
|
3425
|
+
_context30.t2 = customerId;
|
|
3426
|
+
_context30.t3 = this.getDiscountList();
|
|
3427
|
+
_context30.t4 = (nextTempOrder === null || nextTempOrder === void 0 ? void 0 : nextTempOrder.products) || [];
|
|
3428
|
+
_context30.t5 = summaryBefore;
|
|
3429
|
+
_context30.next = 57;
|
|
3270
3430
|
return this.getSummary();
|
|
3271
3431
|
case 57:
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
customerId:
|
|
3278
|
-
discountList:
|
|
3279
|
-
products:
|
|
3280
|
-
summaryBefore:
|
|
3281
|
-
summaryAfter:
|
|
3282
|
-
status:
|
|
3283
|
-
preferredDiscountId:
|
|
3284
|
-
preferredDiscountFound:
|
|
3432
|
+
_context30.t6 = _context30.sent;
|
|
3433
|
+
_context30.t7 = params.applyBestDiscount === false && !preferredDiscount ? 'loaded' : 'applied';
|
|
3434
|
+
_context30.t8 = preferredDiscountId;
|
|
3435
|
+
_context30.t9 = preferredDiscountId === undefined || preferredDiscountId === null ? undefined : Boolean(preferredDiscount);
|
|
3436
|
+
_context30.t10 = {
|
|
3437
|
+
customerId: _context30.t2,
|
|
3438
|
+
discountList: _context30.t3,
|
|
3439
|
+
products: _context30.t4,
|
|
3440
|
+
summaryBefore: _context30.t5,
|
|
3441
|
+
summaryAfter: _context30.t6,
|
|
3442
|
+
status: _context30.t7,
|
|
3443
|
+
preferredDiscountId: _context30.t8,
|
|
3444
|
+
preferredDiscountFound: _context30.t9
|
|
3285
3445
|
};
|
|
3286
|
-
return
|
|
3446
|
+
return _context30.abrupt("return", (0, _context30.t1)(_context30.t10));
|
|
3287
3447
|
case 63:
|
|
3288
3448
|
case "end":
|
|
3289
|
-
return
|
|
3449
|
+
return _context30.stop();
|
|
3290
3450
|
}
|
|
3291
|
-
},
|
|
3451
|
+
}, _callee30, this, [[18, 30, 33, 36]]);
|
|
3292
3452
|
}));
|
|
3293
3453
|
function applyPlannerDiscounts() {
|
|
3294
3454
|
return _applyPlannerDiscounts.apply(this, arguments);
|
|
@@ -3326,29 +3486,29 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3326
3486
|
}, {
|
|
3327
3487
|
key: "removeExistingStagedLines",
|
|
3328
3488
|
value: (function () {
|
|
3329
|
-
var _removeExistingStagedLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3489
|
+
var _removeExistingStagedLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(ownershipKey) {
|
|
3330
3490
|
var _this$getTempOrder;
|
|
3331
3491
|
var existingLines;
|
|
3332
|
-
return _regeneratorRuntime().wrap(function
|
|
3333
|
-
while (1) switch (
|
|
3492
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
3493
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
3334
3494
|
case 0:
|
|
3335
3495
|
existingLines = (((_this$getTempOrder = this.getTempOrder()) === null || _this$getTempOrder === void 0 ? void 0 : _this$getTempOrder.products) || []).filter(function (product) {
|
|
3336
3496
|
var _product$metadata4;
|
|
3337
3497
|
return (product === null || product === void 0 || (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4[ownershipKey]) === true;
|
|
3338
3498
|
});
|
|
3339
3499
|
if (!(existingLines.length > 0)) {
|
|
3340
|
-
|
|
3500
|
+
_context31.next = 4;
|
|
3341
3501
|
break;
|
|
3342
3502
|
}
|
|
3343
|
-
|
|
3503
|
+
_context31.next = 4;
|
|
3344
3504
|
return this.removeProductsFromOrder(existingLines.map(buildAvailabilityLineIdentity));
|
|
3345
3505
|
case 4:
|
|
3346
3506
|
case "end":
|
|
3347
|
-
return
|
|
3507
|
+
return _context31.stop();
|
|
3348
3508
|
}
|
|
3349
|
-
},
|
|
3509
|
+
}, _callee31, this);
|
|
3350
3510
|
}));
|
|
3351
|
-
function removeExistingStagedLines(
|
|
3511
|
+
function removeExistingStagedLines(_x19) {
|
|
3352
3512
|
return _removeExistingStagedLines.apply(this, arguments);
|
|
3353
3513
|
}
|
|
3354
3514
|
return removeExistingStagedLines;
|
|
@@ -3356,80 +3516,80 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3356
3516
|
}, {
|
|
3357
3517
|
key: "stageProducts",
|
|
3358
3518
|
value: function () {
|
|
3359
|
-
var _stageProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3519
|
+
var _stageProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params, ownershipKey) {
|
|
3360
3520
|
var _params$rawProducts;
|
|
3361
3521
|
var productIds, existingIds, missingIds, productIdSet, selectedProducts, _i, _arr, sourceProduct, productInput;
|
|
3362
|
-
return _regeneratorRuntime().wrap(function
|
|
3363
|
-
while (1) switch (
|
|
3522
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
3523
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
3364
3524
|
case 0:
|
|
3365
3525
|
productIds = params.productIds || [];
|
|
3366
3526
|
if (productIds.length) {
|
|
3367
|
-
|
|
3527
|
+
_context32.next = 3;
|
|
3368
3528
|
break;
|
|
3369
3529
|
}
|
|
3370
|
-
return
|
|
3530
|
+
return _context32.abrupt("return", this.getTempOrder());
|
|
3371
3531
|
case 3:
|
|
3372
3532
|
if (!((_params$rawProducts = params.rawProducts) !== null && _params$rawProducts !== void 0 && _params$rawProducts.length)) {
|
|
3373
|
-
|
|
3533
|
+
_context32.next = 7;
|
|
3374
3534
|
break;
|
|
3375
3535
|
}
|
|
3376
3536
|
this.unifiedProductCatalog = params.rawProducts;
|
|
3377
|
-
|
|
3537
|
+
_context32.next = 12;
|
|
3378
3538
|
break;
|
|
3379
3539
|
case 7:
|
|
3380
3540
|
existingIds = new Set((this.unifiedProductCatalog || []).map(function (product) {
|
|
3381
|
-
var _product$
|
|
3382
|
-
return String((_product$
|
|
3541
|
+
var _product$id2;
|
|
3542
|
+
return String((_product$id2 = product.id) !== null && _product$id2 !== void 0 ? _product$id2 : product.product_id);
|
|
3383
3543
|
}));
|
|
3384
3544
|
missingIds = productIds.filter(function (id) {
|
|
3385
3545
|
return !existingIds.has(String(id));
|
|
3386
3546
|
});
|
|
3387
3547
|
if (!(missingIds.length || params.productLoadParams)) {
|
|
3388
|
-
|
|
3548
|
+
_context32.next = 12;
|
|
3389
3549
|
break;
|
|
3390
3550
|
}
|
|
3391
|
-
|
|
3551
|
+
_context32.next = 12;
|
|
3392
3552
|
return this.loadProducts(_objectSpread(_objectSpread({}, params.productLoadParams || {}), {}, {
|
|
3393
3553
|
product_ids: productIds.map(Number).filter(Number.isFinite)
|
|
3394
3554
|
}));
|
|
3395
3555
|
case 12:
|
|
3396
|
-
|
|
3556
|
+
_context32.next = 14;
|
|
3397
3557
|
return this.removeExistingStagedLines(ownershipKey);
|
|
3398
3558
|
case 14:
|
|
3399
3559
|
productIdSet = new Set(productIds.map(function (id) {
|
|
3400
3560
|
return String(id);
|
|
3401
3561
|
}));
|
|
3402
3562
|
selectedProducts = (this.unifiedProductCatalog || []).filter(function (product) {
|
|
3403
|
-
var _product$
|
|
3404
|
-
return productIdSet.has(String((_product$
|
|
3563
|
+
var _product$id3;
|
|
3564
|
+
return productIdSet.has(String((_product$id3 = product.id) !== null && _product$id3 !== void 0 ? _product$id3 : product.product_id));
|
|
3405
3565
|
});
|
|
3406
3566
|
_i = 0, _arr = selectedProducts;
|
|
3407
3567
|
case 17:
|
|
3408
3568
|
if (!(_i < _arr.length)) {
|
|
3409
|
-
|
|
3569
|
+
_context32.next = 26;
|
|
3410
3570
|
break;
|
|
3411
3571
|
}
|
|
3412
3572
|
sourceProduct = _arr[_i];
|
|
3413
3573
|
productInput = this.buildUnifiedOrderProduct(sourceProduct, ownershipKey);
|
|
3414
3574
|
if (!productInput) {
|
|
3415
|
-
|
|
3575
|
+
_context32.next = 23;
|
|
3416
3576
|
break;
|
|
3417
3577
|
}
|
|
3418
|
-
|
|
3578
|
+
_context32.next = 23;
|
|
3419
3579
|
return this.addProductToOrder(productInput);
|
|
3420
3580
|
case 23:
|
|
3421
3581
|
_i++;
|
|
3422
|
-
|
|
3582
|
+
_context32.next = 17;
|
|
3423
3583
|
break;
|
|
3424
3584
|
case 26:
|
|
3425
|
-
return
|
|
3585
|
+
return _context32.abrupt("return", this.getTempOrder());
|
|
3426
3586
|
case 27:
|
|
3427
3587
|
case "end":
|
|
3428
|
-
return
|
|
3588
|
+
return _context32.stop();
|
|
3429
3589
|
}
|
|
3430
|
-
},
|
|
3590
|
+
}, _callee32, this);
|
|
3431
3591
|
}));
|
|
3432
|
-
function stageProducts(
|
|
3592
|
+
function stageProducts(_x20, _x21) {
|
|
3433
3593
|
return _stageProducts.apply(this, arguments);
|
|
3434
3594
|
}
|
|
3435
3595
|
return stageProducts;
|
|
@@ -3441,18 +3601,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3441
3601
|
}, {
|
|
3442
3602
|
key: "stageRetailProducts",
|
|
3443
3603
|
value: (function () {
|
|
3444
|
-
var _stageRetailProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3445
|
-
return _regeneratorRuntime().wrap(function
|
|
3446
|
-
while (1) switch (
|
|
3604
|
+
var _stageRetailProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
|
|
3605
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
3606
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
3447
3607
|
case 0:
|
|
3448
|
-
return
|
|
3608
|
+
return _context33.abrupt("return", this.stageProducts(params, 'unified_booking_sales_retail'));
|
|
3449
3609
|
case 1:
|
|
3450
3610
|
case "end":
|
|
3451
|
-
return
|
|
3611
|
+
return _context33.stop();
|
|
3452
3612
|
}
|
|
3453
|
-
},
|
|
3613
|
+
}, _callee33, this);
|
|
3454
3614
|
}));
|
|
3455
|
-
function stageRetailProducts(
|
|
3615
|
+
function stageRetailProducts(_x22) {
|
|
3456
3616
|
return _stageRetailProducts.apply(this, arguments);
|
|
3457
3617
|
}
|
|
3458
3618
|
return stageRetailProducts;
|
|
@@ -3466,15 +3626,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3466
3626
|
}, {
|
|
3467
3627
|
key: "addRetailProduct",
|
|
3468
3628
|
value: (function () {
|
|
3469
|
-
var _addRetailProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3629
|
+
var _addRetailProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
3470
3630
|
var _params$quantity, _ref46, _params$productId, _params$product, _params$product2;
|
|
3471
3631
|
var quantity, productId, sourceProduct, products, orderProduct;
|
|
3472
|
-
return _regeneratorRuntime().wrap(function
|
|
3473
|
-
while (1) switch (
|
|
3632
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
3633
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
3474
3634
|
case 0:
|
|
3475
3635
|
quantity = Math.floor(Number((_params$quantity = params.quantity) !== null && _params$quantity !== void 0 ? _params$quantity : 1));
|
|
3476
3636
|
if (!(!Number.isFinite(quantity) || quantity <= 0)) {
|
|
3477
|
-
|
|
3637
|
+
_context34.next = 3;
|
|
3478
3638
|
break;
|
|
3479
3639
|
}
|
|
3480
3640
|
throw new Error('[UnifiedBookingSales] retail 商品数量必须大于 0');
|
|
@@ -3483,27 +3643,27 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3483
3643
|
sourceProduct = params.product;
|
|
3484
3644
|
if (!sourceProduct && productId !== undefined && productId !== null) {
|
|
3485
3645
|
sourceProduct = this.unifiedProductCatalog.find(function (product) {
|
|
3486
|
-
var _product$
|
|
3487
|
-
return String((_product$
|
|
3646
|
+
var _product$id4;
|
|
3647
|
+
return String((_product$id4 = product.id) !== null && _product$id4 !== void 0 ? _product$id4 : product.product_id) === String(productId);
|
|
3488
3648
|
});
|
|
3489
3649
|
}
|
|
3490
3650
|
if (!(!sourceProduct && productId !== undefined && productId !== null)) {
|
|
3491
|
-
|
|
3651
|
+
_context34.next = 11;
|
|
3492
3652
|
break;
|
|
3493
3653
|
}
|
|
3494
|
-
|
|
3654
|
+
_context34.next = 9;
|
|
3495
3655
|
return this.loadProducts(_objectSpread(_objectSpread({}, params.productLoadParams || {}), {}, {
|
|
3496
3656
|
product_ids: [Number(productId)].filter(Number.isFinite)
|
|
3497
3657
|
}));
|
|
3498
3658
|
case 9:
|
|
3499
|
-
products =
|
|
3659
|
+
products = _context34.sent;
|
|
3500
3660
|
sourceProduct = products.find(function (product) {
|
|
3501
|
-
var _product$
|
|
3502
|
-
return String((_product$
|
|
3661
|
+
var _product$id5;
|
|
3662
|
+
return String((_product$id5 = product.id) !== null && _product$id5 !== void 0 ? _product$id5 : product.product_id) === String(productId);
|
|
3503
3663
|
});
|
|
3504
3664
|
case 11:
|
|
3505
3665
|
if (sourceProduct) {
|
|
3506
|
-
|
|
3666
|
+
_context34.next = 13;
|
|
3507
3667
|
break;
|
|
3508
3668
|
}
|
|
3509
3669
|
throw new Error("[UnifiedBookingSales] \u672A\u627E\u5230\u96F6\u552E\u5546\u54C1 ".concat(String(productId !== null && productId !== void 0 ? productId : '')).trim());
|
|
@@ -3512,19 +3672,19 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3512
3672
|
quantity: quantity
|
|
3513
3673
|
}), 'unified_booking_sales_retail');
|
|
3514
3674
|
if (orderProduct) {
|
|
3515
|
-
|
|
3675
|
+
_context34.next = 16;
|
|
3516
3676
|
break;
|
|
3517
3677
|
}
|
|
3518
3678
|
throw new Error('[UnifiedBookingSales] 无法生成零售商品订单行');
|
|
3519
3679
|
case 16:
|
|
3520
|
-
return
|
|
3680
|
+
return _context34.abrupt("return", this.addProductToOrder(orderProduct));
|
|
3521
3681
|
case 17:
|
|
3522
3682
|
case "end":
|
|
3523
|
-
return
|
|
3683
|
+
return _context34.stop();
|
|
3524
3684
|
}
|
|
3525
|
-
},
|
|
3685
|
+
}, _callee34, this);
|
|
3526
3686
|
}));
|
|
3527
|
-
function addRetailProduct(
|
|
3687
|
+
function addRetailProduct(_x23) {
|
|
3528
3688
|
return _addRetailProduct.apply(this, arguments);
|
|
3529
3689
|
}
|
|
3530
3690
|
return addRetailProduct;
|
|
@@ -3624,7 +3784,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3624
3784
|
}, {
|
|
3625
3785
|
key: "buildAvailabilityOperatingHoursSnapshot",
|
|
3626
3786
|
value: function buildAvailabilityOperatingHoursSnapshot(params) {
|
|
3627
|
-
var
|
|
3787
|
+
var _this8 = this;
|
|
3628
3788
|
var descriptor = params.prepare._availabilityOperatingHours || {
|
|
3629
3789
|
source: params.prepare.businessHours ? 'prepare_business_hours' : 'default_business_hours',
|
|
3630
3790
|
scheduleIds: []
|
|
@@ -3634,7 +3794,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3634
3794
|
var range = normalizeAvailabilityLocalDateTimeRange({
|
|
3635
3795
|
startAt: "".concat(date, "T").concat(params.businessHours.startTime, ":00"),
|
|
3636
3796
|
endAt: "".concat(date, "T").concat(params.businessHours.endTime, ":00"),
|
|
3637
|
-
fixedOffsetMinutes:
|
|
3797
|
+
fixedOffsetMinutes: _this8.getAvailabilityRuntimeOffsetMinutes(),
|
|
3638
3798
|
rollOverEnd: true
|
|
3639
3799
|
});
|
|
3640
3800
|
return range ? [{
|
|
@@ -3669,7 +3829,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3669
3829
|
var range = normalizeAvailabilityLocalDateTimeRange({
|
|
3670
3830
|
startAt: slot.start_at,
|
|
3671
3831
|
endAt: slot.end_at,
|
|
3672
|
-
fixedOffsetMinutes:
|
|
3832
|
+
fixedOffsetMinutes: _this8.getAvailabilityRuntimeOffsetMinutes(),
|
|
3673
3833
|
rollOverEnd: true
|
|
3674
3834
|
});
|
|
3675
3835
|
return range ? [{
|
|
@@ -3685,7 +3845,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3685
3845
|
var range = normalizeAvailabilityLocalDateTimeRange({
|
|
3686
3846
|
startAt: slot.start_at,
|
|
3687
3847
|
endAt: slot.end_at,
|
|
3688
|
-
fixedOffsetMinutes:
|
|
3848
|
+
fixedOffsetMinutes: _this8.getAvailabilityRuntimeOffsetMinutes(),
|
|
3689
3849
|
rollOverEnd: true
|
|
3690
3850
|
});
|
|
3691
3851
|
return range ? [{
|
|
@@ -3712,46 +3872,46 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3712
3872
|
}, {
|
|
3713
3873
|
key: "loadAvailabilityProducts",
|
|
3714
3874
|
value: function () {
|
|
3715
|
-
var _loadAvailabilityProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3875
|
+
var _loadAvailabilityProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
|
|
3716
3876
|
var _prepare$catalogScope,
|
|
3717
3877
|
_prepare$catalogScope2,
|
|
3718
|
-
|
|
3878
|
+
_this9 = this,
|
|
3719
3879
|
_prepare$resourceIds;
|
|
3720
3880
|
var prepare, dateRange, explicitProductIds, rawProducts, _this$store$schedule$6, _this$store$schedule6, _this$store$schedule$7, _this$store$schedule7, dateSet, scheduleProductIds, productIds, normalized, productIdSet;
|
|
3721
|
-
return _regeneratorRuntime().wrap(function
|
|
3722
|
-
while (1) switch (
|
|
3881
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
3882
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
3723
3883
|
case 0:
|
|
3724
3884
|
prepare = params.prepare, dateRange = params.dateRange;
|
|
3725
3885
|
explicitProductIds = prepare.productIds || [];
|
|
3726
3886
|
rawProducts = [];
|
|
3727
3887
|
if (!Array.isArray(prepare.rawProducts)) {
|
|
3728
|
-
|
|
3888
|
+
_context35.next = 8;
|
|
3729
3889
|
break;
|
|
3730
3890
|
}
|
|
3731
3891
|
rawProducts = prepare.rawProducts;
|
|
3732
3892
|
this.unifiedProductCatalog = _toConsumableArray(rawProducts);
|
|
3733
|
-
|
|
3893
|
+
_context35.next = 34;
|
|
3734
3894
|
break;
|
|
3735
3895
|
case 8:
|
|
3736
3896
|
if (!(explicitProductIds.length > 0)) {
|
|
3737
|
-
|
|
3897
|
+
_context35.next = 14;
|
|
3738
3898
|
break;
|
|
3739
3899
|
}
|
|
3740
|
-
|
|
3900
|
+
_context35.next = 11;
|
|
3741
3901
|
return this.loadProducts({
|
|
3742
3902
|
product_ids: explicitProductIds,
|
|
3743
3903
|
schedule_date: dateRange.startDate
|
|
3744
3904
|
});
|
|
3745
3905
|
case 11:
|
|
3746
|
-
rawProducts =
|
|
3747
|
-
|
|
3906
|
+
rawProducts = _context35.sent;
|
|
3907
|
+
_context35.next = 34;
|
|
3748
3908
|
break;
|
|
3749
3909
|
case 14:
|
|
3750
3910
|
if (!(((_prepare$catalogScope = prepare.catalogScope) === null || _prepare$catalogScope === void 0 ? void 0 : _prepare$catalogScope.type) === 'schedule')) {
|
|
3751
|
-
|
|
3911
|
+
_context35.next = 30;
|
|
3752
3912
|
break;
|
|
3753
3913
|
}
|
|
3754
|
-
|
|
3914
|
+
_context35.next = 17;
|
|
3755
3915
|
return this.loadScheduleAvailableDate({
|
|
3756
3916
|
startDate: dateRange.startDate,
|
|
3757
3917
|
endDate: dateRange.endDate,
|
|
@@ -3767,44 +3927,44 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3767
3927
|
});
|
|
3768
3928
|
productIds = uniqueAvailabilityIds([].concat(_toConsumableArray(scheduleProductIds), _toConsumableArray(((_this$store$schedule$7 = (_this$store$schedule7 = this.store.schedule).getOtherProductsIds) === null || _this$store$schedule$7 === void 0 ? void 0 : _this$store$schedule$7.call(_this$store$schedule7)) || [])));
|
|
3769
3929
|
if (!(productIds.length > 0)) {
|
|
3770
|
-
|
|
3930
|
+
_context35.next = 27;
|
|
3771
3931
|
break;
|
|
3772
3932
|
}
|
|
3773
3933
|
assertAvailabilityCatalogProductIds(productIds, 'prepare.catalogScope.scheduleProductIds');
|
|
3774
|
-
|
|
3934
|
+
_context35.next = 24;
|
|
3775
3935
|
return this.loadProducts({
|
|
3776
3936
|
product_ids: productIds,
|
|
3777
3937
|
schedule_date: dateRange.startDate
|
|
3778
3938
|
});
|
|
3779
3939
|
case 24:
|
|
3780
|
-
rawProducts =
|
|
3781
|
-
|
|
3940
|
+
rawProducts = _context35.sent;
|
|
3941
|
+
_context35.next = 28;
|
|
3782
3942
|
break;
|
|
3783
3943
|
case 27:
|
|
3784
3944
|
this.unifiedProductCatalog = [];
|
|
3785
3945
|
case 28:
|
|
3786
|
-
|
|
3946
|
+
_context35.next = 34;
|
|
3787
3947
|
break;
|
|
3788
3948
|
case 30:
|
|
3789
3949
|
if (!(((_prepare$catalogScope2 = prepare.catalogScope) === null || _prepare$catalogScope2 === void 0 ? void 0 : _prepare$catalogScope2.type) === 'productList')) {
|
|
3790
|
-
|
|
3950
|
+
_context35.next = 34;
|
|
3791
3951
|
break;
|
|
3792
3952
|
}
|
|
3793
|
-
|
|
3953
|
+
_context35.next = 33;
|
|
3794
3954
|
return this.loadProducts(_objectSpread(_objectSpread({}, prepare.catalogScope.params), {}, {
|
|
3795
3955
|
schedule_date: prepare.catalogScope.params.schedule_date || dateRange.startDate
|
|
3796
3956
|
}));
|
|
3797
3957
|
case 33:
|
|
3798
|
-
rawProducts =
|
|
3958
|
+
rawProducts = _context35.sent;
|
|
3799
3959
|
case 34:
|
|
3800
3960
|
normalized = rawProducts.map(function (product) {
|
|
3801
|
-
return normalizeProductForAvailability(product, params.scheduleList,
|
|
3961
|
+
return normalizeProductForAvailability(product, params.scheduleList, _this9.getAvailabilityRuntimeOffsetMinutes());
|
|
3802
3962
|
});
|
|
3803
3963
|
if (!(!explicitProductIds.length && (_prepare$resourceIds = prepare.resourceIds) !== null && _prepare$resourceIds !== void 0 && _prepare$resourceIds.length)) {
|
|
3804
|
-
|
|
3964
|
+
_context35.next = 37;
|
|
3805
3965
|
break;
|
|
3806
3966
|
}
|
|
3807
|
-
return
|
|
3967
|
+
return _context35.abrupt("return", normalized.filter(function (product) {
|
|
3808
3968
|
var _product$requirementG2;
|
|
3809
3969
|
return (_product$requirementG2 = product.requirementGroups) === null || _product$requirementG2 === void 0 ? void 0 : _product$requirementG2.some(function (group) {
|
|
3810
3970
|
var _group$resourceIds3;
|
|
@@ -3817,16 +3977,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3817
3977
|
}));
|
|
3818
3978
|
case 37:
|
|
3819
3979
|
productIdSet = explicitProductIds.length ? new Set(explicitProductIds.map(String)) : null;
|
|
3820
|
-
return
|
|
3980
|
+
return _context35.abrupt("return", productIdSet ? normalized.filter(function (product) {
|
|
3821
3981
|
return productIdSet.has(String(product.id));
|
|
3822
3982
|
}) : normalized);
|
|
3823
3983
|
case 39:
|
|
3824
3984
|
case "end":
|
|
3825
|
-
return
|
|
3985
|
+
return _context35.stop();
|
|
3826
3986
|
}
|
|
3827
|
-
},
|
|
3987
|
+
}, _callee35, this);
|
|
3828
3988
|
}));
|
|
3829
|
-
function loadAvailabilityProducts(
|
|
3989
|
+
function loadAvailabilityProducts(_x24) {
|
|
3830
3990
|
return _loadAvailabilityProducts.apply(this, arguments);
|
|
3831
3991
|
}
|
|
3832
3992
|
return loadAvailabilityProducts;
|
|
@@ -3839,12 +3999,12 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3839
3999
|
}, {
|
|
3840
4000
|
key: "fetchAvailabilityResourcesV2",
|
|
3841
4001
|
value: (function () {
|
|
3842
|
-
var _fetchAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4002
|
+
var _fetchAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
|
|
3843
4003
|
var response, data;
|
|
3844
|
-
return _regeneratorRuntime().wrap(function
|
|
3845
|
-
while (1) switch (
|
|
4004
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
4005
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
3846
4006
|
case 0:
|
|
3847
|
-
|
|
4007
|
+
_context36.next = 2;
|
|
3848
4008
|
return this.request.get('/schedule/resource/list/v2', {
|
|
3849
4009
|
start_date: params.dateRange.startDate,
|
|
3850
4010
|
end_date: params.dateRange.endDate,
|
|
@@ -3854,28 +4014,28 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3854
4014
|
useCache: false
|
|
3855
4015
|
});
|
|
3856
4016
|
case 2:
|
|
3857
|
-
response =
|
|
4017
|
+
response = _context36.sent;
|
|
3858
4018
|
data = response === null || response === void 0 ? void 0 : response.data;
|
|
3859
4019
|
if (!Array.isArray(data)) {
|
|
3860
|
-
|
|
4020
|
+
_context36.next = 6;
|
|
3861
4021
|
break;
|
|
3862
4022
|
}
|
|
3863
|
-
return
|
|
4023
|
+
return _context36.abrupt("return", data);
|
|
3864
4024
|
case 6:
|
|
3865
4025
|
if (!Array.isArray(data === null || data === void 0 ? void 0 : data.list)) {
|
|
3866
|
-
|
|
4026
|
+
_context36.next = 8;
|
|
3867
4027
|
break;
|
|
3868
4028
|
}
|
|
3869
|
-
return
|
|
4029
|
+
return _context36.abrupt("return", data.list);
|
|
3870
4030
|
case 8:
|
|
3871
|
-
return
|
|
4031
|
+
return _context36.abrupt("return", []);
|
|
3872
4032
|
case 9:
|
|
3873
4033
|
case "end":
|
|
3874
|
-
return
|
|
4034
|
+
return _context36.stop();
|
|
3875
4035
|
}
|
|
3876
|
-
},
|
|
4036
|
+
}, _callee36, this);
|
|
3877
4037
|
}));
|
|
3878
|
-
function fetchAvailabilityResourcesV2(
|
|
4038
|
+
function fetchAvailabilityResourcesV2(_x25) {
|
|
3879
4039
|
return _fetchAvailabilityResourcesV.apply(this, arguments);
|
|
3880
4040
|
}
|
|
3881
4041
|
return fetchAvailabilityResourcesV2;
|
|
@@ -3883,17 +4043,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3883
4043
|
}, {
|
|
3884
4044
|
key: "fetchAndPublishAvailabilityResourcesV2",
|
|
3885
4045
|
value: function () {
|
|
3886
|
-
var _fetchAndPublishAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4046
|
+
var _fetchAndPublishAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
|
|
3887
4047
|
var normalizedResourceIds, scopeKey, cacheParams, cachedRawResources;
|
|
3888
|
-
return _regeneratorRuntime().wrap(function
|
|
3889
|
-
while (1) switch (
|
|
4048
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
4049
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
3890
4050
|
case 0:
|
|
3891
4051
|
normalizedResourceIds = this.normalizeAvailabilityIdList(params.resourceIds) || [];
|
|
3892
4052
|
if (!(normalizedResourceIds.length === 0)) {
|
|
3893
|
-
|
|
4053
|
+
_context37.next = 3;
|
|
3894
4054
|
break;
|
|
3895
4055
|
}
|
|
3896
|
-
return
|
|
4056
|
+
return _context37.abrupt("return", []);
|
|
3897
4057
|
case 3:
|
|
3898
4058
|
scopeKey = this.buildAvailabilityRemoteResourceScopeKey(params.timezone);
|
|
3899
4059
|
cacheParams = {
|
|
@@ -3903,7 +4063,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3903
4063
|
};
|
|
3904
4064
|
cachedRawResources = this.availabilityRemoteOccupancyCache.read(cacheParams);
|
|
3905
4065
|
if (!cachedRawResources) {
|
|
3906
|
-
|
|
4066
|
+
_context37.next = 9;
|
|
3907
4067
|
break;
|
|
3908
4068
|
}
|
|
3909
4069
|
if (params.useCacheOnHit) {
|
|
@@ -3915,23 +4075,23 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3915
4075
|
console.warn('[UnifiedBookingSales] Remote occupancy background refresh failed', error);
|
|
3916
4076
|
});
|
|
3917
4077
|
}
|
|
3918
|
-
return
|
|
4078
|
+
return _context37.abrupt("return", cachedRawResources);
|
|
3919
4079
|
case 9:
|
|
3920
|
-
|
|
4080
|
+
_context37.next = 11;
|
|
3921
4081
|
return this.refreshAvailabilityRemoteResourceQuery({
|
|
3922
4082
|
timezone: params.timezone,
|
|
3923
4083
|
dateRange: params.dateRange,
|
|
3924
4084
|
resourceIds: normalizedResourceIds
|
|
3925
4085
|
});
|
|
3926
4086
|
case 11:
|
|
3927
|
-
return
|
|
4087
|
+
return _context37.abrupt("return", _context37.sent);
|
|
3928
4088
|
case 12:
|
|
3929
4089
|
case "end":
|
|
3930
|
-
return
|
|
4090
|
+
return _context37.stop();
|
|
3931
4091
|
}
|
|
3932
|
-
},
|
|
4092
|
+
}, _callee37, this);
|
|
3933
4093
|
}));
|
|
3934
|
-
function fetchAndPublishAvailabilityResourcesV2(
|
|
4094
|
+
function fetchAndPublishAvailabilityResourcesV2(_x26) {
|
|
3935
4095
|
return _fetchAndPublishAvailabilityResourcesV.apply(this, arguments);
|
|
3936
4096
|
}
|
|
3937
4097
|
return fetchAndPublishAvailabilityResourcesV2;
|
|
@@ -3939,17 +4099,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3939
4099
|
}, {
|
|
3940
4100
|
key: "refreshAvailabilityRemoteResourceQuery",
|
|
3941
4101
|
value: function () {
|
|
3942
|
-
var _refreshAvailabilityRemoteResourceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4102
|
+
var _refreshAvailabilityRemoteResourceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
|
|
3943
4103
|
var normalizedResourceIds, queryKey, epoch, existing, writeVersion, promise, rawResources, current;
|
|
3944
|
-
return _regeneratorRuntime().wrap(function
|
|
3945
|
-
while (1) switch (
|
|
4104
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
4105
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
3946
4106
|
case 0:
|
|
3947
4107
|
normalizedResourceIds = this.normalizeAvailabilityIdList(params.resourceIds) || [];
|
|
3948
4108
|
if (!(normalizedResourceIds.length === 0)) {
|
|
3949
|
-
|
|
4109
|
+
_context38.next = 3;
|
|
3950
4110
|
break;
|
|
3951
4111
|
}
|
|
3952
|
-
return
|
|
4112
|
+
return _context38.abrupt("return", []);
|
|
3953
4113
|
case 3:
|
|
3954
4114
|
queryKey = this.buildAvailabilityRemoteResourceQueryKey({
|
|
3955
4115
|
timezone: params.timezone,
|
|
@@ -3959,13 +4119,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3959
4119
|
epoch = this.availabilityRemoteResourceEpoch;
|
|
3960
4120
|
existing = this.availabilityRemoteResourceQueryInFlight.get(queryKey);
|
|
3961
4121
|
if (!((existing === null || existing === void 0 ? void 0 : existing.epoch) === epoch)) {
|
|
3962
|
-
|
|
4122
|
+
_context38.next = 10;
|
|
3963
4123
|
break;
|
|
3964
4124
|
}
|
|
3965
|
-
|
|
4125
|
+
_context38.next = 9;
|
|
3966
4126
|
return existing.promise;
|
|
3967
4127
|
case 9:
|
|
3968
|
-
return
|
|
4128
|
+
return _context38.abrupt("return", _context38.sent);
|
|
3969
4129
|
case 10:
|
|
3970
4130
|
this.availabilityRemoteResourceQuerySequence += 1;
|
|
3971
4131
|
writeVersion = this.availabilityRemoteResourceQuerySequence;
|
|
@@ -3977,11 +4137,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3977
4137
|
epoch: epoch,
|
|
3978
4138
|
promise: promise
|
|
3979
4139
|
});
|
|
3980
|
-
|
|
3981
|
-
|
|
4140
|
+
_context38.prev = 14;
|
|
4141
|
+
_context38.next = 17;
|
|
3982
4142
|
return promise;
|
|
3983
4143
|
case 17:
|
|
3984
|
-
rawResources =
|
|
4144
|
+
rawResources = _context38.sent;
|
|
3985
4145
|
if (epoch === this.availabilityRemoteResourceEpoch) {
|
|
3986
4146
|
this.availabilityRemoteOccupancyCache.publish({
|
|
3987
4147
|
scopeKey: this.buildAvailabilityRemoteResourceScopeKey(params.timezone),
|
|
@@ -3992,21 +4152,21 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
3992
4152
|
version: writeVersion
|
|
3993
4153
|
});
|
|
3994
4154
|
}
|
|
3995
|
-
return
|
|
4155
|
+
return _context38.abrupt("return", rawResources);
|
|
3996
4156
|
case 20:
|
|
3997
|
-
|
|
4157
|
+
_context38.prev = 20;
|
|
3998
4158
|
current = this.availabilityRemoteResourceQueryInFlight.get(queryKey);
|
|
3999
4159
|
if ((current === null || current === void 0 ? void 0 : current.promise) === promise) {
|
|
4000
4160
|
this.availabilityRemoteResourceQueryInFlight.delete(queryKey);
|
|
4001
4161
|
}
|
|
4002
|
-
return
|
|
4162
|
+
return _context38.finish(20);
|
|
4003
4163
|
case 24:
|
|
4004
4164
|
case "end":
|
|
4005
|
-
return
|
|
4165
|
+
return _context38.stop();
|
|
4006
4166
|
}
|
|
4007
|
-
},
|
|
4167
|
+
}, _callee38, this, [[14,, 20, 24]]);
|
|
4008
4168
|
}));
|
|
4009
|
-
function refreshAvailabilityRemoteResourceQuery(
|
|
4169
|
+
function refreshAvailabilityRemoteResourceQuery(_x27) {
|
|
4010
4170
|
return _refreshAvailabilityRemoteResourceQuery.apply(this, arguments);
|
|
4011
4171
|
}
|
|
4012
4172
|
return refreshAvailabilityRemoteResourceQuery;
|
|
@@ -4014,26 +4174,26 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4014
4174
|
}, {
|
|
4015
4175
|
key: "loadAvailabilityResources",
|
|
4016
4176
|
value: function () {
|
|
4017
|
-
var _loadAvailabilityResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4177
|
+
var _loadAvailabilityResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
4018
4178
|
var resourceIds, cachedRawResources, rawResources;
|
|
4019
|
-
return _regeneratorRuntime().wrap(function
|
|
4020
|
-
while (1) switch (
|
|
4179
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
4180
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
4021
4181
|
case 0:
|
|
4022
4182
|
resourceIds = collectAvailabilityResourceIds(params.products, params.resourceIds || []);
|
|
4023
4183
|
if (!(resourceIds.length === 0)) {
|
|
4024
|
-
|
|
4184
|
+
_context39.next = 3;
|
|
4025
4185
|
break;
|
|
4026
4186
|
}
|
|
4027
|
-
return
|
|
4187
|
+
return _context39.abrupt("return", {
|
|
4028
4188
|
resources: [],
|
|
4029
4189
|
resourceOccupancies: []
|
|
4030
4190
|
});
|
|
4031
4191
|
case 3:
|
|
4032
4192
|
if (!Array.isArray(params.rawResources)) {
|
|
4033
|
-
|
|
4193
|
+
_context39.next = 5;
|
|
4034
4194
|
break;
|
|
4035
4195
|
}
|
|
4036
|
-
return
|
|
4196
|
+
return _context39.abrupt("return", buildAvailabilityResourcesFromV2({
|
|
4037
4197
|
rawResources: params.rawResources,
|
|
4038
4198
|
scheduleList: params.scheduleList,
|
|
4039
4199
|
dateRange: params.dateRange,
|
|
@@ -4041,7 +4201,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4041
4201
|
}));
|
|
4042
4202
|
case 5:
|
|
4043
4203
|
if (!(params.fetchPolicy === 'cache_only')) {
|
|
4044
|
-
|
|
4204
|
+
_context39.next = 10;
|
|
4045
4205
|
break;
|
|
4046
4206
|
}
|
|
4047
4207
|
cachedRawResources = this.availabilityRemoteOccupancyCache.read({
|
|
@@ -4050,22 +4210,22 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4050
4210
|
dateRange: params.dateRange
|
|
4051
4211
|
});
|
|
4052
4212
|
if (!cachedRawResources) {
|
|
4053
|
-
|
|
4213
|
+
_context39.next = 9;
|
|
4054
4214
|
break;
|
|
4055
4215
|
}
|
|
4056
|
-
return
|
|
4216
|
+
return _context39.abrupt("return", buildAvailabilityResourcesFromV2({
|
|
4057
4217
|
rawResources: cachedRawResources,
|
|
4058
4218
|
scheduleList: params.scheduleList,
|
|
4059
4219
|
dateRange: params.dateRange,
|
|
4060
4220
|
fixedOffsetMinutes: this.getAvailabilityRuntimeOffsetMinutes()
|
|
4061
4221
|
}));
|
|
4062
4222
|
case 9:
|
|
4063
|
-
return
|
|
4223
|
+
return _context39.abrupt("return", params.fallbackResources ? cloneDeep(params.fallbackResources) : {
|
|
4064
4224
|
resources: [],
|
|
4065
4225
|
resourceOccupancies: []
|
|
4066
4226
|
});
|
|
4067
4227
|
case 10:
|
|
4068
|
-
|
|
4228
|
+
_context39.next = 12;
|
|
4069
4229
|
return this.fetchAndPublishAvailabilityResourcesV2({
|
|
4070
4230
|
timezone: params.timezone,
|
|
4071
4231
|
dateRange: params.dateRange,
|
|
@@ -4073,8 +4233,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4073
4233
|
useCacheOnHit: true
|
|
4074
4234
|
});
|
|
4075
4235
|
case 12:
|
|
4076
|
-
rawResources =
|
|
4077
|
-
return
|
|
4236
|
+
rawResources = _context39.sent;
|
|
4237
|
+
return _context39.abrupt("return", buildAvailabilityResourcesFromV2({
|
|
4078
4238
|
rawResources: rawResources,
|
|
4079
4239
|
scheduleList: params.scheduleList,
|
|
4080
4240
|
dateRange: params.dateRange,
|
|
@@ -4082,11 +4242,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4082
4242
|
}));
|
|
4083
4243
|
case 14:
|
|
4084
4244
|
case "end":
|
|
4085
|
-
return
|
|
4245
|
+
return _context39.stop();
|
|
4086
4246
|
}
|
|
4087
|
-
},
|
|
4247
|
+
}, _callee39, this);
|
|
4088
4248
|
}));
|
|
4089
|
-
function loadAvailabilityResources(
|
|
4249
|
+
function loadAvailabilityResources(_x28) {
|
|
4090
4250
|
return _loadAvailabilityResources.apply(this, arguments);
|
|
4091
4251
|
}
|
|
4092
4252
|
return loadAvailabilityResources;
|
|
@@ -4159,7 +4319,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4159
4319
|
}, {
|
|
4160
4320
|
key: "collectCartResourceOccupancies",
|
|
4161
4321
|
value: function collectCartResourceOccupancies(tempOrder, exclusions) {
|
|
4162
|
-
var
|
|
4322
|
+
var _this10 = this;
|
|
4163
4323
|
var bookings = Array.isArray(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.bookings) ? tempOrder.bookings : [];
|
|
4164
4324
|
return bookings.flatMap(function (booking) {
|
|
4165
4325
|
var _ref48, _booking$product_uid2, _booking$metadata2;
|
|
@@ -4176,7 +4336,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4176
4336
|
var range = normalizeAvailabilityLocalDateTimeRange({
|
|
4177
4337
|
startAt: startAt,
|
|
4178
4338
|
endAt: endAt,
|
|
4179
|
-
fixedOffsetMinutes:
|
|
4339
|
+
fixedOffsetMinutes: _this10.getAvailabilityRuntimeOffsetMinutes(),
|
|
4180
4340
|
rollOverEnd: false
|
|
4181
4341
|
});
|
|
4182
4342
|
if (!range) return [];
|
|
@@ -4194,7 +4354,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4194
4354
|
resource: resource
|
|
4195
4355
|
}
|
|
4196
4356
|
};
|
|
4197
|
-
return
|
|
4357
|
+
return _this10.occupancyIsExcluded(occupancy, exclusions) ? [] : [occupancy];
|
|
4198
4358
|
});
|
|
4199
4359
|
});
|
|
4200
4360
|
}
|
|
@@ -4261,16 +4421,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4261
4421
|
}, {
|
|
4262
4422
|
key: "assertContextualQueryFreshness",
|
|
4263
4423
|
value: function assertContextualQueryFreshness(context, request) {
|
|
4264
|
-
var
|
|
4424
|
+
var _this11 = this;
|
|
4265
4425
|
if (request.target === 'time') {
|
|
4266
4426
|
request.candidates.forEach(function (candidate) {
|
|
4267
|
-
|
|
4427
|
+
_this11.assertAvailabilityCandidateFreshness(context, candidate);
|
|
4268
4428
|
});
|
|
4269
4429
|
return;
|
|
4270
4430
|
}
|
|
4271
4431
|
if (request.target === 'resource') {
|
|
4272
4432
|
request.selectedRanges.forEach(function (candidate) {
|
|
4273
|
-
|
|
4433
|
+
_this11.assertAvailabilityCandidateFreshness(context, candidate);
|
|
4274
4434
|
});
|
|
4275
4435
|
}
|
|
4276
4436
|
}
|
|
@@ -4317,8 +4477,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4317
4477
|
}, {
|
|
4318
4478
|
key: "buildAvailabilityProjectionSnapshot",
|
|
4319
4479
|
value: function () {
|
|
4320
|
-
var _buildAvailabilityProjectionSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4321
|
-
var
|
|
4480
|
+
var _buildAvailabilityProjectionSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
|
|
4481
|
+
var _this12 = this;
|
|
4322
4482
|
var options,
|
|
4323
4483
|
normalizedPrepareParams,
|
|
4324
4484
|
timezoneLabel,
|
|
@@ -4339,11 +4499,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4339
4499
|
durationCandidateAnchorAt,
|
|
4340
4500
|
orderRevision,
|
|
4341
4501
|
projection,
|
|
4342
|
-
|
|
4343
|
-
return _regeneratorRuntime().wrap(function
|
|
4344
|
-
while (1) switch (
|
|
4502
|
+
_args40 = arguments;
|
|
4503
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
4504
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
4345
4505
|
case 0:
|
|
4346
|
-
options =
|
|
4506
|
+
options = _args40.length > 1 && _args40[1] !== undefined ? _args40[1] : {};
|
|
4347
4507
|
normalizedPrepareParams = this.normalizeAvailabilityPrepareDescriptor(params);
|
|
4348
4508
|
timezoneLabel = String(normalizedPrepareParams.timezone);
|
|
4349
4509
|
dateRange = normalizedPrepareParams.dateRange;
|
|
@@ -4357,15 +4517,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4357
4517
|
scheduleList: scheduleList,
|
|
4358
4518
|
businessHours: businessHours
|
|
4359
4519
|
});
|
|
4360
|
-
|
|
4520
|
+
_context40.next = 11;
|
|
4361
4521
|
return this.loadAvailabilityProducts({
|
|
4362
4522
|
prepare: normalizedPrepareParams,
|
|
4363
4523
|
dateRange: dateRange,
|
|
4364
4524
|
scheduleList: scheduleList
|
|
4365
4525
|
});
|
|
4366
4526
|
case 11:
|
|
4367
|
-
products =
|
|
4368
|
-
|
|
4527
|
+
products = _context40.sent;
|
|
4528
|
+
_context40.next = 14;
|
|
4369
4529
|
return this.loadAvailabilityResources({
|
|
4370
4530
|
timezone: timezoneLabel,
|
|
4371
4531
|
dateRange: dateRange,
|
|
@@ -4377,14 +4537,14 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4377
4537
|
fallbackResources: options.fallbackResources
|
|
4378
4538
|
});
|
|
4379
4539
|
case 14:
|
|
4380
|
-
loadedResources =
|
|
4540
|
+
loadedResources = _context40.sent;
|
|
4381
4541
|
tempOrder = this.getTempOrder();
|
|
4382
4542
|
exclusions = this.resolveEditingOccupancyExclusions(tempOrder, normalizedPrepareParams.editingProductLineUids);
|
|
4383
4543
|
injectedRawOccupancies = (normalizedPrepareParams.rawOccupancies || []).flatMap(function (occupancy) {
|
|
4384
4544
|
var range = normalizeAvailabilityLocalDateTimeRange({
|
|
4385
4545
|
startAt: occupancy.startAt,
|
|
4386
4546
|
endAt: occupancy.endAt,
|
|
4387
|
-
fixedOffsetMinutes:
|
|
4547
|
+
fixedOffsetMinutes: _this12.getAvailabilityRuntimeOffsetMinutes(),
|
|
4388
4548
|
rollOverEnd: false
|
|
4389
4549
|
});
|
|
4390
4550
|
if (!range) return [];
|
|
@@ -4394,7 +4554,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4394
4554
|
})];
|
|
4395
4555
|
});
|
|
4396
4556
|
remoteOccupancies = [].concat(_toConsumableArray(loadedResources.resourceOccupancies), _toConsumableArray(loadedResources.includesInjectedRawOccupancies ? [] : injectedRawOccupancies)).filter(function (occupancy) {
|
|
4397
|
-
return !
|
|
4557
|
+
return !_this12.occupancyIsExcluded(occupancy, exclusions);
|
|
4398
4558
|
});
|
|
4399
4559
|
cartOccupancies = this.collectCartResourceOccupancies(tempOrder, exclusions);
|
|
4400
4560
|
preparedAt = this.getAvailabilityRuntimeDateTime();
|
|
@@ -4423,18 +4583,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4423
4583
|
prepareParams: normalizedPrepareParams,
|
|
4424
4584
|
durationCandidateAnchorAt: durationCandidateAnchorAt
|
|
4425
4585
|
});
|
|
4426
|
-
return
|
|
4586
|
+
return _context40.abrupt("return", {
|
|
4427
4587
|
projection: projection,
|
|
4428
4588
|
prepareParams: normalizedPrepareParams,
|
|
4429
4589
|
orderRevision: orderRevision
|
|
4430
4590
|
});
|
|
4431
4591
|
case 26:
|
|
4432
4592
|
case "end":
|
|
4433
|
-
return
|
|
4593
|
+
return _context40.stop();
|
|
4434
4594
|
}
|
|
4435
|
-
},
|
|
4595
|
+
}, _callee40, this);
|
|
4436
4596
|
}));
|
|
4437
|
-
function buildAvailabilityProjectionSnapshot(
|
|
4597
|
+
function buildAvailabilityProjectionSnapshot(_x29) {
|
|
4438
4598
|
return _buildAvailabilityProjectionSnapshot.apply(this, arguments);
|
|
4439
4599
|
}
|
|
4440
4600
|
return buildAvailabilityProjectionSnapshot;
|
|
@@ -4442,10 +4602,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4442
4602
|
}, {
|
|
4443
4603
|
key: "getSharedPreparedAvailabilitySnapshot",
|
|
4444
4604
|
value: function () {
|
|
4445
|
-
var _getSharedPreparedAvailabilitySnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4605
|
+
var _getSharedPreparedAvailabilitySnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
|
|
4446
4606
|
var lifecycleGeneration, normalizedParams, hasRawInputs, prepareKey, snapshot, existing, promise, _snapshot, current;
|
|
4447
|
-
return _regeneratorRuntime().wrap(function
|
|
4448
|
-
while (1) switch (
|
|
4607
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
4608
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
4449
4609
|
case 0:
|
|
4450
4610
|
lifecycleGeneration = this.availabilityLifecycleGeneration;
|
|
4451
4611
|
normalizedParams = this.normalizeAvailabilityPrepareDescriptor(params);
|
|
@@ -4464,15 +4624,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4464
4624
|
}
|
|
4465
4625
|
})) : this.buildAvailabilityPrepareKey(normalizedParams);
|
|
4466
4626
|
if (!hasRawInputs) {
|
|
4467
|
-
|
|
4627
|
+
_context41.next = 11;
|
|
4468
4628
|
break;
|
|
4469
4629
|
}
|
|
4470
|
-
|
|
4630
|
+
_context41.next = 7;
|
|
4471
4631
|
return this.buildAvailabilityProjectionSnapshot(normalizedParams);
|
|
4472
4632
|
case 7:
|
|
4473
|
-
snapshot =
|
|
4633
|
+
snapshot = _context41.sent;
|
|
4474
4634
|
if (!(lifecycleGeneration !== this.availabilityLifecycleGeneration)) {
|
|
4475
|
-
|
|
4635
|
+
_context41.next = 10;
|
|
4476
4636
|
break;
|
|
4477
4637
|
}
|
|
4478
4638
|
throw this.createAvailabilityFacadeError('AVAILABILITY_CONTEXT_NOT_FOUND', 'prepare 期间业务作用域或实例生命周期已变化,请重新 prepare', {
|
|
@@ -4481,7 +4641,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4481
4641
|
currentLifecycleGeneration: this.availabilityLifecycleGeneration
|
|
4482
4642
|
});
|
|
4483
4643
|
case 10:
|
|
4484
|
-
return
|
|
4644
|
+
return _context41.abrupt("return", {
|
|
4485
4645
|
prepareKey: prepareKey,
|
|
4486
4646
|
snapshot: snapshot
|
|
4487
4647
|
});
|
|
@@ -4495,13 +4655,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4495
4655
|
promise: promise
|
|
4496
4656
|
});
|
|
4497
4657
|
}
|
|
4498
|
-
|
|
4499
|
-
|
|
4658
|
+
_context41.prev = 14;
|
|
4659
|
+
_context41.next = 17;
|
|
4500
4660
|
return promise;
|
|
4501
4661
|
case 17:
|
|
4502
|
-
_snapshot =
|
|
4662
|
+
_snapshot = _context41.sent;
|
|
4503
4663
|
if (!(lifecycleGeneration !== this.availabilityLifecycleGeneration)) {
|
|
4504
|
-
|
|
4664
|
+
_context41.next = 20;
|
|
4505
4665
|
break;
|
|
4506
4666
|
}
|
|
4507
4667
|
throw this.createAvailabilityFacadeError('AVAILABILITY_CONTEXT_NOT_FOUND', 'prepare 期间业务作用域或实例生命周期已变化,请重新 prepare', {
|
|
@@ -4510,24 +4670,24 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4510
4670
|
currentLifecycleGeneration: this.availabilityLifecycleGeneration
|
|
4511
4671
|
});
|
|
4512
4672
|
case 20:
|
|
4513
|
-
return
|
|
4673
|
+
return _context41.abrupt("return", {
|
|
4514
4674
|
prepareKey: prepareKey,
|
|
4515
4675
|
snapshot: _snapshot
|
|
4516
4676
|
});
|
|
4517
4677
|
case 21:
|
|
4518
|
-
|
|
4678
|
+
_context41.prev = 21;
|
|
4519
4679
|
current = this.availabilityPrepareInFlight.get(prepareKey);
|
|
4520
4680
|
if ((current === null || current === void 0 ? void 0 : current.promise) === promise) {
|
|
4521
4681
|
this.availabilityPrepareInFlight.delete(prepareKey);
|
|
4522
4682
|
}
|
|
4523
|
-
return
|
|
4683
|
+
return _context41.finish(21);
|
|
4524
4684
|
case 25:
|
|
4525
4685
|
case "end":
|
|
4526
|
-
return
|
|
4686
|
+
return _context41.stop();
|
|
4527
4687
|
}
|
|
4528
|
-
},
|
|
4688
|
+
}, _callee41, this, [[14,, 21, 25]]);
|
|
4529
4689
|
}));
|
|
4530
|
-
function getSharedPreparedAvailabilitySnapshot(
|
|
4690
|
+
function getSharedPreparedAvailabilitySnapshot(_x30) {
|
|
4531
4691
|
return _getSharedPreparedAvailabilitySnapshot.apply(this, arguments);
|
|
4532
4692
|
}
|
|
4533
4693
|
return getSharedPreparedAvailabilitySnapshot;
|
|
@@ -4535,51 +4695,51 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4535
4695
|
}, {
|
|
4536
4696
|
key: "refreshAvailabilityContextProjection",
|
|
4537
4697
|
value: function () {
|
|
4538
|
-
var _refreshAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4539
|
-
var
|
|
4698
|
+
var _refreshAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
|
|
4699
|
+
var _this13 = this;
|
|
4540
4700
|
var existingInFlight, context, expectedVersion, expectedRefreshNonce, expectedLifecycleGeneration, refreshPromise, current;
|
|
4541
|
-
return _regeneratorRuntime().wrap(function
|
|
4542
|
-
while (1) switch (
|
|
4701
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
4702
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
4543
4703
|
case 0:
|
|
4544
4704
|
existingInFlight = this.availabilityProjectionRefreshInFlight.get(params.contextId);
|
|
4545
4705
|
if (!existingInFlight) {
|
|
4546
|
-
|
|
4706
|
+
_context43.next = 5;
|
|
4547
4707
|
break;
|
|
4548
4708
|
}
|
|
4549
|
-
|
|
4709
|
+
_context43.next = 4;
|
|
4550
4710
|
return existingInFlight;
|
|
4551
4711
|
case 4:
|
|
4552
|
-
return
|
|
4712
|
+
return _context43.abrupt("return", _context43.sent);
|
|
4553
4713
|
case 5:
|
|
4554
4714
|
context = this.getAvailabilityContextEntry(params.contextId);
|
|
4555
4715
|
expectedVersion = context.activeVersion;
|
|
4556
4716
|
expectedRefreshNonce = context.refreshNonce;
|
|
4557
4717
|
expectedLifecycleGeneration = this.availabilityLifecycleGeneration;
|
|
4558
|
-
refreshPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4718
|
+
refreshPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42() {
|
|
4559
4719
|
var snapshot, currentContext, projectionEntry;
|
|
4560
|
-
return _regeneratorRuntime().wrap(function
|
|
4561
|
-
while (1) switch (
|
|
4720
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
4721
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
4562
4722
|
case 0:
|
|
4563
|
-
|
|
4564
|
-
return
|
|
4723
|
+
_context42.next = 2;
|
|
4724
|
+
return _this13.buildAvailabilityProjectionSnapshot(_this13.cloneAvailabilityPrepareParams(context.prepareParams), {
|
|
4565
4725
|
durationCandidateAnchorAt: context.durationCandidateAnchorAt
|
|
4566
4726
|
});
|
|
4567
4727
|
case 2:
|
|
4568
|
-
snapshot =
|
|
4569
|
-
currentContext =
|
|
4728
|
+
snapshot = _context42.sent;
|
|
4729
|
+
currentContext = _this13.availabilityContextRegistry.get(params.contextId);
|
|
4570
4730
|
if (currentContext) {
|
|
4571
|
-
|
|
4731
|
+
_context42.next = 6;
|
|
4572
4732
|
break;
|
|
4573
4733
|
}
|
|
4574
|
-
return
|
|
4734
|
+
return _context42.abrupt("return", null);
|
|
4575
4735
|
case 6:
|
|
4576
|
-
if (!(expectedLifecycleGeneration !==
|
|
4577
|
-
|
|
4736
|
+
if (!(expectedLifecycleGeneration !== _this13.availabilityLifecycleGeneration || currentContext.activeVersion !== expectedVersion || currentContext.refreshNonce !== expectedRefreshNonce || currentContext.lifecycleGeneration !== expectedLifecycleGeneration)) {
|
|
4737
|
+
_context42.next = 8;
|
|
4578
4738
|
break;
|
|
4579
4739
|
}
|
|
4580
|
-
return
|
|
4740
|
+
return _context42.abrupt("return", null);
|
|
4581
4741
|
case 8:
|
|
4582
|
-
projectionEntry =
|
|
4742
|
+
projectionEntry = _this13.storeAvailabilityProjectionEntry({
|
|
4583
4743
|
contextId: currentContext.contextId,
|
|
4584
4744
|
prepareParams: snapshot.prepareParams,
|
|
4585
4745
|
prepareKey: currentContext.prepareKey,
|
|
@@ -4587,8 +4747,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4587
4747
|
orderRevision: snapshot.orderRevision,
|
|
4588
4748
|
incrementVersion: true
|
|
4589
4749
|
});
|
|
4590
|
-
|
|
4591
|
-
return
|
|
4750
|
+
_context42.next = 11;
|
|
4751
|
+
return _this13.emitAvailabilityDiagnostic({
|
|
4592
4752
|
action: 'refresh',
|
|
4593
4753
|
contextId: currentContext.contextId,
|
|
4594
4754
|
contextVersion: projectionEntry.contextVersion,
|
|
@@ -4599,33 +4759,33 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4599
4759
|
reason: params.reason
|
|
4600
4760
|
});
|
|
4601
4761
|
case 11:
|
|
4602
|
-
return
|
|
4762
|
+
return _context42.abrupt("return", projectionEntry);
|
|
4603
4763
|
case 12:
|
|
4604
4764
|
case "end":
|
|
4605
|
-
return
|
|
4765
|
+
return _context42.stop();
|
|
4606
4766
|
}
|
|
4607
|
-
},
|
|
4767
|
+
}, _callee42);
|
|
4608
4768
|
}))();
|
|
4609
4769
|
this.availabilityProjectionRefreshInFlight.set(params.contextId, refreshPromise);
|
|
4610
|
-
|
|
4611
|
-
|
|
4770
|
+
_context43.prev = 11;
|
|
4771
|
+
_context43.next = 14;
|
|
4612
4772
|
return refreshPromise;
|
|
4613
4773
|
case 14:
|
|
4614
|
-
return
|
|
4774
|
+
return _context43.abrupt("return", _context43.sent);
|
|
4615
4775
|
case 15:
|
|
4616
|
-
|
|
4776
|
+
_context43.prev = 15;
|
|
4617
4777
|
current = this.availabilityProjectionRefreshInFlight.get(params.contextId);
|
|
4618
4778
|
if (current === refreshPromise) {
|
|
4619
4779
|
this.availabilityProjectionRefreshInFlight.delete(params.contextId);
|
|
4620
4780
|
}
|
|
4621
|
-
return
|
|
4781
|
+
return _context43.finish(15);
|
|
4622
4782
|
case 19:
|
|
4623
4783
|
case "end":
|
|
4624
|
-
return
|
|
4784
|
+
return _context43.stop();
|
|
4625
4785
|
}
|
|
4626
|
-
},
|
|
4786
|
+
}, _callee43, this, [[11,, 15, 19]]);
|
|
4627
4787
|
}));
|
|
4628
|
-
function refreshAvailabilityContextProjection(
|
|
4788
|
+
function refreshAvailabilityContextProjection(_x31) {
|
|
4629
4789
|
return _refreshAvailabilityContextProjection.apply(this, arguments);
|
|
4630
4790
|
}
|
|
4631
4791
|
return refreshAvailabilityContextProjection;
|
|
@@ -4633,53 +4793,53 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4633
4793
|
}, {
|
|
4634
4794
|
key: "ensureAvailabilityContextProjection",
|
|
4635
4795
|
value: function () {
|
|
4636
|
-
var _ensureAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4796
|
+
var _ensureAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(contextId, reason) {
|
|
4637
4797
|
var retries, context, currentOrderRevision, projectionEntry, refreshedProjectionEntry;
|
|
4638
|
-
return _regeneratorRuntime().wrap(function
|
|
4639
|
-
while (1) switch (
|
|
4798
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
4799
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
4640
4800
|
case 0:
|
|
4641
4801
|
retries = 0;
|
|
4642
4802
|
case 1:
|
|
4643
4803
|
if (!(retries < 3)) {
|
|
4644
|
-
|
|
4804
|
+
_context44.next = 19;
|
|
4645
4805
|
break;
|
|
4646
4806
|
}
|
|
4647
4807
|
context = this.getAvailabilityContextEntry(contextId);
|
|
4648
4808
|
currentOrderRevision = this.getCurrentOrderRevision();
|
|
4649
4809
|
projectionEntry = this.getActiveAvailabilityProjectionEntry(context);
|
|
4650
4810
|
if (!(projectionEntry && projectionEntry.orderRevision === currentOrderRevision)) {
|
|
4651
|
-
|
|
4811
|
+
_context44.next = 7;
|
|
4652
4812
|
break;
|
|
4653
4813
|
}
|
|
4654
|
-
return
|
|
4814
|
+
return _context44.abrupt("return", {
|
|
4655
4815
|
context: context,
|
|
4656
4816
|
projectionEntry: projectionEntry,
|
|
4657
4817
|
refreshed: false
|
|
4658
4818
|
});
|
|
4659
4819
|
case 7:
|
|
4660
|
-
|
|
4820
|
+
_context44.next = 9;
|
|
4661
4821
|
return this.refreshAvailabilityContextProjection({
|
|
4662
4822
|
contextId: contextId,
|
|
4663
4823
|
reason: projectionEntry ? reason : "".concat(reason, ":projection_cache_miss"),
|
|
4664
4824
|
previousOrderRevision: context.lastKnownOrderRevision
|
|
4665
4825
|
});
|
|
4666
4826
|
case 9:
|
|
4667
|
-
refreshedProjectionEntry =
|
|
4827
|
+
refreshedProjectionEntry = _context44.sent;
|
|
4668
4828
|
if (refreshedProjectionEntry) {
|
|
4669
|
-
|
|
4829
|
+
_context44.next = 13;
|
|
4670
4830
|
break;
|
|
4671
4831
|
}
|
|
4672
4832
|
retries += 1;
|
|
4673
|
-
return
|
|
4833
|
+
return _context44.abrupt("continue", 1);
|
|
4674
4834
|
case 13:
|
|
4675
4835
|
if (!(refreshedProjectionEntry.orderRevision !== this.getCurrentOrderRevision())) {
|
|
4676
|
-
|
|
4836
|
+
_context44.next = 16;
|
|
4677
4837
|
break;
|
|
4678
4838
|
}
|
|
4679
4839
|
retries += 1;
|
|
4680
|
-
return
|
|
4840
|
+
return _context44.abrupt("continue", 1);
|
|
4681
4841
|
case 16:
|
|
4682
|
-
return
|
|
4842
|
+
return _context44.abrupt("return", {
|
|
4683
4843
|
context: this.getAvailabilityContextEntry(contextId),
|
|
4684
4844
|
projectionEntry: refreshedProjectionEntry,
|
|
4685
4845
|
refreshed: true
|
|
@@ -4691,11 +4851,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4691
4851
|
});
|
|
4692
4852
|
case 20:
|
|
4693
4853
|
case "end":
|
|
4694
|
-
return
|
|
4854
|
+
return _context44.stop();
|
|
4695
4855
|
}
|
|
4696
|
-
},
|
|
4856
|
+
}, _callee44, this);
|
|
4697
4857
|
}));
|
|
4698
|
-
function ensureAvailabilityContextProjection(
|
|
4858
|
+
function ensureAvailabilityContextProjection(_x32, _x33) {
|
|
4699
4859
|
return _ensureAvailabilityContextProjection.apply(this, arguments);
|
|
4700
4860
|
}
|
|
4701
4861
|
return ensureAvailabilityContextProjection;
|
|
@@ -4703,18 +4863,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4703
4863
|
}, {
|
|
4704
4864
|
key: "tryAcquireAvailabilityCommitLock",
|
|
4705
4865
|
value: function () {
|
|
4706
|
-
var _tryAcquireAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4866
|
+
var _tryAcquireAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(contextId) {
|
|
4707
4867
|
var _currentContext$activ;
|
|
4708
4868
|
var _waitingContext$activ, waitingContext, currentContext;
|
|
4709
|
-
return _regeneratorRuntime().wrap(function
|
|
4710
|
-
while (1) switch (
|
|
4869
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context45) {
|
|
4870
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
4711
4871
|
case 0:
|
|
4712
4872
|
if (!this.availabilityCommitLocks.has(contextId)) {
|
|
4713
|
-
|
|
4873
|
+
_context45.next = 5;
|
|
4714
4874
|
break;
|
|
4715
4875
|
}
|
|
4716
4876
|
waitingContext = this.availabilityContextRegistry.get(contextId);
|
|
4717
|
-
|
|
4877
|
+
_context45.next = 4;
|
|
4718
4878
|
return this.emitAvailabilityDiagnostic({
|
|
4719
4879
|
action: 'commit_lock_wait',
|
|
4720
4880
|
contextId: contextId,
|
|
@@ -4731,7 +4891,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4731
4891
|
case 5:
|
|
4732
4892
|
this.availabilityCommitLocks.add(contextId);
|
|
4733
4893
|
currentContext = this.availabilityContextRegistry.get(contextId);
|
|
4734
|
-
|
|
4894
|
+
_context45.next = 9;
|
|
4735
4895
|
return this.emitAvailabilityDiagnostic({
|
|
4736
4896
|
action: 'commit_lock_acquired',
|
|
4737
4897
|
contextId: contextId,
|
|
@@ -4743,11 +4903,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4743
4903
|
});
|
|
4744
4904
|
case 9:
|
|
4745
4905
|
case "end":
|
|
4746
|
-
return
|
|
4906
|
+
return _context45.stop();
|
|
4747
4907
|
}
|
|
4748
|
-
},
|
|
4908
|
+
}, _callee45, this);
|
|
4749
4909
|
}));
|
|
4750
|
-
function tryAcquireAvailabilityCommitLock(
|
|
4910
|
+
function tryAcquireAvailabilityCommitLock(_x34) {
|
|
4751
4911
|
return _tryAcquireAvailabilityCommitLock.apply(this, arguments);
|
|
4752
4912
|
}
|
|
4753
4913
|
return tryAcquireAvailabilityCommitLock;
|
|
@@ -4755,15 +4915,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4755
4915
|
}, {
|
|
4756
4916
|
key: "releaseAvailabilityCommitLock",
|
|
4757
4917
|
value: function () {
|
|
4758
|
-
var _releaseAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4918
|
+
var _releaseAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(contextId) {
|
|
4759
4919
|
var _releasedContext$acti;
|
|
4760
4920
|
var releasedContext;
|
|
4761
|
-
return _regeneratorRuntime().wrap(function
|
|
4762
|
-
while (1) switch (
|
|
4921
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
4922
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
4763
4923
|
case 0:
|
|
4764
4924
|
this.availabilityCommitLocks.delete(contextId);
|
|
4765
4925
|
releasedContext = this.availabilityContextRegistry.get(contextId);
|
|
4766
|
-
|
|
4926
|
+
_context46.next = 4;
|
|
4767
4927
|
return this.emitAvailabilityDiagnostic({
|
|
4768
4928
|
action: 'commit_lock_released',
|
|
4769
4929
|
contextId: contextId,
|
|
@@ -4775,11 +4935,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4775
4935
|
});
|
|
4776
4936
|
case 4:
|
|
4777
4937
|
case "end":
|
|
4778
|
-
return
|
|
4938
|
+
return _context46.stop();
|
|
4779
4939
|
}
|
|
4780
|
-
},
|
|
4940
|
+
}, _callee46, this);
|
|
4781
4941
|
}));
|
|
4782
|
-
function releaseAvailabilityCommitLock(
|
|
4942
|
+
function releaseAvailabilityCommitLock(_x35) {
|
|
4783
4943
|
return _releaseAvailabilityCommitLock.apply(this, arguments);
|
|
4784
4944
|
}
|
|
4785
4945
|
return releaseAvailabilityCommitLock;
|
|
@@ -4787,20 +4947,20 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4787
4947
|
}, {
|
|
4788
4948
|
key: "prepareAvailabilityProjection",
|
|
4789
4949
|
value: (function () {
|
|
4790
|
-
var _prepareAvailabilityProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4950
|
+
var _prepareAvailabilityProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
|
|
4791
4951
|
var paramsWithDefaults, _yield$this$getShared, prepareKey, snapshot, contextId, projectionEntry, context, handle, payload;
|
|
4792
|
-
return _regeneratorRuntime().wrap(function
|
|
4793
|
-
while (1) switch (
|
|
4952
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context47) {
|
|
4953
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
4794
4954
|
case 0:
|
|
4795
4955
|
this.assertAvailabilityPrepareParams(params);
|
|
4796
|
-
|
|
4956
|
+
_context47.next = 3;
|
|
4797
4957
|
return this.resolveAvailabilityPrepareDefaults(params);
|
|
4798
4958
|
case 3:
|
|
4799
|
-
paramsWithDefaults =
|
|
4800
|
-
|
|
4959
|
+
paramsWithDefaults = _context47.sent;
|
|
4960
|
+
_context47.next = 6;
|
|
4801
4961
|
return this.getSharedPreparedAvailabilitySnapshot(paramsWithDefaults);
|
|
4802
4962
|
case 6:
|
|
4803
|
-
_yield$this$getShared =
|
|
4963
|
+
_yield$this$getShared = _context47.sent;
|
|
4804
4964
|
prepareKey = _yield$this$getShared.prepareKey;
|
|
4805
4965
|
snapshot = _yield$this$getShared.snapshot;
|
|
4806
4966
|
contextId = this.createAvailabilityContextId();
|
|
@@ -4821,7 +4981,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4821
4981
|
refreshed: false,
|
|
4822
4982
|
reason: 'prepare'
|
|
4823
4983
|
};
|
|
4824
|
-
|
|
4984
|
+
_context47.next = 16;
|
|
4825
4985
|
return this.emitAvailabilityDiagnostic({
|
|
4826
4986
|
action: 'prepare',
|
|
4827
4987
|
contextId: contextId,
|
|
@@ -4832,17 +4992,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4832
4992
|
reason: 'prepare'
|
|
4833
4993
|
});
|
|
4834
4994
|
case 16:
|
|
4835
|
-
|
|
4995
|
+
_context47.next = 18;
|
|
4836
4996
|
return this.core.effects.emit("".concat(this.name, ":").concat(UnifiedBookingSalesHooks.onAvailabilityProjectionPrepared), payload);
|
|
4837
4997
|
case 18:
|
|
4838
|
-
return
|
|
4998
|
+
return _context47.abrupt("return", handle);
|
|
4839
4999
|
case 19:
|
|
4840
5000
|
case "end":
|
|
4841
|
-
return
|
|
5001
|
+
return _context47.stop();
|
|
4842
5002
|
}
|
|
4843
|
-
},
|
|
5003
|
+
}, _callee47, this);
|
|
4844
5004
|
}));
|
|
4845
|
-
function prepareAvailabilityProjection(
|
|
5005
|
+
function prepareAvailabilityProjection(_x36) {
|
|
4846
5006
|
return _prepareAvailabilityProjection.apply(this, arguments);
|
|
4847
5007
|
}
|
|
4848
5008
|
return prepareAvailabilityProjection;
|
|
@@ -4850,10 +5010,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4850
5010
|
}, {
|
|
4851
5011
|
key: "getProductTimeRanges",
|
|
4852
5012
|
value: (function () {
|
|
4853
|
-
var _getProductTimeRanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5013
|
+
var _getProductTimeRanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(contextId) {
|
|
4854
5014
|
var _this$otherParams$pla,
|
|
4855
5015
|
_this$otherParams24,
|
|
4856
|
-
|
|
5016
|
+
_this14 = this;
|
|
4857
5017
|
var request,
|
|
4858
5018
|
_yield$this$ensureAva,
|
|
4859
5019
|
context,
|
|
@@ -4861,15 +5021,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4861
5021
|
contextVersion,
|
|
4862
5022
|
isPosAvailabilityRequest,
|
|
4863
5023
|
allowOutsideOperatingHoursForRequestedStartTimes,
|
|
4864
|
-
|
|
4865
|
-
return _regeneratorRuntime().wrap(function
|
|
4866
|
-
while (1) switch (
|
|
5024
|
+
_args48 = arguments;
|
|
5025
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context48) {
|
|
5026
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
4867
5027
|
case 0:
|
|
4868
|
-
request =
|
|
4869
|
-
|
|
5028
|
+
request = _args48.length > 1 && _args48[1] !== undefined ? _args48[1] : {};
|
|
5029
|
+
_context48.next = 3;
|
|
4870
5030
|
return this.ensureAvailabilityContextProjection(contextId, 'get_product_time_ranges');
|
|
4871
5031
|
case 3:
|
|
4872
|
-
_yield$this$ensureAva =
|
|
5032
|
+
_yield$this$ensureAva = _context48.sent;
|
|
4873
5033
|
context = _yield$this$ensureAva.context;
|
|
4874
5034
|
projectionEntry = _yield$this$ensureAva.projectionEntry;
|
|
4875
5035
|
contextVersion = context.activeVersion;
|
|
@@ -4877,7 +5037,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4877
5037
|
allowOutsideOperatingHoursForRequestedStartTimes = isPosAvailabilityRequest && Object.values(request.durationStartTimesByProductId || {}).some(function (startTimes) {
|
|
4878
5038
|
return Array.isArray(startTimes) && startTimes.length > 0;
|
|
4879
5039
|
});
|
|
4880
|
-
return
|
|
5040
|
+
return _context48.abrupt("return", getProjectionProductTimeRanges(projectionEntry.projection, _objectSpread(_objectSpread({}, request), allowOutsideOperatingHoursForRequestedStartTimes ? {
|
|
4881
5041
|
allowOutsideOperatingHoursForRequestedStartTimes: true
|
|
4882
5042
|
} : {}), {
|
|
4883
5043
|
evaluatedAt: this.getAvailabilityRuntimeDateTime(),
|
|
@@ -4887,17 +5047,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4887
5047
|
}).map(function (group) {
|
|
4888
5048
|
return _objectSpread(_objectSpread({}, group), {}, {
|
|
4889
5049
|
ranges: group.ranges.map(function (candidate) {
|
|
4890
|
-
return
|
|
5050
|
+
return _this14.decorateAvailabilityCandidate(context.contextId, contextVersion, candidate);
|
|
4891
5051
|
})
|
|
4892
5052
|
});
|
|
4893
5053
|
}));
|
|
4894
5054
|
case 10:
|
|
4895
5055
|
case "end":
|
|
4896
|
-
return
|
|
5056
|
+
return _context48.stop();
|
|
4897
5057
|
}
|
|
4898
|
-
},
|
|
5058
|
+
}, _callee48, this);
|
|
4899
5059
|
}));
|
|
4900
|
-
function getProductTimeRanges(
|
|
5060
|
+
function getProductTimeRanges(_x37) {
|
|
4901
5061
|
return _getProductTimeRanges.apply(this, arguments);
|
|
4902
5062
|
}
|
|
4903
5063
|
return getProductTimeRanges;
|
|
@@ -4905,16 +5065,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4905
5065
|
}, {
|
|
4906
5066
|
key: "queryBookingAvailability",
|
|
4907
5067
|
value: (function () {
|
|
4908
|
-
var _queryBookingAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5068
|
+
var _queryBookingAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(contextId, request) {
|
|
4909
5069
|
var _this$otherParams$pla2, _this$otherParams25;
|
|
4910
5070
|
var _yield$this$ensureAva2, context, projectionEntry, refreshed, isPosAvailabilityRequest, result, contextVersion, contextualResult;
|
|
4911
|
-
return _regeneratorRuntime().wrap(function
|
|
4912
|
-
while (1) switch (
|
|
5071
|
+
return _regeneratorRuntime().wrap(function _callee49$(_context49) {
|
|
5072
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
4913
5073
|
case 0:
|
|
4914
|
-
|
|
5074
|
+
_context49.next = 2;
|
|
4915
5075
|
return this.ensureAvailabilityContextProjection(contextId, 'query_booking_availability');
|
|
4916
5076
|
case 2:
|
|
4917
|
-
_yield$this$ensureAva2 =
|
|
5077
|
+
_yield$this$ensureAva2 = _context49.sent;
|
|
4918
5078
|
context = _yield$this$ensureAva2.context;
|
|
4919
5079
|
projectionEntry = _yield$this$ensureAva2.projectionEntry;
|
|
4920
5080
|
refreshed = _yield$this$ensureAva2.refreshed;
|
|
@@ -4950,18 +5110,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
4950
5110
|
});
|
|
4951
5111
|
})
|
|
4952
5112
|
}) : result;
|
|
4953
|
-
return
|
|
5113
|
+
return _context49.abrupt("return", _objectSpread(_objectSpread({}, contextualResult), {}, {
|
|
4954
5114
|
contextId: context.contextId,
|
|
4955
5115
|
contextVersion: contextVersion,
|
|
4956
5116
|
refreshed: refreshed
|
|
4957
5117
|
}));
|
|
4958
5118
|
case 12:
|
|
4959
5119
|
case "end":
|
|
4960
|
-
return
|
|
5120
|
+
return _context49.stop();
|
|
4961
5121
|
}
|
|
4962
|
-
},
|
|
5122
|
+
}, _callee49, this);
|
|
4963
5123
|
}));
|
|
4964
|
-
function queryBookingAvailability(
|
|
5124
|
+
function queryBookingAvailability(_x38, _x39) {
|
|
4965
5125
|
return _queryBookingAvailability.apply(this, arguments);
|
|
4966
5126
|
}
|
|
4967
5127
|
return queryBookingAvailability;
|
|
@@ -5031,27 +5191,27 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5031
5191
|
}, {
|
|
5032
5192
|
key: "commitAvailabilitySelection",
|
|
5033
5193
|
value: (function () {
|
|
5034
|
-
var _commitAvailabilitySelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5194
|
+
var _commitAvailabilitySelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(contextId, params) {
|
|
5035
5195
|
var normalizedContextId, _params$bookingCount, _ref53, _params$orderProduct$, _params$orderProduct, _params$orderProduct2, _params$orderProduct3, _params$orderProduct$2, _params$orderProduct4, _params$orderProduct5, _editingLine$product_, _baseProjection$meta$, _refreshedProjection$, _baseProjection$meta$2, _this$otherParams$pla3, _this$otherParams26, _ref54, _params$orderProduct$3, _params$orderProduct6, _existingBooking$meta, _ref55, _ref56, _params$orderProduct$4, _params$orderProduct7, _params$orderProduct8, _existingBooking$meta2, _existingBooking$hold, bookingCount, orderProductQuantity, partySize, _yield$this$ensureAva3, context, projectionEntry, refreshed, boundEditingUids, orderProductId, editingLine, _editingLine$product_2, baseProjection, commitWriteGuard, prepareParams, fallbackResources, commitSnapshot, refreshedProjection, _baseProjection$meta$3, latestContext, candidateDurationMinutes, candidateStartTime, allowPosAvailabilityOverride, refreshedRanges, refreshedCandidateBase, product, validation, forced, capacityConflict, revalidationEntry, revalidatedContext, refreshedCandidate, existingBooking, existingBookingUid, booking, transformed, productLineUid, bookingUid, productLineUids, bookingUids, _transformed$product_, _transformed$product_2, _transformed$product_3, _ref57, _transformed$product_4, _this$getTempOrder4, _this$getTempOrder5, _params$salesNotes, _this$getTempOrder6, beforeProductLineUids, beforeBookingUids, products, addedLines, addedBookings, nextContext, result;
|
|
5036
|
-
return _regeneratorRuntime().wrap(function
|
|
5037
|
-
while (1) switch (
|
|
5196
|
+
return _regeneratorRuntime().wrap(function _callee50$(_context50) {
|
|
5197
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
5038
5198
|
case 0:
|
|
5039
5199
|
normalizedContextId = String(contextId || '').trim();
|
|
5040
5200
|
if (normalizedContextId) {
|
|
5041
|
-
|
|
5201
|
+
_context50.next = 3;
|
|
5042
5202
|
break;
|
|
5043
5203
|
}
|
|
5044
5204
|
throw new AvailabilityError('INVALID_TARGET_FILTER', 'commitAvailabilitySelection 缺少 contextId', {
|
|
5045
5205
|
candidate: params.candidate
|
|
5046
5206
|
});
|
|
5047
5207
|
case 3:
|
|
5048
|
-
|
|
5208
|
+
_context50.next = 5;
|
|
5049
5209
|
return this.tryAcquireAvailabilityCommitLock(normalizedContextId);
|
|
5050
5210
|
case 5:
|
|
5051
|
-
|
|
5211
|
+
_context50.prev = 5;
|
|
5052
5212
|
bookingCount = Number((_params$bookingCount = params.bookingCount) !== null && _params$bookingCount !== void 0 ? _params$bookingCount : 1);
|
|
5053
5213
|
if (!(!Number.isInteger(bookingCount) || bookingCount <= 0)) {
|
|
5054
|
-
|
|
5214
|
+
_context50.next = 9;
|
|
5055
5215
|
break;
|
|
5056
5216
|
}
|
|
5057
5217
|
throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', 'bookingCount 必须是正整数', {
|
|
@@ -5059,7 +5219,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5059
5219
|
});
|
|
5060
5220
|
case 9:
|
|
5061
5221
|
if (!(params.mode === 'edit' && bookingCount !== 1)) {
|
|
5062
|
-
|
|
5222
|
+
_context50.next = 11;
|
|
5063
5223
|
break;
|
|
5064
5224
|
}
|
|
5065
5225
|
throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', '编辑预约商品时 bookingCount 必须为 1', {
|
|
@@ -5068,7 +5228,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5068
5228
|
case 11:
|
|
5069
5229
|
orderProductQuantity = (_ref53 = (_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 && _ref53 !== void 0 ? _ref53 : (_params$orderProduct3 = params.orderProduct) === null || _params$orderProduct3 === void 0 || (_params$orderProduct3 = _params$orderProduct3._extend) === null || _params$orderProduct3 === void 0 ? void 0 : _params$orderProduct3.quantity;
|
|
5070
5230
|
if (!(orderProductQuantity !== undefined && orderProductQuantity !== null && Number(orderProductQuantity) !== bookingCount)) {
|
|
5071
|
-
|
|
5231
|
+
_context50.next = 14;
|
|
5072
5232
|
break;
|
|
5073
5233
|
}
|
|
5074
5234
|
throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', 'orderProduct 数量与 bookingCount 不一致', {
|
|
@@ -5078,22 +5238,22 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5078
5238
|
case 14:
|
|
5079
5239
|
partySize = Number(params.partySize);
|
|
5080
5240
|
if (!(!Number.isInteger(partySize) || partySize <= 0)) {
|
|
5081
|
-
|
|
5241
|
+
_context50.next = 17;
|
|
5082
5242
|
break;
|
|
5083
5243
|
}
|
|
5084
5244
|
throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', 'partySize 必须是正整数', {
|
|
5085
5245
|
partySize: params.partySize
|
|
5086
5246
|
});
|
|
5087
5247
|
case 17:
|
|
5088
|
-
|
|
5248
|
+
_context50.next = 19;
|
|
5089
5249
|
return this.ensureAvailabilityContextProjection(normalizedContextId, 'commit_precheck');
|
|
5090
5250
|
case 19:
|
|
5091
|
-
_yield$this$ensureAva3 =
|
|
5251
|
+
_yield$this$ensureAva3 = _context50.sent;
|
|
5092
5252
|
context = _yield$this$ensureAva3.context;
|
|
5093
5253
|
projectionEntry = _yield$this$ensureAva3.projectionEntry;
|
|
5094
5254
|
refreshed = _yield$this$ensureAva3.refreshed;
|
|
5095
5255
|
if (!refreshed) {
|
|
5096
|
-
|
|
5256
|
+
_context50.next = 25;
|
|
5097
5257
|
break;
|
|
5098
5258
|
}
|
|
5099
5259
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'availability context 已刷新,请重新获取候选', {
|
|
@@ -5104,11 +5264,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5104
5264
|
case 25:
|
|
5105
5265
|
boundEditingUids = context.prepareParams.editingProductLineUids || [];
|
|
5106
5266
|
if (!(params.mode === 'edit')) {
|
|
5107
|
-
|
|
5267
|
+
_context50.next = 31;
|
|
5108
5268
|
break;
|
|
5109
5269
|
}
|
|
5110
5270
|
if (!(!params.productLineUid || !boundEditingUids.includes(String(params.productLineUid)))) {
|
|
5111
|
-
|
|
5271
|
+
_context50.next = 29;
|
|
5112
5272
|
break;
|
|
5113
5273
|
}
|
|
5114
5274
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'edit context 与当前商品行不匹配,请重新 prepare 编辑上下文', {
|
|
@@ -5117,11 +5277,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5117
5277
|
editingProductLineUids: boundEditingUids
|
|
5118
5278
|
});
|
|
5119
5279
|
case 29:
|
|
5120
|
-
|
|
5280
|
+
_context50.next = 33;
|
|
5121
5281
|
break;
|
|
5122
5282
|
case 31:
|
|
5123
5283
|
if (!(boundEditingUids.length > 0)) {
|
|
5124
|
-
|
|
5284
|
+
_context50.next = 33;
|
|
5125
5285
|
break;
|
|
5126
5286
|
}
|
|
5127
5287
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'edit context 不能用于 add,请重新 prepare 新增上下文', {
|
|
@@ -5130,7 +5290,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5130
5290
|
});
|
|
5131
5291
|
case 33:
|
|
5132
5292
|
if (!(projectionEntry.contextVersion !== context.activeVersion)) {
|
|
5133
|
-
|
|
5293
|
+
_context50.next = 35;
|
|
5134
5294
|
break;
|
|
5135
5295
|
}
|
|
5136
5296
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'availability context 已刷新,请重新获取候选', {
|
|
@@ -5140,7 +5300,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5140
5300
|
});
|
|
5141
5301
|
case 35:
|
|
5142
5302
|
if (!(projectionEntry.orderRevision !== this.getCurrentOrderRevision())) {
|
|
5143
|
-
|
|
5303
|
+
_context50.next = 37;
|
|
5144
5304
|
break;
|
|
5145
5305
|
}
|
|
5146
5306
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '购物车已变化,请重新获取候选', {
|
|
@@ -5151,7 +5311,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5151
5311
|
});
|
|
5152
5312
|
case 37:
|
|
5153
5313
|
if (!(projectionEntry.contextVersion !== params.candidate.availabilityContextVersion)) {
|
|
5154
|
-
|
|
5314
|
+
_context50.next = 39;
|
|
5155
5315
|
break;
|
|
5156
5316
|
}
|
|
5157
5317
|
throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '候选已过期,请重新获取最新时间段', {
|
|
@@ -5163,7 +5323,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5163
5323
|
this.assertAvailabilityCandidateFreshness(context, params.candidate);
|
|
5164
5324
|
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;
|
|
5165
5325
|
if (sameAvailabilityId(orderProductId, params.candidate.productId)) {
|
|
5166
|
-
|
|
5326
|
+
_context50.next = 43;
|
|
5167
5327
|
break;
|
|
5168
5328
|
}
|
|
5169
5329
|
throw new AvailabilityError('INVALID_TARGET_FILTER', 'orderProduct 与 candidate 商品不一致', {
|
|
@@ -5172,14 +5332,14 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5172
5332
|
});
|
|
5173
5333
|
case 43:
|
|
5174
5334
|
if (!(params.mode === 'edit' && !params.productLineUid)) {
|
|
5175
|
-
|
|
5335
|
+
_context50.next = 45;
|
|
5176
5336
|
break;
|
|
5177
5337
|
}
|
|
5178
5338
|
throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', 'edit 模式必须提供 productLineUid');
|
|
5179
5339
|
case 45:
|
|
5180
5340
|
editingLine = params.mode === 'edit' ? this.findProductLineByUid(String(params.productLineUid)) : undefined;
|
|
5181
5341
|
if (!(params.mode === 'edit' && !editingLine)) {
|
|
5182
|
-
|
|
5342
|
+
_context50.next = 48;
|
|
5183
5343
|
break;
|
|
5184
5344
|
}
|
|
5185
5345
|
throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', '找不到要编辑的预约商品行', {
|
|
@@ -5187,7 +5347,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5187
5347
|
});
|
|
5188
5348
|
case 48:
|
|
5189
5349
|
if (!(editingLine && !sameAvailabilityId((_editingLine$product_ = editingLine.product_id) !== null && _editingLine$product_ !== void 0 ? _editingLine$product_ : editingLine.id, params.candidate.productId))) {
|
|
5190
|
-
|
|
5350
|
+
_context50.next = 50;
|
|
5191
5351
|
break;
|
|
5192
5352
|
}
|
|
5193
5353
|
throw new AvailabilityError('INVALID_TARGET_FILTER', '编辑商品行与 candidate 商品不一致', {
|
|
@@ -5197,7 +5357,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5197
5357
|
});
|
|
5198
5358
|
case 50:
|
|
5199
5359
|
if (Array.isArray(params.requirementSelections)) {
|
|
5200
|
-
|
|
5360
|
+
_context50.next = 52;
|
|
5201
5361
|
break;
|
|
5202
5362
|
}
|
|
5203
5363
|
throw new AvailabilityError('INVALID_TARGET_FILTER', 'requirementSelections 必须是数组', {
|
|
@@ -5214,7 +5374,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5214
5374
|
};
|
|
5215
5375
|
prepareParams = baseProjection.meta.prepareParams;
|
|
5216
5376
|
if (prepareParams) {
|
|
5217
|
-
|
|
5377
|
+
_context50.next = 57;
|
|
5218
5378
|
break;
|
|
5219
5379
|
}
|
|
5220
5380
|
throw new AvailabilityError('REVALIDATION_FAILED', 'projection 缺少 prepareParams,无法执行缓存重校验');
|
|
@@ -5226,7 +5386,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5226
5386
|
})),
|
|
5227
5387
|
includesInjectedRawOccupancies: true
|
|
5228
5388
|
};
|
|
5229
|
-
|
|
5389
|
+
_context50.next = 60;
|
|
5230
5390
|
return this.buildAvailabilityProjectionSnapshot(_objectSpread(_objectSpread({}, this.cloneAvailabilityPrepareParams(prepareParams)), {}, {
|
|
5231
5391
|
editingProductLineUids: params.mode === 'edit' && params.productLineUid ? [params.productLineUid] : []
|
|
5232
5392
|
}), {
|
|
@@ -5235,13 +5395,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5235
5395
|
durationCandidateAnchorAt: this.getAvailabilityDurationCandidateAnchorAt(baseProjection) || context.durationCandidateAnchorAt
|
|
5236
5396
|
});
|
|
5237
5397
|
case 60:
|
|
5238
|
-
commitSnapshot =
|
|
5398
|
+
commitSnapshot = _context50.sent;
|
|
5239
5399
|
refreshedProjection = commitSnapshot.projection;
|
|
5240
5400
|
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 : ''))) {
|
|
5241
|
-
|
|
5401
|
+
_context50.next = 67;
|
|
5242
5402
|
break;
|
|
5243
5403
|
}
|
|
5244
|
-
|
|
5404
|
+
_context50.next = 65;
|
|
5245
5405
|
return this.refreshAvailabilityContextProjection({
|
|
5246
5406
|
contextId: normalizedContextId,
|
|
5247
5407
|
reason: 'commit_order_revision_changed',
|
|
@@ -5286,7 +5446,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5286
5446
|
return candidate.startAt === params.candidate.startAt && candidate.endAt === params.candidate.endAt && candidate.bookingStartAt === params.candidate.bookingStartAt && candidate.bookingEndAt === params.candidate.bookingEndAt;
|
|
5287
5447
|
});
|
|
5288
5448
|
if (refreshedCandidateBase) {
|
|
5289
|
-
|
|
5449
|
+
_context50.next = 75;
|
|
5290
5450
|
break;
|
|
5291
5451
|
}
|
|
5292
5452
|
throw new AvailabilityError('REVALIDATION_FAILED', '缓存重校验后候选时间已不在商品配置中', {
|
|
@@ -5299,7 +5459,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5299
5459
|
return sameAvailabilityId(item.id, refreshedCandidateBase.productId);
|
|
5300
5460
|
});
|
|
5301
5461
|
if (product) {
|
|
5302
|
-
|
|
5462
|
+
_context50.next = 78;
|
|
5303
5463
|
break;
|
|
5304
5464
|
}
|
|
5305
5465
|
throw new AvailabilityError('REVALIDATION_FAILED', '缓存重校验后商品不在 projection 中', {
|
|
@@ -5336,7 +5496,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5336
5496
|
});
|
|
5337
5497
|
}
|
|
5338
5498
|
if (validation.ok) {
|
|
5339
|
-
|
|
5499
|
+
_context50.next = 83;
|
|
5340
5500
|
break;
|
|
5341
5501
|
}
|
|
5342
5502
|
capacityConflict = validation.conflicts.find(function (conflict) {
|
|
@@ -5359,7 +5519,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5359
5519
|
incrementVersion: true
|
|
5360
5520
|
});
|
|
5361
5521
|
revalidatedContext = this.getAvailabilityContextEntry(normalizedContextId);
|
|
5362
|
-
|
|
5522
|
+
_context50.next = 87;
|
|
5363
5523
|
return this.emitAvailabilityDiagnostic({
|
|
5364
5524
|
action: 'refresh',
|
|
5365
5525
|
contextId: normalizedContextId,
|
|
@@ -5382,7 +5542,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5382
5542
|
existingBooking = editingLine ? this.findLinkedBooking(editingLine) : undefined;
|
|
5383
5543
|
existingBookingUid = existingBooking ? getBookingUid(existingBooking) : '';
|
|
5384
5544
|
if (!(params.mode === 'edit' && !existingBookingUid)) {
|
|
5385
|
-
|
|
5545
|
+
_context50.next = 93;
|
|
5386
5546
|
break;
|
|
5387
5547
|
}
|
|
5388
5548
|
throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', '编辑商品行缺少关联 booking', {
|
|
@@ -5404,7 +5564,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5404
5564
|
quantity: bookingCount
|
|
5405
5565
|
}), 'unified_booking_sales', product);
|
|
5406
5566
|
if (transformed) {
|
|
5407
|
-
|
|
5567
|
+
_context50.next = 98;
|
|
5408
5568
|
break;
|
|
5409
5569
|
}
|
|
5410
5570
|
throw new AvailabilityError('INVALID_TARGET_FILTER', 'orderProduct 无法转换为订单行', {
|
|
@@ -5423,7 +5583,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5423
5583
|
productLineUids = [];
|
|
5424
5584
|
bookingUids = [];
|
|
5425
5585
|
if (!(params.mode === 'edit' && editingLine && params.productLineUid)) {
|
|
5426
|
-
|
|
5586
|
+
_context50.next = 117;
|
|
5427
5587
|
break;
|
|
5428
5588
|
}
|
|
5429
5589
|
transformed.product_sku = (_transformed$product_ = transformed.product_sku) !== null && _transformed$product_ !== void 0 ? _transformed$product_ : editingLine.product_sku;
|
|
@@ -5433,7 +5593,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5433
5593
|
unique_identification_number: params.productLineUid,
|
|
5434
5594
|
booking_uid: existingBookingUid
|
|
5435
5595
|
});
|
|
5436
|
-
|
|
5596
|
+
_context50.next = 111;
|
|
5437
5597
|
return this.updateOrderProduct(_objectSpread(_objectSpread({
|
|
5438
5598
|
product_id: (_transformed$product_3 = transformed.product_id) !== null && _transformed$product_3 !== void 0 ? _transformed$product_3 : editingLine.product_id,
|
|
5439
5599
|
product_variant_id: (_ref57 = (_transformed$product_4 = transformed.product_variant_id) !== null && _transformed$product_4 !== void 0 ? _transformed$product_4 : editingLine.product_variant_id) !== null && _ref57 !== void 0 ? _ref57 : 0,
|
|
@@ -5450,7 +5610,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5450
5610
|
bookingUid = existingBookingUid;
|
|
5451
5611
|
productLineUids = [productLineUid];
|
|
5452
5612
|
bookingUids = [bookingUid];
|
|
5453
|
-
|
|
5613
|
+
_context50.next = 129;
|
|
5454
5614
|
break;
|
|
5455
5615
|
case 117:
|
|
5456
5616
|
beforeProductLineUids = new Set((((_this$getTempOrder4 = this.getTempOrder()) === null || _this$getTempOrder4 === void 0 ? void 0 : _this$getTempOrder4.products) || []).map(function (line) {
|
|
@@ -5459,12 +5619,12 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5459
5619
|
beforeBookingUids = new Set((((_this$getTempOrder5 = this.getTempOrder()) === null || _this$getTempOrder5 === void 0 ? void 0 : _this$getTempOrder5.bookings) || []).map(function (item) {
|
|
5460
5620
|
return getBookingUid(item);
|
|
5461
5621
|
}).filter(Boolean));
|
|
5462
|
-
|
|
5622
|
+
_context50.next = 121;
|
|
5463
5623
|
return this.addProductToOrder(transformed, booking, (_params$salesNotes = params.salesNotes) !== null && _params$salesNotes !== void 0 && _params$salesNotes.length ? {
|
|
5464
5624
|
salesNotes: params.salesNotes
|
|
5465
5625
|
} : undefined);
|
|
5466
5626
|
case 121:
|
|
5467
|
-
products =
|
|
5627
|
+
products = _context50.sent;
|
|
5468
5628
|
addedLines = products.filter(function (line) {
|
|
5469
5629
|
var _line$product_id, _line$metadata;
|
|
5470
5630
|
return sameAvailabilityId((_line$product_id = line.product_id) !== null && _line$product_id !== void 0 ? _line$product_id : line.id, refreshedCandidate.productId) && ((_line$metadata = line.metadata) === null || _line$metadata === void 0 ? void 0 : _line$metadata.availability_candidate_key) === refreshedCandidate.key && !beforeProductLineUids.has(getProductLineUid(line));
|
|
@@ -5501,23 +5661,23 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
5501
5661
|
productLineUids: productLineUids,
|
|
5502
5662
|
bookingUids: bookingUids
|
|
5503
5663
|
};
|
|
5504
|
-
|
|
5664
|
+
_context50.next = 134;
|
|
5505
5665
|
return this.core.effects.emit("".concat(this.name, ":").concat(UnifiedBookingSalesHooks.onAvailabilitySelectionCommitted), result);
|
|
5506
5666
|
case 134:
|
|
5507
|
-
return
|
|
5667
|
+
return _context50.abrupt("return", result);
|
|
5508
5668
|
case 135:
|
|
5509
|
-
|
|
5510
|
-
|
|
5669
|
+
_context50.prev = 135;
|
|
5670
|
+
_context50.next = 138;
|
|
5511
5671
|
return this.releaseAvailabilityCommitLock(normalizedContextId);
|
|
5512
5672
|
case 138:
|
|
5513
|
-
return
|
|
5673
|
+
return _context50.finish(135);
|
|
5514
5674
|
case 139:
|
|
5515
5675
|
case "end":
|
|
5516
|
-
return
|
|
5676
|
+
return _context50.stop();
|
|
5517
5677
|
}
|
|
5518
|
-
},
|
|
5678
|
+
}, _callee50, this, [[5,, 135, 139]]);
|
|
5519
5679
|
}));
|
|
5520
|
-
function commitAvailabilitySelection(
|
|
5680
|
+
function commitAvailabilitySelection(_x40, _x41) {
|
|
5521
5681
|
return _commitAvailabilitySelection.apply(this, arguments);
|
|
5522
5682
|
}
|
|
5523
5683
|
return commitAvailabilitySelection;
|