@pisell/pisellos 2.3.187 → 2.3.190
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/BookingContext/utils/productExtend.d.ts +9 -1
- package/dist/modules/BookingContext/utils/productExtend.js +47 -13
- package/dist/modules/Order/index.d.ts +15 -5
- package/dist/modules/Order/index.js +1161 -921
- package/dist/modules/Order/types.d.ts +16 -4
- package/dist/modules/Order/utils.d.ts +1 -3
- package/dist/modules/Order/utils.js +2 -5
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/ResourcePlanner/planner.js +29 -2
- package/dist/modules/ResourcePlanner/types.d.ts +6 -0
- package/dist/modules/Rules/index.js +19 -30
- package/dist/solution/BaseSales/index.d.ts +4 -0
- package/dist/solution/BaseSales/index.js +204 -176
- package/dist/solution/BaseSales/types.d.ts +1 -0
- package/dist/solution/BaseSales/types.js +1 -0
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingByStep/index.js +8 -5
- package/dist/solution/BookingByStep/utils/resources.d.ts +10 -0
- package/dist/solution/BookingByStep/utils/resources.js +117 -76
- package/dist/solution/BookingTicket/index.js +52 -31
- package/dist/solution/UnifiedBookingSales/index.d.ts +3 -0
- package/dist/solution/UnifiedBookingSales/index.js +279 -204
- package/dist/solution/UnifiedBookingSales/types.d.ts +6 -1
- package/lib/modules/BookingContext/utils/productExtend.d.ts +9 -1
- package/lib/modules/BookingContext/utils/productExtend.js +38 -5
- package/lib/modules/Order/index.d.ts +15 -5
- package/lib/modules/Order/index.js +167 -21
- package/lib/modules/Order/types.d.ts +16 -4
- package/lib/modules/Order/utils.d.ts +1 -3
- package/lib/modules/Order/utils.js +2 -5
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/ResourcePlanner/planner.js +25 -1
- package/lib/modules/ResourcePlanner/types.d.ts +6 -0
- package/lib/modules/Rules/index.js +9 -19
- package/lib/solution/BaseSales/index.d.ts +4 -0
- package/lib/solution/BaseSales/index.js +14 -0
- package/lib/solution/BaseSales/types.d.ts +1 -0
- package/lib/solution/BaseSales/types.js +1 -0
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingByStep/index.js +8 -2
- package/lib/solution/BookingByStep/utils/resources.d.ts +10 -0
- package/lib/solution/BookingByStep/utils/resources.js +25 -15
- package/lib/solution/BookingTicket/index.js +8 -2
- package/lib/solution/UnifiedBookingSales/index.d.ts +3 -0
- package/lib/solution/UnifiedBookingSales/index.js +80 -15
- package/lib/solution/UnifiedBookingSales/types.d.ts +6 -1
- package/package.json +1 -1
|
@@ -174,6 +174,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
174
174
|
_defineProperty(_assertThisInitialized(_this), "openCache", false);
|
|
175
175
|
_defineProperty(_assertThisInitialized(_this), "sessionStoragePersistEnabled", false);
|
|
176
176
|
_defineProperty(_assertThisInitialized(_this), "sessionStorageRestoreRecord", null);
|
|
177
|
+
_defineProperty(_assertThisInitialized(_this), "orderSessionId", null);
|
|
178
|
+
_defineProperty(_assertThisInitialized(_this), "orderSessionDestroyed", false);
|
|
179
|
+
_defineProperty(_assertThisInitialized(_this), "orderSessionAliases", new Set());
|
|
180
|
+
_defineProperty(_assertThisInitialized(_this), "orderReplacement", null);
|
|
177
181
|
/** 只允许当前订单最新的 prepare/config 请求回写客户资产态。 */
|
|
178
182
|
_defineProperty(_assertThisInitialized(_this), "customerWalletPrepareConfigEpoch", 0);
|
|
179
183
|
/** Payment 可能早于 prepare/config 返回;先按实例 ID 暂存卡号等待 Snapshot。 */
|
|
@@ -537,6 +541,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
537
541
|
case 0:
|
|
538
542
|
this.core = core;
|
|
539
543
|
this.store = options.store;
|
|
544
|
+
this.orderReplacement = null;
|
|
545
|
+
this.orderSessionId = null;
|
|
546
|
+
this.orderSessionDestroyed = false;
|
|
547
|
+
this.orderSessionAliases.clear();
|
|
540
548
|
otherParams = options.otherParams || {};
|
|
541
549
|
this.syncSessionStorageOptions(otherParams);
|
|
542
550
|
if (this.sessionStoragePersistEnabled) {
|
|
@@ -576,8 +584,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
576
584
|
this.orderHooks = this.moduleHooksOverride || ((_otherParams$order = otherParams.order) === null || _otherParams$order === void 0 ? void 0 : _otherParams$order.hooks) || ((_otherParams$hooks = otherParams.hooks) === null || _otherParams$hooks === void 0 ? void 0 : _otherParams$hooks.order);
|
|
577
585
|
this.otherParams = otherParams;
|
|
578
586
|
this.registerDiscountModules(options);
|
|
587
|
+
this.publishOrderSession(this.store.tempOrder);
|
|
579
588
|
this.logInfo('OrderModule initialized successfully');
|
|
580
|
-
case
|
|
589
|
+
case 26:
|
|
581
590
|
case "end":
|
|
582
591
|
return _context4.stop();
|
|
583
592
|
}
|
|
@@ -598,49 +607,52 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
598
607
|
while (1) switch (_context5.prev = _context5.next) {
|
|
599
608
|
case 0:
|
|
600
609
|
this.sessionStorageRestoreRecord = null;
|
|
610
|
+
this.orderReplacement = null;
|
|
611
|
+
this.orderSessionDestroyed = true;
|
|
612
|
+
this.publishOrderSession(null);
|
|
601
613
|
childModules = [(_this$store = this.store) === null || _this$store === void 0 ? void 0 : _this$store.discount, (_this$store2 = this.store) === null || _this$store2 === void 0 ? void 0 : _this$store2.rules];
|
|
602
614
|
_i = 0, _childModules = childModules;
|
|
603
|
-
case
|
|
615
|
+
case 6:
|
|
604
616
|
if (!(_i < _childModules.length)) {
|
|
605
|
-
_context5.next =
|
|
617
|
+
_context5.next = 22;
|
|
606
618
|
break;
|
|
607
619
|
}
|
|
608
620
|
childModule = _childModules[_i];
|
|
609
621
|
if (!(!childModule || typeof childModule.destroy !== 'function')) {
|
|
610
|
-
_context5.next =
|
|
622
|
+
_context5.next = 10;
|
|
611
623
|
break;
|
|
612
624
|
}
|
|
613
|
-
return _context5.abrupt("continue",
|
|
614
|
-
case 7:
|
|
615
|
-
_context5.prev = 7;
|
|
616
|
-
_context5.next = 10;
|
|
617
|
-
return childModule.destroy();
|
|
625
|
+
return _context5.abrupt("continue", 19);
|
|
618
626
|
case 10:
|
|
619
|
-
_context5.
|
|
627
|
+
_context5.prev = 10;
|
|
628
|
+
_context5.next = 13;
|
|
629
|
+
return childModule.destroy();
|
|
630
|
+
case 13:
|
|
631
|
+
_context5.next = 19;
|
|
620
632
|
break;
|
|
621
|
-
case
|
|
622
|
-
_context5.prev =
|
|
623
|
-
_context5.t0 = _context5["catch"](
|
|
633
|
+
case 15:
|
|
634
|
+
_context5.prev = 15;
|
|
635
|
+
_context5.t0 = _context5["catch"](10);
|
|
624
636
|
errorMessage = _context5.t0 instanceof Error ? _context5.t0.message : String(_context5.t0);
|
|
625
637
|
this.logWarning('Destroy child module failed', {
|
|
626
638
|
module: childModule.name,
|
|
627
639
|
error: errorMessage
|
|
628
640
|
});
|
|
629
|
-
case
|
|
641
|
+
case 19:
|
|
630
642
|
_i++;
|
|
631
|
-
_context5.next =
|
|
643
|
+
_context5.next = 6;
|
|
632
644
|
break;
|
|
633
|
-
case
|
|
645
|
+
case 22:
|
|
634
646
|
if (this.store) {
|
|
635
647
|
this.store.discount = null;
|
|
636
648
|
this.store.rules = null;
|
|
637
649
|
}
|
|
638
650
|
_get(_getPrototypeOf(OrderModule.prototype), "destroy", this).call(this);
|
|
639
|
-
case
|
|
651
|
+
case 24:
|
|
640
652
|
case "end":
|
|
641
653
|
return _context5.stop();
|
|
642
654
|
}
|
|
643
|
-
}, _callee5, this, [[
|
|
655
|
+
}, _callee5, this, [[10, 15]]);
|
|
644
656
|
}));
|
|
645
657
|
function destroy() {
|
|
646
658
|
return _destroy.apply(this, arguments);
|
|
@@ -1969,6 +1981,169 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1969
1981
|
}
|
|
1970
1982
|
|
|
1971
1983
|
// ─── TempOrder: 创建 & 获取 ───
|
|
1984
|
+
}, {
|
|
1985
|
+
key: "getOrderSessionAliases",
|
|
1986
|
+
value: function getOrderSessionAliases(order) {
|
|
1987
|
+
var aliases = new Set();
|
|
1988
|
+
if (!order) return aliases;
|
|
1989
|
+
var _iterator9 = _createForOfIteratorHelper(['external_sale_number', 'order_id']),
|
|
1990
|
+
_step9;
|
|
1991
|
+
try {
|
|
1992
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
1993
|
+
var key = _step9.value;
|
|
1994
|
+
var value = order[key];
|
|
1995
|
+
if (value !== null && value !== undefined && String(value).trim() !== '' && (key !== 'order_id' || String(value) !== '0')) {
|
|
1996
|
+
aliases.add("".concat(key, ":").concat(String(value).trim()));
|
|
1997
|
+
}
|
|
1998
|
+
}
|
|
1999
|
+
} catch (err) {
|
|
2000
|
+
_iterator9.e(err);
|
|
2001
|
+
} finally {
|
|
2002
|
+
_iterator9.f();
|
|
2003
|
+
}
|
|
2004
|
+
return aliases;
|
|
2005
|
+
}
|
|
2006
|
+
}, {
|
|
2007
|
+
key: "publishOrderSession",
|
|
2008
|
+
value: function publishOrderSession(order) {
|
|
2009
|
+
var _this9 = this,
|
|
2010
|
+
_this$core;
|
|
2011
|
+
var fresh = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
2012
|
+
var previousSessionId = this.orderSessionId;
|
|
2013
|
+
if (!order) {
|
|
2014
|
+
this.orderSessionId = null;
|
|
2015
|
+
this.orderSessionAliases.clear();
|
|
2016
|
+
} else {
|
|
2017
|
+
if (fresh || !this.orderSessionId) {
|
|
2018
|
+
this.orderSessionId = createUuidV4();
|
|
2019
|
+
this.orderSessionAliases = new Set();
|
|
2020
|
+
}
|
|
2021
|
+
this.getOrderSessionAliases(order).forEach(function (alias) {
|
|
2022
|
+
return _this9.orderSessionAliases.add(alias);
|
|
2023
|
+
});
|
|
2024
|
+
}
|
|
2025
|
+
if (previousSessionId === this.orderSessionId || !((_this$core = this.core) !== null && _this$core !== void 0 && _this$core.effects)) return;
|
|
2026
|
+
// The session is already published. A listener failure must not turn a successful
|
|
2027
|
+
// reset into a failed reset or roll the active order back.
|
|
2028
|
+
var reportError = function reportError(error) {
|
|
2029
|
+
return _this9.logWarning('Order session listener failed', {
|
|
2030
|
+
error: error instanceof Error ? error.message : String(error)
|
|
2031
|
+
});
|
|
2032
|
+
};
|
|
2033
|
+
try {
|
|
2034
|
+
void Promise.resolve(this.effectsEmit('onOrderSessionChanged', {
|
|
2035
|
+
sessionId: this.orderSessionId,
|
|
2036
|
+
previousSessionId: previousSessionId
|
|
2037
|
+
})).catch(reportError);
|
|
2038
|
+
} catch (error) {
|
|
2039
|
+
reportError(error);
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
}, {
|
|
2043
|
+
key: "getOrderSessionId",
|
|
2044
|
+
value: function getOrderSessionId() {
|
|
2045
|
+
var _this$store3;
|
|
2046
|
+
if (this.orderSessionDestroyed) return null;
|
|
2047
|
+
if (this.orderReplacement) return this.orderReplacement.sessionId;
|
|
2048
|
+
// Existing in-memory orders can be adopted during initialization. Adding a
|
|
2049
|
+
// remote ID later only extends the aliases; it does not create a new order.
|
|
2050
|
+
this.publishOrderSession(((_this$store3 = this.store) === null || _this$store3 === void 0 ? void 0 : _this$store3.tempOrder) || null);
|
|
2051
|
+
return this.orderSessionId;
|
|
2052
|
+
}
|
|
2053
|
+
}, {
|
|
2054
|
+
key: "isOrderSessionCurrent",
|
|
2055
|
+
value: function isOrderSessionCurrent(sessionId) {
|
|
2056
|
+
return !this.orderReplacement && Boolean(sessionId) && this.getOrderSessionId() === sessionId;
|
|
2057
|
+
}
|
|
2058
|
+
}, {
|
|
2059
|
+
key: "beginOrderReplacement",
|
|
2060
|
+
value: function beginOrderReplacement(preserveOrderSessionId) {
|
|
2061
|
+
var _discount$getOriginal, _discount$getDiscount;
|
|
2062
|
+
if (this.orderReplacement) {
|
|
2063
|
+
throw Object.assign(new Error('An order replacement is already pending'), {
|
|
2064
|
+
code: 'ORDER_SESSION_TRANSITION_PENDING'
|
|
2065
|
+
});
|
|
2066
|
+
}
|
|
2067
|
+
var sessionId = this.getOrderSessionId();
|
|
2068
|
+
if (preserveOrderSessionId && preserveOrderSessionId !== sessionId) {
|
|
2069
|
+
throw Object.assign(new Error('The order session has changed'), {
|
|
2070
|
+
code: 'ORDER_SESSION_CHANGED'
|
|
2071
|
+
});
|
|
2072
|
+
}
|
|
2073
|
+
var discount = this.store.discount;
|
|
2074
|
+
var replacement = {
|
|
2075
|
+
state: _objectSpread({}, this.store),
|
|
2076
|
+
sessionId: sessionId,
|
|
2077
|
+
aliases: new Set(this.orderSessionAliases),
|
|
2078
|
+
originalDiscounts: cloneDeep((discount === null || discount === void 0 || (_discount$getOriginal = discount.getOriginalDiscountList) === null || _discount$getOriginal === void 0 ? void 0 : _discount$getOriginal.call(discount)) || []),
|
|
2079
|
+
discounts: cloneDeep((discount === null || discount === void 0 || (_discount$getDiscount = discount.getDiscountList) === null || _discount$getDiscount === void 0 ? void 0 : _discount$getDiscount.call(discount)) || []),
|
|
2080
|
+
walletEpoch: this.customerWalletPrepareConfigEpoch,
|
|
2081
|
+
pointCardCandidates: new Map(this.pointCardSnapshotCodeCandidates),
|
|
2082
|
+
sessionStorageRestoreRecord: this.sessionStorageRestoreRecord
|
|
2083
|
+
};
|
|
2084
|
+
this.orderReplacement = replacement;
|
|
2085
|
+
return replacement;
|
|
2086
|
+
}
|
|
2087
|
+
}, {
|
|
2088
|
+
key: "assertOrderReplacementCurrent",
|
|
2089
|
+
value: function assertOrderReplacementCurrent(replacement) {
|
|
2090
|
+
if (this.orderReplacement !== replacement) {
|
|
2091
|
+
throw Object.assign(new Error('The order changed while its replacement was pending'), {
|
|
2092
|
+
code: 'ORDER_SESSION_CHANGED'
|
|
2093
|
+
});
|
|
2094
|
+
}
|
|
2095
|
+
}
|
|
2096
|
+
}, {
|
|
2097
|
+
key: "completeOrderReplacement",
|
|
2098
|
+
value: function completeOrderReplacement(replacement, nextOrder, preserveOrderSessionId) {
|
|
2099
|
+
this.assertOrderReplacementCurrent(replacement);
|
|
2100
|
+
var aliases = this.getOrderSessionAliases(nextOrder);
|
|
2101
|
+
var sameOrder = Boolean(replacement.sessionId) && (preserveOrderSessionId === replacement.sessionId || _toConsumableArray(aliases).some(function (alias) {
|
|
2102
|
+
return replacement.aliases.has(alias);
|
|
2103
|
+
}));
|
|
2104
|
+
this.orderReplacement = null;
|
|
2105
|
+
this.publishOrderSession(nextOrder, !sameOrder);
|
|
2106
|
+
}
|
|
2107
|
+
}, {
|
|
2108
|
+
key: "rollbackOrderReplacement",
|
|
2109
|
+
value: function () {
|
|
2110
|
+
var _rollbackOrderReplacement = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(replacement) {
|
|
2111
|
+
var discount, restore;
|
|
2112
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context13) {
|
|
2113
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
2114
|
+
case 0:
|
|
2115
|
+
if (!(this.orderReplacement !== replacement)) {
|
|
2116
|
+
_context13.next = 2;
|
|
2117
|
+
break;
|
|
2118
|
+
}
|
|
2119
|
+
return _context13.abrupt("return");
|
|
2120
|
+
case 2:
|
|
2121
|
+
Object.assign(this.store, replacement.state);
|
|
2122
|
+
this.customerWalletPrepareConfigEpoch = replacement.walletEpoch;
|
|
2123
|
+
this.pointCardSnapshotCodeCandidates = replacement.pointCardCandidates;
|
|
2124
|
+
this.sessionStorageRestoreRecord = replacement.sessionStorageRestoreRecord;
|
|
2125
|
+
discount = this.store.discount;
|
|
2126
|
+
_context13.next = 9;
|
|
2127
|
+
return Promise.allSettled([discount === null || discount === void 0 ? void 0 : discount.setOriginalDiscountList(replacement.originalDiscounts), discount === null || discount === void 0 ? void 0 : discount.setDiscountList(replacement.discounts)]);
|
|
2128
|
+
case 9:
|
|
2129
|
+
restore = _context13.sent;
|
|
2130
|
+
if (restore.some(function (result) {
|
|
2131
|
+
return result.status === 'rejected';
|
|
2132
|
+
})) {
|
|
2133
|
+
this.logWarning('Order replacement discount rollback listener failed');
|
|
2134
|
+
}
|
|
2135
|
+
if (this.orderReplacement === replacement) this.orderReplacement = null;
|
|
2136
|
+
case 12:
|
|
2137
|
+
case "end":
|
|
2138
|
+
return _context13.stop();
|
|
2139
|
+
}
|
|
2140
|
+
}, _callee12, this);
|
|
2141
|
+
}));
|
|
2142
|
+
function rollbackOrderReplacement(_x12) {
|
|
2143
|
+
return _rollbackOrderReplacement.apply(this, arguments);
|
|
2144
|
+
}
|
|
2145
|
+
return rollbackOrderReplacement;
|
|
2146
|
+
}()
|
|
1972
2147
|
}, {
|
|
1973
2148
|
key: "createDefaultTempOrderInstance",
|
|
1974
2149
|
value: function createDefaultTempOrderInstance() {
|
|
@@ -2007,12 +2182,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2007
2182
|
}, {
|
|
2008
2183
|
key: "rememberPointCardSnapshotCodeCandidates",
|
|
2009
2184
|
value: function rememberPointCardSnapshotCodeCandidates(value) {
|
|
2010
|
-
var
|
|
2185
|
+
var _this10 = this;
|
|
2011
2186
|
collectPointCardSnapshotCodeCandidates(value).forEach(function (_ref19) {
|
|
2012
2187
|
var id = _ref19.id,
|
|
2013
2188
|
code = _ref19.code;
|
|
2014
|
-
if (!
|
|
2015
|
-
|
|
2189
|
+
if (!_this10.pointCardSnapshotCodeCandidates.has(id)) {
|
|
2190
|
+
_this10.pointCardSnapshotCodeCandidates.set(id, code);
|
|
2016
2191
|
}
|
|
2017
2192
|
});
|
|
2018
2193
|
}
|
|
@@ -2104,11 +2279,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2104
2279
|
}, {
|
|
2105
2280
|
key: "createExternalSaleNumber",
|
|
2106
2281
|
value: function createExternalSaleNumber() {
|
|
2107
|
-
var _this$
|
|
2282
|
+
var _this$core2;
|
|
2108
2283
|
var timestamp = dayjs().format('YYYYMMDDHHmmssSSS');
|
|
2109
2284
|
var random6 = String(Math.floor(Math.random() * 1000000)).padStart(6, '0');
|
|
2110
2285
|
var parts = ['LOCAL'];
|
|
2111
|
-
var context = (_this$
|
|
2286
|
+
var context = (_this$core2 = this.core) === null || _this$core2 === void 0 ? void 0 : _this$core2.context;
|
|
2112
2287
|
var getData = context === null || context === void 0 ? void 0 : context.getData;
|
|
2113
2288
|
if (typeof getData === 'function') {
|
|
2114
2289
|
var shopId = getData.call(context, 'shop_id');
|
|
@@ -2160,14 +2335,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2160
2335
|
}, {
|
|
2161
2336
|
key: "saveDraft",
|
|
2162
2337
|
value: function () {
|
|
2163
|
-
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2164
|
-
return _regeneratorRuntime().wrap(function
|
|
2165
|
-
while (1) switch (
|
|
2338
|
+
var _saveDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
2339
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context14) {
|
|
2340
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
2166
2341
|
case 0:
|
|
2167
2342
|
case "end":
|
|
2168
|
-
return
|
|
2343
|
+
return _context14.stop();
|
|
2169
2344
|
}
|
|
2170
|
-
},
|
|
2345
|
+
}, _callee13);
|
|
2171
2346
|
}));
|
|
2172
2347
|
function saveDraft() {
|
|
2173
2348
|
return _saveDraft.apply(this, arguments);
|
|
@@ -2182,18 +2357,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2182
2357
|
}, {
|
|
2183
2358
|
key: "hydrateTempOrderFromLocalRecord",
|
|
2184
2359
|
value: function () {
|
|
2185
|
-
var _hydrateTempOrderFromLocalRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2186
|
-
return _regeneratorRuntime().wrap(function
|
|
2187
|
-
while (1) switch (
|
|
2360
|
+
var _hydrateTempOrderFromLocalRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(record) {
|
|
2361
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context15) {
|
|
2362
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
2188
2363
|
case 0:
|
|
2189
|
-
return
|
|
2364
|
+
return _context15.abrupt("return", this.hydrateTempOrderFromRecord(record));
|
|
2190
2365
|
case 1:
|
|
2191
2366
|
case "end":
|
|
2192
|
-
return
|
|
2367
|
+
return _context15.stop();
|
|
2193
2368
|
}
|
|
2194
|
-
},
|
|
2369
|
+
}, _callee14, this);
|
|
2195
2370
|
}));
|
|
2196
|
-
function hydrateTempOrderFromLocalRecord(
|
|
2371
|
+
function hydrateTempOrderFromLocalRecord(_x13) {
|
|
2197
2372
|
return _hydrateTempOrderFromLocalRecord.apply(this, arguments);
|
|
2198
2373
|
}
|
|
2199
2374
|
return hydrateTempOrderFromLocalRecord;
|
|
@@ -2219,23 +2394,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2219
2394
|
}, {
|
|
2220
2395
|
key: "calculatePaymentTotal",
|
|
2221
2396
|
value: function calculatePaymentTotal(payments) {
|
|
2222
|
-
var
|
|
2397
|
+
var _this11 = this;
|
|
2223
2398
|
return mapPaymentItemsToOrderPayments(payments, {
|
|
2224
2399
|
includeVoided: false
|
|
2225
2400
|
}).reduce(function (sum, payment) {
|
|
2226
2401
|
if (!isPaidPaymentRecord(payment)) return sum;
|
|
2227
|
-
return sum.plus(
|
|
2402
|
+
return sum.plus(_this11.calculatePaymentEffectiveAmount(payment));
|
|
2228
2403
|
}, new Decimal(0));
|
|
2229
2404
|
}
|
|
2230
2405
|
}, {
|
|
2231
2406
|
key: "calculateOrderPaidPaymentTotal",
|
|
2232
2407
|
value: function calculateOrderPaidPaymentTotal(payments) {
|
|
2233
|
-
var
|
|
2408
|
+
var _this12 = this;
|
|
2234
2409
|
return mapPaymentItemsToOrderPayments(payments, {
|
|
2235
2410
|
includeVoided: false
|
|
2236
2411
|
}).reduce(function (sum, payment) {
|
|
2237
2412
|
if (!isPaidPaymentRecord(payment)) return sum;
|
|
2238
|
-
return sum.plus(
|
|
2413
|
+
return sum.plus(_this12.calculatePaymentGapAmount(payment));
|
|
2239
2414
|
}, new Decimal(0));
|
|
2240
2415
|
}
|
|
2241
2416
|
}, {
|
|
@@ -2371,13 +2546,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2371
2546
|
}, {
|
|
2372
2547
|
key: "calculateDepositPaidAmount",
|
|
2373
2548
|
value: function calculateDepositPaidAmount(payments) {
|
|
2374
|
-
var
|
|
2549
|
+
var _this13 = this;
|
|
2375
2550
|
return (payments || []).reduce(function (sum, payment) {
|
|
2376
2551
|
var paymentRecord = payment;
|
|
2377
2552
|
if (!isPaidPaymentRecord(paymentRecord)) return sum;
|
|
2378
2553
|
var isDepositPayment = paymentRecord.type === 'deposit' || paymentRecord.order_payment_type === 'deposit';
|
|
2379
2554
|
if (!isDepositPayment) return sum;
|
|
2380
|
-
return sum.plus(
|
|
2555
|
+
return sum.plus(_this13.calculatePaymentGapAmount(paymentRecord));
|
|
2381
2556
|
}, new Decimal(0));
|
|
2382
2557
|
}
|
|
2383
2558
|
}, {
|
|
@@ -2414,17 +2589,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2414
2589
|
}, {
|
|
2415
2590
|
key: "getPaymentNumberDevicePrefixSync",
|
|
2416
2591
|
value: function getPaymentNumberDevicePrefixSync() {
|
|
2417
|
-
var
|
|
2592
|
+
var _this14 = this;
|
|
2418
2593
|
return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
|
|
2419
|
-
return
|
|
2594
|
+
return _this14.getPaymentNumberAppData(key);
|
|
2420
2595
|
});
|
|
2421
2596
|
}
|
|
2422
2597
|
}, {
|
|
2423
2598
|
key: "getPaymentNumberDevicePrefixAsync",
|
|
2424
2599
|
value: function getPaymentNumberDevicePrefixAsync() {
|
|
2425
|
-
var
|
|
2600
|
+
var _this15 = this;
|
|
2426
2601
|
return resolvePaymentNumberDevicePrefix(function (key) {
|
|
2427
|
-
return
|
|
2602
|
+
return _this15.getPaymentNumberAppData(key);
|
|
2428
2603
|
});
|
|
2429
2604
|
}
|
|
2430
2605
|
}, {
|
|
@@ -2521,11 +2696,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2521
2696
|
if (targetAmount.lte(0)) return [];
|
|
2522
2697
|
var remainingAmount = Decimal.max(targetAmount.minus(nonVoucherTotal), 0);
|
|
2523
2698
|
var cappedVouchers = [];
|
|
2524
|
-
var
|
|
2525
|
-
|
|
2699
|
+
var _iterator10 = _createForOfIteratorHelper(params.vouchers),
|
|
2700
|
+
_step10;
|
|
2526
2701
|
try {
|
|
2527
|
-
for (
|
|
2528
|
-
var voucher =
|
|
2702
|
+
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
2703
|
+
var voucher = _step10.value;
|
|
2529
2704
|
if (remainingAmount.lte(0)) break;
|
|
2530
2705
|
var voucherAmount = Decimal.max(new Decimal(voucher.amount || 0), 0);
|
|
2531
2706
|
if (voucherAmount.lte(0)) continue;
|
|
@@ -2545,25 +2720,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2545
2720
|
remainingAmount = remainingAmount.minus(cappedAmount);
|
|
2546
2721
|
}
|
|
2547
2722
|
} catch (err) {
|
|
2548
|
-
|
|
2723
|
+
_iterator10.e(err);
|
|
2549
2724
|
} finally {
|
|
2550
|
-
|
|
2725
|
+
_iterator10.f();
|
|
2551
2726
|
}
|
|
2552
2727
|
return cappedVouchers;
|
|
2553
2728
|
}
|
|
2554
2729
|
}, {
|
|
2555
2730
|
key: "calculatePaidPaymentSummary",
|
|
2556
2731
|
value: function calculatePaidPaymentSummary(payments) {
|
|
2557
|
-
var
|
|
2732
|
+
var _this16 = this;
|
|
2558
2733
|
return (payments || []).reduce(function (summary, payment) {
|
|
2559
2734
|
var paymentRecord = payment;
|
|
2560
2735
|
if (!isPaidPaymentRecord(paymentRecord)) return summary;
|
|
2561
2736
|
return {
|
|
2562
2737
|
customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
|
|
2563
|
-
orderPaidAmount: summary.orderPaidAmount.plus(
|
|
2564
|
-
gapPaidAmount: summary.gapPaidAmount.plus(
|
|
2565
|
-
payServiceChargeAmount: summary.payServiceChargeAmount.plus(
|
|
2566
|
-
roundingAmount: summary.roundingAmount.plus(
|
|
2738
|
+
orderPaidAmount: summary.orderPaidAmount.plus(_this16.calculatePaymentOrderAmount(paymentRecord)),
|
|
2739
|
+
gapPaidAmount: summary.gapPaidAmount.plus(_this16.calculatePaymentGapAmount(paymentRecord)),
|
|
2740
|
+
payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this16.calculatePaymentServiceFee(paymentRecord)),
|
|
2741
|
+
roundingAmount: summary.roundingAmount.plus(_this16.calculatePaymentRoundingAmount(paymentRecord))
|
|
2567
2742
|
};
|
|
2568
2743
|
}, {
|
|
2569
2744
|
customerPaidAmount: new Decimal(0),
|
|
@@ -2632,43 +2807,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2632
2807
|
// 整单折扣均摊层产出的 payment 维度字段,直接由计算层写入 metadata,
|
|
2633
2808
|
// 这里需把它们一并回写到商品 metadata 以便持久化/出站。
|
|
2634
2809
|
var metadataMoneyKeys = ['main_product_attached_bundle_selling_price', 'main_product_attached_bundle_payment_price'];
|
|
2635
|
-
var
|
|
2636
|
-
|
|
2810
|
+
var _iterator11 = _createForOfIteratorHelper(products || []),
|
|
2811
|
+
_step11;
|
|
2637
2812
|
try {
|
|
2638
|
-
for (
|
|
2639
|
-
var product =
|
|
2813
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
2814
|
+
var product = _step11.value;
|
|
2640
2815
|
var productRecord = product;
|
|
2641
2816
|
var metadata = productRecord.metadata && _typeof(productRecord.metadata) === 'object' ? _objectSpread({}, productRecord.metadata) : {};
|
|
2642
2817
|
var hasMetadataPatch = false;
|
|
2643
|
-
var
|
|
2644
|
-
|
|
2818
|
+
var _iterator12 = _createForOfIteratorHelper(moneyKeys),
|
|
2819
|
+
_step12;
|
|
2645
2820
|
try {
|
|
2646
|
-
for (
|
|
2647
|
-
var key =
|
|
2821
|
+
for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
|
|
2822
|
+
var key = _step12.value;
|
|
2648
2823
|
var value = this.formatSummaryMetadataMoney(productRecord[key]);
|
|
2649
2824
|
if (value === undefined) continue;
|
|
2650
2825
|
metadata[key] = value;
|
|
2651
2826
|
hasMetadataPatch = true;
|
|
2652
2827
|
}
|
|
2653
2828
|
} catch (err) {
|
|
2654
|
-
|
|
2829
|
+
_iterator12.e(err);
|
|
2655
2830
|
} finally {
|
|
2656
|
-
|
|
2831
|
+
_iterator12.f();
|
|
2657
2832
|
}
|
|
2658
|
-
var
|
|
2659
|
-
|
|
2833
|
+
var _iterator13 = _createForOfIteratorHelper(metadataMoneyKeys),
|
|
2834
|
+
_step13;
|
|
2660
2835
|
try {
|
|
2661
|
-
for (
|
|
2662
|
-
var _key =
|
|
2836
|
+
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
|
2837
|
+
var _key = _step13.value;
|
|
2663
2838
|
var _value = this.formatSummaryMetadataMoney(metadata[_key]);
|
|
2664
2839
|
if (_value === undefined) continue;
|
|
2665
2840
|
metadata[_key] = _value;
|
|
2666
2841
|
hasMetadataPatch = true;
|
|
2667
2842
|
}
|
|
2668
2843
|
} catch (err) {
|
|
2669
|
-
|
|
2844
|
+
_iterator13.e(err);
|
|
2670
2845
|
} finally {
|
|
2671
|
-
|
|
2846
|
+
_iterator13.f();
|
|
2672
2847
|
}
|
|
2673
2848
|
if (metadata.average_discount_amount_rate !== undefined) {
|
|
2674
2849
|
hasMetadataPatch = true;
|
|
@@ -2683,11 +2858,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2683
2858
|
}
|
|
2684
2859
|
if (hasMetadataPatch) productRecord.metadata = metadata;
|
|
2685
2860
|
if (!Array.isArray(productRecord.product_bundle)) continue;
|
|
2686
|
-
var
|
|
2687
|
-
|
|
2861
|
+
var _iterator14 = _createForOfIteratorHelper(productRecord.product_bundle),
|
|
2862
|
+
_step14;
|
|
2688
2863
|
try {
|
|
2689
|
-
for (
|
|
2690
|
-
var bundle =
|
|
2864
|
+
for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
|
|
2865
|
+
var bundle = _step14.value;
|
|
2691
2866
|
var bundleRecord = bundle;
|
|
2692
2867
|
var bundleMetadata = bundleRecord.metadata && _typeof(bundleRecord.metadata) === 'object' ? _objectSpread({}, bundleRecord.metadata) : {};
|
|
2693
2868
|
var hasBundleMetadataPatch = false;
|
|
@@ -2707,15 +2882,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2707
2882
|
if (hasBundleMetadataPatch) bundleRecord.metadata = bundleMetadata;
|
|
2708
2883
|
}
|
|
2709
2884
|
} catch (err) {
|
|
2710
|
-
|
|
2885
|
+
_iterator14.e(err);
|
|
2711
2886
|
} finally {
|
|
2712
|
-
|
|
2887
|
+
_iterator14.f();
|
|
2713
2888
|
}
|
|
2714
2889
|
}
|
|
2715
2890
|
} catch (err) {
|
|
2716
|
-
|
|
2891
|
+
_iterator11.e(err);
|
|
2717
2892
|
} finally {
|
|
2718
|
-
|
|
2893
|
+
_iterator11.f();
|
|
2719
2894
|
}
|
|
2720
2895
|
}
|
|
2721
2896
|
}, {
|
|
@@ -2770,15 +2945,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2770
2945
|
}, {
|
|
2771
2946
|
key: "normalizeFingerprintValue",
|
|
2772
2947
|
value: function normalizeFingerprintValue(value) {
|
|
2773
|
-
var
|
|
2948
|
+
var _this17 = this;
|
|
2774
2949
|
if (Array.isArray(value)) {
|
|
2775
2950
|
return value.map(function (item) {
|
|
2776
|
-
return
|
|
2951
|
+
return _this17.normalizeFingerprintValue(item);
|
|
2777
2952
|
});
|
|
2778
2953
|
}
|
|
2779
2954
|
if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
|
|
2780
2955
|
return Object.keys(value).sort().reduce(function (result, key) {
|
|
2781
|
-
result[key] =
|
|
2956
|
+
result[key] = _this17.normalizeFingerprintValue(value[key]);
|
|
2782
2957
|
return result;
|
|
2783
2958
|
}, {});
|
|
2784
2959
|
}
|
|
@@ -2793,7 +2968,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2793
2968
|
_sku$barcode,
|
|
2794
2969
|
_ref27,
|
|
2795
2970
|
_sku$variant_id,
|
|
2796
|
-
|
|
2971
|
+
_this18 = this;
|
|
2797
2972
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
2798
2973
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
2799
2974
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -2832,7 +3007,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2832
3007
|
option_group_id: (_option$option_group_ = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_ !== void 0 ? _option$option_group_ : null,
|
|
2833
3008
|
option_group_item_id: (_ref29 = (_option$option_group_2 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_2 !== void 0 ? _option$option_group_2 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref29 !== void 0 ? _ref29 : null,
|
|
2834
3009
|
num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
|
|
2835
|
-
add_price:
|
|
3010
|
+
add_price: _this18.normalizeFingerprintMoney((_option$add_price = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price !== void 0 ? _option$add_price : option === null || option === void 0 ? void 0 : option.price)
|
|
2836
3011
|
};
|
|
2837
3012
|
})
|
|
2838
3013
|
}),
|
|
@@ -2842,8 +3017,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2842
3017
|
bundle_product_id: (_ref30 = (_ref31 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref31 !== void 0 ? _ref31 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref30 !== void 0 ? _ref30 : null,
|
|
2843
3018
|
bundle_variant_id: (_ref32 = (_bundle$bundle_varian = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref32 !== void 0 ? _ref32 : 0,
|
|
2844
3019
|
num: getSafeProductNum((_bundle$num = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle === null || bundle === void 0 ? void 0 : bundle.quantity),
|
|
2845
|
-
price:
|
|
2846
|
-
bundle_selling_price:
|
|
3020
|
+
price: _this18.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
|
|
3021
|
+
bundle_selling_price: _this18.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
|
|
2847
3022
|
price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
|
|
2848
3023
|
price_type_ext: (_bundle$price_type_ex = bundle === null || bundle === void 0 ? void 0 : bundle.price_type_ext) !== null && _bundle$price_type_ex !== void 0 ? _bundle$price_type_ex : ''
|
|
2849
3024
|
};
|
|
@@ -2853,7 +3028,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2853
3028
|
return {
|
|
2854
3029
|
type: (_ref33 = (_discount$type2 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type2 !== void 0 ? _discount$type2 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref33 !== void 0 ? _ref33 : '',
|
|
2855
3030
|
discount_id: (_ref34 = (_ref35 = (_discount$discount_id = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id !== void 0 ? _discount$discount_id : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref35 !== void 0 ? _ref35 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref34 !== void 0 ? _ref34 : null,
|
|
2856
|
-
amount:
|
|
3031
|
+
amount: _this18.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2857
3032
|
};
|
|
2858
3033
|
}))
|
|
2859
3034
|
};
|
|
@@ -2861,9 +3036,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2861
3036
|
}, {
|
|
2862
3037
|
key: "buildOrderProductsFingerprint",
|
|
2863
3038
|
value: function buildOrderProductsFingerprint(products) {
|
|
2864
|
-
var
|
|
3039
|
+
var _this19 = this;
|
|
2865
3040
|
var items = (products || []).map(function (product) {
|
|
2866
|
-
return
|
|
3041
|
+
return _this19.buildProductFingerprintItem(product);
|
|
2867
3042
|
});
|
|
2868
3043
|
items.sort(function (left, right) {
|
|
2869
3044
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -2885,7 +3060,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2885
3060
|
_sku$barcode2,
|
|
2886
3061
|
_ref37,
|
|
2887
3062
|
_sku$variant_id2,
|
|
2888
|
-
|
|
3063
|
+
_this20 = this;
|
|
2889
3064
|
var order = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.store.tempOrder || {};
|
|
2890
3065
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
2891
3066
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
@@ -2922,7 +3097,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2922
3097
|
option_group_id: (_option$option_group_3 = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_3 !== void 0 ? _option$option_group_3 : null,
|
|
2923
3098
|
option_group_item_id: (_ref39 = (_option$option_group_4 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_4 !== void 0 ? _option$option_group_4 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref39 !== void 0 ? _ref39 : null,
|
|
2924
3099
|
num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
|
|
2925
|
-
add_price:
|
|
3100
|
+
add_price: _this20.normalizeFingerprintMoney((_option$add_price2 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price2 !== void 0 ? _option$add_price2 : option === null || option === void 0 ? void 0 : option.price)
|
|
2926
3101
|
};
|
|
2927
3102
|
})
|
|
2928
3103
|
}),
|
|
@@ -2936,14 +3111,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2936
3111
|
num: getSafeProductNum((_bundle$num2 = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num2 !== void 0 ? _bundle$num2 : bundle === null || bundle === void 0 ? void 0 : bundle.quantity),
|
|
2937
3112
|
price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
|
|
2938
3113
|
price_type_ext: (_bundle$price_type_ex2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type_ext) !== null && _bundle$price_type_ex2 !== void 0 ? _bundle$price_type_ex2 : '',
|
|
2939
|
-
option:
|
|
3114
|
+
option: _this20.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
|
|
2940
3115
|
var _ref45, _option$id3, _option$option_group_5, _ref46, _option$option_group_6, _option$num3, _option$add_price3;
|
|
2941
3116
|
return {
|
|
2942
3117
|
id: (_ref45 = (_option$id3 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id3 !== void 0 ? _option$id3 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref45 !== void 0 ? _ref45 : null,
|
|
2943
3118
|
option_group_id: (_option$option_group_5 = option === null || option === void 0 ? void 0 : option.option_group_id) !== null && _option$option_group_5 !== void 0 ? _option$option_group_5 : null,
|
|
2944
3119
|
option_group_item_id: (_ref46 = (_option$option_group_6 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_6 !== void 0 ? _option$option_group_6 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref46 !== void 0 ? _ref46 : null,
|
|
2945
3120
|
num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
|
|
2946
|
-
add_price:
|
|
3121
|
+
add_price: _this20.normalizeFingerprintMoney((_option$add_price3 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price3 !== void 0 ? _option$add_price3 : option === null || option === void 0 ? void 0 : option.price)
|
|
2947
3122
|
};
|
|
2948
3123
|
}))
|
|
2949
3124
|
};
|
|
@@ -2953,7 +3128,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2953
3128
|
return {
|
|
2954
3129
|
type: (_ref47 = (_discount$type4 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type4 !== void 0 ? _discount$type4 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref47 !== void 0 ? _ref47 : '',
|
|
2955
3130
|
discount_id: (_ref48 = (_ref49 = (_discount$discount_id2 = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id2 !== void 0 ? _discount$discount_id2 : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref49 !== void 0 ? _ref49 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref48 !== void 0 ? _ref48 : null,
|
|
2956
|
-
amount:
|
|
3131
|
+
amount: _this20.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2957
3132
|
};
|
|
2958
3133
|
}))
|
|
2959
3134
|
};
|
|
@@ -2961,10 +3136,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2961
3136
|
}, {
|
|
2962
3137
|
key: "buildOrderProductsStructuralFingerprint",
|
|
2963
3138
|
value: function buildOrderProductsStructuralFingerprint(products) {
|
|
2964
|
-
var
|
|
3139
|
+
var _this21 = this;
|
|
2965
3140
|
var order = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.store.tempOrder || {};
|
|
2966
3141
|
var items = (products || []).map(function (product) {
|
|
2967
|
-
return
|
|
3142
|
+
return _this21.buildProductStructuralFingerprintItem(product, order);
|
|
2968
3143
|
});
|
|
2969
3144
|
items.sort(function (left, right) {
|
|
2970
3145
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -3097,82 +3272,82 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3097
3272
|
value: function clearPersistedAmountFieldsForFullRecalc(products) {
|
|
3098
3273
|
var moneyKeys = ['surcharge_fee', 'main_product_attached_bundle_surcharge_fee', 'surcharge_rounding_remainder', 'main_product_attached_bundle_tax_fee', 'tax_fee', 'original_tax_fee', 'tax_fee_rounding_remainder', 'original_tax_fee_rounding_remainder'];
|
|
3099
3274
|
var metadataMoneyKeys = ['main_product_attached_bundle_surcharge_fee', 'surcharge_rounding_remainder', 'main_product_attached_bundle_tax_fee', 'tax_fee_rounding_remainder'];
|
|
3100
|
-
var
|
|
3101
|
-
|
|
3275
|
+
var _iterator15 = _createForOfIteratorHelper(products || []),
|
|
3276
|
+
_step15;
|
|
3102
3277
|
try {
|
|
3103
|
-
for (
|
|
3104
|
-
var product =
|
|
3278
|
+
for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
|
|
3279
|
+
var product = _step15.value;
|
|
3105
3280
|
var record = product;
|
|
3106
|
-
var
|
|
3107
|
-
|
|
3281
|
+
var _iterator16 = _createForOfIteratorHelper(moneyKeys),
|
|
3282
|
+
_step16;
|
|
3108
3283
|
try {
|
|
3109
|
-
for (
|
|
3110
|
-
var _key2 =
|
|
3284
|
+
for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
|
|
3285
|
+
var _key2 = _step16.value;
|
|
3111
3286
|
delete record[_key2];
|
|
3112
3287
|
}
|
|
3113
3288
|
} catch (err) {
|
|
3114
|
-
|
|
3289
|
+
_iterator16.e(err);
|
|
3115
3290
|
} finally {
|
|
3116
|
-
|
|
3291
|
+
_iterator16.f();
|
|
3117
3292
|
}
|
|
3118
3293
|
if (record.metadata && _typeof(record.metadata) === 'object') {
|
|
3119
3294
|
record.metadata = _objectSpread({}, record.metadata);
|
|
3120
|
-
var
|
|
3121
|
-
|
|
3295
|
+
var _iterator17 = _createForOfIteratorHelper(metadataMoneyKeys),
|
|
3296
|
+
_step17;
|
|
3122
3297
|
try {
|
|
3123
|
-
for (
|
|
3124
|
-
var key =
|
|
3298
|
+
for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
|
|
3299
|
+
var key = _step17.value;
|
|
3125
3300
|
delete record.metadata[key];
|
|
3126
3301
|
}
|
|
3127
3302
|
} catch (err) {
|
|
3128
|
-
|
|
3303
|
+
_iterator17.e(err);
|
|
3129
3304
|
} finally {
|
|
3130
|
-
|
|
3305
|
+
_iterator17.f();
|
|
3131
3306
|
}
|
|
3132
3307
|
}
|
|
3133
|
-
var
|
|
3134
|
-
|
|
3308
|
+
var _iterator18 = _createForOfIteratorHelper(record.product_bundle || []),
|
|
3309
|
+
_step18;
|
|
3135
3310
|
try {
|
|
3136
|
-
for (
|
|
3137
|
-
var bundle =
|
|
3138
|
-
var
|
|
3139
|
-
|
|
3311
|
+
for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
|
|
3312
|
+
var bundle = _step18.value;
|
|
3313
|
+
var _iterator19 = _createForOfIteratorHelper(moneyKeys),
|
|
3314
|
+
_step19;
|
|
3140
3315
|
try {
|
|
3141
|
-
for (
|
|
3142
|
-
var _key4 =
|
|
3316
|
+
for (_iterator19.s(); !(_step19 = _iterator19.n()).done;) {
|
|
3317
|
+
var _key4 = _step19.value;
|
|
3143
3318
|
delete bundle[_key4];
|
|
3144
3319
|
}
|
|
3145
3320
|
} catch (err) {
|
|
3146
|
-
|
|
3321
|
+
_iterator19.e(err);
|
|
3147
3322
|
} finally {
|
|
3148
|
-
|
|
3323
|
+
_iterator19.f();
|
|
3149
3324
|
}
|
|
3150
3325
|
if (bundle.metadata && _typeof(bundle.metadata) === 'object') {
|
|
3151
3326
|
bundle.metadata = _objectSpread({}, bundle.metadata);
|
|
3152
|
-
var
|
|
3153
|
-
|
|
3327
|
+
var _iterator20 = _createForOfIteratorHelper(metadataMoneyKeys),
|
|
3328
|
+
_step20;
|
|
3154
3329
|
try {
|
|
3155
|
-
for (
|
|
3156
|
-
var _key3 =
|
|
3330
|
+
for (_iterator20.s(); !(_step20 = _iterator20.n()).done;) {
|
|
3331
|
+
var _key3 = _step20.value;
|
|
3157
3332
|
delete bundle.metadata[_key3];
|
|
3158
3333
|
}
|
|
3159
3334
|
} catch (err) {
|
|
3160
|
-
|
|
3335
|
+
_iterator20.e(err);
|
|
3161
3336
|
} finally {
|
|
3162
|
-
|
|
3337
|
+
_iterator20.f();
|
|
3163
3338
|
}
|
|
3164
3339
|
}
|
|
3165
3340
|
}
|
|
3166
3341
|
} catch (err) {
|
|
3167
|
-
|
|
3342
|
+
_iterator18.e(err);
|
|
3168
3343
|
} finally {
|
|
3169
|
-
|
|
3344
|
+
_iterator18.f();
|
|
3170
3345
|
}
|
|
3171
3346
|
}
|
|
3172
3347
|
} catch (err) {
|
|
3173
|
-
|
|
3348
|
+
_iterator15.e(err);
|
|
3174
3349
|
} finally {
|
|
3175
|
-
|
|
3350
|
+
_iterator15.f();
|
|
3176
3351
|
}
|
|
3177
3352
|
}
|
|
3178
3353
|
}, {
|
|
@@ -3190,11 +3365,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3190
3365
|
value: function ensureTempOrder() {
|
|
3191
3366
|
if (this.store.tempOrder) {
|
|
3192
3367
|
this.ensureExternalSaleNumber(this.store.tempOrder);
|
|
3368
|
+
if (!this.orderReplacement) this.publishOrderSession(this.store.tempOrder);
|
|
3193
3369
|
return this.store.tempOrder;
|
|
3194
3370
|
}
|
|
3195
3371
|
var newOrder = this.createDefaultTempOrderInstance();
|
|
3196
3372
|
this.ensureExternalSaleNumber(newOrder);
|
|
3197
3373
|
this.store.tempOrder = newOrder;
|
|
3374
|
+
this.publishOrderSession(newOrder, true);
|
|
3198
3375
|
this.persistTempOrder();
|
|
3199
3376
|
return newOrder;
|
|
3200
3377
|
}
|
|
@@ -3203,6 +3380,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3203
3380
|
value: function restoreOrder() {
|
|
3204
3381
|
var _this$store$discount18, _this$store$discount19;
|
|
3205
3382
|
this.logInfo('restoreOrder start', {});
|
|
3383
|
+
this.orderReplacement = null;
|
|
3206
3384
|
this.sessionStorageRestoreRecord = null;
|
|
3207
3385
|
var freshTempOrder = this.createDefaultTempOrderInstance();
|
|
3208
3386
|
this.ensureExternalSaleNumber(freshTempOrder);
|
|
@@ -3213,66 +3391,82 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3213
3391
|
this.store.syncState = undefined;
|
|
3214
3392
|
void ((_this$store$discount18 = this.store.discount) === null || _this$store$discount18 === void 0 ? void 0 : _this$store$discount18.setOriginalDiscountList([]));
|
|
3215
3393
|
void ((_this$store$discount19 = this.store.discount) === null || _this$store$discount19 === void 0 ? void 0 : _this$store$discount19.setDiscountList([]));
|
|
3394
|
+
this.publishOrderSession(freshTempOrder, true);
|
|
3216
3395
|
this.persistTempOrder();
|
|
3217
3396
|
return freshTempOrder;
|
|
3218
3397
|
}
|
|
3219
3398
|
}, {
|
|
3220
3399
|
key: "getTempOrder",
|
|
3221
3400
|
value: function getTempOrder() {
|
|
3222
|
-
return this.store.tempOrder;
|
|
3401
|
+
return this.orderReplacement ? this.orderReplacement.state.tempOrder : this.store.tempOrder;
|
|
3223
3402
|
}
|
|
3224
3403
|
}, {
|
|
3225
3404
|
key: "replaceTempOrder",
|
|
3226
3405
|
value: function () {
|
|
3227
|
-
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3228
|
-
var
|
|
3229
|
-
|
|
3230
|
-
|
|
3406
|
+
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(tempOrder, options) {
|
|
3407
|
+
var _this22 = this;
|
|
3408
|
+
var nextTempOrder, replacement;
|
|
3409
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context16) {
|
|
3410
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
3231
3411
|
case 0:
|
|
3232
3412
|
if (isTempOrder(tempOrder)) {
|
|
3233
|
-
|
|
3413
|
+
_context16.next = 2;
|
|
3234
3414
|
break;
|
|
3235
3415
|
}
|
|
3236
3416
|
throw new Error('无效的 tempOrder 数据');
|
|
3237
3417
|
case 2:
|
|
3238
|
-
this.sessionStorageRestoreRecord = null;
|
|
3239
3418
|
nextTempOrder = this.normalizeTempOrderForRuntime(cloneDeep(tempOrder), {
|
|
3240
3419
|
ensureIdentity: false
|
|
3241
3420
|
});
|
|
3421
|
+
replacement = this.beginOrderReplacement(options === null || options === void 0 ? void 0 : options.preserveOrderSessionId);
|
|
3422
|
+
_context16.prev = 4;
|
|
3423
|
+
this.sessionStorageRestoreRecord = null;
|
|
3242
3424
|
this.store.tempOrder = nextTempOrder;
|
|
3243
3425
|
this.clearCustomerWalletRuntimeState();
|
|
3244
3426
|
if (!((options === null || options === void 0 ? void 0 : options.recalculateSummary) !== false)) {
|
|
3245
|
-
|
|
3427
|
+
_context16.next = 13;
|
|
3246
3428
|
break;
|
|
3247
3429
|
}
|
|
3248
|
-
|
|
3430
|
+
_context16.next = 11;
|
|
3249
3431
|
return this.recalculateSummary({
|
|
3250
|
-
createIfMissing: false
|
|
3432
|
+
createIfMissing: false,
|
|
3433
|
+
isCurrentOrder: function isCurrentOrder() {
|
|
3434
|
+
return _this22.orderReplacement === replacement;
|
|
3435
|
+
}
|
|
3251
3436
|
});
|
|
3252
|
-
case 9:
|
|
3253
|
-
_context15.next = 12;
|
|
3254
|
-
break;
|
|
3255
3437
|
case 11:
|
|
3438
|
+
_context16.next = 14;
|
|
3439
|
+
break;
|
|
3440
|
+
case 13:
|
|
3256
3441
|
this.store.summary = createEmptySummary();
|
|
3257
|
-
case
|
|
3258
|
-
|
|
3259
|
-
this.persistTempOrder();
|
|
3260
|
-
}
|
|
3442
|
+
case 14:
|
|
3443
|
+
this.assertOrderReplacementCurrent(replacement);
|
|
3261
3444
|
if (!(options !== null && options !== void 0 && options.saveDraft)) {
|
|
3262
|
-
|
|
3445
|
+
_context16.next = 19;
|
|
3263
3446
|
break;
|
|
3264
3447
|
}
|
|
3265
|
-
|
|
3448
|
+
_context16.next = 18;
|
|
3266
3449
|
return this.saveDraft();
|
|
3267
|
-
case
|
|
3268
|
-
|
|
3269
|
-
case
|
|
3450
|
+
case 18:
|
|
3451
|
+
this.assertOrderReplacementCurrent(replacement);
|
|
3452
|
+
case 19:
|
|
3453
|
+
if ((options === null || options === void 0 ? void 0 : options.persist) !== false) this.persistTempOrder();
|
|
3454
|
+
this.completeOrderReplacement(replacement, nextTempOrder, options === null || options === void 0 ? void 0 : options.preserveOrderSessionId);
|
|
3455
|
+
return _context16.abrupt("return", nextTempOrder);
|
|
3456
|
+
case 24:
|
|
3457
|
+
_context16.prev = 24;
|
|
3458
|
+
_context16.t0 = _context16["catch"](4);
|
|
3459
|
+
_context16.next = 28;
|
|
3460
|
+
return this.rollbackOrderReplacement(replacement);
|
|
3461
|
+
case 28:
|
|
3462
|
+
throw _context16.t0;
|
|
3463
|
+
case 29:
|
|
3270
3464
|
case "end":
|
|
3271
|
-
return
|
|
3465
|
+
return _context16.stop();
|
|
3272
3466
|
}
|
|
3273
|
-
},
|
|
3467
|
+
}, _callee15, this, [[4, 24]]);
|
|
3274
3468
|
}));
|
|
3275
|
-
function replaceTempOrder(
|
|
3469
|
+
function replaceTempOrder(_x14, _x15) {
|
|
3276
3470
|
return _replaceTempOrder.apply(this, arguments);
|
|
3277
3471
|
}
|
|
3278
3472
|
return replaceTempOrder;
|
|
@@ -3358,32 +3552,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3358
3552
|
}, {
|
|
3359
3553
|
key: "addNewOrder",
|
|
3360
3554
|
value: function () {
|
|
3361
|
-
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3555
|
+
var _addNewOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
3362
3556
|
var tempOrder;
|
|
3363
|
-
return _regeneratorRuntime().wrap(function
|
|
3364
|
-
while (1) switch (
|
|
3557
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context17) {
|
|
3558
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
3365
3559
|
case 0:
|
|
3366
3560
|
tempOrder = this.ensureTempOrder();
|
|
3367
3561
|
this.ensureExternalSaleNumber(tempOrder);
|
|
3368
|
-
|
|
3562
|
+
_context17.next = 4;
|
|
3369
3563
|
return this.recalculateSummary({
|
|
3370
3564
|
createIfMissing: true
|
|
3371
3565
|
});
|
|
3372
3566
|
case 4:
|
|
3373
3567
|
this.persistTempOrder();
|
|
3374
3568
|
if (!this.draftPersistEnabled) {
|
|
3375
|
-
|
|
3569
|
+
_context17.next = 8;
|
|
3376
3570
|
break;
|
|
3377
3571
|
}
|
|
3378
|
-
|
|
3572
|
+
_context17.next = 8;
|
|
3379
3573
|
return this.saveDraft();
|
|
3380
3574
|
case 8:
|
|
3381
|
-
return
|
|
3575
|
+
return _context17.abrupt("return", tempOrder);
|
|
3382
3576
|
case 9:
|
|
3383
3577
|
case "end":
|
|
3384
|
-
return
|
|
3578
|
+
return _context17.stop();
|
|
3385
3579
|
}
|
|
3386
|
-
},
|
|
3580
|
+
}, _callee16, this);
|
|
3387
3581
|
}));
|
|
3388
3582
|
function addNewOrder() {
|
|
3389
3583
|
return _addNewOrder.apply(this, arguments);
|
|
@@ -3425,9 +3619,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3425
3619
|
}, {
|
|
3426
3620
|
key: "sanitizeTempOrderProducts",
|
|
3427
3621
|
value: function sanitizeTempOrderProducts(tempOrder) {
|
|
3428
|
-
var
|
|
3622
|
+
var _this23 = this;
|
|
3429
3623
|
tempOrder.products = (tempOrder.products || []).map(function (product) {
|
|
3430
|
-
return
|
|
3624
|
+
return _this23.sanitizeOrderProductForTempOrder(_this23.normalizeVirtualSettlementProductIfEnabled(product));
|
|
3431
3625
|
});
|
|
3432
3626
|
this.syncTempOrderSettlementState(tempOrder);
|
|
3433
3627
|
ensureUniqueProductLineUids(tempOrder);
|
|
@@ -3550,7 +3744,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3550
3744
|
}, {
|
|
3551
3745
|
key: "syncLinkedBookingHoldersToProducts",
|
|
3552
3746
|
value: function syncLinkedBookingHoldersToProducts(tempOrder) {
|
|
3553
|
-
var
|
|
3747
|
+
var _this24 = this;
|
|
3554
3748
|
var bookings = tempOrder.bookings || [];
|
|
3555
3749
|
var products = tempOrder.products || [];
|
|
3556
3750
|
if (!bookings.length || !products.length) return;
|
|
@@ -3576,7 +3770,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3576
3770
|
var bookingUid = product.booking_uid || ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.booking_uid);
|
|
3577
3771
|
var linkedBooking = (productUid !== undefined && productUid !== null && String(productUid) !== '' ? bookingByProductUid.get(String(productUid)) : undefined) || (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '' ? bookingByBookingUid.get(String(bookingUid)) : undefined);
|
|
3578
3772
|
if (linkedBooking) {
|
|
3579
|
-
|
|
3773
|
+
_this24.setProductHolderFromBooking(product, linkedBooking);
|
|
3580
3774
|
}
|
|
3581
3775
|
});
|
|
3582
3776
|
}
|
|
@@ -3619,11 +3813,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3619
3813
|
var holderNames = [];
|
|
3620
3814
|
var baseHolder = null;
|
|
3621
3815
|
var seen = new Set();
|
|
3622
|
-
var
|
|
3623
|
-
|
|
3816
|
+
var _iterator21 = _createForOfIteratorHelper(tempOrder.bookings || []),
|
|
3817
|
+
_step21;
|
|
3624
3818
|
try {
|
|
3625
|
-
for (
|
|
3626
|
-
var booking =
|
|
3819
|
+
for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
|
|
3820
|
+
var booking = _step21.value;
|
|
3627
3821
|
if (isFulfillmentTimingBooking(booking)) continue;
|
|
3628
3822
|
var holder = booking !== null && booking !== void 0 && booking.holder && _typeof(booking.holder) === 'object' ? booking.holder : null;
|
|
3629
3823
|
if (!baseHolder && holder) {
|
|
@@ -3631,13 +3825,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3631
3825
|
}
|
|
3632
3826
|
var records = this.collectBookingHolderRecords(booking);
|
|
3633
3827
|
var names = this.collectBookingHolderNames(booking);
|
|
3634
|
-
var
|
|
3635
|
-
|
|
3828
|
+
var _iterator22 = _createForOfIteratorHelper(records.entries()),
|
|
3829
|
+
_step22;
|
|
3636
3830
|
try {
|
|
3637
|
-
for (
|
|
3638
|
-
var
|
|
3639
|
-
index =
|
|
3640
|
-
record =
|
|
3831
|
+
for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
|
|
3832
|
+
var _step22$value = _slicedToArray(_step22.value, 2),
|
|
3833
|
+
index = _step22$value[0],
|
|
3834
|
+
record = _step22$value[1];
|
|
3641
3835
|
var key = String(record);
|
|
3642
3836
|
if (seen.has(key)) continue;
|
|
3643
3837
|
seen.add(key);
|
|
@@ -3647,15 +3841,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3647
3841
|
}
|
|
3648
3842
|
}
|
|
3649
3843
|
} catch (err) {
|
|
3650
|
-
|
|
3844
|
+
_iterator22.e(err);
|
|
3651
3845
|
} finally {
|
|
3652
|
-
|
|
3846
|
+
_iterator22.f();
|
|
3653
3847
|
}
|
|
3654
3848
|
}
|
|
3655
3849
|
} catch (err) {
|
|
3656
|
-
|
|
3850
|
+
_iterator21.e(err);
|
|
3657
3851
|
} finally {
|
|
3658
|
-
|
|
3852
|
+
_iterator21.f();
|
|
3659
3853
|
}
|
|
3660
3854
|
if (!holderRecords.length) {
|
|
3661
3855
|
return null;
|
|
@@ -3707,9 +3901,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3707
3901
|
}, {
|
|
3708
3902
|
key: "findBookingIndexByUniqueIdentificationNumber",
|
|
3709
3903
|
value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
|
|
3710
|
-
var
|
|
3904
|
+
var _this25 = this;
|
|
3711
3905
|
return (tempOrder.bookings || []).findIndex(function (booking) {
|
|
3712
|
-
return
|
|
3906
|
+
return _this25.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
|
|
3713
3907
|
});
|
|
3714
3908
|
}
|
|
3715
3909
|
}, {
|
|
@@ -3717,13 +3911,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3717
3911
|
value: function removeLinkedBookingsForProduct(tempOrder, product) {
|
|
3718
3912
|
var _product$metadata5,
|
|
3719
3913
|
_product$metadata6,
|
|
3720
|
-
|
|
3914
|
+
_this26 = this;
|
|
3721
3915
|
var productUid = (product === null || product === void 0 || (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
3722
3916
|
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid);
|
|
3723
3917
|
if (!productUid && !bookingUid) return;
|
|
3724
3918
|
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
3725
3919
|
if (isFulfillmentTimingBooking(booking)) return true;
|
|
3726
|
-
var currentBookingUid =
|
|
3920
|
+
var currentBookingUid = _this26.getBookingUniqueIdentificationNumber(booking);
|
|
3727
3921
|
if (bookingUid && currentBookingUid === String(bookingUid)) return false;
|
|
3728
3922
|
if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
|
|
3729
3923
|
return true;
|
|
@@ -3769,24 +3963,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3769
3963
|
}, {
|
|
3770
3964
|
key: "recalculateSummary",
|
|
3771
3965
|
value: function () {
|
|
3772
|
-
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3966
|
+
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(options) {
|
|
3773
3967
|
var _this$otherParams3, _ref54, _salesSummaryResult$e;
|
|
3774
3968
|
var tempOrder, originalSnapshot, hasShopDiscountChanged, shouldReuseOriginalSnapshot, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummaryBase, emptySummaryWithDeposit, emptySummary, summaryMutationBaseline, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
|
|
3775
|
-
return _regeneratorRuntime().wrap(function
|
|
3776
|
-
while (1) switch (
|
|
3969
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context18) {
|
|
3970
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
3777
3971
|
case 0:
|
|
3778
3972
|
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
|
|
3779
|
-
|
|
3973
|
+
_context18.next = 2;
|
|
3780
3974
|
break;
|
|
3781
3975
|
}
|
|
3782
|
-
return
|
|
3976
|
+
return _context18.abrupt("return", null);
|
|
3783
3977
|
case 2:
|
|
3784
3978
|
tempOrder = options !== null && options !== void 0 && options.createIfMissing ? this.ensureTempOrder() : this.store.tempOrder;
|
|
3785
3979
|
if (tempOrder) {
|
|
3786
|
-
|
|
3980
|
+
_context18.next = 5;
|
|
3787
3981
|
break;
|
|
3788
3982
|
}
|
|
3789
|
-
return
|
|
3983
|
+
return _context18.abrupt("return", null);
|
|
3790
3984
|
case 5:
|
|
3791
3985
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3792
3986
|
originalSnapshot = this.getOriginalSalesSnapshot(tempOrder);
|
|
@@ -3794,10 +3988,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3794
3988
|
shouldReuseOriginalSnapshot = originalSnapshot && !hasShopDiscountChanged;
|
|
3795
3989
|
snapshotSummary = shouldReuseOriginalSnapshot ? this.restoreOriginalSnapshotIfProductsUnchanged(tempOrder, originalSnapshot) : null;
|
|
3796
3990
|
if (!snapshotSummary) {
|
|
3797
|
-
|
|
3991
|
+
_context18.next = 12;
|
|
3798
3992
|
break;
|
|
3799
3993
|
}
|
|
3800
|
-
return
|
|
3994
|
+
return _context18.abrupt("return", snapshotSummary);
|
|
3801
3995
|
case 12:
|
|
3802
3996
|
shouldFullRecalculateFromSnapshot = Boolean(originalSnapshot);
|
|
3803
3997
|
summaryProducts = shouldFullRecalculateFromSnapshot || options !== null && options !== void 0 && options.isCurrentOrder ? cloneDeep(tempOrder.products || []) : tempOrder.products;
|
|
@@ -3809,7 +4003,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3809
4003
|
totalRefundAmount = existedSummary.total_refund_amount || '0.00';
|
|
3810
4004
|
paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
|
|
3811
4005
|
if (salesSummary) {
|
|
3812
|
-
|
|
4006
|
+
_context18.next = 28;
|
|
3813
4007
|
break;
|
|
3814
4008
|
}
|
|
3815
4009
|
emptyBaseSummary = _objectSpread(_objectSpread(_objectSpread({}, createEmptySummary()), existedSummary), {}, {
|
|
@@ -3835,13 +4029,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3835
4029
|
previousSummary: existedSummary,
|
|
3836
4030
|
summary: emptySummary
|
|
3837
4031
|
});
|
|
3838
|
-
return
|
|
4032
|
+
return _context18.abrupt("return", this.store.summary);
|
|
3839
4033
|
case 28:
|
|
3840
4034
|
summaryMutationBaseline = options !== null && options !== void 0 && options.isCurrentOrder ? cloneDeep({
|
|
3841
4035
|
tempOrder: tempOrder,
|
|
3842
4036
|
summary: this.store.summary
|
|
3843
4037
|
}) : null;
|
|
3844
|
-
|
|
4038
|
+
_context18.next = 31;
|
|
3845
4039
|
return salesSummary.getSummary(_objectSpread({
|
|
3846
4040
|
products: summaryProducts,
|
|
3847
4041
|
isPriceIncludeTax: tempOrder.is_price_include_tax,
|
|
@@ -3851,21 +4045,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3851
4045
|
channel: this.otherParams.channel
|
|
3852
4046
|
} : {}));
|
|
3853
4047
|
case 31:
|
|
3854
|
-
salesSummaryResult =
|
|
4048
|
+
salesSummaryResult = _context18.sent;
|
|
3855
4049
|
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !options.isCurrentOrder())) {
|
|
3856
|
-
|
|
4050
|
+
_context18.next = 34;
|
|
3857
4051
|
break;
|
|
3858
4052
|
}
|
|
3859
|
-
return
|
|
4053
|
+
return _context18.abrupt("return", null);
|
|
3860
4054
|
case 34:
|
|
3861
4055
|
if (!(options !== null && options !== void 0 && options.isCurrentOrder && !isEqual({
|
|
3862
4056
|
tempOrder: tempOrder,
|
|
3863
4057
|
summary: this.store.summary
|
|
3864
4058
|
}, summaryMutationBaseline))) {
|
|
3865
|
-
|
|
4059
|
+
_context18.next = 36;
|
|
3866
4060
|
break;
|
|
3867
4061
|
}
|
|
3868
|
-
return
|
|
4062
|
+
return _context18.abrupt("return", null);
|
|
3869
4063
|
case 36:
|
|
3870
4064
|
if (shouldFullRecalculateFromSnapshot || options !== null && options !== void 0 && options.isCurrentOrder) {
|
|
3871
4065
|
tempOrder.products = summaryProducts;
|
|
@@ -3911,14 +4105,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3911
4105
|
previousSummary: existedSummary,
|
|
3912
4106
|
summary: summary
|
|
3913
4107
|
});
|
|
3914
|
-
return
|
|
4108
|
+
return _context18.abrupt("return", this.store.summary);
|
|
3915
4109
|
case 53:
|
|
3916
4110
|
case "end":
|
|
3917
|
-
return
|
|
4111
|
+
return _context18.stop();
|
|
3918
4112
|
}
|
|
3919
|
-
},
|
|
4113
|
+
}, _callee17, this);
|
|
3920
4114
|
}));
|
|
3921
|
-
function recalculateSummary(
|
|
4115
|
+
function recalculateSummary(_x16) {
|
|
3922
4116
|
return _recalculateSummary.apply(this, arguments);
|
|
3923
4117
|
}
|
|
3924
4118
|
return recalculateSummary;
|
|
@@ -3926,30 +4120,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3926
4120
|
}, {
|
|
3927
4121
|
key: "getOrderSummary",
|
|
3928
4122
|
value: function () {
|
|
3929
|
-
var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4123
|
+
var _getOrderSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
3930
4124
|
var summary;
|
|
3931
|
-
return _regeneratorRuntime().wrap(function
|
|
3932
|
-
while (1) switch (
|
|
4125
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context19) {
|
|
4126
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
3933
4127
|
case 0:
|
|
3934
|
-
|
|
4128
|
+
_context19.next = 2;
|
|
3935
4129
|
return this.recalculateSummary({
|
|
3936
4130
|
createIfMissing: true
|
|
3937
4131
|
});
|
|
3938
4132
|
case 2:
|
|
3939
|
-
summary =
|
|
4133
|
+
summary = _context19.sent;
|
|
3940
4134
|
if (summary) {
|
|
3941
|
-
|
|
4135
|
+
_context19.next = 5;
|
|
3942
4136
|
break;
|
|
3943
4137
|
}
|
|
3944
|
-
return
|
|
4138
|
+
return _context19.abrupt("return", createEmptySummary());
|
|
3945
4139
|
case 5:
|
|
3946
4140
|
this.persistTempOrder();
|
|
3947
|
-
return
|
|
4141
|
+
return _context19.abrupt("return", summary);
|
|
3948
4142
|
case 7:
|
|
3949
4143
|
case "end":
|
|
3950
|
-
return
|
|
4144
|
+
return _context19.stop();
|
|
3951
4145
|
}
|
|
3952
|
-
},
|
|
4146
|
+
}, _callee18, this);
|
|
3953
4147
|
}));
|
|
3954
4148
|
function getOrderSummary() {
|
|
3955
4149
|
return _getOrderSummary.apply(this, arguments);
|
|
@@ -3973,23 +4167,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3973
4167
|
}, {
|
|
3974
4168
|
key: "syncTempOrderNoteToRemote",
|
|
3975
4169
|
value: function () {
|
|
3976
|
-
var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3977
|
-
return _regeneratorRuntime().wrap(function
|
|
3978
|
-
while (1) switch (
|
|
4170
|
+
var _syncTempOrderNoteToRemote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(orderId, note) {
|
|
4171
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context20) {
|
|
4172
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
3979
4173
|
case 0:
|
|
3980
|
-
|
|
4174
|
+
_context20.next = 2;
|
|
3981
4175
|
return this.request.put("/order/order/".concat(orderId, "/note"), {
|
|
3982
4176
|
note: note
|
|
3983
4177
|
});
|
|
3984
4178
|
case 2:
|
|
3985
|
-
return
|
|
4179
|
+
return _context20.abrupt("return", note);
|
|
3986
4180
|
case 3:
|
|
3987
4181
|
case "end":
|
|
3988
|
-
return
|
|
4182
|
+
return _context20.stop();
|
|
3989
4183
|
}
|
|
3990
|
-
},
|
|
4184
|
+
}, _callee19, this);
|
|
3991
4185
|
}));
|
|
3992
|
-
function syncTempOrderNoteToRemote(
|
|
4186
|
+
function syncTempOrderNoteToRemote(_x17, _x18) {
|
|
3993
4187
|
return _syncTempOrderNoteToRemote.apply(this, arguments);
|
|
3994
4188
|
}
|
|
3995
4189
|
return syncTempOrderNoteToRemote;
|
|
@@ -4050,7 +4244,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4050
4244
|
}, {
|
|
4051
4245
|
key: "removeSalesNotesForMissingProductLines",
|
|
4052
4246
|
value: function removeSalesNotesForMissingProductLines(tempOrder) {
|
|
4053
|
-
var
|
|
4247
|
+
var _this27 = this;
|
|
4054
4248
|
var state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
4055
4249
|
if (!state.loaded || !Array.isArray(tempOrder.notes) || tempOrder.notes.length === 0) {
|
|
4056
4250
|
return;
|
|
@@ -4062,7 +4256,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4062
4256
|
return typeof uid === 'string' && uid.length > 0;
|
|
4063
4257
|
}));
|
|
4064
4258
|
var nextNotes = tempOrder.notes.filter(function (note) {
|
|
4065
|
-
var primary =
|
|
4259
|
+
var primary = _this27.getSalesNotePrimaryRelation(note);
|
|
4066
4260
|
if (!primary || primary.target_type !== 'order_detail') return true;
|
|
4067
4261
|
return remainingProductUids.has(primary.target_uuid);
|
|
4068
4262
|
});
|
|
@@ -4074,7 +4268,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4074
4268
|
key: "setSalesNoteOnTempOrder",
|
|
4075
4269
|
value: function setSalesNoteOnTempOrder(tempOrder, input) {
|
|
4076
4270
|
var _input$target,
|
|
4077
|
-
|
|
4271
|
+
_this28 = this,
|
|
4078
4272
|
_tempOrder$shop_order;
|
|
4079
4273
|
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
4080
4274
|
var note_type = String(input.note_type || '').trim();
|
|
@@ -4098,7 +4292,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4098
4292
|
var notes = tempOrder.notes || [];
|
|
4099
4293
|
// 当前 allergy policy 固定同一商品行只保留一条;业务调用方不参与去重规则。
|
|
4100
4294
|
var existingIndex = policy.uniquePerPrimaryTarget ? notes.findIndex(function (note) {
|
|
4101
|
-
var primary =
|
|
4295
|
+
var primary = _this28.getSalesNotePrimaryRelation(note);
|
|
4102
4296
|
return note.note_type === note_type && (primary === null || primary === void 0 ? void 0 : primary.target_type) === 'order_detail' && primary.target_uuid === target_uuid;
|
|
4103
4297
|
}) : -1;
|
|
4104
4298
|
var existing = existingIndex >= 0 ? notes[existingIndex] : null;
|
|
@@ -4190,22 +4384,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4190
4384
|
}, {
|
|
4191
4385
|
key: "setSalesNote",
|
|
4192
4386
|
value: function () {
|
|
4193
|
-
var _setSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4387
|
+
var _setSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(input) {
|
|
4194
4388
|
var tempOrder, note;
|
|
4195
|
-
return _regeneratorRuntime().wrap(function
|
|
4196
|
-
while (1) switch (
|
|
4389
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context21) {
|
|
4390
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
4197
4391
|
case 0:
|
|
4198
4392
|
tempOrder = this.ensureTempOrder();
|
|
4199
4393
|
note = this.setSalesNoteOnTempOrder(tempOrder, input);
|
|
4200
4394
|
this.notifyTempOrderChanged();
|
|
4201
|
-
return
|
|
4395
|
+
return _context21.abrupt("return", cloneDeep(note));
|
|
4202
4396
|
case 4:
|
|
4203
4397
|
case "end":
|
|
4204
|
-
return
|
|
4398
|
+
return _context21.stop();
|
|
4205
4399
|
}
|
|
4206
|
-
},
|
|
4400
|
+
}, _callee20, this);
|
|
4207
4401
|
}));
|
|
4208
|
-
function setSalesNote(
|
|
4402
|
+
function setSalesNote(_x19) {
|
|
4209
4403
|
return _setSalesNote.apply(this, arguments);
|
|
4210
4404
|
}
|
|
4211
4405
|
return setSalesNote;
|
|
@@ -4213,10 +4407,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4213
4407
|
}, {
|
|
4214
4408
|
key: "removeSalesNote",
|
|
4215
4409
|
value: function () {
|
|
4216
|
-
var _removeSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4410
|
+
var _removeSalesNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(uuid) {
|
|
4217
4411
|
var tempOrder, normalizedUuid, notes, nextNotes, state;
|
|
4218
|
-
return _regeneratorRuntime().wrap(function
|
|
4219
|
-
while (1) switch (
|
|
4412
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context22) {
|
|
4413
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
4220
4414
|
case 0:
|
|
4221
4415
|
tempOrder = this.ensureTempOrder();
|
|
4222
4416
|
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
@@ -4226,10 +4420,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4226
4420
|
return note.uuid !== normalizedUuid;
|
|
4227
4421
|
});
|
|
4228
4422
|
if (!(nextNotes.length === notes.length)) {
|
|
4229
|
-
|
|
4423
|
+
_context22.next = 7;
|
|
4230
4424
|
break;
|
|
4231
4425
|
}
|
|
4232
|
-
return
|
|
4426
|
+
return _context22.abrupt("return");
|
|
4233
4427
|
case 7:
|
|
4234
4428
|
tempOrder.notes = nextNotes;
|
|
4235
4429
|
state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
@@ -4237,11 +4431,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4237
4431
|
this.notifyTempOrderChanged();
|
|
4238
4432
|
case 11:
|
|
4239
4433
|
case "end":
|
|
4240
|
-
return
|
|
4434
|
+
return _context22.stop();
|
|
4241
4435
|
}
|
|
4242
|
-
},
|
|
4436
|
+
}, _callee21, this);
|
|
4243
4437
|
}));
|
|
4244
|
-
function removeSalesNote(
|
|
4438
|
+
function removeSalesNote(_x20) {
|
|
4245
4439
|
return _removeSalesNote.apply(this, arguments);
|
|
4246
4440
|
}
|
|
4247
4441
|
return removeSalesNote;
|
|
@@ -4249,10 +4443,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4249
4443
|
}, {
|
|
4250
4444
|
key: "clearSalesNotes",
|
|
4251
4445
|
value: function () {
|
|
4252
|
-
var _clearSalesNotes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4446
|
+
var _clearSalesNotes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
|
4253
4447
|
var tempOrder, state;
|
|
4254
|
-
return _regeneratorRuntime().wrap(function
|
|
4255
|
-
while (1) switch (
|
|
4448
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context23) {
|
|
4449
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
4256
4450
|
case 0:
|
|
4257
4451
|
tempOrder = this.ensureTempOrder();
|
|
4258
4452
|
tempOrder.notes = [];
|
|
@@ -4262,9 +4456,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4262
4456
|
this.notifyTempOrderChanged();
|
|
4263
4457
|
case 6:
|
|
4264
4458
|
case "end":
|
|
4265
|
-
return
|
|
4459
|
+
return _context23.stop();
|
|
4266
4460
|
}
|
|
4267
|
-
},
|
|
4461
|
+
}, _callee22, this);
|
|
4268
4462
|
}));
|
|
4269
4463
|
function clearSalesNotes() {
|
|
4270
4464
|
return _clearSalesNotes.apply(this, arguments);
|
|
@@ -4417,15 +4611,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4417
4611
|
}, {
|
|
4418
4612
|
key: "productHasCustomerBoundDiscount",
|
|
4419
4613
|
value: function productHasCustomerBoundDiscount(product) {
|
|
4420
|
-
var
|
|
4614
|
+
var _this29 = this;
|
|
4421
4615
|
if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
|
|
4422
|
-
return
|
|
4616
|
+
return _this29.isCustomerBoundDiscount(discount);
|
|
4423
4617
|
})) {
|
|
4424
4618
|
return true;
|
|
4425
4619
|
}
|
|
4426
4620
|
return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
|
|
4427
4621
|
return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
|
|
4428
|
-
return
|
|
4622
|
+
return _this29.isCustomerBoundDiscount(discount);
|
|
4429
4623
|
});
|
|
4430
4624
|
});
|
|
4431
4625
|
}
|
|
@@ -4434,18 +4628,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4434
4628
|
value: function shouldSkipDiscountCalculation(tempOrder) {
|
|
4435
4629
|
var _this$store$discount20,
|
|
4436
4630
|
_this$store$discount21,
|
|
4437
|
-
|
|
4631
|
+
_this30 = this;
|
|
4438
4632
|
if (this.hasActiveCustomerBoundDiscount) return false;
|
|
4439
4633
|
var discountList = ((_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 || (_this$store$discount21 = _this$store$discount20.getDiscountList) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.call(_this$store$discount20)) || [];
|
|
4440
4634
|
if (discountList.length > 0) return false;
|
|
4441
4635
|
return !(tempOrder.products || []).some(function (product) {
|
|
4442
|
-
return
|
|
4636
|
+
return _this30.productHasCustomerBoundDiscount(product);
|
|
4443
4637
|
});
|
|
4444
4638
|
}
|
|
4445
4639
|
}, {
|
|
4446
4640
|
key: "clearCustomerBoundDiscounts",
|
|
4447
4641
|
value: function clearCustomerBoundDiscounts(tempOrder) {
|
|
4448
|
-
var
|
|
4642
|
+
var _this31 = this,
|
|
4449
4643
|
_discountModule$getDi,
|
|
4450
4644
|
_discountModule$getOr,
|
|
4451
4645
|
_discountModule$setDi,
|
|
@@ -4454,7 +4648,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4454
4648
|
var filterDiscountList = function filterDiscountList(discountList) {
|
|
4455
4649
|
if (!Array.isArray(discountList)) return [];
|
|
4456
4650
|
return discountList.filter(function (discount) {
|
|
4457
|
-
var shouldRemove =
|
|
4651
|
+
var shouldRemove = _this31.isCustomerBoundDiscount(discount);
|
|
4458
4652
|
if (shouldRemove) didRemoveCustomerBoundDiscount = true;
|
|
4459
4653
|
return !shouldRemove;
|
|
4460
4654
|
});
|
|
@@ -4481,12 +4675,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4481
4675
|
var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
|
|
4482
4676
|
var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
|
|
4483
4677
|
var nextDiscounts = currentDiscounts.filter(function (discount) {
|
|
4484
|
-
if (
|
|
4485
|
-
return !
|
|
4678
|
+
if (_this31.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
4679
|
+
return !_this31.isCustomerBoundDiscount(discount);
|
|
4486
4680
|
});
|
|
4487
4681
|
var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
|
|
4488
|
-
if (
|
|
4489
|
-
return !
|
|
4682
|
+
if (_this31.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
4683
|
+
return !_this31.isCustomerBoundDiscount(discount);
|
|
4490
4684
|
});
|
|
4491
4685
|
void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
|
|
4492
4686
|
void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
|
|
@@ -4653,10 +4847,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4653
4847
|
}, {
|
|
4654
4848
|
key: "setOrderPayments",
|
|
4655
4849
|
value: function setOrderPayments(payments) {
|
|
4656
|
-
var
|
|
4850
|
+
var _this32 = this;
|
|
4657
4851
|
var tempOrder = this.ensureTempOrder();
|
|
4658
4852
|
tempOrder.payments = mapPaymentItemsToOrderPayments((payments || []).map(function (payment) {
|
|
4659
|
-
return
|
|
4853
|
+
return _this32.normalizePaymentSource(payment, {
|
|
4660
4854
|
defaultPaid: false
|
|
4661
4855
|
});
|
|
4662
4856
|
}));
|
|
@@ -4676,34 +4870,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4676
4870
|
}, {
|
|
4677
4871
|
key: "addOrderPaymentAsync",
|
|
4678
4872
|
value: (function () {
|
|
4679
|
-
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4873
|
+
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(payment) {
|
|
4680
4874
|
var hasPaymentNumber, devicePrefix;
|
|
4681
|
-
return _regeneratorRuntime().wrap(function
|
|
4682
|
-
while (1) switch (
|
|
4875
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context24) {
|
|
4876
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
4683
4877
|
case 0:
|
|
4684
4878
|
hasPaymentNumber = String(payment.payment_number || '').trim() !== '';
|
|
4685
4879
|
if (!hasPaymentNumber) {
|
|
4686
|
-
|
|
4880
|
+
_context24.next = 5;
|
|
4687
4881
|
break;
|
|
4688
4882
|
}
|
|
4689
|
-
|
|
4690
|
-
|
|
4883
|
+
_context24.t0 = 'LOCAL';
|
|
4884
|
+
_context24.next = 8;
|
|
4691
4885
|
break;
|
|
4692
4886
|
case 5:
|
|
4693
|
-
|
|
4887
|
+
_context24.next = 7;
|
|
4694
4888
|
return this.getPaymentNumberDevicePrefixAsync();
|
|
4695
4889
|
case 7:
|
|
4696
|
-
|
|
4890
|
+
_context24.t0 = _context24.sent;
|
|
4697
4891
|
case 8:
|
|
4698
|
-
devicePrefix =
|
|
4699
|
-
return
|
|
4892
|
+
devicePrefix = _context24.t0;
|
|
4893
|
+
return _context24.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
|
|
4700
4894
|
case 10:
|
|
4701
4895
|
case "end":
|
|
4702
|
-
return
|
|
4896
|
+
return _context24.stop();
|
|
4703
4897
|
}
|
|
4704
|
-
},
|
|
4898
|
+
}, _callee23, this);
|
|
4705
4899
|
}));
|
|
4706
|
-
function addOrderPaymentAsync(
|
|
4900
|
+
function addOrderPaymentAsync(_x21) {
|
|
4707
4901
|
return _addOrderPaymentAsync.apply(this, arguments);
|
|
4708
4902
|
}
|
|
4709
4903
|
return addOrderPaymentAsync;
|
|
@@ -4711,7 +4905,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4711
4905
|
}, {
|
|
4712
4906
|
key: "addOrderPaymentWithDevicePrefix",
|
|
4713
4907
|
value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
|
|
4714
|
-
var
|
|
4908
|
+
var _this33 = this;
|
|
4715
4909
|
this.logInfo('addOrderPayment', {
|
|
4716
4910
|
payment: payment
|
|
4717
4911
|
});
|
|
@@ -4729,7 +4923,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4729
4923
|
void this.recalculateSummary({
|
|
4730
4924
|
createIfMissing: true
|
|
4731
4925
|
}).catch(function (error) {
|
|
4732
|
-
|
|
4926
|
+
_this33.logError('recalculate summary after addOrderPayment failed', {
|
|
4733
4927
|
error: error instanceof Error ? error.message : String(error)
|
|
4734
4928
|
});
|
|
4735
4929
|
});
|
|
@@ -4743,7 +4937,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4743
4937
|
}, {
|
|
4744
4938
|
key: "updateOrderPayment",
|
|
4745
4939
|
value: (function () {
|
|
4746
|
-
var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4940
|
+
var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(paymentIdentity, updates) {
|
|
4747
4941
|
var options,
|
|
4748
4942
|
tempOrder,
|
|
4749
4943
|
identity,
|
|
@@ -4754,17 +4948,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4754
4948
|
updatedPayment,
|
|
4755
4949
|
summary,
|
|
4756
4950
|
payments,
|
|
4757
|
-
|
|
4758
|
-
return _regeneratorRuntime().wrap(function
|
|
4759
|
-
while (1) switch (
|
|
4951
|
+
_args25 = arguments;
|
|
4952
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context25) {
|
|
4953
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
4760
4954
|
case 0:
|
|
4761
|
-
options =
|
|
4955
|
+
options = _args25.length > 2 && _args25[2] !== undefined ? _args25[2] : {};
|
|
4762
4956
|
tempOrder = this.ensureTempOrder();
|
|
4763
4957
|
identity = String(paymentIdentity);
|
|
4764
4958
|
matchMode = options.matchBy === 'compat' || options.matchBy === 'legacy' ? 'compat' : 'payment_number';
|
|
4765
4959
|
matchedPayment = resolveOrderPaymentIdentity(tempOrder.payments || [], identity, matchMode);
|
|
4766
4960
|
if (matchedPayment) {
|
|
4767
|
-
|
|
4961
|
+
_context25.next = 8;
|
|
4768
4962
|
break;
|
|
4769
4963
|
}
|
|
4770
4964
|
try {
|
|
@@ -4793,15 +4987,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4793
4987
|
return nextPayment;
|
|
4794
4988
|
});
|
|
4795
4989
|
this.persistTempOrder();
|
|
4796
|
-
|
|
4990
|
+
_context25.next = 13;
|
|
4797
4991
|
return this.recalculateSummary({
|
|
4798
4992
|
createIfMissing: true
|
|
4799
4993
|
});
|
|
4800
4994
|
case 13:
|
|
4801
|
-
summary =
|
|
4995
|
+
summary = _context25.sent;
|
|
4802
4996
|
this.persistTempOrder();
|
|
4803
4997
|
payments = tempOrder.payments;
|
|
4804
|
-
return
|
|
4998
|
+
return _context25.abrupt("return", {
|
|
4805
4999
|
updated: true,
|
|
4806
5000
|
payment: payments[matchedPayment.index] || updatedPayment,
|
|
4807
5001
|
payments: payments,
|
|
@@ -4809,11 +5003,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4809
5003
|
});
|
|
4810
5004
|
case 17:
|
|
4811
5005
|
case "end":
|
|
4812
|
-
return
|
|
5006
|
+
return _context25.stop();
|
|
4813
5007
|
}
|
|
4814
|
-
},
|
|
5008
|
+
}, _callee24, this);
|
|
4815
5009
|
}));
|
|
4816
|
-
function updateOrderPayment(
|
|
5010
|
+
function updateOrderPayment(_x22, _x23) {
|
|
4817
5011
|
return _updateOrderPayment.apply(this, arguments);
|
|
4818
5012
|
}
|
|
4819
5013
|
return updateOrderPayment;
|
|
@@ -4858,7 +5052,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4858
5052
|
}, {
|
|
4859
5053
|
key: "applyPaymentLifecycleChange",
|
|
4860
5054
|
value: function applyPaymentLifecycleChange(tempOrder, options) {
|
|
4861
|
-
var
|
|
5055
|
+
var _this34 = this;
|
|
4862
5056
|
this.updateTempOrderPaymentStatus(tempOrder);
|
|
4863
5057
|
if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
|
|
4864
5058
|
this.persistTempOrder();
|
|
@@ -4868,7 +5062,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4868
5062
|
void this.recalculateSummary({
|
|
4869
5063
|
createIfMissing: true
|
|
4870
5064
|
}).catch(function (error) {
|
|
4871
|
-
|
|
5065
|
+
_this34.logError("recalculate summary after ".concat(logContext, " failed"), {
|
|
4872
5066
|
error: error instanceof Error ? error.message : String(error)
|
|
4873
5067
|
});
|
|
4874
5068
|
});
|
|
@@ -4912,7 +5106,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4912
5106
|
}, {
|
|
4913
5107
|
key: "updateVoucherOrderPayments",
|
|
4914
5108
|
value: function updateVoucherOrderPayments(payments, options) {
|
|
4915
|
-
var
|
|
5109
|
+
var _this35 = this;
|
|
4916
5110
|
var tempOrder = this.ensureTempOrder();
|
|
4917
5111
|
var isOrderPaymentType = function isOrderPaymentType(value) {
|
|
4918
5112
|
return value === 'normal' || value === 'deposit';
|
|
@@ -4947,7 +5141,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4947
5141
|
});
|
|
4948
5142
|
};
|
|
4949
5143
|
var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
|
|
4950
|
-
return
|
|
5144
|
+
return _this35.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
|
|
4951
5145
|
defaultPaid: false,
|
|
4952
5146
|
devicePrefix: options === null || options === void 0 ? void 0 : options.devicePrefix
|
|
4953
5147
|
});
|
|
@@ -5000,7 +5194,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5000
5194
|
void this.recalculateSummary({
|
|
5001
5195
|
createIfMissing: true
|
|
5002
5196
|
}).catch(function (error) {
|
|
5003
|
-
|
|
5197
|
+
_this35.logError('recalculate summary after updateVoucherOrderPayments failed', {
|
|
5004
5198
|
error: error instanceof Error ? error.message : String(error)
|
|
5005
5199
|
});
|
|
5006
5200
|
});
|
|
@@ -5009,38 +5203,38 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5009
5203
|
}, {
|
|
5010
5204
|
key: "updateVoucherOrderPaymentsAsync",
|
|
5011
5205
|
value: function () {
|
|
5012
|
-
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5206
|
+
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(payments, options) {
|
|
5013
5207
|
var needsPaymentNumber, devicePrefix;
|
|
5014
|
-
return _regeneratorRuntime().wrap(function
|
|
5015
|
-
while (1) switch (
|
|
5208
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context26) {
|
|
5209
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
5016
5210
|
case 0:
|
|
5017
5211
|
needsPaymentNumber = (payments || []).some(function (payment) {
|
|
5018
5212
|
return String(payment.payment_number || '').trim() === '';
|
|
5019
5213
|
});
|
|
5020
5214
|
if (!needsPaymentNumber) {
|
|
5021
|
-
|
|
5215
|
+
_context26.next = 7;
|
|
5022
5216
|
break;
|
|
5023
5217
|
}
|
|
5024
|
-
|
|
5218
|
+
_context26.next = 4;
|
|
5025
5219
|
return this.getPaymentNumberDevicePrefixAsync();
|
|
5026
5220
|
case 4:
|
|
5027
|
-
|
|
5028
|
-
|
|
5221
|
+
_context26.t0 = _context26.sent;
|
|
5222
|
+
_context26.next = 8;
|
|
5029
5223
|
break;
|
|
5030
5224
|
case 7:
|
|
5031
|
-
|
|
5225
|
+
_context26.t0 = 'LOCAL';
|
|
5032
5226
|
case 8:
|
|
5033
|
-
devicePrefix =
|
|
5034
|
-
return
|
|
5227
|
+
devicePrefix = _context26.t0;
|
|
5228
|
+
return _context26.abrupt("return", this.updateVoucherOrderPayments(payments, _objectSpread(_objectSpread({}, options), {}, {
|
|
5035
5229
|
devicePrefix: devicePrefix
|
|
5036
5230
|
})));
|
|
5037
5231
|
case 10:
|
|
5038
5232
|
case "end":
|
|
5039
|
-
return
|
|
5233
|
+
return _context26.stop();
|
|
5040
5234
|
}
|
|
5041
|
-
},
|
|
5235
|
+
}, _callee25, this);
|
|
5042
5236
|
}));
|
|
5043
|
-
function updateVoucherOrderPaymentsAsync(
|
|
5237
|
+
function updateVoucherOrderPaymentsAsync(_x24, _x25) {
|
|
5044
5238
|
return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
|
|
5045
5239
|
}
|
|
5046
5240
|
return updateVoucherOrderPaymentsAsync;
|
|
@@ -5058,7 +5252,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5058
5252
|
key: "shouldMergeProductToOrder",
|
|
5059
5253
|
value: function shouldMergeProductToOrder(params) {
|
|
5060
5254
|
var _this$orderHooks5,
|
|
5061
|
-
|
|
5255
|
+
_this36 = this;
|
|
5062
5256
|
var onBeforeMergeProductToOrder = (_this$orderHooks5 = this.orderHooks) === null || _this$orderHooks5 === void 0 ? void 0 : _this$orderHooks5.onBeforeMergeProductToOrder;
|
|
5063
5257
|
if (!onBeforeMergeProductToOrder) return true;
|
|
5064
5258
|
var result = onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
@@ -5066,7 +5260,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5066
5260
|
}));
|
|
5067
5261
|
if (result && _typeof(result) === 'object' && typeof result.then === 'function') {
|
|
5068
5262
|
return Promise.resolve(result).then(function (resolved) {
|
|
5069
|
-
return
|
|
5263
|
+
return _this36.normalizeShouldMergeProductResult(resolved);
|
|
5070
5264
|
});
|
|
5071
5265
|
}
|
|
5072
5266
|
return this.normalizeShouldMergeProductResult(result);
|
|
@@ -5195,83 +5389,83 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5195
5389
|
}, {
|
|
5196
5390
|
key: "finalizeProductOrderMutation",
|
|
5197
5391
|
value: function () {
|
|
5198
|
-
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5392
|
+
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(tempOrder, options) {
|
|
5199
5393
|
var isCurrentOrder, isVirtualSettlement, promotionPayload, summary;
|
|
5200
|
-
return _regeneratorRuntime().wrap(function
|
|
5201
|
-
while (1) switch (
|
|
5202
|
-
case 0:
|
|
5394
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context27) {
|
|
5395
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
5396
|
+
case 0:
|
|
5203
5397
|
isCurrentOrder = options === null || options === void 0 ? void 0 : options.isCurrentOrder;
|
|
5204
5398
|
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
5205
|
-
|
|
5399
|
+
_context27.next = 3;
|
|
5206
5400
|
break;
|
|
5207
5401
|
}
|
|
5208
|
-
return
|
|
5402
|
+
return _context27.abrupt("return");
|
|
5209
5403
|
case 3:
|
|
5210
5404
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
5211
5405
|
this.prepareVirtualSettlementTempOrder(tempOrder);
|
|
5212
5406
|
isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
|
|
5213
5407
|
if (!(!(options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) && !isVirtualSettlement)) {
|
|
5214
|
-
|
|
5408
|
+
_context27.next = 9;
|
|
5215
5409
|
break;
|
|
5216
5410
|
}
|
|
5217
|
-
|
|
5411
|
+
_context27.next = 9;
|
|
5218
5412
|
return this.ensureEditDiscountConfigForProductChange(tempOrder);
|
|
5219
5413
|
case 9:
|
|
5220
5414
|
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
5221
|
-
|
|
5415
|
+
_context27.next = 11;
|
|
5222
5416
|
break;
|
|
5223
5417
|
}
|
|
5224
|
-
return
|
|
5418
|
+
return _context27.abrupt("return");
|
|
5225
5419
|
case 11:
|
|
5226
5420
|
if (!(!(options !== null && options !== void 0 && options.skipDiscountRecalculation) && !isVirtualSettlement)) {
|
|
5227
|
-
|
|
5421
|
+
_context27.next = 17;
|
|
5228
5422
|
break;
|
|
5229
5423
|
}
|
|
5230
|
-
|
|
5424
|
+
_context27.next = 14;
|
|
5231
5425
|
return this.evaluatePromotion(isCurrentOrder ? {
|
|
5232
5426
|
isCurrentOrder: isCurrentOrder
|
|
5233
5427
|
} : undefined);
|
|
5234
5428
|
case 14:
|
|
5235
|
-
|
|
5236
|
-
|
|
5429
|
+
_context27.t0 = _context27.sent;
|
|
5430
|
+
_context27.next = 18;
|
|
5237
5431
|
break;
|
|
5238
5432
|
case 17:
|
|
5239
|
-
|
|
5433
|
+
_context27.t0 = null;
|
|
5240
5434
|
case 18:
|
|
5241
|
-
promotionPayload =
|
|
5435
|
+
promotionPayload = _context27.t0;
|
|
5242
5436
|
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
5243
|
-
|
|
5437
|
+
_context27.next = 21;
|
|
5244
5438
|
break;
|
|
5245
5439
|
}
|
|
5246
|
-
return
|
|
5440
|
+
return _context27.abrupt("return");
|
|
5247
5441
|
case 21:
|
|
5248
5442
|
if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation) && !isVirtualSettlement) {
|
|
5249
5443
|
this.applyDiscount();
|
|
5250
5444
|
}
|
|
5251
5445
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
5252
|
-
|
|
5446
|
+
_context27.next = 25;
|
|
5253
5447
|
return this.recalculateSummary(_objectSpread({
|
|
5254
5448
|
createIfMissing: true
|
|
5255
5449
|
}, isCurrentOrder ? {
|
|
5256
5450
|
isCurrentOrder: isCurrentOrder
|
|
5257
5451
|
} : {}));
|
|
5258
5452
|
case 25:
|
|
5259
|
-
summary =
|
|
5453
|
+
summary = _context27.sent;
|
|
5260
5454
|
if (!(isCurrentOrder && (!isCurrentOrder() || !summary))) {
|
|
5261
|
-
|
|
5455
|
+
_context27.next = 28;
|
|
5262
5456
|
break;
|
|
5263
5457
|
}
|
|
5264
|
-
return
|
|
5458
|
+
return _context27.abrupt("return");
|
|
5265
5459
|
case 28:
|
|
5266
5460
|
this.persistTempOrder();
|
|
5267
5461
|
this.emitPromotionApplied(promotionPayload);
|
|
5268
5462
|
case 30:
|
|
5269
5463
|
case "end":
|
|
5270
|
-
return
|
|
5464
|
+
return _context27.stop();
|
|
5271
5465
|
}
|
|
5272
|
-
},
|
|
5466
|
+
}, _callee26, this);
|
|
5273
5467
|
}));
|
|
5274
|
-
function finalizeProductOrderMutation(
|
|
5468
|
+
function finalizeProductOrderMutation(_x26, _x27) {
|
|
5275
5469
|
return _finalizeProductOrderMutation.apply(this, arguments);
|
|
5276
5470
|
}
|
|
5277
5471
|
return finalizeProductOrderMutation;
|
|
@@ -5298,7 +5492,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5298
5492
|
_productToAdd$_extend,
|
|
5299
5493
|
_productToAdd$metadat,
|
|
5300
5494
|
_origin,
|
|
5301
|
-
|
|
5495
|
+
_this37 = this;
|
|
5302
5496
|
var linked = booking ? this.createLinkedProductAndBooking({
|
|
5303
5497
|
product: product,
|
|
5304
5498
|
booking: booking
|
|
@@ -5337,27 +5531,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5337
5531
|
var matchedIndex = shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
5338
5532
|
var _item$metadata4;
|
|
5339
5533
|
if (productVoucherGroupKey(tempOrder, item) !== productToAdd._productVoucherGroupKey) return false;
|
|
5340
|
-
if (
|
|
5534
|
+
if (_this37.hasGoodPassDiscount(item)) return false;
|
|
5341
5535
|
if (getProductHolderRelations(tempOrder, item).length > 0 || hasAssignedHolderId((_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.holder_id)) return false;
|
|
5342
|
-
var isRuntimeEntitlementPass =
|
|
5536
|
+
var isRuntimeEntitlementPass = _this37.isRuntimeEntitlementAppend(item, tempOrder);
|
|
5343
5537
|
if (isIncomingEntitlementAppend !== isRuntimeEntitlementPass) {
|
|
5344
5538
|
return false;
|
|
5345
5539
|
}
|
|
5346
|
-
if (isIncomingEntitlementAppend &&
|
|
5540
|
+
if (isIncomingEntitlementAppend && _this37.isPersistedProductLine(item)) {
|
|
5347
5541
|
return false;
|
|
5348
5542
|
}
|
|
5349
|
-
var hasExistingProductNote =
|
|
5543
|
+
var hasExistingProductNote = _this37.hasOrderProductLineNote(item);
|
|
5350
5544
|
if ((hasIncomingProductNote || hasExistingProductNote) && (!isRuntimeEntitlementPass || String(normalizedIncoming.note || '').trim() !== String(item.note || '').trim())) {
|
|
5351
5545
|
return false;
|
|
5352
5546
|
}
|
|
5353
5547
|
var hasExistingManualProductDiscount = isManualProductDiscountProduct(item);
|
|
5354
|
-
if (isRuntimeEntitlementPass && !
|
|
5548
|
+
if (isRuntimeEntitlementPass && !_this37.hasSameEntitlementMergePriceConfig(normalizedIncoming, item)) {
|
|
5355
5549
|
return false;
|
|
5356
5550
|
}
|
|
5357
5551
|
if ((hasIncomingManualProductDiscount || hasExistingManualProductDiscount) && !isRuntimeEntitlementPass) {
|
|
5358
5552
|
return false;
|
|
5359
5553
|
}
|
|
5360
|
-
if (
|
|
5554
|
+
if (_this37.isPersistedProductLine(item)) return false;
|
|
5361
5555
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
5362
5556
|
if (item.product_variant_id !== productToAdd.product_variant_id) return false;
|
|
5363
5557
|
var existedFingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
|
|
@@ -5368,10 +5562,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5368
5562
|
var commitProductLine = function commitProductLine(shouldMerge) {
|
|
5369
5563
|
var _options$beforeCommit2;
|
|
5370
5564
|
options === null || options === void 0 || (_options$beforeCommit2 = options.beforeCommit) === null || _options$beforeCommit2 === void 0 || _options$beforeCommit2.call(options);
|
|
5371
|
-
|
|
5565
|
+
_this37.assertAndLockProductSettlement(tempOrder, productToAdd);
|
|
5372
5566
|
var committedProduct;
|
|
5373
5567
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
5374
|
-
|
|
5568
|
+
_this37.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
5375
5569
|
if (linked) {
|
|
5376
5570
|
normalizedIncoming.booking_uid = linked.bookingUid;
|
|
5377
5571
|
normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, {
|
|
@@ -5389,7 +5583,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5389
5583
|
var _targetProduct$metada;
|
|
5390
5584
|
var targetProduct = matchedProduct;
|
|
5391
5585
|
var targetUid = (_targetProduct$metada = targetProduct.metadata) === null || _targetProduct$metada === void 0 ? void 0 : _targetProduct$metada.unique_identification_number;
|
|
5392
|
-
var normalizedProduct =
|
|
5586
|
+
var normalizedProduct = _this37.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
|
|
5393
5587
|
metadata: _objectSpread(_objectSpread({}, productToAdd.metadata || {}), {}, {
|
|
5394
5588
|
unique_identification_number: targetUid
|
|
5395
5589
|
})
|
|
@@ -5412,7 +5606,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5412
5606
|
order_detail_id: targetProduct.order_detail_id,
|
|
5413
5607
|
num: nextNum
|
|
5414
5608
|
});
|
|
5415
|
-
|
|
5609
|
+
_this37.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
|
|
5416
5610
|
committedProduct = tempOrder.products[matchedIndex];
|
|
5417
5611
|
if (matchedIndex !== tempOrder.products.length - 1) {
|
|
5418
5612
|
var mergedProduct = tempOrder.products[matchedIndex];
|
|
@@ -5522,21 +5716,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5522
5716
|
}, {
|
|
5523
5717
|
key: "addProductToOrder",
|
|
5524
5718
|
value: (function () {
|
|
5525
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5526
|
-
var
|
|
5527
|
-
return _regeneratorRuntime().wrap(function
|
|
5528
|
-
while (1) switch (
|
|
5719
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(product, booking, options) {
|
|
5720
|
+
var _this38 = this;
|
|
5721
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context28) {
|
|
5722
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
5529
5723
|
case 0:
|
|
5530
|
-
return
|
|
5531
|
-
return
|
|
5724
|
+
return _context28.abrupt("return", this.queueCartCommand(function () {
|
|
5725
|
+
return _this38.addProductToOrderDraft(product, booking, options);
|
|
5532
5726
|
}));
|
|
5533
5727
|
case 1:
|
|
5534
5728
|
case "end":
|
|
5535
|
-
return
|
|
5729
|
+
return _context28.stop();
|
|
5536
5730
|
}
|
|
5537
|
-
},
|
|
5731
|
+
}, _callee27, this);
|
|
5538
5732
|
}));
|
|
5539
|
-
function addProductToOrder(
|
|
5733
|
+
function addProductToOrder(_x28, _x29, _x30) {
|
|
5540
5734
|
return _addProductToOrder.apply(this, arguments);
|
|
5541
5735
|
}
|
|
5542
5736
|
return addProductToOrder;
|
|
@@ -5544,11 +5738,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5544
5738
|
}, {
|
|
5545
5739
|
key: "addProductToOrderDraft",
|
|
5546
5740
|
value: function () {
|
|
5547
|
-
var _addProductToOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5548
|
-
var
|
|
5741
|
+
var _addProductToOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(product, booking, options) {
|
|
5742
|
+
var _this39 = this;
|
|
5549
5743
|
var availabilityCommitGuard, liveTempOrder, beforeCommit, mutation, tempOrder, beforeAppend, guardedMutationFields, readGuardedMutationFields, guardedMutationBaseline, beforePublish, _tempOrder$_extend10, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref72, _productRecord$num, productRecord, splitCount, i, splitLine, committedProduct, _committedProduct, _committedProduct2, committedIdentity, isCurrentOrder;
|
|
5550
|
-
return _regeneratorRuntime().wrap(function
|
|
5551
|
-
while (1) switch (
|
|
5744
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context29) {
|
|
5745
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
5552
5746
|
case 0:
|
|
5553
5747
|
availabilityCommitGuard = options === null || options === void 0 ? void 0 : options.availabilityCommitGuard;
|
|
5554
5748
|
availabilityCommitGuard === null || availabilityCommitGuard === void 0 || availabilityCommitGuard();
|
|
@@ -5575,13 +5769,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5575
5769
|
}
|
|
5576
5770
|
};
|
|
5577
5771
|
if (!(options !== null && options !== void 0 && options.productVoucherGroupKey)) {
|
|
5578
|
-
|
|
5772
|
+
_context29.next = 15;
|
|
5579
5773
|
break;
|
|
5580
5774
|
}
|
|
5581
5775
|
if ((_tempOrder$_extend10 = tempOrder._extend) !== null && _tempOrder$_extend10 !== void 0 && (_tempOrder$_extend10 = _tempOrder$_extend10.productVoucherGroups) !== null && _tempOrder$_extend10 !== void 0 && _tempOrder$_extend10.some(function (group) {
|
|
5582
5776
|
return group.key === options.productVoucherGroupKey;
|
|
5583
5777
|
})) {
|
|
5584
|
-
|
|
5778
|
+
_context29.next = 14;
|
|
5585
5779
|
break;
|
|
5586
5780
|
}
|
|
5587
5781
|
throw voucherGroupError();
|
|
@@ -5614,7 +5808,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5614
5808
|
throw new Error('[Order Notes] 商品行缺少 unique_identification_number');
|
|
5615
5809
|
}
|
|
5616
5810
|
salesNoteDrafts.forEach(function (draft) {
|
|
5617
|
-
|
|
5811
|
+
_this39.setSalesNoteOnTempOrder(tempOrder, {
|
|
5618
5812
|
note_type: draft.note_type,
|
|
5619
5813
|
target: {
|
|
5620
5814
|
target_type: 'order_detail',
|
|
@@ -5639,21 +5833,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5639
5833
|
return uid !== undefined && uid !== null && String(uid) === String(insertAfterProductUid);
|
|
5640
5834
|
}) : -1;
|
|
5641
5835
|
insertAtIndex = options !== null && options !== void 0 && options.insertAtStart ? 0 : anchorIndex >= 0 ? anchorIndex + 1 : undefined;
|
|
5642
|
-
|
|
5836
|
+
_context29.prev = 22;
|
|
5643
5837
|
if (!booking) {
|
|
5644
|
-
|
|
5838
|
+
_context29.next = 49;
|
|
5645
5839
|
break;
|
|
5646
5840
|
}
|
|
5647
5841
|
productRecord = product;
|
|
5648
5842
|
splitCount = getSafeProductNum((_ref72 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref72 !== void 0 ? _ref72 : 1);
|
|
5649
5843
|
if (!(splitCount > 1)) {
|
|
5650
|
-
|
|
5844
|
+
_context29.next = 42;
|
|
5651
5845
|
break;
|
|
5652
5846
|
}
|
|
5653
5847
|
i = 0;
|
|
5654
5848
|
case 28:
|
|
5655
5849
|
if (!(i < splitCount)) {
|
|
5656
|
-
|
|
5850
|
+
_context29.next = 40;
|
|
5657
5851
|
break;
|
|
5658
5852
|
}
|
|
5659
5853
|
splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
|
|
@@ -5671,60 +5865,60 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5671
5865
|
delete splitLine.booking.metadata.unique_identification_number;
|
|
5672
5866
|
}
|
|
5673
5867
|
}
|
|
5674
|
-
|
|
5868
|
+
_context29.next = 33;
|
|
5675
5869
|
return this.appendProductLineToTempOrder(tempOrder, splitLine.product, splitLine.booking, {
|
|
5676
5870
|
insertAtIndex: insertAtIndex,
|
|
5677
5871
|
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
|
|
5678
5872
|
beforeCommit: beforeAppend
|
|
5679
5873
|
});
|
|
5680
5874
|
case 33:
|
|
5681
|
-
committedProduct =
|
|
5875
|
+
committedProduct = _context29.sent;
|
|
5682
5876
|
availabilityCommitGuard === null || availabilityCommitGuard === void 0 || availabilityCommitGuard();
|
|
5683
5877
|
attachSalesNoteDrafts(committedProduct);
|
|
5684
5878
|
if (insertAtIndex !== undefined) insertAtIndex += 1;
|
|
5685
5879
|
case 37:
|
|
5686
5880
|
i += 1;
|
|
5687
|
-
|
|
5881
|
+
_context29.next = 28;
|
|
5688
5882
|
break;
|
|
5689
5883
|
case 40:
|
|
5690
|
-
|
|
5884
|
+
_context29.next = 47;
|
|
5691
5885
|
break;
|
|
5692
5886
|
case 42:
|
|
5693
|
-
|
|
5887
|
+
_context29.next = 44;
|
|
5694
5888
|
return this.appendProductLineToTempOrder(tempOrder, product, cloneDeep(booking), {
|
|
5695
5889
|
insertAtIndex: insertAtIndex,
|
|
5696
5890
|
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
|
|
5697
5891
|
beforeCommit: beforeAppend
|
|
5698
5892
|
});
|
|
5699
5893
|
case 44:
|
|
5700
|
-
_committedProduct =
|
|
5894
|
+
_committedProduct = _context29.sent;
|
|
5701
5895
|
availabilityCommitGuard === null || availabilityCommitGuard === void 0 || availabilityCommitGuard();
|
|
5702
5896
|
attachSalesNoteDrafts(_committedProduct);
|
|
5703
5897
|
case 47:
|
|
5704
|
-
|
|
5898
|
+
_context29.next = 54;
|
|
5705
5899
|
break;
|
|
5706
5900
|
case 49:
|
|
5707
|
-
|
|
5901
|
+
_context29.next = 51;
|
|
5708
5902
|
return this.appendProductLineToTempOrder(tempOrder, product, undefined, {
|
|
5709
5903
|
insertAtIndex: insertAtIndex,
|
|
5710
5904
|
disableMerge: options === null || options === void 0 ? void 0 : options.disableMerge,
|
|
5711
5905
|
beforeCommit: beforeAppend
|
|
5712
5906
|
});
|
|
5713
5907
|
case 51:
|
|
5714
|
-
_committedProduct2 =
|
|
5908
|
+
_committedProduct2 = _context29.sent;
|
|
5715
5909
|
availabilityCommitGuard === null || availabilityCommitGuard === void 0 || availabilityCommitGuard();
|
|
5716
5910
|
attachSalesNoteDrafts(_committedProduct2);
|
|
5717
5911
|
case 54:
|
|
5718
5912
|
if (!mutation.commit) {
|
|
5719
|
-
|
|
5913
|
+
_context29.next = 59;
|
|
5720
5914
|
break;
|
|
5721
5915
|
}
|
|
5722
|
-
|
|
5916
|
+
_context29.next = 57;
|
|
5723
5917
|
return mutation.commit({
|
|
5724
5918
|
beforeCommit: beforePublish
|
|
5725
5919
|
});
|
|
5726
5920
|
case 57:
|
|
5727
|
-
|
|
5921
|
+
_context29.next = 60;
|
|
5728
5922
|
break;
|
|
5729
5923
|
case 59:
|
|
5730
5924
|
if (availabilityCommitGuard) {
|
|
@@ -5734,61 +5928,61 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5734
5928
|
Object.assign(liveTempOrder, readGuardedMutationFields(tempOrder));
|
|
5735
5929
|
}
|
|
5736
5930
|
case 60:
|
|
5737
|
-
|
|
5931
|
+
_context29.next = 66;
|
|
5738
5932
|
break;
|
|
5739
5933
|
case 62:
|
|
5740
|
-
|
|
5741
|
-
|
|
5934
|
+
_context29.prev = 62;
|
|
5935
|
+
_context29.t0 = _context29["catch"](22);
|
|
5742
5936
|
rollbackProductAndNotesMutation();
|
|
5743
|
-
throw
|
|
5937
|
+
throw _context29.t0;
|
|
5744
5938
|
case 66:
|
|
5745
5939
|
if (!availabilityCommitGuard) {
|
|
5746
|
-
|
|
5940
|
+
_context29.next = 80;
|
|
5747
5941
|
break;
|
|
5748
5942
|
}
|
|
5749
5943
|
committedIdentity = [liveTempOrder.order_id, liveTempOrder.external_sale_number];
|
|
5750
5944
|
isCurrentOrder = function isCurrentOrder() {
|
|
5751
5945
|
var _options$availability, _options$availability2;
|
|
5752
|
-
return
|
|
5946
|
+
return _this39.store.tempOrder === liveTempOrder && liveTempOrder.order_id === committedIdentity[0] && liveTempOrder.external_sale_number === committedIdentity[1] && ((_options$availability = options === null || options === void 0 || (_options$availability2 = options.availabilityCommitTargetGuard) === null || _options$availability2 === void 0 ? void 0 : _options$availability2.call(options)) !== null && _options$availability !== void 0 ? _options$availability : true);
|
|
5753
5947
|
};
|
|
5754
|
-
|
|
5948
|
+
_context29.prev = 69;
|
|
5755
5949
|
// 新增已发布,即使后续报价/促销收尾失败,也不能向调用方报告未加购。
|
|
5756
5950
|
// 先保存已提交行;异步结果只允许写回仍属于本次提交的订单。
|
|
5757
5951
|
if (isCurrentOrder()) this.persistTempOrder();
|
|
5758
|
-
|
|
5952
|
+
_context29.next = 73;
|
|
5759
5953
|
return this.finalizeProductOrderMutation(liveTempOrder, {
|
|
5760
5954
|
isCurrentOrder: isCurrentOrder
|
|
5761
5955
|
});
|
|
5762
5956
|
case 73:
|
|
5763
|
-
|
|
5957
|
+
_context29.next = 78;
|
|
5764
5958
|
break;
|
|
5765
5959
|
case 75:
|
|
5766
|
-
|
|
5767
|
-
|
|
5960
|
+
_context29.prev = 75;
|
|
5961
|
+
_context29.t1 = _context29["catch"](69);
|
|
5768
5962
|
this.logWarning('addProductToOrder committed; finalization failed', {
|
|
5769
5963
|
product_id: product.product_id,
|
|
5770
5964
|
committed: true,
|
|
5771
|
-
error:
|
|
5965
|
+
error: _context29.t1 instanceof Error ? _context29.t1.message : String(_context29.t1)
|
|
5772
5966
|
});
|
|
5773
5967
|
case 78:
|
|
5774
|
-
|
|
5968
|
+
_context29.next = 82;
|
|
5775
5969
|
break;
|
|
5776
5970
|
case 80:
|
|
5777
|
-
|
|
5971
|
+
_context29.next = 82;
|
|
5778
5972
|
return this.finalizeProductOrderMutation(liveTempOrder);
|
|
5779
5973
|
case 82:
|
|
5780
5974
|
this.logInfo('addProductToOrder success', {
|
|
5781
5975
|
product_id: product.product_id,
|
|
5782
5976
|
with_booking: !!booking
|
|
5783
5977
|
});
|
|
5784
|
-
return
|
|
5978
|
+
return _context29.abrupt("return", liveTempOrder.products);
|
|
5785
5979
|
case 84:
|
|
5786
5980
|
case "end":
|
|
5787
|
-
return
|
|
5981
|
+
return _context29.stop();
|
|
5788
5982
|
}
|
|
5789
|
-
},
|
|
5983
|
+
}, _callee28, this, [[22, 62], [69, 75]]);
|
|
5790
5984
|
}));
|
|
5791
|
-
function addProductToOrderDraft(
|
|
5985
|
+
function addProductToOrderDraft(_x31, _x32, _x33) {
|
|
5792
5986
|
return _addProductToOrderDraft.apply(this, arguments);
|
|
5793
5987
|
}
|
|
5794
5988
|
return addProductToOrderDraft;
|
|
@@ -5805,21 +5999,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5805
5999
|
}, {
|
|
5806
6000
|
key: "addProductsToOrder",
|
|
5807
6001
|
value: (function () {
|
|
5808
|
-
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5809
|
-
var
|
|
5810
|
-
return _regeneratorRuntime().wrap(function
|
|
5811
|
-
while (1) switch (
|
|
6002
|
+
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(items, options) {
|
|
6003
|
+
var _this40 = this;
|
|
6004
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context30) {
|
|
6005
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
5812
6006
|
case 0:
|
|
5813
|
-
return
|
|
5814
|
-
return
|
|
6007
|
+
return _context30.abrupt("return", this.queueCartCommand(function () {
|
|
6008
|
+
return _this40.addProductsToOrderDraft(items, options);
|
|
5815
6009
|
}));
|
|
5816
6010
|
case 1:
|
|
5817
6011
|
case "end":
|
|
5818
|
-
return
|
|
6012
|
+
return _context30.stop();
|
|
5819
6013
|
}
|
|
5820
|
-
},
|
|
6014
|
+
}, _callee29, this);
|
|
5821
6015
|
}));
|
|
5822
|
-
function addProductsToOrder(
|
|
6016
|
+
function addProductsToOrder(_x34, _x35) {
|
|
5823
6017
|
return _addProductsToOrder.apply(this, arguments);
|
|
5824
6018
|
}
|
|
5825
6019
|
return addProductsToOrder;
|
|
@@ -5827,51 +6021,51 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5827
6021
|
}, {
|
|
5828
6022
|
key: "addProductsToOrderDraft",
|
|
5829
6023
|
value: function () {
|
|
5830
|
-
var _addProductsToOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5831
|
-
var mutation, tempOrder, beforeCommit, beforeAppend,
|
|
5832
|
-
return _regeneratorRuntime().wrap(function
|
|
5833
|
-
while (1) switch (
|
|
6024
|
+
var _addProductsToOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(items, options) {
|
|
6025
|
+
var mutation, tempOrder, beforeCommit, beforeAppend, _iterator23, _step23, item, product, booking, _ref73, _productRecord$num2, productRecord, splitCount, i, splitLine, _appendResult, appendResult;
|
|
6026
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context31) {
|
|
6027
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
5834
6028
|
case 0:
|
|
5835
6029
|
mutation = this.beginCartMutation();
|
|
5836
6030
|
tempOrder = mutation.draft;
|
|
5837
6031
|
if (!(!Array.isArray(items) || items.length === 0)) {
|
|
5838
|
-
|
|
6032
|
+
_context31.next = 4;
|
|
5839
6033
|
break;
|
|
5840
6034
|
}
|
|
5841
|
-
return
|
|
6035
|
+
return _context31.abrupt("return", tempOrder.products);
|
|
5842
6036
|
case 4:
|
|
5843
6037
|
beforeCommit = this.createCartIntentCommitGuard('add_product');
|
|
5844
6038
|
beforeAppend = mutation.commit ? undefined : beforeCommit;
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
6039
|
+
_iterator23 = _createForOfIteratorHelper(items || []);
|
|
6040
|
+
_context31.prev = 7;
|
|
6041
|
+
_iterator23.s();
|
|
5848
6042
|
case 9:
|
|
5849
|
-
if ((
|
|
5850
|
-
|
|
6043
|
+
if ((_step23 = _iterator23.n()).done) {
|
|
6044
|
+
_context31.next = 35;
|
|
5851
6045
|
break;
|
|
5852
6046
|
}
|
|
5853
|
-
item =
|
|
6047
|
+
item = _step23.value;
|
|
5854
6048
|
product = item.product, booking = item.booking;
|
|
5855
6049
|
if (product) {
|
|
5856
|
-
|
|
6050
|
+
_context31.next = 14;
|
|
5857
6051
|
break;
|
|
5858
6052
|
}
|
|
5859
|
-
return
|
|
6053
|
+
return _context31.abrupt("continue", 33);
|
|
5860
6054
|
case 14:
|
|
5861
6055
|
if (!booking) {
|
|
5862
|
-
|
|
6056
|
+
_context31.next = 29;
|
|
5863
6057
|
break;
|
|
5864
6058
|
}
|
|
5865
6059
|
productRecord = product;
|
|
5866
6060
|
splitCount = getSafeProductNum((_ref73 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref73 !== void 0 ? _ref73 : 1);
|
|
5867
6061
|
if (!(splitCount > 1)) {
|
|
5868
|
-
|
|
6062
|
+
_context31.next = 29;
|
|
5869
6063
|
break;
|
|
5870
6064
|
}
|
|
5871
6065
|
i = 0;
|
|
5872
6066
|
case 19:
|
|
5873
6067
|
if (!(i < splitCount)) {
|
|
5874
|
-
|
|
6068
|
+
_context31.next = 28;
|
|
5875
6069
|
break;
|
|
5876
6070
|
}
|
|
5877
6071
|
splitLine = this.createSplitBookingLine(productRecord, booking, i, splitCount);
|
|
@@ -5879,67 +6073,67 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5879
6073
|
beforeCommit: beforeAppend
|
|
5880
6074
|
});
|
|
5881
6075
|
if (!_appendResult) {
|
|
5882
|
-
|
|
6076
|
+
_context31.next = 25;
|
|
5883
6077
|
break;
|
|
5884
6078
|
}
|
|
5885
|
-
|
|
6079
|
+
_context31.next = 25;
|
|
5886
6080
|
return _appendResult;
|
|
5887
6081
|
case 25:
|
|
5888
6082
|
i += 1;
|
|
5889
|
-
|
|
6083
|
+
_context31.next = 19;
|
|
5890
6084
|
break;
|
|
5891
6085
|
case 28:
|
|
5892
|
-
return
|
|
6086
|
+
return _context31.abrupt("continue", 33);
|
|
5893
6087
|
case 29:
|
|
5894
6088
|
appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking, {
|
|
5895
6089
|
beforeCommit: beforeAppend
|
|
5896
6090
|
});
|
|
5897
6091
|
if (!appendResult) {
|
|
5898
|
-
|
|
6092
|
+
_context31.next = 33;
|
|
5899
6093
|
break;
|
|
5900
6094
|
}
|
|
5901
|
-
|
|
6095
|
+
_context31.next = 33;
|
|
5902
6096
|
return appendResult;
|
|
5903
6097
|
case 33:
|
|
5904
|
-
|
|
6098
|
+
_context31.next = 9;
|
|
5905
6099
|
break;
|
|
5906
6100
|
case 35:
|
|
5907
|
-
|
|
6101
|
+
_context31.next = 40;
|
|
5908
6102
|
break;
|
|
5909
6103
|
case 37:
|
|
5910
|
-
|
|
5911
|
-
|
|
5912
|
-
|
|
6104
|
+
_context31.prev = 37;
|
|
6105
|
+
_context31.t0 = _context31["catch"](7);
|
|
6106
|
+
_iterator23.e(_context31.t0);
|
|
5913
6107
|
case 40:
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
return
|
|
6108
|
+
_context31.prev = 40;
|
|
6109
|
+
_iterator23.f();
|
|
6110
|
+
return _context31.finish(40);
|
|
5917
6111
|
case 43:
|
|
5918
6112
|
if (!mutation.commit) {
|
|
5919
|
-
|
|
6113
|
+
_context31.next = 47;
|
|
5920
6114
|
break;
|
|
5921
6115
|
}
|
|
5922
|
-
|
|
6116
|
+
_context31.next = 46;
|
|
5923
6117
|
return mutation.commit({
|
|
5924
6118
|
beforeCommit: beforeCommit
|
|
5925
6119
|
});
|
|
5926
6120
|
case 46:
|
|
5927
|
-
tempOrder =
|
|
6121
|
+
tempOrder = _context31.sent;
|
|
5928
6122
|
case 47:
|
|
5929
|
-
|
|
6123
|
+
_context31.next = 49;
|
|
5930
6124
|
return this.finalizeProductOrderMutation(tempOrder, options);
|
|
5931
6125
|
case 49:
|
|
5932
6126
|
this.logInfo('addProductsToOrder success', {
|
|
5933
6127
|
itemsCount: items.length
|
|
5934
6128
|
});
|
|
5935
|
-
return
|
|
6129
|
+
return _context31.abrupt("return", tempOrder.products);
|
|
5936
6130
|
case 51:
|
|
5937
6131
|
case "end":
|
|
5938
|
-
return
|
|
6132
|
+
return _context31.stop();
|
|
5939
6133
|
}
|
|
5940
|
-
},
|
|
6134
|
+
}, _callee30, this, [[7, 37, 40, 43]]);
|
|
5941
6135
|
}));
|
|
5942
|
-
function addProductsToOrderDraft(
|
|
6136
|
+
function addProductsToOrderDraft(_x36, _x37) {
|
|
5943
6137
|
return _addProductsToOrderDraft.apply(this, arguments);
|
|
5944
6138
|
}
|
|
5945
6139
|
return addProductsToOrderDraft;
|
|
@@ -5991,7 +6185,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5991
6185
|
}, {
|
|
5992
6186
|
key: "hasSameEntitlementMergePriceConfig",
|
|
5993
6187
|
value: function hasSameEntitlementMergePriceConfig(incoming, existing) {
|
|
5994
|
-
var
|
|
6188
|
+
var _this41 = this;
|
|
5995
6189
|
var buildPriceConfig = function buildPriceConfig(product) {
|
|
5996
6190
|
var metadata = product.metadata || {};
|
|
5997
6191
|
var bundle = (product.product_bundle || []).map(function (item) {
|
|
@@ -6007,10 +6201,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6007
6201
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
6008
6202
|
});
|
|
6009
6203
|
return JSON.stringify({
|
|
6010
|
-
original_price:
|
|
6011
|
-
source_product_price:
|
|
6012
|
-
main_product_original_price:
|
|
6013
|
-
price_override:
|
|
6204
|
+
original_price: _this41.normalizeFingerprintMoney(product.original_price),
|
|
6205
|
+
source_product_price: _this41.normalizeFingerprintMoney(metadata.source_product_price),
|
|
6206
|
+
main_product_original_price: _this41.normalizeFingerprintMoney(metadata.main_product_original_price),
|
|
6207
|
+
price_override: _this41.normalizeFingerprintMoney(metadata.price_override),
|
|
6014
6208
|
is_manual_discount: Boolean(metadata.is_manual_discount),
|
|
6015
6209
|
bundle: bundle
|
|
6016
6210
|
});
|
|
@@ -6027,17 +6221,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6027
6221
|
}, {
|
|
6028
6222
|
key: "preservePersistedBundlePriceFields",
|
|
6029
6223
|
value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
|
|
6030
|
-
var
|
|
6224
|
+
var _this42 = this;
|
|
6031
6225
|
if (!Array.isArray(nextBundles)) return nextBundles;
|
|
6032
6226
|
if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
|
|
6033
6227
|
var previousByIdentity = new Map();
|
|
6034
6228
|
previousBundles.forEach(function (bundle) {
|
|
6035
|
-
var identity =
|
|
6229
|
+
var identity = _this42.getBundleRuntimeIdentity(bundle);
|
|
6036
6230
|
if (identity) previousByIdentity.set(identity, bundle);
|
|
6037
6231
|
});
|
|
6038
6232
|
return nextBundles.map(function (bundle, index) {
|
|
6039
6233
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
6040
|
-
var previous = previousByIdentity.get(
|
|
6234
|
+
var previous = previousByIdentity.get(_this42.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
6041
6235
|
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
6042
6236
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
|
|
6043
6237
|
cover: previous.cover
|
|
@@ -6309,21 +6503,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6309
6503
|
}, {
|
|
6310
6504
|
key: "updateOrderProduct",
|
|
6311
6505
|
value: function () {
|
|
6312
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6313
|
-
var
|
|
6314
|
-
return _regeneratorRuntime().wrap(function
|
|
6315
|
-
while (1) switch (
|
|
6506
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
6507
|
+
var _this43 = this;
|
|
6508
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context32) {
|
|
6509
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
6316
6510
|
case 0:
|
|
6317
|
-
return
|
|
6318
|
-
return
|
|
6511
|
+
return _context32.abrupt("return", this.queueCartCommand(function () {
|
|
6512
|
+
return _this43.updateOrderProductDraft(params);
|
|
6319
6513
|
}));
|
|
6320
6514
|
case 1:
|
|
6321
6515
|
case "end":
|
|
6322
|
-
return
|
|
6516
|
+
return _context32.stop();
|
|
6323
6517
|
}
|
|
6324
|
-
},
|
|
6518
|
+
}, _callee31, this);
|
|
6325
6519
|
}));
|
|
6326
|
-
function updateOrderProduct(
|
|
6520
|
+
function updateOrderProduct(_x38) {
|
|
6327
6521
|
return _updateOrderProduct.apply(this, arguments);
|
|
6328
6522
|
}
|
|
6329
6523
|
return updateOrderProduct;
|
|
@@ -6331,10 +6525,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6331
6525
|
}, {
|
|
6332
6526
|
key: "updateOrderProductDraft",
|
|
6333
6527
|
value: function () {
|
|
6334
|
-
var _updateOrderProductDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6528
|
+
var _updateOrderProductDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
|
|
6335
6529
|
var mutation, tempOrder, beforeCommit, reapplyWeighedDiscountProductUids, updatedProductUid, promotionPayload;
|
|
6336
|
-
return _regeneratorRuntime().wrap(function
|
|
6337
|
-
while (1) switch (
|
|
6530
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context33) {
|
|
6531
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
6338
6532
|
case 0:
|
|
6339
6533
|
mutation = this.beginCartMutation();
|
|
6340
6534
|
tempOrder = mutation.draft;
|
|
@@ -6343,26 +6537,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6343
6537
|
reapplyWeighedDiscountProductUids = [];
|
|
6344
6538
|
updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
|
|
6345
6539
|
if (!mutation.commit) {
|
|
6346
|
-
|
|
6540
|
+
_context33.next = 10;
|
|
6347
6541
|
break;
|
|
6348
6542
|
}
|
|
6349
|
-
|
|
6543
|
+
_context33.next = 9;
|
|
6350
6544
|
return mutation.commit({
|
|
6351
6545
|
beforeCommit: beforeCommit
|
|
6352
6546
|
});
|
|
6353
6547
|
case 9:
|
|
6354
|
-
tempOrder =
|
|
6548
|
+
tempOrder = _context33.sent;
|
|
6355
6549
|
case 10:
|
|
6356
|
-
|
|
6550
|
+
_context33.next = 12;
|
|
6357
6551
|
return this.evaluatePromotion();
|
|
6358
6552
|
case 12:
|
|
6359
|
-
promotionPayload =
|
|
6553
|
+
promotionPayload = _context33.sent;
|
|
6360
6554
|
this.applyDiscount({
|
|
6361
6555
|
reapplyWeighedDiscountProductUids: reapplyWeighedDiscountProductUids,
|
|
6362
6556
|
reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
|
|
6363
6557
|
});
|
|
6364
6558
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
6365
|
-
|
|
6559
|
+
_context33.next = 17;
|
|
6366
6560
|
return this.recalculateSummary({
|
|
6367
6561
|
createIfMissing: true
|
|
6368
6562
|
});
|
|
@@ -6372,14 +6566,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6372
6566
|
this.logInfo('updateOrderProduct success', {
|
|
6373
6567
|
params: params
|
|
6374
6568
|
});
|
|
6375
|
-
return
|
|
6569
|
+
return _context33.abrupt("return", tempOrder.products);
|
|
6376
6570
|
case 21:
|
|
6377
6571
|
case "end":
|
|
6378
|
-
return
|
|
6572
|
+
return _context33.stop();
|
|
6379
6573
|
}
|
|
6380
|
-
},
|
|
6574
|
+
}, _callee32, this);
|
|
6381
6575
|
}));
|
|
6382
|
-
function updateOrderProductDraft(
|
|
6576
|
+
function updateOrderProductDraft(_x39) {
|
|
6383
6577
|
return _updateOrderProductDraft.apply(this, arguments);
|
|
6384
6578
|
}
|
|
6385
6579
|
return updateOrderProductDraft;
|
|
@@ -6387,21 +6581,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6387
6581
|
}, {
|
|
6388
6582
|
key: "updateOrderProducts",
|
|
6389
6583
|
value: function () {
|
|
6390
|
-
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6391
|
-
var
|
|
6392
|
-
return _regeneratorRuntime().wrap(function
|
|
6393
|
-
while (1) switch (
|
|
6584
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(paramsList) {
|
|
6585
|
+
var _this44 = this;
|
|
6586
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context34) {
|
|
6587
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
6394
6588
|
case 0:
|
|
6395
|
-
return
|
|
6396
|
-
return
|
|
6589
|
+
return _context34.abrupt("return", this.queueCartCommand(function () {
|
|
6590
|
+
return _this44.updateOrderProductsDraft(paramsList);
|
|
6397
6591
|
}));
|
|
6398
6592
|
case 1:
|
|
6399
6593
|
case "end":
|
|
6400
|
-
return
|
|
6594
|
+
return _context34.stop();
|
|
6401
6595
|
}
|
|
6402
|
-
},
|
|
6596
|
+
}, _callee33, this);
|
|
6403
6597
|
}));
|
|
6404
|
-
function updateOrderProducts(
|
|
6598
|
+
function updateOrderProducts(_x40) {
|
|
6405
6599
|
return _updateOrderProducts.apply(this, arguments);
|
|
6406
6600
|
}
|
|
6407
6601
|
return updateOrderProducts;
|
|
@@ -6409,27 +6603,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6409
6603
|
}, {
|
|
6410
6604
|
key: "updateOrderProductsDraft",
|
|
6411
6605
|
value: function () {
|
|
6412
|
-
var _updateOrderProductsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6413
|
-
var
|
|
6606
|
+
var _updateOrderProductsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(paramsList) {
|
|
6607
|
+
var _this45 = this;
|
|
6414
6608
|
var mutation, tempOrder, beforeCommit, reapplyWeighedDiscountProductUids, reapplyBookingDiscountProductUids;
|
|
6415
|
-
return _regeneratorRuntime().wrap(function
|
|
6416
|
-
while (1) switch (
|
|
6609
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context35) {
|
|
6610
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
6417
6611
|
case 0:
|
|
6418
6612
|
mutation = this.beginCartMutation();
|
|
6419
6613
|
tempOrder = mutation.draft;
|
|
6420
6614
|
if (paramsList.length) {
|
|
6421
|
-
|
|
6615
|
+
_context35.next = 4;
|
|
6422
6616
|
break;
|
|
6423
6617
|
}
|
|
6424
|
-
return
|
|
6618
|
+
return _context35.abrupt("return", tempOrder.products);
|
|
6425
6619
|
case 4:
|
|
6426
6620
|
beforeCommit = paramsList.some(function (params) {
|
|
6427
|
-
return
|
|
6621
|
+
return _this45.isRestrictedCartProductUpdate(tempOrder, params);
|
|
6428
6622
|
}) ? this.createCartIntentCommitGuard('update_product') : undefined;
|
|
6429
6623
|
if (!mutation.commit) beforeCommit === null || beforeCommit === void 0 || beforeCommit();
|
|
6430
6624
|
reapplyWeighedDiscountProductUids = [];
|
|
6431
6625
|
reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
|
|
6432
|
-
var updatedProductUid =
|
|
6626
|
+
var updatedProductUid = _this45.applyOrderProductUpdateToTempOrder(tempOrder, params, reapplyWeighedDiscountProductUids);
|
|
6433
6627
|
// 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
|
|
6434
6628
|
if (params.allow_booking_discount_reapply && updatedProductUid) {
|
|
6435
6629
|
acc.push(String(updatedProductUid));
|
|
@@ -6437,17 +6631,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6437
6631
|
return acc;
|
|
6438
6632
|
}, []);
|
|
6439
6633
|
if (!mutation.commit) {
|
|
6440
|
-
|
|
6634
|
+
_context35.next = 12;
|
|
6441
6635
|
break;
|
|
6442
6636
|
}
|
|
6443
|
-
|
|
6637
|
+
_context35.next = 11;
|
|
6444
6638
|
return mutation.commit({
|
|
6445
6639
|
beforeCommit: beforeCommit
|
|
6446
6640
|
});
|
|
6447
6641
|
case 11:
|
|
6448
|
-
tempOrder =
|
|
6642
|
+
tempOrder = _context35.sent;
|
|
6449
6643
|
case 12:
|
|
6450
|
-
|
|
6644
|
+
_context35.next = 14;
|
|
6451
6645
|
return this.finalizeAfterProductsMutation(tempOrder, {
|
|
6452
6646
|
reapplyWeighedDiscountProductUids: reapplyWeighedDiscountProductUids,
|
|
6453
6647
|
reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
|
|
@@ -6456,14 +6650,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6456
6650
|
this.logInfo('updateOrderProduct success', {
|
|
6457
6651
|
paramsList: paramsList
|
|
6458
6652
|
});
|
|
6459
|
-
return
|
|
6653
|
+
return _context35.abrupt("return", tempOrder.products);
|
|
6460
6654
|
case 16:
|
|
6461
6655
|
case "end":
|
|
6462
|
-
return
|
|
6656
|
+
return _context35.stop();
|
|
6463
6657
|
}
|
|
6464
|
-
},
|
|
6658
|
+
}, _callee34, this);
|
|
6465
6659
|
}));
|
|
6466
|
-
function updateOrderProductsDraft(
|
|
6660
|
+
function updateOrderProductsDraft(_x41) {
|
|
6467
6661
|
return _updateOrderProductsDraft.apply(this, arguments);
|
|
6468
6662
|
}
|
|
6469
6663
|
return updateOrderProductsDraft;
|
|
@@ -6471,21 +6665,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6471
6665
|
}, {
|
|
6472
6666
|
key: "updateOrderProductQuantity",
|
|
6473
6667
|
value: function () {
|
|
6474
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6475
|
-
var
|
|
6476
|
-
return _regeneratorRuntime().wrap(function
|
|
6477
|
-
while (1) switch (
|
|
6668
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params, options) {
|
|
6669
|
+
var _this46 = this;
|
|
6670
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context36) {
|
|
6671
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
6478
6672
|
case 0:
|
|
6479
|
-
return
|
|
6480
|
-
return
|
|
6673
|
+
return _context36.abrupt("return", this.queueCartCommand(function () {
|
|
6674
|
+
return _this46.updateOrderProductQuantityDraft(params, options);
|
|
6481
6675
|
}));
|
|
6482
6676
|
case 1:
|
|
6483
6677
|
case "end":
|
|
6484
|
-
return
|
|
6678
|
+
return _context36.stop();
|
|
6485
6679
|
}
|
|
6486
|
-
},
|
|
6680
|
+
}, _callee35, this);
|
|
6487
6681
|
}));
|
|
6488
|
-
function updateOrderProductQuantity(
|
|
6682
|
+
function updateOrderProductQuantity(_x42, _x43) {
|
|
6489
6683
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
6490
6684
|
}
|
|
6491
6685
|
return updateOrderProductQuantity;
|
|
@@ -6493,18 +6687,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6493
6687
|
}, {
|
|
6494
6688
|
key: "updateOrderProductQuantityDraft",
|
|
6495
6689
|
value: function () {
|
|
6496
|
-
var _updateOrderProductQuantityDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6690
|
+
var _updateOrderProductQuantityDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params, options) {
|
|
6497
6691
|
var _this$store$tempOrder10, _targetProduct$metada22;
|
|
6498
6692
|
var isCurrentOrder, product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, mutation, tempOrder, identityLookup, productIndex, targetUid, targetProduct, isPersistedOrderLine, normalizedProduct, settlementSnapshot, currencyProductId, asset, requiredAmount, balance, beforeCommit, isVirtualSettlement, promotionPayload;
|
|
6499
|
-
return _regeneratorRuntime().wrap(function
|
|
6500
|
-
while (1) switch (
|
|
6693
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context37) {
|
|
6694
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
6501
6695
|
case 0:
|
|
6502
6696
|
isCurrentOrder = options === null || options === void 0 ? void 0 : options.isCurrentOrder;
|
|
6503
6697
|
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
6504
|
-
|
|
6698
|
+
_context37.next = 3;
|
|
6505
6699
|
break;
|
|
6506
6700
|
}
|
|
6507
|
-
return
|
|
6701
|
+
return _context37.abrupt("return", ((_this$store$tempOrder10 = this.store.tempOrder) === null || _this$store$tempOrder10 === void 0 ? void 0 : _this$store$tempOrder10.products) || []);
|
|
6508
6702
|
case 3:
|
|
6509
6703
|
product_id = params.product_id, product_variant_id = params.product_variant_id, num = params.num, unique_identification_number = params.unique_identification_number, identity_key = params.identity_key, product_sku = params.product_sku, product_bundle = params.product_bundle;
|
|
6510
6704
|
mutation = this.beginCartMutation();
|
|
@@ -6535,7 +6729,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6535
6729
|
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
6536
6730
|
}
|
|
6537
6731
|
if (!(productIndex === -1)) {
|
|
6538
|
-
|
|
6732
|
+
_context37.next = 17;
|
|
6539
6733
|
break;
|
|
6540
6734
|
}
|
|
6541
6735
|
throw new Error('[Order] 目标商品不存在,无法更新数量');
|
|
@@ -6551,7 +6745,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6551
6745
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(isPersistedOrderLine ? syncReducedEntitlementPassUsageCount(normalizedProduct.discount_list, targetProduct.num, normalizedProduct.num) : normalizedProduct.discount_list);
|
|
6552
6746
|
settlementSnapshot = getSelectedSettlementSnapshot(normalizedProduct);
|
|
6553
6747
|
if (!(this.isMultiCurrencySettlementEnabled() && (settlementSnapshot === null || settlementSnapshot === void 0 ? void 0 : settlementSnapshot.settlement_type) === 'virtual_currency' && tempOrder.customer_id && Number(tempOrder.customer_id) !== 1)) {
|
|
6554
|
-
|
|
6748
|
+
_context37.next = 31;
|
|
6555
6749
|
break;
|
|
6556
6750
|
}
|
|
6557
6751
|
currencyProductId = Number(settlementSnapshot.currency_product_id);
|
|
@@ -6559,7 +6753,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6559
6753
|
return Number(item === null || item === void 0 ? void 0 : item.product_id) === currencyProductId;
|
|
6560
6754
|
});
|
|
6561
6755
|
if (asset) {
|
|
6562
|
-
|
|
6756
|
+
_context37.next = 27;
|
|
6563
6757
|
break;
|
|
6564
6758
|
}
|
|
6565
6759
|
throw new VirtualCurrencyAssetNotFoundError(currencyProductId);
|
|
@@ -6571,7 +6765,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6571
6765
|
}, new Decimal(0));
|
|
6572
6766
|
balance = new Decimal(asset.balance || 0);
|
|
6573
6767
|
if (!balance.lt(requiredAmount)) {
|
|
6574
|
-
|
|
6768
|
+
_context37.next = 31;
|
|
6575
6769
|
break;
|
|
6576
6770
|
}
|
|
6577
6771
|
throw new VirtualCurrencyBalanceError(balance.toFixed(2), requiredAmount.toFixed(2));
|
|
@@ -6579,58 +6773,58 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6579
6773
|
beforeCommit = normalizedProduct.num > targetProduct.num ? this.createCartIntentCommitGuard('increase_quantity') : undefined;
|
|
6580
6774
|
if (!mutation.commit) beforeCommit === null || beforeCommit === void 0 || beforeCommit();
|
|
6581
6775
|
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
6582
|
-
|
|
6776
|
+
_context37.next = 35;
|
|
6583
6777
|
break;
|
|
6584
6778
|
}
|
|
6585
|
-
return
|
|
6779
|
+
return _context37.abrupt("return", tempOrder.products);
|
|
6586
6780
|
case 35:
|
|
6587
6781
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
6588
6782
|
if (!mutation.commit) {
|
|
6589
|
-
|
|
6783
|
+
_context37.next = 40;
|
|
6590
6784
|
break;
|
|
6591
6785
|
}
|
|
6592
|
-
|
|
6786
|
+
_context37.next = 39;
|
|
6593
6787
|
return mutation.commit({
|
|
6594
6788
|
beforeCommit: beforeCommit,
|
|
6595
6789
|
isCurrentOrder: isCurrentOrder
|
|
6596
6790
|
});
|
|
6597
6791
|
case 39:
|
|
6598
|
-
tempOrder =
|
|
6792
|
+
tempOrder = _context37.sent;
|
|
6599
6793
|
case 40:
|
|
6600
6794
|
if (!isCurrentOrder) {
|
|
6601
|
-
|
|
6795
|
+
_context37.next = 45;
|
|
6602
6796
|
break;
|
|
6603
6797
|
}
|
|
6604
|
-
|
|
6798
|
+
_context37.next = 43;
|
|
6605
6799
|
return this.finalizeProductOrderMutation(tempOrder, {
|
|
6606
6800
|
skipEditDiscountConfigRefresh: true,
|
|
6607
6801
|
isCurrentOrder: isCurrentOrder
|
|
6608
6802
|
});
|
|
6609
6803
|
case 43:
|
|
6610
|
-
|
|
6804
|
+
_context37.next = 61;
|
|
6611
6805
|
break;
|
|
6612
6806
|
case 45:
|
|
6613
6807
|
this.prepareVirtualSettlementTempOrder(tempOrder);
|
|
6614
6808
|
isVirtualSettlement = this.isActiveVirtualSettlementOrder(tempOrder);
|
|
6615
6809
|
if (isVirtualSettlement) {
|
|
6616
|
-
|
|
6810
|
+
_context37.next = 53;
|
|
6617
6811
|
break;
|
|
6618
6812
|
}
|
|
6619
|
-
|
|
6813
|
+
_context37.next = 50;
|
|
6620
6814
|
return this.evaluatePromotion();
|
|
6621
6815
|
case 50:
|
|
6622
|
-
|
|
6623
|
-
|
|
6816
|
+
_context37.t0 = _context37.sent;
|
|
6817
|
+
_context37.next = 54;
|
|
6624
6818
|
break;
|
|
6625
6819
|
case 53:
|
|
6626
|
-
|
|
6820
|
+
_context37.t0 = null;
|
|
6627
6821
|
case 54:
|
|
6628
|
-
promotionPayload =
|
|
6822
|
+
promotionPayload = _context37.t0;
|
|
6629
6823
|
if (!isVirtualSettlement) {
|
|
6630
6824
|
this.applyDiscount();
|
|
6631
6825
|
}
|
|
6632
6826
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
6633
|
-
|
|
6827
|
+
_context37.next = 59;
|
|
6634
6828
|
return this.recalculateSummary({
|
|
6635
6829
|
createIfMissing: true
|
|
6636
6830
|
});
|
|
@@ -6641,14 +6835,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6641
6835
|
this.logInfo('updateOrderProductQuantity success', {
|
|
6642
6836
|
params: params
|
|
6643
6837
|
});
|
|
6644
|
-
return
|
|
6838
|
+
return _context37.abrupt("return", tempOrder.products);
|
|
6645
6839
|
case 63:
|
|
6646
6840
|
case "end":
|
|
6647
|
-
return
|
|
6841
|
+
return _context37.stop();
|
|
6648
6842
|
}
|
|
6649
|
-
},
|
|
6843
|
+
}, _callee36, this);
|
|
6650
6844
|
}));
|
|
6651
|
-
function updateOrderProductQuantityDraft(
|
|
6845
|
+
function updateOrderProductQuantityDraft(_x44, _x45) {
|
|
6652
6846
|
return _updateOrderProductQuantityDraft.apply(this, arguments);
|
|
6653
6847
|
}
|
|
6654
6848
|
return updateOrderProductQuantityDraft;
|
|
@@ -6689,22 +6883,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6689
6883
|
}, {
|
|
6690
6884
|
key: "finalizeAfterProductsMutation",
|
|
6691
6885
|
value: (function () {
|
|
6692
|
-
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6886
|
+
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(tempOrder, options) {
|
|
6693
6887
|
var promotionPayload;
|
|
6694
|
-
return _regeneratorRuntime().wrap(function
|
|
6695
|
-
while (1) switch (
|
|
6888
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context38) {
|
|
6889
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
6696
6890
|
case 0:
|
|
6697
6891
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
6698
|
-
|
|
6892
|
+
_context38.next = 3;
|
|
6699
6893
|
return this.evaluatePromotion();
|
|
6700
6894
|
case 3:
|
|
6701
|
-
promotionPayload =
|
|
6895
|
+
promotionPayload = _context38.sent;
|
|
6702
6896
|
this.applyDiscount({
|
|
6703
6897
|
reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids,
|
|
6704
6898
|
reapplyWeighedDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyWeighedDiscountProductUids
|
|
6705
6899
|
});
|
|
6706
6900
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
6707
|
-
|
|
6901
|
+
_context38.next = 8;
|
|
6708
6902
|
return this.recalculateSummary({
|
|
6709
6903
|
createIfMissing: true
|
|
6710
6904
|
});
|
|
@@ -6713,11 +6907,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6713
6907
|
this.emitPromotionApplied(promotionPayload);
|
|
6714
6908
|
case 10:
|
|
6715
6909
|
case "end":
|
|
6716
|
-
return
|
|
6910
|
+
return _context38.stop();
|
|
6717
6911
|
}
|
|
6718
|
-
},
|
|
6912
|
+
}, _callee37, this);
|
|
6719
6913
|
}));
|
|
6720
|
-
function finalizeAfterProductsMutation(
|
|
6914
|
+
function finalizeAfterProductsMutation(_x46, _x47) {
|
|
6721
6915
|
return _finalizeAfterProductsMutation.apply(this, arguments);
|
|
6722
6916
|
}
|
|
6723
6917
|
return finalizeAfterProductsMutation;
|
|
@@ -6732,21 +6926,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6732
6926
|
}, {
|
|
6733
6927
|
key: "removeProductsFromOrder",
|
|
6734
6928
|
value: (function () {
|
|
6735
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6736
|
-
var
|
|
6737
|
-
return _regeneratorRuntime().wrap(function
|
|
6738
|
-
while (1) switch (
|
|
6929
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(identities, options) {
|
|
6930
|
+
var _this47 = this;
|
|
6931
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context39) {
|
|
6932
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
6739
6933
|
case 0:
|
|
6740
|
-
return
|
|
6741
|
-
return
|
|
6934
|
+
return _context39.abrupt("return", this.queueCartCommand(function () {
|
|
6935
|
+
return _this47.removeProductsFromOrderDraft(identities, options);
|
|
6742
6936
|
}));
|
|
6743
6937
|
case 1:
|
|
6744
6938
|
case "end":
|
|
6745
|
-
return
|
|
6939
|
+
return _context39.stop();
|
|
6746
6940
|
}
|
|
6747
|
-
},
|
|
6941
|
+
}, _callee38, this);
|
|
6748
6942
|
}));
|
|
6749
|
-
function removeProductsFromOrder(
|
|
6943
|
+
function removeProductsFromOrder(_x48, _x49) {
|
|
6750
6944
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
6751
6945
|
}
|
|
6752
6946
|
return removeProductsFromOrder;
|
|
@@ -6754,27 +6948,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6754
6948
|
}, {
|
|
6755
6949
|
key: "removeProductsFromOrderDraft",
|
|
6756
6950
|
value: function () {
|
|
6757
|
-
var _removeProductsFromOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6951
|
+
var _removeProductsFromOrderDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(identities, options) {
|
|
6758
6952
|
var _this$store$tempOrder11,
|
|
6759
|
-
|
|
6760
|
-
var isCurrentOrder, mutation, tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove,
|
|
6761
|
-
return _regeneratorRuntime().wrap(function
|
|
6762
|
-
while (1) switch (
|
|
6953
|
+
_this48 = this;
|
|
6954
|
+
var isCurrentOrder, mutation, tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator24, _step24, _loop2, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
|
|
6955
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context41) {
|
|
6956
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
6763
6957
|
case 0:
|
|
6764
6958
|
isCurrentOrder = options === null || options === void 0 ? void 0 : options.isCurrentOrder;
|
|
6765
6959
|
if (!(isCurrentOrder && !isCurrentOrder())) {
|
|
6766
|
-
|
|
6960
|
+
_context41.next = 3;
|
|
6767
6961
|
break;
|
|
6768
6962
|
}
|
|
6769
|
-
return
|
|
6963
|
+
return _context41.abrupt("return", ((_this$store$tempOrder11 = this.store.tempOrder) === null || _this$store$tempOrder11 === void 0 ? void 0 : _this$store$tempOrder11.products) || []);
|
|
6770
6964
|
case 3:
|
|
6771
6965
|
mutation = this.beginCartMutation();
|
|
6772
6966
|
tempOrder = mutation.draft;
|
|
6773
6967
|
if (identities.length) {
|
|
6774
|
-
|
|
6968
|
+
_context41.next = 7;
|
|
6775
6969
|
break;
|
|
6776
6970
|
}
|
|
6777
|
-
return
|
|
6971
|
+
return _context41.abrupt("return", tempOrder.products);
|
|
6778
6972
|
case 7:
|
|
6779
6973
|
// 商品删除会同步删除以商品行为主关系的 Notes;快照不完整时禁止产生孤儿 Relation。
|
|
6780
6974
|
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
@@ -6806,30 +7000,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6806
7000
|
this.removeLinkedBookingsForProduct(tempOrder, product);
|
|
6807
7001
|
}
|
|
6808
7002
|
linkedBookingUidsToRemove = new Set();
|
|
6809
|
-
|
|
6810
|
-
|
|
7003
|
+
_iterator24 = _createForOfIteratorHelper(matchedProducts);
|
|
7004
|
+
_context41.prev = 20;
|
|
6811
7005
|
_loop2 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop2() {
|
|
6812
7006
|
var _metadata11, _metadata12, _metadata13, _metadata14;
|
|
6813
7007
|
var product, productUid, productBookingUid, isAddTimeProduct;
|
|
6814
|
-
return _regeneratorRuntime().wrap(function _loop2$(
|
|
6815
|
-
while (1) switch (
|
|
7008
|
+
return _regeneratorRuntime().wrap(function _loop2$(_context40) {
|
|
7009
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
6816
7010
|
case 0:
|
|
6817
|
-
product =
|
|
7011
|
+
product = _step24.value;
|
|
6818
7012
|
productUid = (product === null || product === void 0 || (_metadata11 = product.metadata) === null || _metadata11 === void 0 ? void 0 : _metadata11.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
6819
7013
|
productBookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_metadata12 = product.metadata) === null || _metadata12 === void 0 ? void 0 : _metadata12.booking_uid);
|
|
6820
7014
|
isAddTimeProduct = (product === null || product === void 0 || (_metadata13 = product.metadata) === null || _metadata13 === void 0 ? void 0 : _metadata13.product_add_schedule_time) !== undefined && (product === null || product === void 0 || (_metadata14 = product.metadata) === null || _metadata14 === void 0 ? void 0 : _metadata14.product_add_schedule_time) !== null;
|
|
6821
7015
|
if (!isAddTimeProduct) {
|
|
6822
|
-
|
|
7016
|
+
_context40.next = 6;
|
|
6823
7017
|
break;
|
|
6824
7018
|
}
|
|
6825
|
-
return
|
|
7019
|
+
return _context40.abrupt("return", 1);
|
|
6826
7020
|
case 6:
|
|
6827
7021
|
if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
|
|
6828
7022
|
linkedBookingUidsToRemove.add(String(productBookingUid));
|
|
6829
7023
|
}
|
|
6830
7024
|
if (productUid !== undefined && productUid !== null && productUid !== '') {
|
|
6831
7025
|
bookingsBeforeRemove.forEach(function (booking) {
|
|
6832
|
-
var bookingUid =
|
|
7026
|
+
var bookingUid = _this48.getBookingUniqueIdentificationNumber(booking);
|
|
6833
7027
|
if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
|
|
6834
7028
|
linkedBookingUidsToRemove.add(bookingUid);
|
|
6835
7029
|
}
|
|
@@ -6837,37 +7031,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6837
7031
|
}
|
|
6838
7032
|
case 8:
|
|
6839
7033
|
case "end":
|
|
6840
|
-
return
|
|
7034
|
+
return _context40.stop();
|
|
6841
7035
|
}
|
|
6842
7036
|
}, _loop2);
|
|
6843
7037
|
});
|
|
6844
|
-
|
|
7038
|
+
_iterator24.s();
|
|
6845
7039
|
case 23:
|
|
6846
|
-
if ((
|
|
6847
|
-
|
|
7040
|
+
if ((_step24 = _iterator24.n()).done) {
|
|
7041
|
+
_context41.next = 29;
|
|
6848
7042
|
break;
|
|
6849
7043
|
}
|
|
6850
|
-
return
|
|
7044
|
+
return _context41.delegateYield(_loop2(), "t0", 25);
|
|
6851
7045
|
case 25:
|
|
6852
|
-
if (!
|
|
6853
|
-
|
|
7046
|
+
if (!_context41.t0) {
|
|
7047
|
+
_context41.next = 27;
|
|
6854
7048
|
break;
|
|
6855
7049
|
}
|
|
6856
|
-
return
|
|
7050
|
+
return _context41.abrupt("continue", 27);
|
|
6857
7051
|
case 27:
|
|
6858
|
-
|
|
7052
|
+
_context41.next = 23;
|
|
6859
7053
|
break;
|
|
6860
7054
|
case 29:
|
|
6861
|
-
|
|
7055
|
+
_context41.next = 34;
|
|
6862
7056
|
break;
|
|
6863
7057
|
case 31:
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
|
|
7058
|
+
_context41.prev = 31;
|
|
7059
|
+
_context41.t1 = _context41["catch"](20);
|
|
7060
|
+
_iterator24.e(_context41.t1);
|
|
6867
7061
|
case 34:
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
return
|
|
7062
|
+
_context41.prev = 34;
|
|
7063
|
+
_iterator24.f();
|
|
7064
|
+
return _context41.finish(34);
|
|
6871
7065
|
case 37:
|
|
6872
7066
|
if (linkedBookingUidsToRemove.size > 0) {
|
|
6873
7067
|
// 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
|
|
@@ -6903,43 +7097,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6903
7097
|
tempOrder.shop_discount = '0.00';
|
|
6904
7098
|
}
|
|
6905
7099
|
if (!mutation.commit) {
|
|
6906
|
-
|
|
7100
|
+
_context41.next = 46;
|
|
6907
7101
|
break;
|
|
6908
7102
|
}
|
|
6909
|
-
|
|
7103
|
+
_context41.next = 45;
|
|
6910
7104
|
return mutation.commit({
|
|
6911
7105
|
isCurrentOrder: isCurrentOrder
|
|
6912
7106
|
});
|
|
6913
7107
|
case 45:
|
|
6914
|
-
tempOrder =
|
|
7108
|
+
tempOrder = _context41.sent;
|
|
6915
7109
|
case 46:
|
|
6916
7110
|
if (!isCurrentOrder) {
|
|
6917
|
-
|
|
7111
|
+
_context41.next = 51;
|
|
6918
7112
|
break;
|
|
6919
7113
|
}
|
|
6920
|
-
|
|
7114
|
+
_context41.next = 49;
|
|
6921
7115
|
return this.finalizeProductOrderMutation(tempOrder, {
|
|
6922
7116
|
skipEditDiscountConfigRefresh: true,
|
|
6923
7117
|
isCurrentOrder: isCurrentOrder
|
|
6924
7118
|
});
|
|
6925
7119
|
case 49:
|
|
6926
|
-
|
|
7120
|
+
_context41.next = 53;
|
|
6927
7121
|
break;
|
|
6928
7122
|
case 51:
|
|
6929
|
-
|
|
7123
|
+
_context41.next = 53;
|
|
6930
7124
|
return this.finalizeAfterProductsMutation(tempOrder);
|
|
6931
7125
|
case 53:
|
|
6932
7126
|
this.logInfo('removeProductsFromOrder success', {
|
|
6933
7127
|
identities: identities
|
|
6934
7128
|
});
|
|
6935
|
-
return
|
|
7129
|
+
return _context41.abrupt("return", tempOrder.products);
|
|
6936
7130
|
case 55:
|
|
6937
7131
|
case "end":
|
|
6938
|
-
return
|
|
7132
|
+
return _context41.stop();
|
|
6939
7133
|
}
|
|
6940
|
-
},
|
|
7134
|
+
}, _callee39, this, [[20, 31, 34, 37]]);
|
|
6941
7135
|
}));
|
|
6942
|
-
function removeProductsFromOrderDraft(
|
|
7136
|
+
function removeProductsFromOrderDraft(_x50, _x51) {
|
|
6943
7137
|
return _removeProductsFromOrderDraft.apply(this, arguments);
|
|
6944
7138
|
}
|
|
6945
7139
|
return removeProductsFromOrderDraft;
|
|
@@ -6947,18 +7141,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6947
7141
|
}, {
|
|
6948
7142
|
key: "removeProductFromOrder",
|
|
6949
7143
|
value: function () {
|
|
6950
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6951
|
-
return _regeneratorRuntime().wrap(function
|
|
6952
|
-
while (1) switch (
|
|
7144
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(identity, options) {
|
|
7145
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context42) {
|
|
7146
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
6953
7147
|
case 0:
|
|
6954
|
-
return
|
|
7148
|
+
return _context42.abrupt("return", this.removeProductsFromOrder([identity], options));
|
|
6955
7149
|
case 1:
|
|
6956
7150
|
case "end":
|
|
6957
|
-
return
|
|
7151
|
+
return _context42.stop();
|
|
6958
7152
|
}
|
|
6959
|
-
},
|
|
7153
|
+
}, _callee40, this);
|
|
6960
7154
|
}));
|
|
6961
|
-
function removeProductFromOrder(
|
|
7155
|
+
function removeProductFromOrder(_x52, _x53) {
|
|
6962
7156
|
return _removeProductFromOrder.apply(this, arguments);
|
|
6963
7157
|
}
|
|
6964
7158
|
return removeProductFromOrder;
|
|
@@ -6970,19 +7164,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6970
7164
|
}, {
|
|
6971
7165
|
key: "clearOrderCartLines",
|
|
6972
7166
|
value: (function () {
|
|
6973
|
-
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6974
|
-
var
|
|
6975
|
-
return _regeneratorRuntime().wrap(function
|
|
6976
|
-
while (1) switch (
|
|
7167
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41() {
|
|
7168
|
+
var _this49 = this;
|
|
7169
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context43) {
|
|
7170
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
6977
7171
|
case 0:
|
|
6978
|
-
return
|
|
6979
|
-
return
|
|
7172
|
+
return _context43.abrupt("return", this.queueCartCommand(function () {
|
|
7173
|
+
return _this49.clearOrderCartLinesDraft();
|
|
6980
7174
|
}));
|
|
6981
7175
|
case 1:
|
|
6982
7176
|
case "end":
|
|
6983
|
-
return
|
|
7177
|
+
return _context43.stop();
|
|
6984
7178
|
}
|
|
6985
|
-
},
|
|
7179
|
+
}, _callee41, this);
|
|
6986
7180
|
}));
|
|
6987
7181
|
function clearOrderCartLines() {
|
|
6988
7182
|
return _clearOrderCartLines.apply(this, arguments);
|
|
@@ -6992,10 +7186,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6992
7186
|
}, {
|
|
6993
7187
|
key: "clearOrderCartLinesDraft",
|
|
6994
7188
|
value: function () {
|
|
6995
|
-
var _clearOrderCartLinesDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7189
|
+
var _clearOrderCartLinesDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42() {
|
|
6996
7190
|
var mutation, tempOrder, promotionPayload;
|
|
6997
|
-
return _regeneratorRuntime().wrap(function
|
|
6998
|
-
while (1) switch (
|
|
7191
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context44) {
|
|
7192
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
6999
7193
|
case 0:
|
|
7000
7194
|
mutation = this.beginCartMutation();
|
|
7001
7195
|
tempOrder = mutation.draft;
|
|
@@ -7013,21 +7207,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7013
7207
|
});
|
|
7014
7208
|
}
|
|
7015
7209
|
if (!mutation.commit) {
|
|
7016
|
-
|
|
7210
|
+
_context44.next = 15;
|
|
7017
7211
|
break;
|
|
7018
7212
|
}
|
|
7019
|
-
|
|
7213
|
+
_context44.next = 14;
|
|
7020
7214
|
return mutation.commit();
|
|
7021
7215
|
case 14:
|
|
7022
|
-
tempOrder =
|
|
7216
|
+
tempOrder = _context44.sent;
|
|
7023
7217
|
case 15:
|
|
7024
|
-
|
|
7218
|
+
_context44.next = 17;
|
|
7025
7219
|
return this.evaluatePromotion();
|
|
7026
7220
|
case 17:
|
|
7027
|
-
promotionPayload =
|
|
7221
|
+
promotionPayload = _context44.sent;
|
|
7028
7222
|
this.applyDiscount();
|
|
7029
7223
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
7030
|
-
|
|
7224
|
+
_context44.next = 22;
|
|
7031
7225
|
return this.recalculateSummary({
|
|
7032
7226
|
createIfMissing: true
|
|
7033
7227
|
});
|
|
@@ -7035,12 +7229,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7035
7229
|
this.persistTempOrder();
|
|
7036
7230
|
this.emitPromotionApplied(promotionPayload);
|
|
7037
7231
|
this.logInfo('clearOrderCartLines success', {});
|
|
7038
|
-
return
|
|
7232
|
+
return _context44.abrupt("return", tempOrder);
|
|
7039
7233
|
case 26:
|
|
7040
7234
|
case "end":
|
|
7041
|
-
return
|
|
7235
|
+
return _context44.stop();
|
|
7042
7236
|
}
|
|
7043
|
-
},
|
|
7237
|
+
}, _callee42, this);
|
|
7044
7238
|
}));
|
|
7045
7239
|
function clearOrderCartLinesDraft() {
|
|
7046
7240
|
return _clearOrderCartLinesDraft.apply(this, arguments);
|
|
@@ -7053,11 +7247,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7053
7247
|
}, {
|
|
7054
7248
|
key: "clearOrderForSettlementSwitch",
|
|
7055
7249
|
value: (function () {
|
|
7056
|
-
var _clearOrderForSettlementSwitch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7250
|
+
var _clearOrderForSettlementSwitch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43() {
|
|
7057
7251
|
var _this$store$discount22, _this$store$discount23;
|
|
7058
7252
|
var tempOrder;
|
|
7059
|
-
return _regeneratorRuntime().wrap(function
|
|
7060
|
-
while (1) switch (
|
|
7253
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context45) {
|
|
7254
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
7061
7255
|
case 0:
|
|
7062
7256
|
tempOrder = this.ensureTempOrder();
|
|
7063
7257
|
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
@@ -7077,28 +7271,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7077
7271
|
productsByUid: {}
|
|
7078
7272
|
});
|
|
7079
7273
|
}
|
|
7080
|
-
|
|
7274
|
+
_context45.next = 16;
|
|
7081
7275
|
return (_this$store$discount22 = this.store.discount) === null || _this$store$discount22 === void 0 ? void 0 : _this$store$discount22.setDiscountList([]);
|
|
7082
7276
|
case 16:
|
|
7083
|
-
|
|
7277
|
+
_context45.next = 18;
|
|
7084
7278
|
return (_this$store$discount23 = this.store.discount) === null || _this$store$discount23 === void 0 ? void 0 : _this$store$discount23.setOriginalDiscountList([]);
|
|
7085
7279
|
case 18:
|
|
7086
7280
|
this.hasActiveCustomerBoundDiscount = false;
|
|
7087
7281
|
this.lastUnfulfilledPromotions = [];
|
|
7088
7282
|
this.lastGiftActions = null;
|
|
7089
|
-
|
|
7283
|
+
_context45.next = 23;
|
|
7090
7284
|
return this.recalculateSummary({
|
|
7091
7285
|
createIfMissing: true
|
|
7092
7286
|
});
|
|
7093
7287
|
case 23:
|
|
7094
7288
|
this.persistTempOrder();
|
|
7095
7289
|
this.logInfo('clearOrderForSettlementSwitch success', {});
|
|
7096
|
-
return
|
|
7290
|
+
return _context45.abrupt("return", tempOrder);
|
|
7097
7291
|
case 26:
|
|
7098
7292
|
case "end":
|
|
7099
|
-
return
|
|
7293
|
+
return _context45.stop();
|
|
7100
7294
|
}
|
|
7101
|
-
},
|
|
7295
|
+
}, _callee43, this);
|
|
7102
7296
|
}));
|
|
7103
7297
|
function clearOrderForSettlementSwitch() {
|
|
7104
7298
|
return _clearOrderForSettlementSwitch.apply(this, arguments);
|
|
@@ -7136,17 +7330,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7136
7330
|
}, {
|
|
7137
7331
|
key: "applyLocalPrintOrderNumbers",
|
|
7138
7332
|
value: function () {
|
|
7139
|
-
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7333
|
+
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(order) {
|
|
7140
7334
|
var tempOrder, shopOrderNumber, shopFullOrderNumber;
|
|
7141
|
-
return _regeneratorRuntime().wrap(function
|
|
7142
|
-
while (1) switch (
|
|
7335
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context46) {
|
|
7336
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
7143
7337
|
case 0:
|
|
7144
7338
|
tempOrder = this.ensureTempOrder();
|
|
7145
7339
|
if (!(!order || _typeof(order) !== 'object')) {
|
|
7146
|
-
|
|
7340
|
+
_context46.next = 3;
|
|
7147
7341
|
break;
|
|
7148
7342
|
}
|
|
7149
|
-
return
|
|
7343
|
+
return _context46.abrupt("return", tempOrder);
|
|
7150
7344
|
case 3:
|
|
7151
7345
|
shopOrderNumber = order.shop_order_number;
|
|
7152
7346
|
shopFullOrderNumber = order.shop_full_order_number;
|
|
@@ -7157,17 +7351,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7157
7351
|
tempOrder.shop_full_order_number = String(shopFullOrderNumber);
|
|
7158
7352
|
}
|
|
7159
7353
|
this.persistTempOrder();
|
|
7160
|
-
|
|
7354
|
+
_context46.next = 10;
|
|
7161
7355
|
return this.saveDraft();
|
|
7162
7356
|
case 10:
|
|
7163
|
-
return
|
|
7357
|
+
return _context46.abrupt("return", tempOrder);
|
|
7164
7358
|
case 11:
|
|
7165
7359
|
case "end":
|
|
7166
|
-
return
|
|
7360
|
+
return _context46.stop();
|
|
7167
7361
|
}
|
|
7168
|
-
},
|
|
7362
|
+
}, _callee44, this);
|
|
7169
7363
|
}));
|
|
7170
|
-
function applyLocalPrintOrderNumbers(
|
|
7364
|
+
function applyLocalPrintOrderNumbers(_x54) {
|
|
7171
7365
|
return _applyLocalPrintOrderNumbers.apply(this, arguments);
|
|
7172
7366
|
}
|
|
7173
7367
|
return applyLocalPrintOrderNumbers;
|
|
@@ -7175,35 +7369,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7175
7369
|
}, {
|
|
7176
7370
|
key: "saveTempOrderAsDraft",
|
|
7177
7371
|
value: function () {
|
|
7178
|
-
var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7372
|
+
var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(params) {
|
|
7179
7373
|
var _params$cacheId2, _this$otherParams8, _this$otherParams9, _this$otherParams10, _params$type, _this$otherParams11, _payload$products;
|
|
7180
7374
|
var tempOrder, latestSummary, payload;
|
|
7181
|
-
return _regeneratorRuntime().wrap(function
|
|
7182
|
-
while (1) switch (
|
|
7375
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context47) {
|
|
7376
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
7183
7377
|
case 0:
|
|
7184
7378
|
tempOrder = this.ensureTempOrder();
|
|
7185
7379
|
this.ensureExternalSaleNumber(tempOrder);
|
|
7186
7380
|
this.persistTempOrder();
|
|
7187
|
-
|
|
7381
|
+
_context47.next = 5;
|
|
7188
7382
|
return this.recalculateSummary({
|
|
7189
7383
|
createIfMissing: true
|
|
7190
7384
|
});
|
|
7191
7385
|
case 5:
|
|
7192
|
-
|
|
7193
|
-
if (
|
|
7194
|
-
|
|
7386
|
+
_context47.t1 = _context47.sent;
|
|
7387
|
+
if (_context47.t1) {
|
|
7388
|
+
_context47.next = 8;
|
|
7195
7389
|
break;
|
|
7196
7390
|
}
|
|
7197
|
-
|
|
7391
|
+
_context47.t1 = this.store.summary;
|
|
7198
7392
|
case 8:
|
|
7199
|
-
|
|
7200
|
-
if (
|
|
7201
|
-
|
|
7393
|
+
_context47.t0 = _context47.t1;
|
|
7394
|
+
if (_context47.t0) {
|
|
7395
|
+
_context47.next = 11;
|
|
7202
7396
|
break;
|
|
7203
7397
|
}
|
|
7204
|
-
|
|
7398
|
+
_context47.t0 = createEmptySummary();
|
|
7205
7399
|
case 11:
|
|
7206
|
-
latestSummary =
|
|
7400
|
+
latestSummary = _context47.t0;
|
|
7207
7401
|
payload = buildSubmitPayload({
|
|
7208
7402
|
tempOrder: tempOrder,
|
|
7209
7403
|
cacheId: (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId,
|
|
@@ -7224,17 +7418,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7224
7418
|
externalSaleNumber: payload.external_sale_number,
|
|
7225
7419
|
productsCount: ((_payload$products = payload.products) === null || _payload$products === void 0 ? void 0 : _payload$products.length) || 0
|
|
7226
7420
|
});
|
|
7227
|
-
return
|
|
7421
|
+
return _context47.abrupt("return", this.request.post('/order/sales/draft', payload, {
|
|
7228
7422
|
osServer: true,
|
|
7229
7423
|
customToast: function customToast() {}
|
|
7230
7424
|
}));
|
|
7231
7425
|
case 18:
|
|
7232
7426
|
case "end":
|
|
7233
|
-
return
|
|
7427
|
+
return _context47.stop();
|
|
7234
7428
|
}
|
|
7235
|
-
},
|
|
7429
|
+
}, _callee45, this);
|
|
7236
7430
|
}));
|
|
7237
|
-
function saveTempOrderAsDraft(
|
|
7431
|
+
function saveTempOrderAsDraft(_x55) {
|
|
7238
7432
|
return _saveTempOrderAsDraft.apply(this, arguments);
|
|
7239
7433
|
}
|
|
7240
7434
|
return saveTempOrderAsDraft;
|
|
@@ -7248,18 +7442,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7248
7442
|
}, {
|
|
7249
7443
|
key: "submitTempOrder",
|
|
7250
7444
|
value: (function () {
|
|
7251
|
-
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7252
|
-
return _regeneratorRuntime().wrap(function
|
|
7253
|
-
while (1) switch (
|
|
7445
|
+
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(params) {
|
|
7446
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context48) {
|
|
7447
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
7254
7448
|
case 0:
|
|
7255
|
-
return
|
|
7449
|
+
return _context48.abrupt("return", this.runSubmitTempOrder(params));
|
|
7256
7450
|
case 1:
|
|
7257
7451
|
case "end":
|
|
7258
|
-
return
|
|
7452
|
+
return _context48.stop();
|
|
7259
7453
|
}
|
|
7260
|
-
},
|
|
7454
|
+
}, _callee46, this);
|
|
7261
7455
|
}));
|
|
7262
|
-
function submitTempOrder(
|
|
7456
|
+
function submitTempOrder(_x56) {
|
|
7263
7457
|
return _submitTempOrder.apply(this, arguments);
|
|
7264
7458
|
}
|
|
7265
7459
|
return submitTempOrder;
|
|
@@ -7267,20 +7461,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7267
7461
|
}, {
|
|
7268
7462
|
key: "submitTempOrderAsync",
|
|
7269
7463
|
value: function () {
|
|
7270
|
-
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7271
|
-
return _regeneratorRuntime().wrap(function
|
|
7272
|
-
while (1) switch (
|
|
7464
|
+
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(params) {
|
|
7465
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context49) {
|
|
7466
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
7273
7467
|
case 0:
|
|
7274
|
-
return
|
|
7468
|
+
return _context49.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
7275
7469
|
syncMode: true
|
|
7276
7470
|
})));
|
|
7277
7471
|
case 1:
|
|
7278
7472
|
case "end":
|
|
7279
|
-
return
|
|
7473
|
+
return _context49.stop();
|
|
7280
7474
|
}
|
|
7281
|
-
},
|
|
7475
|
+
}, _callee47, this);
|
|
7282
7476
|
}));
|
|
7283
|
-
function submitTempOrderAsync(
|
|
7477
|
+
function submitTempOrderAsync(_x57) {
|
|
7284
7478
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
7285
7479
|
}
|
|
7286
7480
|
return submitTempOrderAsync;
|
|
@@ -7288,15 +7482,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7288
7482
|
}, {
|
|
7289
7483
|
key: "runSubmitTempOrder",
|
|
7290
7484
|
value: function () {
|
|
7291
|
-
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7485
|
+
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
|
|
7292
7486
|
var _params$cacheId3, _this$otherParams12, _ref93, _ref94, _submitSnapshot$busin, _this$otherParams13, _this$otherParams14, _submitSnapshot$type;
|
|
7293
7487
|
var tempOrder, isOnlineStorePlatform, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, shouldOverridePaymentStatus, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, isLocalPendingSubmit, salesNotesState, submittedOrderId, resultRecord;
|
|
7294
|
-
return _regeneratorRuntime().wrap(function
|
|
7295
|
-
while (1) switch (
|
|
7488
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context50) {
|
|
7489
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
7296
7490
|
case 0:
|
|
7297
7491
|
tempOrder = this.ensureTempOrder();
|
|
7298
7492
|
if (!requiresLocalPaymentRefresh(tempOrder)) {
|
|
7299
|
-
|
|
7493
|
+
_context50.next = 3;
|
|
7300
7494
|
break;
|
|
7301
7495
|
}
|
|
7302
7496
|
throw new Error(PAYMENT_REFRESH_MESSAGE);
|
|
@@ -7323,26 +7517,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7323
7517
|
}
|
|
7324
7518
|
}
|
|
7325
7519
|
this.persistTempOrder();
|
|
7326
|
-
|
|
7520
|
+
_context50.next = 13;
|
|
7327
7521
|
return this.recalculateSummary({
|
|
7328
7522
|
createIfMissing: true
|
|
7329
7523
|
});
|
|
7330
7524
|
case 13:
|
|
7331
|
-
|
|
7332
|
-
if (
|
|
7333
|
-
|
|
7525
|
+
_context50.t1 = _context50.sent;
|
|
7526
|
+
if (_context50.t1) {
|
|
7527
|
+
_context50.next = 16;
|
|
7334
7528
|
break;
|
|
7335
7529
|
}
|
|
7336
|
-
|
|
7530
|
+
_context50.t1 = this.store.summary;
|
|
7337
7531
|
case 16:
|
|
7338
|
-
|
|
7339
|
-
if (
|
|
7340
|
-
|
|
7532
|
+
_context50.t0 = _context50.t1;
|
|
7533
|
+
if (_context50.t0) {
|
|
7534
|
+
_context50.next = 19;
|
|
7341
7535
|
break;
|
|
7342
7536
|
}
|
|
7343
|
-
|
|
7537
|
+
_context50.t0 = createEmptySummary();
|
|
7344
7538
|
case 19:
|
|
7345
|
-
latestSummary =
|
|
7539
|
+
latestSummary = _context50.t0;
|
|
7346
7540
|
effectiveCacheId = (_params$cacheId3 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId3 !== void 0 ? _params$cacheId3 : this.cacheId;
|
|
7347
7541
|
hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
|
|
7348
7542
|
shouldOverridePaymentStatus = hasPaymentStatusOverride && !isOnlineStorePlatform && !shouldConfirmPendingVoucherPayments;
|
|
@@ -7378,10 +7572,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7378
7572
|
if (!payload.created_at) {
|
|
7379
7573
|
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
7380
7574
|
}
|
|
7381
|
-
|
|
7575
|
+
_context50.next = 31;
|
|
7382
7576
|
return this.saveDraft();
|
|
7383
7577
|
case 31:
|
|
7384
|
-
|
|
7578
|
+
_context50.prev = 31;
|
|
7385
7579
|
this.logInfo('submitTempOrder calling sales checkout', {
|
|
7386
7580
|
orderId: payload.order_id,
|
|
7387
7581
|
externalSaleNumber: payload.external_sale_number,
|
|
@@ -7391,43 +7585,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7391
7585
|
smallTicketDataFlag: payload.small_ticket_data_flag,
|
|
7392
7586
|
syncMode: payload.sync_mode
|
|
7393
7587
|
});
|
|
7394
|
-
|
|
7588
|
+
_context50.next = 35;
|
|
7395
7589
|
return this.submitSalesOrder({
|
|
7396
7590
|
query: payload
|
|
7397
7591
|
});
|
|
7398
7592
|
case 35:
|
|
7399
|
-
result =
|
|
7400
|
-
|
|
7593
|
+
result = _context50.sent;
|
|
7594
|
+
_context50.next = 48;
|
|
7401
7595
|
break;
|
|
7402
7596
|
case 38:
|
|
7403
|
-
|
|
7404
|
-
|
|
7405
|
-
backendErrorResponse = this.extractSubmitErrorResponse(
|
|
7597
|
+
_context50.prev = 38;
|
|
7598
|
+
_context50.t2 = _context50["catch"](31);
|
|
7599
|
+
backendErrorResponse = this.extractSubmitErrorResponse(_context50.t2);
|
|
7406
7600
|
if (!backendErrorResponse) {
|
|
7407
|
-
|
|
7601
|
+
_context50.next = 45;
|
|
7408
7602
|
break;
|
|
7409
7603
|
}
|
|
7410
7604
|
this.store.syncState = 'failed';
|
|
7411
7605
|
this.logSubmitBackendRejected(backendErrorResponse, payload);
|
|
7412
|
-
return
|
|
7606
|
+
return _context50.abrupt("return", backendErrorResponse);
|
|
7413
7607
|
case 45:
|
|
7414
7608
|
this.store.syncState = 'failed';
|
|
7415
7609
|
this.logError('submitTempOrder failed', {
|
|
7416
|
-
error:
|
|
7610
|
+
error: _context50.t2 instanceof Error ? _context50.t2.message : String(_context50.t2),
|
|
7417
7611
|
orderId: payload.order_id,
|
|
7418
7612
|
externalSaleNumber: payload.external_sale_number,
|
|
7419
7613
|
paymentStatus: payload.payment_status,
|
|
7420
7614
|
paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
|
|
7421
7615
|
});
|
|
7422
|
-
throw
|
|
7616
|
+
throw _context50.t2;
|
|
7423
7617
|
case 48:
|
|
7424
7618
|
if (!this.isSubmitResponseRejected(result)) {
|
|
7425
|
-
|
|
7619
|
+
_context50.next = 52;
|
|
7426
7620
|
break;
|
|
7427
7621
|
}
|
|
7428
7622
|
this.store.syncState = 'failed';
|
|
7429
7623
|
this.logSubmitBackendRejected(result, payload);
|
|
7430
|
-
return
|
|
7624
|
+
return _context50.abrupt("return", result);
|
|
7431
7625
|
case 52:
|
|
7432
7626
|
isLocalPendingSubmit = this.isLocalPendingSubmitResult(result); // need_sync=1 仅表示已进入本地同步队列,不能视为远端已确认 Notes。
|
|
7433
7627
|
if (Object.prototype.hasOwnProperty.call(payload, 'notes') && !isLocalPendingSubmit) {
|
|
@@ -7443,12 +7637,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7443
7637
|
})
|
|
7444
7638
|
});
|
|
7445
7639
|
if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
|
|
7446
|
-
|
|
7640
|
+
_context50.next = 61;
|
|
7447
7641
|
break;
|
|
7448
7642
|
}
|
|
7449
7643
|
tempOrder.order_id = submittedOrderId;
|
|
7450
7644
|
resultRecord = result;
|
|
7451
|
-
|
|
7645
|
+
_context50.next = 61;
|
|
7452
7646
|
return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
|
|
7453
7647
|
case 61:
|
|
7454
7648
|
if (isLocalPendingSubmit) {
|
|
@@ -7456,14 +7650,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7456
7650
|
} else if (submittedOrderId === null || submittedOrderId === undefined) {
|
|
7457
7651
|
this.store.syncState = 'submitted';
|
|
7458
7652
|
}
|
|
7459
|
-
return
|
|
7653
|
+
return _context50.abrupt("return", result);
|
|
7460
7654
|
case 63:
|
|
7461
7655
|
case "end":
|
|
7462
|
-
return
|
|
7656
|
+
return _context50.stop();
|
|
7463
7657
|
}
|
|
7464
|
-
},
|
|
7658
|
+
}, _callee48, this, [[31, 38]]);
|
|
7465
7659
|
}));
|
|
7466
|
-
function runSubmitTempOrder(
|
|
7660
|
+
function runSubmitTempOrder(_x58) {
|
|
7467
7661
|
return _runSubmitTempOrder.apply(this, arguments);
|
|
7468
7662
|
}
|
|
7469
7663
|
return runSubmitTempOrder;
|
|
@@ -7471,10 +7665,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7471
7665
|
}, {
|
|
7472
7666
|
key: "markLocalOrderSynced",
|
|
7473
7667
|
value: function () {
|
|
7474
|
-
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7668
|
+
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(orderId, remoteOrder) {
|
|
7475
7669
|
var tempOrder;
|
|
7476
|
-
return _regeneratorRuntime().wrap(function
|
|
7477
|
-
while (1) switch (
|
|
7670
|
+
return _regeneratorRuntime().wrap(function _callee49$(_context51) {
|
|
7671
|
+
while (1) switch (_context51.prev = _context51.next) {
|
|
7478
7672
|
case 0:
|
|
7479
7673
|
tempOrder = this.ensureTempOrder();
|
|
7480
7674
|
tempOrder.order_id = orderId;
|
|
@@ -7482,15 +7676,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7482
7676
|
this.store.lastOrderInfo = remoteOrder;
|
|
7483
7677
|
this.store.syncState = 'submitted';
|
|
7484
7678
|
this.persistTempOrder();
|
|
7485
|
-
|
|
7679
|
+
_context51.next = 8;
|
|
7486
7680
|
return this.saveDraft();
|
|
7487
7681
|
case 8:
|
|
7488
7682
|
case "end":
|
|
7489
|
-
return
|
|
7683
|
+
return _context51.stop();
|
|
7490
7684
|
}
|
|
7491
|
-
},
|
|
7685
|
+
}, _callee49, this);
|
|
7492
7686
|
}));
|
|
7493
|
-
function markLocalOrderSynced(
|
|
7687
|
+
function markLocalOrderSynced(_x59, _x60) {
|
|
7494
7688
|
return _markLocalOrderSynced.apply(this, arguments);
|
|
7495
7689
|
}
|
|
7496
7690
|
return markLocalOrderSynced;
|
|
@@ -7533,10 +7727,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7533
7727
|
value: function extractSubmitErrorResponse(error) {
|
|
7534
7728
|
var _error$response,
|
|
7535
7729
|
_error$response2,
|
|
7536
|
-
|
|
7730
|
+
_this50 = this;
|
|
7537
7731
|
var candidates = [error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.body, error === null || error === void 0 ? void 0 : error.body];
|
|
7538
7732
|
return candidates.find(function (candidate) {
|
|
7539
|
-
return
|
|
7733
|
+
return _this50.isSubmitErrorResponse(candidate);
|
|
7540
7734
|
}) || null;
|
|
7541
7735
|
}
|
|
7542
7736
|
}, {
|
|
@@ -7563,33 +7757,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7563
7757
|
}, {
|
|
7564
7758
|
key: "syncPaymentsToOrder",
|
|
7565
7759
|
value: function () {
|
|
7566
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7567
|
-
var
|
|
7760
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
|
|
7761
|
+
var _this51 = this,
|
|
7568
7762
|
_params$confirmPendin;
|
|
7569
7763
|
var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, enhancePayload, submitParams, submitResult;
|
|
7570
|
-
return _regeneratorRuntime().wrap(function
|
|
7571
|
-
while (1) switch (
|
|
7764
|
+
return _regeneratorRuntime().wrap(function _callee50$(_context52) {
|
|
7765
|
+
while (1) switch (_context52.prev = _context52.next) {
|
|
7572
7766
|
case 0:
|
|
7573
7767
|
tempOrder = this.ensureTempOrder();
|
|
7574
7768
|
needsPaymentNumber = (params.payments || []).some(function (payment) {
|
|
7575
7769
|
return String(payment.payment_number || '').trim() === '';
|
|
7576
7770
|
});
|
|
7577
7771
|
if (!needsPaymentNumber) {
|
|
7578
|
-
|
|
7772
|
+
_context52.next = 8;
|
|
7579
7773
|
break;
|
|
7580
7774
|
}
|
|
7581
|
-
|
|
7775
|
+
_context52.next = 5;
|
|
7582
7776
|
return this.getPaymentNumberDevicePrefixAsync();
|
|
7583
7777
|
case 5:
|
|
7584
|
-
|
|
7585
|
-
|
|
7778
|
+
_context52.t0 = _context52.sent;
|
|
7779
|
+
_context52.next = 9;
|
|
7586
7780
|
break;
|
|
7587
7781
|
case 8:
|
|
7588
|
-
|
|
7782
|
+
_context52.t0 = 'LOCAL';
|
|
7589
7783
|
case 9:
|
|
7590
|
-
devicePrefix =
|
|
7784
|
+
devicePrefix = _context52.t0;
|
|
7591
7785
|
mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
|
|
7592
|
-
return
|
|
7786
|
+
return _this51.normalizePaymentSource(payment, {
|
|
7593
7787
|
defaultPaid: false,
|
|
7594
7788
|
devicePrefix: devicePrefix
|
|
7595
7789
|
});
|
|
@@ -7602,20 +7796,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7602
7796
|
tempOrder.payments = effectivePayments;
|
|
7603
7797
|
tempOrder.payment_status = paymentStatus;
|
|
7604
7798
|
this.persistTempOrder();
|
|
7605
|
-
|
|
7799
|
+
_context52.next = 21;
|
|
7606
7800
|
return this.saveDraft();
|
|
7607
7801
|
case 21:
|
|
7608
7802
|
if (params.submitWhenPaid) {
|
|
7609
|
-
|
|
7803
|
+
_context52.next = 23;
|
|
7610
7804
|
break;
|
|
7611
7805
|
}
|
|
7612
|
-
return
|
|
7806
|
+
return _context52.abrupt("return", completion);
|
|
7613
7807
|
case 23:
|
|
7614
7808
|
if (!(this.store.syncState === 'submitting')) {
|
|
7615
|
-
|
|
7809
|
+
_context52.next = 25;
|
|
7616
7810
|
break;
|
|
7617
7811
|
}
|
|
7618
|
-
return
|
|
7812
|
+
return _context52.abrupt("return", completion);
|
|
7619
7813
|
case 25:
|
|
7620
7814
|
this.store.syncState = 'submitting';
|
|
7621
7815
|
paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
|
|
@@ -7635,32 +7829,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7635
7829
|
enhancePayload: enhancePayload
|
|
7636
7830
|
};
|
|
7637
7831
|
if (!(params.checkoutSyncTaskEnabled === false)) {
|
|
7638
|
-
|
|
7832
|
+
_context52.next = 35;
|
|
7639
7833
|
break;
|
|
7640
7834
|
}
|
|
7641
|
-
|
|
7835
|
+
_context52.next = 32;
|
|
7642
7836
|
return this.submitTempOrderAsync(submitParams);
|
|
7643
7837
|
case 32:
|
|
7644
|
-
|
|
7645
|
-
|
|
7838
|
+
_context52.t1 = _context52.sent;
|
|
7839
|
+
_context52.next = 38;
|
|
7646
7840
|
break;
|
|
7647
7841
|
case 35:
|
|
7648
|
-
|
|
7842
|
+
_context52.next = 37;
|
|
7649
7843
|
return this.submitTempOrder(submitParams);
|
|
7650
7844
|
case 37:
|
|
7651
|
-
|
|
7845
|
+
_context52.t1 = _context52.sent;
|
|
7652
7846
|
case 38:
|
|
7653
|
-
submitResult =
|
|
7654
|
-
return
|
|
7847
|
+
submitResult = _context52.t1;
|
|
7848
|
+
return _context52.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
|
|
7655
7849
|
submitResult: submitResult
|
|
7656
7850
|
}));
|
|
7657
7851
|
case 40:
|
|
7658
7852
|
case "end":
|
|
7659
|
-
return
|
|
7853
|
+
return _context52.stop();
|
|
7660
7854
|
}
|
|
7661
|
-
},
|
|
7855
|
+
}, _callee50, this);
|
|
7662
7856
|
}));
|
|
7663
|
-
function syncPaymentsToOrder(
|
|
7857
|
+
function syncPaymentsToOrder(_x61) {
|
|
7664
7858
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
7665
7859
|
}
|
|
7666
7860
|
return syncPaymentsToOrder;
|
|
@@ -7668,7 +7862,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7668
7862
|
}, {
|
|
7669
7863
|
key: "createOrder",
|
|
7670
7864
|
value: function createOrder(params) {
|
|
7671
|
-
var
|
|
7865
|
+
var _this52 = this;
|
|
7672
7866
|
var order = _objectSpread({
|
|
7673
7867
|
type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
|
|
7674
7868
|
// 要从外面拿,virtual
|
|
@@ -7700,7 +7894,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7700
7894
|
|
|
7701
7895
|
// 为预约补齐 holder 信息
|
|
7702
7896
|
if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
|
|
7703
|
-
ensureCartItemOriginHolder(item,
|
|
7897
|
+
ensureCartItemOriginHolder(item, _this52.window);
|
|
7704
7898
|
}
|
|
7705
7899
|
|
|
7706
7900
|
// 购物车是否为普通商品
|
|
@@ -7757,11 +7951,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7757
7951
|
}, {
|
|
7758
7952
|
key: "submitOrder",
|
|
7759
7953
|
value: function () {
|
|
7760
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7954
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(order) {
|
|
7761
7955
|
var _order$query$cartItem, _params$bookings, _params$relation_prod;
|
|
7762
7956
|
var url, query, fetchUrl, params;
|
|
7763
|
-
return _regeneratorRuntime().wrap(function
|
|
7764
|
-
while (1) switch (
|
|
7957
|
+
return _regeneratorRuntime().wrap(function _callee51$(_context53) {
|
|
7958
|
+
while (1) switch (_context53.prev = _context53.next) {
|
|
7765
7959
|
case 0:
|
|
7766
7960
|
this.logInfo('submitOrder called', {
|
|
7767
7961
|
url: order.url,
|
|
@@ -7781,14 +7975,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7781
7975
|
relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
|
|
7782
7976
|
scheduleDate: params.schedule_date
|
|
7783
7977
|
});
|
|
7784
|
-
return
|
|
7978
|
+
return _context53.abrupt("return", this.request.post(fetchUrl, params));
|
|
7785
7979
|
case 6:
|
|
7786
7980
|
case "end":
|
|
7787
|
-
return
|
|
7981
|
+
return _context53.stop();
|
|
7788
7982
|
}
|
|
7789
|
-
},
|
|
7983
|
+
}, _callee51, this);
|
|
7790
7984
|
}));
|
|
7791
|
-
function submitOrder(
|
|
7985
|
+
function submitOrder(_x62) {
|
|
7792
7986
|
return _submitOrder.apply(this, arguments);
|
|
7793
7987
|
}
|
|
7794
7988
|
return submitOrder;
|
|
@@ -7796,13 +7990,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7796
7990
|
}, {
|
|
7797
7991
|
key: "cancelOrder",
|
|
7798
7992
|
value: function () {
|
|
7799
|
-
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7993
|
+
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
|
|
7800
7994
|
var payload;
|
|
7801
|
-
return _regeneratorRuntime().wrap(function
|
|
7802
|
-
while (1) switch (
|
|
7995
|
+
return _regeneratorRuntime().wrap(function _callee52$(_context54) {
|
|
7996
|
+
while (1) switch (_context54.prev = _context54.next) {
|
|
7803
7997
|
case 0:
|
|
7804
7998
|
if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
|
|
7805
|
-
|
|
7999
|
+
_context54.next = 2;
|
|
7806
8000
|
break;
|
|
7807
8001
|
}
|
|
7808
8002
|
throw new Error('取消订单失败:order_ids 不能为空');
|
|
@@ -7818,16 +8012,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7818
8012
|
method: 'PUT',
|
|
7819
8013
|
orderIdsCount: params.order_ids.length
|
|
7820
8014
|
});
|
|
7821
|
-
return
|
|
8015
|
+
return _context54.abrupt("return", this.request.put('/order/update-status', payload, {
|
|
7822
8016
|
isShopApi: true
|
|
7823
8017
|
}));
|
|
7824
8018
|
case 5:
|
|
7825
8019
|
case "end":
|
|
7826
|
-
return
|
|
8020
|
+
return _context54.stop();
|
|
7827
8021
|
}
|
|
7828
|
-
},
|
|
8022
|
+
}, _callee52, this);
|
|
7829
8023
|
}));
|
|
7830
|
-
function cancelOrder(
|
|
8024
|
+
function cancelOrder(_x63) {
|
|
7831
8025
|
return _cancelOrder.apply(this, arguments);
|
|
7832
8026
|
}
|
|
7833
8027
|
return cancelOrder;
|
|
@@ -7835,19 +8029,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7835
8029
|
}, {
|
|
7836
8030
|
key: "changeBookingStatus",
|
|
7837
8031
|
value: function () {
|
|
7838
|
-
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8032
|
+
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(params) {
|
|
7839
8033
|
var url, payload;
|
|
7840
|
-
return _regeneratorRuntime().wrap(function
|
|
7841
|
-
while (1) switch (
|
|
8034
|
+
return _regeneratorRuntime().wrap(function _callee53$(_context55) {
|
|
8035
|
+
while (1) switch (_context55.prev = _context55.next) {
|
|
7842
8036
|
case 0:
|
|
7843
8037
|
if (params.booking_id) {
|
|
7844
|
-
|
|
8038
|
+
_context55.next = 2;
|
|
7845
8039
|
break;
|
|
7846
8040
|
}
|
|
7847
8041
|
throw new Error('变更预约状态失败:booking_id 不能为空');
|
|
7848
8042
|
case 2:
|
|
7849
8043
|
if (params.appointment_status) {
|
|
7850
|
-
|
|
8044
|
+
_context55.next = 4;
|
|
7851
8045
|
break;
|
|
7852
8046
|
}
|
|
7853
8047
|
throw new Error('变更预约状态失败:appointment_status 不能为空');
|
|
@@ -7862,16 +8056,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7862
8056
|
bookingId: params.booking_id,
|
|
7863
8057
|
appointmentStatus: params.appointment_status
|
|
7864
8058
|
});
|
|
7865
|
-
return
|
|
8059
|
+
return _context55.abrupt("return", this.request.put(url, payload, {
|
|
7866
8060
|
isShopApi: true
|
|
7867
8061
|
}));
|
|
7868
8062
|
case 8:
|
|
7869
8063
|
case "end":
|
|
7870
|
-
return
|
|
8064
|
+
return _context55.stop();
|
|
7871
8065
|
}
|
|
7872
|
-
},
|
|
8066
|
+
}, _callee53, this);
|
|
7873
8067
|
}));
|
|
7874
|
-
function changeBookingStatus(
|
|
8068
|
+
function changeBookingStatus(_x64) {
|
|
7875
8069
|
return _changeBookingStatus.apply(this, arguments);
|
|
7876
8070
|
}
|
|
7877
8071
|
return changeBookingStatus;
|
|
@@ -7889,11 +8083,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7889
8083
|
}, {
|
|
7890
8084
|
key: "createOrderByCheckout",
|
|
7891
8085
|
value: (function () {
|
|
7892
|
-
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8086
|
+
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(params) {
|
|
7893
8087
|
var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3;
|
|
7894
8088
|
var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, orderData, response;
|
|
7895
|
-
return _regeneratorRuntime().wrap(function
|
|
7896
|
-
while (1) switch (
|
|
8089
|
+
return _regeneratorRuntime().wrap(function _callee54$(_context56) {
|
|
8090
|
+
while (1) switch (_context56.prev = _context56.next) {
|
|
7897
8091
|
case 0:
|
|
7898
8092
|
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
7899
8093
|
onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
@@ -7918,7 +8112,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7918
8112
|
return p.code;
|
|
7919
8113
|
})) || []
|
|
7920
8114
|
});
|
|
7921
|
-
|
|
8115
|
+
_context56.prev = 3;
|
|
7922
8116
|
// 构建订单数据,设置默认值并允许 params 覆盖
|
|
7923
8117
|
orderData = _objectSpread({
|
|
7924
8118
|
sales_channel: 'my_pisel',
|
|
@@ -7966,32 +8160,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7966
8160
|
hasOrderId: !!orderData.order_id,
|
|
7967
8161
|
smallTicketDataFlag: orderData.small_ticket_data_flag
|
|
7968
8162
|
});
|
|
7969
|
-
|
|
8163
|
+
_context56.next = 10;
|
|
7970
8164
|
return this.request.post('/order/checkout', orderData, {
|
|
7971
8165
|
osServer: true,
|
|
7972
8166
|
customToast: function customToast() {}
|
|
7973
8167
|
});
|
|
7974
8168
|
case 10:
|
|
7975
|
-
response =
|
|
8169
|
+
response = _context56.sent;
|
|
7976
8170
|
this.logInfo('Order API called successfully', {
|
|
7977
8171
|
response: response
|
|
7978
8172
|
});
|
|
7979
|
-
return
|
|
8173
|
+
return _context56.abrupt("return", response);
|
|
7980
8174
|
case 15:
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
console.error('[Order] createOrderByCheckout 创建订单失败:',
|
|
8175
|
+
_context56.prev = 15;
|
|
8176
|
+
_context56.t0 = _context56["catch"](3);
|
|
8177
|
+
console.error('[Order] createOrderByCheckout 创建订单失败:', _context56.t0);
|
|
7984
8178
|
this.logInfo('Order API called failed', {
|
|
7985
|
-
error:
|
|
8179
|
+
error: _context56.t0 instanceof Error ? _context56.t0.message : String(_context56.t0)
|
|
7986
8180
|
});
|
|
7987
|
-
throw
|
|
8181
|
+
throw _context56.t0;
|
|
7988
8182
|
case 20:
|
|
7989
8183
|
case "end":
|
|
7990
|
-
return
|
|
8184
|
+
return _context56.stop();
|
|
7991
8185
|
}
|
|
7992
|
-
},
|
|
8186
|
+
}, _callee54, this, [[3, 15]]);
|
|
7993
8187
|
}));
|
|
7994
|
-
function createOrderByCheckout(
|
|
8188
|
+
function createOrderByCheckout(_x65) {
|
|
7995
8189
|
return _createOrderByCheckout.apply(this, arguments);
|
|
7996
8190
|
}
|
|
7997
8191
|
return createOrderByCheckout;
|
|
@@ -7999,25 +8193,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7999
8193
|
}, {
|
|
8000
8194
|
key: "submitSalesOrder",
|
|
8001
8195
|
value: function () {
|
|
8002
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8196
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(params) {
|
|
8003
8197
|
var url, query, fetchUrl, requestQuery;
|
|
8004
|
-
return _regeneratorRuntime().wrap(function
|
|
8005
|
-
while (1) switch (
|
|
8198
|
+
return _regeneratorRuntime().wrap(function _callee55$(_context57) {
|
|
8199
|
+
while (1) switch (_context57.prev = _context57.next) {
|
|
8006
8200
|
case 0:
|
|
8007
8201
|
url = params.url, query = params.query;
|
|
8008
8202
|
fetchUrl = url || '/order/sales/checkout';
|
|
8009
8203
|
requestQuery = this.isSalesCheckoutHandledByOsServer(fetchUrl) ? query : stripLocalEftposState(stripOsPrivatePayloadFields(query));
|
|
8010
|
-
return
|
|
8204
|
+
return _context57.abrupt("return", this.request.post(fetchUrl, requestQuery, {
|
|
8011
8205
|
osServer: true,
|
|
8012
8206
|
customToast: function customToast() {}
|
|
8013
8207
|
}));
|
|
8014
8208
|
case 4:
|
|
8015
8209
|
case "end":
|
|
8016
|
-
return
|
|
8210
|
+
return _context57.stop();
|
|
8017
8211
|
}
|
|
8018
|
-
},
|
|
8212
|
+
}, _callee55, this);
|
|
8019
8213
|
}));
|
|
8020
|
-
function submitSalesOrder(
|
|
8214
|
+
function submitSalesOrder(_x66) {
|
|
8021
8215
|
return _submitSalesOrder.apply(this, arguments);
|
|
8022
8216
|
}
|
|
8023
8217
|
return submitSalesOrder;
|
|
@@ -8025,8 +8219,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8025
8219
|
}, {
|
|
8026
8220
|
key: "isSalesCheckoutHandledByOsServer",
|
|
8027
8221
|
value: function isSalesCheckoutHandledByOsServer(fetchUrl) {
|
|
8028
|
-
var _this$
|
|
8029
|
-
var server = (_this$
|
|
8222
|
+
var _this$core3, _this$request;
|
|
8223
|
+
var server = (_this$core3 = this.core) === null || _this$core3 === void 0 ? void 0 : _this$core3.server;
|
|
8030
8224
|
if (!server || typeof server.hasRoute !== 'function') return false;
|
|
8031
8225
|
var requestBaseUrl = String(((_this$request = this.request) === null || _this$request === void 0 ? void 0 : _this$request.baseUrl) || '/shop').replace(/\/+$/, '');
|
|
8032
8226
|
if (!requestBaseUrl.startsWith('/')) return false;
|
|
@@ -8044,37 +8238,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8044
8238
|
}, {
|
|
8045
8239
|
key: "sendCustomerPayLink",
|
|
8046
8240
|
value: (function () {
|
|
8047
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8241
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(params) {
|
|
8048
8242
|
var _params$emails;
|
|
8049
8243
|
var orderIds;
|
|
8050
|
-
return _regeneratorRuntime().wrap(function
|
|
8051
|
-
while (1) switch (
|
|
8244
|
+
return _regeneratorRuntime().wrap(function _callee56$(_context58) {
|
|
8245
|
+
while (1) switch (_context58.prev = _context58.next) {
|
|
8052
8246
|
case 0:
|
|
8053
8247
|
orderIds = params.order_ids || params.orderIds || [];
|
|
8054
8248
|
if (orderIds.length) {
|
|
8055
|
-
|
|
8249
|
+
_context58.next = 3;
|
|
8056
8250
|
break;
|
|
8057
8251
|
}
|
|
8058
8252
|
throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
|
|
8059
8253
|
case 3:
|
|
8060
8254
|
if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
|
|
8061
|
-
|
|
8255
|
+
_context58.next = 5;
|
|
8062
8256
|
break;
|
|
8063
8257
|
}
|
|
8064
8258
|
throw new Error('发送支付链接需要至少一个邮箱');
|
|
8065
8259
|
case 5:
|
|
8066
|
-
return
|
|
8260
|
+
return _context58.abrupt("return", this.request.post('/order/batch-email', {
|
|
8067
8261
|
order_ids: orderIds,
|
|
8068
8262
|
notify_action: params.notify_action || 'order_payment_reminder',
|
|
8069
8263
|
emails: params.emails
|
|
8070
8264
|
}));
|
|
8071
8265
|
case 6:
|
|
8072
8266
|
case "end":
|
|
8073
|
-
return
|
|
8267
|
+
return _context58.stop();
|
|
8074
8268
|
}
|
|
8075
|
-
},
|
|
8269
|
+
}, _callee56, this);
|
|
8076
8270
|
}));
|
|
8077
|
-
function sendCustomerPayLink(
|
|
8271
|
+
function sendCustomerPayLink(_x67) {
|
|
8078
8272
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
8079
8273
|
}
|
|
8080
8274
|
return sendCustomerPayLink;
|
|
@@ -8082,14 +8276,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8082
8276
|
}, {
|
|
8083
8277
|
key: "getSalesOrderByLookup",
|
|
8084
8278
|
value: function () {
|
|
8085
|
-
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8279
|
+
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
|
|
8086
8280
|
var lookup, res;
|
|
8087
|
-
return _regeneratorRuntime().wrap(function
|
|
8088
|
-
while (1) switch (
|
|
8281
|
+
return _regeneratorRuntime().wrap(function _callee57$(_context59) {
|
|
8282
|
+
while (1) switch (_context59.prev = _context59.next) {
|
|
8089
8283
|
case 0:
|
|
8090
8284
|
lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
|
|
8091
8285
|
if (lookup) {
|
|
8092
|
-
|
|
8286
|
+
_context59.next = 3;
|
|
8093
8287
|
break;
|
|
8094
8288
|
}
|
|
8095
8289
|
throw new Error('加载销售详情需要 lookup');
|
|
@@ -8098,25 +8292,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8098
8292
|
if (lookup.startsWith('LOCAL_')) {
|
|
8099
8293
|
params.forceRemote = false;
|
|
8100
8294
|
}
|
|
8101
|
-
|
|
8295
|
+
_context59.next = 6;
|
|
8102
8296
|
return loadSalesOrderSnapshot(this.request, {
|
|
8103
8297
|
lookup: lookup,
|
|
8104
8298
|
transport: 'os-server',
|
|
8105
8299
|
forceRemote: params.forceRemote
|
|
8106
8300
|
});
|
|
8107
8301
|
case 6:
|
|
8108
|
-
res =
|
|
8302
|
+
res = _context59.sent;
|
|
8109
8303
|
if (res.code === 200) {
|
|
8110
8304
|
this.store.lastOrderInfo = res.data;
|
|
8111
8305
|
}
|
|
8112
|
-
return
|
|
8306
|
+
return _context59.abrupt("return", res);
|
|
8113
8307
|
case 9:
|
|
8114
8308
|
case "end":
|
|
8115
|
-
return
|
|
8309
|
+
return _context59.stop();
|
|
8116
8310
|
}
|
|
8117
|
-
},
|
|
8311
|
+
}, _callee57, this);
|
|
8118
8312
|
}));
|
|
8119
|
-
function getSalesOrderByLookup(
|
|
8313
|
+
function getSalesOrderByLookup(_x68) {
|
|
8120
8314
|
return _getSalesOrderByLookup.apply(this, arguments);
|
|
8121
8315
|
}
|
|
8122
8316
|
return getSalesOrderByLookup;
|
|
@@ -8130,11 +8324,49 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8130
8324
|
}, {
|
|
8131
8325
|
key: "hydrateTempOrderFromRecord",
|
|
8132
8326
|
value: (function () {
|
|
8133
|
-
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8134
|
-
var
|
|
8327
|
+
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(record, options) {
|
|
8328
|
+
var replacement, nextTempOrder;
|
|
8329
|
+
return _regeneratorRuntime().wrap(function _callee58$(_context60) {
|
|
8330
|
+
while (1) switch (_context60.prev = _context60.next) {
|
|
8331
|
+
case 0:
|
|
8332
|
+
replacement = this.beginOrderReplacement(options === null || options === void 0 ? void 0 : options.preserveOrderSessionId);
|
|
8333
|
+
_context60.prev = 1;
|
|
8334
|
+
_context60.next = 4;
|
|
8335
|
+
return this.prepareHydratedTempOrder(record, options, replacement);
|
|
8336
|
+
case 4:
|
|
8337
|
+
nextTempOrder = _context60.sent;
|
|
8338
|
+
this.assertOrderReplacementCurrent(replacement);
|
|
8339
|
+
this.persistTempOrder();
|
|
8340
|
+
this.completeOrderReplacement(replacement, nextTempOrder, options === null || options === void 0 ? void 0 : options.preserveOrderSessionId);
|
|
8341
|
+
return _context60.abrupt("return", nextTempOrder);
|
|
8342
|
+
case 11:
|
|
8343
|
+
_context60.prev = 11;
|
|
8344
|
+
_context60.t0 = _context60["catch"](1);
|
|
8345
|
+
_context60.next = 15;
|
|
8346
|
+
return this.rollbackOrderReplacement(replacement);
|
|
8347
|
+
case 15:
|
|
8348
|
+
throw _context60.t0;
|
|
8349
|
+
case 16:
|
|
8350
|
+
case "end":
|
|
8351
|
+
return _context60.stop();
|
|
8352
|
+
}
|
|
8353
|
+
}, _callee58, this, [[1, 11]]);
|
|
8354
|
+
}));
|
|
8355
|
+
function hydrateTempOrderFromRecord(_x69, _x70) {
|
|
8356
|
+
return _hydrateTempOrderFromRecord.apply(this, arguments);
|
|
8357
|
+
}
|
|
8358
|
+
return hydrateTempOrderFromRecord;
|
|
8359
|
+
}())
|
|
8360
|
+
}, {
|
|
8361
|
+
key: "prepareHydratedTempOrder",
|
|
8362
|
+
value: function () {
|
|
8363
|
+
var _prepareHydratedTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(record, options, replacement) {
|
|
8364
|
+
var _sourceRaw$_extend,
|
|
8365
|
+
_this53 = this,
|
|
8366
|
+
_this$store$discount26;
|
|
8135
8367
|
var sourceRaw, duplicateProductIdentityRepair, duplicateIdentityReadySource, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, isSessionStorageHydrate, isMergedSalesDetailHydrate, nextTempOrder, _this$store$discount24, _this$store$discount25, restoredSessionDiscounts, nextExtend, sourceLastOrderInfo, isDraftOrder, syntheticIdentityOptions, rawSummary, historicalDepositSnapshot, summarySurcharges, hadSyntheticDraftOrderId, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount27, _this$store$discount28;
|
|
8136
|
-
return _regeneratorRuntime().wrap(function
|
|
8137
|
-
while (1) switch (
|
|
8368
|
+
return _regeneratorRuntime().wrap(function _callee59$(_context61) {
|
|
8369
|
+
while (1) switch (_context61.prev = _context61.next) {
|
|
8138
8370
|
case 0:
|
|
8139
8371
|
sourceRaw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
|
|
8140
8372
|
duplicateProductIdentityRepair = repairDuplicateOrderProductLineIdentities(Array.isArray(sourceRaw.products) ? sourceRaw.products : [], (_sourceRaw$_extend = sourceRaw._extend) === null || _sourceRaw$_extend === void 0 ? void 0 : _sourceRaw$_extend.productsByUid);
|
|
@@ -8176,7 +8408,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8176
8408
|
this.store.tempOrder = nextTempOrder;
|
|
8177
8409
|
this.clearCustomerWalletRuntimeState();
|
|
8178
8410
|
if (!isSessionStorageHydrate) {
|
|
8179
|
-
|
|
8411
|
+
_context61.next = 32;
|
|
8180
8412
|
break;
|
|
8181
8413
|
}
|
|
8182
8414
|
// 会话快照是未提交购物车,不应获得编辑订单的 saved/edit 标记与服务端基线。
|
|
@@ -8192,24 +8424,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8192
8424
|
nextTempOrder.discount_list = restoredSessionDiscounts;
|
|
8193
8425
|
this.store.summary = createEmptySummary();
|
|
8194
8426
|
this.store.lastOrderInfo = undefined;
|
|
8195
|
-
|
|
8427
|
+
_context61.next = 24;
|
|
8196
8428
|
return (_this$store$discount24 = this.store.discount) === null || _this$store$discount24 === void 0 ? void 0 : _this$store$discount24.setOriginalDiscountList(cloneDeep(restoredSessionDiscounts));
|
|
8197
8429
|
case 24:
|
|
8198
|
-
|
|
8430
|
+
this.assertOrderReplacementCurrent(replacement);
|
|
8431
|
+
_context61.next = 27;
|
|
8199
8432
|
return (_this$store$discount25 = this.store.discount) === null || _this$store$discount25 === void 0 ? void 0 : _this$store$discount25.setDiscountList(cloneDeep(restoredSessionDiscounts));
|
|
8200
|
-
case
|
|
8433
|
+
case 27:
|
|
8434
|
+
this.assertOrderReplacementCurrent(replacement);
|
|
8201
8435
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
8202
|
-
|
|
8436
|
+
_context61.next = 31;
|
|
8203
8437
|
break;
|
|
8204
8438
|
}
|
|
8205
|
-
|
|
8439
|
+
_context61.next = 31;
|
|
8206
8440
|
return this.recalculateSummary({
|
|
8207
|
-
createIfMissing: false
|
|
8441
|
+
createIfMissing: false,
|
|
8442
|
+
isCurrentOrder: function isCurrentOrder() {
|
|
8443
|
+
return _this53.orderReplacement === replacement;
|
|
8444
|
+
}
|
|
8208
8445
|
});
|
|
8209
|
-
case 29:
|
|
8210
|
-
this.persistTempOrder();
|
|
8211
|
-
return _context59.abrupt("return", nextTempOrder);
|
|
8212
8446
|
case 31:
|
|
8447
|
+
return _context61.abrupt("return", nextTempOrder);
|
|
8448
|
+
case 32:
|
|
8213
8449
|
// Server list compatibility may synthesize order_id from external_sale_number; tempOrder must not.
|
|
8214
8450
|
sourceLastOrderInfo = sourceRaw.lastOrderInfo || sourceRaw;
|
|
8215
8451
|
isDraftOrder = Number(nextTempOrder.is_draft_order || 0) === 1;
|
|
@@ -8261,37 +8497,42 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8261
8497
|
nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
|
|
8262
8498
|
shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
|
|
8263
8499
|
if (shouldSkipEmptyDiscountSync) {
|
|
8264
|
-
|
|
8500
|
+
_context61.next = 58;
|
|
8265
8501
|
break;
|
|
8266
8502
|
}
|
|
8267
8503
|
OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
|
|
8268
|
-
|
|
8504
|
+
_context61.next = 54;
|
|
8269
8505
|
return (_this$store$discount27 = this.store.discount) === null || _this$store$discount27 === void 0 ? void 0 : _this$store$discount27.setOriginalDiscountList(nextDiscounts);
|
|
8270
|
-
case
|
|
8271
|
-
|
|
8506
|
+
case 54:
|
|
8507
|
+
this.assertOrderReplacementCurrent(replacement);
|
|
8508
|
+
_context61.next = 57;
|
|
8272
8509
|
return (_this$store$discount28 = this.store.discount) === null || _this$store$discount28 === void 0 ? void 0 : _this$store$discount28.setDiscountList(nextDiscounts);
|
|
8273
|
-
case
|
|
8510
|
+
case 57:
|
|
8511
|
+
this.assertOrderReplacementCurrent(replacement);
|
|
8512
|
+
case 58:
|
|
8274
8513
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
8275
|
-
|
|
8514
|
+
_context61.next = 61;
|
|
8276
8515
|
break;
|
|
8277
8516
|
}
|
|
8278
|
-
|
|
8517
|
+
_context61.next = 61;
|
|
8279
8518
|
return this.recalculateSummary({
|
|
8280
|
-
createIfMissing: false
|
|
8519
|
+
createIfMissing: false,
|
|
8520
|
+
isCurrentOrder: function isCurrentOrder() {
|
|
8521
|
+
return _this53.orderReplacement === replacement;
|
|
8522
|
+
}
|
|
8281
8523
|
});
|
|
8282
|
-
case
|
|
8283
|
-
|
|
8284
|
-
|
|
8285
|
-
case 60:
|
|
8524
|
+
case 61:
|
|
8525
|
+
return _context61.abrupt("return", nextTempOrder);
|
|
8526
|
+
case 62:
|
|
8286
8527
|
case "end":
|
|
8287
|
-
return
|
|
8528
|
+
return _context61.stop();
|
|
8288
8529
|
}
|
|
8289
|
-
},
|
|
8530
|
+
}, _callee59, this);
|
|
8290
8531
|
}));
|
|
8291
|
-
function
|
|
8292
|
-
return
|
|
8532
|
+
function prepareHydratedTempOrder(_x71, _x72, _x73) {
|
|
8533
|
+
return _prepareHydratedTempOrder.apply(this, arguments);
|
|
8293
8534
|
}
|
|
8294
|
-
return
|
|
8535
|
+
return prepareHydratedTempOrder;
|
|
8295
8536
|
}()
|
|
8296
8537
|
/**
|
|
8297
8538
|
* 兼容后端详情将 holder 放在 metadata.holder 的历史形态,统一补到运行时展示路径。
|
|
@@ -8299,7 +8540,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8299
8540
|
* @example
|
|
8300
8541
|
* this.normalizeHydratedBookingHolder({ metadata: { holder: { form_record: [1] } } });
|
|
8301
8542
|
*/
|
|
8302
|
-
)
|
|
8303
8543
|
}, {
|
|
8304
8544
|
key: "normalizeHydratedBookingHolder",
|
|
8305
8545
|
value: function normalizeHydratedBookingHolder(booking) {
|
|
@@ -8337,12 +8577,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8337
8577
|
if (!raw || _typeof(raw) !== 'object') return {};
|
|
8338
8578
|
if (!Array.isArray(raw.bookings) || !Array.isArray(raw.products)) return raw;
|
|
8339
8579
|
var bookingUidsByProductUid = new Map();
|
|
8340
|
-
var
|
|
8341
|
-
|
|
8580
|
+
var _iterator25 = _createForOfIteratorHelper(raw.products),
|
|
8581
|
+
_step25;
|
|
8342
8582
|
try {
|
|
8343
|
-
for (
|
|
8583
|
+
for (_iterator25.s(); !(_step25 = _iterator25.n()).done;) {
|
|
8344
8584
|
var _product$metadata13;
|
|
8345
|
-
var product =
|
|
8585
|
+
var product = _step25.value;
|
|
8346
8586
|
var productUid = getOrderCollectionUid('product', product);
|
|
8347
8587
|
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata13 = product.metadata) === null || _product$metadata13 === void 0 ? void 0 : _product$metadata13.booking_uid);
|
|
8348
8588
|
if (!productUid || bookingUid === undefined || bookingUid === null || bookingUid === '') {
|
|
@@ -8353,18 +8593,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8353
8593
|
bookingUidsByProductUid.set(productUid, candidates);
|
|
8354
8594
|
}
|
|
8355
8595
|
} catch (err) {
|
|
8356
|
-
|
|
8596
|
+
_iterator25.e(err);
|
|
8357
8597
|
} finally {
|
|
8358
|
-
|
|
8598
|
+
_iterator25.f();
|
|
8359
8599
|
}
|
|
8360
8600
|
if (bookingUidsByProductUid.size === 0) return raw;
|
|
8361
8601
|
var anonymousBookingCountByProductUid = new Map();
|
|
8362
|
-
var
|
|
8363
|
-
|
|
8602
|
+
var _iterator26 = _createForOfIteratorHelper(raw.bookings),
|
|
8603
|
+
_step26;
|
|
8364
8604
|
try {
|
|
8365
|
-
for (
|
|
8605
|
+
for (_iterator26.s(); !(_step26 = _iterator26.n()).done;) {
|
|
8366
8606
|
var _booking$metadata9;
|
|
8367
|
-
var booking =
|
|
8607
|
+
var booking = _step26.value;
|
|
8368
8608
|
if (getOrderCollectionPersistentId('booking', booking) || getOrderCollectionUid('booking', booking)) {
|
|
8369
8609
|
continue;
|
|
8370
8610
|
}
|
|
@@ -8374,9 +8614,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8374
8614
|
anonymousBookingCountByProductUid.set(key, (anonymousBookingCountByProductUid.get(key) || 0) + 1);
|
|
8375
8615
|
}
|
|
8376
8616
|
} catch (err) {
|
|
8377
|
-
|
|
8617
|
+
_iterator26.e(err);
|
|
8378
8618
|
} finally {
|
|
8379
|
-
|
|
8619
|
+
_iterator26.f();
|
|
8380
8620
|
}
|
|
8381
8621
|
return _objectSpread(_objectSpread({}, raw), {}, {
|
|
8382
8622
|
bookings: raw.bookings.map(function (booking) {
|
|
@@ -8402,7 +8642,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8402
8642
|
}, {
|
|
8403
8643
|
key: "normalizeTempOrderForRuntime",
|
|
8404
8644
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
8405
|
-
var
|
|
8645
|
+
var _this54 = this,
|
|
8406
8646
|
_raw$_extend;
|
|
8407
8647
|
var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
|
|
8408
8648
|
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
|
|
@@ -8430,12 +8670,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8430
8670
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
8431
8671
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
8432
8672
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
8433
|
-
return
|
|
8673
|
+
return _this54.normalizeHydratedOrderProduct(p, {
|
|
8434
8674
|
makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
|
|
8435
8675
|
});
|
|
8436
8676
|
}) : [];
|
|
8437
8677
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
8438
|
-
var booking =
|
|
8678
|
+
var booking = _this54.normalizeHydratedBookingHolder(b || {});
|
|
8439
8679
|
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
8440
8680
|
is_all: normalizeBookingIsAll(booking),
|
|
8441
8681
|
sub_type: normalizeBookingSubType(booking)
|
|
@@ -8481,14 +8721,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8481
8721
|
dirty: decodedSalesNotes.complete && ((restoredSalesNotesState === null || restoredSalesNotesState === void 0 ? void 0 : restoredSalesNotesState.dirty) === true || allowUnresolvedSalesNotes && hasUnresolvedSalesNoteOrderTarget)
|
|
8482
8722
|
};
|
|
8483
8723
|
var productsByUid = tempOrderExtend.productsByUid || {};
|
|
8484
|
-
var
|
|
8485
|
-
|
|
8724
|
+
var _iterator27 = _createForOfIteratorHelper(nextTempOrder.products.entries()),
|
|
8725
|
+
_step27;
|
|
8486
8726
|
try {
|
|
8487
|
-
for (
|
|
8727
|
+
for (_iterator27.s(); !(_step27 = _iterator27.n()).done;) {
|
|
8488
8728
|
var _product$metadata14, _ref95, _ref96, _existed$origin, _rawProduct$metadata;
|
|
8489
|
-
var
|
|
8490
|
-
index =
|
|
8491
|
-
product =
|
|
8729
|
+
var _step27$value = _slicedToArray(_step27.value, 2),
|
|
8730
|
+
index = _step27$value[0],
|
|
8731
|
+
product = _step27$value[1];
|
|
8492
8732
|
var uid = (_product$metadata14 = product.metadata) === null || _product$metadata14 === void 0 ? void 0 : _product$metadata14.unique_identification_number;
|
|
8493
8733
|
if (!uid) continue;
|
|
8494
8734
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
@@ -8509,14 +8749,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8509
8749
|
});
|
|
8510
8750
|
}
|
|
8511
8751
|
} catch (err) {
|
|
8512
|
-
|
|
8752
|
+
_iterator27.e(err);
|
|
8513
8753
|
} finally {
|
|
8514
|
-
|
|
8754
|
+
_iterator27.f();
|
|
8515
8755
|
}
|
|
8516
8756
|
tempOrderExtend.productsByUid = productsByUid;
|
|
8517
8757
|
this.hydrateLinkedBookingIdentity(nextTempOrder);
|
|
8518
8758
|
nextTempOrder.products.forEach(function (product) {
|
|
8519
|
-
return
|
|
8759
|
+
return _this54.sanitizeOrderProductForTempOrder(product);
|
|
8520
8760
|
});
|
|
8521
8761
|
if ((options === null || options === void 0 ? void 0 : options.ensureIdentity) !== false) {
|
|
8522
8762
|
this.ensureExternalSaleNumber(nextTempOrder);
|
|
@@ -8606,18 +8846,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8606
8846
|
var segments = [];
|
|
8607
8847
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
8608
8848
|
if (Array.isArray(sku.variant)) {
|
|
8609
|
-
var
|
|
8610
|
-
|
|
8849
|
+
var _iterator28 = _createForOfIteratorHelper(sku.variant),
|
|
8850
|
+
_step28;
|
|
8611
8851
|
try {
|
|
8612
|
-
for (
|
|
8613
|
-
var variant =
|
|
8852
|
+
for (_iterator28.s(); !(_step28 = _iterator28.n()).done;) {
|
|
8853
|
+
var variant = _step28.value;
|
|
8614
8854
|
var segment = this.formatHydratedNamePair(variant === null || variant === void 0 ? void 0 : variant.group, variant === null || variant === void 0 ? void 0 : variant.item);
|
|
8615
8855
|
if (segment) segments.push(segment);
|
|
8616
8856
|
}
|
|
8617
8857
|
} catch (err) {
|
|
8618
|
-
|
|
8858
|
+
_iterator28.e(err);
|
|
8619
8859
|
} finally {
|
|
8620
|
-
|
|
8860
|
+
_iterator28.f();
|
|
8621
8861
|
}
|
|
8622
8862
|
}
|
|
8623
8863
|
return segments.join(', ');
|
|
@@ -8645,7 +8885,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8645
8885
|
}, {
|
|
8646
8886
|
key: "normalizeHydratedOrderProduct",
|
|
8647
8887
|
value: function normalizeHydratedOrderProduct(product, options) {
|
|
8648
|
-
var
|
|
8888
|
+
var _this55 = this;
|
|
8649
8889
|
var row = _objectSpread({}, product || {});
|
|
8650
8890
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
8651
8891
|
row.num = row.product_quantity;
|
|
@@ -8653,7 +8893,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8653
8893
|
var productSku = ensureProductSku(row);
|
|
8654
8894
|
row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
|
|
8655
8895
|
option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
|
|
8656
|
-
return
|
|
8896
|
+
return _this55.normalizeHydratedProductOptionItem(optionItem || {});
|
|
8657
8897
|
}))
|
|
8658
8898
|
});
|
|
8659
8899
|
delete row["product_".concat('option', "_item")];
|
|
@@ -8707,33 +8947,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8707
8947
|
}, {
|
|
8708
8948
|
key: "getLastOrderInfo",
|
|
8709
8949
|
value: function getLastOrderInfo() {
|
|
8710
|
-
var _this$
|
|
8711
|
-
return (_this$
|
|
8950
|
+
var _this$store4;
|
|
8951
|
+
return (_this$store4 = this.store) === null || _this$store4 === void 0 ? void 0 : _this$store4.lastOrderInfo;
|
|
8712
8952
|
}
|
|
8713
8953
|
}, {
|
|
8714
8954
|
key: "getOrderInfo",
|
|
8715
8955
|
value: function () {
|
|
8716
|
-
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8956
|
+
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(order_id) {
|
|
8717
8957
|
var res;
|
|
8718
|
-
return _regeneratorRuntime().wrap(function
|
|
8719
|
-
while (1) switch (
|
|
8958
|
+
return _regeneratorRuntime().wrap(function _callee60$(_context62) {
|
|
8959
|
+
while (1) switch (_context62.prev = _context62.next) {
|
|
8720
8960
|
case 0:
|
|
8721
|
-
|
|
8961
|
+
_context62.next = 2;
|
|
8722
8962
|
return this.request.get("/order/sales/".concat(order_id), {
|
|
8723
8963
|
with: ['products', 'bookings', 'notes']
|
|
8724
8964
|
}, {
|
|
8725
8965
|
osServer: true
|
|
8726
8966
|
});
|
|
8727
8967
|
case 2:
|
|
8728
|
-
res =
|
|
8729
|
-
return
|
|
8968
|
+
res = _context62.sent;
|
|
8969
|
+
return _context62.abrupt("return", res);
|
|
8730
8970
|
case 4:
|
|
8731
8971
|
case "end":
|
|
8732
|
-
return
|
|
8972
|
+
return _context62.stop();
|
|
8733
8973
|
}
|
|
8734
|
-
},
|
|
8974
|
+
}, _callee60, this);
|
|
8735
8975
|
}));
|
|
8736
|
-
function getOrderInfo(
|
|
8976
|
+
function getOrderInfo(_x74) {
|
|
8737
8977
|
return _getOrderInfo.apply(this, arguments);
|
|
8738
8978
|
}
|
|
8739
8979
|
return getOrderInfo;
|
|
@@ -8769,69 +9009,69 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
8769
9009
|
addDiscountAmount(savedMap, discountKey, amount);
|
|
8770
9010
|
addDiscountAmount(isPersistedProduct || discount.order_discount_id != null ? editModeSavedMap : runtimeSavedMap, discountKey, amount);
|
|
8771
9011
|
};
|
|
8772
|
-
var
|
|
8773
|
-
|
|
9012
|
+
var _iterator29 = _createForOfIteratorHelper(productList),
|
|
9013
|
+
_step29;
|
|
8774
9014
|
try {
|
|
8775
|
-
for (
|
|
8776
|
-
var product =
|
|
9015
|
+
for (_iterator29.s(); !(_step29 = _iterator29.n()).done;) {
|
|
9016
|
+
var product = _step29.value;
|
|
8777
9017
|
var qty = product.num || 1;
|
|
8778
9018
|
var isPersistedProduct = Boolean(product.order_detail_id || product.orderDetailId || product.booking_id);
|
|
8779
|
-
var
|
|
8780
|
-
|
|
9019
|
+
var _iterator31 = _createForOfIteratorHelper(product.discount_list || []),
|
|
9020
|
+
_step31;
|
|
8781
9021
|
try {
|
|
8782
|
-
for (
|
|
8783
|
-
var pd =
|
|
9022
|
+
for (_iterator31.s(); !(_step31 = _iterator31.n()).done;) {
|
|
9023
|
+
var pd = _step31.value;
|
|
8784
9024
|
addProductDiscountAmount(pd, qty, isPersistedProduct);
|
|
8785
9025
|
}
|
|
8786
9026
|
} catch (err) {
|
|
8787
|
-
|
|
9027
|
+
_iterator31.e(err);
|
|
8788
9028
|
} finally {
|
|
8789
|
-
|
|
9029
|
+
_iterator31.f();
|
|
8790
9030
|
}
|
|
8791
|
-
var
|
|
8792
|
-
|
|
9031
|
+
var _iterator32 = _createForOfIteratorHelper(product.product_bundle || []),
|
|
9032
|
+
_step32;
|
|
8793
9033
|
try {
|
|
8794
|
-
for (
|
|
8795
|
-
var bundle =
|
|
9034
|
+
for (_iterator32.s(); !(_step32 = _iterator32.n()).done;) {
|
|
9035
|
+
var bundle = _step32.value;
|
|
8796
9036
|
var isPersistedBundleProduct = isPersistedProduct || Boolean((bundle === null || bundle === void 0 ? void 0 : bundle.order_detail_id) || (bundle === null || bundle === void 0 ? void 0 : bundle.orderDetailId) || (bundle === null || bundle === void 0 ? void 0 : bundle.booking_id));
|
|
8797
9037
|
var bundleQty = Number(qty) || 1;
|
|
8798
|
-
var
|
|
8799
|
-
|
|
9038
|
+
var _iterator33 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
|
|
9039
|
+
_step33;
|
|
8800
9040
|
try {
|
|
8801
|
-
for (
|
|
8802
|
-
var _pd =
|
|
9041
|
+
for (_iterator33.s(); !(_step33 = _iterator33.n()).done;) {
|
|
9042
|
+
var _pd = _step33.value;
|
|
8803
9043
|
addProductDiscountAmount(_pd, bundleQty, isPersistedBundleProduct);
|
|
8804
9044
|
}
|
|
8805
9045
|
} catch (err) {
|
|
8806
|
-
|
|
9046
|
+
_iterator33.e(err);
|
|
8807
9047
|
} finally {
|
|
8808
|
-
|
|
9048
|
+
_iterator33.f();
|
|
8809
9049
|
}
|
|
8810
9050
|
}
|
|
8811
9051
|
} catch (err) {
|
|
8812
|
-
|
|
9052
|
+
_iterator32.e(err);
|
|
8813
9053
|
} finally {
|
|
8814
|
-
|
|
9054
|
+
_iterator32.f();
|
|
8815
9055
|
}
|
|
8816
9056
|
}
|
|
8817
9057
|
} catch (err) {
|
|
8818
|
-
|
|
9058
|
+
_iterator29.e(err);
|
|
8819
9059
|
} finally {
|
|
8820
|
-
|
|
9060
|
+
_iterator29.f();
|
|
8821
9061
|
}
|
|
8822
|
-
var
|
|
8823
|
-
|
|
9062
|
+
var _iterator30 = _createForOfIteratorHelper(discountList),
|
|
9063
|
+
_step30;
|
|
8824
9064
|
try {
|
|
8825
|
-
for (
|
|
8826
|
-
var d =
|
|
9065
|
+
for (_iterator30.s(); !(_step30 = _iterator30.n()).done;) {
|
|
9066
|
+
var d = _step30.value;
|
|
8827
9067
|
var key = d.id;
|
|
8828
9068
|
var sourceMap = d.isEditMode ? editModeSavedMap : editModeDiscountKeys.has(key) ? runtimeSavedMap : savedMap;
|
|
8829
9069
|
d.savedAmount = d.isSelected && key != null && sourceMap.has(key) ? sourceMap.get(key).toNumber() : 0;
|
|
8830
9070
|
}
|
|
8831
9071
|
} catch (err) {
|
|
8832
|
-
|
|
9072
|
+
_iterator30.e(err);
|
|
8833
9073
|
} finally {
|
|
8834
|
-
|
|
9074
|
+
_iterator30.f();
|
|
8835
9075
|
}
|
|
8836
9076
|
}
|
|
8837
9077
|
}]);
|