@pisell/pisellos 2.2.276 → 2.2.800
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/core/index.d.ts +0 -2
- package/dist/core/index.js +0 -7
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +0 -4
- package/dist/model/strategy/adapter/promotion/adapter.js +0 -23
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
- package/dist/model/strategy/adapter/promotion/evaluator.js +6 -279
- package/dist/model/strategy/adapter/promotion/examples.d.ts +0 -86
- package/dist/model/strategy/adapter/promotion/examples.js +0 -99
- package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/model/strategy/adapter/promotion/type.d.ts +2 -90
- package/dist/model/strategy/adapter/promotion/type.js +0 -45
- package/dist/modules/OpenData/index.d.ts +0 -2
- package/dist/modules/OpenData/index.js +0 -8
- package/dist/modules/Order/index.d.ts +8 -28
- package/dist/modules/Order/index.js +496 -808
- package/dist/modules/Order/types.d.ts +1 -35
- package/dist/modules/Order/utils/orderCollectionIdentity.js +2 -7
- package/dist/modules/Order/utils.js +6 -10
- package/dist/modules/Payment/index.d.ts +0 -2
- package/dist/modules/Payment/index.js +49 -78
- package/dist/modules/Payment/types.d.ts +25 -104
- package/dist/modules/Payment/types.js +0 -17
- package/dist/modules/Payment/walletpass.d.ts +1 -38
- package/dist/modules/Payment/walletpass.js +114 -917
- package/dist/modules/Rules/index.d.ts +0 -3
- package/dist/modules/Rules/index.js +70 -100
- package/dist/server/index.d.ts +0 -25
- package/dist/server/index.js +1069 -2001
- package/dist/server/modules/index.d.ts +1 -1
- package/dist/server/modules/order/index.d.ts +4 -70
- package/dist/server/modules/order/index.js +728 -1816
- package/dist/server/modules/order/types.d.ts +3 -25
- package/dist/server/modules/order/types.js +1 -7
- package/dist/server/utils/small-ticket.js +2 -1
- package/dist/solution/BaseSales/index.d.ts +5 -104
- package/dist/solution/BaseSales/index.js +436 -1767
- package/dist/solution/BaseSales/types.d.ts +1 -55
- package/dist/solution/BaseSales/types.js +1 -2
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
- package/dist/solution/BaseSales/utils/cartPromotion.js +31 -90
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +4 -7
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +5 -21
- package/dist/solution/BookingTicket/index.js +56 -139
- package/dist/solution/BookingTicket/types.d.ts +0 -1
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -8
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +83 -173
- package/dist/solution/Sales/index.d.ts +0 -2
- package/dist/solution/Sales/index.js +4 -26
- package/dist/solution/ScanOrder/index.js +20 -31
- package/dist/solution/VenueBooking/index.d.ts +0 -1
- package/dist/solution/VenueBooking/index.js +19 -30
- package/dist/types/index.d.ts +0 -1
- package/lib/core/index.d.ts +0 -2
- package/lib/core/index.js +0 -4
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +0 -4
- package/lib/model/strategy/adapter/promotion/adapter.js +0 -20
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
- package/lib/model/strategy/adapter/promotion/evaluator.js +0 -235
- package/lib/model/strategy/adapter/promotion/examples.d.ts +0 -86
- package/lib/model/strategy/adapter/promotion/examples.js +0 -91
- package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +0 -2
- package/lib/model/strategy/adapter/promotion/type.d.ts +2 -90
- package/lib/model/strategy/adapter/promotion/type.js +0 -2
- package/lib/modules/OpenData/index.d.ts +0 -2
- package/lib/modules/OpenData/index.js +0 -5
- package/lib/modules/Order/index.d.ts +8 -28
- package/lib/modules/Order/index.js +69 -231
- package/lib/modules/Order/types.d.ts +1 -35
- package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -3
- package/lib/modules/Order/utils.js +4 -11
- package/lib/modules/Payment/index.d.ts +0 -2
- package/lib/modules/Payment/index.js +12 -33
- package/lib/modules/Payment/types.d.ts +25 -104
- package/lib/modules/Payment/types.js +0 -1
- package/lib/modules/Payment/walletpass.d.ts +1 -38
- package/lib/modules/Payment/walletpass.js +21 -730
- package/lib/modules/Rules/index.d.ts +0 -3
- package/lib/modules/Rules/index.js +9 -38
- package/lib/server/index.d.ts +0 -25
- package/lib/server/index.js +31 -726
- package/lib/server/modules/index.d.ts +1 -1
- package/lib/server/modules/order/index.d.ts +4 -70
- package/lib/server/modules/order/index.js +69 -818
- package/lib/server/modules/order/types.d.ts +3 -25
- package/lib/server/modules/order/types.js +0 -1
- package/lib/server/utils/small-ticket.js +1 -1
- package/lib/solution/BaseSales/index.d.ts +5 -104
- package/lib/solution/BaseSales/index.js +27 -858
- package/lib/solution/BaseSales/types.d.ts +1 -55
- package/lib/solution/BaseSales/types.js +1 -2
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
- package/lib/solution/BaseSales/utils/cartPromotion.js +12 -63
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -4
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +5 -21
- package/lib/solution/BookingTicket/index.js +13 -64
- package/lib/solution/BookingTicket/types.d.ts +0 -1
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -8
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +5 -37
- package/lib/solution/Sales/index.d.ts +0 -2
- package/lib/solution/Sales/index.js +6 -20
- package/lib/solution/ScanOrder/index.js +0 -8
- package/lib/solution/VenueBooking/index.d.ts +0 -1
- package/lib/solution/VenueBooking/index.js +0 -8
- package/lib/types/index.d.ts +0 -1
- package/package.json +1 -1
- package/dist/modules/Order/payment-utils.d.ts +0 -26
- package/dist/modules/Order/payment-utils.js +0 -225
- package/dist/utils/payment-number.d.ts +0 -9
- package/dist/utils/payment-number.js +0 -69
- package/lib/modules/Order/payment-utils.d.ts +0 -26
- package/lib/modules/Order/payment-utils.js +0 -224
- package/lib/utils/payment-number.d.ts +0 -9
- package/lib/utils/payment-number.js +0 -64
|
@@ -10,6 +10,8 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableTo
|
|
|
10
10
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
11
11
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
12
12
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
13
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
15
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
14
16
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
15
17
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
@@ -25,8 +27,6 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
|
25
27
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
26
28
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
27
29
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
28
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
29
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
30
30
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
31
31
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
32
32
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
@@ -35,8 +35,6 @@ import { OrderHooks } from "./types";
|
|
|
35
35
|
import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit, mergeOrderProductDisplayFields, resolveIsFormSubject } from "./utils";
|
|
36
36
|
import { isNormalProduct } from "../Product/utils";
|
|
37
37
|
import dayjs from 'dayjs';
|
|
38
|
-
import { ensureOrderPaymentNumber, mergeOrderPaymentRecord, resolveOrderPaymentIdentity } from "./payment-utils";
|
|
39
|
-
import { resolvePaymentNumberDevicePrefix, resolvePaymentNumberDevicePrefixFromDeviceId } from "../../utils/payment-number";
|
|
40
38
|
import { processCartPromotion, appendPromotionTags as _appendPromotionTags, getOrderProductUid as getPromotionUid } from "../../solution/BaseSales/utils/cartPromotion";
|
|
41
39
|
import { buildProductLineFingerprint, getProductIdentityIndex, getSafeProductNum, isIdentityMatch, normalizeOrderProduct } from "../../solution/ScanOrder/utils";
|
|
42
40
|
import { syncManualProductDiscountProductNum } from "./utils/manualProductDiscount";
|
|
@@ -70,22 +68,6 @@ function isManualProductDiscountProduct(product) {
|
|
|
70
68
|
}
|
|
71
69
|
var ORDER_PAYMENT_STATUS_PAID = 'paid';
|
|
72
70
|
var ORDER_PAYMENT_STATUS_PENDING = 'payment_pending';
|
|
73
|
-
var CUSTOMER_PROMOTION_DISCOUNT_TAGS = new Set(['good_pass', 'product_discount_card', 'discount_card']);
|
|
74
|
-
function isCustomerPromotionDiscount(discount) {
|
|
75
|
-
return CUSTOMER_PROMOTION_DISCOUNT_TAGS.has(String((discount === null || discount === void 0 ? void 0 : discount.tag) || (discount === null || discount === void 0 ? void 0 : discount.type) || '').toLowerCase());
|
|
76
|
-
}
|
|
77
|
-
function markScannedDiscounts(discountList, scannedDiscountList) {
|
|
78
|
-
var scannedIds = new Set(scannedDiscountList.map(function (discount) {
|
|
79
|
-
return discount === null || discount === void 0 ? void 0 : discount.id;
|
|
80
|
-
}).filter(function (id) {
|
|
81
|
-
return id !== undefined && id !== null;
|
|
82
|
-
}).map(String));
|
|
83
|
-
return discountList.map(function (discount) {
|
|
84
|
-
return scannedIds.has(String(discount === null || discount === void 0 ? void 0 : discount.id)) ? _objectSpread(_objectSpread({}, discount), {}, {
|
|
85
|
-
isScan: true
|
|
86
|
-
}) : discount;
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
71
|
function isVoucherPaymentRecord(payment) {
|
|
90
72
|
return (payment === null || payment === void 0 ? void 0 : payment.voucher_id) !== undefined && Number(payment.voucher_id) !== 0;
|
|
91
73
|
}
|
|
@@ -101,10 +83,6 @@ function isPaidPaymentRecord(payment) {
|
|
|
101
83
|
function isCommittedVoucherPaymentRecord(payment) {
|
|
102
84
|
return isVoucherPaymentRecord(payment) && (payment === null || payment === void 0 ? void 0 : payment.status) !== 'voided' && (hasSyncedOrderPaymentRecord(payment) || isPaidPaymentRecord(payment));
|
|
103
85
|
}
|
|
104
|
-
function getVoucherPaymentLifecycleKey(payment) {
|
|
105
|
-
if (!isVoucherPaymentRecord(payment)) return null;
|
|
106
|
-
return "".concat(String(payment.voucher_id), "::").concat(String(payment.status || ''));
|
|
107
|
-
}
|
|
108
86
|
export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
109
87
|
_inherits(OrderModule, _BaseModule);
|
|
110
88
|
var _super = _createSuper(OrderModule);
|
|
@@ -119,7 +97,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
119
97
|
_defineProperty(_assertThisInitialized(_this), "logger", void 0);
|
|
120
98
|
// LoggerManager 实例
|
|
121
99
|
_defineProperty(_assertThisInitialized(_this), "window", void 0);
|
|
122
|
-
_defineProperty(_assertThisInitialized(_this), "appPlugin", void 0);
|
|
123
100
|
_defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
|
|
124
101
|
_defineProperty(_assertThisInitialized(_this), "salesSummaryModuleName", void 0);
|
|
125
102
|
_defineProperty(_assertThisInitialized(_this), "rulesHooksOverride", void 0);
|
|
@@ -312,7 +289,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
312
289
|
value: function () {
|
|
313
290
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
314
291
|
var _otherParams$rules, _otherParams$order, _otherParams$hooks;
|
|
315
|
-
var app, otherParams;
|
|
292
|
+
var appPlugin, app, otherParams;
|
|
316
293
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
317
294
|
while (1) switch (_context.prev = _context.next) {
|
|
318
295
|
case 0:
|
|
@@ -328,14 +305,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
328
305
|
this.store.availableWalletIds = [];
|
|
329
306
|
}
|
|
330
307
|
this.request = this.core.getPlugin('request');
|
|
331
|
-
|
|
332
|
-
if (
|
|
308
|
+
appPlugin = this.core.getPlugin('app');
|
|
309
|
+
if (appPlugin) {
|
|
333
310
|
_context.next = 9;
|
|
334
311
|
break;
|
|
335
312
|
}
|
|
336
313
|
throw new Error('Order 模块需要 app 插件支持');
|
|
337
314
|
case 9:
|
|
338
|
-
app =
|
|
315
|
+
app = appPlugin.getApp();
|
|
339
316
|
this.logger = app.logger;
|
|
340
317
|
this.window = this.core.getPlugin('window');
|
|
341
318
|
otherParams = options.otherParams || {};
|
|
@@ -688,7 +665,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
688
665
|
value: function () {
|
|
689
666
|
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(code, customerId) {
|
|
690
667
|
var _this$store$discount11, _tempOrder$holder, _this$store$summary;
|
|
691
|
-
var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref12, isAvailable, newDiscountList,
|
|
668
|
+
var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref12, isAvailable, newDiscountList, unavailableReason, _this$store$discount12;
|
|
692
669
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
693
670
|
while (1) switch (_context6.prev = _context6.next) {
|
|
694
671
|
case 0:
|
|
@@ -717,7 +694,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
717
694
|
return _context6.abrupt("return", {
|
|
718
695
|
type: 'clientCalc',
|
|
719
696
|
isAvailable: false,
|
|
720
|
-
isAccepted: false,
|
|
721
697
|
discountList: this.getDiscountList(),
|
|
722
698
|
scannedDiscountList: resultDiscountList,
|
|
723
699
|
unavailableReason: UnavailableReason.Unknown
|
|
@@ -730,7 +706,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
730
706
|
return _context6.abrupt("return", {
|
|
731
707
|
type: 'server',
|
|
732
708
|
isAvailable: false,
|
|
733
|
-
isAccepted: false,
|
|
734
709
|
discountList: this.getDiscountList(),
|
|
735
710
|
scannedDiscountList: resultDiscountList,
|
|
736
711
|
unavailableReasonKey: unavailableReasonKey
|
|
@@ -758,7 +733,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
758
733
|
return _context6.abrupt("return", {
|
|
759
734
|
type: 'clientCalc',
|
|
760
735
|
isAvailable: true,
|
|
761
|
-
isAccepted: true,
|
|
762
736
|
discountList: this.getDiscountList(),
|
|
763
737
|
scannedDiscountList: resultDiscountList
|
|
764
738
|
});
|
|
@@ -777,47 +751,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
777
751
|
}) || {
|
|
778
752
|
isAvailable: false,
|
|
779
753
|
discountList: this.getDiscountList()
|
|
780
|
-
}, isAvailable = _ref12.isAvailable, newDiscountList = _ref12.discountList,
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
retainedDiscountList = evaluatedDiscountList ? markScannedDiscounts(evaluatedDiscountList, withScanList) : normalizedNewDiscountList;
|
|
784
|
-
resolvedDiscountList = normalizedNewDiscountList || this.getDiscountList();
|
|
785
|
-
if (!(isAvailable && normalizedNewDiscountList)) {
|
|
786
|
-
_context6.next = 34;
|
|
754
|
+
}, isAvailable = _ref12.isAvailable, newDiscountList = _ref12.discountList, unavailableReason = _ref12.unavailableReason;
|
|
755
|
+
if (!(isAvailable && newDiscountList)) {
|
|
756
|
+
_context6.next = 26;
|
|
787
757
|
break;
|
|
788
758
|
}
|
|
789
|
-
|
|
790
|
-
return (_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 ? void 0 : _this$store$discount12.setDiscountList(normalizedNewDiscountList);
|
|
791
|
-
case 28:
|
|
759
|
+
(_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 || _this$store$discount12.setDiscountList(newDiscountList);
|
|
792
760
|
this.applyDiscount();
|
|
793
|
-
_context6.next =
|
|
794
|
-
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
795
|
-
case 31:
|
|
796
|
-
resolvedDiscountList = this.getDiscountList();
|
|
797
|
-
_context6.next = 40;
|
|
798
|
-
break;
|
|
799
|
-
case 34:
|
|
800
|
-
if (!(shouldRetainForLater && retainedDiscountList)) {
|
|
801
|
-
_context6.next = 40;
|
|
802
|
-
break;
|
|
803
|
-
}
|
|
804
|
-
_context6.next = 37;
|
|
805
|
-
return (_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.setDiscountList(retainedDiscountList);
|
|
806
|
-
case 37:
|
|
807
|
-
_context6.next = 39;
|
|
761
|
+
_context6.next = 26;
|
|
808
762
|
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
809
|
-
case
|
|
810
|
-
resolvedDiscountList = this.getDiscountList();
|
|
811
|
-
case 40:
|
|
763
|
+
case 26:
|
|
812
764
|
return _context6.abrupt("return", {
|
|
813
765
|
type: 'clientCalc',
|
|
814
766
|
isAvailable: isAvailable || false,
|
|
815
|
-
|
|
816
|
-
discountList: resolvedDiscountList,
|
|
767
|
+
discountList: newDiscountList || this.getDiscountList(),
|
|
817
768
|
scannedDiscountList: resultDiscountList,
|
|
818
769
|
unavailableReason: unavailableReason
|
|
819
770
|
});
|
|
820
|
-
case
|
|
771
|
+
case 27:
|
|
821
772
|
case "end":
|
|
822
773
|
return _context6.stop();
|
|
823
774
|
}
|
|
@@ -831,7 +782,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
831
782
|
}, {
|
|
832
783
|
key: "applyDiscount",
|
|
833
784
|
value: function applyDiscount(options) {
|
|
834
|
-
var _this$store$
|
|
785
|
+
var _this$store$discount13,
|
|
835
786
|
_this$store$summary2,
|
|
836
787
|
_this2 = this;
|
|
837
788
|
var tempOrder = this.store.tempOrder;
|
|
@@ -841,7 +792,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
841
792
|
if (!tempOrder) return;
|
|
842
793
|
this.syncLinkedBookingHoldersToProducts(tempOrder);
|
|
843
794
|
delete tempOrder.discount_list;
|
|
844
|
-
var discountList = ((_this$store$
|
|
795
|
+
var discountList = ((_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.getDiscountList()) || [];
|
|
845
796
|
var shouldSkipDiscountCalculation = this.shouldSkipDiscountCalculation(tempOrder);
|
|
846
797
|
if (shouldSkipDiscountCalculation) return;
|
|
847
798
|
var rulesModule = this.store.rules;
|
|
@@ -873,9 +824,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
873
824
|
}));
|
|
874
825
|
}
|
|
875
826
|
if (result !== null && result !== void 0 && result.discountList) {
|
|
876
|
-
var _this$store$
|
|
827
|
+
var _this$store$discount14;
|
|
877
828
|
OrderModule.populateSavedAmounts(result.productList || tempOrder.products, result.discountList);
|
|
878
|
-
(_this$store$
|
|
829
|
+
(_this$store$discount14 = this.store.discount) === null || _this$store$discount14 === void 0 || _this$store$discount14.setDiscountList(result.discountList);
|
|
879
830
|
}
|
|
880
831
|
this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(function (product) {
|
|
881
832
|
return _this2.productHasCustomerBoundDiscount(product);
|
|
@@ -1564,44 +1515,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1564
1515
|
var depositPaidAmount = this.calculateDepositPaidAmount(tempOrder.payments || []);
|
|
1565
1516
|
return depositPaidAmount.lt(depositAmount) ? 'deposit' : 'normal';
|
|
1566
1517
|
}
|
|
1567
|
-
}, {
|
|
1568
|
-
key: "getPaymentNumberAppData",
|
|
1569
|
-
value: function getPaymentNumberAppData(key) {
|
|
1570
|
-
var _appPlugin$getData, _app$models, _app$models$getStore, _app$models$getStore$, _app$models$getStore$2;
|
|
1571
|
-
var appPlugin = this.appPlugin;
|
|
1572
|
-
if (!appPlugin) return undefined;
|
|
1573
|
-
var getData = (_appPlugin$getData = appPlugin.getData) === null || _appPlugin$getData === void 0 ? void 0 : _appPlugin$getData.call(appPlugin);
|
|
1574
|
-
if (typeof getData === 'function') return getData(key);
|
|
1575
|
-
var app = appPlugin.getApp();
|
|
1576
|
-
var coreData = app === null || app === void 0 || (_app$models = app.models) === null || _app$models === void 0 || (_app$models$getStore = _app$models.getStore) === null || _app$models$getStore === void 0 || (_app$models$getStore$ = (_app$models$getStore$2 = _app$models$getStore.call(_app$models)).getDataByModel) === null || _app$models$getStore$ === void 0 ? void 0 : _app$models$getStore$.call(_app$models$getStore$2, 'core', 'core');
|
|
1577
|
-
return coreData === null || coreData === void 0 ? void 0 : coreData[key];
|
|
1578
|
-
}
|
|
1579
|
-
}, {
|
|
1580
|
-
key: "getPaymentNumberDevicePrefixSync",
|
|
1581
|
-
value: function getPaymentNumberDevicePrefixSync() {
|
|
1582
|
-
var _this7 = this;
|
|
1583
|
-
return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
|
|
1584
|
-
return _this7.getPaymentNumberAppData(key);
|
|
1585
|
-
});
|
|
1586
|
-
}
|
|
1587
|
-
}, {
|
|
1588
|
-
key: "getPaymentNumberDevicePrefixAsync",
|
|
1589
|
-
value: function getPaymentNumberDevicePrefixAsync() {
|
|
1590
|
-
var _this8 = this;
|
|
1591
|
-
return resolvePaymentNumberDevicePrefix(function (key) {
|
|
1592
|
-
return _this8.getPaymentNumberAppData(key);
|
|
1593
|
-
});
|
|
1594
|
-
}
|
|
1595
1518
|
}, {
|
|
1596
1519
|
key: "normalizePaymentSource",
|
|
1597
1520
|
value: function normalizePaymentSource(payment, options) {
|
|
1598
1521
|
var _ref18, _paymentRecord$origin;
|
|
1599
1522
|
var paymentRecord = payment;
|
|
1600
1523
|
var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
|
|
1601
|
-
|
|
1524
|
+
if (!metadata.unique_payment_number) {
|
|
1525
|
+
metadata.unique_payment_number = createUuidV4();
|
|
1526
|
+
}
|
|
1527
|
+
var normalized = _objectSpread(_objectSpread({}, paymentRecord), {}, {
|
|
1602
1528
|
metadata: metadata,
|
|
1603
1529
|
origin_amount: (_ref18 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref18 !== void 0 ? _ref18 : '0.00'
|
|
1604
|
-
})
|
|
1530
|
+
});
|
|
1605
1531
|
if (paymentRecord.status !== undefined) {
|
|
1606
1532
|
normalized.status = paymentRecord.status;
|
|
1607
1533
|
} else if ((options === null || options === void 0 ? void 0 : options.defaultPaid) !== false) {
|
|
@@ -1719,16 +1645,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1719
1645
|
}, {
|
|
1720
1646
|
key: "calculatePaidPaymentSummary",
|
|
1721
1647
|
value: function calculatePaidPaymentSummary(payments) {
|
|
1722
|
-
var
|
|
1648
|
+
var _this7 = this;
|
|
1723
1649
|
return (payments || []).reduce(function (summary, payment) {
|
|
1724
1650
|
var paymentRecord = payment;
|
|
1725
1651
|
if (!isPaidPaymentRecord(paymentRecord)) return summary;
|
|
1726
1652
|
return {
|
|
1727
1653
|
customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
|
|
1728
|
-
orderPaidAmount: summary.orderPaidAmount.plus(
|
|
1729
|
-
gapPaidAmount: summary.gapPaidAmount.plus(
|
|
1730
|
-
payServiceChargeAmount: summary.payServiceChargeAmount.plus(
|
|
1731
|
-
roundingAmount: summary.roundingAmount.plus(
|
|
1654
|
+
orderPaidAmount: summary.orderPaidAmount.plus(_this7.calculatePaymentOrderAmount(paymentRecord)),
|
|
1655
|
+
gapPaidAmount: summary.gapPaidAmount.plus(_this7.calculatePaymentGapAmount(paymentRecord)),
|
|
1656
|
+
payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this7.calculatePaymentServiceFee(paymentRecord)),
|
|
1657
|
+
roundingAmount: summary.roundingAmount.plus(_this7.calculatePaymentRoundingAmount(paymentRecord))
|
|
1732
1658
|
};
|
|
1733
1659
|
}, {
|
|
1734
1660
|
customerPaidAmount: new Decimal(0),
|
|
@@ -1930,15 +1856,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1930
1856
|
}, {
|
|
1931
1857
|
key: "normalizeFingerprintValue",
|
|
1932
1858
|
value: function normalizeFingerprintValue(value) {
|
|
1933
|
-
var
|
|
1859
|
+
var _this8 = this;
|
|
1934
1860
|
if (Array.isArray(value)) {
|
|
1935
1861
|
return value.map(function (item) {
|
|
1936
|
-
return
|
|
1862
|
+
return _this8.normalizeFingerprintValue(item);
|
|
1937
1863
|
});
|
|
1938
1864
|
}
|
|
1939
1865
|
if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
|
|
1940
1866
|
return Object.keys(value).sort().reduce(function (result, key) {
|
|
1941
|
-
result[key] =
|
|
1867
|
+
result[key] = _this8.normalizeFingerprintValue(value[key]);
|
|
1942
1868
|
return result;
|
|
1943
1869
|
}, {});
|
|
1944
1870
|
}
|
|
@@ -1953,7 +1879,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1953
1879
|
_sku$barcode,
|
|
1954
1880
|
_ref19,
|
|
1955
1881
|
_sku$variant_id,
|
|
1956
|
-
|
|
1882
|
+
_this9 = this;
|
|
1957
1883
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
1958
1884
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
1959
1885
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -1987,7 +1913,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1987
1913
|
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,
|
|
1988
1914
|
option_group_item_id: (_ref21 = (_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 && _ref21 !== void 0 ? _ref21 : null,
|
|
1989
1915
|
num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
|
|
1990
|
-
add_price:
|
|
1916
|
+
add_price: _this9.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)
|
|
1991
1917
|
};
|
|
1992
1918
|
})
|
|
1993
1919
|
}),
|
|
@@ -1997,8 +1923,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1997
1923
|
bundle_product_id: (_ref22 = (_ref23 = (_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 && _ref23 !== void 0 ? _ref23 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref22 !== void 0 ? _ref22 : null,
|
|
1998
1924
|
bundle_variant_id: (_ref24 = (_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 && _ref24 !== void 0 ? _ref24 : 0,
|
|
1999
1925
|
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),
|
|
2000
|
-
price:
|
|
2001
|
-
bundle_selling_price:
|
|
1926
|
+
price: _this9.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
|
|
1927
|
+
bundle_selling_price: _this9.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
|
|
2002
1928
|
price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
|
|
2003
1929
|
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 : ''
|
|
2004
1930
|
};
|
|
@@ -2008,7 +1934,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2008
1934
|
return {
|
|
2009
1935
|
type: (_ref25 = (_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 && _ref25 !== void 0 ? _ref25 : '',
|
|
2010
1936
|
discount_id: (_ref26 = (_ref27 = (_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 && _ref27 !== void 0 ? _ref27 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref26 !== void 0 ? _ref26 : null,
|
|
2011
|
-
amount:
|
|
1937
|
+
amount: _this9.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2012
1938
|
};
|
|
2013
1939
|
}))
|
|
2014
1940
|
};
|
|
@@ -2016,9 +1942,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2016
1942
|
}, {
|
|
2017
1943
|
key: "buildOrderProductsFingerprint",
|
|
2018
1944
|
value: function buildOrderProductsFingerprint(products) {
|
|
2019
|
-
var
|
|
1945
|
+
var _this10 = this;
|
|
2020
1946
|
var items = (products || []).map(function (product) {
|
|
2021
|
-
return
|
|
1947
|
+
return _this10.buildProductFingerprintItem(product);
|
|
2022
1948
|
});
|
|
2023
1949
|
items.sort(function (left, right) {
|
|
2024
1950
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -2040,7 +1966,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2040
1966
|
_sku$barcode2,
|
|
2041
1967
|
_ref29,
|
|
2042
1968
|
_sku$variant_id2,
|
|
2043
|
-
|
|
1969
|
+
_this11 = this;
|
|
2044
1970
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
2045
1971
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
2046
1972
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -2071,7 +1997,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2071
1997
|
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,
|
|
2072
1998
|
option_group_item_id: (_ref31 = (_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 && _ref31 !== void 0 ? _ref31 : null,
|
|
2073
1999
|
num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
|
|
2074
|
-
add_price:
|
|
2000
|
+
add_price: _this11.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)
|
|
2075
2001
|
};
|
|
2076
2002
|
})
|
|
2077
2003
|
}),
|
|
@@ -2085,14 +2011,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2085
2011
|
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),
|
|
2086
2012
|
price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
|
|
2087
2013
|
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 : '',
|
|
2088
|
-
option:
|
|
2014
|
+
option: _this11.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
|
|
2089
2015
|
var _ref37, _option$id3, _option$option_group_5, _ref38, _option$option_group_6, _option$num3, _option$add_price3;
|
|
2090
2016
|
return {
|
|
2091
2017
|
id: (_ref37 = (_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 && _ref37 !== void 0 ? _ref37 : null,
|
|
2092
2018
|
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,
|
|
2093
2019
|
option_group_item_id: (_ref38 = (_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 && _ref38 !== void 0 ? _ref38 : null,
|
|
2094
2020
|
num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
|
|
2095
|
-
add_price:
|
|
2021
|
+
add_price: _this11.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)
|
|
2096
2022
|
};
|
|
2097
2023
|
}))
|
|
2098
2024
|
};
|
|
@@ -2102,7 +2028,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2102
2028
|
return {
|
|
2103
2029
|
type: (_ref39 = (_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 && _ref39 !== void 0 ? _ref39 : '',
|
|
2104
2030
|
discount_id: (_ref40 = (_ref41 = (_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 && _ref41 !== void 0 ? _ref41 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref40 !== void 0 ? _ref40 : null,
|
|
2105
|
-
amount:
|
|
2031
|
+
amount: _this11.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2106
2032
|
};
|
|
2107
2033
|
}))
|
|
2108
2034
|
};
|
|
@@ -2110,9 +2036,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2110
2036
|
}, {
|
|
2111
2037
|
key: "buildOrderProductsStructuralFingerprint",
|
|
2112
2038
|
value: function buildOrderProductsStructuralFingerprint(products) {
|
|
2113
|
-
var
|
|
2039
|
+
var _this12 = this;
|
|
2114
2040
|
var items = (products || []).map(function (product) {
|
|
2115
|
-
return
|
|
2041
|
+
return _this12.buildProductStructuralFingerprintItem(product);
|
|
2116
2042
|
});
|
|
2117
2043
|
items.sort(function (left, right) {
|
|
2118
2044
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -2329,7 +2255,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2329
2255
|
}, {
|
|
2330
2256
|
key: "restoreOrder",
|
|
2331
2257
|
value: function restoreOrder() {
|
|
2332
|
-
var _this$store$
|
|
2258
|
+
var _this$store$discount15, _this$store$discount16;
|
|
2333
2259
|
this.logInfo('restoreOrder start', {});
|
|
2334
2260
|
var freshTempOrder = this.createDefaultTempOrderInstance();
|
|
2335
2261
|
this.ensureExternalSaleNumber(freshTempOrder);
|
|
@@ -2337,8 +2263,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2337
2263
|
this.store.summary = createEmptySummary();
|
|
2338
2264
|
this.store.lastOrderInfo = undefined;
|
|
2339
2265
|
this.store.syncState = undefined;
|
|
2340
|
-
void ((_this$store$
|
|
2341
|
-
void ((_this$store$
|
|
2266
|
+
void ((_this$store$discount15 = this.store.discount) === null || _this$store$discount15 === void 0 ? void 0 : _this$store$discount15.setOriginalDiscountList([]));
|
|
2267
|
+
void ((_this$store$discount16 = this.store.discount) === null || _this$store$discount16 === void 0 ? void 0 : _this$store$discount16.setDiscountList([]));
|
|
2342
2268
|
this.persistTempOrder();
|
|
2343
2269
|
return freshTempOrder;
|
|
2344
2270
|
}
|
|
@@ -2540,9 +2466,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2540
2466
|
}, {
|
|
2541
2467
|
key: "sanitizeTempOrderProducts",
|
|
2542
2468
|
value: function sanitizeTempOrderProducts(tempOrder) {
|
|
2543
|
-
var
|
|
2469
|
+
var _this13 = this;
|
|
2544
2470
|
tempOrder.products = (tempOrder.products || []).map(function (product) {
|
|
2545
|
-
return
|
|
2471
|
+
return _this13.sanitizeOrderProductForTempOrder(product);
|
|
2546
2472
|
});
|
|
2547
2473
|
}
|
|
2548
2474
|
}, {
|
|
@@ -2645,7 +2571,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2645
2571
|
}, {
|
|
2646
2572
|
key: "syncLinkedBookingHoldersToProducts",
|
|
2647
2573
|
value: function syncLinkedBookingHoldersToProducts(tempOrder) {
|
|
2648
|
-
var
|
|
2574
|
+
var _this14 = this;
|
|
2649
2575
|
var bookings = tempOrder.bookings || [];
|
|
2650
2576
|
var products = tempOrder.products || [];
|
|
2651
2577
|
if (!bookings.length || !products.length) return;
|
|
@@ -2670,7 +2596,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2670
2596
|
var bookingUid = product.booking_uid || ((_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid);
|
|
2671
2597
|
var linkedBooking = (productUid !== undefined && productUid !== null && String(productUid) !== '' ? bookingByProductUid.get(String(productUid)) : undefined) || (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '' ? bookingByBookingUid.get(String(bookingUid)) : undefined);
|
|
2672
2598
|
if (linkedBooking) {
|
|
2673
|
-
|
|
2599
|
+
_this14.setProductHolderFromBooking(product, linkedBooking);
|
|
2674
2600
|
}
|
|
2675
2601
|
});
|
|
2676
2602
|
}
|
|
@@ -2798,9 +2724,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2798
2724
|
}, {
|
|
2799
2725
|
key: "findBookingIndexByUniqueIdentificationNumber",
|
|
2800
2726
|
value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
|
|
2801
|
-
var
|
|
2727
|
+
var _this15 = this;
|
|
2802
2728
|
return (tempOrder.bookings || []).findIndex(function (booking) {
|
|
2803
|
-
return
|
|
2729
|
+
return _this15.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
|
|
2804
2730
|
});
|
|
2805
2731
|
}
|
|
2806
2732
|
}, {
|
|
@@ -2808,12 +2734,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2808
2734
|
value: function removeLinkedBookingsForProduct(tempOrder, product) {
|
|
2809
2735
|
var _product$metadata7,
|
|
2810
2736
|
_product$metadata8,
|
|
2811
|
-
|
|
2737
|
+
_this16 = this;
|
|
2812
2738
|
var productUid = (product === null || product === void 0 || (_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
2813
2739
|
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.booking_uid);
|
|
2814
2740
|
if (!productUid && !bookingUid) return;
|
|
2815
2741
|
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
2816
|
-
var currentBookingUid =
|
|
2742
|
+
var currentBookingUid = _this16.getBookingUniqueIdentificationNumber(booking);
|
|
2817
2743
|
if (bookingUid && currentBookingUid === String(bookingUid)) return false;
|
|
2818
2744
|
if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
|
|
2819
2745
|
return true;
|
|
@@ -3146,35 +3072,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3146
3072
|
}, {
|
|
3147
3073
|
key: "productHasCustomerBoundDiscount",
|
|
3148
3074
|
value: function productHasCustomerBoundDiscount(product) {
|
|
3149
|
-
var
|
|
3075
|
+
var _this17 = this;
|
|
3150
3076
|
if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
|
|
3151
|
-
return
|
|
3077
|
+
return _this17.isCustomerBoundDiscount(discount);
|
|
3152
3078
|
})) {
|
|
3153
3079
|
return true;
|
|
3154
3080
|
}
|
|
3155
3081
|
return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
|
|
3156
3082
|
return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
|
|
3157
|
-
return
|
|
3083
|
+
return _this17.isCustomerBoundDiscount(discount);
|
|
3158
3084
|
});
|
|
3159
3085
|
});
|
|
3160
3086
|
}
|
|
3161
3087
|
}, {
|
|
3162
3088
|
key: "shouldSkipDiscountCalculation",
|
|
3163
3089
|
value: function shouldSkipDiscountCalculation(tempOrder) {
|
|
3164
|
-
var _this$store$
|
|
3165
|
-
_this$store$
|
|
3166
|
-
|
|
3090
|
+
var _this$store$discount17,
|
|
3091
|
+
_this$store$discount18,
|
|
3092
|
+
_this18 = this;
|
|
3167
3093
|
if (this.hasActiveCustomerBoundDiscount) return false;
|
|
3168
|
-
var discountList = ((_this$store$
|
|
3094
|
+
var discountList = ((_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 || (_this$store$discount18 = _this$store$discount17.getDiscountList) === null || _this$store$discount18 === void 0 ? void 0 : _this$store$discount18.call(_this$store$discount17)) || [];
|
|
3169
3095
|
if (discountList.length > 0) return false;
|
|
3170
3096
|
return !(tempOrder.products || []).some(function (product) {
|
|
3171
|
-
return
|
|
3097
|
+
return _this18.productHasCustomerBoundDiscount(product);
|
|
3172
3098
|
});
|
|
3173
3099
|
}
|
|
3174
3100
|
}, {
|
|
3175
3101
|
key: "clearCustomerBoundDiscounts",
|
|
3176
3102
|
value: function clearCustomerBoundDiscounts(tempOrder) {
|
|
3177
|
-
var
|
|
3103
|
+
var _this19 = this,
|
|
3178
3104
|
_discountModule$getDi,
|
|
3179
3105
|
_discountModule$getOr,
|
|
3180
3106
|
_discountModule$setDi,
|
|
@@ -3183,7 +3109,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3183
3109
|
var filterDiscountList = function filterDiscountList(discountList) {
|
|
3184
3110
|
if (!Array.isArray(discountList)) return [];
|
|
3185
3111
|
return discountList.filter(function (discount) {
|
|
3186
|
-
var shouldRemove =
|
|
3112
|
+
var shouldRemove = _this19.isCustomerBoundDiscount(discount);
|
|
3187
3113
|
if (shouldRemove) didRemoveCustomerBoundDiscount = true;
|
|
3188
3114
|
return !shouldRemove;
|
|
3189
3115
|
});
|
|
@@ -3210,12 +3136,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3210
3136
|
var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
|
|
3211
3137
|
var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
|
|
3212
3138
|
var nextDiscounts = currentDiscounts.filter(function (discount) {
|
|
3213
|
-
if (
|
|
3214
|
-
return !
|
|
3139
|
+
if (_this19.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
3140
|
+
return !_this19.isCustomerBoundDiscount(discount);
|
|
3215
3141
|
});
|
|
3216
3142
|
var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
|
|
3217
|
-
if (
|
|
3218
|
-
return !
|
|
3143
|
+
if (_this19.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
3144
|
+
return !_this19.isCustomerBoundDiscount(discount);
|
|
3219
3145
|
});
|
|
3220
3146
|
void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
|
|
3221
3147
|
void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
|
|
@@ -3369,71 +3295,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3369
3295
|
* 用一组支付来源覆盖当前订单支付项。
|
|
3370
3296
|
*
|
|
3371
3297
|
* 入参允许来自 PaymentModule 的 PaymentItem,内部统一映射为 Sales 协议:
|
|
3372
|
-
*
|
|
3298
|
+
* uuid -> metadata.unique_payment_number,id -> custom_payment_id,
|
|
3373
3299
|
* isSynced 等运行态字段不会进入 tempOrder.payments。
|
|
3374
3300
|
*/
|
|
3375
3301
|
}, {
|
|
3376
3302
|
key: "setOrderPayments",
|
|
3377
3303
|
value: function setOrderPayments(payments) {
|
|
3378
|
-
var _this22 = this;
|
|
3379
3304
|
var tempOrder = this.ensureTempOrder();
|
|
3380
|
-
tempOrder.payments = mapPaymentItemsToOrderPayments(
|
|
3381
|
-
return _this22.normalizePaymentSource(payment, {
|
|
3382
|
-
defaultPaid: false
|
|
3383
|
-
});
|
|
3384
|
-
}));
|
|
3305
|
+
tempOrder.payments = mapPaymentItemsToOrderPayments(payments);
|
|
3385
3306
|
this.persistTempOrder();
|
|
3386
3307
|
return tempOrder.payments;
|
|
3387
3308
|
}
|
|
3388
3309
|
|
|
3389
|
-
/**
|
|
3310
|
+
/** 追加单个支付项,并立即持久化当前 tempOrder。 */
|
|
3390
3311
|
}, {
|
|
3391
3312
|
key: "addOrderPayment",
|
|
3392
3313
|
value: function addOrderPayment(payment) {
|
|
3393
|
-
var
|
|
3394
|
-
return this.addOrderPaymentWithDevicePrefix(payment, hasPaymentNumber ? 'LOCAL' : this.getPaymentNumberDevicePrefixSync());
|
|
3395
|
-
}
|
|
3396
|
-
|
|
3397
|
-
/** 异步入口:创建支付项时读取最新 IoT 设备短号。 */
|
|
3398
|
-
}, {
|
|
3399
|
-
key: "addOrderPaymentAsync",
|
|
3400
|
-
value: (function () {
|
|
3401
|
-
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(payment) {
|
|
3402
|
-
var hasPaymentNumber, devicePrefix;
|
|
3403
|
-
return _regeneratorRuntime().wrap(function _callee15$(_context17) {
|
|
3404
|
-
while (1) switch (_context17.prev = _context17.next) {
|
|
3405
|
-
case 0:
|
|
3406
|
-
hasPaymentNumber = String(payment.payment_number || '').trim() !== '';
|
|
3407
|
-
if (!hasPaymentNumber) {
|
|
3408
|
-
_context17.next = 5;
|
|
3409
|
-
break;
|
|
3410
|
-
}
|
|
3411
|
-
_context17.t0 = 'LOCAL';
|
|
3412
|
-
_context17.next = 8;
|
|
3413
|
-
break;
|
|
3414
|
-
case 5:
|
|
3415
|
-
_context17.next = 7;
|
|
3416
|
-
return this.getPaymentNumberDevicePrefixAsync();
|
|
3417
|
-
case 7:
|
|
3418
|
-
_context17.t0 = _context17.sent;
|
|
3419
|
-
case 8:
|
|
3420
|
-
devicePrefix = _context17.t0;
|
|
3421
|
-
return _context17.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
|
|
3422
|
-
case 10:
|
|
3423
|
-
case "end":
|
|
3424
|
-
return _context17.stop();
|
|
3425
|
-
}
|
|
3426
|
-
}, _callee15, this);
|
|
3427
|
-
}));
|
|
3428
|
-
function addOrderPaymentAsync(_x14) {
|
|
3429
|
-
return _addOrderPaymentAsync.apply(this, arguments);
|
|
3430
|
-
}
|
|
3431
|
-
return addOrderPaymentAsync;
|
|
3432
|
-
}())
|
|
3433
|
-
}, {
|
|
3434
|
-
key: "addOrderPaymentWithDevicePrefix",
|
|
3435
|
-
value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
|
|
3436
|
-
var _this23 = this;
|
|
3314
|
+
var _this20 = this;
|
|
3437
3315
|
this.logInfo('addOrderPayment', {
|
|
3438
3316
|
payment: payment
|
|
3439
3317
|
});
|
|
@@ -3443,15 +3321,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3443
3321
|
type: orderPaymentType,
|
|
3444
3322
|
order_payment_type: orderPaymentType
|
|
3445
3323
|
}), {
|
|
3446
|
-
defaultPaid: true
|
|
3447
|
-
devicePrefix: devicePrefix
|
|
3324
|
+
defaultPaid: true
|
|
3448
3325
|
})]);
|
|
3449
3326
|
tempOrder.payments = [].concat(_toConsumableArray(tempOrder.payments || []), _toConsumableArray(mapped));
|
|
3450
3327
|
this.persistTempOrder();
|
|
3451
3328
|
void this.recalculateSummary({
|
|
3452
3329
|
createIfMissing: true
|
|
3453
3330
|
}).catch(function (error) {
|
|
3454
|
-
|
|
3331
|
+
_this20.logError('recalculate summary after addOrderPayment failed', {
|
|
3455
3332
|
error: error instanceof Error ? error.message : String(error)
|
|
3456
3333
|
});
|
|
3457
3334
|
});
|
|
@@ -3459,80 +3336,49 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3459
3336
|
}
|
|
3460
3337
|
|
|
3461
3338
|
/**
|
|
3462
|
-
*
|
|
3463
|
-
*
|
|
3339
|
+
* 按支付唯一号、后端支付 ID、自定义支付方式 ID 或旧 uuid 更新支付项。
|
|
3340
|
+
*
|
|
3341
|
+
* 该方法服务 PaymentModal 的 void / 编辑场景;更新 metadata 时会做浅合并,
|
|
3342
|
+
* 避免覆盖 unique_payment_number、现金实付/找零等已有元数据。
|
|
3464
3343
|
*/
|
|
3465
3344
|
}, {
|
|
3466
3345
|
key: "updateOrderPayment",
|
|
3467
|
-
value:
|
|
3468
|
-
var
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
}
|
|
3490
|
-
throw new Error("\u672A\u627E\u5230\u652F\u4ED8\u9879: ".concat(identity));
|
|
3491
|
-
case 7:
|
|
3492
|
-
updatedPayment = null;
|
|
3493
|
-
tempOrder.payments = (tempOrder.payments || []).map(function (payment, index) {
|
|
3494
|
-
if (index !== matchedPayment.index) return payment;
|
|
3495
|
-
var nextPayment = mergeOrderPaymentRecord(payment, _objectSpread(_objectSpread({}, updates), {}, {
|
|
3496
|
-
updated_at: updates.updated_at || dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
3497
|
-
}));
|
|
3498
|
-
updatedPayment = nextPayment;
|
|
3499
|
-
return nextPayment;
|
|
3500
|
-
});
|
|
3501
|
-
this.persistTempOrder();
|
|
3502
|
-
_context18.next = 12;
|
|
3503
|
-
return this.recalculateSummary({
|
|
3504
|
-
createIfMissing: true
|
|
3505
|
-
});
|
|
3506
|
-
case 12:
|
|
3507
|
-
summary = _context18.sent;
|
|
3508
|
-
this.persistTempOrder();
|
|
3509
|
-
payments = tempOrder.payments;
|
|
3510
|
-
return _context18.abrupt("return", {
|
|
3511
|
-
updated: true,
|
|
3512
|
-
payment: payments[matchedPayment.index] || updatedPayment,
|
|
3513
|
-
payments: payments,
|
|
3514
|
-
summary: summary
|
|
3515
|
-
});
|
|
3516
|
-
case 16:
|
|
3517
|
-
case "end":
|
|
3518
|
-
return _context18.stop();
|
|
3519
|
-
}
|
|
3520
|
-
}, _callee16, this);
|
|
3521
|
-
}));
|
|
3522
|
-
function updateOrderPayment(_x15, _x16) {
|
|
3523
|
-
return _updateOrderPayment.apply(this, arguments);
|
|
3524
|
-
}
|
|
3525
|
-
return updateOrderPayment;
|
|
3526
|
-
}() /** 从当前订单支付项中移除指定支付项。 */)
|
|
3346
|
+
value: function updateOrderPayment(paymentIdentity, updates) {
|
|
3347
|
+
var tempOrder = this.ensureTempOrder();
|
|
3348
|
+
var identity = String(paymentIdentity);
|
|
3349
|
+
tempOrder.payments = (tempOrder.payments || []).map(function (payment) {
|
|
3350
|
+
var _payment$metadata;
|
|
3351
|
+
var uniquePaymentNumber = payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.unique_payment_number;
|
|
3352
|
+
var orderPaymentId = payment === null || payment === void 0 ? void 0 : payment.order_payment_id;
|
|
3353
|
+
var customPaymentId = payment === null || payment === void 0 ? void 0 : payment.custom_payment_id;
|
|
3354
|
+
var uuid = payment === null || payment === void 0 ? void 0 : payment.uuid;
|
|
3355
|
+
var matched = [uniquePaymentNumber, orderPaymentId, customPaymentId, uuid].some(function (value) {
|
|
3356
|
+
return value !== undefined && String(value) === identity;
|
|
3357
|
+
});
|
|
3358
|
+
if (!matched) return payment;
|
|
3359
|
+
return _objectSpread(_objectSpread(_objectSpread({}, payment), updates), {}, {
|
|
3360
|
+
metadata: _objectSpread(_objectSpread({}, payment.metadata || {}), updates.metadata || {})
|
|
3361
|
+
});
|
|
3362
|
+
});
|
|
3363
|
+
this.persistTempOrder();
|
|
3364
|
+
return tempOrder.payments;
|
|
3365
|
+
}
|
|
3366
|
+
|
|
3367
|
+
/** 从当前订单支付项中移除指定支付项。 */
|
|
3527
3368
|
}, {
|
|
3528
3369
|
key: "deleteOrderPayment",
|
|
3529
3370
|
value: function deleteOrderPayment(paymentIdentity) {
|
|
3530
3371
|
var tempOrder = this.ensureTempOrder();
|
|
3531
3372
|
var identity = String(paymentIdentity);
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3373
|
+
tempOrder.payments = (tempOrder.payments || []).filter(function (payment) {
|
|
3374
|
+
var _payment$metadata2;
|
|
3375
|
+
var uniquePaymentNumber = payment === null || payment === void 0 || (_payment$metadata2 = payment.metadata) === null || _payment$metadata2 === void 0 ? void 0 : _payment$metadata2.unique_payment_number;
|
|
3376
|
+
var orderPaymentId = payment === null || payment === void 0 ? void 0 : payment.order_payment_id;
|
|
3377
|
+
var customPaymentId = payment === null || payment === void 0 ? void 0 : payment.custom_payment_id;
|
|
3378
|
+
var uuid = payment === null || payment === void 0 ? void 0 : payment.uuid;
|
|
3379
|
+
return ![uniquePaymentNumber, orderPaymentId, customPaymentId, uuid].some(function (value) {
|
|
3380
|
+
return value !== undefined && String(value) === identity;
|
|
3381
|
+
});
|
|
3536
3382
|
});
|
|
3537
3383
|
this.persistTempOrder();
|
|
3538
3384
|
return tempOrder.payments;
|
|
@@ -3564,7 +3410,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3564
3410
|
}, {
|
|
3565
3411
|
key: "applyPaymentLifecycleChange",
|
|
3566
3412
|
value: function applyPaymentLifecycleChange(tempOrder, options) {
|
|
3567
|
-
var
|
|
3413
|
+
var _this21 = this;
|
|
3568
3414
|
this.updateTempOrderPaymentStatus(tempOrder);
|
|
3569
3415
|
if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
|
|
3570
3416
|
this.persistTempOrder();
|
|
@@ -3574,7 +3420,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3574
3420
|
void this.recalculateSummary({
|
|
3575
3421
|
createIfMissing: true
|
|
3576
3422
|
}).catch(function (error) {
|
|
3577
|
-
|
|
3423
|
+
_this21.logError("recalculate summary after ".concat(logContext, " failed"), {
|
|
3578
3424
|
error: error instanceof Error ? error.message : String(error)
|
|
3579
3425
|
});
|
|
3580
3426
|
});
|
|
@@ -3618,7 +3464,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3618
3464
|
}, {
|
|
3619
3465
|
key: "updateVoucherOrderPayments",
|
|
3620
3466
|
value: function updateVoucherOrderPayments(payments, options) {
|
|
3621
|
-
var
|
|
3467
|
+
var _this22 = this;
|
|
3622
3468
|
var tempOrder = this.ensureTempOrder();
|
|
3623
3469
|
var isOrderPaymentType = function isOrderPaymentType(value) {
|
|
3624
3470
|
return value === 'normal' || value === 'deposit';
|
|
@@ -3653,9 +3499,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3653
3499
|
});
|
|
3654
3500
|
};
|
|
3655
3501
|
var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
|
|
3656
|
-
return
|
|
3657
|
-
defaultPaid: false
|
|
3658
|
-
devicePrefix: options === null || options === void 0 ? void 0 : options.devicePrefix
|
|
3502
|
+
return _this22.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
|
|
3503
|
+
defaultPaid: false
|
|
3659
3504
|
});
|
|
3660
3505
|
})).filter(function (payment) {
|
|
3661
3506
|
return isVoucherPaymentRecord(payment);
|
|
@@ -3681,17 +3526,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3681
3526
|
}).map(function (payment) {
|
|
3682
3527
|
return String(payment.order_payment_id);
|
|
3683
3528
|
}));
|
|
3684
|
-
var
|
|
3685
|
-
return
|
|
3686
|
-
}).filter(function (key) {
|
|
3687
|
-
return key !== null;
|
|
3529
|
+
var committedVoucherIds = new Set(committedVoucherPayments.map(function (payment) {
|
|
3530
|
+
return String(payment.voucher_id);
|
|
3688
3531
|
}));
|
|
3689
3532
|
var replaceableVouchers = mappedVouchers.filter(function (payment) {
|
|
3690
3533
|
if (hasSyncedOrderPaymentRecord(payment) && committedVoucherPaymentIds.has(String(payment.order_payment_id))) {
|
|
3691
3534
|
return false;
|
|
3692
3535
|
}
|
|
3693
|
-
|
|
3694
|
-
if (lifecycleKey && committedVoucherLifecycleKeys.has(lifecycleKey)) {
|
|
3536
|
+
if (payment.voucher_id !== undefined && committedVoucherIds.has(String(payment.voucher_id))) {
|
|
3695
3537
|
return false;
|
|
3696
3538
|
}
|
|
3697
3539
|
return true;
|
|
@@ -3706,93 +3548,54 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3706
3548
|
void this.recalculateSummary({
|
|
3707
3549
|
createIfMissing: true
|
|
3708
3550
|
}).catch(function (error) {
|
|
3709
|
-
|
|
3551
|
+
_this22.logError('recalculate summary after updateVoucherOrderPayments failed', {
|
|
3710
3552
|
error: error instanceof Error ? error.message : String(error)
|
|
3711
3553
|
});
|
|
3712
3554
|
});
|
|
3713
3555
|
return tempOrder.payments;
|
|
3714
3556
|
}
|
|
3715
|
-
}, {
|
|
3716
|
-
key: "updateVoucherOrderPaymentsAsync",
|
|
3717
|
-
value: function () {
|
|
3718
|
-
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(payments, options) {
|
|
3719
|
-
var needsPaymentNumber, devicePrefix;
|
|
3720
|
-
return _regeneratorRuntime().wrap(function _callee17$(_context19) {
|
|
3721
|
-
while (1) switch (_context19.prev = _context19.next) {
|
|
3722
|
-
case 0:
|
|
3723
|
-
needsPaymentNumber = (payments || []).some(function (payment) {
|
|
3724
|
-
return String(payment.payment_number || '').trim() === '';
|
|
3725
|
-
});
|
|
3726
|
-
if (!needsPaymentNumber) {
|
|
3727
|
-
_context19.next = 7;
|
|
3728
|
-
break;
|
|
3729
|
-
}
|
|
3730
|
-
_context19.next = 4;
|
|
3731
|
-
return this.getPaymentNumberDevicePrefixAsync();
|
|
3732
|
-
case 4:
|
|
3733
|
-
_context19.t0 = _context19.sent;
|
|
3734
|
-
_context19.next = 8;
|
|
3735
|
-
break;
|
|
3736
|
-
case 7:
|
|
3737
|
-
_context19.t0 = 'LOCAL';
|
|
3738
|
-
case 8:
|
|
3739
|
-
devicePrefix = _context19.t0;
|
|
3740
|
-
return _context19.abrupt("return", this.updateVoucherOrderPayments(payments, _objectSpread(_objectSpread({}, options), {}, {
|
|
3741
|
-
devicePrefix: devicePrefix
|
|
3742
|
-
})));
|
|
3743
|
-
case 10:
|
|
3744
|
-
case "end":
|
|
3745
|
-
return _context19.stop();
|
|
3746
|
-
}
|
|
3747
|
-
}, _callee17, this);
|
|
3748
|
-
}));
|
|
3749
|
-
function updateVoucherOrderPaymentsAsync(_x17, _x18) {
|
|
3750
|
-
return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
|
|
3751
|
-
}
|
|
3752
|
-
return updateVoucherOrderPaymentsAsync;
|
|
3753
|
-
}()
|
|
3754
3557
|
}, {
|
|
3755
3558
|
key: "shouldMergeProductToOrder",
|
|
3756
3559
|
value: function () {
|
|
3757
|
-
var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3560
|
+
var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
|
|
3758
3561
|
var _this$orderHooks;
|
|
3759
3562
|
var onBeforeMergeProductToOrder, result;
|
|
3760
|
-
return _regeneratorRuntime().wrap(function
|
|
3761
|
-
while (1) switch (
|
|
3563
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context17) {
|
|
3564
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
3762
3565
|
case 0:
|
|
3763
3566
|
onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
|
|
3764
3567
|
if (onBeforeMergeProductToOrder) {
|
|
3765
|
-
|
|
3568
|
+
_context17.next = 3;
|
|
3766
3569
|
break;
|
|
3767
3570
|
}
|
|
3768
|
-
return
|
|
3571
|
+
return _context17.abrupt("return", true);
|
|
3769
3572
|
case 3:
|
|
3770
|
-
|
|
3573
|
+
_context17.next = 5;
|
|
3771
3574
|
return onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
3772
3575
|
defaultShouldMerge: true
|
|
3773
3576
|
}));
|
|
3774
3577
|
case 5:
|
|
3775
|
-
result =
|
|
3578
|
+
result = _context17.sent;
|
|
3776
3579
|
if (!(typeof result === 'boolean')) {
|
|
3777
|
-
|
|
3580
|
+
_context17.next = 8;
|
|
3778
3581
|
break;
|
|
3779
3582
|
}
|
|
3780
|
-
return
|
|
3583
|
+
return _context17.abrupt("return", result);
|
|
3781
3584
|
case 8:
|
|
3782
3585
|
if (!(result && _typeof(result) === 'object' && typeof result.shouldMerge === 'boolean')) {
|
|
3783
|
-
|
|
3586
|
+
_context17.next = 10;
|
|
3784
3587
|
break;
|
|
3785
3588
|
}
|
|
3786
|
-
return
|
|
3589
|
+
return _context17.abrupt("return", result.shouldMerge);
|
|
3787
3590
|
case 10:
|
|
3788
|
-
return
|
|
3591
|
+
return _context17.abrupt("return", true);
|
|
3789
3592
|
case 11:
|
|
3790
3593
|
case "end":
|
|
3791
|
-
return
|
|
3594
|
+
return _context17.stop();
|
|
3792
3595
|
}
|
|
3793
|
-
},
|
|
3596
|
+
}, _callee15, this);
|
|
3794
3597
|
}));
|
|
3795
|
-
function shouldMergeProductToOrder(
|
|
3598
|
+
function shouldMergeProductToOrder(_x14) {
|
|
3796
3599
|
return _shouldMergeProductToOrder.apply(this, arguments);
|
|
3797
3600
|
}
|
|
3798
3601
|
return shouldMergeProductToOrder;
|
|
@@ -3828,30 +3631,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3828
3631
|
}, {
|
|
3829
3632
|
key: "finalizeProductOrderMutation",
|
|
3830
3633
|
value: function () {
|
|
3831
|
-
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3832
|
-
return _regeneratorRuntime().wrap(function
|
|
3833
|
-
while (1) switch (
|
|
3634
|
+
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(tempOrder, options) {
|
|
3635
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context18) {
|
|
3636
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
3834
3637
|
case 0:
|
|
3835
3638
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
3836
3639
|
if (options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) {
|
|
3837
|
-
|
|
3640
|
+
_context18.next = 4;
|
|
3838
3641
|
break;
|
|
3839
3642
|
}
|
|
3840
|
-
|
|
3643
|
+
_context18.next = 4;
|
|
3841
3644
|
return this.ensureEditDiscountConfigForProductChange(tempOrder);
|
|
3842
3645
|
case 4:
|
|
3843
3646
|
if (options !== null && options !== void 0 && options.skipDiscountRecalculation) {
|
|
3844
|
-
|
|
3647
|
+
_context18.next = 7;
|
|
3845
3648
|
break;
|
|
3846
3649
|
}
|
|
3847
|
-
|
|
3650
|
+
_context18.next = 7;
|
|
3848
3651
|
return this.applyPromotion();
|
|
3849
3652
|
case 7:
|
|
3850
3653
|
if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation)) {
|
|
3851
3654
|
this.applyDiscount();
|
|
3852
3655
|
}
|
|
3853
3656
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3854
|
-
|
|
3657
|
+
_context18.next = 11;
|
|
3855
3658
|
return this.recalculateSummary({
|
|
3856
3659
|
createIfMissing: true
|
|
3857
3660
|
});
|
|
@@ -3859,11 +3662,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3859
3662
|
this.persistTempOrder();
|
|
3860
3663
|
case 12:
|
|
3861
3664
|
case "end":
|
|
3862
|
-
return
|
|
3665
|
+
return _context18.stop();
|
|
3863
3666
|
}
|
|
3864
|
-
},
|
|
3667
|
+
}, _callee16, this);
|
|
3865
3668
|
}));
|
|
3866
|
-
function finalizeProductOrderMutation(
|
|
3669
|
+
function finalizeProductOrderMutation(_x15, _x16) {
|
|
3867
3670
|
return _finalizeProductOrderMutation.apply(this, arguments);
|
|
3868
3671
|
}
|
|
3869
3672
|
return finalizeProductOrderMutation;
|
|
@@ -3878,17 +3681,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3878
3681
|
}, {
|
|
3879
3682
|
key: "appendProductLineToTempOrder",
|
|
3880
3683
|
value: (function () {
|
|
3881
|
-
var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3684
|
+
var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(tempOrder, product, booking, options) {
|
|
3882
3685
|
var _normalizedIncoming$p,
|
|
3883
3686
|
_normalizedIncoming$p2,
|
|
3884
3687
|
_booking_uid,
|
|
3885
3688
|
_metadata,
|
|
3886
3689
|
_productToAdd$metadat,
|
|
3887
3690
|
_origin,
|
|
3888
|
-
|
|
3691
|
+
_this23 = this;
|
|
3889
3692
|
var linked, productToAdd, incomingFingerprint, normalizedIncoming, isWeighingProduct, netWeight, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingBookingUid, isIncomingCustomItem, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, insertAtIndex, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList, mergedProduct;
|
|
3890
|
-
return _regeneratorRuntime().wrap(function
|
|
3891
|
-
while (1) switch (
|
|
3693
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context19) {
|
|
3694
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
3892
3695
|
case 0:
|
|
3893
3696
|
linked = booking ? this.createLinkedProductAndBooking({
|
|
3894
3697
|
product: product,
|
|
@@ -3900,7 +3703,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3900
3703
|
isWeighingProduct = Number(((_normalizedIncoming$p = normalizedIncoming.product_sku) === null || _normalizedIncoming$p === void 0 ? void 0 : _normalizedIncoming$p.open_sold_weight) || 0) === 1;
|
|
3901
3704
|
netWeight = Number((_normalizedIncoming$p2 = normalizedIncoming.product_sku) === null || _normalizedIncoming$p2 === void 0 ? void 0 : _normalizedIncoming$p2.net_weight);
|
|
3902
3705
|
if (!(isWeighingProduct && (!Number.isFinite(netWeight) || netWeight <= 0))) {
|
|
3903
|
-
|
|
3706
|
+
_context19.next = 8;
|
|
3904
3707
|
break;
|
|
3905
3708
|
}
|
|
3906
3709
|
throw new Error('[Order] 称重商品净重必须大于 0');
|
|
@@ -3920,8 +3723,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3920
3723
|
shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
|
|
3921
3724
|
matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
3922
3725
|
var _item$metadata3;
|
|
3923
|
-
if (
|
|
3924
|
-
if (
|
|
3726
|
+
if (_this23.hasGoodPassDiscount(item)) return false;
|
|
3727
|
+
if (_this23.hasOrderProductLineNote(item)) return false;
|
|
3925
3728
|
if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
|
|
3926
3729
|
if ((_item$metadata3 = item.metadata) !== null && _item$metadata3 !== void 0 && _item$metadata3.is_edit_for_runtime) return false;
|
|
3927
3730
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
@@ -3932,10 +3735,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3932
3735
|
matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
|
|
3933
3736
|
existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
|
|
3934
3737
|
if (!matchedProduct) {
|
|
3935
|
-
|
|
3738
|
+
_context19.next = 25;
|
|
3936
3739
|
break;
|
|
3937
3740
|
}
|
|
3938
|
-
|
|
3741
|
+
_context19.next = 22;
|
|
3939
3742
|
return this.shouldMergeProductToOrder({
|
|
3940
3743
|
incomingProduct: productToAdd,
|
|
3941
3744
|
normalizedIncoming: normalizedIncoming,
|
|
@@ -3947,13 +3750,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3947
3750
|
booking: booking
|
|
3948
3751
|
});
|
|
3949
3752
|
case 22:
|
|
3950
|
-
|
|
3951
|
-
|
|
3753
|
+
_context19.t0 = _context19.sent;
|
|
3754
|
+
_context19.next = 26;
|
|
3952
3755
|
break;
|
|
3953
3756
|
case 25:
|
|
3954
|
-
|
|
3757
|
+
_context19.t0 = false;
|
|
3955
3758
|
case 26:
|
|
3956
|
-
shouldMerge =
|
|
3759
|
+
shouldMerge = _context19.t0;
|
|
3957
3760
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
3958
3761
|
this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
3959
3762
|
if (linked) {
|
|
@@ -4015,11 +3818,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4015
3818
|
}
|
|
4016
3819
|
case 29:
|
|
4017
3820
|
case "end":
|
|
4018
|
-
return
|
|
3821
|
+
return _context19.stop();
|
|
4019
3822
|
}
|
|
4020
|
-
},
|
|
3823
|
+
}, _callee17, this);
|
|
4021
3824
|
}));
|
|
4022
|
-
function appendProductLineToTempOrder(
|
|
3825
|
+
function appendProductLineToTempOrder(_x17, _x18, _x19, _x20) {
|
|
4023
3826
|
return _appendProductLineToTempOrder.apply(this, arguments);
|
|
4024
3827
|
}
|
|
4025
3828
|
return appendProductLineToTempOrder;
|
|
@@ -4035,10 +3838,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4035
3838
|
}, {
|
|
4036
3839
|
key: "addProductToOrder",
|
|
4037
3840
|
value: (function () {
|
|
4038
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3841
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(product, booking, options) {
|
|
4039
3842
|
var tempOrder, insertAfterProductUid, anchorIndex, insertAtIndex, _ref60, _productRecord$num, productRecord, splitCount, i, singleLine;
|
|
4040
|
-
return _regeneratorRuntime().wrap(function
|
|
4041
|
-
while (1) switch (
|
|
3843
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context20) {
|
|
3844
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
4042
3845
|
case 0:
|
|
4043
3846
|
tempOrder = this.ensureTempOrder();
|
|
4044
3847
|
insertAfterProductUid = options === null || options === void 0 ? void 0 : options.insertAfterProductUid;
|
|
@@ -4049,25 +3852,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4049
3852
|
}) : -1;
|
|
4050
3853
|
insertAtIndex = anchorIndex >= 0 ? anchorIndex + 1 : undefined;
|
|
4051
3854
|
if (!booking) {
|
|
4052
|
-
|
|
3855
|
+
_context20.next = 22;
|
|
4053
3856
|
break;
|
|
4054
3857
|
}
|
|
4055
3858
|
productRecord = product;
|
|
4056
3859
|
splitCount = getSafeProductNum((_ref60 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref60 !== void 0 ? _ref60 : 1);
|
|
4057
3860
|
if (!(splitCount > 1)) {
|
|
4058
|
-
|
|
3861
|
+
_context20.next = 22;
|
|
4059
3862
|
break;
|
|
4060
3863
|
}
|
|
4061
3864
|
i = 0;
|
|
4062
3865
|
case 9:
|
|
4063
3866
|
if (!(i < splitCount)) {
|
|
4064
|
-
|
|
3867
|
+
_context20.next = 19;
|
|
4065
3868
|
break;
|
|
4066
3869
|
}
|
|
4067
3870
|
singleLine = cloneDeep(productRecord);
|
|
4068
3871
|
singleLine.num = 1;
|
|
4069
3872
|
delete singleLine.product_quantity;
|
|
4070
|
-
|
|
3873
|
+
_context20.next = 15;
|
|
4071
3874
|
return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking), {
|
|
4072
3875
|
insertAtIndex: insertAtIndex
|
|
4073
3876
|
});
|
|
@@ -4075,34 +3878,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4075
3878
|
if (insertAtIndex !== undefined) insertAtIndex += 1;
|
|
4076
3879
|
case 16:
|
|
4077
3880
|
i += 1;
|
|
4078
|
-
|
|
3881
|
+
_context20.next = 9;
|
|
4079
3882
|
break;
|
|
4080
3883
|
case 19:
|
|
4081
|
-
|
|
3884
|
+
_context20.next = 21;
|
|
4082
3885
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
4083
3886
|
case 21:
|
|
4084
|
-
return
|
|
3887
|
+
return _context20.abrupt("return", tempOrder.products);
|
|
4085
3888
|
case 22:
|
|
4086
|
-
|
|
3889
|
+
_context20.next = 24;
|
|
4087
3890
|
return this.appendProductLineToTempOrder(tempOrder, product, booking, {
|
|
4088
3891
|
insertAtIndex: insertAtIndex
|
|
4089
3892
|
});
|
|
4090
3893
|
case 24:
|
|
4091
|
-
|
|
3894
|
+
_context20.next = 26;
|
|
4092
3895
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
4093
3896
|
case 26:
|
|
4094
3897
|
this.logInfo('addProductToOrder success', {
|
|
4095
3898
|
product_id: product.product_id,
|
|
4096
3899
|
with_booking: !!booking
|
|
4097
3900
|
});
|
|
4098
|
-
return
|
|
3901
|
+
return _context20.abrupt("return", tempOrder.products);
|
|
4099
3902
|
case 28:
|
|
4100
3903
|
case "end":
|
|
4101
|
-
return
|
|
3904
|
+
return _context20.stop();
|
|
4102
3905
|
}
|
|
4103
|
-
},
|
|
3906
|
+
}, _callee18, this);
|
|
4104
3907
|
}));
|
|
4105
|
-
function addProductToOrder(
|
|
3908
|
+
function addProductToOrder(_x21, _x22, _x23) {
|
|
4106
3909
|
return _addProductToOrder.apply(this, arguments);
|
|
4107
3910
|
}
|
|
4108
3911
|
return addProductToOrder;
|
|
@@ -4120,93 +3923,93 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4120
3923
|
}, {
|
|
4121
3924
|
key: "addProductsToOrder",
|
|
4122
3925
|
value: (function () {
|
|
4123
|
-
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3926
|
+
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(items, options) {
|
|
4124
3927
|
var tempOrder, _iterator20, _step20, item, product, booking, _ref61, _productRecord$num2, productRecord, splitCount, i, singleLine;
|
|
4125
|
-
return _regeneratorRuntime().wrap(function
|
|
4126
|
-
while (1) switch (
|
|
3928
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context21) {
|
|
3929
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
4127
3930
|
case 0:
|
|
4128
3931
|
tempOrder = this.ensureTempOrder();
|
|
4129
3932
|
if (!(!Array.isArray(items) || items.length === 0)) {
|
|
4130
|
-
|
|
3933
|
+
_context21.next = 3;
|
|
4131
3934
|
break;
|
|
4132
3935
|
}
|
|
4133
|
-
return
|
|
3936
|
+
return _context21.abrupt("return", tempOrder.products);
|
|
4134
3937
|
case 3:
|
|
4135
3938
|
_iterator20 = _createForOfIteratorHelper(items || []);
|
|
4136
|
-
|
|
3939
|
+
_context21.prev = 4;
|
|
4137
3940
|
_iterator20.s();
|
|
4138
3941
|
case 6:
|
|
4139
3942
|
if ((_step20 = _iterator20.n()).done) {
|
|
4140
|
-
|
|
3943
|
+
_context21.next = 30;
|
|
4141
3944
|
break;
|
|
4142
3945
|
}
|
|
4143
3946
|
item = _step20.value;
|
|
4144
3947
|
product = item.product, booking = item.booking;
|
|
4145
3948
|
if (product) {
|
|
4146
|
-
|
|
3949
|
+
_context21.next = 11;
|
|
4147
3950
|
break;
|
|
4148
3951
|
}
|
|
4149
|
-
return
|
|
3952
|
+
return _context21.abrupt("continue", 28);
|
|
4150
3953
|
case 11:
|
|
4151
3954
|
if (!booking) {
|
|
4152
|
-
|
|
3955
|
+
_context21.next = 26;
|
|
4153
3956
|
break;
|
|
4154
3957
|
}
|
|
4155
3958
|
productRecord = product;
|
|
4156
3959
|
splitCount = getSafeProductNum((_ref61 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref61 !== void 0 ? _ref61 : 1);
|
|
4157
3960
|
if (!(splitCount > 1)) {
|
|
4158
|
-
|
|
3961
|
+
_context21.next = 26;
|
|
4159
3962
|
break;
|
|
4160
3963
|
}
|
|
4161
3964
|
i = 0;
|
|
4162
3965
|
case 16:
|
|
4163
3966
|
if (!(i < splitCount)) {
|
|
4164
|
-
|
|
3967
|
+
_context21.next = 25;
|
|
4165
3968
|
break;
|
|
4166
3969
|
}
|
|
4167
3970
|
singleLine = cloneDeep(productRecord);
|
|
4168
3971
|
singleLine.num = 1;
|
|
4169
3972
|
delete singleLine.product_quantity;
|
|
4170
|
-
|
|
3973
|
+
_context21.next = 22;
|
|
4171
3974
|
return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
|
|
4172
3975
|
case 22:
|
|
4173
3976
|
i += 1;
|
|
4174
|
-
|
|
3977
|
+
_context21.next = 16;
|
|
4175
3978
|
break;
|
|
4176
3979
|
case 25:
|
|
4177
|
-
return
|
|
3980
|
+
return _context21.abrupt("continue", 28);
|
|
4178
3981
|
case 26:
|
|
4179
|
-
|
|
3982
|
+
_context21.next = 28;
|
|
4180
3983
|
return this.appendProductLineToTempOrder(tempOrder, product, booking);
|
|
4181
3984
|
case 28:
|
|
4182
|
-
|
|
3985
|
+
_context21.next = 6;
|
|
4183
3986
|
break;
|
|
4184
3987
|
case 30:
|
|
4185
|
-
|
|
3988
|
+
_context21.next = 35;
|
|
4186
3989
|
break;
|
|
4187
3990
|
case 32:
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
_iterator20.e(
|
|
3991
|
+
_context21.prev = 32;
|
|
3992
|
+
_context21.t0 = _context21["catch"](4);
|
|
3993
|
+
_iterator20.e(_context21.t0);
|
|
4191
3994
|
case 35:
|
|
4192
|
-
|
|
3995
|
+
_context21.prev = 35;
|
|
4193
3996
|
_iterator20.f();
|
|
4194
|
-
return
|
|
3997
|
+
return _context21.finish(35);
|
|
4195
3998
|
case 38:
|
|
4196
|
-
|
|
3999
|
+
_context21.next = 40;
|
|
4197
4000
|
return this.finalizeProductOrderMutation(tempOrder, options);
|
|
4198
4001
|
case 40:
|
|
4199
4002
|
this.logInfo('addProductsToOrder success', {
|
|
4200
4003
|
itemsCount: items.length
|
|
4201
4004
|
});
|
|
4202
|
-
return
|
|
4005
|
+
return _context21.abrupt("return", tempOrder.products);
|
|
4203
4006
|
case 42:
|
|
4204
4007
|
case "end":
|
|
4205
|
-
return
|
|
4008
|
+
return _context21.stop();
|
|
4206
4009
|
}
|
|
4207
|
-
},
|
|
4010
|
+
}, _callee19, this, [[4, 32, 35, 38]]);
|
|
4208
4011
|
}));
|
|
4209
|
-
function addProductsToOrder(
|
|
4012
|
+
function addProductsToOrder(_x24, _x25) {
|
|
4210
4013
|
return _addProductsToOrder.apply(this, arguments);
|
|
4211
4014
|
}
|
|
4212
4015
|
return addProductsToOrder;
|
|
@@ -4240,17 +4043,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4240
4043
|
}, {
|
|
4241
4044
|
key: "preservePersistedBundlePriceFields",
|
|
4242
4045
|
value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
|
|
4243
|
-
var
|
|
4046
|
+
var _this24 = this;
|
|
4244
4047
|
if (!Array.isArray(nextBundles)) return nextBundles;
|
|
4245
4048
|
if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
|
|
4246
4049
|
var previousByIdentity = new Map();
|
|
4247
4050
|
previousBundles.forEach(function (bundle) {
|
|
4248
|
-
var identity =
|
|
4051
|
+
var identity = _this24.getBundleRuntimeIdentity(bundle);
|
|
4249
4052
|
if (identity) previousByIdentity.set(identity, bundle);
|
|
4250
4053
|
});
|
|
4251
4054
|
return nextBundles.map(function (bundle, index) {
|
|
4252
4055
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
4253
|
-
var previous = previousByIdentity.get(
|
|
4056
|
+
var previous = previousByIdentity.get(_this24.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
4254
4057
|
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
4255
4058
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
|
|
4256
4059
|
cover: previous.cover
|
|
@@ -4451,21 +4254,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4451
4254
|
}, {
|
|
4452
4255
|
key: "updateOrderProduct",
|
|
4453
4256
|
value: function () {
|
|
4454
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4257
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
|
|
4455
4258
|
var tempOrder, updatedProductUid;
|
|
4456
|
-
return _regeneratorRuntime().wrap(function
|
|
4457
|
-
while (1) switch (
|
|
4259
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context22) {
|
|
4260
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
4458
4261
|
case 0:
|
|
4459
4262
|
tempOrder = this.ensureTempOrder();
|
|
4460
4263
|
updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
4461
|
-
|
|
4264
|
+
_context22.next = 4;
|
|
4462
4265
|
return this.applyPromotion();
|
|
4463
4266
|
case 4:
|
|
4464
4267
|
this.applyDiscount({
|
|
4465
4268
|
reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
|
|
4466
4269
|
});
|
|
4467
4270
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4468
|
-
|
|
4271
|
+
_context22.next = 8;
|
|
4469
4272
|
return this.recalculateSummary({
|
|
4470
4273
|
createIfMissing: true
|
|
4471
4274
|
});
|
|
@@ -4474,14 +4277,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4474
4277
|
this.logInfo('updateOrderProduct success', {
|
|
4475
4278
|
params: params
|
|
4476
4279
|
});
|
|
4477
|
-
return
|
|
4280
|
+
return _context22.abrupt("return", tempOrder.products);
|
|
4478
4281
|
case 11:
|
|
4479
4282
|
case "end":
|
|
4480
|
-
return
|
|
4283
|
+
return _context22.stop();
|
|
4481
4284
|
}
|
|
4482
|
-
},
|
|
4285
|
+
}, _callee20, this);
|
|
4483
4286
|
}));
|
|
4484
|
-
function updateOrderProduct(
|
|
4287
|
+
function updateOrderProduct(_x26) {
|
|
4485
4288
|
return _updateOrderProduct.apply(this, arguments);
|
|
4486
4289
|
}
|
|
4487
4290
|
return updateOrderProduct;
|
|
@@ -4489,28 +4292,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4489
4292
|
}, {
|
|
4490
4293
|
key: "updateOrderProducts",
|
|
4491
4294
|
value: function () {
|
|
4492
|
-
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4493
|
-
var
|
|
4295
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(paramsList) {
|
|
4296
|
+
var _this25 = this;
|
|
4494
4297
|
var tempOrder, reapplyBookingDiscountProductUids;
|
|
4495
|
-
return _regeneratorRuntime().wrap(function
|
|
4496
|
-
while (1) switch (
|
|
4298
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context23) {
|
|
4299
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
4497
4300
|
case 0:
|
|
4498
4301
|
tempOrder = this.ensureTempOrder();
|
|
4499
4302
|
if (paramsList.length) {
|
|
4500
|
-
|
|
4303
|
+
_context23.next = 3;
|
|
4501
4304
|
break;
|
|
4502
4305
|
}
|
|
4503
|
-
return
|
|
4306
|
+
return _context23.abrupt("return", tempOrder.products);
|
|
4504
4307
|
case 3:
|
|
4505
4308
|
reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
|
|
4506
|
-
var updatedProductUid =
|
|
4309
|
+
var updatedProductUid = _this25.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
4507
4310
|
// 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
|
|
4508
4311
|
if (params.allow_booking_discount_reapply && updatedProductUid) {
|
|
4509
4312
|
acc.push(String(updatedProductUid));
|
|
4510
4313
|
}
|
|
4511
4314
|
return acc;
|
|
4512
4315
|
}, []);
|
|
4513
|
-
|
|
4316
|
+
_context23.next = 6;
|
|
4514
4317
|
return this.finalizeAfterProductsMutation(tempOrder, {
|
|
4515
4318
|
reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
|
|
4516
4319
|
});
|
|
@@ -4518,14 +4321,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4518
4321
|
this.logInfo('updateOrderProduct success', {
|
|
4519
4322
|
paramsList: paramsList
|
|
4520
4323
|
});
|
|
4521
|
-
return
|
|
4324
|
+
return _context23.abrupt("return", tempOrder.products);
|
|
4522
4325
|
case 8:
|
|
4523
4326
|
case "end":
|
|
4524
|
-
return
|
|
4327
|
+
return _context23.stop();
|
|
4525
4328
|
}
|
|
4526
|
-
},
|
|
4329
|
+
}, _callee21, this);
|
|
4527
4330
|
}));
|
|
4528
|
-
function updateOrderProducts(
|
|
4331
|
+
function updateOrderProducts(_x27) {
|
|
4529
4332
|
return _updateOrderProducts.apply(this, arguments);
|
|
4530
4333
|
}
|
|
4531
4334
|
return updateOrderProducts;
|
|
@@ -4533,11 +4336,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4533
4336
|
}, {
|
|
4534
4337
|
key: "updateOrderProductQuantity",
|
|
4535
4338
|
value: function () {
|
|
4536
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4339
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
|
|
4537
4340
|
var _targetProduct$metada17;
|
|
4538
4341
|
var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
|
|
4539
|
-
return _regeneratorRuntime().wrap(function
|
|
4540
|
-
while (1) switch (
|
|
4342
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context24) {
|
|
4343
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
4541
4344
|
case 0:
|
|
4542
4345
|
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;
|
|
4543
4346
|
tempOrder = this.ensureTempOrder();
|
|
@@ -4566,7 +4369,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4566
4369
|
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
4567
4370
|
}
|
|
4568
4371
|
if (!(productIndex === -1)) {
|
|
4569
|
-
|
|
4372
|
+
_context24.next = 12;
|
|
4570
4373
|
break;
|
|
4571
4374
|
}
|
|
4572
4375
|
throw new Error('[Order] 目标商品不存在,无法更新数量');
|
|
@@ -4580,12 +4383,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4580
4383
|
}));
|
|
4581
4384
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
4582
4385
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
4583
|
-
|
|
4386
|
+
_context24.next = 18;
|
|
4584
4387
|
return this.applyPromotion();
|
|
4585
4388
|
case 18:
|
|
4586
4389
|
this.applyDiscount();
|
|
4587
4390
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4588
|
-
|
|
4391
|
+
_context24.next = 22;
|
|
4589
4392
|
return this.recalculateSummary({
|
|
4590
4393
|
createIfMissing: true
|
|
4591
4394
|
});
|
|
@@ -4594,14 +4397,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4594
4397
|
this.logInfo('updateOrderProductQuantity success', {
|
|
4595
4398
|
params: params
|
|
4596
4399
|
});
|
|
4597
|
-
return
|
|
4400
|
+
return _context24.abrupt("return", tempOrder.products);
|
|
4598
4401
|
case 25:
|
|
4599
4402
|
case "end":
|
|
4600
|
-
return
|
|
4403
|
+
return _context24.stop();
|
|
4601
4404
|
}
|
|
4602
|
-
},
|
|
4405
|
+
}, _callee22, this);
|
|
4603
4406
|
}));
|
|
4604
|
-
function updateOrderProductQuantity(
|
|
4407
|
+
function updateOrderProductQuantity(_x28) {
|
|
4605
4408
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
4606
4409
|
}
|
|
4607
4410
|
return updateOrderProductQuantity;
|
|
@@ -4642,19 +4445,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4642
4445
|
}, {
|
|
4643
4446
|
key: "finalizeAfterProductsMutation",
|
|
4644
4447
|
value: (function () {
|
|
4645
|
-
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4646
|
-
return _regeneratorRuntime().wrap(function
|
|
4647
|
-
while (1) switch (
|
|
4448
|
+
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(tempOrder, options) {
|
|
4449
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context25) {
|
|
4450
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
4648
4451
|
case 0:
|
|
4649
4452
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
4650
|
-
|
|
4453
|
+
_context25.next = 3;
|
|
4651
4454
|
return this.applyPromotion();
|
|
4652
4455
|
case 3:
|
|
4653
4456
|
this.applyDiscount({
|
|
4654
4457
|
reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
|
|
4655
4458
|
});
|
|
4656
4459
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4657
|
-
|
|
4460
|
+
_context25.next = 7;
|
|
4658
4461
|
return this.recalculateSummary({
|
|
4659
4462
|
createIfMissing: true
|
|
4660
4463
|
});
|
|
@@ -4662,11 +4465,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4662
4465
|
this.persistTempOrder();
|
|
4663
4466
|
case 8:
|
|
4664
4467
|
case "end":
|
|
4665
|
-
return
|
|
4468
|
+
return _context25.stop();
|
|
4666
4469
|
}
|
|
4667
|
-
},
|
|
4470
|
+
}, _callee23, this);
|
|
4668
4471
|
}));
|
|
4669
|
-
function finalizeAfterProductsMutation(
|
|
4472
|
+
function finalizeAfterProductsMutation(_x29, _x30) {
|
|
4670
4473
|
return _finalizeAfterProductsMutation.apply(this, arguments);
|
|
4671
4474
|
}
|
|
4672
4475
|
return finalizeAfterProductsMutation;
|
|
@@ -4681,18 +4484,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4681
4484
|
}, {
|
|
4682
4485
|
key: "removeProductsFromOrder",
|
|
4683
4486
|
value: (function () {
|
|
4684
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4685
|
-
var
|
|
4487
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(identities, options) {
|
|
4488
|
+
var _this26 = this;
|
|
4686
4489
|
var tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
|
|
4687
|
-
return _regeneratorRuntime().wrap(function
|
|
4688
|
-
while (1) switch (
|
|
4490
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context27) {
|
|
4491
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
4689
4492
|
case 0:
|
|
4690
4493
|
tempOrder = this.ensureTempOrder();
|
|
4691
4494
|
if (identities.length) {
|
|
4692
|
-
|
|
4495
|
+
_context27.next = 3;
|
|
4693
4496
|
break;
|
|
4694
4497
|
}
|
|
4695
|
-
return
|
|
4498
|
+
return _context27.abrupt("return", tempOrder.products);
|
|
4696
4499
|
case 3:
|
|
4697
4500
|
productsBeforeRemove = tempOrder.products || [];
|
|
4698
4501
|
bookingsBeforeRemove = tempOrder.bookings || [];
|
|
@@ -4722,29 +4525,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4722
4525
|
}
|
|
4723
4526
|
linkedBookingUidsToRemove = new Set();
|
|
4724
4527
|
_iterator21 = _createForOfIteratorHelper(matchedProducts);
|
|
4725
|
-
|
|
4528
|
+
_context27.prev = 14;
|
|
4726
4529
|
_loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
|
|
4727
4530
|
var _metadata11, _metadata12, _metadata13, _metadata14;
|
|
4728
4531
|
var product, productUid, productBookingUid, isAddTimeProduct;
|
|
4729
|
-
return _regeneratorRuntime().wrap(function _loop3$(
|
|
4730
|
-
while (1) switch (
|
|
4532
|
+
return _regeneratorRuntime().wrap(function _loop3$(_context26) {
|
|
4533
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
4731
4534
|
case 0:
|
|
4732
4535
|
product = _step21.value;
|
|
4733
4536
|
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);
|
|
4734
4537
|
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);
|
|
4735
4538
|
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;
|
|
4736
4539
|
if (!isAddTimeProduct) {
|
|
4737
|
-
|
|
4540
|
+
_context26.next = 6;
|
|
4738
4541
|
break;
|
|
4739
4542
|
}
|
|
4740
|
-
return
|
|
4543
|
+
return _context26.abrupt("return", 1);
|
|
4741
4544
|
case 6:
|
|
4742
4545
|
if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
|
|
4743
4546
|
linkedBookingUidsToRemove.add(String(productBookingUid));
|
|
4744
4547
|
}
|
|
4745
4548
|
if (productUid !== undefined && productUid !== null && productUid !== '') {
|
|
4746
4549
|
bookingsBeforeRemove.forEach(function (booking) {
|
|
4747
|
-
var bookingUid =
|
|
4550
|
+
var bookingUid = _this26.getBookingUniqueIdentificationNumber(booking);
|
|
4748
4551
|
if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
|
|
4749
4552
|
linkedBookingUidsToRemove.add(bookingUid);
|
|
4750
4553
|
}
|
|
@@ -4752,37 +4555,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4752
4555
|
}
|
|
4753
4556
|
case 8:
|
|
4754
4557
|
case "end":
|
|
4755
|
-
return
|
|
4558
|
+
return _context26.stop();
|
|
4756
4559
|
}
|
|
4757
4560
|
}, _loop3);
|
|
4758
4561
|
});
|
|
4759
4562
|
_iterator21.s();
|
|
4760
4563
|
case 17:
|
|
4761
4564
|
if ((_step21 = _iterator21.n()).done) {
|
|
4762
|
-
|
|
4565
|
+
_context27.next = 23;
|
|
4763
4566
|
break;
|
|
4764
4567
|
}
|
|
4765
|
-
return
|
|
4568
|
+
return _context27.delegateYield(_loop3(), "t0", 19);
|
|
4766
4569
|
case 19:
|
|
4767
|
-
if (!
|
|
4768
|
-
|
|
4570
|
+
if (!_context27.t0) {
|
|
4571
|
+
_context27.next = 21;
|
|
4769
4572
|
break;
|
|
4770
4573
|
}
|
|
4771
|
-
return
|
|
4574
|
+
return _context27.abrupt("continue", 21);
|
|
4772
4575
|
case 21:
|
|
4773
|
-
|
|
4576
|
+
_context27.next = 17;
|
|
4774
4577
|
break;
|
|
4775
4578
|
case 23:
|
|
4776
|
-
|
|
4579
|
+
_context27.next = 28;
|
|
4777
4580
|
break;
|
|
4778
4581
|
case 25:
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
_iterator21.e(
|
|
4582
|
+
_context27.prev = 25;
|
|
4583
|
+
_context27.t1 = _context27["catch"](14);
|
|
4584
|
+
_iterator21.e(_context27.t1);
|
|
4782
4585
|
case 28:
|
|
4783
|
-
|
|
4586
|
+
_context27.prev = 28;
|
|
4784
4587
|
_iterator21.f();
|
|
4785
|
-
return
|
|
4588
|
+
return _context27.finish(28);
|
|
4786
4589
|
case 31:
|
|
4787
4590
|
if (linkedBookingUidsToRemove.size > 0) {
|
|
4788
4591
|
// 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
|
|
@@ -4809,20 +4612,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4809
4612
|
tempOrder.products = nextProductIndex >= 0 ? [].concat(_toConsumableArray(productsWithoutRemaining.slice(0, nextProductIndex)), [remainingProduct], _toConsumableArray(productsWithoutRemaining.slice(nextProductIndex))) : [].concat(_toConsumableArray(productsWithoutRemaining), [remainingProduct]);
|
|
4810
4613
|
}
|
|
4811
4614
|
}
|
|
4812
|
-
|
|
4615
|
+
_context27.next = 35;
|
|
4813
4616
|
return this.finalizeAfterProductsMutation(tempOrder);
|
|
4814
4617
|
case 35:
|
|
4815
4618
|
this.logInfo('removeProductsFromOrder success', {
|
|
4816
4619
|
identities: identities
|
|
4817
4620
|
});
|
|
4818
|
-
return
|
|
4621
|
+
return _context27.abrupt("return", tempOrder.products);
|
|
4819
4622
|
case 37:
|
|
4820
4623
|
case "end":
|
|
4821
|
-
return
|
|
4624
|
+
return _context27.stop();
|
|
4822
4625
|
}
|
|
4823
|
-
},
|
|
4626
|
+
}, _callee24, this, [[14, 25, 28, 31]]);
|
|
4824
4627
|
}));
|
|
4825
|
-
function removeProductsFromOrder(
|
|
4628
|
+
function removeProductsFromOrder(_x31, _x32) {
|
|
4826
4629
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
4827
4630
|
}
|
|
4828
4631
|
return removeProductsFromOrder;
|
|
@@ -4830,18 +4633,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4830
4633
|
}, {
|
|
4831
4634
|
key: "removeProductFromOrder",
|
|
4832
4635
|
value: function () {
|
|
4833
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4834
|
-
return _regeneratorRuntime().wrap(function
|
|
4835
|
-
while (1) switch (
|
|
4636
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(identity, options) {
|
|
4637
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context28) {
|
|
4638
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
4836
4639
|
case 0:
|
|
4837
|
-
return
|
|
4640
|
+
return _context28.abrupt("return", this.removeProductsFromOrder([identity], options));
|
|
4838
4641
|
case 1:
|
|
4839
4642
|
case "end":
|
|
4840
|
-
return
|
|
4643
|
+
return _context28.stop();
|
|
4841
4644
|
}
|
|
4842
|
-
},
|
|
4645
|
+
}, _callee25, this);
|
|
4843
4646
|
}));
|
|
4844
|
-
function removeProductFromOrder(
|
|
4647
|
+
function removeProductFromOrder(_x33, _x34) {
|
|
4845
4648
|
return _removeProductFromOrder.apply(this, arguments);
|
|
4846
4649
|
}
|
|
4847
4650
|
return removeProductFromOrder;
|
|
@@ -4853,10 +4656,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4853
4656
|
}, {
|
|
4854
4657
|
key: "clearOrderCartLines",
|
|
4855
4658
|
value: (function () {
|
|
4856
|
-
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4659
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
4857
4660
|
var tempOrder;
|
|
4858
|
-
return _regeneratorRuntime().wrap(function
|
|
4859
|
-
while (1) switch (
|
|
4661
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context29) {
|
|
4662
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
4860
4663
|
case 0:
|
|
4861
4664
|
tempOrder = this.ensureTempOrder();
|
|
4862
4665
|
tempOrder.products = [];
|
|
@@ -4867,24 +4670,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4867
4670
|
productsByUid: {}
|
|
4868
4671
|
});
|
|
4869
4672
|
}
|
|
4870
|
-
|
|
4673
|
+
_context29.next = 7;
|
|
4871
4674
|
return this.applyPromotion();
|
|
4872
4675
|
case 7:
|
|
4873
4676
|
this.applyDiscount();
|
|
4874
4677
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4875
|
-
|
|
4678
|
+
_context29.next = 11;
|
|
4876
4679
|
return this.recalculateSummary({
|
|
4877
4680
|
createIfMissing: true
|
|
4878
4681
|
});
|
|
4879
4682
|
case 11:
|
|
4880
4683
|
this.persistTempOrder();
|
|
4881
4684
|
this.logInfo('clearOrderCartLines success', {});
|
|
4882
|
-
return
|
|
4685
|
+
return _context29.abrupt("return", tempOrder);
|
|
4883
4686
|
case 14:
|
|
4884
4687
|
case "end":
|
|
4885
|
-
return
|
|
4688
|
+
return _context29.stop();
|
|
4886
4689
|
}
|
|
4887
|
-
},
|
|
4690
|
+
}, _callee26, this);
|
|
4888
4691
|
}));
|
|
4889
4692
|
function clearOrderCartLines() {
|
|
4890
4693
|
return _clearOrderCartLines.apply(this, arguments);
|
|
@@ -4922,17 +4725,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4922
4725
|
}, {
|
|
4923
4726
|
key: "applyLocalPrintOrderNumbers",
|
|
4924
4727
|
value: function () {
|
|
4925
|
-
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4728
|
+
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(order) {
|
|
4926
4729
|
var tempOrder, shopOrderNumber, shopFullOrderNumber;
|
|
4927
|
-
return _regeneratorRuntime().wrap(function
|
|
4928
|
-
while (1) switch (
|
|
4730
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context30) {
|
|
4731
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
4929
4732
|
case 0:
|
|
4930
4733
|
tempOrder = this.ensureTempOrder();
|
|
4931
4734
|
if (!(!order || _typeof(order) !== 'object')) {
|
|
4932
|
-
|
|
4735
|
+
_context30.next = 3;
|
|
4933
4736
|
break;
|
|
4934
4737
|
}
|
|
4935
|
-
return
|
|
4738
|
+
return _context30.abrupt("return", tempOrder);
|
|
4936
4739
|
case 3:
|
|
4937
4740
|
shopOrderNumber = order.shop_order_number;
|
|
4938
4741
|
shopFullOrderNumber = order.shop_full_order_number;
|
|
@@ -4943,88 +4746,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4943
4746
|
tempOrder.shop_full_order_number = String(shopFullOrderNumber);
|
|
4944
4747
|
}
|
|
4945
4748
|
this.persistTempOrder();
|
|
4946
|
-
|
|
4749
|
+
_context30.next = 10;
|
|
4947
4750
|
return this.saveDraft();
|
|
4948
4751
|
case 10:
|
|
4949
|
-
return
|
|
4752
|
+
return _context30.abrupt("return", tempOrder);
|
|
4950
4753
|
case 11:
|
|
4951
4754
|
case "end":
|
|
4952
|
-
return
|
|
4755
|
+
return _context30.stop();
|
|
4953
4756
|
}
|
|
4954
|
-
},
|
|
4757
|
+
}, _callee27, this);
|
|
4955
4758
|
}));
|
|
4956
|
-
function applyLocalPrintOrderNumbers(
|
|
4759
|
+
function applyLocalPrintOrderNumbers(_x35) {
|
|
4957
4760
|
return _applyLocalPrintOrderNumbers.apply(this, arguments);
|
|
4958
4761
|
}
|
|
4959
4762
|
return applyLocalPrintOrderNumbers;
|
|
4960
4763
|
}()
|
|
4961
|
-
}, {
|
|
4962
|
-
key: "saveTempOrderAsDraft",
|
|
4963
|
-
value: function () {
|
|
4964
|
-
var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
4965
|
-
var _params$cacheId2, _this$otherParams6, _this$otherParams7, _this$otherParams8, _params$type, _this$otherParams9, _payload$products;
|
|
4966
|
-
var tempOrder, latestSummary, payload;
|
|
4967
|
-
return _regeneratorRuntime().wrap(function _callee31$(_context34) {
|
|
4968
|
-
while (1) switch (_context34.prev = _context34.next) {
|
|
4969
|
-
case 0:
|
|
4970
|
-
tempOrder = this.ensureTempOrder();
|
|
4971
|
-
this.ensureExternalSaleNumber(tempOrder);
|
|
4972
|
-
this.persistTempOrder();
|
|
4973
|
-
_context34.next = 5;
|
|
4974
|
-
return this.recalculateSummary({
|
|
4975
|
-
createIfMissing: true
|
|
4976
|
-
});
|
|
4977
|
-
case 5:
|
|
4978
|
-
_context34.t1 = _context34.sent;
|
|
4979
|
-
if (_context34.t1) {
|
|
4980
|
-
_context34.next = 8;
|
|
4981
|
-
break;
|
|
4982
|
-
}
|
|
4983
|
-
_context34.t1 = this.store.summary;
|
|
4984
|
-
case 8:
|
|
4985
|
-
_context34.t0 = _context34.t1;
|
|
4986
|
-
if (_context34.t0) {
|
|
4987
|
-
_context34.next = 11;
|
|
4988
|
-
break;
|
|
4989
|
-
}
|
|
4990
|
-
_context34.t0 = createEmptySummary();
|
|
4991
|
-
case 11:
|
|
4992
|
-
latestSummary = _context34.t0;
|
|
4993
|
-
payload = buildSubmitPayload({
|
|
4994
|
-
tempOrder: tempOrder,
|
|
4995
|
-
cacheId: (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId,
|
|
4996
|
-
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform),
|
|
4997
|
-
businessCode: (params === null || params === void 0 ? void 0 : params.businessCode) || ((_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode) || ((_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.business_code) || tempOrder.business_code,
|
|
4998
|
-
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
4999
|
-
type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.type,
|
|
5000
|
-
summary: latestSummary,
|
|
5001
|
-
enhance: params === null || params === void 0 ? void 0 : params.enhancePayload
|
|
5002
|
-
});
|
|
5003
|
-
if (!payload.created_at) {
|
|
5004
|
-
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
5005
|
-
}
|
|
5006
|
-
payload.need_sync = 0;
|
|
5007
|
-
payload.is_draft_order = 1;
|
|
5008
|
-
this.logInfo('saveTempOrderAsDraft calling sales draft', {
|
|
5009
|
-
orderId: payload.order_id,
|
|
5010
|
-
externalSaleNumber: payload.external_sale_number,
|
|
5011
|
-
productsCount: ((_payload$products = payload.products) === null || _payload$products === void 0 ? void 0 : _payload$products.length) || 0
|
|
5012
|
-
});
|
|
5013
|
-
return _context34.abrupt("return", this.request.post('/order/sales/draft', payload, {
|
|
5014
|
-
osServer: true,
|
|
5015
|
-
customToast: function customToast() {}
|
|
5016
|
-
}));
|
|
5017
|
-
case 18:
|
|
5018
|
-
case "end":
|
|
5019
|
-
return _context34.stop();
|
|
5020
|
-
}
|
|
5021
|
-
}, _callee31, this);
|
|
5022
|
-
}));
|
|
5023
|
-
function saveTempOrderAsDraft(_x41) {
|
|
5024
|
-
return _saveTempOrderAsDraft.apply(this, arguments);
|
|
5025
|
-
}
|
|
5026
|
-
return saveTempOrderAsDraft;
|
|
5027
|
-
}()
|
|
5028
4764
|
/**
|
|
5029
4765
|
* 提交当前 Sales tempOrder。
|
|
5030
4766
|
*
|
|
@@ -5034,18 +4770,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5034
4770
|
}, {
|
|
5035
4771
|
key: "submitTempOrder",
|
|
5036
4772
|
value: (function () {
|
|
5037
|
-
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5038
|
-
return _regeneratorRuntime().wrap(function
|
|
5039
|
-
while (1) switch (
|
|
4773
|
+
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
4774
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context31) {
|
|
4775
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
5040
4776
|
case 0:
|
|
5041
|
-
return
|
|
4777
|
+
return _context31.abrupt("return", this.runSubmitTempOrder(params));
|
|
5042
4778
|
case 1:
|
|
5043
4779
|
case "end":
|
|
5044
|
-
return
|
|
4780
|
+
return _context31.stop();
|
|
5045
4781
|
}
|
|
5046
|
-
},
|
|
4782
|
+
}, _callee28, this);
|
|
5047
4783
|
}));
|
|
5048
|
-
function submitTempOrder(
|
|
4784
|
+
function submitTempOrder(_x36) {
|
|
5049
4785
|
return _submitTempOrder.apply(this, arguments);
|
|
5050
4786
|
}
|
|
5051
4787
|
return submitTempOrder;
|
|
@@ -5053,20 +4789,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5053
4789
|
}, {
|
|
5054
4790
|
key: "submitTempOrderAsync",
|
|
5055
4791
|
value: function () {
|
|
5056
|
-
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5057
|
-
return _regeneratorRuntime().wrap(function
|
|
5058
|
-
while (1) switch (
|
|
4792
|
+
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
4793
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context32) {
|
|
4794
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
5059
4795
|
case 0:
|
|
5060
|
-
return
|
|
4796
|
+
return _context32.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
5061
4797
|
syncMode: true
|
|
5062
4798
|
})));
|
|
5063
4799
|
case 1:
|
|
5064
4800
|
case "end":
|
|
5065
|
-
return
|
|
4801
|
+
return _context32.stop();
|
|
5066
4802
|
}
|
|
5067
|
-
},
|
|
4803
|
+
}, _callee29, this);
|
|
5068
4804
|
}));
|
|
5069
|
-
function submitTempOrderAsync(
|
|
4805
|
+
function submitTempOrderAsync(_x37) {
|
|
5070
4806
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
5071
4807
|
}
|
|
5072
4808
|
return submitTempOrderAsync;
|
|
@@ -5074,11 +4810,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5074
4810
|
}, {
|
|
5075
4811
|
key: "runSubmitTempOrder",
|
|
5076
4812
|
value: function () {
|
|
5077
|
-
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5078
|
-
var _params$
|
|
4813
|
+
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
|
|
4814
|
+
var _params$cacheId2, _this$otherParams6, _ref73, _ref74, _submitSnapshot$busin, _this$otherParams7, _this$otherParams8, _submitSnapshot$type;
|
|
5079
4815
|
var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
|
|
5080
|
-
return _regeneratorRuntime().wrap(function
|
|
5081
|
-
while (1) switch (
|
|
4816
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context33) {
|
|
4817
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
5082
4818
|
case 0:
|
|
5083
4819
|
tempOrder = this.ensureTempOrder();
|
|
5084
4820
|
shouldConfirmPendingVoucherPayments = (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== false;
|
|
@@ -5098,27 +4834,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5098
4834
|
}
|
|
5099
4835
|
}
|
|
5100
4836
|
this.persistTempOrder();
|
|
5101
|
-
|
|
4837
|
+
_context33.next = 8;
|
|
5102
4838
|
return this.recalculateSummary({
|
|
5103
4839
|
createIfMissing: true
|
|
5104
4840
|
});
|
|
5105
4841
|
case 8:
|
|
5106
|
-
|
|
5107
|
-
if (
|
|
5108
|
-
|
|
4842
|
+
_context33.t1 = _context33.sent;
|
|
4843
|
+
if (_context33.t1) {
|
|
4844
|
+
_context33.next = 11;
|
|
5109
4845
|
break;
|
|
5110
4846
|
}
|
|
5111
|
-
|
|
4847
|
+
_context33.t1 = this.store.summary;
|
|
5112
4848
|
case 11:
|
|
5113
|
-
|
|
5114
|
-
if (
|
|
5115
|
-
|
|
4849
|
+
_context33.t0 = _context33.t1;
|
|
4850
|
+
if (_context33.t0) {
|
|
4851
|
+
_context33.next = 14;
|
|
5116
4852
|
break;
|
|
5117
4853
|
}
|
|
5118
|
-
|
|
4854
|
+
_context33.t0 = createEmptySummary();
|
|
5119
4855
|
case 14:
|
|
5120
|
-
latestSummary =
|
|
5121
|
-
effectiveCacheId = (_params$
|
|
4856
|
+
latestSummary = _context33.t0;
|
|
4857
|
+
effectiveCacheId = (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId;
|
|
5122
4858
|
hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
|
|
5123
4859
|
hasSmallTicketDataFlagOverride = (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined;
|
|
5124
4860
|
enhancePayload = hasPaymentOverride || hasPaymentStatusOverride || hasSmallTicketDataFlagOverride || params !== null && params !== void 0 && params.enhancePayload ? function (payload, ctx) {
|
|
@@ -5136,8 +4872,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5136
4872
|
payload = buildSubmitPayload({
|
|
5137
4873
|
tempOrder: tempOrder,
|
|
5138
4874
|
cacheId: effectiveCacheId,
|
|
5139
|
-
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$
|
|
5140
|
-
businessCode: (_ref73 = (_ref74 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref74 !== void 0 ? _ref74 : (_this$
|
|
4875
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform),
|
|
4876
|
+
businessCode: (_ref73 = (_ref74 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref74 !== void 0 ? _ref74 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode) !== null && _ref73 !== void 0 ? _ref73 : (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.business_code,
|
|
5141
4877
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
5142
4878
|
type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
|
|
5143
4879
|
summary: latestSummary,
|
|
@@ -5152,10 +4888,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5152
4888
|
if (!payload.created_at) {
|
|
5153
4889
|
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
5154
4890
|
}
|
|
5155
|
-
|
|
4891
|
+
_context33.next = 26;
|
|
5156
4892
|
return this.saveDraft();
|
|
5157
4893
|
case 26:
|
|
5158
|
-
|
|
4894
|
+
_context33.prev = 26;
|
|
5159
4895
|
this.logInfo('submitTempOrder calling sales checkout', {
|
|
5160
4896
|
orderId: payload.order_id,
|
|
5161
4897
|
externalSaleNumber: payload.external_sale_number,
|
|
@@ -5165,43 +4901,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5165
4901
|
smallTicketDataFlag: payload.small_ticket_data_flag,
|
|
5166
4902
|
syncMode: payload.sync_mode
|
|
5167
4903
|
});
|
|
5168
|
-
|
|
4904
|
+
_context33.next = 30;
|
|
5169
4905
|
return this.submitSalesOrder({
|
|
5170
4906
|
query: payload
|
|
5171
4907
|
});
|
|
5172
4908
|
case 30:
|
|
5173
|
-
result =
|
|
5174
|
-
|
|
4909
|
+
result = _context33.sent;
|
|
4910
|
+
_context33.next = 43;
|
|
5175
4911
|
break;
|
|
5176
4912
|
case 33:
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
backendErrorResponse = this.extractSubmitErrorResponse(
|
|
4913
|
+
_context33.prev = 33;
|
|
4914
|
+
_context33.t2 = _context33["catch"](26);
|
|
4915
|
+
backendErrorResponse = this.extractSubmitErrorResponse(_context33.t2);
|
|
5180
4916
|
if (!backendErrorResponse) {
|
|
5181
|
-
|
|
4917
|
+
_context33.next = 40;
|
|
5182
4918
|
break;
|
|
5183
4919
|
}
|
|
5184
4920
|
this.store.syncState = 'failed';
|
|
5185
4921
|
this.logSubmitBackendRejected(backendErrorResponse, payload);
|
|
5186
|
-
return
|
|
4922
|
+
return _context33.abrupt("return", backendErrorResponse);
|
|
5187
4923
|
case 40:
|
|
5188
4924
|
this.store.syncState = 'failed';
|
|
5189
4925
|
this.logError('submitTempOrder failed', {
|
|
5190
|
-
error:
|
|
4926
|
+
error: _context33.t2 instanceof Error ? _context33.t2.message : String(_context33.t2),
|
|
5191
4927
|
orderId: payload.order_id,
|
|
5192
4928
|
externalSaleNumber: payload.external_sale_number,
|
|
5193
4929
|
paymentStatus: payload.payment_status,
|
|
5194
4930
|
paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
|
|
5195
4931
|
});
|
|
5196
|
-
throw
|
|
4932
|
+
throw _context33.t2;
|
|
5197
4933
|
case 43:
|
|
5198
4934
|
if (!this.isSubmitResponseRejected(result)) {
|
|
5199
|
-
|
|
4935
|
+
_context33.next = 47;
|
|
5200
4936
|
break;
|
|
5201
4937
|
}
|
|
5202
4938
|
this.store.syncState = 'failed';
|
|
5203
4939
|
this.logSubmitBackendRejected(result, payload);
|
|
5204
|
-
return
|
|
4940
|
+
return _context33.abrupt("return", result);
|
|
5205
4941
|
case 47:
|
|
5206
4942
|
submittedOrderId = this.extractOrderIdFromSubmitResult(result);
|
|
5207
4943
|
this.logInfo('runSubmitTempOrder: 提交成功', {
|
|
@@ -5212,15 +4948,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5212
4948
|
})
|
|
5213
4949
|
});
|
|
5214
4950
|
if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
|
|
5215
|
-
|
|
4951
|
+
_context33.next = 56;
|
|
5216
4952
|
break;
|
|
5217
4953
|
}
|
|
5218
4954
|
tempOrder.order_id = submittedOrderId;
|
|
5219
4955
|
resultRecord = result;
|
|
5220
|
-
|
|
4956
|
+
_context33.next = 54;
|
|
5221
4957
|
return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
|
|
5222
4958
|
case 54:
|
|
5223
|
-
|
|
4959
|
+
_context33.next = 57;
|
|
5224
4960
|
break;
|
|
5225
4961
|
case 56:
|
|
5226
4962
|
if (this.isLocalPendingSubmitResult(result)) {
|
|
@@ -5229,14 +4965,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5229
4965
|
this.store.syncState = 'submitted';
|
|
5230
4966
|
}
|
|
5231
4967
|
case 57:
|
|
5232
|
-
return
|
|
4968
|
+
return _context33.abrupt("return", result);
|
|
5233
4969
|
case 58:
|
|
5234
4970
|
case "end":
|
|
5235
|
-
return
|
|
4971
|
+
return _context33.stop();
|
|
5236
4972
|
}
|
|
5237
|
-
},
|
|
4973
|
+
}, _callee30, this, [[26, 33]]);
|
|
5238
4974
|
}));
|
|
5239
|
-
function runSubmitTempOrder(
|
|
4975
|
+
function runSubmitTempOrder(_x38) {
|
|
5240
4976
|
return _runSubmitTempOrder.apply(this, arguments);
|
|
5241
4977
|
}
|
|
5242
4978
|
return runSubmitTempOrder;
|
|
@@ -5244,10 +4980,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5244
4980
|
}, {
|
|
5245
4981
|
key: "markLocalOrderSynced",
|
|
5246
4982
|
value: function () {
|
|
5247
|
-
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4983
|
+
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(orderId, remoteOrder) {
|
|
5248
4984
|
var tempOrder;
|
|
5249
|
-
return _regeneratorRuntime().wrap(function
|
|
5250
|
-
while (1) switch (
|
|
4985
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context34) {
|
|
4986
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
5251
4987
|
case 0:
|
|
5252
4988
|
tempOrder = this.ensureTempOrder();
|
|
5253
4989
|
tempOrder.order_id = orderId;
|
|
@@ -5255,15 +4991,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5255
4991
|
this.store.lastOrderInfo = remoteOrder;
|
|
5256
4992
|
this.store.syncState = 'submitted';
|
|
5257
4993
|
this.persistTempOrder();
|
|
5258
|
-
|
|
4994
|
+
_context34.next = 8;
|
|
5259
4995
|
return this.saveDraft();
|
|
5260
4996
|
case 8:
|
|
5261
4997
|
case "end":
|
|
5262
|
-
return
|
|
4998
|
+
return _context34.stop();
|
|
5263
4999
|
}
|
|
5264
|
-
},
|
|
5000
|
+
}, _callee31, this);
|
|
5265
5001
|
}));
|
|
5266
|
-
function markLocalOrderSynced(
|
|
5002
|
+
function markLocalOrderSynced(_x39, _x40) {
|
|
5267
5003
|
return _markLocalOrderSynced.apply(this, arguments);
|
|
5268
5004
|
}
|
|
5269
5005
|
return markLocalOrderSynced;
|
|
@@ -5306,10 +5042,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5306
5042
|
value: function extractSubmitErrorResponse(error) {
|
|
5307
5043
|
var _error$response,
|
|
5308
5044
|
_error$response2,
|
|
5309
|
-
|
|
5045
|
+
_this27 = this;
|
|
5310
5046
|
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];
|
|
5311
5047
|
return candidates.find(function (candidate) {
|
|
5312
|
-
return
|
|
5048
|
+
return _this27.isSubmitErrorResponse(candidate);
|
|
5313
5049
|
}) || null;
|
|
5314
5050
|
}
|
|
5315
5051
|
}, {
|
|
@@ -5336,37 +5072,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5336
5072
|
}, {
|
|
5337
5073
|
key: "syncPaymentsToOrder",
|
|
5338
5074
|
value: function () {
|
|
5339
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5340
|
-
var
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
while (1) switch (_context39.prev = _context39.next) {
|
|
5075
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
|
|
5076
|
+
var _params$confirmPendin;
|
|
5077
|
+
var tempOrder, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, submitResult;
|
|
5078
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context35) {
|
|
5079
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
5345
5080
|
case 0:
|
|
5346
5081
|
tempOrder = this.ensureTempOrder();
|
|
5347
|
-
|
|
5348
|
-
return String(payment.payment_number || '').trim() === '';
|
|
5349
|
-
});
|
|
5350
|
-
if (!needsPaymentNumber) {
|
|
5351
|
-
_context39.next = 8;
|
|
5352
|
-
break;
|
|
5353
|
-
}
|
|
5354
|
-
_context39.next = 5;
|
|
5355
|
-
return this.getPaymentNumberDevicePrefixAsync();
|
|
5356
|
-
case 5:
|
|
5357
|
-
_context39.t0 = _context39.sent;
|
|
5358
|
-
_context39.next = 9;
|
|
5359
|
-
break;
|
|
5360
|
-
case 8:
|
|
5361
|
-
_context39.t0 = 'LOCAL';
|
|
5362
|
-
case 9:
|
|
5363
|
-
devicePrefix = _context39.t0;
|
|
5364
|
-
mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
|
|
5365
|
-
return _this31.normalizePaymentSource(payment, {
|
|
5366
|
-
defaultPaid: false,
|
|
5367
|
-
devicePrefix: devicePrefix
|
|
5368
|
-
});
|
|
5369
|
-
}));
|
|
5082
|
+
mappedPayments = mapPaymentItemsToOrderPayments(params.payments || []);
|
|
5370
5083
|
shouldConfirmPendingVoucherPayments = (_params$confirmPendin = params.confirmPendingVoucherPayments) !== null && _params$confirmPendin !== void 0 ? _params$confirmPendin : params.submitWhenPaid === true;
|
|
5371
5084
|
effectivePayments = shouldConfirmPendingVoucherPayments ? this.confirmPendingVoucherPaymentsInList(mappedPayments) : params.confirmPendingVoucherPayments === false ? this.discardPendingVoucherPaymentsFromList(mappedPayments) : mappedPayments;
|
|
5372
5085
|
completion = this.getPaymentCompletion(effectivePayments);
|
|
@@ -5375,24 +5088,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5375
5088
|
tempOrder.payments = effectivePayments;
|
|
5376
5089
|
tempOrder.payment_status = paymentStatus;
|
|
5377
5090
|
this.persistTempOrder();
|
|
5378
|
-
|
|
5091
|
+
_context35.next = 12;
|
|
5379
5092
|
return this.saveDraft();
|
|
5380
|
-
case
|
|
5093
|
+
case 12:
|
|
5381
5094
|
if (params.submitWhenPaid) {
|
|
5382
|
-
|
|
5095
|
+
_context35.next = 14;
|
|
5383
5096
|
break;
|
|
5384
5097
|
}
|
|
5385
|
-
return
|
|
5386
|
-
case
|
|
5098
|
+
return _context35.abrupt("return", completion);
|
|
5099
|
+
case 14:
|
|
5387
5100
|
if (!(this.store.syncState === 'submitting')) {
|
|
5388
|
-
|
|
5101
|
+
_context35.next = 16;
|
|
5389
5102
|
break;
|
|
5390
5103
|
}
|
|
5391
|
-
return
|
|
5392
|
-
case
|
|
5104
|
+
return _context35.abrupt("return", completion);
|
|
5105
|
+
case 16:
|
|
5393
5106
|
this.store.syncState = 'submitting';
|
|
5394
5107
|
paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
|
|
5395
|
-
|
|
5108
|
+
_context35.next = 20;
|
|
5396
5109
|
return this.submitTempOrder({
|
|
5397
5110
|
payments: effectivePayments,
|
|
5398
5111
|
paymentStatus: paymentStatus,
|
|
@@ -5407,18 +5120,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5407
5120
|
return nextPayload;
|
|
5408
5121
|
}
|
|
5409
5122
|
});
|
|
5410
|
-
case
|
|
5411
|
-
submitResult =
|
|
5412
|
-
return
|
|
5123
|
+
case 20:
|
|
5124
|
+
submitResult = _context35.sent;
|
|
5125
|
+
return _context35.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
|
|
5413
5126
|
submitResult: submitResult
|
|
5414
5127
|
}));
|
|
5415
|
-
case
|
|
5128
|
+
case 22:
|
|
5416
5129
|
case "end":
|
|
5417
|
-
return
|
|
5130
|
+
return _context35.stop();
|
|
5418
5131
|
}
|
|
5419
|
-
},
|
|
5132
|
+
}, _callee32, this);
|
|
5420
5133
|
}));
|
|
5421
|
-
function syncPaymentsToOrder(
|
|
5134
|
+
function syncPaymentsToOrder(_x41) {
|
|
5422
5135
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
5423
5136
|
}
|
|
5424
5137
|
return syncPaymentsToOrder;
|
|
@@ -5507,11 +5220,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5507
5220
|
}, {
|
|
5508
5221
|
key: "submitOrder",
|
|
5509
5222
|
value: function () {
|
|
5510
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5223
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(order) {
|
|
5511
5224
|
var _order$query$cartItem, _params$bookings, _params$relation_prod;
|
|
5512
5225
|
var url, query, fetchUrl, params;
|
|
5513
|
-
return _regeneratorRuntime().wrap(function
|
|
5514
|
-
while (1) switch (
|
|
5226
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context36) {
|
|
5227
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
5515
5228
|
case 0:
|
|
5516
5229
|
this.logInfo('submitOrder called', {
|
|
5517
5230
|
url: order.url,
|
|
@@ -5531,14 +5244,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5531
5244
|
relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
|
|
5532
5245
|
scheduleDate: params.schedule_date
|
|
5533
5246
|
});
|
|
5534
|
-
return
|
|
5247
|
+
return _context36.abrupt("return", this.request.post(fetchUrl, params));
|
|
5535
5248
|
case 6:
|
|
5536
5249
|
case "end":
|
|
5537
|
-
return
|
|
5250
|
+
return _context36.stop();
|
|
5538
5251
|
}
|
|
5539
|
-
},
|
|
5252
|
+
}, _callee33, this);
|
|
5540
5253
|
}));
|
|
5541
|
-
function submitOrder(
|
|
5254
|
+
function submitOrder(_x42) {
|
|
5542
5255
|
return _submitOrder.apply(this, arguments);
|
|
5543
5256
|
}
|
|
5544
5257
|
return submitOrder;
|
|
@@ -5546,13 +5259,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5546
5259
|
}, {
|
|
5547
5260
|
key: "cancelOrder",
|
|
5548
5261
|
value: function () {
|
|
5549
|
-
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5262
|
+
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
5550
5263
|
var payload;
|
|
5551
|
-
return _regeneratorRuntime().wrap(function
|
|
5552
|
-
while (1) switch (
|
|
5264
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context37) {
|
|
5265
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
5553
5266
|
case 0:
|
|
5554
5267
|
if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
|
|
5555
|
-
|
|
5268
|
+
_context37.next = 2;
|
|
5556
5269
|
break;
|
|
5557
5270
|
}
|
|
5558
5271
|
throw new Error('取消订单失败:order_ids 不能为空');
|
|
@@ -5568,16 +5281,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5568
5281
|
method: 'PUT',
|
|
5569
5282
|
orderIdsCount: params.order_ids.length
|
|
5570
5283
|
});
|
|
5571
|
-
return
|
|
5284
|
+
return _context37.abrupt("return", this.request.put('/order/update-status', payload, {
|
|
5572
5285
|
isShopApi: true
|
|
5573
5286
|
}));
|
|
5574
5287
|
case 5:
|
|
5575
5288
|
case "end":
|
|
5576
|
-
return
|
|
5289
|
+
return _context37.stop();
|
|
5577
5290
|
}
|
|
5578
|
-
},
|
|
5291
|
+
}, _callee34, this);
|
|
5579
5292
|
}));
|
|
5580
|
-
function cancelOrder(
|
|
5293
|
+
function cancelOrder(_x43) {
|
|
5581
5294
|
return _cancelOrder.apply(this, arguments);
|
|
5582
5295
|
}
|
|
5583
5296
|
return cancelOrder;
|
|
@@ -5585,19 +5298,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5585
5298
|
}, {
|
|
5586
5299
|
key: "changeBookingStatus",
|
|
5587
5300
|
value: function () {
|
|
5588
|
-
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5301
|
+
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
|
|
5589
5302
|
var url, payload;
|
|
5590
|
-
return _regeneratorRuntime().wrap(function
|
|
5591
|
-
while (1) switch (
|
|
5303
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context38) {
|
|
5304
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
5592
5305
|
case 0:
|
|
5593
5306
|
if (params.booking_id) {
|
|
5594
|
-
|
|
5307
|
+
_context38.next = 2;
|
|
5595
5308
|
break;
|
|
5596
5309
|
}
|
|
5597
5310
|
throw new Error('变更预约状态失败:booking_id 不能为空');
|
|
5598
5311
|
case 2:
|
|
5599
5312
|
if (params.appointment_status) {
|
|
5600
|
-
|
|
5313
|
+
_context38.next = 4;
|
|
5601
5314
|
break;
|
|
5602
5315
|
}
|
|
5603
5316
|
throw new Error('变更预约状态失败:appointment_status 不能为空');
|
|
@@ -5612,16 +5325,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5612
5325
|
bookingId: params.booking_id,
|
|
5613
5326
|
appointmentStatus: params.appointment_status
|
|
5614
5327
|
});
|
|
5615
|
-
return
|
|
5328
|
+
return _context38.abrupt("return", this.request.put(url, payload, {
|
|
5616
5329
|
isShopApi: true
|
|
5617
5330
|
}));
|
|
5618
5331
|
case 8:
|
|
5619
5332
|
case "end":
|
|
5620
|
-
return
|
|
5333
|
+
return _context38.stop();
|
|
5621
5334
|
}
|
|
5622
|
-
},
|
|
5335
|
+
}, _callee35, this);
|
|
5623
5336
|
}));
|
|
5624
|
-
function changeBookingStatus(
|
|
5337
|
+
function changeBookingStatus(_x44) {
|
|
5625
5338
|
return _changeBookingStatus.apply(this, arguments);
|
|
5626
5339
|
}
|
|
5627
5340
|
return changeBookingStatus;
|
|
@@ -5639,11 +5352,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5639
5352
|
}, {
|
|
5640
5353
|
key: "createOrderByCheckout",
|
|
5641
5354
|
value: (function () {
|
|
5642
|
-
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5355
|
+
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
|
|
5643
5356
|
var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
|
|
5644
5357
|
var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, _orderData$bookings2, _orderData$relation_p2, _orderData$payments4, _orderData$payments5, _response$data, orderData, response;
|
|
5645
|
-
return _regeneratorRuntime().wrap(function
|
|
5646
|
-
while (1) switch (
|
|
5358
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context39) {
|
|
5359
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
5647
5360
|
case 0:
|
|
5648
5361
|
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
5649
5362
|
onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
@@ -5677,7 +5390,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5677
5390
|
relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
|
|
5678
5391
|
paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
|
|
5679
5392
|
});
|
|
5680
|
-
|
|
5393
|
+
_context39.prev = 4;
|
|
5681
5394
|
// 构建订单数据,设置默认值并允许 params 覆盖
|
|
5682
5395
|
orderData = _objectSpread({
|
|
5683
5396
|
sales_channel: 'my_pisel',
|
|
@@ -5739,13 +5452,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5739
5452
|
hasOrderId: !!orderData.order_id,
|
|
5740
5453
|
smallTicketDataFlag: orderData.small_ticket_data_flag
|
|
5741
5454
|
});
|
|
5742
|
-
|
|
5455
|
+
_context39.next = 12;
|
|
5743
5456
|
return this.request.post('/order/checkout', orderData, {
|
|
5744
5457
|
osServer: true,
|
|
5745
5458
|
customToast: function customToast() {}
|
|
5746
5459
|
});
|
|
5747
5460
|
case 12:
|
|
5748
|
-
response =
|
|
5461
|
+
response = _context39.sent;
|
|
5749
5462
|
this.logInfo('Order API called successfully', {
|
|
5750
5463
|
response: response
|
|
5751
5464
|
});
|
|
@@ -5753,22 +5466,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5753
5466
|
success: !!response,
|
|
5754
5467
|
hasOrderId: !!(response !== null && response !== void 0 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data.order_id || response !== null && response !== void 0 && response.order_id)
|
|
5755
5468
|
});
|
|
5756
|
-
return
|
|
5469
|
+
return _context39.abrupt("return", response);
|
|
5757
5470
|
case 18:
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
console.error('[Order] createOrderByCheckout 创建订单失败:',
|
|
5471
|
+
_context39.prev = 18;
|
|
5472
|
+
_context39.t0 = _context39["catch"](4);
|
|
5473
|
+
console.error('[Order] createOrderByCheckout 创建订单失败:', _context39.t0);
|
|
5761
5474
|
this.logInfo('Order API called failed', {
|
|
5762
|
-
error:
|
|
5475
|
+
error: _context39.t0 instanceof Error ? _context39.t0.message : String(_context39.t0)
|
|
5763
5476
|
});
|
|
5764
|
-
throw
|
|
5477
|
+
throw _context39.t0;
|
|
5765
5478
|
case 23:
|
|
5766
5479
|
case "end":
|
|
5767
|
-
return
|
|
5480
|
+
return _context39.stop();
|
|
5768
5481
|
}
|
|
5769
|
-
},
|
|
5482
|
+
}, _callee36, this, [[4, 18]]);
|
|
5770
5483
|
}));
|
|
5771
|
-
function createOrderByCheckout(
|
|
5484
|
+
function createOrderByCheckout(_x45) {
|
|
5772
5485
|
return _createOrderByCheckout.apply(this, arguments);
|
|
5773
5486
|
}
|
|
5774
5487
|
return createOrderByCheckout;
|
|
@@ -5776,24 +5489,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5776
5489
|
}, {
|
|
5777
5490
|
key: "submitSalesOrder",
|
|
5778
5491
|
value: function () {
|
|
5779
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5492
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
|
|
5780
5493
|
var url, query, fetchUrl;
|
|
5781
|
-
return _regeneratorRuntime().wrap(function
|
|
5782
|
-
while (1) switch (
|
|
5494
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context40) {
|
|
5495
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
5783
5496
|
case 0:
|
|
5784
5497
|
url = params.url, query = params.query;
|
|
5785
5498
|
fetchUrl = url || '/order/sales/checkout';
|
|
5786
|
-
return
|
|
5499
|
+
return _context40.abrupt("return", this.request.post(fetchUrl, query, {
|
|
5787
5500
|
osServer: true,
|
|
5788
5501
|
customToast: function customToast() {}
|
|
5789
5502
|
}));
|
|
5790
5503
|
case 3:
|
|
5791
5504
|
case "end":
|
|
5792
|
-
return
|
|
5505
|
+
return _context40.stop();
|
|
5793
5506
|
}
|
|
5794
|
-
},
|
|
5507
|
+
}, _callee37, this);
|
|
5795
5508
|
}));
|
|
5796
|
-
function submitSalesOrder(
|
|
5509
|
+
function submitSalesOrder(_x46) {
|
|
5797
5510
|
return _submitSalesOrder.apply(this, arguments);
|
|
5798
5511
|
}
|
|
5799
5512
|
return submitSalesOrder;
|
|
@@ -5807,37 +5520,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5807
5520
|
}, {
|
|
5808
5521
|
key: "sendCustomerPayLink",
|
|
5809
5522
|
value: (function () {
|
|
5810
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5523
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
|
|
5811
5524
|
var _params$emails;
|
|
5812
5525
|
var orderIds;
|
|
5813
|
-
return _regeneratorRuntime().wrap(function
|
|
5814
|
-
while (1) switch (
|
|
5526
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context41) {
|
|
5527
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
5815
5528
|
case 0:
|
|
5816
5529
|
orderIds = params.order_ids || params.orderIds || [];
|
|
5817
5530
|
if (orderIds.length) {
|
|
5818
|
-
|
|
5531
|
+
_context41.next = 3;
|
|
5819
5532
|
break;
|
|
5820
5533
|
}
|
|
5821
5534
|
throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
|
|
5822
5535
|
case 3:
|
|
5823
5536
|
if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
|
|
5824
|
-
|
|
5537
|
+
_context41.next = 5;
|
|
5825
5538
|
break;
|
|
5826
5539
|
}
|
|
5827
5540
|
throw new Error('发送支付链接需要至少一个邮箱');
|
|
5828
5541
|
case 5:
|
|
5829
|
-
return
|
|
5542
|
+
return _context41.abrupt("return", this.request.post('/order/batch-email', {
|
|
5830
5543
|
order_ids: orderIds,
|
|
5831
5544
|
notify_action: params.notify_action || 'order_payment_reminder',
|
|
5832
5545
|
emails: params.emails
|
|
5833
5546
|
}));
|
|
5834
5547
|
case 6:
|
|
5835
5548
|
case "end":
|
|
5836
|
-
return
|
|
5549
|
+
return _context41.stop();
|
|
5837
5550
|
}
|
|
5838
|
-
},
|
|
5551
|
+
}, _callee38, this);
|
|
5839
5552
|
}));
|
|
5840
|
-
function sendCustomerPayLink(
|
|
5553
|
+
function sendCustomerPayLink(_x47) {
|
|
5841
5554
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
5842
5555
|
}
|
|
5843
5556
|
return sendCustomerPayLink;
|
|
@@ -5845,14 +5558,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5845
5558
|
}, {
|
|
5846
5559
|
key: "getSalesOrderByLookup",
|
|
5847
5560
|
value: function () {
|
|
5848
|
-
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5561
|
+
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
5849
5562
|
var lookup, res;
|
|
5850
|
-
return _regeneratorRuntime().wrap(function
|
|
5851
|
-
while (1) switch (
|
|
5563
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context42) {
|
|
5564
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
5852
5565
|
case 0:
|
|
5853
5566
|
lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
|
|
5854
5567
|
if (lookup) {
|
|
5855
|
-
|
|
5568
|
+
_context42.next = 3;
|
|
5856
5569
|
break;
|
|
5857
5570
|
}
|
|
5858
5571
|
throw new Error('加载销售详情需要 lookup');
|
|
@@ -5861,27 +5574,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5861
5574
|
if (lookup.startsWith('LOCAL_')) {
|
|
5862
5575
|
params.forceRemote = false;
|
|
5863
5576
|
}
|
|
5864
|
-
|
|
5577
|
+
_context42.next = 6;
|
|
5865
5578
|
return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
|
|
5866
|
-
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info'
|
|
5579
|
+
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info']
|
|
5867
5580
|
}, params.forceRemote ? {
|
|
5868
5581
|
forceRemote: true
|
|
5869
5582
|
} : {}), {
|
|
5870
5583
|
osServer: true
|
|
5871
5584
|
});
|
|
5872
5585
|
case 6:
|
|
5873
|
-
res =
|
|
5586
|
+
res = _context42.sent;
|
|
5874
5587
|
if (res.code === 200) {
|
|
5875
5588
|
this.store.lastOrderInfo = res.data;
|
|
5876
5589
|
}
|
|
5877
|
-
return
|
|
5590
|
+
return _context42.abrupt("return", res);
|
|
5878
5591
|
case 9:
|
|
5879
5592
|
case "end":
|
|
5880
|
-
return
|
|
5593
|
+
return _context42.stop();
|
|
5881
5594
|
}
|
|
5882
|
-
},
|
|
5595
|
+
}, _callee39, this);
|
|
5883
5596
|
}));
|
|
5884
|
-
function getSalesOrderByLookup(
|
|
5597
|
+
function getSalesOrderByLookup(_x48) {
|
|
5885
5598
|
return _getSalesOrderByLookup.apply(this, arguments);
|
|
5886
5599
|
}
|
|
5887
5600
|
return getSalesOrderByLookup;
|
|
@@ -5895,11 +5608,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5895
5608
|
}, {
|
|
5896
5609
|
key: "hydrateTempOrderFromRecord",
|
|
5897
5610
|
value: (function () {
|
|
5898
|
-
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5899
|
-
var _this$store$
|
|
5900
|
-
var sourceRaw, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, nextTempOrder,
|
|
5901
|
-
return _regeneratorRuntime().wrap(function
|
|
5902
|
-
while (1) switch (
|
|
5611
|
+
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(record, options) {
|
|
5612
|
+
var _this$store$discount19;
|
|
5613
|
+
var sourceRaw, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, nextTempOrder, rawSummary, summarySurcharges, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount20, _this$store$discount21;
|
|
5614
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context43) {
|
|
5615
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
5903
5616
|
case 0:
|
|
5904
5617
|
sourceRaw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
|
|
5905
5618
|
identityReadySource = this.seedAnonymousBookingUidsFromProducts(sourceRaw);
|
|
@@ -5924,13 +5637,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5924
5637
|
}
|
|
5925
5638
|
nextTempOrder = this.normalizeTempOrderForRuntime(raw, {
|
|
5926
5639
|
makeEditMark: true
|
|
5927
|
-
});
|
|
5928
|
-
sourceLastOrderInfo = raw.lastOrderInfo || raw;
|
|
5929
|
-
isDraftOrder = Number(nextTempOrder.is_draft_order || 0) === 1;
|
|
5930
|
-
syntheticIdentityOptions = {
|
|
5931
|
-
isDraftOrder: isDraftOrder,
|
|
5932
|
-
externalSaleNumber: nextTempOrder.external_sale_number
|
|
5933
|
-
};
|
|
5640
|
+
});
|
|
5934
5641
|
rawSummary = raw.summary && _typeof(raw.summary) === 'object' ? raw.summary : {};
|
|
5935
5642
|
summarySurcharges = Array.isArray(rawSummary.surcharges) ? rawSummary.surcharges.map(function (s) {
|
|
5936
5643
|
return _objectSpread({}, s || {});
|
|
@@ -5950,13 +5657,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5950
5657
|
productFingerprint: this.buildOrderProductsFingerprint(nextTempOrder.products || [])
|
|
5951
5658
|
}
|
|
5952
5659
|
});
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
}
|
|
5660
|
+
// lastOrderInfo carries the exact backend snapshot used by deposit/type recovery.
|
|
5661
|
+
// Runtime collection repair lives in tempOrder/originalSalesSnapshot and must not
|
|
5662
|
+
// rewrite this protocol snapshot as a side effect of hydration.
|
|
5663
|
+
this.store.lastOrderInfo = sourceRaw.lastOrderInfo || sourceRaw;
|
|
5958
5664
|
hydratedEditDiscounts = this.collectHydratedEditDiscounts(nextTempOrder.products);
|
|
5959
|
-
currentDiscounts = typeof ((_this$store$
|
|
5665
|
+
currentDiscounts = typeof ((_this$store$discount19 = this.store.discount) === null || _this$store$discount19 === void 0 ? void 0 : _this$store$discount19.getDiscountList) === 'function' ? this.store.discount.getDiscountList() || [] : [];
|
|
5960
5666
|
currentScanDiscounts = currentDiscounts.filter(function (discount) {
|
|
5961
5667
|
return discount === null || discount === void 0 ? void 0 : discount.isScan;
|
|
5962
5668
|
});
|
|
@@ -5969,34 +5675,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5969
5675
|
nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
|
|
5970
5676
|
shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
|
|
5971
5677
|
if (shouldSkipEmptyDiscountSync) {
|
|
5972
|
-
|
|
5678
|
+
_context43.next = 26;
|
|
5973
5679
|
break;
|
|
5974
5680
|
}
|
|
5975
5681
|
OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
|
|
5976
|
-
|
|
5977
|
-
return (_this$store$
|
|
5978
|
-
case
|
|
5979
|
-
|
|
5980
|
-
return (_this$store$
|
|
5981
|
-
case
|
|
5682
|
+
_context43.next = 24;
|
|
5683
|
+
return (_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 ? void 0 : _this$store$discount20.setOriginalDiscountList(nextDiscounts);
|
|
5684
|
+
case 24:
|
|
5685
|
+
_context43.next = 26;
|
|
5686
|
+
return (_this$store$discount21 = this.store.discount) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.setDiscountList(nextDiscounts);
|
|
5687
|
+
case 26:
|
|
5982
5688
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
5983
|
-
|
|
5689
|
+
_context43.next = 29;
|
|
5984
5690
|
break;
|
|
5985
5691
|
}
|
|
5986
|
-
|
|
5692
|
+
_context43.next = 29;
|
|
5987
5693
|
return this.recalculateSummary({
|
|
5988
5694
|
createIfMissing: false
|
|
5989
5695
|
});
|
|
5990
|
-
case
|
|
5696
|
+
case 29:
|
|
5991
5697
|
this.persistTempOrder();
|
|
5992
|
-
return
|
|
5993
|
-
case
|
|
5698
|
+
return _context43.abrupt("return", nextTempOrder);
|
|
5699
|
+
case 31:
|
|
5994
5700
|
case "end":
|
|
5995
|
-
return
|
|
5701
|
+
return _context43.stop();
|
|
5996
5702
|
}
|
|
5997
|
-
},
|
|
5703
|
+
}, _callee40, this);
|
|
5998
5704
|
}));
|
|
5999
|
-
function hydrateTempOrderFromRecord(
|
|
5705
|
+
function hydrateTempOrderFromRecord(_x49, _x50) {
|
|
6000
5706
|
return _hydrateTempOrderFromRecord.apply(this, arguments);
|
|
6001
5707
|
}
|
|
6002
5708
|
return hydrateTempOrderFromRecord;
|
|
@@ -6110,12 +5816,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6110
5816
|
}, {
|
|
6111
5817
|
key: "normalizeTempOrderForRuntime",
|
|
6112
5818
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
6113
|
-
var
|
|
6114
|
-
var
|
|
6115
|
-
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
|
|
5819
|
+
var _this28 = this;
|
|
5820
|
+
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), raw || {});
|
|
6116
5821
|
// ES 列表详情使用 id 表示订单主键;OS 详情态统一依赖 order_id 驱动操作按钮。
|
|
6117
|
-
if ((nextTempOrder.order_id === undefined || nextTempOrder.order_id === null) && (
|
|
6118
|
-
nextTempOrder.order_id =
|
|
5822
|
+
if ((nextTempOrder.order_id === undefined || nextTempOrder.order_id === null) && (raw === null || raw === void 0 ? void 0 : raw.id) !== undefined && (raw === null || raw === void 0 ? void 0 : raw.id) !== null) {
|
|
5823
|
+
nextTempOrder.order_id = raw.id;
|
|
6119
5824
|
}
|
|
6120
5825
|
delete nextTempOrder.summary;
|
|
6121
5826
|
delete nextTempOrder.lastOrderInfo;
|
|
@@ -6134,12 +5839,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6134
5839
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
6135
5840
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
6136
5841
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
6137
|
-
return
|
|
5842
|
+
return _this28.normalizeHydratedOrderProduct(p, {
|
|
6138
5843
|
makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
|
|
6139
5844
|
});
|
|
6140
5845
|
}) : [];
|
|
6141
5846
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
6142
|
-
var booking =
|
|
5847
|
+
var booking = _this28.normalizeHydratedBookingHolder(b || {});
|
|
6143
5848
|
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
6144
5849
|
is_all: normalizeBookingIsAll(booking),
|
|
6145
5850
|
sub_type: normalizeBookingSubType(booking)
|
|
@@ -6205,23 +5910,6 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6205
5910
|
nextTempOrder.vouchers = raw.vouchers || [];
|
|
6206
5911
|
return nextTempOrder;
|
|
6207
5912
|
}
|
|
6208
|
-
}, {
|
|
6209
|
-
key: "isSyntheticDraftOrderIdForRuntime",
|
|
6210
|
-
value: function isSyntheticDraftOrderIdForRuntime(record, options) {
|
|
6211
|
-
var _options$isDraftOrder, _record$external_sale;
|
|
6212
|
-
var isDraftOrder = (_options$isDraftOrder = options === null || options === void 0 ? void 0 : options.isDraftOrder) !== null && _options$isDraftOrder !== void 0 ? _options$isDraftOrder : Number((record === null || record === void 0 ? void 0 : record.is_draft_order) || 0) === 1;
|
|
6213
|
-
var externalSaleNumber = (_record$external_sale = record === null || record === void 0 ? void 0 : record.external_sale_number) !== null && _record$external_sale !== void 0 ? _record$external_sale : options === null || options === void 0 ? void 0 : options.externalSaleNumber;
|
|
6214
|
-
var orderId = record === null || record === void 0 ? void 0 : record.order_id;
|
|
6215
|
-
return Boolean(isDraftOrder && orderId !== undefined && orderId !== null && orderId !== '' && externalSaleNumber !== undefined && externalSaleNumber !== null && externalSaleNumber !== '' && String(orderId) === String(externalSaleNumber));
|
|
6216
|
-
}
|
|
6217
|
-
}, {
|
|
6218
|
-
key: "withoutSyntheticDraftOrderIdForRuntime",
|
|
6219
|
-
value: function withoutSyntheticDraftOrderIdForRuntime(record, options) {
|
|
6220
|
-
if (!this.isSyntheticDraftOrderIdForRuntime(record, options)) return record;
|
|
6221
|
-
return _objectSpread(_objectSpread({}, record), {}, {
|
|
6222
|
-
order_id: null
|
|
6223
|
-
});
|
|
6224
|
-
}
|
|
6225
5913
|
}, {
|
|
6226
5914
|
key: "hydrateLinkedBookingIdentity",
|
|
6227
5915
|
value: function hydrateLinkedBookingIdentity(tempOrder) {
|
|
@@ -6326,7 +6014,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6326
6014
|
}, {
|
|
6327
6015
|
key: "normalizeHydratedOrderProduct",
|
|
6328
6016
|
value: function normalizeHydratedOrderProduct(product, options) {
|
|
6329
|
-
var
|
|
6017
|
+
var _this29 = this;
|
|
6330
6018
|
var row = _objectSpread({}, product || {});
|
|
6331
6019
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
6332
6020
|
row.num = row.product_quantity;
|
|
@@ -6334,7 +6022,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6334
6022
|
var productSku = ensureProductSku(row);
|
|
6335
6023
|
row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
|
|
6336
6024
|
option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
|
|
6337
|
-
return
|
|
6025
|
+
return _this29.normalizeHydratedProductOptionItem(optionItem || {});
|
|
6338
6026
|
}))
|
|
6339
6027
|
});
|
|
6340
6028
|
delete row["product_".concat('option', "_item")];
|
|
@@ -6371,27 +6059,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6371
6059
|
}, {
|
|
6372
6060
|
key: "getOrderInfo",
|
|
6373
6061
|
value: function () {
|
|
6374
|
-
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6062
|
+
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(order_id) {
|
|
6375
6063
|
var res;
|
|
6376
|
-
return _regeneratorRuntime().wrap(function
|
|
6377
|
-
while (1) switch (
|
|
6064
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context44) {
|
|
6065
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
6378
6066
|
case 0:
|
|
6379
|
-
|
|
6067
|
+
_context44.next = 2;
|
|
6380
6068
|
return this.request.get("/order/sales/".concat(order_id), {
|
|
6381
6069
|
with: ['products', 'bookings']
|
|
6382
6070
|
}, {
|
|
6383
6071
|
osServer: true
|
|
6384
6072
|
});
|
|
6385
6073
|
case 2:
|
|
6386
|
-
res =
|
|
6387
|
-
return
|
|
6074
|
+
res = _context44.sent;
|
|
6075
|
+
return _context44.abrupt("return", res);
|
|
6388
6076
|
case 4:
|
|
6389
6077
|
case "end":
|
|
6390
|
-
return
|
|
6078
|
+
return _context44.stop();
|
|
6391
6079
|
}
|
|
6392
|
-
},
|
|
6080
|
+
}, _callee41, this);
|
|
6393
6081
|
}));
|
|
6394
|
-
function getOrderInfo(
|
|
6082
|
+
function getOrderInfo(_x51) {
|
|
6395
6083
|
return _getOrderInfo.apply(this, arguments);
|
|
6396
6084
|
}
|
|
6397
6085
|
return getOrderInfo;
|