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