@pisell/pisellos 0.10.9 → 0.10.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/OpenData/types.d.ts +1 -0
- package/dist/modules/Order/index.d.ts +2 -0
- package/dist/modules/Order/index.js +60 -47
- package/dist/modules/Order/types.d.ts +5 -2
- package/dist/modules/Order/utils.d.ts +1 -0
- package/dist/modules/Order/utils.js +7 -4
- package/dist/modules/ResourcePlanner/index.d.ts +0 -22
- package/dist/modules/ResourcePlanner/index.js +1 -180
- package/dist/modules/ResourcePlanner/localClock.d.ts +33 -0
- package/dist/modules/ResourcePlanner/localClock.js +183 -0
- package/dist/modules/ResourcePlanner/planner.d.ts +5 -14
- package/dist/modules/ResourcePlanner/planner.js +2019 -936
- package/dist/modules/ResourcePlanner/types.d.ts +346 -187
- package/dist/modules/ResourcePlanner/types.js +33 -1
- package/dist/solution/BaseSales/index.js +32 -9
- package/dist/solution/BookingTicket/index.js +4 -2
- package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.js +3 -2
- package/dist/solution/UnifiedBookingSales/index.d.ts +110 -73
- package/dist/solution/UnifiedBookingSales/index.js +3349 -971
- package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +49 -0
- package/dist/solution/UnifiedBookingSales/remoteOccupancyCache.js +430 -0
- package/dist/solution/UnifiedBookingSales/types.d.ts +133 -76
- package/dist/solution/UnifiedBookingSales/types.js +4 -9
- package/lib/modules/OpenData/types.d.ts +1 -0
- package/lib/modules/Order/index.d.ts +2 -0
- package/lib/modules/Order/index.js +16 -5
- package/lib/modules/Order/types.d.ts +5 -2
- package/lib/modules/Order/utils.d.ts +1 -0
- package/lib/modules/Order/utils.js +2 -1
- package/lib/modules/ResourcePlanner/index.d.ts +0 -22
- package/lib/modules/ResourcePlanner/index.js +0 -123
- package/lib/modules/ResourcePlanner/localClock.d.ts +33 -0
- package/lib/modules/ResourcePlanner/localClock.js +270 -0
- package/lib/modules/ResourcePlanner/planner.d.ts +5 -14
- package/lib/modules/ResourcePlanner/planner.js +1903 -798
- package/lib/modules/ResourcePlanner/types.d.ts +346 -187
- package/lib/modules/ResourcePlanner/types.js +19 -0
- package/lib/solution/BaseSales/index.js +38 -22
- package/lib/solution/BookingTicket/index.js +2 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +2 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.js +2 -0
- package/lib/solution/UnifiedBookingSales/index.d.ts +110 -73
- package/lib/solution/UnifiedBookingSales/index.js +2289 -374
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.d.ts +49 -0
- package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +376 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +133 -76
- package/lib/solution/UnifiedBookingSales/types.js +3 -2
- package/package.json +1 -1
|
@@ -23,6 +23,7 @@ export interface OpenDataConfig {
|
|
|
23
23
|
'reservation.auto_confirm'?: boolean;
|
|
24
24
|
'reservation.auto_confirm_mode'?: string;
|
|
25
25
|
'reservation.auto_confirm_delay_seconds'?: number;
|
|
26
|
+
'reservation.time_slice'?: number | string;
|
|
26
27
|
'sale.allow_item_notes'?: boolean;
|
|
27
28
|
'sale.allow_order_notes'?: boolean;
|
|
28
29
|
'sale.enable_item_rules'?: boolean;
|
|
@@ -60,6 +60,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
60
60
|
* orderModule.updateOtherParams({ cacheId: 'cache-2', channel: 'pos' });
|
|
61
61
|
*/
|
|
62
62
|
updateOtherParams(params: Record<string, any>): void;
|
|
63
|
+
/** PC/H5 属于在线店铺;其它或缺失平台统一沿用 POS 行为。 */
|
|
64
|
+
isOnlineStorePlatform(): boolean;
|
|
63
65
|
/**
|
|
64
66
|
* 记录信息日志
|
|
65
67
|
*/
|
|
@@ -459,6 +459,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
459
459
|
this.otherParams = otherParams;
|
|
460
460
|
}
|
|
461
461
|
|
|
462
|
+
/** PC/H5 属于在线店铺;其它或缺失平台统一沿用 POS 行为。 */
|
|
463
|
+
}, {
|
|
464
|
+
key: "isOnlineStorePlatform",
|
|
465
|
+
value: function isOnlineStorePlatform() {
|
|
466
|
+
var _this$otherParams;
|
|
467
|
+
var platform = String(((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.platform) || '').trim().toLowerCase();
|
|
468
|
+
return platform === 'pc' || platform === 'h5';
|
|
469
|
+
}
|
|
470
|
+
|
|
462
471
|
/**
|
|
463
472
|
* 记录信息日志
|
|
464
473
|
*/
|
|
@@ -2892,7 +2901,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2892
2901
|
}, {
|
|
2893
2902
|
key: "buildTempOrderHolderFromBookings",
|
|
2894
2903
|
value: function buildTempOrderHolderFromBookings(tempOrder) {
|
|
2895
|
-
var _baseHolder$customer_, _baseHolder, _ref45, _baseHolder$form_id, _baseHolder2, _tempOrder$holder2, _baseHolder3, _this$
|
|
2904
|
+
var _baseHolder$customer_, _baseHolder, _ref45, _baseHolder$form_id, _baseHolder2, _tempOrder$holder2, _baseHolder3, _this$otherParams2;
|
|
2896
2905
|
var holderRecords = [];
|
|
2897
2906
|
var holderNames = [];
|
|
2898
2907
|
var baseHolder = null;
|
|
@@ -2945,7 +2954,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2945
2954
|
if (holderNames.length) {
|
|
2946
2955
|
nextHolder.name = holderNames.join(',');
|
|
2947
2956
|
}
|
|
2948
|
-
if ((_baseHolder3 = baseHolder) !== null && _baseHolder3 !== void 0 && _baseHolder3.is_source_shop || (_this$
|
|
2957
|
+
if ((_baseHolder3 = baseHolder) !== null && _baseHolder3 !== void 0 && _baseHolder3.is_source_shop || (_this$otherParams2 = this.otherParams) !== null && _this$otherParams2 !== void 0 && _this$otherParams2.isFranchisee) {
|
|
2949
2958
|
nextHolder.is_source_shop = 1;
|
|
2950
2959
|
}
|
|
2951
2960
|
return nextHolder;
|
|
@@ -3044,7 +3053,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3044
3053
|
key: "recalculateSummary",
|
|
3045
3054
|
value: function () {
|
|
3046
3055
|
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(options) {
|
|
3047
|
-
var _this$
|
|
3056
|
+
var _this$otherParams3, _ref46, _salesSummaryResult$e;
|
|
3048
3057
|
var tempOrder, originalSnapshot, hasShopDiscountChanged, shouldReuseOriginalSnapshot, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummaryBase, emptySummaryWithDeposit, emptySummary, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
|
|
3049
3058
|
return _regeneratorRuntime().wrap(function _callee12$(_context14) {
|
|
3050
3059
|
while (1) switch (_context14.prev = _context14.next) {
|
|
@@ -3111,7 +3120,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3111
3120
|
isPriceIncludeTax: tempOrder.is_price_include_tax,
|
|
3112
3121
|
shopDiscount: tempOrder.shop_discount,
|
|
3113
3122
|
virtualSettlementMode: this.shouldUseVirtualSettlementSummary(tempOrder)
|
|
3114
|
-
}, (_this$
|
|
3123
|
+
}, (_this$otherParams3 = this.otherParams) !== null && _this$otherParams3 !== void 0 && _this$otherParams3.channel ? {
|
|
3115
3124
|
channel: this.otherParams.channel
|
|
3116
3125
|
} : {}));
|
|
3117
3126
|
case 28:
|
|
@@ -3987,8 +3996,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3987
3996
|
}, {
|
|
3988
3997
|
key: "isMultiCurrencySettlementEnabled",
|
|
3989
3998
|
value: function isMultiCurrencySettlementEnabled() {
|
|
3990
|
-
var _this$
|
|
3991
|
-
return ((_this$
|
|
3999
|
+
var _this$otherParams4;
|
|
4000
|
+
return ((_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.enableMultiCurrencySettlement) === true;
|
|
3992
4001
|
}
|
|
3993
4002
|
}, {
|
|
3994
4003
|
key: "isActiveVirtualSettlementOrder",
|
|
@@ -5249,14 +5258,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5249
5258
|
}, {
|
|
5250
5259
|
key: "buildCurrentSubmitPayloadForLocalPrint",
|
|
5251
5260
|
value: function buildCurrentSubmitPayloadForLocalPrint(params) {
|
|
5252
|
-
var _params$cacheId, _this$
|
|
5261
|
+
var _params$cacheId, _this$otherParams5, _ref71, _params$businessCode, _this$otherParams6, _this$otherParams7;
|
|
5253
5262
|
var tempOrder = this.ensureTempOrder();
|
|
5254
5263
|
this.persistTempOrder();
|
|
5255
5264
|
var payload = buildSubmitPayload({
|
|
5256
5265
|
tempOrder: tempOrder,
|
|
5257
5266
|
cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
|
|
5258
|
-
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$
|
|
5259
|
-
businessCode: (_ref71 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$
|
|
5267
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform),
|
|
5268
|
+
businessCode: (_ref71 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode) !== null && _ref71 !== void 0 ? _ref71 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code,
|
|
5260
5269
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
5261
5270
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
5262
5271
|
summary: this.store.summary || createEmptySummary(),
|
|
@@ -5316,7 +5325,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5316
5325
|
key: "saveTempOrderAsDraft",
|
|
5317
5326
|
value: function () {
|
|
5318
5327
|
var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
|
|
5319
|
-
var _params$cacheId2, _this$
|
|
5328
|
+
var _params$cacheId2, _this$otherParams8, _this$otherParams9, _this$otherParams10, _params$type, _this$otherParams11, _payload$products;
|
|
5320
5329
|
var tempOrder, latestSummary, payload;
|
|
5321
5330
|
return _regeneratorRuntime().wrap(function _callee30$(_context33) {
|
|
5322
5331
|
while (1) switch (_context33.prev = _context33.next) {
|
|
@@ -5347,10 +5356,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5347
5356
|
payload = buildSubmitPayload({
|
|
5348
5357
|
tempOrder: tempOrder,
|
|
5349
5358
|
cacheId: (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId,
|
|
5350
|
-
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$
|
|
5351
|
-
businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$
|
|
5359
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.platform),
|
|
5360
|
+
businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.businessCode) || ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.business_code) || tempOrder.business_code,
|
|
5352
5361
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
5353
|
-
type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$
|
|
5362
|
+
type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.type,
|
|
5354
5363
|
summary: latestSummary,
|
|
5355
5364
|
enhance: params === null || params === void 0 ? void 0 : params.enhancePayload
|
|
5356
5365
|
});
|
|
@@ -5429,16 +5438,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5429
5438
|
key: "runSubmitTempOrder",
|
|
5430
5439
|
value: function () {
|
|
5431
5440
|
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
|
|
5432
|
-
var _params$cacheId3, _this$
|
|
5433
|
-
var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
|
|
5441
|
+
var _params$cacheId3, _this$otherParams12, _ref75, _ref76, _submitSnapshot$busin, _this$otherParams13, _this$otherParams14, _submitSnapshot$type;
|
|
5442
|
+
var tempOrder, isOnlineStorePlatform, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
|
|
5434
5443
|
return _regeneratorRuntime().wrap(function _callee33$(_context36) {
|
|
5435
5444
|
while (1) switch (_context36.prev = _context36.next) {
|
|
5436
5445
|
case 0:
|
|
5437
5446
|
tempOrder = this.ensureTempOrder();
|
|
5438
5447
|
this.prepareVirtualSettlementTempOrder(tempOrder);
|
|
5448
|
+
isOnlineStorePlatform = this.isOnlineStorePlatform();
|
|
5439
5449
|
shouldConfirmPendingVoucherPayments = (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== false;
|
|
5440
5450
|
hasPaymentOverride = (params === null || params === void 0 ? void 0 : params.payments) !== undefined;
|
|
5441
|
-
|
|
5451
|
+
if (hasPaymentOverride) {
|
|
5452
|
+
preparedPaymentOverride = isOnlineStorePlatform ? (params === null || params === void 0 ? void 0 : params.payments) || [] : this.prepareVoucherPaymentsForSubmit((params === null || params === void 0 ? void 0 : params.payments) || [], shouldConfirmPendingVoucherPayments);
|
|
5453
|
+
}
|
|
5442
5454
|
if (!hasPaymentOverride) {
|
|
5443
5455
|
if (shouldConfirmPendingVoucherPayments) {
|
|
5444
5456
|
this.confirmPendingVoucherPayments({
|
|
@@ -5453,25 +5465,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5453
5465
|
}
|
|
5454
5466
|
}
|
|
5455
5467
|
this.persistTempOrder();
|
|
5456
|
-
_context36.next =
|
|
5468
|
+
_context36.next = 10;
|
|
5457
5469
|
return this.recalculateSummary({
|
|
5458
5470
|
createIfMissing: true
|
|
5459
5471
|
});
|
|
5460
|
-
case
|
|
5472
|
+
case 10:
|
|
5461
5473
|
_context36.t1 = _context36.sent;
|
|
5462
5474
|
if (_context36.t1) {
|
|
5463
|
-
_context36.next =
|
|
5475
|
+
_context36.next = 13;
|
|
5464
5476
|
break;
|
|
5465
5477
|
}
|
|
5466
5478
|
_context36.t1 = this.store.summary;
|
|
5467
|
-
case
|
|
5479
|
+
case 13:
|
|
5468
5480
|
_context36.t0 = _context36.t1;
|
|
5469
5481
|
if (_context36.t0) {
|
|
5470
|
-
_context36.next =
|
|
5482
|
+
_context36.next = 16;
|
|
5471
5483
|
break;
|
|
5472
5484
|
}
|
|
5473
5485
|
_context36.t0 = createEmptySummary();
|
|
5474
|
-
case
|
|
5486
|
+
case 16:
|
|
5475
5487
|
latestSummary = _context36.t0;
|
|
5476
5488
|
effectiveCacheId = (_params$cacheId3 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId3 !== void 0 ? _params$cacheId3 : this.cacheId;
|
|
5477
5489
|
hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
|
|
@@ -5479,7 +5491,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5479
5491
|
enhancePayload = hasPaymentOverride || hasPaymentStatusOverride || hasSmallTicketDataFlagOverride || params !== null && params !== void 0 && params.enhancePayload ? function (payload, ctx) {
|
|
5480
5492
|
var nextPayload = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, payload), hasPaymentOverride ? {
|
|
5481
5493
|
payments: preparedPaymentOverride || []
|
|
5482
|
-
} : {}), hasPaymentStatusOverride && !shouldConfirmPendingVoucherPayments ? {
|
|
5494
|
+
} : {}), hasPaymentStatusOverride && !isOnlineStorePlatform && !shouldConfirmPendingVoucherPayments ? {
|
|
5483
5495
|
payment_status: params === null || params === void 0 ? void 0 : params.paymentStatus
|
|
5484
5496
|
} : {}), hasSmallTicketDataFlagOverride ? {
|
|
5485
5497
|
small_ticket_data_flag: params === null || params === void 0 ? void 0 : params.smallTicketDataFlag
|
|
@@ -5491,12 +5503,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5491
5503
|
payload = buildSubmitPayload({
|
|
5492
5504
|
tempOrder: tempOrder,
|
|
5493
5505
|
cacheId: effectiveCacheId,
|
|
5494
|
-
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$
|
|
5495
|
-
businessCode: (_ref75 = (_ref76 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref76 !== void 0 ? _ref76 : (_this$
|
|
5506
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.platform),
|
|
5507
|
+
businessCode: (_ref75 = (_ref76 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref76 !== void 0 ? _ref76 : (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.businessCode) !== null && _ref75 !== void 0 ? _ref75 : (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.business_code,
|
|
5496
5508
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
5497
5509
|
type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
|
|
5498
5510
|
summary: latestSummary,
|
|
5499
5511
|
request_unique_idempotency_token: params === null || params === void 0 ? void 0 : params.request_unique_idempotency_token,
|
|
5512
|
+
includePaymentStatus: !isOnlineStorePlatform,
|
|
5500
5513
|
enhance: enhancePayload
|
|
5501
5514
|
});
|
|
5502
5515
|
console.log('[Order.runSubmitTempOrder.payload]', payload);
|
|
@@ -5507,10 +5520,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5507
5520
|
if (!payload.created_at) {
|
|
5508
5521
|
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
5509
5522
|
}
|
|
5510
|
-
_context36.next =
|
|
5523
|
+
_context36.next = 28;
|
|
5511
5524
|
return this.saveDraft();
|
|
5512
|
-
case
|
|
5513
|
-
_context36.prev =
|
|
5525
|
+
case 28:
|
|
5526
|
+
_context36.prev = 28;
|
|
5514
5527
|
this.logInfo('submitTempOrder calling sales checkout', {
|
|
5515
5528
|
orderId: payload.order_id,
|
|
5516
5529
|
externalSaleNumber: payload.external_sale_number,
|
|
@@ -5520,26 +5533,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5520
5533
|
smallTicketDataFlag: payload.small_ticket_data_flag,
|
|
5521
5534
|
syncMode: payload.sync_mode
|
|
5522
5535
|
});
|
|
5523
|
-
_context36.next =
|
|
5536
|
+
_context36.next = 32;
|
|
5524
5537
|
return this.submitSalesOrder({
|
|
5525
5538
|
query: payload
|
|
5526
5539
|
});
|
|
5527
|
-
case
|
|
5540
|
+
case 32:
|
|
5528
5541
|
result = _context36.sent;
|
|
5529
|
-
_context36.next =
|
|
5542
|
+
_context36.next = 45;
|
|
5530
5543
|
break;
|
|
5531
|
-
case
|
|
5532
|
-
_context36.prev =
|
|
5533
|
-
_context36.t2 = _context36["catch"](
|
|
5544
|
+
case 35:
|
|
5545
|
+
_context36.prev = 35;
|
|
5546
|
+
_context36.t2 = _context36["catch"](28);
|
|
5534
5547
|
backendErrorResponse = this.extractSubmitErrorResponse(_context36.t2);
|
|
5535
5548
|
if (!backendErrorResponse) {
|
|
5536
|
-
_context36.next =
|
|
5549
|
+
_context36.next = 42;
|
|
5537
5550
|
break;
|
|
5538
5551
|
}
|
|
5539
5552
|
this.store.syncState = 'failed';
|
|
5540
5553
|
this.logSubmitBackendRejected(backendErrorResponse, payload);
|
|
5541
5554
|
return _context36.abrupt("return", backendErrorResponse);
|
|
5542
|
-
case
|
|
5555
|
+
case 42:
|
|
5543
5556
|
this.store.syncState = 'failed';
|
|
5544
5557
|
this.logError('submitTempOrder failed', {
|
|
5545
5558
|
error: _context36.t2 instanceof Error ? _context36.t2.message : String(_context36.t2),
|
|
@@ -5549,15 +5562,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5549
5562
|
paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
|
|
5550
5563
|
});
|
|
5551
5564
|
throw _context36.t2;
|
|
5552
|
-
case
|
|
5565
|
+
case 45:
|
|
5553
5566
|
if (!this.isSubmitResponseRejected(result)) {
|
|
5554
|
-
_context36.next =
|
|
5567
|
+
_context36.next = 49;
|
|
5555
5568
|
break;
|
|
5556
5569
|
}
|
|
5557
5570
|
this.store.syncState = 'failed';
|
|
5558
5571
|
this.logSubmitBackendRejected(result, payload);
|
|
5559
5572
|
return _context36.abrupt("return", result);
|
|
5560
|
-
case
|
|
5573
|
+
case 49:
|
|
5561
5574
|
submittedOrderId = this.extractOrderIdFromSubmitResult(result);
|
|
5562
5575
|
this.logInfo('runSubmitTempOrder: 提交成功', {
|
|
5563
5576
|
submittedOrderId: submittedOrderId,
|
|
@@ -5567,29 +5580,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5567
5580
|
})
|
|
5568
5581
|
});
|
|
5569
5582
|
if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
|
|
5570
|
-
_context36.next =
|
|
5583
|
+
_context36.next = 58;
|
|
5571
5584
|
break;
|
|
5572
5585
|
}
|
|
5573
5586
|
tempOrder.order_id = submittedOrderId;
|
|
5574
5587
|
resultRecord = result;
|
|
5575
|
-
_context36.next =
|
|
5588
|
+
_context36.next = 56;
|
|
5576
5589
|
return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
|
|
5577
|
-
case
|
|
5578
|
-
_context36.next =
|
|
5590
|
+
case 56:
|
|
5591
|
+
_context36.next = 59;
|
|
5579
5592
|
break;
|
|
5580
|
-
case
|
|
5593
|
+
case 58:
|
|
5581
5594
|
if (this.isLocalPendingSubmitResult(result)) {
|
|
5582
5595
|
this.store.syncState = 'local';
|
|
5583
5596
|
} else {
|
|
5584
5597
|
this.store.syncState = 'submitted';
|
|
5585
5598
|
}
|
|
5586
|
-
case 58:
|
|
5587
|
-
return _context36.abrupt("return", result);
|
|
5588
5599
|
case 59:
|
|
5600
|
+
return _context36.abrupt("return", result);
|
|
5601
|
+
case 60:
|
|
5589
5602
|
case "end":
|
|
5590
5603
|
return _context36.stop();
|
|
5591
5604
|
}
|
|
5592
|
-
}, _callee33, this, [[
|
|
5605
|
+
}, _callee33, this, [[28, 35]]);
|
|
5593
5606
|
}));
|
|
5594
5607
|
function runSubmitTempOrder(_x39) {
|
|
5595
5608
|
return _runSubmitTempOrder.apply(this, arguments);
|
|
@@ -295,8 +295,9 @@ export interface OrderSubmitProduct extends Omit<OrderProduct, 'unique_identific
|
|
|
295
295
|
payment_price: string;
|
|
296
296
|
product_sku: OrderProductSku;
|
|
297
297
|
}
|
|
298
|
-
export interface OrderSubmitPayload extends Omit<OrderTempOrder, 'platform' | 'products' | '_extend' | 'customer' | 'discount_list' | 'created_at'> {
|
|
298
|
+
export interface OrderSubmitPayload extends Omit<OrderTempOrder, 'platform' | 'products' | '_extend' | 'customer' | 'discount_list' | 'created_at' | 'payment_status'> {
|
|
299
299
|
platform: string;
|
|
300
|
+
payment_status?: string;
|
|
300
301
|
created_at?: string | undefined;
|
|
301
302
|
request_unique_idempotency_token?: string;
|
|
302
303
|
form_record_ids?: Array<{
|
|
@@ -449,7 +450,7 @@ export interface SubmitSalesOrderParams {
|
|
|
449
450
|
sales_channel: string;
|
|
450
451
|
order_sales_channel: string;
|
|
451
452
|
status: string;
|
|
452
|
-
payment_status
|
|
453
|
+
payment_status?: string;
|
|
453
454
|
shipping_status: string;
|
|
454
455
|
customer_id: number | null;
|
|
455
456
|
customer_name: string;
|
|
@@ -776,6 +777,8 @@ export interface OrderModuleAPI {
|
|
|
776
777
|
isTempOrderPersistEnabled: () => boolean;
|
|
777
778
|
/** 提交 tempOrder 变更并触发 `{moduleName}:changed` 事件 */
|
|
778
779
|
notifyTempOrderChanged: () => void;
|
|
780
|
+
/** PC/H5 为在线店铺;其它或缺失平台统一按 POS 处理。 */
|
|
781
|
+
isOnlineStorePlatform: () => boolean;
|
|
779
782
|
submitTempOrder: <T = any>(params?: {
|
|
780
783
|
cacheId?: string;
|
|
781
784
|
platform?: string;
|
|
@@ -220,6 +220,7 @@ export declare function buildSubmitPayload(params: {
|
|
|
220
220
|
type?: string;
|
|
221
221
|
summary?: OrderSummary | null;
|
|
222
222
|
request_unique_idempotency_token?: string;
|
|
223
|
+
includePaymentStatus?: boolean;
|
|
223
224
|
enhance?: SubmitPayloadEnhancer;
|
|
224
225
|
}): OrderSubmitPayload;
|
|
225
226
|
export declare function mapPaymentItemToOrderPayment(paymentItem: OrderPaymentSource): OrderPaymentData;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var _excluded = ["custom_product_bundle_map_id"],
|
|
2
2
|
_excluded2 = ["unique_identification_number"],
|
|
3
3
|
_excluded3 = ["num", "surcharge_fee", "discount_amount", "discount_type", "discountway", "product_discount_reason", "discount_per"],
|
|
4
|
-
_excluded4 = ["_extend", "relation_id", "table_form_id", "resource_id", "summary", "lastOrderInfo", "paid_amount", "shop_id", "shop_note", "shop_service_type", "start_time", "customer", "discount_list", "tax_fee", "total_amount", "total_refund_amount", "create_date", "holder_id"],
|
|
4
|
+
_excluded4 = ["_extend", "relation_id", "table_form_id", "resource_id", "summary", "lastOrderInfo", "paid_amount", "shop_id", "shop_note", "shop_service_type", "start_time", "customer", "discount_list", "tax_fee", "total_amount", "total_refund_amount", "create_date", "holder_id", "payment_status"],
|
|
5
5
|
_excluded5 = ["collect_pax", "table_occupancy_duration", "cart_settlement_key", "cart_settlement_snapshot", "legal_currency_snapshot"];
|
|
6
6
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
7
7
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
@@ -1148,6 +1148,7 @@ export function buildSubmitPayload(params) {
|
|
|
1148
1148
|
_totalRefundAmount = _ref30.total_refund_amount,
|
|
1149
1149
|
_createDate = _ref30.create_date,
|
|
1150
1150
|
_holderId = _ref30.holder_id,
|
|
1151
|
+
_paymentStatus = _ref30.payment_status,
|
|
1151
1152
|
tempOrderRest = _objectWithoutProperties(_ref30, _excluded4);
|
|
1152
1153
|
var submitType = type !== null && type !== void 0 ? type : tempOrder.type;
|
|
1153
1154
|
if (!submitType) {
|
|
@@ -1159,7 +1160,7 @@ export function buildSubmitPayload(params) {
|
|
|
1159
1160
|
submitType = 'virtual';
|
|
1160
1161
|
}
|
|
1161
1162
|
}
|
|
1162
|
-
var payload = _objectSpread(_objectSpread({}, tempOrderRest), {}, {
|
|
1163
|
+
var payload = _objectSpread(_objectSpread(_objectSpread({}, tempOrderRest), {}, {
|
|
1163
1164
|
customer_id: (_tempOrder$customer_i = tempOrder.customer_id) !== null && _tempOrder$customer_i !== void 0 ? _tempOrder$customer_i : 1,
|
|
1164
1165
|
customer_name: tempOrder.customer_name || 'Walk-In',
|
|
1165
1166
|
country_calling_code: String((_tempOrder$country_ca = tempOrder.country_calling_code) !== null && _tempOrder$country_ca !== void 0 ? _tempOrder$country_ca : ''),
|
|
@@ -1174,8 +1175,10 @@ export function buildSubmitPayload(params) {
|
|
|
1174
1175
|
business_code: businessCode !== null && businessCode !== void 0 ? businessCode : tempOrder.business_code,
|
|
1175
1176
|
sales_channel: tempOrder.sales_channel || 'my_pisel',
|
|
1176
1177
|
order_sales_channel: (_ref31 = channel !== null && channel !== void 0 ? channel : tempOrder.order_sales_channel) !== null && _ref31 !== void 0 ? _ref31 : 'online_store',
|
|
1177
|
-
status: tempOrder.status || 'normal'
|
|
1178
|
-
|
|
1178
|
+
status: tempOrder.status || 'normal'
|
|
1179
|
+
}, params.includePaymentStatus !== false ? {
|
|
1180
|
+
payment_status: tempOrder.payment_status || 'payment_processing'
|
|
1181
|
+
} : {}), {}, {
|
|
1179
1182
|
// shipping_status: tempOrder.shipping_status || 'unfulfilled',
|
|
1180
1183
|
is_price_include_tax: (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : 1,
|
|
1181
1184
|
currency_format: tempOrder.currency_format || 'symbol_first',
|
|
@@ -1,24 +1,2 @@
|
|
|
1
|
-
import { BaseModule } from '../BaseModule';
|
|
2
|
-
import type { Module, ModuleOptions, PisellCore } from '../../types';
|
|
3
|
-
import type { ResourcePlannerAssignmentResult, ResourcePlannerAssignableSlotResult, ResourcePlannerContextInput, ResourcePlannerProjection, ResourcePlannerQuery, ResourcePlannerSelectionPatch, ResourcePlannerSnapshot, ResourcePlannerValidationResult } from './types';
|
|
4
1
|
export * from './types';
|
|
5
2
|
export * from './planner';
|
|
6
|
-
export declare enum ResourcePlannerHooks {
|
|
7
|
-
onContextChanged = "resourcePlanner:onContextChanged",
|
|
8
|
-
onSelectionChanged = "resourcePlanner:onSelectionChanged",
|
|
9
|
-
onProjectionChanged = "resourcePlanner:onProjectionChanged"
|
|
10
|
-
}
|
|
11
|
-
export declare class ResourcePlannerModule extends BaseModule implements Module {
|
|
12
|
-
protected defaultName: string;
|
|
13
|
-
protected defaultVersion: string;
|
|
14
|
-
private store;
|
|
15
|
-
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
16
|
-
setContext(input: ResourcePlannerContextInput): ResourcePlannerSnapshot;
|
|
17
|
-
mergeContext(input: ResourcePlannerContextInput): ResourcePlannerSnapshot;
|
|
18
|
-
setSelectionPatch(patch: ResourcePlannerSelectionPatch): ResourcePlannerSnapshot;
|
|
19
|
-
queryAvailability(query?: ResourcePlannerQuery): ResourcePlannerProjection;
|
|
20
|
-
autoAssign(query?: ResourcePlannerQuery): ResourcePlannerAssignmentResult;
|
|
21
|
-
resolveAssignableSlots(query?: ResourcePlannerQuery): ResourcePlannerAssignableSlotResult;
|
|
22
|
-
validateSelection(): ResourcePlannerValidationResult;
|
|
23
|
-
getSnapshot(): ResourcePlannerSnapshot;
|
|
24
|
-
}
|
|
@@ -1,181 +1,2 @@
|
|
|
1
|
-
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); }
|
|
2
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
|
-
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; }
|
|
8
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
9
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
12
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
13
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
14
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
15
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
16
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
17
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
18
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
19
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
20
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
21
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
22
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
23
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
24
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
25
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
26
|
-
import { BaseModule } from "../BaseModule";
|
|
27
|
-
import { autoAssignResources, DEFAULT_RESOURCE_PLANNER_CONTEXT, DEFAULT_RESOURCE_PLANNER_SELECTION, normalizePlannerContext, queryPlannerAvailability, resolveAssignableSlots as _resolveAssignableSlots, validateAssignments } from "./planner";
|
|
28
1
|
export * from "./types";
|
|
29
|
-
export * from "./planner";
|
|
30
|
-
export var ResourcePlannerHooks = /*#__PURE__*/function (ResourcePlannerHooks) {
|
|
31
|
-
ResourcePlannerHooks["onContextChanged"] = "resourcePlanner:onContextChanged";
|
|
32
|
-
ResourcePlannerHooks["onSelectionChanged"] = "resourcePlanner:onSelectionChanged";
|
|
33
|
-
ResourcePlannerHooks["onProjectionChanged"] = "resourcePlanner:onProjectionChanged";
|
|
34
|
-
return ResourcePlannerHooks;
|
|
35
|
-
}({});
|
|
36
|
-
export var ResourcePlannerModule = /*#__PURE__*/function (_BaseModule) {
|
|
37
|
-
_inherits(ResourcePlannerModule, _BaseModule);
|
|
38
|
-
var _super = _createSuper(ResourcePlannerModule);
|
|
39
|
-
function ResourcePlannerModule() {
|
|
40
|
-
var _this;
|
|
41
|
-
_classCallCheck(this, ResourcePlannerModule);
|
|
42
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
43
|
-
args[_key] = arguments[_key];
|
|
44
|
-
}
|
|
45
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
46
|
-
_defineProperty(_assertThisInitialized(_this), "defaultName", 'resourcePlanner');
|
|
47
|
-
_defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
|
|
48
|
-
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
49
|
-
return _this;
|
|
50
|
-
}
|
|
51
|
-
_createClass(ResourcePlannerModule, [{
|
|
52
|
-
key: "initialize",
|
|
53
|
-
value: function () {
|
|
54
|
-
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
55
|
-
var initialState;
|
|
56
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
57
|
-
while (1) switch (_context.prev = _context.next) {
|
|
58
|
-
case 0:
|
|
59
|
-
this.core = core;
|
|
60
|
-
initialState = options.initialState;
|
|
61
|
-
this.store = {
|
|
62
|
-
context: normalizePlannerContext((initialState === null || initialState === void 0 ? void 0 : initialState.context) || DEFAULT_RESOURCE_PLANNER_CONTEXT),
|
|
63
|
-
selection: (initialState === null || initialState === void 0 ? void 0 : initialState.selection) || _objectSpread({}, DEFAULT_RESOURCE_PLANNER_SELECTION),
|
|
64
|
-
projection: (initialState === null || initialState === void 0 ? void 0 : initialState.projection) || null,
|
|
65
|
-
version: (initialState === null || initialState === void 0 ? void 0 : initialState.version) || 0
|
|
66
|
-
};
|
|
67
|
-
case 3:
|
|
68
|
-
case "end":
|
|
69
|
-
return _context.stop();
|
|
70
|
-
}
|
|
71
|
-
}, _callee, this);
|
|
72
|
-
}));
|
|
73
|
-
function initialize(_x, _x2) {
|
|
74
|
-
return _initialize.apply(this, arguments);
|
|
75
|
-
}
|
|
76
|
-
return initialize;
|
|
77
|
-
}()
|
|
78
|
-
}, {
|
|
79
|
-
key: "setContext",
|
|
80
|
-
value: function setContext(input) {
|
|
81
|
-
this.store.context = normalizePlannerContext(input);
|
|
82
|
-
this.store.version += 1;
|
|
83
|
-
this.store.projection = null;
|
|
84
|
-
var snapshot = this.getSnapshot();
|
|
85
|
-
void this.core.effects.emit("".concat(this.name, ":contextChanged"), snapshot);
|
|
86
|
-
return snapshot;
|
|
87
|
-
}
|
|
88
|
-
}, {
|
|
89
|
-
key: "mergeContext",
|
|
90
|
-
value: function mergeContext(input) {
|
|
91
|
-
return this.setContext(_objectSpread(_objectSpread(_objectSpread({}, this.store.context), input), {}, {
|
|
92
|
-
products: input.products || this.store.context.products,
|
|
93
|
-
resources: input.resources || this.store.context.resources,
|
|
94
|
-
externalEvents: input.externalEvents || this.store.context.externalEvents
|
|
95
|
-
}));
|
|
96
|
-
}
|
|
97
|
-
}, {
|
|
98
|
-
key: "setSelectionPatch",
|
|
99
|
-
value: function setSelectionPatch(patch) {
|
|
100
|
-
var assignments = patch.assignments ? patch.replaceAssignments === false ? [].concat(_toConsumableArray(this.store.selection.assignments), _toConsumableArray(patch.assignments)) : patch.assignments : this.store.selection.assignments;
|
|
101
|
-
this.store.selection = _objectSpread(_objectSpread(_objectSpread({}, this.store.selection), patch), {}, {
|
|
102
|
-
productIds: patch.productIds || this.store.selection.productIds,
|
|
103
|
-
resourceIds: patch.resourceIds || this.store.selection.resourceIds,
|
|
104
|
-
assignments: assignments
|
|
105
|
-
});
|
|
106
|
-
this.store.version += 1;
|
|
107
|
-
var snapshot = this.getSnapshot();
|
|
108
|
-
void this.core.effects.emit("".concat(this.name, ":selectionChanged"), snapshot);
|
|
109
|
-
return snapshot;
|
|
110
|
-
}
|
|
111
|
-
}, {
|
|
112
|
-
key: "queryAvailability",
|
|
113
|
-
value: function queryAvailability() {
|
|
114
|
-
var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
115
|
-
var mergedQuery = _objectSpread({
|
|
116
|
-
mode: this.store.selection.mode,
|
|
117
|
-
productIds: this.store.selection.productIds,
|
|
118
|
-
date: this.store.selection.date,
|
|
119
|
-
startTime: this.store.selection.startTime,
|
|
120
|
-
endTime: this.store.selection.endTime,
|
|
121
|
-
resourceIds: this.store.selection.resourceIds
|
|
122
|
-
}, query);
|
|
123
|
-
var projection = queryPlannerAvailability(this.store.context, mergedQuery);
|
|
124
|
-
this.store.projection = projection;
|
|
125
|
-
this.store.version += 1;
|
|
126
|
-
void this.core.effects.emit("".concat(this.name, ":projectionChanged"), this.getSnapshot());
|
|
127
|
-
return projection;
|
|
128
|
-
}
|
|
129
|
-
}, {
|
|
130
|
-
key: "autoAssign",
|
|
131
|
-
value: function autoAssign() {
|
|
132
|
-
var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
133
|
-
var result = autoAssignResources(this.store.context, _objectSpread({
|
|
134
|
-
mode: this.store.selection.mode,
|
|
135
|
-
productIds: this.store.selection.productIds,
|
|
136
|
-
date: this.store.selection.date,
|
|
137
|
-
startTime: this.store.selection.startTime,
|
|
138
|
-
endTime: this.store.selection.endTime,
|
|
139
|
-
resourceIds: this.store.selection.resourceIds
|
|
140
|
-
}, query));
|
|
141
|
-
var resourceIds = Array.from(new Map(result.assignments.map(function (assignment) {
|
|
142
|
-
return [String(assignment.resourceId), assignment.resourceId];
|
|
143
|
-
})).values());
|
|
144
|
-
this.setSelectionPatch(_objectSpread({
|
|
145
|
-
assignments: result.assignments
|
|
146
|
-
}, resourceIds.length ? {
|
|
147
|
-
resourceIds: resourceIds
|
|
148
|
-
} : {}));
|
|
149
|
-
return result;
|
|
150
|
-
}
|
|
151
|
-
}, {
|
|
152
|
-
key: "resolveAssignableSlots",
|
|
153
|
-
value: function resolveAssignableSlots() {
|
|
154
|
-
var query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
155
|
-
return _resolveAssignableSlots(this.store.context, _objectSpread({
|
|
156
|
-
mode: this.store.selection.mode,
|
|
157
|
-
productIds: this.store.selection.productIds,
|
|
158
|
-
date: this.store.selection.date,
|
|
159
|
-
startTime: this.store.selection.startTime,
|
|
160
|
-
endTime: this.store.selection.endTime,
|
|
161
|
-
resourceIds: this.store.selection.resourceIds
|
|
162
|
-
}, query));
|
|
163
|
-
}
|
|
164
|
-
}, {
|
|
165
|
-
key: "validateSelection",
|
|
166
|
-
value: function validateSelection() {
|
|
167
|
-
return validateAssignments(this.store.context, this.store.selection);
|
|
168
|
-
}
|
|
169
|
-
}, {
|
|
170
|
-
key: "getSnapshot",
|
|
171
|
-
value: function getSnapshot() {
|
|
172
|
-
return {
|
|
173
|
-
context: this.store.context,
|
|
174
|
-
selection: this.store.selection,
|
|
175
|
-
projection: this.store.projection,
|
|
176
|
-
version: this.store.version
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
}]);
|
|
180
|
-
return ResourcePlannerModule;
|
|
181
|
-
}(BaseModule);
|
|
2
|
+
export * from "./planner";
|