@pisell/pisellos 2.3.67 → 2.3.69
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/walletPass/evaluator.js +0 -1
- package/dist/model/strategy/adapter/walletPass/utils.js +0 -2
- package/dist/modules/BaseModule.d.ts +1 -0
- package/dist/modules/BaseModule.js +24 -28
- package/dist/modules/Customer/index.d.ts +4 -0
- package/dist/modules/Customer/index.js +91 -59
- package/dist/modules/Customer/types.d.ts +2 -0
- package/dist/modules/Order/index.d.ts +22 -2
- package/dist/modules/Order/index.js +313 -142
- package/dist/modules/Order/types.d.ts +13 -1
- package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +15 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +75 -0
- package/dist/modules/Order/utils.js +0 -1
- package/dist/modules/Payment/index.d.ts +4 -0
- package/dist/modules/Payment/index.js +14 -4
- package/dist/modules/Payment/walletpass.js +52 -18
- package/dist/modules/Rules/index.js +46 -31
- package/dist/server/index.js +3 -6
- package/dist/server/modules/order/index.d.ts +1 -0
- package/dist/server/modules/order/index.js +252 -93
- package/dist/server/utils/small-ticket.js +2 -1
- package/dist/solution/BaseSales/index.d.ts +13 -1
- package/dist/solution/BaseSales/index.js +903 -831
- package/dist/solution/BaseSales/utils.js +31 -20
- package/dist/solution/BookingTicket/index.d.ts +7 -1
- package/dist/solution/BookingTicket/index.js +310 -224
- package/dist/solution/ScanOrder/utils.js +31 -20
- package/dist/solution/UnifiedBookingSales/index.d.ts +25 -0
- package/dist/solution/UnifiedBookingSales/index.js +640 -321
- package/dist/solution/UnifiedBookingSales/types.d.ts +7 -0
- package/lib/model/strategy/adapter/walletPass/evaluator.js +0 -1
- package/lib/model/strategy/adapter/walletPass/utils.js +0 -1
- package/lib/modules/BaseModule.d.ts +1 -0
- package/lib/modules/BaseModule.js +24 -37
- package/lib/modules/Customer/index.d.ts +4 -0
- package/lib/modules/Customer/index.js +11 -0
- package/lib/modules/Customer/types.d.ts +2 -0
- package/lib/modules/Order/index.d.ts +22 -2
- package/lib/modules/Order/index.js +212 -54
- package/lib/modules/Order/types.d.ts +13 -1
- package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +15 -0
- package/lib/modules/Order/utils/orderCollectionIdentity.js +70 -0
- package/lib/modules/Order/utils.js +0 -1
- package/lib/modules/Payment/index.d.ts +4 -0
- package/lib/modules/Payment/index.js +7 -0
- package/lib/modules/Payment/walletpass.js +27 -2
- package/lib/modules/Rules/index.js +17 -1
- package/lib/server/index.js +3 -6
- package/lib/server/modules/order/index.d.ts +1 -0
- package/lib/server/modules/order/index.js +66 -2
- package/lib/server/utils/small-ticket.js +1 -1
- package/lib/solution/BaseSales/index.d.ts +13 -1
- package/lib/solution/BaseSales/index.js +61 -18
- package/lib/solution/BaseSales/utils.js +29 -18
- package/lib/solution/BookingTicket/index.d.ts +7 -1
- package/lib/solution/BookingTicket/index.js +65 -14
- package/lib/solution/ScanOrder/utils.js +29 -18
- package/lib/solution/UnifiedBookingSales/index.d.ts +25 -0
- package/lib/solution/UnifiedBookingSales/index.js +188 -0
- package/lib/solution/UnifiedBookingSales/types.d.ts +7 -0
- package/package.json +1 -1
|
@@ -40,6 +40,9 @@ import { BookingTicket } from "../BookingTicket";
|
|
|
40
40
|
export * from "./types";
|
|
41
41
|
var OPEN_DATA_SECTION_CODES = ['sale', 'reservation', 'fulfillment', 'menu', 'workflow'];
|
|
42
42
|
var OPEN_DATA_CACHE_TTL = 5 * 60 * 1000;
|
|
43
|
+
function isRecord(value) {
|
|
44
|
+
return !!value && _typeof(value) === 'object' && !Array.isArray(value);
|
|
45
|
+
}
|
|
43
46
|
function pickLocalizedText(value) {
|
|
44
47
|
if (!value) return undefined;
|
|
45
48
|
if (typeof value === 'string') return value;
|
|
@@ -139,6 +142,28 @@ function toNumberId(value) {
|
|
|
139
142
|
var parsed = Number(value);
|
|
140
143
|
return Number.isFinite(parsed) ? parsed : String(value);
|
|
141
144
|
}
|
|
145
|
+
function toCustomerId(value) {
|
|
146
|
+
var parsed = Number(value);
|
|
147
|
+
return Number.isFinite(parsed) && parsed > 1 ? parsed : null;
|
|
148
|
+
}
|
|
149
|
+
function resolveTempOrderCustomerId(tempOrder) {
|
|
150
|
+
var _tempOrder$customer, _tempOrder$_extend, _tempOrder$_extend2;
|
|
151
|
+
return toCustomerId((tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.customer_id) || (tempOrder === null || tempOrder === void 0 || (_tempOrder$customer = tempOrder.customer) === null || _tempOrder$customer === void 0 ? void 0 : _tempOrder$customer.id) || (tempOrder === null || tempOrder === void 0 || (_tempOrder$_extend = tempOrder._extend) === null || _tempOrder$_extend === void 0 || (_tempOrder$_extend = _tempOrder$_extend.customerSnapshot) === null || _tempOrder$_extend === void 0 ? void 0 : _tempOrder$_extend.id) || (tempOrder === null || tempOrder === void 0 || (_tempOrder$_extend2 = tempOrder._extend) === null || _tempOrder$_extend2 === void 0 || (_tempOrder$_extend2 = _tempOrder$_extend2.customerSnapshot) === null || _tempOrder$_extend2 === void 0 ? void 0 : _tempOrder$_extend2.customer_id));
|
|
152
|
+
}
|
|
153
|
+
function isLocalOrderId(orderId) {
|
|
154
|
+
return typeof orderId === 'string' && orderId.startsWith('local_order');
|
|
155
|
+
}
|
|
156
|
+
function isCustomerBoundDiscount(discount) {
|
|
157
|
+
var _discount$type;
|
|
158
|
+
var type = (_discount$type = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type !== void 0 ? _discount$type : discount === null || discount === void 0 ? void 0 : discount.tag;
|
|
159
|
+
return type === 'good_pass' || type === 'discount_card' || type === 'product_discount_card';
|
|
160
|
+
}
|
|
161
|
+
function filterCustomerBoundDiscounts(discountList) {
|
|
162
|
+
if (!Array.isArray(discountList)) return [];
|
|
163
|
+
return discountList.filter(function (discount) {
|
|
164
|
+
return !isCustomerBoundDiscount(discount);
|
|
165
|
+
});
|
|
166
|
+
}
|
|
142
167
|
|
|
143
168
|
/** Maps several legacy product shapes into the Planner's small, stable vocabulary. */
|
|
144
169
|
function resolveProductKind(product) {
|
|
@@ -498,15 +523,87 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
498
523
|
return _this;
|
|
499
524
|
}
|
|
500
525
|
_createClass(UnifiedBookingSalesImpl, [{
|
|
501
|
-
key: "
|
|
502
|
-
value:
|
|
526
|
+
key: "getSubmitOrderSalesChannel",
|
|
527
|
+
value: function getSubmitOrderSalesChannel() {
|
|
528
|
+
var _this$otherParams$cha, _this$otherParams;
|
|
529
|
+
var channel = String((_this$otherParams$cha = (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.channel) !== null && _this$otherParams$cha !== void 0 ? _this$otherParams$cha : '').trim();
|
|
530
|
+
return channel || _get(_getPrototypeOf(UnifiedBookingSalesImpl.prototype), "getSubmitOrderSalesChannel", this).call(this);
|
|
531
|
+
}
|
|
532
|
+
}, {
|
|
533
|
+
key: "isSessionStoragePersistEnabled",
|
|
534
|
+
value: function isSessionStoragePersistEnabled() {
|
|
535
|
+
var _this$otherParams2;
|
|
536
|
+
return Boolean(this.cacheId && ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.enableSessionStoragePersist) === true);
|
|
537
|
+
}
|
|
538
|
+
}, {
|
|
539
|
+
key: "shouldUseSessionStorageForSubModule",
|
|
540
|
+
value: function shouldUseSessionStorageForSubModule(moduleName) {
|
|
541
|
+
return this.isSessionStoragePersistEnabled() && moduleName === 'order';
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* 读取与当前 cacheId 同分桶的 Solution 会话状态。
|
|
546
|
+
* 该状态独立于 otherParams,适合页面皮肤保存短生命周期 UI 状态。
|
|
547
|
+
*/
|
|
548
|
+
}, {
|
|
549
|
+
key: "getSessionStateValue",
|
|
550
|
+
value: function getSessionStateValue(key) {
|
|
551
|
+
if (!key || !this.isSessionStoragePersistEnabled()) return undefined;
|
|
552
|
+
var cacheData = this.readSessionCacheData();
|
|
553
|
+
var solutionCache = cacheData === null || cacheData === void 0 ? void 0 : cacheData[this.name];
|
|
554
|
+
if (!isRecord(solutionCache) || !isRecord(solutionCache.sessionState)) {
|
|
555
|
+
return undefined;
|
|
556
|
+
}
|
|
557
|
+
return solutionCache.sessionState[key];
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* 写入与当前 cacheId 同分桶的 Solution 会话状态。
|
|
562
|
+
* value 为 undefined 时删除该 key;存储失败不阻断业务流程。
|
|
563
|
+
*/
|
|
564
|
+
}, {
|
|
565
|
+
key: "setSessionStateValue",
|
|
566
|
+
value: function setSessionStateValue(key, value) {
|
|
567
|
+
if (!key || !this.isSessionStoragePersistEnabled()) return;
|
|
568
|
+
var cacheData = this.readSessionCacheData();
|
|
569
|
+
var solutionCache = cacheData === null || cacheData === void 0 ? void 0 : cacheData[this.name];
|
|
570
|
+
var currentSessionState = isRecord(solutionCache) && isRecord(solutionCache.sessionState) ? solutionCache.sessionState : {};
|
|
571
|
+
var nextSessionState = _objectSpread({}, currentSessionState);
|
|
572
|
+
if (value === undefined) {
|
|
573
|
+
delete nextSessionState[key];
|
|
574
|
+
} else {
|
|
575
|
+
nextSessionState[key] = value;
|
|
576
|
+
}
|
|
577
|
+
this.checkSaveCache({
|
|
578
|
+
cacheId: this.cacheId,
|
|
579
|
+
fatherModule: this.name,
|
|
580
|
+
store: {
|
|
581
|
+
sessionState: nextSessionState
|
|
582
|
+
},
|
|
583
|
+
cacheKey: ['sessionState']
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* 清除当前 cacheId 的可恢复订单快照,同时保留 Solution UI sessionState。
|
|
589
|
+
* 用于支付跳转等终态场景,避免浏览器返回时恢复已提交订单。
|
|
590
|
+
*/
|
|
591
|
+
}, {
|
|
592
|
+
key: "clearSessionStorageOrderSnapshot",
|
|
593
|
+
value: function clearSessionStorageOrderSnapshot() {
|
|
594
|
+
var _this$store$order, _this$store$order$cle;
|
|
595
|
+
(_this$store$order = this.store.order) === null || _this$store$order === void 0 || (_this$store$order$cle = _this$store$order.clearSessionStoragePersistedTempOrder) === null || _this$store$order$cle === void 0 || _this$store$order$cle.call(_this$store$order);
|
|
596
|
+
}
|
|
597
|
+
|
|
503
598
|
/**
|
|
504
599
|
* Kiosk 不能把已收款订单留在本地等待重试:默认直接等待云端 checkout。
|
|
505
600
|
* 兼容仍需要 WebPOS 待同步模式的入口可显式传 checkoutSyncTaskEnabled: true。
|
|
506
601
|
*/
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
602
|
+
}, {
|
|
603
|
+
key: "shouldUseCheckoutSyncTask",
|
|
604
|
+
value: function shouldUseCheckoutSyncTask() {
|
|
605
|
+
var _this$otherParams3;
|
|
606
|
+
var configured = (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.checkoutSyncTaskEnabled;
|
|
510
607
|
return typeof configured === 'boolean' ? configured : false;
|
|
511
608
|
}
|
|
512
609
|
|
|
@@ -532,7 +629,229 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
532
629
|
}
|
|
533
630
|
return _get(_getPrototypeOf(UnifiedBookingSalesImpl.prototype), "createSubModule", this).call(this, moduleName);
|
|
534
631
|
}
|
|
535
|
-
|
|
632
|
+
}, {
|
|
633
|
+
key: "addNewOrder",
|
|
634
|
+
value: function () {
|
|
635
|
+
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
636
|
+
var _this$store$order2, _this$store$order2$co, _this$store$order4;
|
|
637
|
+
var sessionRecord, tempOrder, _this$store$order3, didSyncAuthenticatedCustomer;
|
|
638
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
639
|
+
while (1) switch (_context.prev = _context.next) {
|
|
640
|
+
case 0:
|
|
641
|
+
sessionRecord = this.isSessionStoragePersistEnabled() ? (_this$store$order2 = this.store.order) === null || _this$store$order2 === void 0 || (_this$store$order2$co = _this$store$order2.consumeSessionStorageRestore) === null || _this$store$order2$co === void 0 ? void 0 : _this$store$order2$co.call(_this$store$order2) : null;
|
|
642
|
+
if (!sessionRecord) {
|
|
643
|
+
_context.next = 4;
|
|
644
|
+
break;
|
|
645
|
+
}
|
|
646
|
+
_context.next = 4;
|
|
647
|
+
return this.loadSalesDetail({
|
|
648
|
+
preloadedSalesDetail: sessionRecord,
|
|
649
|
+
hydrateSource: 'sessionStorage'
|
|
650
|
+
});
|
|
651
|
+
case 4:
|
|
652
|
+
_context.next = 6;
|
|
653
|
+
return _get(_getPrototypeOf(UnifiedBookingSalesImpl.prototype), "addNewOrder", this).call(this);
|
|
654
|
+
case 6:
|
|
655
|
+
tempOrder = _context.sent;
|
|
656
|
+
if (sessionRecord) {
|
|
657
|
+
(_this$store$order3 = this.store.order) === null || _this$store$order3 === void 0 || _this$store$order3.persistTempOrder();
|
|
658
|
+
}
|
|
659
|
+
if (!this.isAuthenticatedCustomerUserPlatform()) {
|
|
660
|
+
_context.next = 23;
|
|
661
|
+
break;
|
|
662
|
+
}
|
|
663
|
+
_context.prev = 9;
|
|
664
|
+
_context.next = 12;
|
|
665
|
+
return this.syncAuthenticatedOrderCustomer();
|
|
666
|
+
case 12:
|
|
667
|
+
didSyncAuthenticatedCustomer = _context.sent;
|
|
668
|
+
if (!(!didSyncAuthenticatedCustomer && sessionRecord)) {
|
|
669
|
+
_context.next = 16;
|
|
670
|
+
break;
|
|
671
|
+
}
|
|
672
|
+
_context.next = 16;
|
|
673
|
+
return this.refreshLegacySessionCustomerDiscounts(tempOrder);
|
|
674
|
+
case 16:
|
|
675
|
+
_context.next = 21;
|
|
676
|
+
break;
|
|
677
|
+
case 18:
|
|
678
|
+
_context.prev = 18;
|
|
679
|
+
_context.t0 = _context["catch"](9);
|
|
680
|
+
console.warn('[UnifiedBookingSales] Failed to sync authenticated order customer after addNewOrder', _context.t0);
|
|
681
|
+
case 21:
|
|
682
|
+
_context.next = 32;
|
|
683
|
+
break;
|
|
684
|
+
case 23:
|
|
685
|
+
if (!sessionRecord) {
|
|
686
|
+
_context.next = 32;
|
|
687
|
+
break;
|
|
688
|
+
}
|
|
689
|
+
_context.prev = 24;
|
|
690
|
+
_context.next = 27;
|
|
691
|
+
return this.refreshLegacySessionCustomerDiscounts(tempOrder);
|
|
692
|
+
case 27:
|
|
693
|
+
_context.next = 32;
|
|
694
|
+
break;
|
|
695
|
+
case 29:
|
|
696
|
+
_context.prev = 29;
|
|
697
|
+
_context.t1 = _context["catch"](24);
|
|
698
|
+
console.warn('[UnifiedBookingSales] Failed to refresh cached customer discounts after addNewOrder', _context.t1);
|
|
699
|
+
case 32:
|
|
700
|
+
return _context.abrupt("return", ((_this$store$order4 = this.store.order) === null || _this$store$order4 === void 0 ? void 0 : _this$store$order4.getTempOrder()) || tempOrder);
|
|
701
|
+
case 33:
|
|
702
|
+
case "end":
|
|
703
|
+
return _context.stop();
|
|
704
|
+
}
|
|
705
|
+
}, _callee, this, [[9, 18], [24, 29]]);
|
|
706
|
+
}));
|
|
707
|
+
function addNewOrder() {
|
|
708
|
+
return _addNewOrder.apply(this, arguments);
|
|
709
|
+
}
|
|
710
|
+
return addNewOrder;
|
|
711
|
+
}()
|
|
712
|
+
}, {
|
|
713
|
+
key: "syncAuthenticatedOrderCustomer",
|
|
714
|
+
value: function () {
|
|
715
|
+
var _syncAuthenticatedOrderCustomer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
716
|
+
var _this$core, _this$core$getPlugin, _this$core$getPlugin$, _this$store$customer, _this$store$customer$;
|
|
717
|
+
var authenticatedCustomer, authenticatedCustomerId, tempOrder, cachedCustomerId;
|
|
718
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
719
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
720
|
+
case 0:
|
|
721
|
+
if (this.isAuthenticatedCustomerUserPlatform()) {
|
|
722
|
+
_context2.next = 2;
|
|
723
|
+
break;
|
|
724
|
+
}
|
|
725
|
+
return _context2.abrupt("return", false);
|
|
726
|
+
case 2:
|
|
727
|
+
authenticatedCustomer = (_this$core = this.core) === null || _this$core === void 0 || (_this$core$getPlugin = _this$core.getPlugin) === null || _this$core$getPlugin === void 0 || (_this$core$getPlugin = _this$core$getPlugin.call(_this$core, 'user')) === null || _this$core$getPlugin === void 0 || (_this$core$getPlugin$ = _this$core$getPlugin.get) === null || _this$core$getPlugin$ === void 0 ? void 0 : _this$core$getPlugin$.call(_this$core$getPlugin);
|
|
728
|
+
authenticatedCustomerId = toCustomerId(authenticatedCustomer === null || authenticatedCustomer === void 0 ? void 0 : authenticatedCustomer.id);
|
|
729
|
+
if (authenticatedCustomerId) {
|
|
730
|
+
_context2.next = 6;
|
|
731
|
+
break;
|
|
732
|
+
}
|
|
733
|
+
return _context2.abrupt("return", false);
|
|
734
|
+
case 6:
|
|
735
|
+
tempOrder = this.getTempOrder();
|
|
736
|
+
cachedCustomerId = resolveTempOrderCustomerId(tempOrder);
|
|
737
|
+
if (!(cachedCustomerId !== null && cachedCustomerId !== authenticatedCustomerId)) {
|
|
738
|
+
_context2.next = 11;
|
|
739
|
+
break;
|
|
740
|
+
}
|
|
741
|
+
_context2.next = 11;
|
|
742
|
+
return this.resetCachedCustomerDiscountState();
|
|
743
|
+
case 11:
|
|
744
|
+
(_this$store$customer = this.store.customer) === null || _this$store$customer === void 0 || (_this$store$customer$ = _this$store$customer.setSelectedCustomer) === null || _this$store$customer$ === void 0 || _this$store$customer$.call(_this$store$customer, authenticatedCustomer);
|
|
745
|
+
this.setOrderCustomer(authenticatedCustomer);
|
|
746
|
+
_context2.next = 15;
|
|
747
|
+
return Promise.all([this.refreshDiscountConfigAfterOrderCustomerChange(authenticatedCustomerId), this.waitForOrderCustomerPromotionRefresh()]);
|
|
748
|
+
case 15:
|
|
749
|
+
return _context2.abrupt("return", true);
|
|
750
|
+
case 16:
|
|
751
|
+
case "end":
|
|
752
|
+
return _context2.stop();
|
|
753
|
+
}
|
|
754
|
+
}, _callee2, this);
|
|
755
|
+
}));
|
|
756
|
+
function syncAuthenticatedOrderCustomer() {
|
|
757
|
+
return _syncAuthenticatedOrderCustomer.apply(this, arguments);
|
|
758
|
+
}
|
|
759
|
+
return syncAuthenticatedOrderCustomer;
|
|
760
|
+
}()
|
|
761
|
+
}, {
|
|
762
|
+
key: "isAuthenticatedCustomerUserPlatform",
|
|
763
|
+
value: function isAuthenticatedCustomerUserPlatform() {
|
|
764
|
+
var _this$otherParams4;
|
|
765
|
+
var platform = String(((_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.platform) || '').toLowerCase();
|
|
766
|
+
return platform === 'pc' || platform === 'h5';
|
|
767
|
+
}
|
|
768
|
+
}, {
|
|
769
|
+
key: "resolveDiscountOrderIdentity",
|
|
770
|
+
value: function resolveDiscountOrderIdentity(tempOrder) {
|
|
771
|
+
var _this$store$order5, _this$store$order5$ge;
|
|
772
|
+
return (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_id) || ((_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 || (_this$store$order5$ge = _this$store$order5.getOrderIdentity) === null || _this$store$order5$ge === void 0 || (_this$store$order5$ge = _this$store$order5$ge.call(_this$store$order5)) === null || _this$store$order5$ge === void 0 ? void 0 : _this$store$order5$ge.orderId) || null;
|
|
773
|
+
}
|
|
774
|
+
}, {
|
|
775
|
+
key: "resolveDiscountAction",
|
|
776
|
+
value: function resolveDiscountAction(orderId) {
|
|
777
|
+
if (!orderId || isLocalOrderId(orderId)) return 'create';
|
|
778
|
+
return 'edit';
|
|
779
|
+
}
|
|
780
|
+
}, {
|
|
781
|
+
key: "resetCachedCustomerDiscountState",
|
|
782
|
+
value: function () {
|
|
783
|
+
var _resetCachedCustomerDiscountState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
784
|
+
var _this$store$order6, _this$store$order6$cl, _this$store$customer2, _this$store$customer3, _this$store$order7, _discountModule$getOr, _discountModule$getDi, _discountModule$setOr, _discountModule$setDi, _this$store$order8, _this$store$order8$ap, _this$store$order9, _this$store$order9$re, _this$store$order10, _this$store$order10$p;
|
|
785
|
+
var orderStore, discountModule, filteredOriginalDiscounts, filteredCurrentDiscounts;
|
|
786
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
787
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
788
|
+
case 0:
|
|
789
|
+
(_this$store$order6 = this.store.order) === null || _this$store$order6 === void 0 || (_this$store$order6$cl = _this$store$order6.clearOrderCustomer) === null || _this$store$order6$cl === void 0 || _this$store$order6$cl.call(_this$store$order6);
|
|
790
|
+
(_this$store$customer2 = this.store.customer) === null || _this$store$customer2 === void 0 || (_this$store$customer3 = _this$store$customer2.setSelectedCustomer) === null || _this$store$customer3 === void 0 || _this$store$customer3.call(_this$store$customer2, null);
|
|
791
|
+
this.discountConfigCacheKey = null;
|
|
792
|
+
this.hasManualDiscountSelection = false;
|
|
793
|
+
orderStore = ((_this$store$order7 = this.store.order) === null || _this$store$order7 === void 0 ? void 0 : _this$store$order7.store) || {};
|
|
794
|
+
discountModule = orderStore.discount;
|
|
795
|
+
filteredOriginalDiscounts = filterCustomerBoundDiscounts((discountModule === null || discountModule === void 0 || (_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || []);
|
|
796
|
+
filteredCurrentDiscounts = filterCustomerBoundDiscounts((discountModule === null || discountModule === void 0 || (_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || []);
|
|
797
|
+
_context3.next = 10;
|
|
798
|
+
return discountModule === null || discountModule === void 0 || (_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, filteredOriginalDiscounts);
|
|
799
|
+
case 10:
|
|
800
|
+
_context3.next = 12;
|
|
801
|
+
return discountModule === null || discountModule === void 0 || (_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, filteredCurrentDiscounts);
|
|
802
|
+
case 12:
|
|
803
|
+
(_this$store$order8 = this.store.order) === null || _this$store$order8 === void 0 || (_this$store$order8$ap = _this$store$order8.applyDiscount) === null || _this$store$order8$ap === void 0 || _this$store$order8$ap.call(_this$store$order8);
|
|
804
|
+
_context3.next = 15;
|
|
805
|
+
return (_this$store$order9 = this.store.order) === null || _this$store$order9 === void 0 || (_this$store$order9$re = _this$store$order9.recalculateSummary) === null || _this$store$order9$re === void 0 ? void 0 : _this$store$order9$re.call(_this$store$order9, {
|
|
806
|
+
createIfMissing: true
|
|
807
|
+
});
|
|
808
|
+
case 15:
|
|
809
|
+
(_this$store$order10 = this.store.order) === null || _this$store$order10 === void 0 || (_this$store$order10$p = _this$store$order10.persistTempOrder) === null || _this$store$order10$p === void 0 || _this$store$order10$p.call(_this$store$order10);
|
|
810
|
+
case 16:
|
|
811
|
+
case "end":
|
|
812
|
+
return _context3.stop();
|
|
813
|
+
}
|
|
814
|
+
}, _callee3, this);
|
|
815
|
+
}));
|
|
816
|
+
function resetCachedCustomerDiscountState() {
|
|
817
|
+
return _resetCachedCustomerDiscountState.apply(this, arguments);
|
|
818
|
+
}
|
|
819
|
+
return resetCachedCustomerDiscountState;
|
|
820
|
+
}()
|
|
821
|
+
}, {
|
|
822
|
+
key: "refreshLegacySessionCustomerDiscounts",
|
|
823
|
+
value: function () {
|
|
824
|
+
var _refreshLegacySessionCustomerDiscounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(tempOrder) {
|
|
825
|
+
var customerId, loadDiscountConfig;
|
|
826
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
827
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
828
|
+
case 0:
|
|
829
|
+
customerId = resolveTempOrderCustomerId(tempOrder);
|
|
830
|
+
if (customerId) {
|
|
831
|
+
_context4.next = 3;
|
|
832
|
+
break;
|
|
833
|
+
}
|
|
834
|
+
return _context4.abrupt("return", undefined);
|
|
835
|
+
case 3:
|
|
836
|
+
loadDiscountConfig = _get(_getPrototypeOf(UnifiedBookingSalesImpl.prototype), "loadDiscountConfig", this).bind(this);
|
|
837
|
+
_context4.next = 6;
|
|
838
|
+
return loadDiscountConfig({
|
|
839
|
+
customerId: customerId,
|
|
840
|
+
action: this.resolveDiscountAction(this.resolveDiscountOrderIdentity(tempOrder))
|
|
841
|
+
});
|
|
842
|
+
case 6:
|
|
843
|
+
return _context4.abrupt("return", _context4.sent);
|
|
844
|
+
case 7:
|
|
845
|
+
case "end":
|
|
846
|
+
return _context4.stop();
|
|
847
|
+
}
|
|
848
|
+
}, _callee4, this);
|
|
849
|
+
}));
|
|
850
|
+
function refreshLegacySessionCustomerDiscounts(_x) {
|
|
851
|
+
return _refreshLegacySessionCustomerDiscounts.apply(this, arguments);
|
|
852
|
+
}
|
|
853
|
+
return refreshLegacySessionCustomerDiscounts;
|
|
854
|
+
}()
|
|
536
855
|
/**
|
|
537
856
|
* Loads OpenData without borrowing BookingTicket. Cache ownership is tied to the exact
|
|
538
857
|
* business/channel target so a reused solution instance cannot leak another entry's menus.
|
|
@@ -540,13 +859,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
540
859
|
}, {
|
|
541
860
|
key: "loadOpenData",
|
|
542
861
|
value: (function () {
|
|
543
|
-
var _loadOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
862
|
+
var _loadOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params) {
|
|
544
863
|
var businessCode, channel, target, cachedData, lastFetchedAt, openData;
|
|
545
|
-
return _regeneratorRuntime().wrap(function
|
|
546
|
-
while (1) switch (
|
|
864
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
865
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
547
866
|
case 0:
|
|
548
867
|
if (this.store.openData) {
|
|
549
|
-
|
|
868
|
+
_context5.next = 2;
|
|
550
869
|
break;
|
|
551
870
|
}
|
|
552
871
|
throw new Error('[UnifiedBookingSales] openData 模块未初始化');
|
|
@@ -554,7 +873,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
554
873
|
businessCode = String(params.businessCode || '').trim();
|
|
555
874
|
channel = String(params.channel || '').trim();
|
|
556
875
|
if (!(!businessCode || !channel)) {
|
|
557
|
-
|
|
876
|
+
_context5.next = 6;
|
|
558
877
|
break;
|
|
559
878
|
}
|
|
560
879
|
throw new Error('[UnifiedBookingSales] OpenData 需要 businessCode 与 channel');
|
|
@@ -563,28 +882,28 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
563
882
|
cachedData = this.store.openData.getOpenData();
|
|
564
883
|
lastFetchedAt = this.store.openData.getLastFetchedAt();
|
|
565
884
|
if (!(!params.force && this.openDataTarget === target && cachedData && lastFetchedAt && Date.now() - lastFetchedAt < OPEN_DATA_CACHE_TTL)) {
|
|
566
|
-
|
|
885
|
+
_context5.next = 11;
|
|
567
886
|
break;
|
|
568
887
|
}
|
|
569
|
-
return
|
|
888
|
+
return _context5.abrupt("return", cachedData);
|
|
570
889
|
case 11:
|
|
571
890
|
if (!this.loadOpenDataInFlight) {
|
|
572
|
-
|
|
891
|
+
_context5.next = 19;
|
|
573
892
|
break;
|
|
574
893
|
}
|
|
575
894
|
if (!(this.loadOpenDataInFlightTarget === target)) {
|
|
576
|
-
|
|
895
|
+
_context5.next = 16;
|
|
577
896
|
break;
|
|
578
897
|
}
|
|
579
|
-
|
|
898
|
+
_context5.next = 15;
|
|
580
899
|
return this.loadOpenDataInFlight;
|
|
581
900
|
case 15:
|
|
582
|
-
return
|
|
901
|
+
return _context5.abrupt("return", _context5.sent);
|
|
583
902
|
case 16:
|
|
584
|
-
|
|
903
|
+
_context5.next = 18;
|
|
585
904
|
return this.loadOpenDataInFlight;
|
|
586
905
|
case 18:
|
|
587
|
-
return
|
|
906
|
+
return _context5.abrupt("return", this.loadOpenData(params));
|
|
588
907
|
case 19:
|
|
589
908
|
this.loadOpenDataInFlightTarget = target;
|
|
590
909
|
this.loadOpenDataInFlight = this.store.openData.fetchOpenData({
|
|
@@ -592,28 +911,28 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
592
911
|
target: target,
|
|
593
912
|
section_code: [].concat(OPEN_DATA_SECTION_CODES)
|
|
594
913
|
});
|
|
595
|
-
|
|
596
|
-
|
|
914
|
+
_context5.prev = 21;
|
|
915
|
+
_context5.next = 24;
|
|
597
916
|
return this.loadOpenDataInFlight;
|
|
598
917
|
case 24:
|
|
599
|
-
openData =
|
|
918
|
+
openData = _context5.sent;
|
|
600
919
|
this.openDataTarget = target;
|
|
601
920
|
this.otherParams.openData = openData;
|
|
602
921
|
this.otherParams.businessCode = businessCode;
|
|
603
922
|
this.otherParams.channel = channel;
|
|
604
|
-
return
|
|
923
|
+
return _context5.abrupt("return", openData);
|
|
605
924
|
case 30:
|
|
606
|
-
|
|
925
|
+
_context5.prev = 30;
|
|
607
926
|
this.loadOpenDataInFlight = null;
|
|
608
927
|
this.loadOpenDataInFlightTarget = null;
|
|
609
|
-
return
|
|
928
|
+
return _context5.finish(30);
|
|
610
929
|
case 34:
|
|
611
930
|
case "end":
|
|
612
|
-
return
|
|
931
|
+
return _context5.stop();
|
|
613
932
|
}
|
|
614
|
-
},
|
|
933
|
+
}, _callee5, this, [[21,, 30, 34]]);
|
|
615
934
|
}));
|
|
616
|
-
function loadOpenData(
|
|
935
|
+
function loadOpenData(_x2) {
|
|
617
936
|
return _loadOpenData.apply(this, arguments);
|
|
618
937
|
}
|
|
619
938
|
return loadOpenData;
|
|
@@ -621,37 +940,37 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
621
940
|
}, {
|
|
622
941
|
key: "getOpenData",
|
|
623
942
|
value: function () {
|
|
624
|
-
var _getOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
625
|
-
var _this$
|
|
943
|
+
var _getOpenData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
944
|
+
var _this$otherParams5, _this$otherParams6, _this$store$openData;
|
|
626
945
|
var businessCode, channel, target, cachedData;
|
|
627
|
-
return _regeneratorRuntime().wrap(function
|
|
628
|
-
while (1) switch (
|
|
946
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
947
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
629
948
|
case 0:
|
|
630
|
-
businessCode = String(((_this$
|
|
631
|
-
channel = String(((_this$
|
|
949
|
+
businessCode = String(((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.businessCode) || '').trim();
|
|
950
|
+
channel = String(((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.channel) || '').trim();
|
|
632
951
|
if (!(!businessCode || !channel)) {
|
|
633
|
-
|
|
952
|
+
_context6.next = 4;
|
|
634
953
|
break;
|
|
635
954
|
}
|
|
636
|
-
return
|
|
955
|
+
return _context6.abrupt("return", null);
|
|
637
956
|
case 4:
|
|
638
957
|
target = "".concat(businessCode, "+").concat(channel);
|
|
639
958
|
cachedData = ((_this$store$openData = this.store.openData) === null || _this$store$openData === void 0 ? void 0 : _this$store$openData.getOpenData()) || null;
|
|
640
959
|
if (!(cachedData && this.openDataTarget === target)) {
|
|
641
|
-
|
|
960
|
+
_context6.next = 8;
|
|
642
961
|
break;
|
|
643
962
|
}
|
|
644
|
-
return
|
|
963
|
+
return _context6.abrupt("return", cachedData);
|
|
645
964
|
case 8:
|
|
646
|
-
return
|
|
965
|
+
return _context6.abrupt("return", this.loadOpenData({
|
|
647
966
|
businessCode: businessCode,
|
|
648
967
|
channel: channel
|
|
649
968
|
}));
|
|
650
969
|
case 9:
|
|
651
970
|
case "end":
|
|
652
|
-
return
|
|
971
|
+
return _context6.stop();
|
|
653
972
|
}
|
|
654
|
-
},
|
|
973
|
+
}, _callee6, this);
|
|
655
974
|
}));
|
|
656
975
|
function getOpenData() {
|
|
657
976
|
return _getOpenData.apply(this, arguments);
|
|
@@ -665,27 +984,27 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
665
984
|
}, {
|
|
666
985
|
key: "loadProducts",
|
|
667
986
|
value: (function () {
|
|
668
|
-
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
987
|
+
var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
669
988
|
var params,
|
|
670
989
|
options,
|
|
671
990
|
schedule_date,
|
|
672
991
|
schedule_datetime,
|
|
673
992
|
result,
|
|
674
|
-
|
|
675
|
-
return _regeneratorRuntime().wrap(function
|
|
676
|
-
while (1) switch (
|
|
993
|
+
_args7 = arguments;
|
|
994
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
995
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
677
996
|
case 0:
|
|
678
|
-
params =
|
|
679
|
-
options =
|
|
997
|
+
params = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {};
|
|
998
|
+
options = _args7.length > 1 ? _args7[1] : undefined;
|
|
680
999
|
if (this.store.products) {
|
|
681
|
-
|
|
1000
|
+
_context7.next = 4;
|
|
682
1001
|
break;
|
|
683
1002
|
}
|
|
684
1003
|
throw new Error('[UnifiedBookingSales] products 模块未初始化');
|
|
685
1004
|
case 4:
|
|
686
1005
|
schedule_date = params.schedule_date || dayjs().format('YYYY-MM-DD');
|
|
687
1006
|
schedule_datetime = params.schedule_datetime || "".concat(schedule_date, " ").concat(dayjs().format('HH:mm:ss'));
|
|
688
|
-
|
|
1007
|
+
_context7.next = 8;
|
|
689
1008
|
return this.store.products.loadProducts(_objectSpread(_objectSpread({
|
|
690
1009
|
with_count: ['bundleGroup', 'optionGroup'],
|
|
691
1010
|
with_schedule: 1
|
|
@@ -695,17 +1014,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
695
1014
|
cacheId: this.cacheId
|
|
696
1015
|
}), options);
|
|
697
1016
|
case 8:
|
|
698
|
-
result =
|
|
1017
|
+
result = _context7.sent;
|
|
699
1018
|
this.unifiedProductCatalog = Array.isArray(result) ? _toConsumableArray(result) : [];
|
|
700
|
-
|
|
1019
|
+
_context7.next = 12;
|
|
701
1020
|
return this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), result);
|
|
702
1021
|
case 12:
|
|
703
|
-
return
|
|
1022
|
+
return _context7.abrupt("return", result);
|
|
704
1023
|
case 13:
|
|
705
1024
|
case "end":
|
|
706
|
-
return
|
|
1025
|
+
return _context7.stop();
|
|
707
1026
|
}
|
|
708
|
-
},
|
|
1027
|
+
}, _callee7, this);
|
|
709
1028
|
}));
|
|
710
1029
|
function loadProducts() {
|
|
711
1030
|
return _loadProducts.apply(this, arguments);
|
|
@@ -715,24 +1034,24 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
715
1034
|
}, {
|
|
716
1035
|
key: "loadScheduleAvailableDate",
|
|
717
1036
|
value: (function () {
|
|
718
|
-
var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
719
|
-
return _regeneratorRuntime().wrap(function
|
|
720
|
-
while (1) switch (
|
|
1037
|
+
var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
|
|
1038
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
1039
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
721
1040
|
case 0:
|
|
722
1041
|
if (this.store.schedule) {
|
|
723
|
-
|
|
1042
|
+
_context8.next = 2;
|
|
724
1043
|
break;
|
|
725
1044
|
}
|
|
726
1045
|
throw new Error('[UnifiedBookingSales] schedule 模块未初始化');
|
|
727
1046
|
case 2:
|
|
728
|
-
return
|
|
1047
|
+
return _context8.abrupt("return", this.store.schedule.loadScheduleAvailableDate(params));
|
|
729
1048
|
case 3:
|
|
730
1049
|
case "end":
|
|
731
|
-
return
|
|
1050
|
+
return _context8.stop();
|
|
732
1051
|
}
|
|
733
|
-
},
|
|
1052
|
+
}, _callee8, this);
|
|
734
1053
|
}));
|
|
735
|
-
function loadScheduleAvailableDate(
|
|
1054
|
+
function loadScheduleAvailableDate(_x3) {
|
|
736
1055
|
return _loadScheduleAvailableDate.apply(this, arguments);
|
|
737
1056
|
}
|
|
738
1057
|
return loadScheduleAvailableDate;
|
|
@@ -746,15 +1065,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
746
1065
|
}, {
|
|
747
1066
|
key: "loadProductsByScheduleDate",
|
|
748
1067
|
value: (function () {
|
|
749
|
-
var _loadProductsByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1068
|
+
var _loadProductsByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
|
|
750
1069
|
var _this$store$schedule$, _this$store$schedule, _this$store$schedule$2, _this$store$schedule2, _this$store$schedule$3, _this$store$schedule3, _this$store$schedule$4, _this$store$schedule4;
|
|
751
1070
|
var date, custom_page_id, channel, product_ids, productLoadParams, cachedDates, hasCachedDate, hasOtherProducts, scheduleDate, productIdFilter, availableProductIds, products, fallbackProducts, _iterator, _step, productId, result;
|
|
752
|
-
return _regeneratorRuntime().wrap(function
|
|
753
|
-
while (1) switch (
|
|
1071
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
1072
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
754
1073
|
case 0:
|
|
755
1074
|
date = params.date, custom_page_id = params.custom_page_id, channel = params.channel, product_ids = params.product_ids, productLoadParams = _objectWithoutProperties(params, _excluded);
|
|
756
1075
|
if (this.store.schedule) {
|
|
757
|
-
|
|
1076
|
+
_context9.next = 3;
|
|
758
1077
|
break;
|
|
759
1078
|
}
|
|
760
1079
|
throw new Error('[UnifiedBookingSales] schedule 模块未初始化');
|
|
@@ -765,10 +1084,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
765
1084
|
});
|
|
766
1085
|
hasOtherProducts = (((_this$store$schedule$2 = (_this$store$schedule2 = this.store.schedule).getOtherProductsIds) === null || _this$store$schedule$2 === void 0 ? void 0 : _this$store$schedule$2.call(_this$store$schedule2)) || []).length > 0;
|
|
767
1086
|
if (!(!hasCachedDate && !hasOtherProducts)) {
|
|
768
|
-
|
|
1087
|
+
_context9.next = 9;
|
|
769
1088
|
break;
|
|
770
1089
|
}
|
|
771
|
-
|
|
1090
|
+
_context9.next = 9;
|
|
772
1091
|
return this.loadScheduleAvailableDate({
|
|
773
1092
|
startDate: date,
|
|
774
1093
|
endDate: date,
|
|
@@ -788,45 +1107,45 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
788
1107
|
return !productIdFilter || productIdFilter.has(String(id));
|
|
789
1108
|
});
|
|
790
1109
|
if (availableProductIds.length) {
|
|
791
|
-
|
|
1110
|
+
_context9.next = 17;
|
|
792
1111
|
break;
|
|
793
1112
|
}
|
|
794
1113
|
this.unifiedProductCatalog = [];
|
|
795
|
-
|
|
1114
|
+
_context9.next = 16;
|
|
796
1115
|
return this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), []);
|
|
797
1116
|
case 16:
|
|
798
|
-
return
|
|
1117
|
+
return _context9.abrupt("return", []);
|
|
799
1118
|
case 17:
|
|
800
|
-
|
|
1119
|
+
_context9.next = 19;
|
|
801
1120
|
return this.loadProducts(_objectSpread(_objectSpread({}, productLoadParams), {}, {
|
|
802
1121
|
product_ids: availableProductIds,
|
|
803
1122
|
schedule_date: date
|
|
804
1123
|
}));
|
|
805
1124
|
case 19:
|
|
806
|
-
products =
|
|
1125
|
+
products = _context9.sent;
|
|
807
1126
|
if (!(products.length || availableProductIds.length <= 1)) {
|
|
808
|
-
|
|
1127
|
+
_context9.next = 22;
|
|
809
1128
|
break;
|
|
810
1129
|
}
|
|
811
|
-
return
|
|
1130
|
+
return _context9.abrupt("return", products);
|
|
812
1131
|
case 22:
|
|
813
1132
|
fallbackProducts = [];
|
|
814
1133
|
_iterator = _createForOfIteratorHelper(availableProductIds);
|
|
815
|
-
|
|
1134
|
+
_context9.prev = 24;
|
|
816
1135
|
_iterator.s();
|
|
817
1136
|
case 26:
|
|
818
1137
|
if ((_step = _iterator.n()).done) {
|
|
819
|
-
|
|
1138
|
+
_context9.next = 34;
|
|
820
1139
|
break;
|
|
821
1140
|
}
|
|
822
1141
|
productId = _step.value;
|
|
823
|
-
|
|
1142
|
+
_context9.next = 30;
|
|
824
1143
|
return this.loadProducts(_objectSpread(_objectSpread({}, productLoadParams), {}, {
|
|
825
1144
|
product_ids: [productId],
|
|
826
1145
|
schedule_date: date
|
|
827
1146
|
}));
|
|
828
1147
|
case 30:
|
|
829
|
-
result =
|
|
1148
|
+
result = _context9.sent;
|
|
830
1149
|
result.forEach(function (product) {
|
|
831
1150
|
var _id;
|
|
832
1151
|
var id = (_id = product === null || product === void 0 ? void 0 : product.id) !== null && _id !== void 0 ? _id : product === null || product === void 0 ? void 0 : product.product_id;
|
|
@@ -838,32 +1157,32 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
838
1157
|
}
|
|
839
1158
|
});
|
|
840
1159
|
case 32:
|
|
841
|
-
|
|
1160
|
+
_context9.next = 26;
|
|
842
1161
|
break;
|
|
843
1162
|
case 34:
|
|
844
|
-
|
|
1163
|
+
_context9.next = 39;
|
|
845
1164
|
break;
|
|
846
1165
|
case 36:
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
_iterator.e(
|
|
1166
|
+
_context9.prev = 36;
|
|
1167
|
+
_context9.t0 = _context9["catch"](24);
|
|
1168
|
+
_iterator.e(_context9.t0);
|
|
850
1169
|
case 39:
|
|
851
|
-
|
|
1170
|
+
_context9.prev = 39;
|
|
852
1171
|
_iterator.f();
|
|
853
|
-
return
|
|
1172
|
+
return _context9.finish(39);
|
|
854
1173
|
case 42:
|
|
855
1174
|
this.unifiedProductCatalog = [].concat(fallbackProducts);
|
|
856
|
-
|
|
1175
|
+
_context9.next = 45;
|
|
857
1176
|
return this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), fallbackProducts);
|
|
858
1177
|
case 45:
|
|
859
|
-
return
|
|
1178
|
+
return _context9.abrupt("return", fallbackProducts);
|
|
860
1179
|
case 46:
|
|
861
1180
|
case "end":
|
|
862
|
-
return
|
|
1181
|
+
return _context9.stop();
|
|
863
1182
|
}
|
|
864
|
-
},
|
|
1183
|
+
}, _callee9, this, [[24, 36, 39, 42]]);
|
|
865
1184
|
}));
|
|
866
|
-
function loadProductsByScheduleDate(
|
|
1185
|
+
function loadProductsByScheduleDate(_x4) {
|
|
867
1186
|
return _loadProductsByScheduleDate.apply(this, arguments);
|
|
868
1187
|
}
|
|
869
1188
|
return loadProductsByScheduleDate;
|
|
@@ -916,7 +1235,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
916
1235
|
}, {
|
|
917
1236
|
key: "applyPlannerDiscounts",
|
|
918
1237
|
value: (function () {
|
|
919
|
-
var _applyPlannerDiscounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1238
|
+
var _applyPlannerDiscounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
920
1239
|
var _params$customerId;
|
|
921
1240
|
var params,
|
|
922
1241
|
tempOrder,
|
|
@@ -933,24 +1252,24 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
933
1252
|
discount,
|
|
934
1253
|
discountId,
|
|
935
1254
|
nextTempOrder,
|
|
936
|
-
|
|
937
|
-
return _regeneratorRuntime().wrap(function
|
|
938
|
-
while (1) switch (
|
|
1255
|
+
_args10 = arguments;
|
|
1256
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1257
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
939
1258
|
case 0:
|
|
940
|
-
params =
|
|
1259
|
+
params = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : {};
|
|
941
1260
|
tempOrder = this.getTempOrder();
|
|
942
1261
|
requestedCustomerId = (_params$customerId = params.customerId) !== null && _params$customerId !== void 0 ? _params$customerId : tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.customer_id;
|
|
943
1262
|
parsedCustomerId = Number(requestedCustomerId);
|
|
944
1263
|
customerId = Number.isFinite(parsedCustomerId) && parsedCustomerId > 1 ? parsedCustomerId : null;
|
|
945
|
-
|
|
1264
|
+
_context10.next = 7;
|
|
946
1265
|
return this.getSummary();
|
|
947
1266
|
case 7:
|
|
948
|
-
summaryBefore =
|
|
1267
|
+
summaryBefore = _context10.sent;
|
|
949
1268
|
if (customerId) {
|
|
950
|
-
|
|
1269
|
+
_context10.next = 10;
|
|
951
1270
|
break;
|
|
952
1271
|
}
|
|
953
|
-
return
|
|
1272
|
+
return _context10.abrupt("return", buildPlannerDiscountResult({
|
|
954
1273
|
customerId: null,
|
|
955
1274
|
discountList: this.getDiscountList(),
|
|
956
1275
|
products: (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || [],
|
|
@@ -959,7 +1278,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
959
1278
|
status: 'no_customer'
|
|
960
1279
|
}));
|
|
961
1280
|
case 10:
|
|
962
|
-
|
|
1281
|
+
_context10.next = 12;
|
|
963
1282
|
return this.loadDiscountConfig({
|
|
964
1283
|
customerId: customerId,
|
|
965
1284
|
action: 'create'
|
|
@@ -971,7 +1290,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
971
1290
|
return String((_resolvePlannerDiscou = resolvePlannerDiscountId(discount)) !== null && _resolvePlannerDiscou !== void 0 ? _resolvePlannerDiscou : '') === String(preferredDiscountId);
|
|
972
1291
|
});
|
|
973
1292
|
if (!preferredDiscount) {
|
|
974
|
-
|
|
1293
|
+
_context10.next = 40;
|
|
975
1294
|
break;
|
|
976
1295
|
}
|
|
977
1296
|
// A requested card is an explicit UI choice, not a best-effort preference. Clear prior
|
|
@@ -983,98 +1302,98 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
983
1302
|
return discount.isSelected === true && String((_resolvePlannerDiscou2 = resolvePlannerDiscountId(discount)) !== null && _resolvePlannerDiscou2 !== void 0 ? _resolvePlannerDiscou2 : '') !== String(preferredId);
|
|
984
1303
|
});
|
|
985
1304
|
_iterator2 = _createForOfIteratorHelper(selectedOtherDiscounts);
|
|
986
|
-
|
|
1305
|
+
_context10.prev = 18;
|
|
987
1306
|
_iterator2.s();
|
|
988
1307
|
case 20:
|
|
989
1308
|
if ((_step2 = _iterator2.n()).done) {
|
|
990
|
-
|
|
1309
|
+
_context10.next = 28;
|
|
991
1310
|
break;
|
|
992
1311
|
}
|
|
993
1312
|
discount = _step2.value;
|
|
994
1313
|
discountId = Number(resolvePlannerDiscountId(discount));
|
|
995
1314
|
if (!Number.isFinite(discountId)) {
|
|
996
|
-
|
|
1315
|
+
_context10.next = 26;
|
|
997
1316
|
break;
|
|
998
1317
|
}
|
|
999
|
-
|
|
1318
|
+
_context10.next = 26;
|
|
1000
1319
|
return this.setDiscountSelected({
|
|
1001
1320
|
discountId: discountId,
|
|
1002
1321
|
isSelected: false
|
|
1003
1322
|
});
|
|
1004
1323
|
case 26:
|
|
1005
|
-
|
|
1324
|
+
_context10.next = 20;
|
|
1006
1325
|
break;
|
|
1007
1326
|
case 28:
|
|
1008
|
-
|
|
1327
|
+
_context10.next = 33;
|
|
1009
1328
|
break;
|
|
1010
1329
|
case 30:
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
_iterator2.e(
|
|
1330
|
+
_context10.prev = 30;
|
|
1331
|
+
_context10.t0 = _context10["catch"](18);
|
|
1332
|
+
_iterator2.e(_context10.t0);
|
|
1014
1333
|
case 33:
|
|
1015
|
-
|
|
1334
|
+
_context10.prev = 33;
|
|
1016
1335
|
_iterator2.f();
|
|
1017
|
-
return
|
|
1336
|
+
return _context10.finish(33);
|
|
1018
1337
|
case 36:
|
|
1019
|
-
|
|
1338
|
+
_context10.next = 38;
|
|
1020
1339
|
return this.setDiscountSelected({
|
|
1021
1340
|
discountId: Number(preferredId),
|
|
1022
1341
|
isSelected: true
|
|
1023
1342
|
});
|
|
1024
1343
|
case 38:
|
|
1025
|
-
|
|
1344
|
+
_context10.next = 49;
|
|
1026
1345
|
break;
|
|
1027
1346
|
case 40:
|
|
1028
1347
|
if (!(preferredDiscountId === undefined || preferredDiscountId === null)) {
|
|
1029
|
-
|
|
1348
|
+
_context10.next = 46;
|
|
1030
1349
|
break;
|
|
1031
1350
|
}
|
|
1032
1351
|
if (!(params.applyBestDiscount !== false)) {
|
|
1033
|
-
|
|
1352
|
+
_context10.next = 44;
|
|
1034
1353
|
break;
|
|
1035
1354
|
}
|
|
1036
|
-
|
|
1355
|
+
_context10.next = 44;
|
|
1037
1356
|
return this.bestDiscount();
|
|
1038
1357
|
case 44:
|
|
1039
|
-
|
|
1358
|
+
_context10.next = 49;
|
|
1040
1359
|
break;
|
|
1041
1360
|
case 46:
|
|
1042
1361
|
if (!(params.applyBestDiscount !== false)) {
|
|
1043
|
-
|
|
1362
|
+
_context10.next = 49;
|
|
1044
1363
|
break;
|
|
1045
1364
|
}
|
|
1046
|
-
|
|
1365
|
+
_context10.next = 49;
|
|
1047
1366
|
return this.bestDiscount();
|
|
1048
1367
|
case 49:
|
|
1049
1368
|
nextTempOrder = this.getTempOrder();
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1369
|
+
_context10.t1 = buildPlannerDiscountResult;
|
|
1370
|
+
_context10.t2 = customerId;
|
|
1371
|
+
_context10.t3 = this.getDiscountList();
|
|
1372
|
+
_context10.t4 = (nextTempOrder === null || nextTempOrder === void 0 ? void 0 : nextTempOrder.products) || [];
|
|
1373
|
+
_context10.t5 = summaryBefore;
|
|
1374
|
+
_context10.next = 57;
|
|
1056
1375
|
return this.getSummary();
|
|
1057
1376
|
case 57:
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
customerId:
|
|
1064
|
-
discountList:
|
|
1065
|
-
products:
|
|
1066
|
-
summaryBefore:
|
|
1067
|
-
summaryAfter:
|
|
1068
|
-
status:
|
|
1069
|
-
preferredDiscountId:
|
|
1070
|
-
preferredDiscountFound:
|
|
1377
|
+
_context10.t6 = _context10.sent;
|
|
1378
|
+
_context10.t7 = params.applyBestDiscount === false && !preferredDiscount ? 'loaded' : 'applied';
|
|
1379
|
+
_context10.t8 = preferredDiscountId;
|
|
1380
|
+
_context10.t9 = preferredDiscountId === undefined || preferredDiscountId === null ? undefined : Boolean(preferredDiscount);
|
|
1381
|
+
_context10.t10 = {
|
|
1382
|
+
customerId: _context10.t2,
|
|
1383
|
+
discountList: _context10.t3,
|
|
1384
|
+
products: _context10.t4,
|
|
1385
|
+
summaryBefore: _context10.t5,
|
|
1386
|
+
summaryAfter: _context10.t6,
|
|
1387
|
+
status: _context10.t7,
|
|
1388
|
+
preferredDiscountId: _context10.t8,
|
|
1389
|
+
preferredDiscountFound: _context10.t9
|
|
1071
1390
|
};
|
|
1072
|
-
return
|
|
1391
|
+
return _context10.abrupt("return", (0, _context10.t1)(_context10.t10));
|
|
1073
1392
|
case 63:
|
|
1074
1393
|
case "end":
|
|
1075
|
-
return
|
|
1394
|
+
return _context10.stop();
|
|
1076
1395
|
}
|
|
1077
|
-
},
|
|
1396
|
+
}, _callee10, this, [[18, 30, 33, 36]]);
|
|
1078
1397
|
}));
|
|
1079
1398
|
function applyPlannerDiscounts() {
|
|
1080
1399
|
return _applyPlannerDiscounts.apply(this, arguments);
|
|
@@ -1116,29 +1435,29 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1116
1435
|
}, {
|
|
1117
1436
|
key: "removeExistingStagedLines",
|
|
1118
1437
|
value: (function () {
|
|
1119
|
-
var _removeExistingStagedLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1438
|
+
var _removeExistingStagedLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(ownershipKey) {
|
|
1120
1439
|
var _this$getTempOrder;
|
|
1121
1440
|
var existingLines;
|
|
1122
|
-
return _regeneratorRuntime().wrap(function
|
|
1123
|
-
while (1) switch (
|
|
1441
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
1442
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1124
1443
|
case 0:
|
|
1125
1444
|
existingLines = (((_this$getTempOrder = this.getTempOrder()) === null || _this$getTempOrder === void 0 ? void 0 : _this$getTempOrder.products) || []).filter(function (product) {
|
|
1126
1445
|
var _product$metadata3;
|
|
1127
1446
|
return (product === null || product === void 0 || (_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3[ownershipKey]) === true;
|
|
1128
1447
|
});
|
|
1129
1448
|
if (!(existingLines.length > 0)) {
|
|
1130
|
-
|
|
1449
|
+
_context11.next = 4;
|
|
1131
1450
|
break;
|
|
1132
1451
|
}
|
|
1133
|
-
|
|
1452
|
+
_context11.next = 4;
|
|
1134
1453
|
return this.removeProductsFromOrder(existingLines.map(buildPlannerLineIdentity));
|
|
1135
1454
|
case 4:
|
|
1136
1455
|
case "end":
|
|
1137
|
-
return
|
|
1456
|
+
return _context11.stop();
|
|
1138
1457
|
}
|
|
1139
|
-
},
|
|
1458
|
+
}, _callee11, this);
|
|
1140
1459
|
}));
|
|
1141
|
-
function removeExistingStagedLines(
|
|
1460
|
+
function removeExistingStagedLines(_x5) {
|
|
1142
1461
|
return _removeExistingStagedLines.apply(this, arguments);
|
|
1143
1462
|
}
|
|
1144
1463
|
return removeExistingStagedLines;
|
|
@@ -1146,25 +1465,25 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1146
1465
|
}, {
|
|
1147
1466
|
key: "stageProducts",
|
|
1148
1467
|
value: function () {
|
|
1149
|
-
var _stageProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1468
|
+
var _stageProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(params, ownershipKey) {
|
|
1150
1469
|
var _params$rawProducts;
|
|
1151
1470
|
var productIds, existingIds, missingIds, productIdSet, selectedProducts, _i, _arr, sourceProduct, productInput;
|
|
1152
|
-
return _regeneratorRuntime().wrap(function
|
|
1153
|
-
while (1) switch (
|
|
1471
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
1472
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1154
1473
|
case 0:
|
|
1155
1474
|
productIds = params.productIds || [];
|
|
1156
1475
|
if (productIds.length) {
|
|
1157
|
-
|
|
1476
|
+
_context12.next = 3;
|
|
1158
1477
|
break;
|
|
1159
1478
|
}
|
|
1160
|
-
return
|
|
1479
|
+
return _context12.abrupt("return", this.getTempOrder());
|
|
1161
1480
|
case 3:
|
|
1162
1481
|
if (!((_params$rawProducts = params.rawProducts) !== null && _params$rawProducts !== void 0 && _params$rawProducts.length)) {
|
|
1163
|
-
|
|
1482
|
+
_context12.next = 7;
|
|
1164
1483
|
break;
|
|
1165
1484
|
}
|
|
1166
1485
|
this.unifiedProductCatalog = params.rawProducts;
|
|
1167
|
-
|
|
1486
|
+
_context12.next = 12;
|
|
1168
1487
|
break;
|
|
1169
1488
|
case 7:
|
|
1170
1489
|
existingIds = new Set((this.unifiedProductCatalog || []).map(function (product) {
|
|
@@ -1175,15 +1494,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1175
1494
|
return !existingIds.has(String(id));
|
|
1176
1495
|
});
|
|
1177
1496
|
if (!(missingIds.length || params.productLoadParams)) {
|
|
1178
|
-
|
|
1497
|
+
_context12.next = 12;
|
|
1179
1498
|
break;
|
|
1180
1499
|
}
|
|
1181
|
-
|
|
1500
|
+
_context12.next = 12;
|
|
1182
1501
|
return this.loadProducts(_objectSpread(_objectSpread({}, params.productLoadParams || {}), {}, {
|
|
1183
1502
|
product_ids: productIds.map(Number).filter(Number.isFinite)
|
|
1184
1503
|
}));
|
|
1185
1504
|
case 12:
|
|
1186
|
-
|
|
1505
|
+
_context12.next = 14;
|
|
1187
1506
|
return this.removeExistingStagedLines(ownershipKey);
|
|
1188
1507
|
case 14:
|
|
1189
1508
|
productIdSet = new Set(productIds.map(function (id) {
|
|
@@ -1196,30 +1515,30 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1196
1515
|
_i = 0, _arr = selectedProducts;
|
|
1197
1516
|
case 17:
|
|
1198
1517
|
if (!(_i < _arr.length)) {
|
|
1199
|
-
|
|
1518
|
+
_context12.next = 26;
|
|
1200
1519
|
break;
|
|
1201
1520
|
}
|
|
1202
1521
|
sourceProduct = _arr[_i];
|
|
1203
1522
|
productInput = this.buildUnifiedOrderProduct(sourceProduct, ownershipKey);
|
|
1204
1523
|
if (!productInput) {
|
|
1205
|
-
|
|
1524
|
+
_context12.next = 23;
|
|
1206
1525
|
break;
|
|
1207
1526
|
}
|
|
1208
|
-
|
|
1527
|
+
_context12.next = 23;
|
|
1209
1528
|
return this.addProductToOrder(productInput);
|
|
1210
1529
|
case 23:
|
|
1211
1530
|
_i++;
|
|
1212
|
-
|
|
1531
|
+
_context12.next = 17;
|
|
1213
1532
|
break;
|
|
1214
1533
|
case 26:
|
|
1215
|
-
return
|
|
1534
|
+
return _context12.abrupt("return", this.getTempOrder());
|
|
1216
1535
|
case 27:
|
|
1217
1536
|
case "end":
|
|
1218
|
-
return
|
|
1537
|
+
return _context12.stop();
|
|
1219
1538
|
}
|
|
1220
|
-
},
|
|
1539
|
+
}, _callee12, this);
|
|
1221
1540
|
}));
|
|
1222
|
-
function stageProducts(
|
|
1541
|
+
function stageProducts(_x6, _x7) {
|
|
1223
1542
|
return _stageProducts.apply(this, arguments);
|
|
1224
1543
|
}
|
|
1225
1544
|
return stageProducts;
|
|
@@ -1231,18 +1550,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1231
1550
|
}, {
|
|
1232
1551
|
key: "stagePlannerProducts",
|
|
1233
1552
|
value: (function () {
|
|
1234
|
-
var _stagePlannerProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1235
|
-
return _regeneratorRuntime().wrap(function
|
|
1236
|
-
while (1) switch (
|
|
1553
|
+
var _stagePlannerProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(params) {
|
|
1554
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1555
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1237
1556
|
case 0:
|
|
1238
|
-
return
|
|
1557
|
+
return _context13.abrupt("return", this.stageProducts(params, 'unified_booking_sales'));
|
|
1239
1558
|
case 1:
|
|
1240
1559
|
case "end":
|
|
1241
|
-
return
|
|
1560
|
+
return _context13.stop();
|
|
1242
1561
|
}
|
|
1243
|
-
},
|
|
1562
|
+
}, _callee13, this);
|
|
1244
1563
|
}));
|
|
1245
|
-
function stagePlannerProducts(
|
|
1564
|
+
function stagePlannerProducts(_x8) {
|
|
1246
1565
|
return _stagePlannerProducts.apply(this, arguments);
|
|
1247
1566
|
}
|
|
1248
1567
|
return stagePlannerProducts;
|
|
@@ -1255,18 +1574,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1255
1574
|
}, {
|
|
1256
1575
|
key: "stageRetailProducts",
|
|
1257
1576
|
value: (function () {
|
|
1258
|
-
var _stageRetailProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1259
|
-
return _regeneratorRuntime().wrap(function
|
|
1260
|
-
while (1) switch (
|
|
1577
|
+
var _stageRetailProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
|
|
1578
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1579
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1261
1580
|
case 0:
|
|
1262
|
-
return
|
|
1581
|
+
return _context14.abrupt("return", this.stageProducts(params, 'unified_booking_sales_retail'));
|
|
1263
1582
|
case 1:
|
|
1264
1583
|
case "end":
|
|
1265
|
-
return
|
|
1584
|
+
return _context14.stop();
|
|
1266
1585
|
}
|
|
1267
|
-
},
|
|
1586
|
+
}, _callee14, this);
|
|
1268
1587
|
}));
|
|
1269
|
-
function stageRetailProducts(
|
|
1588
|
+
function stageRetailProducts(_x9) {
|
|
1270
1589
|
return _stageRetailProducts.apply(this, arguments);
|
|
1271
1590
|
}
|
|
1272
1591
|
return stageRetailProducts;
|
|
@@ -1280,15 +1599,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1280
1599
|
}, {
|
|
1281
1600
|
key: "addRetailProduct",
|
|
1282
1601
|
value: (function () {
|
|
1283
|
-
var _addRetailProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1602
|
+
var _addRetailProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
|
|
1284
1603
|
var _params$quantity, _ref18, _params$productId, _params$product, _params$product2;
|
|
1285
1604
|
var quantity, productId, sourceProduct, products, orderProduct;
|
|
1286
|
-
return _regeneratorRuntime().wrap(function
|
|
1287
|
-
while (1) switch (
|
|
1605
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1606
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1288
1607
|
case 0:
|
|
1289
1608
|
quantity = Math.floor(Number((_params$quantity = params.quantity) !== null && _params$quantity !== void 0 ? _params$quantity : 1));
|
|
1290
1609
|
if (!(!Number.isFinite(quantity) || quantity <= 0)) {
|
|
1291
|
-
|
|
1610
|
+
_context15.next = 3;
|
|
1292
1611
|
break;
|
|
1293
1612
|
}
|
|
1294
1613
|
throw new Error('[UnifiedBookingSales] retail 商品数量必须大于 0');
|
|
@@ -1302,22 +1621,22 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1302
1621
|
});
|
|
1303
1622
|
}
|
|
1304
1623
|
if (!(!sourceProduct && productId !== undefined && productId !== null)) {
|
|
1305
|
-
|
|
1624
|
+
_context15.next = 11;
|
|
1306
1625
|
break;
|
|
1307
1626
|
}
|
|
1308
|
-
|
|
1627
|
+
_context15.next = 9;
|
|
1309
1628
|
return this.loadProducts(_objectSpread(_objectSpread({}, params.productLoadParams || {}), {}, {
|
|
1310
1629
|
product_ids: [Number(productId)].filter(Number.isFinite)
|
|
1311
1630
|
}));
|
|
1312
1631
|
case 9:
|
|
1313
|
-
products =
|
|
1632
|
+
products = _context15.sent;
|
|
1314
1633
|
sourceProduct = products.find(function (product) {
|
|
1315
1634
|
var _product$id4;
|
|
1316
1635
|
return String((_product$id4 = product.id) !== null && _product$id4 !== void 0 ? _product$id4 : product.product_id) === String(productId);
|
|
1317
1636
|
});
|
|
1318
1637
|
case 11:
|
|
1319
1638
|
if (sourceProduct) {
|
|
1320
|
-
|
|
1639
|
+
_context15.next = 13;
|
|
1321
1640
|
break;
|
|
1322
1641
|
}
|
|
1323
1642
|
throw new Error("[UnifiedBookingSales] \u672A\u627E\u5230\u96F6\u552E\u5546\u54C1 ".concat(String(productId !== null && productId !== void 0 ? productId : '')).trim());
|
|
@@ -1326,19 +1645,19 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1326
1645
|
quantity: quantity
|
|
1327
1646
|
}), 'unified_booking_sales_retail');
|
|
1328
1647
|
if (orderProduct) {
|
|
1329
|
-
|
|
1648
|
+
_context15.next = 16;
|
|
1330
1649
|
break;
|
|
1331
1650
|
}
|
|
1332
1651
|
throw new Error('[UnifiedBookingSales] 无法生成零售商品订单行');
|
|
1333
1652
|
case 16:
|
|
1334
|
-
return
|
|
1653
|
+
return _context15.abrupt("return", this.addProductToOrder(orderProduct));
|
|
1335
1654
|
case 17:
|
|
1336
1655
|
case "end":
|
|
1337
|
-
return
|
|
1656
|
+
return _context15.stop();
|
|
1338
1657
|
}
|
|
1339
|
-
},
|
|
1658
|
+
}, _callee15, this);
|
|
1340
1659
|
}));
|
|
1341
|
-
function addRetailProduct(
|
|
1660
|
+
function addRetailProduct(_x10) {
|
|
1342
1661
|
return _addRetailProduct.apply(this, arguments);
|
|
1343
1662
|
}
|
|
1344
1663
|
return addRetailProduct;
|
|
@@ -1346,44 +1665,44 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1346
1665
|
}, {
|
|
1347
1666
|
key: "loadPlannerProducts",
|
|
1348
1667
|
value: (function () {
|
|
1349
|
-
var _loadPlannerProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1668
|
+
var _loadPlannerProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
|
|
1350
1669
|
var _params$context, _params$rawProducts2, _params$productLoadPa, _this$getProductCatal;
|
|
1351
1670
|
var productIds, _params$productLoadPa2;
|
|
1352
|
-
return _regeneratorRuntime().wrap(function
|
|
1353
|
-
while (1) switch (
|
|
1671
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1672
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1354
1673
|
case 0:
|
|
1355
1674
|
if (!((_params$context = params.context) !== null && _params$context !== void 0 && (_params$context = _params$context.products) !== null && _params$context !== void 0 && _params$context.length)) {
|
|
1356
|
-
|
|
1675
|
+
_context16.next = 2;
|
|
1357
1676
|
break;
|
|
1358
1677
|
}
|
|
1359
|
-
return
|
|
1678
|
+
return _context16.abrupt("return", params.context.products);
|
|
1360
1679
|
case 2:
|
|
1361
1680
|
if (!((_params$rawProducts2 = params.rawProducts) !== null && _params$rawProducts2 !== void 0 && _params$rawProducts2.length)) {
|
|
1362
|
-
|
|
1681
|
+
_context16.next = 4;
|
|
1363
1682
|
break;
|
|
1364
1683
|
}
|
|
1365
|
-
return
|
|
1684
|
+
return _context16.abrupt("return", params.rawProducts.map(normalizeProductForPlanner));
|
|
1366
1685
|
case 4:
|
|
1367
1686
|
productIds = params.productIds || ((_params$productLoadPa = params.productLoadParams) === null || _params$productLoadPa === void 0 ? void 0 : _params$productLoadPa.product_ids) || [];
|
|
1368
1687
|
if (!(productIds.length > 0 || params.productLoadParams)) {
|
|
1369
|
-
|
|
1688
|
+
_context16.next = 8;
|
|
1370
1689
|
break;
|
|
1371
1690
|
}
|
|
1372
|
-
|
|
1691
|
+
_context16.next = 8;
|
|
1373
1692
|
return this.loadProducts(_objectSpread(_objectSpread(_objectSpread({}, params.date ? {
|
|
1374
1693
|
schedule_date: params.date
|
|
1375
1694
|
} : {}), params.productLoadParams || {}), {}, {
|
|
1376
1695
|
product_ids: productIds.length ? productIds.map(Number).filter(Number.isFinite) : (_params$productLoadPa2 = params.productLoadParams) === null || _params$productLoadPa2 === void 0 ? void 0 : _params$productLoadPa2.product_ids
|
|
1377
1696
|
}));
|
|
1378
1697
|
case 8:
|
|
1379
|
-
return
|
|
1698
|
+
return _context16.abrupt("return", (((_this$getProductCatal = this.getProductCatalog) === null || _this$getProductCatal === void 0 ? void 0 : _this$getProductCatal.call(this).products) || []).map(normalizeProductForPlanner));
|
|
1380
1699
|
case 9:
|
|
1381
1700
|
case "end":
|
|
1382
|
-
return
|
|
1701
|
+
return _context16.stop();
|
|
1383
1702
|
}
|
|
1384
|
-
},
|
|
1703
|
+
}, _callee16, this);
|
|
1385
1704
|
}));
|
|
1386
|
-
function loadPlannerProducts(
|
|
1705
|
+
function loadPlannerProducts(_x11) {
|
|
1387
1706
|
return _loadPlannerProducts.apply(this, arguments);
|
|
1388
1707
|
}
|
|
1389
1708
|
return loadPlannerProducts;
|
|
@@ -1391,32 +1710,32 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1391
1710
|
}, {
|
|
1392
1711
|
key: "ensurePlannerSchedulesLoaded",
|
|
1393
1712
|
value: (function () {
|
|
1394
|
-
var _ensurePlannerSchedulesLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1713
|
+
var _ensurePlannerSchedulesLoaded = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
1395
1714
|
var _this$store$schedule$5, _this$store$schedule5, _this$store$schedule$6, _this$store$schedule6, _this$store$schedule$7, _this$store$schedule7;
|
|
1396
1715
|
var scheduleList;
|
|
1397
|
-
return _regeneratorRuntime().wrap(function
|
|
1398
|
-
while (1) switch (
|
|
1716
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1717
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1399
1718
|
case 0:
|
|
1400
1719
|
if (this.store.schedule) {
|
|
1401
|
-
|
|
1720
|
+
_context17.next = 2;
|
|
1402
1721
|
break;
|
|
1403
1722
|
}
|
|
1404
1723
|
throw new Error('[UnifiedBookingSales] schedule 模块未初始化');
|
|
1405
1724
|
case 2:
|
|
1406
1725
|
scheduleList = ((_this$store$schedule$5 = (_this$store$schedule5 = this.store.schedule).getScheduleList) === null || _this$store$schedule$5 === void 0 ? void 0 : _this$store$schedule$5.call(_this$store$schedule5)) || [];
|
|
1407
1726
|
if (!(!((_this$store$schedule$6 = (_this$store$schedule6 = this.store.schedule).isScheduleListLoaded) !== null && _this$store$schedule$6 !== void 0 && _this$store$schedule$6.call(_this$store$schedule6)) || scheduleList.length === 0)) {
|
|
1408
|
-
|
|
1727
|
+
_context17.next = 6;
|
|
1409
1728
|
break;
|
|
1410
1729
|
}
|
|
1411
|
-
|
|
1730
|
+
_context17.next = 6;
|
|
1412
1731
|
return this.store.schedule.loadAllSchedule();
|
|
1413
1732
|
case 6:
|
|
1414
|
-
return
|
|
1733
|
+
return _context17.abrupt("return", ((_this$store$schedule$7 = (_this$store$schedule7 = this.store.schedule).getScheduleList) === null || _this$store$schedule$7 === void 0 ? void 0 : _this$store$schedule$7.call(_this$store$schedule7)) || []);
|
|
1415
1734
|
case 7:
|
|
1416
1735
|
case "end":
|
|
1417
|
-
return
|
|
1736
|
+
return _context17.stop();
|
|
1418
1737
|
}
|
|
1419
|
-
},
|
|
1738
|
+
}, _callee17, this);
|
|
1420
1739
|
}));
|
|
1421
1740
|
function ensurePlannerSchedulesLoaded() {
|
|
1422
1741
|
return _ensurePlannerSchedulesLoaded.apply(this, arguments);
|
|
@@ -1431,35 +1750,35 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1431
1750
|
}, {
|
|
1432
1751
|
key: "ensurePlannerSchedulesForResources",
|
|
1433
1752
|
value: (function () {
|
|
1434
|
-
var _ensurePlannerSchedulesForResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1753
|
+
var _ensurePlannerSchedulesForResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(rawResources) {
|
|
1435
1754
|
var scheduleList, scheduleIds, _this$store$schedule$8, _this$store$schedule8;
|
|
1436
|
-
return _regeneratorRuntime().wrap(function
|
|
1437
|
-
while (1) switch (
|
|
1755
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1756
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1438
1757
|
case 0:
|
|
1439
|
-
|
|
1758
|
+
_context18.next = 2;
|
|
1440
1759
|
return this.ensurePlannerSchedulesLoaded();
|
|
1441
1760
|
case 2:
|
|
1442
|
-
scheduleList =
|
|
1761
|
+
scheduleList = _context18.sent;
|
|
1443
1762
|
scheduleIds = collectRawScheduleIds(rawResources);
|
|
1444
1763
|
if (scheduleListHasIds(scheduleList, scheduleIds)) {
|
|
1445
|
-
|
|
1764
|
+
_context18.next = 8;
|
|
1446
1765
|
break;
|
|
1447
1766
|
}
|
|
1448
|
-
|
|
1767
|
+
_context18.next = 7;
|
|
1449
1768
|
return this.store.schedule.loadAllSchedule({
|
|
1450
1769
|
useCache: false
|
|
1451
1770
|
});
|
|
1452
1771
|
case 7:
|
|
1453
1772
|
scheduleList = ((_this$store$schedule$8 = (_this$store$schedule8 = this.store.schedule).getScheduleList) === null || _this$store$schedule$8 === void 0 ? void 0 : _this$store$schedule$8.call(_this$store$schedule8)) || [];
|
|
1454
1773
|
case 8:
|
|
1455
|
-
return
|
|
1774
|
+
return _context18.abrupt("return", scheduleList);
|
|
1456
1775
|
case 9:
|
|
1457
1776
|
case "end":
|
|
1458
|
-
return
|
|
1777
|
+
return _context18.stop();
|
|
1459
1778
|
}
|
|
1460
|
-
},
|
|
1779
|
+
}, _callee18, this);
|
|
1461
1780
|
}));
|
|
1462
|
-
function ensurePlannerSchedulesForResources(
|
|
1781
|
+
function ensurePlannerSchedulesForResources(_x12) {
|
|
1463
1782
|
return _ensurePlannerSchedulesForResources.apply(this, arguments);
|
|
1464
1783
|
}
|
|
1465
1784
|
return ensurePlannerSchedulesForResources;
|
|
@@ -1473,12 +1792,12 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1473
1792
|
}, {
|
|
1474
1793
|
key: "fetchPlannerResourcesV2",
|
|
1475
1794
|
value: (function () {
|
|
1476
|
-
var _fetchPlannerResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1795
|
+
var _fetchPlannerResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
|
|
1477
1796
|
var response, data;
|
|
1478
|
-
return _regeneratorRuntime().wrap(function
|
|
1479
|
-
while (1) switch (
|
|
1797
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1798
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1480
1799
|
case 0:
|
|
1481
|
-
|
|
1800
|
+
_context19.next = 2;
|
|
1482
1801
|
return this.request.get('/schedule/resource/list/v2', {
|
|
1483
1802
|
start_date: params.dateRange.start,
|
|
1484
1803
|
end_date: params.dateRange.end,
|
|
@@ -1488,28 +1807,28 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1488
1807
|
useCache: false
|
|
1489
1808
|
});
|
|
1490
1809
|
case 2:
|
|
1491
|
-
response =
|
|
1810
|
+
response = _context19.sent;
|
|
1492
1811
|
data = response === null || response === void 0 ? void 0 : response.data;
|
|
1493
1812
|
if (!Array.isArray(data)) {
|
|
1494
|
-
|
|
1813
|
+
_context19.next = 6;
|
|
1495
1814
|
break;
|
|
1496
1815
|
}
|
|
1497
|
-
return
|
|
1816
|
+
return _context19.abrupt("return", data);
|
|
1498
1817
|
case 6:
|
|
1499
1818
|
if (!Array.isArray(data === null || data === void 0 ? void 0 : data.list)) {
|
|
1500
|
-
|
|
1819
|
+
_context19.next = 8;
|
|
1501
1820
|
break;
|
|
1502
1821
|
}
|
|
1503
|
-
return
|
|
1822
|
+
return _context19.abrupt("return", data.list);
|
|
1504
1823
|
case 8:
|
|
1505
|
-
return
|
|
1824
|
+
return _context19.abrupt("return", []);
|
|
1506
1825
|
case 9:
|
|
1507
1826
|
case "end":
|
|
1508
|
-
return
|
|
1827
|
+
return _context19.stop();
|
|
1509
1828
|
}
|
|
1510
|
-
},
|
|
1829
|
+
}, _callee19, this);
|
|
1511
1830
|
}));
|
|
1512
|
-
function fetchPlannerResourcesV2(
|
|
1831
|
+
function fetchPlannerResourcesV2(_x13) {
|
|
1513
1832
|
return _fetchPlannerResourcesV.apply(this, arguments);
|
|
1514
1833
|
}
|
|
1515
1834
|
return fetchPlannerResourcesV2;
|
|
@@ -1522,7 +1841,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1522
1841
|
}, {
|
|
1523
1842
|
key: "loadPlannerResources",
|
|
1524
1843
|
value: (function () {
|
|
1525
|
-
var _loadPlannerResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1844
|
+
var _loadPlannerResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
|
|
1526
1845
|
var _params$context2, _params$rawResources, _params$context5;
|
|
1527
1846
|
var products,
|
|
1528
1847
|
_params$context3,
|
|
@@ -1531,25 +1850,25 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1531
1850
|
rawResources,
|
|
1532
1851
|
scheduleList,
|
|
1533
1852
|
materialized,
|
|
1534
|
-
|
|
1535
|
-
return _regeneratorRuntime().wrap(function
|
|
1536
|
-
while (1) switch (
|
|
1853
|
+
_args20 = arguments;
|
|
1854
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1855
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1537
1856
|
case 0:
|
|
1538
|
-
products =
|
|
1857
|
+
products = _args20.length > 1 && _args20[1] !== undefined ? _args20[1] : [];
|
|
1539
1858
|
if (!((_params$context2 = params.context) !== null && _params$context2 !== void 0 && (_params$context2 = _params$context2.resources) !== null && _params$context2 !== void 0 && _params$context2.length)) {
|
|
1540
|
-
|
|
1859
|
+
_context20.next = 3;
|
|
1541
1860
|
break;
|
|
1542
1861
|
}
|
|
1543
|
-
return
|
|
1862
|
+
return _context20.abrupt("return", {
|
|
1544
1863
|
resources: params.context.resources,
|
|
1545
1864
|
externalEvents: params.context.externalEvents || []
|
|
1546
1865
|
});
|
|
1547
1866
|
case 3:
|
|
1548
1867
|
if (!((_params$rawResources = params.rawResources) !== null && _params$rawResources !== void 0 && _params$rawResources.length)) {
|
|
1549
|
-
|
|
1868
|
+
_context20.next = 5;
|
|
1550
1869
|
break;
|
|
1551
1870
|
}
|
|
1552
|
-
return
|
|
1871
|
+
return _context20.abrupt("return", {
|
|
1553
1872
|
resources: params.rawResources.map(normalizeResource).filter(function (resource) {
|
|
1554
1873
|
return resource !== null;
|
|
1555
1874
|
}),
|
|
@@ -1558,41 +1877,41 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1558
1877
|
case 5:
|
|
1559
1878
|
resourceIds = collectPlannerResourceIds(products, params.resourceIds || []);
|
|
1560
1879
|
if (!(!params.useResourceDateApi || !params.dateRange || resourceIds.length === 0)) {
|
|
1561
|
-
|
|
1880
|
+
_context20.next = 8;
|
|
1562
1881
|
break;
|
|
1563
1882
|
}
|
|
1564
|
-
return
|
|
1883
|
+
return _context20.abrupt("return", {
|
|
1565
1884
|
resources: [],
|
|
1566
1885
|
externalEvents: ((_params$context4 = params.context) === null || _params$context4 === void 0 ? void 0 : _params$context4.externalEvents) || []
|
|
1567
1886
|
});
|
|
1568
1887
|
case 8:
|
|
1569
|
-
|
|
1888
|
+
_context20.next = 10;
|
|
1570
1889
|
return this.fetchPlannerResourcesV2({
|
|
1571
1890
|
dateRange: params.dateRange,
|
|
1572
1891
|
resourceIds: resourceIds
|
|
1573
1892
|
});
|
|
1574
1893
|
case 10:
|
|
1575
|
-
rawResources =
|
|
1576
|
-
|
|
1894
|
+
rawResources = _context20.sent;
|
|
1895
|
+
_context20.next = 13;
|
|
1577
1896
|
return this.ensurePlannerSchedulesForResources(rawResources);
|
|
1578
1897
|
case 13:
|
|
1579
|
-
scheduleList =
|
|
1898
|
+
scheduleList = _context20.sent;
|
|
1580
1899
|
materialized = buildPlannerResourcesFromV2({
|
|
1581
1900
|
rawResources: rawResources,
|
|
1582
1901
|
scheduleList: scheduleList,
|
|
1583
1902
|
dateRange: params.dateRange
|
|
1584
1903
|
});
|
|
1585
|
-
return
|
|
1904
|
+
return _context20.abrupt("return", {
|
|
1586
1905
|
resources: materialized.resources,
|
|
1587
1906
|
externalEvents: [].concat(_toConsumableArray(((_params$context5 = params.context) === null || _params$context5 === void 0 ? void 0 : _params$context5.externalEvents) || []), _toConsumableArray(materialized.externalEvents))
|
|
1588
1907
|
});
|
|
1589
1908
|
case 16:
|
|
1590
1909
|
case "end":
|
|
1591
|
-
return
|
|
1910
|
+
return _context20.stop();
|
|
1592
1911
|
}
|
|
1593
|
-
},
|
|
1912
|
+
}, _callee20, this);
|
|
1594
1913
|
}));
|
|
1595
|
-
function loadPlannerResources(
|
|
1914
|
+
function loadPlannerResources(_x14) {
|
|
1596
1915
|
return _loadPlannerResources.apply(this, arguments);
|
|
1597
1916
|
}
|
|
1598
1917
|
return loadPlannerResources;
|
|
@@ -1605,25 +1924,25 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1605
1924
|
}, {
|
|
1606
1925
|
key: "loadPlannerContext",
|
|
1607
1926
|
value: (function () {
|
|
1608
|
-
var _loadPlannerContext = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1927
|
+
var _loadPlannerContext = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
1609
1928
|
var params,
|
|
1610
1929
|
products,
|
|
1611
1930
|
plannerResources,
|
|
1612
1931
|
context,
|
|
1613
1932
|
snapshot,
|
|
1614
|
-
|
|
1615
|
-
return _regeneratorRuntime().wrap(function
|
|
1616
|
-
while (1) switch (
|
|
1933
|
+
_args21 = arguments;
|
|
1934
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1935
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1617
1936
|
case 0:
|
|
1618
|
-
params =
|
|
1619
|
-
|
|
1937
|
+
params = _args21.length > 0 && _args21[0] !== undefined ? _args21[0] : {};
|
|
1938
|
+
_context21.next = 3;
|
|
1620
1939
|
return this.loadPlannerProducts(params);
|
|
1621
1940
|
case 3:
|
|
1622
|
-
products =
|
|
1623
|
-
|
|
1941
|
+
products = _context21.sent;
|
|
1942
|
+
_context21.next = 6;
|
|
1624
1943
|
return this.loadPlannerResources(params, products);
|
|
1625
1944
|
case 6:
|
|
1626
|
-
plannerResources =
|
|
1945
|
+
plannerResources = _context21.sent;
|
|
1627
1946
|
context = _objectSpread(_objectSpread({}, params.context || {}), {}, {
|
|
1628
1947
|
products: products,
|
|
1629
1948
|
resources: plannerResources.resources,
|
|
@@ -1638,15 +1957,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1638
1957
|
endTime: params.endTime,
|
|
1639
1958
|
resourceIds: params.resourceIds || []
|
|
1640
1959
|
});
|
|
1641
|
-
|
|
1960
|
+
_context21.next = 12;
|
|
1642
1961
|
return this.core.effects.emit("".concat(this.name, ":").concat(UnifiedBookingSalesHooks.onPlannerContextLoaded), snapshot);
|
|
1643
1962
|
case 12:
|
|
1644
|
-
return
|
|
1963
|
+
return _context21.abrupt("return", this.getPlanner().getSnapshot());
|
|
1645
1964
|
case 13:
|
|
1646
1965
|
case "end":
|
|
1647
|
-
return
|
|
1966
|
+
return _context21.stop();
|
|
1648
1967
|
}
|
|
1649
|
-
},
|
|
1968
|
+
}, _callee21, this);
|
|
1650
1969
|
}));
|
|
1651
1970
|
function loadPlannerContext() {
|
|
1652
1971
|
return _loadPlannerContext.apply(this, arguments);
|
|
@@ -1656,19 +1975,19 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1656
1975
|
}, {
|
|
1657
1976
|
key: "queryPlannerAvailability",
|
|
1658
1977
|
value: (function () {
|
|
1659
|
-
var _queryPlannerAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1978
|
+
var _queryPlannerAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
|
1660
1979
|
var query,
|
|
1661
|
-
|
|
1662
|
-
return _regeneratorRuntime().wrap(function
|
|
1663
|
-
while (1) switch (
|
|
1980
|
+
_args22 = arguments;
|
|
1981
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1982
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1664
1983
|
case 0:
|
|
1665
|
-
query =
|
|
1666
|
-
return
|
|
1984
|
+
query = _args22.length > 0 && _args22[0] !== undefined ? _args22[0] : {};
|
|
1985
|
+
return _context22.abrupt("return", this.getPlanner().queryAvailability(query));
|
|
1667
1986
|
case 2:
|
|
1668
1987
|
case "end":
|
|
1669
|
-
return
|
|
1988
|
+
return _context22.stop();
|
|
1670
1989
|
}
|
|
1671
|
-
},
|
|
1990
|
+
}, _callee22, this);
|
|
1672
1991
|
}));
|
|
1673
1992
|
function queryPlannerAvailability() {
|
|
1674
1993
|
return _queryPlannerAvailability.apply(this, arguments);
|
|
@@ -1696,24 +2015,24 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1696
2015
|
}, {
|
|
1697
2016
|
key: "autoAssignPlanner",
|
|
1698
2017
|
value: (function () {
|
|
1699
|
-
var _autoAssignPlanner = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2018
|
+
var _autoAssignPlanner = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
1700
2019
|
var query,
|
|
1701
2020
|
result,
|
|
1702
|
-
|
|
1703
|
-
return _regeneratorRuntime().wrap(function
|
|
1704
|
-
while (1) switch (
|
|
2021
|
+
_args23 = arguments;
|
|
2022
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
2023
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1705
2024
|
case 0:
|
|
1706
|
-
query =
|
|
2025
|
+
query = _args23.length > 0 && _args23[0] !== undefined ? _args23[0] : {};
|
|
1707
2026
|
result = this.getPlanner().autoAssign(query);
|
|
1708
2027
|
if (result.conflicts.length) {
|
|
1709
2028
|
console.warn('[UnifiedBookingSales] autoAssignPlanner 存在未分配项', result.conflicts);
|
|
1710
2029
|
}
|
|
1711
|
-
return
|
|
2030
|
+
return _context23.abrupt("return", this.getPlanner().getSnapshot());
|
|
1712
2031
|
case 4:
|
|
1713
2032
|
case "end":
|
|
1714
|
-
return
|
|
2033
|
+
return _context23.stop();
|
|
1715
2034
|
}
|
|
1716
|
-
},
|
|
2035
|
+
}, _callee23, this);
|
|
1717
2036
|
}));
|
|
1718
2037
|
function autoAssignPlanner() {
|
|
1719
2038
|
return _autoAssignPlanner.apply(this, arguments);
|
|
@@ -1740,7 +2059,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1740
2059
|
}, {
|
|
1741
2060
|
key: "commitPlannerSelection",
|
|
1742
2061
|
value: (function () {
|
|
1743
|
-
var _commitPlannerSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2062
|
+
var _commitPlannerSelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
1744
2063
|
var params,
|
|
1745
2064
|
snapshot,
|
|
1746
2065
|
assignments,
|
|
@@ -1755,11 +2074,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1755
2074
|
productInput,
|
|
1756
2075
|
submitResult,
|
|
1757
2076
|
result,
|
|
1758
|
-
|
|
1759
|
-
return _regeneratorRuntime().wrap(function
|
|
1760
|
-
while (1) switch (
|
|
2077
|
+
_args24 = arguments;
|
|
2078
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
2079
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1761
2080
|
case 0:
|
|
1762
|
-
params =
|
|
2081
|
+
params = _args24.length > 0 && _args24[0] !== undefined ? _args24[0] : {};
|
|
1763
2082
|
if (params.selection) {
|
|
1764
2083
|
this.setPlannerSelection(params.selection);
|
|
1765
2084
|
}
|
|
@@ -1771,10 +2090,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1771
2090
|
snapshot = this.getPlannerSnapshot();
|
|
1772
2091
|
assignments = snapshot.selection.assignments || [];
|
|
1773
2092
|
if (!(assignments.length === 0)) {
|
|
1774
|
-
|
|
2093
|
+
_context24.next = 7;
|
|
1775
2094
|
break;
|
|
1776
2095
|
}
|
|
1777
|
-
return
|
|
2096
|
+
return _context24.abrupt("return", {
|
|
1778
2097
|
tempOrder: this.getTempOrder(),
|
|
1779
2098
|
assignments: assignments,
|
|
1780
2099
|
validation: {
|
|
@@ -1788,10 +2107,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1788
2107
|
case 7:
|
|
1789
2108
|
validation = this.validatePlannerSelection();
|
|
1790
2109
|
if (validation.ok) {
|
|
1791
|
-
|
|
2110
|
+
_context24.next = 10;
|
|
1792
2111
|
break;
|
|
1793
2112
|
}
|
|
1794
|
-
return
|
|
2113
|
+
return _context24.abrupt("return", {
|
|
1795
2114
|
tempOrder: this.getTempOrder(),
|
|
1796
2115
|
assignments: assignments,
|
|
1797
2116
|
validation: validation
|
|
@@ -1800,7 +2119,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1800
2119
|
productsById = new Map(snapshot.context.products.map(function (product) {
|
|
1801
2120
|
return [String(product.id), product];
|
|
1802
2121
|
}));
|
|
1803
|
-
|
|
2122
|
+
_context24.next = 13;
|
|
1804
2123
|
return this.removeExistingStagedLines('unified_booking_sales');
|
|
1805
2124
|
case 13:
|
|
1806
2125
|
assignmentGroups = new Map();
|
|
@@ -1809,20 +2128,20 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1809
2128
|
assignmentGroups.set(key, [].concat(_toConsumableArray(assignmentGroups.get(key) || []), [assignment]));
|
|
1810
2129
|
});
|
|
1811
2130
|
_iterator3 = _createForOfIteratorHelper(assignmentGroups.values());
|
|
1812
|
-
|
|
2131
|
+
_context24.prev = 16;
|
|
1813
2132
|
_iterator3.s();
|
|
1814
2133
|
case 18:
|
|
1815
2134
|
if ((_step3 = _iterator3.n()).done) {
|
|
1816
|
-
|
|
2135
|
+
_context24.next = 31;
|
|
1817
2136
|
break;
|
|
1818
2137
|
}
|
|
1819
2138
|
groupAssignments = _step3.value;
|
|
1820
2139
|
product = productsById.get(String(groupAssignments[0].productId));
|
|
1821
2140
|
if (product) {
|
|
1822
|
-
|
|
2141
|
+
_context24.next = 23;
|
|
1823
2142
|
break;
|
|
1824
2143
|
}
|
|
1825
|
-
return
|
|
2144
|
+
return _context24.abrupt("continue", 29);
|
|
1826
2145
|
case 23:
|
|
1827
2146
|
sourceProduct = product.raw || {
|
|
1828
2147
|
id: product.id,
|
|
@@ -1831,39 +2150,39 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1831
2150
|
};
|
|
1832
2151
|
productInput = this.buildUnifiedOrderProduct(sourceProduct, 'unified_booking_sales', product);
|
|
1833
2152
|
if (productInput) {
|
|
1834
|
-
|
|
2153
|
+
_context24.next = 27;
|
|
1835
2154
|
break;
|
|
1836
2155
|
}
|
|
1837
|
-
return
|
|
2156
|
+
return _context24.abrupt("continue", 29);
|
|
1838
2157
|
case 27:
|
|
1839
|
-
|
|
2158
|
+
_context24.next = 29;
|
|
1840
2159
|
return this.addProductToOrder(productInput, buildBookingFromAssignments({
|
|
1841
2160
|
assignments: groupAssignments,
|
|
1842
2161
|
product: product
|
|
1843
2162
|
}));
|
|
1844
2163
|
case 29:
|
|
1845
|
-
|
|
2164
|
+
_context24.next = 18;
|
|
1846
2165
|
break;
|
|
1847
2166
|
case 31:
|
|
1848
|
-
|
|
2167
|
+
_context24.next = 36;
|
|
1849
2168
|
break;
|
|
1850
2169
|
case 33:
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
_iterator3.e(
|
|
2170
|
+
_context24.prev = 33;
|
|
2171
|
+
_context24.t0 = _context24["catch"](16);
|
|
2172
|
+
_iterator3.e(_context24.t0);
|
|
1854
2173
|
case 36:
|
|
1855
|
-
|
|
2174
|
+
_context24.prev = 36;
|
|
1856
2175
|
_iterator3.f();
|
|
1857
|
-
return
|
|
2176
|
+
return _context24.finish(36);
|
|
1858
2177
|
case 39:
|
|
1859
2178
|
if (!params.submitAfterCommit) {
|
|
1860
|
-
|
|
2179
|
+
_context24.next = 43;
|
|
1861
2180
|
break;
|
|
1862
2181
|
}
|
|
1863
|
-
|
|
2182
|
+
_context24.next = 42;
|
|
1864
2183
|
return this.submitSalesOrder();
|
|
1865
2184
|
case 42:
|
|
1866
|
-
submitResult =
|
|
2185
|
+
submitResult = _context24.sent;
|
|
1867
2186
|
case 43:
|
|
1868
2187
|
result = {
|
|
1869
2188
|
tempOrder: this.getTempOrder(),
|
|
@@ -1871,15 +2190,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
|
|
|
1871
2190
|
validation: validation,
|
|
1872
2191
|
submitResult: submitResult
|
|
1873
2192
|
};
|
|
1874
|
-
|
|
2193
|
+
_context24.next = 46;
|
|
1875
2194
|
return this.core.effects.emit("".concat(this.name, ":").concat(UnifiedBookingSalesHooks.onPlannerCommitted), result);
|
|
1876
2195
|
case 46:
|
|
1877
|
-
return
|
|
2196
|
+
return _context24.abrupt("return", result);
|
|
1878
2197
|
case 47:
|
|
1879
2198
|
case "end":
|
|
1880
|
-
return
|
|
2199
|
+
return _context24.stop();
|
|
1881
2200
|
}
|
|
1882
|
-
},
|
|
2201
|
+
}, _callee24, this, [[16, 33, 36, 39]]);
|
|
1883
2202
|
}));
|
|
1884
2203
|
function commitPlannerSelection() {
|
|
1885
2204
|
return _commitPlannerSelection.apply(this, arguments);
|