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