@pisell/pisellos 2.2.274 → 2.2.275
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 +2 -0
- package/dist/core/index.js +7 -0
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/dist/model/strategy/adapter/promotion/adapter.js +23 -0
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/dist/model/strategy/adapter/promotion/evaluator.js +279 -6
- package/dist/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/dist/model/strategy/adapter/promotion/examples.js +99 -0
- package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/dist/model/strategy/adapter/promotion/index.js +1 -1
- package/dist/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/dist/model/strategy/adapter/promotion/type.js +45 -0
- package/dist/modules/OpenData/index.d.ts +2 -0
- package/dist/modules/OpenData/index.js +8 -0
- package/dist/modules/Order/index.d.ts +28 -8
- package/dist/modules/Order/index.js +821 -503
- package/dist/modules/Order/payment-utils.d.ts +26 -0
- package/dist/modules/Order/payment-utils.js +225 -0
- package/dist/modules/Order/types.d.ts +35 -1
- package/dist/modules/Order/utils/orderCollectionIdentity.js +7 -2
- package/dist/modules/Order/utils.js +10 -6
- package/dist/modules/Payment/index.d.ts +2 -0
- package/dist/modules/Payment/index.js +78 -49
- package/dist/modules/Payment/types.d.ts +104 -25
- package/dist/modules/Payment/types.js +17 -0
- package/dist/modules/Payment/walletpass.d.ts +38 -1
- package/dist/modules/Payment/walletpass.js +917 -114
- package/dist/modules/Rules/index.d.ts +3 -0
- package/dist/modules/Rules/index.js +100 -70
- package/dist/server/index.d.ts +20 -0
- package/dist/server/index.js +1955 -1049
- package/dist/server/modules/index.d.ts +1 -1
- package/dist/server/modules/order/index.d.ts +70 -4
- package/dist/server/modules/order/index.js +1816 -728
- package/dist/server/modules/order/types.d.ts +25 -3
- package/dist/server/modules/order/types.js +7 -1
- package/dist/solution/BaseSales/index.d.ts +104 -5
- package/dist/solution/BaseSales/index.js +1767 -436
- package/dist/solution/BaseSales/types.d.ts +55 -1
- package/dist/solution/BaseSales/types.js +2 -1
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/dist/solution/BaseSales/utils/cartPromotion.js +94 -32
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +6 -3
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +20 -4
- package/dist/solution/BookingTicket/index.js +138 -52
- package/dist/solution/BookingTicket/types.d.ts +1 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +173 -83
- package/dist/solution/Sales/index.d.ts +2 -0
- package/dist/solution/Sales/index.js +26 -4
- package/dist/solution/ScanOrder/index.js +31 -20
- package/dist/solution/VenueBooking/index.d.ts +1 -0
- package/dist/solution/VenueBooking/index.js +30 -19
- package/dist/types/index.d.ts +1 -0
- package/dist/utils/payment-number.d.ts +9 -0
- package/dist/utils/payment-number.js +69 -0
- package/lib/core/index.d.ts +2 -0
- package/lib/core/index.js +4 -0
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +4 -0
- package/lib/model/strategy/adapter/promotion/adapter.js +20 -0
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +17 -0
- package/lib/model/strategy/adapter/promotion/evaluator.js +235 -0
- package/lib/model/strategy/adapter/promotion/examples.d.ts +86 -0
- package/lib/model/strategy/adapter/promotion/examples.js +91 -0
- package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/lib/model/strategy/adapter/promotion/type.js +2 -0
- package/lib/modules/OpenData/index.d.ts +2 -0
- package/lib/modules/OpenData/index.js +5 -0
- package/lib/modules/Order/index.d.ts +28 -8
- package/lib/modules/Order/index.js +240 -74
- package/lib/modules/Order/payment-utils.d.ts +26 -0
- package/lib/modules/Order/payment-utils.js +224 -0
- package/lib/modules/Order/types.d.ts +35 -1
- package/lib/modules/Order/utils/orderCollectionIdentity.js +3 -0
- package/lib/modules/Order/utils.js +11 -4
- package/lib/modules/Payment/index.d.ts +2 -0
- package/lib/modules/Payment/index.js +33 -12
- package/lib/modules/Payment/types.d.ts +104 -25
- package/lib/modules/Payment/types.js +1 -0
- package/lib/modules/Payment/walletpass.d.ts +38 -1
- package/lib/modules/Payment/walletpass.js +730 -21
- package/lib/modules/Rules/index.d.ts +3 -0
- package/lib/modules/Rules/index.js +38 -9
- package/lib/server/index.d.ts +20 -0
- package/lib/server/index.js +684 -24
- package/lib/server/modules/index.d.ts +1 -1
- package/lib/server/modules/order/index.d.ts +70 -4
- package/lib/server/modules/order/index.js +818 -69
- package/lib/server/modules/order/types.d.ts +25 -3
- package/lib/server/modules/order/types.js +1 -0
- package/lib/solution/BaseSales/index.d.ts +104 -5
- package/lib/solution/BaseSales/index.js +858 -27
- package/lib/solution/BaseSales/types.d.ts +55 -1
- package/lib/solution/BaseSales/types.js +2 -1
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +3 -1
- package/lib/solution/BaseSales/utils/cartPromotion.js +66 -12
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +6 -1
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +3 -2
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +20 -4
- package/lib/solution/BookingTicket/index.js +63 -9
- package/lib/solution/BookingTicket/types.d.ts +1 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +8 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +37 -5
- package/lib/solution/Sales/index.d.ts +2 -0
- package/lib/solution/Sales/index.js +20 -6
- package/lib/solution/ScanOrder/index.js +8 -0
- package/lib/solution/VenueBooking/index.d.ts +1 -0
- package/lib/solution/VenueBooking/index.js +8 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/utils/payment-number.d.ts +9 -0
- package/lib/utils/payment-number.js +64 -0
- package/package.json +1 -1
|
@@ -10,8 +10,6 @@ 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; }
|
|
15
13
|
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; } } }; }
|
|
16
14
|
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); }
|
|
17
15
|
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; }
|
|
@@ -27,6 +25,8 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
|
27
25
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
28
26
|
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; } }
|
|
29
27
|
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,6 +35,8 @@ 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";
|
|
38
40
|
import { processCartPromotion, appendPromotionTags as _appendPromotionTags, getOrderProductUid as getPromotionUid } from "../../solution/BaseSales/utils/cartPromotion";
|
|
39
41
|
import { buildProductLineFingerprint, getProductIdentityIndex, getSafeProductNum, isIdentityMatch, normalizeOrderProduct } from "../../solution/ScanOrder/utils";
|
|
40
42
|
import { syncManualProductDiscountProductNum } from "./utils/manualProductDiscount";
|
|
@@ -68,6 +70,22 @@ function isManualProductDiscountProduct(product) {
|
|
|
68
70
|
}
|
|
69
71
|
var ORDER_PAYMENT_STATUS_PAID = 'paid';
|
|
70
72
|
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
|
+
}
|
|
71
89
|
function isVoucherPaymentRecord(payment) {
|
|
72
90
|
return (payment === null || payment === void 0 ? void 0 : payment.voucher_id) !== undefined && Number(payment.voucher_id) !== 0;
|
|
73
91
|
}
|
|
@@ -83,6 +101,10 @@ function isPaidPaymentRecord(payment) {
|
|
|
83
101
|
function isCommittedVoucherPaymentRecord(payment) {
|
|
84
102
|
return isVoucherPaymentRecord(payment) && (payment === null || payment === void 0 ? void 0 : payment.status) !== 'voided' && (hasSyncedOrderPaymentRecord(payment) || isPaidPaymentRecord(payment));
|
|
85
103
|
}
|
|
104
|
+
function getVoucherPaymentLifecycleKey(payment) {
|
|
105
|
+
if (!isVoucherPaymentRecord(payment)) return null;
|
|
106
|
+
return "".concat(String(payment.voucher_id), "::").concat(String(payment.status || ''));
|
|
107
|
+
}
|
|
86
108
|
export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
87
109
|
_inherits(OrderModule, _BaseModule);
|
|
88
110
|
var _super = _createSuper(OrderModule);
|
|
@@ -97,6 +119,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
97
119
|
_defineProperty(_assertThisInitialized(_this), "logger", void 0);
|
|
98
120
|
// LoggerManager 实例
|
|
99
121
|
_defineProperty(_assertThisInitialized(_this), "window", void 0);
|
|
122
|
+
_defineProperty(_assertThisInitialized(_this), "appPlugin", void 0);
|
|
100
123
|
_defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
|
|
101
124
|
_defineProperty(_assertThisInitialized(_this), "salesSummaryModuleName", void 0);
|
|
102
125
|
_defineProperty(_assertThisInitialized(_this), "rulesHooksOverride", void 0);
|
|
@@ -140,6 +163,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
140
163
|
var item = _step2.value;
|
|
141
164
|
var type = (_item$type2 = item === null || item === void 0 ? void 0 : item.type) !== null && _item$type2 !== void 0 ? _item$type2 : item === null || item === void 0 ? void 0 : item.tag;
|
|
142
165
|
if (!type || type === 'product') continue;
|
|
166
|
+
var isDiscountCard = type === 'discount_card' || type === 'product_discount_card';
|
|
143
167
|
var resourceId = (_ref = (_ref2 = (_item$discount$resour = item === null || item === void 0 || (_item$discount = item.discount) === null || _item$discount === void 0 ? void 0 : _item$discount.resource_id) !== null && _item$discount$resour !== void 0 ? _item$discount$resour : item === null || item === void 0 ? void 0 : item.resource_id) !== null && _ref2 !== void 0 ? _ref2 : item === null || item === void 0 ? void 0 : item.discount_id) !== null && _ref !== void 0 ? _ref : item === null || item === void 0 ? void 0 : item.order_discount_id;
|
|
144
168
|
if (resourceId === undefined || resourceId === null || resourceId === '') continue;
|
|
145
169
|
var id = Number(resourceId);
|
|
@@ -162,7 +186,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
162
186
|
var _existed$limited_rela;
|
|
163
187
|
existed.amount = Number(existed.amount || 0) + amount;
|
|
164
188
|
existed.used_par_value = String(Number(existed.used_par_value || 0) + amount);
|
|
165
|
-
|
|
189
|
+
if (!isDiscountCard) {
|
|
190
|
+
existed.balance = String(Number(existed.balance || 0) + amount);
|
|
191
|
+
}
|
|
166
192
|
var productIds = Array.isArray((_existed$limited_rela = existed.limited_relation_product_data) === null || _existed$limited_rela === void 0 ? void 0 : _existed$limited_rela.product_ids) ? existed.limited_relation_product_data.product_ids : [];
|
|
167
193
|
if ((product === null || product === void 0 ? void 0 : product.product_id) !== undefined && (product === null || product === void 0 ? void 0 : product.product_id) !== null && !productIds.includes(product.product_id)) {
|
|
168
194
|
existed.limited_relation_product_data = _objectSpread(_objectSpread({}, existed.limited_relation_product_data || {}), {}, {
|
|
@@ -194,7 +220,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
194
220
|
filter: 0,
|
|
195
221
|
exclude_product_ids: []
|
|
196
222
|
},
|
|
197
|
-
balance: String((_item$amount3 = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount3 !== void 0 ? _item$amount3 : '0'),
|
|
223
|
+
balance: isDiscountCard ? undefined : String((_item$amount3 = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount3 !== void 0 ? _item$amount3 : '0'),
|
|
198
224
|
format_title: title,
|
|
199
225
|
product: {
|
|
200
226
|
id: (_product$product_id = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : 0,
|
|
@@ -284,7 +310,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
284
310
|
value: function () {
|
|
285
311
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
286
312
|
var _otherParams$rules, _otherParams$order, _otherParams$hooks;
|
|
287
|
-
var
|
|
313
|
+
var app, otherParams;
|
|
288
314
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
289
315
|
while (1) switch (_context.prev = _context.next) {
|
|
290
316
|
case 0:
|
|
@@ -300,14 +326,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
300
326
|
this.store.availableWalletIds = [];
|
|
301
327
|
}
|
|
302
328
|
this.request = this.core.getPlugin('request');
|
|
303
|
-
appPlugin = this.core.getPlugin('app');
|
|
304
|
-
if (appPlugin) {
|
|
329
|
+
this.appPlugin = this.core.getPlugin('app');
|
|
330
|
+
if (this.appPlugin) {
|
|
305
331
|
_context.next = 9;
|
|
306
332
|
break;
|
|
307
333
|
}
|
|
308
334
|
throw new Error('Order 模块需要 app 插件支持');
|
|
309
335
|
case 9:
|
|
310
|
-
app = appPlugin.getApp();
|
|
336
|
+
app = this.appPlugin.getApp();
|
|
311
337
|
this.logger = app.logger;
|
|
312
338
|
this.window = this.core.getPlugin('window');
|
|
313
339
|
otherParams = options.otherParams || {};
|
|
@@ -660,7 +686,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
660
686
|
value: function () {
|
|
661
687
|
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(code, customerId) {
|
|
662
688
|
var _this$store$discount11, _tempOrder$holder, _this$store$summary;
|
|
663
|
-
var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref13, isAvailable, newDiscountList, unavailableReason, _this$store$discount12;
|
|
689
|
+
var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref13, isAvailable, newDiscountList, evaluatedDiscountList, unavailableReason, shouldRetainForLater, normalizedNewDiscountList, retainedDiscountList, resolvedDiscountList, _this$store$discount12, _this$store$discount13;
|
|
664
690
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
665
691
|
while (1) switch (_context6.prev = _context6.next) {
|
|
666
692
|
case 0:
|
|
@@ -689,6 +715,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
689
715
|
return _context6.abrupt("return", {
|
|
690
716
|
type: 'clientCalc',
|
|
691
717
|
isAvailable: false,
|
|
718
|
+
isAccepted: false,
|
|
692
719
|
discountList: this.getDiscountList(),
|
|
693
720
|
scannedDiscountList: resultDiscountList,
|
|
694
721
|
unavailableReason: UnavailableReason.Unknown
|
|
@@ -701,6 +728,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
701
728
|
return _context6.abrupt("return", {
|
|
702
729
|
type: 'server',
|
|
703
730
|
isAvailable: false,
|
|
731
|
+
isAccepted: false,
|
|
704
732
|
discountList: this.getDiscountList(),
|
|
705
733
|
scannedDiscountList: resultDiscountList,
|
|
706
734
|
unavailableReasonKey: unavailableReasonKey
|
|
@@ -728,6 +756,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
728
756
|
return _context6.abrupt("return", {
|
|
729
757
|
type: 'clientCalc',
|
|
730
758
|
isAvailable: true,
|
|
759
|
+
isAccepted: true,
|
|
731
760
|
discountList: this.getDiscountList(),
|
|
732
761
|
scannedDiscountList: resultDiscountList
|
|
733
762
|
});
|
|
@@ -746,24 +775,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
746
775
|
}) || {
|
|
747
776
|
isAvailable: false,
|
|
748
777
|
discountList: this.getDiscountList()
|
|
749
|
-
}, isAvailable = _ref13.isAvailable, newDiscountList = _ref13.discountList, unavailableReason = _ref13.unavailableReason;
|
|
750
|
-
|
|
751
|
-
|
|
778
|
+
}, isAvailable = _ref13.isAvailable, newDiscountList = _ref13.discountList, evaluatedDiscountList = _ref13.evaluatedDiscountList, unavailableReason = _ref13.unavailableReason;
|
|
779
|
+
shouldRetainForLater = !isAvailable && unavailableReason === UnavailableReason.ProductNotApplicable && withScanList.some(isCustomerPromotionDiscount);
|
|
780
|
+
normalizedNewDiscountList = newDiscountList ? markScannedDiscounts(newDiscountList, withScanList) : undefined;
|
|
781
|
+
retainedDiscountList = evaluatedDiscountList ? markScannedDiscounts(evaluatedDiscountList, withScanList) : normalizedNewDiscountList;
|
|
782
|
+
resolvedDiscountList = normalizedNewDiscountList || this.getDiscountList();
|
|
783
|
+
if (!(isAvailable && normalizedNewDiscountList)) {
|
|
784
|
+
_context6.next = 34;
|
|
752
785
|
break;
|
|
753
786
|
}
|
|
754
|
-
|
|
787
|
+
_context6.next = 28;
|
|
788
|
+
return (_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 ? void 0 : _this$store$discount12.setDiscountList(normalizedNewDiscountList);
|
|
789
|
+
case 28:
|
|
755
790
|
this.applyDiscount();
|
|
756
|
-
_context6.next =
|
|
791
|
+
_context6.next = 31;
|
|
757
792
|
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
758
|
-
case
|
|
793
|
+
case 31:
|
|
794
|
+
resolvedDiscountList = this.getDiscountList();
|
|
795
|
+
_context6.next = 40;
|
|
796
|
+
break;
|
|
797
|
+
case 34:
|
|
798
|
+
if (!(shouldRetainForLater && retainedDiscountList)) {
|
|
799
|
+
_context6.next = 40;
|
|
800
|
+
break;
|
|
801
|
+
}
|
|
802
|
+
_context6.next = 37;
|
|
803
|
+
return (_this$store$discount13 = this.store.discount) === null || _this$store$discount13 === void 0 ? void 0 : _this$store$discount13.setDiscountList(retainedDiscountList);
|
|
804
|
+
case 37:
|
|
805
|
+
_context6.next = 39;
|
|
806
|
+
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
807
|
+
case 39:
|
|
808
|
+
resolvedDiscountList = this.getDiscountList();
|
|
809
|
+
case 40:
|
|
759
810
|
return _context6.abrupt("return", {
|
|
760
811
|
type: 'clientCalc',
|
|
761
812
|
isAvailable: isAvailable || false,
|
|
762
|
-
|
|
813
|
+
isAccepted: Boolean(isAvailable || shouldRetainForLater),
|
|
814
|
+
discountList: resolvedDiscountList,
|
|
763
815
|
scannedDiscountList: resultDiscountList,
|
|
764
816
|
unavailableReason: unavailableReason
|
|
765
817
|
});
|
|
766
|
-
case
|
|
818
|
+
case 41:
|
|
767
819
|
case "end":
|
|
768
820
|
return _context6.stop();
|
|
769
821
|
}
|
|
@@ -777,7 +829,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
777
829
|
}, {
|
|
778
830
|
key: "applyDiscount",
|
|
779
831
|
value: function applyDiscount(options) {
|
|
780
|
-
var _this$store$
|
|
832
|
+
var _this$store$discount14,
|
|
781
833
|
_this$store$summary2,
|
|
782
834
|
_this2 = this;
|
|
783
835
|
var tempOrder = this.store.tempOrder;
|
|
@@ -787,7 +839,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
787
839
|
if (!tempOrder) return;
|
|
788
840
|
this.syncLinkedBookingHoldersToProducts(tempOrder);
|
|
789
841
|
delete tempOrder.discount_list;
|
|
790
|
-
var discountList = ((_this$store$
|
|
842
|
+
var discountList = ((_this$store$discount14 = this.store.discount) === null || _this$store$discount14 === void 0 ? void 0 : _this$store$discount14.getDiscountList()) || [];
|
|
791
843
|
var shouldSkipDiscountCalculation = this.shouldSkipDiscountCalculation(tempOrder);
|
|
792
844
|
if (shouldSkipDiscountCalculation) return;
|
|
793
845
|
var rulesModule = this.store.rules;
|
|
@@ -819,9 +871,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
819
871
|
}));
|
|
820
872
|
}
|
|
821
873
|
if (result !== null && result !== void 0 && result.discountList) {
|
|
822
|
-
var _this$store$
|
|
874
|
+
var _this$store$discount15;
|
|
823
875
|
OrderModule.populateSavedAmounts(result.productList || tempOrder.products, result.discountList);
|
|
824
|
-
(_this$store$
|
|
876
|
+
(_this$store$discount15 = this.store.discount) === null || _this$store$discount15 === void 0 || _this$store$discount15.setDiscountList(result.discountList);
|
|
825
877
|
}
|
|
826
878
|
this.hasActiveCustomerBoundDiscount = (tempOrder.products || []).some(function (product) {
|
|
827
879
|
return _this2.productHasCustomerBoundDiscount(product);
|
|
@@ -1510,19 +1562,44 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1510
1562
|
var depositPaidAmount = this.calculateDepositPaidAmount(tempOrder.payments || []);
|
|
1511
1563
|
return depositPaidAmount.lt(depositAmount) ? 'deposit' : 'normal';
|
|
1512
1564
|
}
|
|
1565
|
+
}, {
|
|
1566
|
+
key: "getPaymentNumberAppData",
|
|
1567
|
+
value: function getPaymentNumberAppData(key) {
|
|
1568
|
+
var _appPlugin$getData, _app$models, _app$models$getStore, _app$models$getStore$, _app$models$getStore$2;
|
|
1569
|
+
var appPlugin = this.appPlugin;
|
|
1570
|
+
if (!appPlugin) return undefined;
|
|
1571
|
+
var getData = (_appPlugin$getData = appPlugin.getData) === null || _appPlugin$getData === void 0 ? void 0 : _appPlugin$getData.call(appPlugin);
|
|
1572
|
+
if (typeof getData === 'function') return getData(key);
|
|
1573
|
+
var app = appPlugin.getApp();
|
|
1574
|
+
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');
|
|
1575
|
+
return coreData === null || coreData === void 0 ? void 0 : coreData[key];
|
|
1576
|
+
}
|
|
1577
|
+
}, {
|
|
1578
|
+
key: "getPaymentNumberDevicePrefixSync",
|
|
1579
|
+
value: function getPaymentNumberDevicePrefixSync() {
|
|
1580
|
+
var _this7 = this;
|
|
1581
|
+
return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
|
|
1582
|
+
return _this7.getPaymentNumberAppData(key);
|
|
1583
|
+
});
|
|
1584
|
+
}
|
|
1585
|
+
}, {
|
|
1586
|
+
key: "getPaymentNumberDevicePrefixAsync",
|
|
1587
|
+
value: function getPaymentNumberDevicePrefixAsync() {
|
|
1588
|
+
var _this8 = this;
|
|
1589
|
+
return resolvePaymentNumberDevicePrefix(function (key) {
|
|
1590
|
+
return _this8.getPaymentNumberAppData(key);
|
|
1591
|
+
});
|
|
1592
|
+
}
|
|
1513
1593
|
}, {
|
|
1514
1594
|
key: "normalizePaymentSource",
|
|
1515
1595
|
value: function normalizePaymentSource(payment, options) {
|
|
1516
1596
|
var _ref19, _paymentRecord$origin;
|
|
1517
1597
|
var paymentRecord = payment;
|
|
1518
1598
|
var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
|
|
1519
|
-
|
|
1520
|
-
metadata.unique_payment_number = createUuidV4();
|
|
1521
|
-
}
|
|
1522
|
-
var normalized = _objectSpread(_objectSpread({}, paymentRecord), {}, {
|
|
1599
|
+
var normalized = ensureOrderPaymentNumber(_objectSpread(_objectSpread({}, paymentRecord), {}, {
|
|
1523
1600
|
metadata: metadata,
|
|
1524
1601
|
origin_amount: (_ref19 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref19 !== void 0 ? _ref19 : '0.00'
|
|
1525
|
-
});
|
|
1602
|
+
}), (options === null || options === void 0 ? void 0 : options.devicePrefix) || this.getPaymentNumberDevicePrefixSync(), createUuidV4);
|
|
1526
1603
|
if (paymentRecord.status !== undefined) {
|
|
1527
1604
|
normalized.status = paymentRecord.status;
|
|
1528
1605
|
} else if ((options === null || options === void 0 ? void 0 : options.defaultPaid) !== false) {
|
|
@@ -1640,16 +1717,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1640
1717
|
}, {
|
|
1641
1718
|
key: "calculatePaidPaymentSummary",
|
|
1642
1719
|
value: function calculatePaidPaymentSummary(payments) {
|
|
1643
|
-
var
|
|
1720
|
+
var _this9 = this;
|
|
1644
1721
|
return (payments || []).reduce(function (summary, payment) {
|
|
1645
1722
|
var paymentRecord = payment;
|
|
1646
1723
|
if (!isPaidPaymentRecord(paymentRecord)) return summary;
|
|
1647
1724
|
return {
|
|
1648
1725
|
customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
|
|
1649
|
-
orderPaidAmount: summary.orderPaidAmount.plus(
|
|
1650
|
-
gapPaidAmount: summary.gapPaidAmount.plus(
|
|
1651
|
-
payServiceChargeAmount: summary.payServiceChargeAmount.plus(
|
|
1652
|
-
roundingAmount: summary.roundingAmount.plus(
|
|
1726
|
+
orderPaidAmount: summary.orderPaidAmount.plus(_this9.calculatePaymentOrderAmount(paymentRecord)),
|
|
1727
|
+
gapPaidAmount: summary.gapPaidAmount.plus(_this9.calculatePaymentGapAmount(paymentRecord)),
|
|
1728
|
+
payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this9.calculatePaymentServiceFee(paymentRecord)),
|
|
1729
|
+
roundingAmount: summary.roundingAmount.plus(_this9.calculatePaymentRoundingAmount(paymentRecord))
|
|
1653
1730
|
};
|
|
1654
1731
|
}, {
|
|
1655
1732
|
customerPaidAmount: new Decimal(0),
|
|
@@ -1851,15 +1928,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1851
1928
|
}, {
|
|
1852
1929
|
key: "normalizeFingerprintValue",
|
|
1853
1930
|
value: function normalizeFingerprintValue(value) {
|
|
1854
|
-
var
|
|
1931
|
+
var _this10 = this;
|
|
1855
1932
|
if (Array.isArray(value)) {
|
|
1856
1933
|
return value.map(function (item) {
|
|
1857
|
-
return
|
|
1934
|
+
return _this10.normalizeFingerprintValue(item);
|
|
1858
1935
|
});
|
|
1859
1936
|
}
|
|
1860
1937
|
if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
|
|
1861
1938
|
return Object.keys(value).sort().reduce(function (result, key) {
|
|
1862
|
-
result[key] =
|
|
1939
|
+
result[key] = _this10.normalizeFingerprintValue(value[key]);
|
|
1863
1940
|
return result;
|
|
1864
1941
|
}, {});
|
|
1865
1942
|
}
|
|
@@ -1874,7 +1951,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1874
1951
|
_sku$barcode,
|
|
1875
1952
|
_ref20,
|
|
1876
1953
|
_sku$variant_id,
|
|
1877
|
-
|
|
1954
|
+
_this11 = this;
|
|
1878
1955
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
1879
1956
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
1880
1957
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -1908,7 +1985,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1908
1985
|
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,
|
|
1909
1986
|
option_group_item_id: (_ref22 = (_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 && _ref22 !== void 0 ? _ref22 : null,
|
|
1910
1987
|
num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
|
|
1911
|
-
add_price:
|
|
1988
|
+
add_price: _this11.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)
|
|
1912
1989
|
};
|
|
1913
1990
|
})
|
|
1914
1991
|
}),
|
|
@@ -1918,8 +1995,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1918
1995
|
bundle_product_id: (_ref23 = (_ref24 = (_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 && _ref24 !== void 0 ? _ref24 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref23 !== void 0 ? _ref23 : null,
|
|
1919
1996
|
bundle_variant_id: (_ref25 = (_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 && _ref25 !== void 0 ? _ref25 : 0,
|
|
1920
1997
|
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),
|
|
1921
|
-
price:
|
|
1922
|
-
bundle_selling_price:
|
|
1998
|
+
price: _this11.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
|
|
1999
|
+
bundle_selling_price: _this11.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
|
|
1923
2000
|
price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
|
|
1924
2001
|
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 : ''
|
|
1925
2002
|
};
|
|
@@ -1929,7 +2006,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1929
2006
|
return {
|
|
1930
2007
|
type: (_ref26 = (_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 && _ref26 !== void 0 ? _ref26 : '',
|
|
1931
2008
|
discount_id: (_ref27 = (_ref28 = (_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 && _ref28 !== void 0 ? _ref28 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref27 !== void 0 ? _ref27 : null,
|
|
1932
|
-
amount:
|
|
2009
|
+
amount: _this11.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
1933
2010
|
};
|
|
1934
2011
|
}))
|
|
1935
2012
|
};
|
|
@@ -1937,9 +2014,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1937
2014
|
}, {
|
|
1938
2015
|
key: "buildOrderProductsFingerprint",
|
|
1939
2016
|
value: function buildOrderProductsFingerprint(products) {
|
|
1940
|
-
var
|
|
2017
|
+
var _this12 = this;
|
|
1941
2018
|
var items = (products || []).map(function (product) {
|
|
1942
|
-
return
|
|
2019
|
+
return _this12.buildProductFingerprintItem(product);
|
|
1943
2020
|
});
|
|
1944
2021
|
items.sort(function (left, right) {
|
|
1945
2022
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -1961,7 +2038,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1961
2038
|
_sku$barcode2,
|
|
1962
2039
|
_ref30,
|
|
1963
2040
|
_sku$variant_id2,
|
|
1964
|
-
|
|
2041
|
+
_this13 = this;
|
|
1965
2042
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
1966
2043
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
1967
2044
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -1992,7 +2069,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1992
2069
|
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,
|
|
1993
2070
|
option_group_item_id: (_ref32 = (_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 && _ref32 !== void 0 ? _ref32 : null,
|
|
1994
2071
|
num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
|
|
1995
|
-
add_price:
|
|
2072
|
+
add_price: _this13.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)
|
|
1996
2073
|
};
|
|
1997
2074
|
})
|
|
1998
2075
|
}),
|
|
@@ -2006,14 +2083,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2006
2083
|
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),
|
|
2007
2084
|
price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
|
|
2008
2085
|
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 : '',
|
|
2009
|
-
option:
|
|
2086
|
+
option: _this13.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
|
|
2010
2087
|
var _ref38, _option$id3, _option$option_group_5, _ref39, _option$option_group_6, _option$num3, _option$add_price3;
|
|
2011
2088
|
return {
|
|
2012
2089
|
id: (_ref38 = (_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 && _ref38 !== void 0 ? _ref38 : null,
|
|
2013
2090
|
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,
|
|
2014
2091
|
option_group_item_id: (_ref39 = (_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 && _ref39 !== void 0 ? _ref39 : null,
|
|
2015
2092
|
num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
|
|
2016
|
-
add_price:
|
|
2093
|
+
add_price: _this13.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)
|
|
2017
2094
|
};
|
|
2018
2095
|
}))
|
|
2019
2096
|
};
|
|
@@ -2023,7 +2100,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2023
2100
|
return {
|
|
2024
2101
|
type: (_ref40 = (_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 && _ref40 !== void 0 ? _ref40 : '',
|
|
2025
2102
|
discount_id: (_ref41 = (_ref42 = (_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 && _ref42 !== void 0 ? _ref42 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref41 !== void 0 ? _ref41 : null,
|
|
2026
|
-
amount:
|
|
2103
|
+
amount: _this13.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2027
2104
|
};
|
|
2028
2105
|
}))
|
|
2029
2106
|
};
|
|
@@ -2031,9 +2108,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2031
2108
|
}, {
|
|
2032
2109
|
key: "buildOrderProductsStructuralFingerprint",
|
|
2033
2110
|
value: function buildOrderProductsStructuralFingerprint(products) {
|
|
2034
|
-
var
|
|
2111
|
+
var _this14 = this;
|
|
2035
2112
|
var items = (products || []).map(function (product) {
|
|
2036
|
-
return
|
|
2113
|
+
return _this14.buildProductStructuralFingerprintItem(product);
|
|
2037
2114
|
});
|
|
2038
2115
|
items.sort(function (left, right) {
|
|
2039
2116
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -2250,7 +2327,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2250
2327
|
}, {
|
|
2251
2328
|
key: "restoreOrder",
|
|
2252
2329
|
value: function restoreOrder() {
|
|
2253
|
-
var _this$store$
|
|
2330
|
+
var _this$store$discount16, _this$store$discount17;
|
|
2254
2331
|
this.logInfo('restoreOrder start', {});
|
|
2255
2332
|
var freshTempOrder = this.createDefaultTempOrderInstance();
|
|
2256
2333
|
this.ensureExternalSaleNumber(freshTempOrder);
|
|
@@ -2258,8 +2335,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2258
2335
|
this.store.summary = createEmptySummary();
|
|
2259
2336
|
this.store.lastOrderInfo = undefined;
|
|
2260
2337
|
this.store.syncState = undefined;
|
|
2261
|
-
void ((_this$store$
|
|
2262
|
-
void ((_this$store$
|
|
2338
|
+
void ((_this$store$discount16 = this.store.discount) === null || _this$store$discount16 === void 0 ? void 0 : _this$store$discount16.setOriginalDiscountList([]));
|
|
2339
|
+
void ((_this$store$discount17 = this.store.discount) === null || _this$store$discount17 === void 0 ? void 0 : _this$store$discount17.setDiscountList([]));
|
|
2263
2340
|
this.persistTempOrder();
|
|
2264
2341
|
return freshTempOrder;
|
|
2265
2342
|
}
|
|
@@ -2461,9 +2538,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2461
2538
|
}, {
|
|
2462
2539
|
key: "sanitizeTempOrderProducts",
|
|
2463
2540
|
value: function sanitizeTempOrderProducts(tempOrder) {
|
|
2464
|
-
var
|
|
2541
|
+
var _this15 = this;
|
|
2465
2542
|
tempOrder.products = (tempOrder.products || []).map(function (product) {
|
|
2466
|
-
return
|
|
2543
|
+
return _this15.sanitizeOrderProductForTempOrder(product);
|
|
2467
2544
|
});
|
|
2468
2545
|
}
|
|
2469
2546
|
}, {
|
|
@@ -2566,7 +2643,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2566
2643
|
}, {
|
|
2567
2644
|
key: "syncLinkedBookingHoldersToProducts",
|
|
2568
2645
|
value: function syncLinkedBookingHoldersToProducts(tempOrder) {
|
|
2569
|
-
var
|
|
2646
|
+
var _this16 = this;
|
|
2570
2647
|
var bookings = tempOrder.bookings || [];
|
|
2571
2648
|
var products = tempOrder.products || [];
|
|
2572
2649
|
if (!bookings.length || !products.length) return;
|
|
@@ -2591,7 +2668,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2591
2668
|
var bookingUid = product.booking_uid || ((_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid);
|
|
2592
2669
|
var linkedBooking = (productUid !== undefined && productUid !== null && String(productUid) !== '' ? bookingByProductUid.get(String(productUid)) : undefined) || (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '' ? bookingByBookingUid.get(String(bookingUid)) : undefined);
|
|
2593
2670
|
if (linkedBooking) {
|
|
2594
|
-
|
|
2671
|
+
_this16.setProductHolderFromBooking(product, linkedBooking);
|
|
2595
2672
|
}
|
|
2596
2673
|
});
|
|
2597
2674
|
}
|
|
@@ -2719,9 +2796,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2719
2796
|
}, {
|
|
2720
2797
|
key: "findBookingIndexByUniqueIdentificationNumber",
|
|
2721
2798
|
value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
|
|
2722
|
-
var
|
|
2799
|
+
var _this17 = this;
|
|
2723
2800
|
return (tempOrder.bookings || []).findIndex(function (booking) {
|
|
2724
|
-
return
|
|
2801
|
+
return _this17.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
|
|
2725
2802
|
});
|
|
2726
2803
|
}
|
|
2727
2804
|
}, {
|
|
@@ -2729,12 +2806,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2729
2806
|
value: function removeLinkedBookingsForProduct(tempOrder, product) {
|
|
2730
2807
|
var _product$metadata7,
|
|
2731
2808
|
_product$metadata8,
|
|
2732
|
-
|
|
2809
|
+
_this18 = this;
|
|
2733
2810
|
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);
|
|
2734
2811
|
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);
|
|
2735
2812
|
if (!productUid && !bookingUid) return;
|
|
2736
2813
|
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
2737
|
-
var currentBookingUid =
|
|
2814
|
+
var currentBookingUid = _this18.getBookingUniqueIdentificationNumber(booking);
|
|
2738
2815
|
if (bookingUid && currentBookingUid === String(bookingUid)) return false;
|
|
2739
2816
|
if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
|
|
2740
2817
|
return true;
|
|
@@ -3067,35 +3144,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3067
3144
|
}, {
|
|
3068
3145
|
key: "productHasCustomerBoundDiscount",
|
|
3069
3146
|
value: function productHasCustomerBoundDiscount(product) {
|
|
3070
|
-
var
|
|
3147
|
+
var _this19 = this;
|
|
3071
3148
|
if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
|
|
3072
|
-
return
|
|
3149
|
+
return _this19.isCustomerBoundDiscount(discount);
|
|
3073
3150
|
})) {
|
|
3074
3151
|
return true;
|
|
3075
3152
|
}
|
|
3076
3153
|
return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
|
|
3077
3154
|
return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
|
|
3078
|
-
return
|
|
3155
|
+
return _this19.isCustomerBoundDiscount(discount);
|
|
3079
3156
|
});
|
|
3080
3157
|
});
|
|
3081
3158
|
}
|
|
3082
3159
|
}, {
|
|
3083
3160
|
key: "shouldSkipDiscountCalculation",
|
|
3084
3161
|
value: function shouldSkipDiscountCalculation(tempOrder) {
|
|
3085
|
-
var _this$store$
|
|
3086
|
-
_this$store$
|
|
3087
|
-
|
|
3162
|
+
var _this$store$discount18,
|
|
3163
|
+
_this$store$discount19,
|
|
3164
|
+
_this20 = this;
|
|
3088
3165
|
if (this.hasActiveCustomerBoundDiscount) return false;
|
|
3089
|
-
var discountList = ((_this$store$
|
|
3166
|
+
var discountList = ((_this$store$discount18 = this.store.discount) === null || _this$store$discount18 === void 0 || (_this$store$discount19 = _this$store$discount18.getDiscountList) === null || _this$store$discount19 === void 0 ? void 0 : _this$store$discount19.call(_this$store$discount18)) || [];
|
|
3090
3167
|
if (discountList.length > 0) return false;
|
|
3091
3168
|
return !(tempOrder.products || []).some(function (product) {
|
|
3092
|
-
return
|
|
3169
|
+
return _this20.productHasCustomerBoundDiscount(product);
|
|
3093
3170
|
});
|
|
3094
3171
|
}
|
|
3095
3172
|
}, {
|
|
3096
3173
|
key: "clearCustomerBoundDiscounts",
|
|
3097
3174
|
value: function clearCustomerBoundDiscounts(tempOrder) {
|
|
3098
|
-
var
|
|
3175
|
+
var _this21 = this,
|
|
3099
3176
|
_discountModule$getDi,
|
|
3100
3177
|
_discountModule$getOr,
|
|
3101
3178
|
_discountModule$setDi,
|
|
@@ -3104,7 +3181,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3104
3181
|
var filterDiscountList = function filterDiscountList(discountList) {
|
|
3105
3182
|
if (!Array.isArray(discountList)) return [];
|
|
3106
3183
|
return discountList.filter(function (discount) {
|
|
3107
|
-
var shouldRemove =
|
|
3184
|
+
var shouldRemove = _this21.isCustomerBoundDiscount(discount);
|
|
3108
3185
|
if (shouldRemove) didRemoveCustomerBoundDiscount = true;
|
|
3109
3186
|
return !shouldRemove;
|
|
3110
3187
|
});
|
|
@@ -3131,12 +3208,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3131
3208
|
var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
|
|
3132
3209
|
var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
|
|
3133
3210
|
var nextDiscounts = currentDiscounts.filter(function (discount) {
|
|
3134
|
-
if (
|
|
3135
|
-
return !
|
|
3211
|
+
if (_this21.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
3212
|
+
return !_this21.isCustomerBoundDiscount(discount);
|
|
3136
3213
|
});
|
|
3137
3214
|
var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
|
|
3138
|
-
if (
|
|
3139
|
-
return !
|
|
3215
|
+
if (_this21.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
3216
|
+
return !_this21.isCustomerBoundDiscount(discount);
|
|
3140
3217
|
});
|
|
3141
3218
|
void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
|
|
3142
3219
|
void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
|
|
@@ -3290,23 +3367,71 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3290
3367
|
* 用一组支付来源覆盖当前订单支付项。
|
|
3291
3368
|
*
|
|
3292
3369
|
* 入参允许来自 PaymentModule 的 PaymentItem,内部统一映射为 Sales 协议:
|
|
3293
|
-
* uuid
|
|
3370
|
+
* 新支付来源的 uuid 会作为 payment_number 的唯一号段,id -> custom_payment_id,
|
|
3294
3371
|
* isSynced 等运行态字段不会进入 tempOrder.payments。
|
|
3295
3372
|
*/
|
|
3296
3373
|
}, {
|
|
3297
3374
|
key: "setOrderPayments",
|
|
3298
3375
|
value: function setOrderPayments(payments) {
|
|
3376
|
+
var _this22 = this;
|
|
3299
3377
|
var tempOrder = this.ensureTempOrder();
|
|
3300
|
-
tempOrder.payments = mapPaymentItemsToOrderPayments(payments)
|
|
3378
|
+
tempOrder.payments = mapPaymentItemsToOrderPayments((payments || []).map(function (payment) {
|
|
3379
|
+
return _this22.normalizePaymentSource(payment, {
|
|
3380
|
+
defaultPaid: false
|
|
3381
|
+
});
|
|
3382
|
+
}));
|
|
3301
3383
|
this.persistTempOrder();
|
|
3302
3384
|
return tempOrder.payments;
|
|
3303
3385
|
}
|
|
3304
3386
|
|
|
3305
|
-
/**
|
|
3387
|
+
/** 同步兼容入口:按调用当下的 device_id 或 LOCAL 生成支付编号。 */
|
|
3306
3388
|
}, {
|
|
3307
3389
|
key: "addOrderPayment",
|
|
3308
3390
|
value: function addOrderPayment(payment) {
|
|
3309
|
-
var
|
|
3391
|
+
var hasPaymentNumber = String(payment.payment_number || '').trim() !== '';
|
|
3392
|
+
return this.addOrderPaymentWithDevicePrefix(payment, hasPaymentNumber ? 'LOCAL' : this.getPaymentNumberDevicePrefixSync());
|
|
3393
|
+
}
|
|
3394
|
+
|
|
3395
|
+
/** 异步入口:创建支付项时读取最新 IoT 设备短号。 */
|
|
3396
|
+
}, {
|
|
3397
|
+
key: "addOrderPaymentAsync",
|
|
3398
|
+
value: (function () {
|
|
3399
|
+
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(payment) {
|
|
3400
|
+
var hasPaymentNumber, devicePrefix;
|
|
3401
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context17) {
|
|
3402
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
3403
|
+
case 0:
|
|
3404
|
+
hasPaymentNumber = String(payment.payment_number || '').trim() !== '';
|
|
3405
|
+
if (!hasPaymentNumber) {
|
|
3406
|
+
_context17.next = 5;
|
|
3407
|
+
break;
|
|
3408
|
+
}
|
|
3409
|
+
_context17.t0 = 'LOCAL';
|
|
3410
|
+
_context17.next = 8;
|
|
3411
|
+
break;
|
|
3412
|
+
case 5:
|
|
3413
|
+
_context17.next = 7;
|
|
3414
|
+
return this.getPaymentNumberDevicePrefixAsync();
|
|
3415
|
+
case 7:
|
|
3416
|
+
_context17.t0 = _context17.sent;
|
|
3417
|
+
case 8:
|
|
3418
|
+
devicePrefix = _context17.t0;
|
|
3419
|
+
return _context17.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
|
|
3420
|
+
case 10:
|
|
3421
|
+
case "end":
|
|
3422
|
+
return _context17.stop();
|
|
3423
|
+
}
|
|
3424
|
+
}, _callee15, this);
|
|
3425
|
+
}));
|
|
3426
|
+
function addOrderPaymentAsync(_x14) {
|
|
3427
|
+
return _addOrderPaymentAsync.apply(this, arguments);
|
|
3428
|
+
}
|
|
3429
|
+
return addOrderPaymentAsync;
|
|
3430
|
+
}())
|
|
3431
|
+
}, {
|
|
3432
|
+
key: "addOrderPaymentWithDevicePrefix",
|
|
3433
|
+
value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
|
|
3434
|
+
var _this23 = this;
|
|
3310
3435
|
this.logInfo('addOrderPayment', {
|
|
3311
3436
|
payment: payment
|
|
3312
3437
|
});
|
|
@@ -3316,14 +3441,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3316
3441
|
type: orderPaymentType,
|
|
3317
3442
|
order_payment_type: orderPaymentType
|
|
3318
3443
|
}), {
|
|
3319
|
-
defaultPaid: true
|
|
3444
|
+
defaultPaid: true,
|
|
3445
|
+
devicePrefix: devicePrefix
|
|
3320
3446
|
})]);
|
|
3321
3447
|
tempOrder.payments = [].concat(_toConsumableArray(tempOrder.payments || []), _toConsumableArray(mapped));
|
|
3322
3448
|
this.persistTempOrder();
|
|
3323
3449
|
void this.recalculateSummary({
|
|
3324
3450
|
createIfMissing: true
|
|
3325
3451
|
}).catch(function (error) {
|
|
3326
|
-
|
|
3452
|
+
_this23.logError('recalculate summary after addOrderPayment failed', {
|
|
3327
3453
|
error: error instanceof Error ? error.message : String(error)
|
|
3328
3454
|
});
|
|
3329
3455
|
});
|
|
@@ -3331,49 +3457,80 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3331
3457
|
}
|
|
3332
3458
|
|
|
3333
3459
|
/**
|
|
3334
|
-
*
|
|
3335
|
-
*
|
|
3336
|
-
* 该方法服务 PaymentModal 的 void / 编辑场景;更新 metadata 时会做浅合并,
|
|
3337
|
-
* 避免覆盖 unique_payment_number、现金实付/找零等已有元数据。
|
|
3460
|
+
* 默认按支付唯一号精确更新;仅显式指定 legacy 时兼容历史支付标识。
|
|
3461
|
+
* metadata 与 transactions 会分别合并,避免覆盖支付会话号和已有交易记录。
|
|
3338
3462
|
*/
|
|
3339
3463
|
}, {
|
|
3340
3464
|
key: "updateOrderPayment",
|
|
3341
|
-
value: function
|
|
3342
|
-
var
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3465
|
+
value: (function () {
|
|
3466
|
+
var _updateOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(paymentIdentity, updates) {
|
|
3467
|
+
var options,
|
|
3468
|
+
tempOrder,
|
|
3469
|
+
identity,
|
|
3470
|
+
matchMode,
|
|
3471
|
+
matchedPayment,
|
|
3472
|
+
updatedPayment,
|
|
3473
|
+
summary,
|
|
3474
|
+
payments,
|
|
3475
|
+
_args18 = arguments;
|
|
3476
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context18) {
|
|
3477
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
3478
|
+
case 0:
|
|
3479
|
+
options = _args18.length > 2 && _args18[2] !== undefined ? _args18[2] : {};
|
|
3480
|
+
tempOrder = this.ensureTempOrder();
|
|
3481
|
+
identity = String(paymentIdentity);
|
|
3482
|
+
matchMode = options.matchBy === 'compat' || options.matchBy === 'legacy' ? 'compat' : 'payment_number';
|
|
3483
|
+
matchedPayment = resolveOrderPaymentIdentity(tempOrder.payments || [], identity, matchMode);
|
|
3484
|
+
if (matchedPayment) {
|
|
3485
|
+
_context18.next = 7;
|
|
3486
|
+
break;
|
|
3487
|
+
}
|
|
3488
|
+
throw new Error("\u672A\u627E\u5230\u652F\u4ED8\u9879: ".concat(identity));
|
|
3489
|
+
case 7:
|
|
3490
|
+
updatedPayment = null;
|
|
3491
|
+
tempOrder.payments = (tempOrder.payments || []).map(function (payment, index) {
|
|
3492
|
+
if (index !== matchedPayment.index) return payment;
|
|
3493
|
+
var nextPayment = mergeOrderPaymentRecord(payment, _objectSpread(_objectSpread({}, updates), {}, {
|
|
3494
|
+
updated_at: updates.updated_at || dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
3495
|
+
}));
|
|
3496
|
+
updatedPayment = nextPayment;
|
|
3497
|
+
return nextPayment;
|
|
3498
|
+
});
|
|
3499
|
+
this.persistTempOrder();
|
|
3500
|
+
_context18.next = 12;
|
|
3501
|
+
return this.recalculateSummary({
|
|
3502
|
+
createIfMissing: true
|
|
3503
|
+
});
|
|
3504
|
+
case 12:
|
|
3505
|
+
summary = _context18.sent;
|
|
3506
|
+
this.persistTempOrder();
|
|
3507
|
+
payments = tempOrder.payments;
|
|
3508
|
+
return _context18.abrupt("return", {
|
|
3509
|
+
updated: true,
|
|
3510
|
+
payment: payments[matchedPayment.index] || updatedPayment,
|
|
3511
|
+
payments: payments,
|
|
3512
|
+
summary: summary
|
|
3513
|
+
});
|
|
3514
|
+
case 16:
|
|
3515
|
+
case "end":
|
|
3516
|
+
return _context18.stop();
|
|
3517
|
+
}
|
|
3518
|
+
}, _callee16, this);
|
|
3519
|
+
}));
|
|
3520
|
+
function updateOrderPayment(_x15, _x16) {
|
|
3521
|
+
return _updateOrderPayment.apply(this, arguments);
|
|
3522
|
+
}
|
|
3523
|
+
return updateOrderPayment;
|
|
3524
|
+
}() /** 从当前订单支付项中移除指定支付项。 */)
|
|
3363
3525
|
}, {
|
|
3364
3526
|
key: "deleteOrderPayment",
|
|
3365
3527
|
value: function deleteOrderPayment(paymentIdentity) {
|
|
3366
3528
|
var tempOrder = this.ensureTempOrder();
|
|
3367
3529
|
var identity = String(paymentIdentity);
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
var customPaymentId = payment === null || payment === void 0 ? void 0 : payment.custom_payment_id;
|
|
3373
|
-
var uuid = payment === null || payment === void 0 ? void 0 : payment.uuid;
|
|
3374
|
-
return ![uniquePaymentNumber, orderPaymentId, customPaymentId, uuid].some(function (value) {
|
|
3375
|
-
return value !== undefined && String(value) === identity;
|
|
3376
|
-
});
|
|
3530
|
+
var matchedPayment = resolveOrderPaymentIdentity(tempOrder.payments || [], identity, 'compat');
|
|
3531
|
+
if (!matchedPayment) return tempOrder.payments;
|
|
3532
|
+
tempOrder.payments = (tempOrder.payments || []).filter(function (_, index) {
|
|
3533
|
+
return index !== matchedPayment.index;
|
|
3377
3534
|
});
|
|
3378
3535
|
this.persistTempOrder();
|
|
3379
3536
|
return tempOrder.payments;
|
|
@@ -3405,7 +3562,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3405
3562
|
}, {
|
|
3406
3563
|
key: "applyPaymentLifecycleChange",
|
|
3407
3564
|
value: function applyPaymentLifecycleChange(tempOrder, options) {
|
|
3408
|
-
var
|
|
3565
|
+
var _this24 = this;
|
|
3409
3566
|
this.updateTempOrderPaymentStatus(tempOrder);
|
|
3410
3567
|
if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
|
|
3411
3568
|
this.persistTempOrder();
|
|
@@ -3415,7 +3572,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3415
3572
|
void this.recalculateSummary({
|
|
3416
3573
|
createIfMissing: true
|
|
3417
3574
|
}).catch(function (error) {
|
|
3418
|
-
|
|
3575
|
+
_this24.logError("recalculate summary after ".concat(logContext, " failed"), {
|
|
3419
3576
|
error: error instanceof Error ? error.message : String(error)
|
|
3420
3577
|
});
|
|
3421
3578
|
});
|
|
@@ -3459,7 +3616,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3459
3616
|
}, {
|
|
3460
3617
|
key: "updateVoucherOrderPayments",
|
|
3461
3618
|
value: function updateVoucherOrderPayments(payments, options) {
|
|
3462
|
-
var
|
|
3619
|
+
var _this25 = this;
|
|
3463
3620
|
var tempOrder = this.ensureTempOrder();
|
|
3464
3621
|
var isOrderPaymentType = function isOrderPaymentType(value) {
|
|
3465
3622
|
return value === 'normal' || value === 'deposit';
|
|
@@ -3494,8 +3651,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3494
3651
|
});
|
|
3495
3652
|
};
|
|
3496
3653
|
var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
|
|
3497
|
-
return
|
|
3498
|
-
defaultPaid: false
|
|
3654
|
+
return _this25.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
|
|
3655
|
+
defaultPaid: false,
|
|
3656
|
+
devicePrefix: options === null || options === void 0 ? void 0 : options.devicePrefix
|
|
3499
3657
|
});
|
|
3500
3658
|
})).filter(function (payment) {
|
|
3501
3659
|
return isVoucherPaymentRecord(payment);
|
|
@@ -3521,14 +3679,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3521
3679
|
}).map(function (payment) {
|
|
3522
3680
|
return String(payment.order_payment_id);
|
|
3523
3681
|
}));
|
|
3524
|
-
var
|
|
3525
|
-
return
|
|
3682
|
+
var committedVoucherLifecycleKeys = new Set(committedVoucherPayments.map(function (payment) {
|
|
3683
|
+
return getVoucherPaymentLifecycleKey(payment);
|
|
3684
|
+
}).filter(function (key) {
|
|
3685
|
+
return key !== null;
|
|
3526
3686
|
}));
|
|
3527
3687
|
var replaceableVouchers = mappedVouchers.filter(function (payment) {
|
|
3528
3688
|
if (hasSyncedOrderPaymentRecord(payment) && committedVoucherPaymentIds.has(String(payment.order_payment_id))) {
|
|
3529
3689
|
return false;
|
|
3530
3690
|
}
|
|
3531
|
-
|
|
3691
|
+
var lifecycleKey = getVoucherPaymentLifecycleKey(payment);
|
|
3692
|
+
if (lifecycleKey && committedVoucherLifecycleKeys.has(lifecycleKey)) {
|
|
3532
3693
|
return false;
|
|
3533
3694
|
}
|
|
3534
3695
|
return true;
|
|
@@ -3543,54 +3704,93 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3543
3704
|
void this.recalculateSummary({
|
|
3544
3705
|
createIfMissing: true
|
|
3545
3706
|
}).catch(function (error) {
|
|
3546
|
-
|
|
3707
|
+
_this25.logError('recalculate summary after updateVoucherOrderPayments failed', {
|
|
3547
3708
|
error: error instanceof Error ? error.message : String(error)
|
|
3548
3709
|
});
|
|
3549
3710
|
});
|
|
3550
3711
|
return tempOrder.payments;
|
|
3551
3712
|
}
|
|
3713
|
+
}, {
|
|
3714
|
+
key: "updateVoucherOrderPaymentsAsync",
|
|
3715
|
+
value: function () {
|
|
3716
|
+
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(payments, options) {
|
|
3717
|
+
var needsPaymentNumber, devicePrefix;
|
|
3718
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context19) {
|
|
3719
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
3720
|
+
case 0:
|
|
3721
|
+
needsPaymentNumber = (payments || []).some(function (payment) {
|
|
3722
|
+
return String(payment.payment_number || '').trim() === '';
|
|
3723
|
+
});
|
|
3724
|
+
if (!needsPaymentNumber) {
|
|
3725
|
+
_context19.next = 7;
|
|
3726
|
+
break;
|
|
3727
|
+
}
|
|
3728
|
+
_context19.next = 4;
|
|
3729
|
+
return this.getPaymentNumberDevicePrefixAsync();
|
|
3730
|
+
case 4:
|
|
3731
|
+
_context19.t0 = _context19.sent;
|
|
3732
|
+
_context19.next = 8;
|
|
3733
|
+
break;
|
|
3734
|
+
case 7:
|
|
3735
|
+
_context19.t0 = 'LOCAL';
|
|
3736
|
+
case 8:
|
|
3737
|
+
devicePrefix = _context19.t0;
|
|
3738
|
+
return _context19.abrupt("return", this.updateVoucherOrderPayments(payments, _objectSpread(_objectSpread({}, options), {}, {
|
|
3739
|
+
devicePrefix: devicePrefix
|
|
3740
|
+
})));
|
|
3741
|
+
case 10:
|
|
3742
|
+
case "end":
|
|
3743
|
+
return _context19.stop();
|
|
3744
|
+
}
|
|
3745
|
+
}, _callee17, this);
|
|
3746
|
+
}));
|
|
3747
|
+
function updateVoucherOrderPaymentsAsync(_x17, _x18) {
|
|
3748
|
+
return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
|
|
3749
|
+
}
|
|
3750
|
+
return updateVoucherOrderPaymentsAsync;
|
|
3751
|
+
}()
|
|
3552
3752
|
}, {
|
|
3553
3753
|
key: "shouldMergeProductToOrder",
|
|
3554
3754
|
value: function () {
|
|
3555
|
-
var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3755
|
+
var _shouldMergeProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params) {
|
|
3556
3756
|
var _this$orderHooks;
|
|
3557
3757
|
var onBeforeMergeProductToOrder, result;
|
|
3558
|
-
return _regeneratorRuntime().wrap(function
|
|
3559
|
-
while (1) switch (
|
|
3758
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context20) {
|
|
3759
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
3560
3760
|
case 0:
|
|
3561
3761
|
onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
|
|
3562
3762
|
if (onBeforeMergeProductToOrder) {
|
|
3563
|
-
|
|
3763
|
+
_context20.next = 3;
|
|
3564
3764
|
break;
|
|
3565
3765
|
}
|
|
3566
|
-
return
|
|
3766
|
+
return _context20.abrupt("return", true);
|
|
3567
3767
|
case 3:
|
|
3568
|
-
|
|
3768
|
+
_context20.next = 5;
|
|
3569
3769
|
return onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
3570
3770
|
defaultShouldMerge: true
|
|
3571
3771
|
}));
|
|
3572
3772
|
case 5:
|
|
3573
|
-
result =
|
|
3773
|
+
result = _context20.sent;
|
|
3574
3774
|
if (!(typeof result === 'boolean')) {
|
|
3575
|
-
|
|
3775
|
+
_context20.next = 8;
|
|
3576
3776
|
break;
|
|
3577
3777
|
}
|
|
3578
|
-
return
|
|
3778
|
+
return _context20.abrupt("return", result);
|
|
3579
3779
|
case 8:
|
|
3580
3780
|
if (!(result && _typeof(result) === 'object' && typeof result.shouldMerge === 'boolean')) {
|
|
3581
|
-
|
|
3781
|
+
_context20.next = 10;
|
|
3582
3782
|
break;
|
|
3583
3783
|
}
|
|
3584
|
-
return
|
|
3784
|
+
return _context20.abrupt("return", result.shouldMerge);
|
|
3585
3785
|
case 10:
|
|
3586
|
-
return
|
|
3786
|
+
return _context20.abrupt("return", true);
|
|
3587
3787
|
case 11:
|
|
3588
3788
|
case "end":
|
|
3589
|
-
return
|
|
3789
|
+
return _context20.stop();
|
|
3590
3790
|
}
|
|
3591
|
-
},
|
|
3791
|
+
}, _callee18, this);
|
|
3592
3792
|
}));
|
|
3593
|
-
function shouldMergeProductToOrder(
|
|
3793
|
+
function shouldMergeProductToOrder(_x19) {
|
|
3594
3794
|
return _shouldMergeProductToOrder.apply(this, arguments);
|
|
3595
3795
|
}
|
|
3596
3796
|
return shouldMergeProductToOrder;
|
|
@@ -3626,30 +3826,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3626
3826
|
}, {
|
|
3627
3827
|
key: "finalizeProductOrderMutation",
|
|
3628
3828
|
value: function () {
|
|
3629
|
-
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3630
|
-
return _regeneratorRuntime().wrap(function
|
|
3631
|
-
while (1) switch (
|
|
3829
|
+
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(tempOrder, options) {
|
|
3830
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context21) {
|
|
3831
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
3632
3832
|
case 0:
|
|
3633
3833
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
3634
3834
|
if (options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) {
|
|
3635
|
-
|
|
3835
|
+
_context21.next = 4;
|
|
3636
3836
|
break;
|
|
3637
3837
|
}
|
|
3638
|
-
|
|
3838
|
+
_context21.next = 4;
|
|
3639
3839
|
return this.ensureEditDiscountConfigForProductChange(tempOrder);
|
|
3640
3840
|
case 4:
|
|
3641
3841
|
if (options !== null && options !== void 0 && options.skipDiscountRecalculation) {
|
|
3642
|
-
|
|
3842
|
+
_context21.next = 7;
|
|
3643
3843
|
break;
|
|
3644
3844
|
}
|
|
3645
|
-
|
|
3845
|
+
_context21.next = 7;
|
|
3646
3846
|
return this.applyPromotion();
|
|
3647
3847
|
case 7:
|
|
3648
3848
|
if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation)) {
|
|
3649
3849
|
this.applyDiscount();
|
|
3650
3850
|
}
|
|
3651
3851
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3652
|
-
|
|
3852
|
+
_context21.next = 11;
|
|
3653
3853
|
return this.recalculateSummary({
|
|
3654
3854
|
createIfMissing: true
|
|
3655
3855
|
});
|
|
@@ -3657,11 +3857,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3657
3857
|
this.persistTempOrder();
|
|
3658
3858
|
case 12:
|
|
3659
3859
|
case "end":
|
|
3660
|
-
return
|
|
3860
|
+
return _context21.stop();
|
|
3661
3861
|
}
|
|
3662
|
-
},
|
|
3862
|
+
}, _callee19, this);
|
|
3663
3863
|
}));
|
|
3664
|
-
function finalizeProductOrderMutation(
|
|
3864
|
+
function finalizeProductOrderMutation(_x20, _x21) {
|
|
3665
3865
|
return _finalizeProductOrderMutation.apply(this, arguments);
|
|
3666
3866
|
}
|
|
3667
3867
|
return finalizeProductOrderMutation;
|
|
@@ -3676,15 +3876,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3676
3876
|
}, {
|
|
3677
3877
|
key: "appendProductLineToTempOrder",
|
|
3678
3878
|
value: (function () {
|
|
3679
|
-
var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3879
|
+
var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(tempOrder, product, booking, options) {
|
|
3680
3880
|
var _normalizedIncoming$p,
|
|
3681
3881
|
_normalizedIncoming$p2,
|
|
3682
3882
|
_booking_uid,
|
|
3683
3883
|
_metadata,
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3884
|
+
_productToAdd$metadat,
|
|
3885
|
+
_origin,
|
|
3886
|
+
_this26 = this;
|
|
3887
|
+
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;
|
|
3888
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context22) {
|
|
3889
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
3688
3890
|
case 0:
|
|
3689
3891
|
linked = booking ? this.createLinkedProductAndBooking({
|
|
3690
3892
|
product: product,
|
|
@@ -3696,7 +3898,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3696
3898
|
isWeighingProduct = Number(((_normalizedIncoming$p = normalizedIncoming.product_sku) === null || _normalizedIncoming$p === void 0 ? void 0 : _normalizedIncoming$p.open_sold_weight) || 0) === 1;
|
|
3697
3899
|
netWeight = Number((_normalizedIncoming$p2 = normalizedIncoming.product_sku) === null || _normalizedIncoming$p2 === void 0 ? void 0 : _normalizedIncoming$p2.net_weight);
|
|
3698
3900
|
if (!(isWeighingProduct && (!Number.isFinite(netWeight) || netWeight <= 0))) {
|
|
3699
|
-
|
|
3901
|
+
_context22.next = 8;
|
|
3700
3902
|
break;
|
|
3701
3903
|
}
|
|
3702
3904
|
throw new Error('[Order] 称重商品净重必须大于 0');
|
|
@@ -3712,11 +3914,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3712
3914
|
hasIncomingGoodPass = this.hasGoodPassDiscount(normalizedIncoming);
|
|
3713
3915
|
hasIncomingProductNote = this.hasOrderProductLineNote(normalizedIncoming);
|
|
3714
3916
|
hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
|
|
3715
|
-
|
|
3917
|
+
isIncomingCustomItem = ((_productToAdd$metadat = productToAdd.metadata) === null || _productToAdd$metadat === void 0 || (_productToAdd$metadat = _productToAdd$metadat.origin) === null || _productToAdd$metadat === void 0 ? void 0 : _productToAdd$metadat.isCustomItem) === true || ((_origin = productToAdd._origin) === null || _origin === void 0 ? void 0 : _origin.isCustomItem) === true;
|
|
3918
|
+
shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
|
|
3716
3919
|
matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
3717
3920
|
var _item$metadata3;
|
|
3718
|
-
if (
|
|
3719
|
-
if (
|
|
3921
|
+
if (_this26.hasGoodPassDiscount(item)) return false;
|
|
3922
|
+
if (_this26.hasOrderProductLineNote(item)) return false;
|
|
3720
3923
|
if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
|
|
3721
3924
|
if ((_item$metadata3 = item.metadata) !== null && _item$metadata3 !== void 0 && _item$metadata3.is_edit_for_runtime) return false;
|
|
3722
3925
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
@@ -3727,10 +3930,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3727
3930
|
matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
|
|
3728
3931
|
existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
|
|
3729
3932
|
if (!matchedProduct) {
|
|
3730
|
-
|
|
3933
|
+
_context22.next = 25;
|
|
3731
3934
|
break;
|
|
3732
3935
|
}
|
|
3733
|
-
|
|
3936
|
+
_context22.next = 22;
|
|
3734
3937
|
return this.shouldMergeProductToOrder({
|
|
3735
3938
|
incomingProduct: productToAdd,
|
|
3736
3939
|
normalizedIncoming: normalizedIncoming,
|
|
@@ -3741,14 +3944,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3741
3944
|
tempOrder: tempOrder,
|
|
3742
3945
|
booking: booking
|
|
3743
3946
|
});
|
|
3744
|
-
case
|
|
3745
|
-
|
|
3746
|
-
|
|
3947
|
+
case 22:
|
|
3948
|
+
_context22.t0 = _context22.sent;
|
|
3949
|
+
_context22.next = 26;
|
|
3747
3950
|
break;
|
|
3748
|
-
case 24:
|
|
3749
|
-
_context19.t0 = false;
|
|
3750
3951
|
case 25:
|
|
3751
|
-
|
|
3952
|
+
_context22.t0 = false;
|
|
3953
|
+
case 26:
|
|
3954
|
+
shouldMerge = _context22.t0;
|
|
3752
3955
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
3753
3956
|
this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
3754
3957
|
if (linked) {
|
|
@@ -3808,13 +4011,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3808
4011
|
if (linked) {
|
|
3809
4012
|
tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
|
|
3810
4013
|
}
|
|
3811
|
-
case
|
|
4014
|
+
case 29:
|
|
3812
4015
|
case "end":
|
|
3813
|
-
return
|
|
4016
|
+
return _context22.stop();
|
|
3814
4017
|
}
|
|
3815
|
-
},
|
|
4018
|
+
}, _callee20, this);
|
|
3816
4019
|
}));
|
|
3817
|
-
function appendProductLineToTempOrder(
|
|
4020
|
+
function appendProductLineToTempOrder(_x22, _x23, _x24, _x25) {
|
|
3818
4021
|
return _appendProductLineToTempOrder.apply(this, arguments);
|
|
3819
4022
|
}
|
|
3820
4023
|
return appendProductLineToTempOrder;
|
|
@@ -3830,10 +4033,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3830
4033
|
}, {
|
|
3831
4034
|
key: "addProductToOrder",
|
|
3832
4035
|
value: (function () {
|
|
3833
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4036
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(product, booking, options) {
|
|
3834
4037
|
var tempOrder, insertAfterProductUid, anchorIndex, insertAtIndex, _ref61, _productRecord$num, productRecord, splitCount, i, singleLine;
|
|
3835
|
-
return _regeneratorRuntime().wrap(function
|
|
3836
|
-
while (1) switch (
|
|
4038
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context23) {
|
|
4039
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
3837
4040
|
case 0:
|
|
3838
4041
|
tempOrder = this.ensureTempOrder();
|
|
3839
4042
|
insertAfterProductUid = options === null || options === void 0 ? void 0 : options.insertAfterProductUid;
|
|
@@ -3844,25 +4047,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3844
4047
|
}) : -1;
|
|
3845
4048
|
insertAtIndex = anchorIndex >= 0 ? anchorIndex + 1 : undefined;
|
|
3846
4049
|
if (!booking) {
|
|
3847
|
-
|
|
4050
|
+
_context23.next = 22;
|
|
3848
4051
|
break;
|
|
3849
4052
|
}
|
|
3850
4053
|
productRecord = product;
|
|
3851
4054
|
splitCount = getSafeProductNum((_ref61 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref61 !== void 0 ? _ref61 : 1);
|
|
3852
4055
|
if (!(splitCount > 1)) {
|
|
3853
|
-
|
|
4056
|
+
_context23.next = 22;
|
|
3854
4057
|
break;
|
|
3855
4058
|
}
|
|
3856
4059
|
i = 0;
|
|
3857
4060
|
case 9:
|
|
3858
4061
|
if (!(i < splitCount)) {
|
|
3859
|
-
|
|
4062
|
+
_context23.next = 19;
|
|
3860
4063
|
break;
|
|
3861
4064
|
}
|
|
3862
4065
|
singleLine = cloneDeep(productRecord);
|
|
3863
4066
|
singleLine.num = 1;
|
|
3864
4067
|
delete singleLine.product_quantity;
|
|
3865
|
-
|
|
4068
|
+
_context23.next = 15;
|
|
3866
4069
|
return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking), {
|
|
3867
4070
|
insertAtIndex: insertAtIndex
|
|
3868
4071
|
});
|
|
@@ -3870,34 +4073,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3870
4073
|
if (insertAtIndex !== undefined) insertAtIndex += 1;
|
|
3871
4074
|
case 16:
|
|
3872
4075
|
i += 1;
|
|
3873
|
-
|
|
4076
|
+
_context23.next = 9;
|
|
3874
4077
|
break;
|
|
3875
4078
|
case 19:
|
|
3876
|
-
|
|
4079
|
+
_context23.next = 21;
|
|
3877
4080
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
3878
4081
|
case 21:
|
|
3879
|
-
return
|
|
4082
|
+
return _context23.abrupt("return", tempOrder.products);
|
|
3880
4083
|
case 22:
|
|
3881
|
-
|
|
4084
|
+
_context23.next = 24;
|
|
3882
4085
|
return this.appendProductLineToTempOrder(tempOrder, product, booking, {
|
|
3883
4086
|
insertAtIndex: insertAtIndex
|
|
3884
4087
|
});
|
|
3885
4088
|
case 24:
|
|
3886
|
-
|
|
4089
|
+
_context23.next = 26;
|
|
3887
4090
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
3888
4091
|
case 26:
|
|
3889
4092
|
this.logInfo('addProductToOrder success', {
|
|
3890
4093
|
product_id: product.product_id,
|
|
3891
4094
|
with_booking: !!booking
|
|
3892
4095
|
});
|
|
3893
|
-
return
|
|
4096
|
+
return _context23.abrupt("return", tempOrder.products);
|
|
3894
4097
|
case 28:
|
|
3895
4098
|
case "end":
|
|
3896
|
-
return
|
|
4099
|
+
return _context23.stop();
|
|
3897
4100
|
}
|
|
3898
|
-
},
|
|
4101
|
+
}, _callee21, this);
|
|
3899
4102
|
}));
|
|
3900
|
-
function addProductToOrder(
|
|
4103
|
+
function addProductToOrder(_x26, _x27, _x28) {
|
|
3901
4104
|
return _addProductToOrder.apply(this, arguments);
|
|
3902
4105
|
}
|
|
3903
4106
|
return addProductToOrder;
|
|
@@ -3915,93 +4118,93 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3915
4118
|
}, {
|
|
3916
4119
|
key: "addProductsToOrder",
|
|
3917
4120
|
value: (function () {
|
|
3918
|
-
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4121
|
+
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(items, options) {
|
|
3919
4122
|
var tempOrder, _iterator20, _step20, item, product, booking, _ref62, _productRecord$num2, productRecord, splitCount, i, singleLine;
|
|
3920
|
-
return _regeneratorRuntime().wrap(function
|
|
3921
|
-
while (1) switch (
|
|
4123
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context24) {
|
|
4124
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
3922
4125
|
case 0:
|
|
3923
4126
|
tempOrder = this.ensureTempOrder();
|
|
3924
4127
|
if (!(!Array.isArray(items) || items.length === 0)) {
|
|
3925
|
-
|
|
4128
|
+
_context24.next = 3;
|
|
3926
4129
|
break;
|
|
3927
4130
|
}
|
|
3928
|
-
return
|
|
4131
|
+
return _context24.abrupt("return", tempOrder.products);
|
|
3929
4132
|
case 3:
|
|
3930
4133
|
_iterator20 = _createForOfIteratorHelper(items || []);
|
|
3931
|
-
|
|
4134
|
+
_context24.prev = 4;
|
|
3932
4135
|
_iterator20.s();
|
|
3933
4136
|
case 6:
|
|
3934
4137
|
if ((_step20 = _iterator20.n()).done) {
|
|
3935
|
-
|
|
4138
|
+
_context24.next = 30;
|
|
3936
4139
|
break;
|
|
3937
4140
|
}
|
|
3938
4141
|
item = _step20.value;
|
|
3939
4142
|
product = item.product, booking = item.booking;
|
|
3940
4143
|
if (product) {
|
|
3941
|
-
|
|
4144
|
+
_context24.next = 11;
|
|
3942
4145
|
break;
|
|
3943
4146
|
}
|
|
3944
|
-
return
|
|
4147
|
+
return _context24.abrupt("continue", 28);
|
|
3945
4148
|
case 11:
|
|
3946
4149
|
if (!booking) {
|
|
3947
|
-
|
|
4150
|
+
_context24.next = 26;
|
|
3948
4151
|
break;
|
|
3949
4152
|
}
|
|
3950
4153
|
productRecord = product;
|
|
3951
4154
|
splitCount = getSafeProductNum((_ref62 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref62 !== void 0 ? _ref62 : 1);
|
|
3952
4155
|
if (!(splitCount > 1)) {
|
|
3953
|
-
|
|
4156
|
+
_context24.next = 26;
|
|
3954
4157
|
break;
|
|
3955
4158
|
}
|
|
3956
4159
|
i = 0;
|
|
3957
4160
|
case 16:
|
|
3958
4161
|
if (!(i < splitCount)) {
|
|
3959
|
-
|
|
4162
|
+
_context24.next = 25;
|
|
3960
4163
|
break;
|
|
3961
4164
|
}
|
|
3962
4165
|
singleLine = cloneDeep(productRecord);
|
|
3963
4166
|
singleLine.num = 1;
|
|
3964
4167
|
delete singleLine.product_quantity;
|
|
3965
|
-
|
|
4168
|
+
_context24.next = 22;
|
|
3966
4169
|
return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
|
|
3967
4170
|
case 22:
|
|
3968
4171
|
i += 1;
|
|
3969
|
-
|
|
4172
|
+
_context24.next = 16;
|
|
3970
4173
|
break;
|
|
3971
4174
|
case 25:
|
|
3972
|
-
return
|
|
4175
|
+
return _context24.abrupt("continue", 28);
|
|
3973
4176
|
case 26:
|
|
3974
|
-
|
|
4177
|
+
_context24.next = 28;
|
|
3975
4178
|
return this.appendProductLineToTempOrder(tempOrder, product, booking);
|
|
3976
4179
|
case 28:
|
|
3977
|
-
|
|
4180
|
+
_context24.next = 6;
|
|
3978
4181
|
break;
|
|
3979
4182
|
case 30:
|
|
3980
|
-
|
|
4183
|
+
_context24.next = 35;
|
|
3981
4184
|
break;
|
|
3982
4185
|
case 32:
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
_iterator20.e(
|
|
4186
|
+
_context24.prev = 32;
|
|
4187
|
+
_context24.t0 = _context24["catch"](4);
|
|
4188
|
+
_iterator20.e(_context24.t0);
|
|
3986
4189
|
case 35:
|
|
3987
|
-
|
|
4190
|
+
_context24.prev = 35;
|
|
3988
4191
|
_iterator20.f();
|
|
3989
|
-
return
|
|
4192
|
+
return _context24.finish(35);
|
|
3990
4193
|
case 38:
|
|
3991
|
-
|
|
4194
|
+
_context24.next = 40;
|
|
3992
4195
|
return this.finalizeProductOrderMutation(tempOrder, options);
|
|
3993
4196
|
case 40:
|
|
3994
4197
|
this.logInfo('addProductsToOrder success', {
|
|
3995
4198
|
itemsCount: items.length
|
|
3996
4199
|
});
|
|
3997
|
-
return
|
|
4200
|
+
return _context24.abrupt("return", tempOrder.products);
|
|
3998
4201
|
case 42:
|
|
3999
4202
|
case "end":
|
|
4000
|
-
return
|
|
4203
|
+
return _context24.stop();
|
|
4001
4204
|
}
|
|
4002
|
-
},
|
|
4205
|
+
}, _callee22, this, [[4, 32, 35, 38]]);
|
|
4003
4206
|
}));
|
|
4004
|
-
function addProductsToOrder(
|
|
4207
|
+
function addProductsToOrder(_x29, _x30) {
|
|
4005
4208
|
return _addProductsToOrder.apply(this, arguments);
|
|
4006
4209
|
}
|
|
4007
4210
|
return addProductsToOrder;
|
|
@@ -4035,17 +4238,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4035
4238
|
}, {
|
|
4036
4239
|
key: "preservePersistedBundlePriceFields",
|
|
4037
4240
|
value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
|
|
4038
|
-
var
|
|
4241
|
+
var _this27 = this;
|
|
4039
4242
|
if (!Array.isArray(nextBundles)) return nextBundles;
|
|
4040
4243
|
if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
|
|
4041
4244
|
var previousByIdentity = new Map();
|
|
4042
4245
|
previousBundles.forEach(function (bundle) {
|
|
4043
|
-
var identity =
|
|
4246
|
+
var identity = _this27.getBundleRuntimeIdentity(bundle);
|
|
4044
4247
|
if (identity) previousByIdentity.set(identity, bundle);
|
|
4045
4248
|
});
|
|
4046
4249
|
return nextBundles.map(function (bundle, index) {
|
|
4047
4250
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
4048
|
-
var previous = previousByIdentity.get(
|
|
4251
|
+
var previous = previousByIdentity.get(_this27.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
4049
4252
|
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
4050
4253
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
|
|
4051
4254
|
cover: previous.cover
|
|
@@ -4246,21 +4449,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4246
4449
|
}, {
|
|
4247
4450
|
key: "updateOrderProduct",
|
|
4248
4451
|
value: function () {
|
|
4249
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4452
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
|
|
4250
4453
|
var tempOrder, updatedProductUid;
|
|
4251
|
-
return _regeneratorRuntime().wrap(function
|
|
4252
|
-
while (1) switch (
|
|
4454
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context25) {
|
|
4455
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
4253
4456
|
case 0:
|
|
4254
4457
|
tempOrder = this.ensureTempOrder();
|
|
4255
4458
|
updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
4256
|
-
|
|
4459
|
+
_context25.next = 4;
|
|
4257
4460
|
return this.applyPromotion();
|
|
4258
4461
|
case 4:
|
|
4259
4462
|
this.applyDiscount({
|
|
4260
4463
|
reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
|
|
4261
4464
|
});
|
|
4262
4465
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4263
|
-
|
|
4466
|
+
_context25.next = 8;
|
|
4264
4467
|
return this.recalculateSummary({
|
|
4265
4468
|
createIfMissing: true
|
|
4266
4469
|
});
|
|
@@ -4269,14 +4472,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4269
4472
|
this.logInfo('updateOrderProduct success', {
|
|
4270
4473
|
params: params
|
|
4271
4474
|
});
|
|
4272
|
-
return
|
|
4475
|
+
return _context25.abrupt("return", tempOrder.products);
|
|
4273
4476
|
case 11:
|
|
4274
4477
|
case "end":
|
|
4275
|
-
return
|
|
4478
|
+
return _context25.stop();
|
|
4276
4479
|
}
|
|
4277
|
-
},
|
|
4480
|
+
}, _callee23, this);
|
|
4278
4481
|
}));
|
|
4279
|
-
function updateOrderProduct(
|
|
4482
|
+
function updateOrderProduct(_x31) {
|
|
4280
4483
|
return _updateOrderProduct.apply(this, arguments);
|
|
4281
4484
|
}
|
|
4282
4485
|
return updateOrderProduct;
|
|
@@ -4284,28 +4487,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4284
4487
|
}, {
|
|
4285
4488
|
key: "updateOrderProducts",
|
|
4286
4489
|
value: function () {
|
|
4287
|
-
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4288
|
-
var
|
|
4490
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(paramsList) {
|
|
4491
|
+
var _this28 = this;
|
|
4289
4492
|
var tempOrder, reapplyBookingDiscountProductUids;
|
|
4290
|
-
return _regeneratorRuntime().wrap(function
|
|
4291
|
-
while (1) switch (
|
|
4493
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context26) {
|
|
4494
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
4292
4495
|
case 0:
|
|
4293
4496
|
tempOrder = this.ensureTempOrder();
|
|
4294
4497
|
if (paramsList.length) {
|
|
4295
|
-
|
|
4498
|
+
_context26.next = 3;
|
|
4296
4499
|
break;
|
|
4297
4500
|
}
|
|
4298
|
-
return
|
|
4501
|
+
return _context26.abrupt("return", tempOrder.products);
|
|
4299
4502
|
case 3:
|
|
4300
4503
|
reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
|
|
4301
|
-
var updatedProductUid =
|
|
4504
|
+
var updatedProductUid = _this28.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
4302
4505
|
// 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
|
|
4303
4506
|
if (params.allow_booking_discount_reapply && updatedProductUid) {
|
|
4304
4507
|
acc.push(String(updatedProductUid));
|
|
4305
4508
|
}
|
|
4306
4509
|
return acc;
|
|
4307
4510
|
}, []);
|
|
4308
|
-
|
|
4511
|
+
_context26.next = 6;
|
|
4309
4512
|
return this.finalizeAfterProductsMutation(tempOrder, {
|
|
4310
4513
|
reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
|
|
4311
4514
|
});
|
|
@@ -4313,14 +4516,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4313
4516
|
this.logInfo('updateOrderProduct success', {
|
|
4314
4517
|
paramsList: paramsList
|
|
4315
4518
|
});
|
|
4316
|
-
return
|
|
4519
|
+
return _context26.abrupt("return", tempOrder.products);
|
|
4317
4520
|
case 8:
|
|
4318
4521
|
case "end":
|
|
4319
|
-
return
|
|
4522
|
+
return _context26.stop();
|
|
4320
4523
|
}
|
|
4321
|
-
},
|
|
4524
|
+
}, _callee24, this);
|
|
4322
4525
|
}));
|
|
4323
|
-
function updateOrderProducts(
|
|
4526
|
+
function updateOrderProducts(_x32) {
|
|
4324
4527
|
return _updateOrderProducts.apply(this, arguments);
|
|
4325
4528
|
}
|
|
4326
4529
|
return updateOrderProducts;
|
|
@@ -4328,11 +4531,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4328
4531
|
}, {
|
|
4329
4532
|
key: "updateOrderProductQuantity",
|
|
4330
4533
|
value: function () {
|
|
4331
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4534
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
|
|
4332
4535
|
var _targetProduct$metada17;
|
|
4333
4536
|
var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
|
|
4334
|
-
return _regeneratorRuntime().wrap(function
|
|
4335
|
-
while (1) switch (
|
|
4537
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context27) {
|
|
4538
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
4336
4539
|
case 0:
|
|
4337
4540
|
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;
|
|
4338
4541
|
tempOrder = this.ensureTempOrder();
|
|
@@ -4361,7 +4564,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4361
4564
|
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
4362
4565
|
}
|
|
4363
4566
|
if (!(productIndex === -1)) {
|
|
4364
|
-
|
|
4567
|
+
_context27.next = 12;
|
|
4365
4568
|
break;
|
|
4366
4569
|
}
|
|
4367
4570
|
throw new Error('[Order] 目标商品不存在,无法更新数量');
|
|
@@ -4375,12 +4578,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4375
4578
|
}));
|
|
4376
4579
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
4377
4580
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
4378
|
-
|
|
4581
|
+
_context27.next = 18;
|
|
4379
4582
|
return this.applyPromotion();
|
|
4380
4583
|
case 18:
|
|
4381
4584
|
this.applyDiscount();
|
|
4382
4585
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4383
|
-
|
|
4586
|
+
_context27.next = 22;
|
|
4384
4587
|
return this.recalculateSummary({
|
|
4385
4588
|
createIfMissing: true
|
|
4386
4589
|
});
|
|
@@ -4389,14 +4592,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4389
4592
|
this.logInfo('updateOrderProductQuantity success', {
|
|
4390
4593
|
params: params
|
|
4391
4594
|
});
|
|
4392
|
-
return
|
|
4595
|
+
return _context27.abrupt("return", tempOrder.products);
|
|
4393
4596
|
case 25:
|
|
4394
4597
|
case "end":
|
|
4395
|
-
return
|
|
4598
|
+
return _context27.stop();
|
|
4396
4599
|
}
|
|
4397
|
-
},
|
|
4600
|
+
}, _callee25, this);
|
|
4398
4601
|
}));
|
|
4399
|
-
function updateOrderProductQuantity(
|
|
4602
|
+
function updateOrderProductQuantity(_x33) {
|
|
4400
4603
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
4401
4604
|
}
|
|
4402
4605
|
return updateOrderProductQuantity;
|
|
@@ -4437,19 +4640,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4437
4640
|
}, {
|
|
4438
4641
|
key: "finalizeAfterProductsMutation",
|
|
4439
4642
|
value: (function () {
|
|
4440
|
-
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4441
|
-
return _regeneratorRuntime().wrap(function
|
|
4442
|
-
while (1) switch (
|
|
4643
|
+
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(tempOrder, options) {
|
|
4644
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context28) {
|
|
4645
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
4443
4646
|
case 0:
|
|
4444
4647
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
4445
|
-
|
|
4648
|
+
_context28.next = 3;
|
|
4446
4649
|
return this.applyPromotion();
|
|
4447
4650
|
case 3:
|
|
4448
4651
|
this.applyDiscount({
|
|
4449
4652
|
reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
|
|
4450
4653
|
});
|
|
4451
4654
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4452
|
-
|
|
4655
|
+
_context28.next = 7;
|
|
4453
4656
|
return this.recalculateSummary({
|
|
4454
4657
|
createIfMissing: true
|
|
4455
4658
|
});
|
|
@@ -4457,11 +4660,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4457
4660
|
this.persistTempOrder();
|
|
4458
4661
|
case 8:
|
|
4459
4662
|
case "end":
|
|
4460
|
-
return
|
|
4663
|
+
return _context28.stop();
|
|
4461
4664
|
}
|
|
4462
|
-
},
|
|
4665
|
+
}, _callee26, this);
|
|
4463
4666
|
}));
|
|
4464
|
-
function finalizeAfterProductsMutation(
|
|
4667
|
+
function finalizeAfterProductsMutation(_x34, _x35) {
|
|
4465
4668
|
return _finalizeAfterProductsMutation.apply(this, arguments);
|
|
4466
4669
|
}
|
|
4467
4670
|
return finalizeAfterProductsMutation;
|
|
@@ -4476,18 +4679,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4476
4679
|
}, {
|
|
4477
4680
|
key: "removeProductsFromOrder",
|
|
4478
4681
|
value: (function () {
|
|
4479
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4480
|
-
var
|
|
4682
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(identities, options) {
|
|
4683
|
+
var _this29 = this;
|
|
4481
4684
|
var tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
|
|
4482
|
-
return _regeneratorRuntime().wrap(function
|
|
4483
|
-
while (1) switch (
|
|
4685
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context30) {
|
|
4686
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
4484
4687
|
case 0:
|
|
4485
4688
|
tempOrder = this.ensureTempOrder();
|
|
4486
4689
|
if (identities.length) {
|
|
4487
|
-
|
|
4690
|
+
_context30.next = 3;
|
|
4488
4691
|
break;
|
|
4489
4692
|
}
|
|
4490
|
-
return
|
|
4693
|
+
return _context30.abrupt("return", tempOrder.products);
|
|
4491
4694
|
case 3:
|
|
4492
4695
|
productsBeforeRemove = tempOrder.products || [];
|
|
4493
4696
|
bookingsBeforeRemove = tempOrder.bookings || [];
|
|
@@ -4517,29 +4720,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4517
4720
|
}
|
|
4518
4721
|
linkedBookingUidsToRemove = new Set();
|
|
4519
4722
|
_iterator21 = _createForOfIteratorHelper(matchedProducts);
|
|
4520
|
-
|
|
4723
|
+
_context30.prev = 14;
|
|
4521
4724
|
_loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
|
|
4522
4725
|
var _metadata11, _metadata12, _metadata13, _metadata14;
|
|
4523
4726
|
var product, productUid, productBookingUid, isAddTimeProduct;
|
|
4524
|
-
return _regeneratorRuntime().wrap(function _loop3$(
|
|
4525
|
-
while (1) switch (
|
|
4727
|
+
return _regeneratorRuntime().wrap(function _loop3$(_context29) {
|
|
4728
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
4526
4729
|
case 0:
|
|
4527
4730
|
product = _step21.value;
|
|
4528
4731
|
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);
|
|
4529
4732
|
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);
|
|
4530
4733
|
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;
|
|
4531
4734
|
if (!isAddTimeProduct) {
|
|
4532
|
-
|
|
4735
|
+
_context29.next = 6;
|
|
4533
4736
|
break;
|
|
4534
4737
|
}
|
|
4535
|
-
return
|
|
4738
|
+
return _context29.abrupt("return", 1);
|
|
4536
4739
|
case 6:
|
|
4537
4740
|
if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
|
|
4538
4741
|
linkedBookingUidsToRemove.add(String(productBookingUid));
|
|
4539
4742
|
}
|
|
4540
4743
|
if (productUid !== undefined && productUid !== null && productUid !== '') {
|
|
4541
4744
|
bookingsBeforeRemove.forEach(function (booking) {
|
|
4542
|
-
var bookingUid =
|
|
4745
|
+
var bookingUid = _this29.getBookingUniqueIdentificationNumber(booking);
|
|
4543
4746
|
if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
|
|
4544
4747
|
linkedBookingUidsToRemove.add(bookingUid);
|
|
4545
4748
|
}
|
|
@@ -4547,37 +4750,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4547
4750
|
}
|
|
4548
4751
|
case 8:
|
|
4549
4752
|
case "end":
|
|
4550
|
-
return
|
|
4753
|
+
return _context29.stop();
|
|
4551
4754
|
}
|
|
4552
4755
|
}, _loop3);
|
|
4553
4756
|
});
|
|
4554
4757
|
_iterator21.s();
|
|
4555
4758
|
case 17:
|
|
4556
4759
|
if ((_step21 = _iterator21.n()).done) {
|
|
4557
|
-
|
|
4760
|
+
_context30.next = 23;
|
|
4558
4761
|
break;
|
|
4559
4762
|
}
|
|
4560
|
-
return
|
|
4763
|
+
return _context30.delegateYield(_loop3(), "t0", 19);
|
|
4561
4764
|
case 19:
|
|
4562
|
-
if (!
|
|
4563
|
-
|
|
4765
|
+
if (!_context30.t0) {
|
|
4766
|
+
_context30.next = 21;
|
|
4564
4767
|
break;
|
|
4565
4768
|
}
|
|
4566
|
-
return
|
|
4769
|
+
return _context30.abrupt("continue", 21);
|
|
4567
4770
|
case 21:
|
|
4568
|
-
|
|
4771
|
+
_context30.next = 17;
|
|
4569
4772
|
break;
|
|
4570
4773
|
case 23:
|
|
4571
|
-
|
|
4774
|
+
_context30.next = 28;
|
|
4572
4775
|
break;
|
|
4573
4776
|
case 25:
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
_iterator21.e(
|
|
4777
|
+
_context30.prev = 25;
|
|
4778
|
+
_context30.t1 = _context30["catch"](14);
|
|
4779
|
+
_iterator21.e(_context30.t1);
|
|
4577
4780
|
case 28:
|
|
4578
|
-
|
|
4781
|
+
_context30.prev = 28;
|
|
4579
4782
|
_iterator21.f();
|
|
4580
|
-
return
|
|
4783
|
+
return _context30.finish(28);
|
|
4581
4784
|
case 31:
|
|
4582
4785
|
if (linkedBookingUidsToRemove.size > 0) {
|
|
4583
4786
|
// 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
|
|
@@ -4604,20 +4807,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4604
4807
|
tempOrder.products = nextProductIndex >= 0 ? [].concat(_toConsumableArray(productsWithoutRemaining.slice(0, nextProductIndex)), [remainingProduct], _toConsumableArray(productsWithoutRemaining.slice(nextProductIndex))) : [].concat(_toConsumableArray(productsWithoutRemaining), [remainingProduct]);
|
|
4605
4808
|
}
|
|
4606
4809
|
}
|
|
4607
|
-
|
|
4810
|
+
_context30.next = 35;
|
|
4608
4811
|
return this.finalizeAfterProductsMutation(tempOrder);
|
|
4609
4812
|
case 35:
|
|
4610
4813
|
this.logInfo('removeProductsFromOrder success', {
|
|
4611
4814
|
identities: identities
|
|
4612
4815
|
});
|
|
4613
|
-
return
|
|
4816
|
+
return _context30.abrupt("return", tempOrder.products);
|
|
4614
4817
|
case 37:
|
|
4615
4818
|
case "end":
|
|
4616
|
-
return
|
|
4819
|
+
return _context30.stop();
|
|
4617
4820
|
}
|
|
4618
|
-
},
|
|
4821
|
+
}, _callee27, this, [[14, 25, 28, 31]]);
|
|
4619
4822
|
}));
|
|
4620
|
-
function removeProductsFromOrder(
|
|
4823
|
+
function removeProductsFromOrder(_x36, _x37) {
|
|
4621
4824
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
4622
4825
|
}
|
|
4623
4826
|
return removeProductsFromOrder;
|
|
@@ -4625,18 +4828,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4625
4828
|
}, {
|
|
4626
4829
|
key: "removeProductFromOrder",
|
|
4627
4830
|
value: function () {
|
|
4628
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4629
|
-
return _regeneratorRuntime().wrap(function
|
|
4630
|
-
while (1) switch (
|
|
4831
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(identity, options) {
|
|
4832
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context31) {
|
|
4833
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
4631
4834
|
case 0:
|
|
4632
|
-
return
|
|
4835
|
+
return _context31.abrupt("return", this.removeProductsFromOrder([identity], options));
|
|
4633
4836
|
case 1:
|
|
4634
4837
|
case "end":
|
|
4635
|
-
return
|
|
4838
|
+
return _context31.stop();
|
|
4636
4839
|
}
|
|
4637
|
-
},
|
|
4840
|
+
}, _callee28, this);
|
|
4638
4841
|
}));
|
|
4639
|
-
function removeProductFromOrder(
|
|
4842
|
+
function removeProductFromOrder(_x38, _x39) {
|
|
4640
4843
|
return _removeProductFromOrder.apply(this, arguments);
|
|
4641
4844
|
}
|
|
4642
4845
|
return removeProductFromOrder;
|
|
@@ -4648,10 +4851,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4648
4851
|
}, {
|
|
4649
4852
|
key: "clearOrderCartLines",
|
|
4650
4853
|
value: (function () {
|
|
4651
|
-
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4854
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
4652
4855
|
var tempOrder;
|
|
4653
|
-
return _regeneratorRuntime().wrap(function
|
|
4654
|
-
while (1) switch (
|
|
4856
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context32) {
|
|
4857
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
4655
4858
|
case 0:
|
|
4656
4859
|
tempOrder = this.ensureTempOrder();
|
|
4657
4860
|
tempOrder.products = [];
|
|
@@ -4662,24 +4865,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4662
4865
|
productsByUid: {}
|
|
4663
4866
|
});
|
|
4664
4867
|
}
|
|
4665
|
-
|
|
4868
|
+
_context32.next = 7;
|
|
4666
4869
|
return this.applyPromotion();
|
|
4667
4870
|
case 7:
|
|
4668
4871
|
this.applyDiscount();
|
|
4669
4872
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4670
|
-
|
|
4873
|
+
_context32.next = 11;
|
|
4671
4874
|
return this.recalculateSummary({
|
|
4672
4875
|
createIfMissing: true
|
|
4673
4876
|
});
|
|
4674
4877
|
case 11:
|
|
4675
4878
|
this.persistTempOrder();
|
|
4676
4879
|
this.logInfo('clearOrderCartLines success', {});
|
|
4677
|
-
return
|
|
4880
|
+
return _context32.abrupt("return", tempOrder);
|
|
4678
4881
|
case 14:
|
|
4679
4882
|
case "end":
|
|
4680
|
-
return
|
|
4883
|
+
return _context32.stop();
|
|
4681
4884
|
}
|
|
4682
|
-
},
|
|
4885
|
+
}, _callee29, this);
|
|
4683
4886
|
}));
|
|
4684
4887
|
function clearOrderCartLines() {
|
|
4685
4888
|
return _clearOrderCartLines.apply(this, arguments);
|
|
@@ -4717,17 +4920,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4717
4920
|
}, {
|
|
4718
4921
|
key: "applyLocalPrintOrderNumbers",
|
|
4719
4922
|
value: function () {
|
|
4720
|
-
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4923
|
+
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(order) {
|
|
4721
4924
|
var tempOrder, shopOrderNumber, shopFullOrderNumber;
|
|
4722
|
-
return _regeneratorRuntime().wrap(function
|
|
4723
|
-
while (1) switch (
|
|
4925
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context33) {
|
|
4926
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
4724
4927
|
case 0:
|
|
4725
4928
|
tempOrder = this.ensureTempOrder();
|
|
4726
4929
|
if (!(!order || _typeof(order) !== 'object')) {
|
|
4727
|
-
|
|
4930
|
+
_context33.next = 3;
|
|
4728
4931
|
break;
|
|
4729
4932
|
}
|
|
4730
|
-
return
|
|
4933
|
+
return _context33.abrupt("return", tempOrder);
|
|
4731
4934
|
case 3:
|
|
4732
4935
|
shopOrderNumber = order.shop_order_number;
|
|
4733
4936
|
shopFullOrderNumber = order.shop_full_order_number;
|
|
@@ -4738,21 +4941,88 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4738
4941
|
tempOrder.shop_full_order_number = String(shopFullOrderNumber);
|
|
4739
4942
|
}
|
|
4740
4943
|
this.persistTempOrder();
|
|
4741
|
-
|
|
4944
|
+
_context33.next = 10;
|
|
4742
4945
|
return this.saveDraft();
|
|
4743
4946
|
case 10:
|
|
4744
|
-
return
|
|
4947
|
+
return _context33.abrupt("return", tempOrder);
|
|
4745
4948
|
case 11:
|
|
4746
4949
|
case "end":
|
|
4747
|
-
return
|
|
4950
|
+
return _context33.stop();
|
|
4748
4951
|
}
|
|
4749
|
-
},
|
|
4952
|
+
}, _callee30, this);
|
|
4750
4953
|
}));
|
|
4751
|
-
function applyLocalPrintOrderNumbers(
|
|
4954
|
+
function applyLocalPrintOrderNumbers(_x40) {
|
|
4752
4955
|
return _applyLocalPrintOrderNumbers.apply(this, arguments);
|
|
4753
4956
|
}
|
|
4754
4957
|
return applyLocalPrintOrderNumbers;
|
|
4755
4958
|
}()
|
|
4959
|
+
}, {
|
|
4960
|
+
key: "saveTempOrderAsDraft",
|
|
4961
|
+
value: function () {
|
|
4962
|
+
var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
4963
|
+
var _params$cacheId2, _this$otherParams6, _this$otherParams7, _this$otherParams8, _params$type, _this$otherParams9, _payload$products;
|
|
4964
|
+
var tempOrder, latestSummary, payload;
|
|
4965
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context34) {
|
|
4966
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
4967
|
+
case 0:
|
|
4968
|
+
tempOrder = this.ensureTempOrder();
|
|
4969
|
+
this.ensureExternalSaleNumber(tempOrder);
|
|
4970
|
+
this.persistTempOrder();
|
|
4971
|
+
_context34.next = 5;
|
|
4972
|
+
return this.recalculateSummary({
|
|
4973
|
+
createIfMissing: true
|
|
4974
|
+
});
|
|
4975
|
+
case 5:
|
|
4976
|
+
_context34.t1 = _context34.sent;
|
|
4977
|
+
if (_context34.t1) {
|
|
4978
|
+
_context34.next = 8;
|
|
4979
|
+
break;
|
|
4980
|
+
}
|
|
4981
|
+
_context34.t1 = this.store.summary;
|
|
4982
|
+
case 8:
|
|
4983
|
+
_context34.t0 = _context34.t1;
|
|
4984
|
+
if (_context34.t0) {
|
|
4985
|
+
_context34.next = 11;
|
|
4986
|
+
break;
|
|
4987
|
+
}
|
|
4988
|
+
_context34.t0 = createEmptySummary();
|
|
4989
|
+
case 11:
|
|
4990
|
+
latestSummary = _context34.t0;
|
|
4991
|
+
payload = buildSubmitPayload({
|
|
4992
|
+
tempOrder: tempOrder,
|
|
4993
|
+
cacheId: (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId,
|
|
4994
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform),
|
|
4995
|
+
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,
|
|
4996
|
+
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
4997
|
+
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,
|
|
4998
|
+
summary: latestSummary,
|
|
4999
|
+
enhance: params === null || params === void 0 ? void 0 : params.enhancePayload
|
|
5000
|
+
});
|
|
5001
|
+
if (!payload.created_at) {
|
|
5002
|
+
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
5003
|
+
}
|
|
5004
|
+
payload.need_sync = 0;
|
|
5005
|
+
payload.is_draft_order = 1;
|
|
5006
|
+
this.logInfo('saveTempOrderAsDraft calling sales draft', {
|
|
5007
|
+
orderId: payload.order_id,
|
|
5008
|
+
externalSaleNumber: payload.external_sale_number,
|
|
5009
|
+
productsCount: ((_payload$products = payload.products) === null || _payload$products === void 0 ? void 0 : _payload$products.length) || 0
|
|
5010
|
+
});
|
|
5011
|
+
return _context34.abrupt("return", this.request.post('/order/sales/draft', payload, {
|
|
5012
|
+
osServer: true,
|
|
5013
|
+
customToast: function customToast() {}
|
|
5014
|
+
}));
|
|
5015
|
+
case 18:
|
|
5016
|
+
case "end":
|
|
5017
|
+
return _context34.stop();
|
|
5018
|
+
}
|
|
5019
|
+
}, _callee31, this);
|
|
5020
|
+
}));
|
|
5021
|
+
function saveTempOrderAsDraft(_x41) {
|
|
5022
|
+
return _saveTempOrderAsDraft.apply(this, arguments);
|
|
5023
|
+
}
|
|
5024
|
+
return saveTempOrderAsDraft;
|
|
5025
|
+
}()
|
|
4756
5026
|
/**
|
|
4757
5027
|
* 提交当前 Sales tempOrder。
|
|
4758
5028
|
*
|
|
@@ -4762,18 +5032,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4762
5032
|
}, {
|
|
4763
5033
|
key: "submitTempOrder",
|
|
4764
5034
|
value: (function () {
|
|
4765
|
-
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4766
|
-
return _regeneratorRuntime().wrap(function
|
|
4767
|
-
while (1) switch (
|
|
5035
|
+
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
|
|
5036
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context35) {
|
|
5037
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
4768
5038
|
case 0:
|
|
4769
|
-
return
|
|
5039
|
+
return _context35.abrupt("return", this.runSubmitTempOrder(params));
|
|
4770
5040
|
case 1:
|
|
4771
5041
|
case "end":
|
|
4772
|
-
return
|
|
5042
|
+
return _context35.stop();
|
|
4773
5043
|
}
|
|
4774
|
-
},
|
|
5044
|
+
}, _callee32, this);
|
|
4775
5045
|
}));
|
|
4776
|
-
function submitTempOrder(
|
|
5046
|
+
function submitTempOrder(_x42) {
|
|
4777
5047
|
return _submitTempOrder.apply(this, arguments);
|
|
4778
5048
|
}
|
|
4779
5049
|
return submitTempOrder;
|
|
@@ -4781,20 +5051,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4781
5051
|
}, {
|
|
4782
5052
|
key: "submitTempOrderAsync",
|
|
4783
5053
|
value: function () {
|
|
4784
|
-
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4785
|
-
return _regeneratorRuntime().wrap(function
|
|
4786
|
-
while (1) switch (
|
|
5054
|
+
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
|
|
5055
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context36) {
|
|
5056
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
4787
5057
|
case 0:
|
|
4788
|
-
return
|
|
5058
|
+
return _context36.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
4789
5059
|
syncMode: true
|
|
4790
5060
|
})));
|
|
4791
5061
|
case 1:
|
|
4792
5062
|
case "end":
|
|
4793
|
-
return
|
|
5063
|
+
return _context36.stop();
|
|
4794
5064
|
}
|
|
4795
|
-
},
|
|
5065
|
+
}, _callee33, this);
|
|
4796
5066
|
}));
|
|
4797
|
-
function submitTempOrderAsync(
|
|
5067
|
+
function submitTempOrderAsync(_x43) {
|
|
4798
5068
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
4799
5069
|
}
|
|
4800
5070
|
return submitTempOrderAsync;
|
|
@@ -4802,11 +5072,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4802
5072
|
}, {
|
|
4803
5073
|
key: "runSubmitTempOrder",
|
|
4804
5074
|
value: function () {
|
|
4805
|
-
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4806
|
-
var _params$
|
|
5075
|
+
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
5076
|
+
var _params$cacheId3, _this$otherParams10, _ref74, _ref75, _submitSnapshot$busin, _this$otherParams11, _this$otherParams12, _submitSnapshot$type;
|
|
4807
5077
|
var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
|
|
4808
|
-
return _regeneratorRuntime().wrap(function
|
|
4809
|
-
while (1) switch (
|
|
5078
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context37) {
|
|
5079
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
4810
5080
|
case 0:
|
|
4811
5081
|
tempOrder = this.ensureTempOrder();
|
|
4812
5082
|
shouldConfirmPendingVoucherPayments = (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== false;
|
|
@@ -4826,27 +5096,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4826
5096
|
}
|
|
4827
5097
|
}
|
|
4828
5098
|
this.persistTempOrder();
|
|
4829
|
-
|
|
5099
|
+
_context37.next = 8;
|
|
4830
5100
|
return this.recalculateSummary({
|
|
4831
5101
|
createIfMissing: true
|
|
4832
5102
|
});
|
|
4833
5103
|
case 8:
|
|
4834
|
-
|
|
4835
|
-
if (
|
|
4836
|
-
|
|
5104
|
+
_context37.t1 = _context37.sent;
|
|
5105
|
+
if (_context37.t1) {
|
|
5106
|
+
_context37.next = 11;
|
|
4837
5107
|
break;
|
|
4838
5108
|
}
|
|
4839
|
-
|
|
5109
|
+
_context37.t1 = this.store.summary;
|
|
4840
5110
|
case 11:
|
|
4841
|
-
|
|
4842
|
-
if (
|
|
4843
|
-
|
|
5111
|
+
_context37.t0 = _context37.t1;
|
|
5112
|
+
if (_context37.t0) {
|
|
5113
|
+
_context37.next = 14;
|
|
4844
5114
|
break;
|
|
4845
5115
|
}
|
|
4846
|
-
|
|
5116
|
+
_context37.t0 = createEmptySummary();
|
|
4847
5117
|
case 14:
|
|
4848
|
-
latestSummary =
|
|
4849
|
-
effectiveCacheId = (_params$
|
|
5118
|
+
latestSummary = _context37.t0;
|
|
5119
|
+
effectiveCacheId = (_params$cacheId3 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId3 !== void 0 ? _params$cacheId3 : this.cacheId;
|
|
4850
5120
|
hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
|
|
4851
5121
|
hasSmallTicketDataFlagOverride = (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined;
|
|
4852
5122
|
enhancePayload = hasPaymentOverride || hasPaymentStatusOverride || hasSmallTicketDataFlagOverride || params !== null && params !== void 0 && params.enhancePayload ? function (payload, ctx) {
|
|
@@ -4864,8 +5134,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4864
5134
|
payload = buildSubmitPayload({
|
|
4865
5135
|
tempOrder: tempOrder,
|
|
4866
5136
|
cacheId: effectiveCacheId,
|
|
4867
|
-
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$
|
|
4868
|
-
businessCode: (_ref74 = (_ref75 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref75 !== void 0 ? _ref75 : (_this$
|
|
5137
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.platform),
|
|
5138
|
+
businessCode: (_ref74 = (_ref75 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref75 !== void 0 ? _ref75 : (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) !== null && _ref74 !== void 0 ? _ref74 : (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.business_code,
|
|
4869
5139
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
4870
5140
|
type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
|
|
4871
5141
|
summary: latestSummary,
|
|
@@ -4880,10 +5150,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4880
5150
|
if (!payload.created_at) {
|
|
4881
5151
|
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
4882
5152
|
}
|
|
4883
|
-
|
|
5153
|
+
_context37.next = 26;
|
|
4884
5154
|
return this.saveDraft();
|
|
4885
5155
|
case 26:
|
|
4886
|
-
|
|
5156
|
+
_context37.prev = 26;
|
|
4887
5157
|
this.logInfo('submitTempOrder calling sales checkout', {
|
|
4888
5158
|
orderId: payload.order_id,
|
|
4889
5159
|
externalSaleNumber: payload.external_sale_number,
|
|
@@ -4893,43 +5163,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4893
5163
|
smallTicketDataFlag: payload.small_ticket_data_flag,
|
|
4894
5164
|
syncMode: payload.sync_mode
|
|
4895
5165
|
});
|
|
4896
|
-
|
|
5166
|
+
_context37.next = 30;
|
|
4897
5167
|
return this.submitSalesOrder({
|
|
4898
5168
|
query: payload
|
|
4899
5169
|
});
|
|
4900
5170
|
case 30:
|
|
4901
|
-
result =
|
|
4902
|
-
|
|
5171
|
+
result = _context37.sent;
|
|
5172
|
+
_context37.next = 43;
|
|
4903
5173
|
break;
|
|
4904
5174
|
case 33:
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
backendErrorResponse = this.extractSubmitErrorResponse(
|
|
5175
|
+
_context37.prev = 33;
|
|
5176
|
+
_context37.t2 = _context37["catch"](26);
|
|
5177
|
+
backendErrorResponse = this.extractSubmitErrorResponse(_context37.t2);
|
|
4908
5178
|
if (!backendErrorResponse) {
|
|
4909
|
-
|
|
5179
|
+
_context37.next = 40;
|
|
4910
5180
|
break;
|
|
4911
5181
|
}
|
|
4912
5182
|
this.store.syncState = 'failed';
|
|
4913
5183
|
this.logSubmitBackendRejected(backendErrorResponse, payload);
|
|
4914
|
-
return
|
|
5184
|
+
return _context37.abrupt("return", backendErrorResponse);
|
|
4915
5185
|
case 40:
|
|
4916
5186
|
this.store.syncState = 'failed';
|
|
4917
5187
|
this.logError('submitTempOrder failed', {
|
|
4918
|
-
error:
|
|
5188
|
+
error: _context37.t2 instanceof Error ? _context37.t2.message : String(_context37.t2),
|
|
4919
5189
|
orderId: payload.order_id,
|
|
4920
5190
|
externalSaleNumber: payload.external_sale_number,
|
|
4921
5191
|
paymentStatus: payload.payment_status,
|
|
4922
5192
|
paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
|
|
4923
5193
|
});
|
|
4924
|
-
throw
|
|
5194
|
+
throw _context37.t2;
|
|
4925
5195
|
case 43:
|
|
4926
5196
|
if (!this.isSubmitResponseRejected(result)) {
|
|
4927
|
-
|
|
5197
|
+
_context37.next = 47;
|
|
4928
5198
|
break;
|
|
4929
5199
|
}
|
|
4930
5200
|
this.store.syncState = 'failed';
|
|
4931
5201
|
this.logSubmitBackendRejected(result, payload);
|
|
4932
|
-
return
|
|
5202
|
+
return _context37.abrupt("return", result);
|
|
4933
5203
|
case 47:
|
|
4934
5204
|
submittedOrderId = this.extractOrderIdFromSubmitResult(result);
|
|
4935
5205
|
this.logInfo('runSubmitTempOrder: 提交成功', {
|
|
@@ -4940,15 +5210,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4940
5210
|
})
|
|
4941
5211
|
});
|
|
4942
5212
|
if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
|
|
4943
|
-
|
|
5213
|
+
_context37.next = 56;
|
|
4944
5214
|
break;
|
|
4945
5215
|
}
|
|
4946
5216
|
tempOrder.order_id = submittedOrderId;
|
|
4947
5217
|
resultRecord = result;
|
|
4948
|
-
|
|
5218
|
+
_context37.next = 54;
|
|
4949
5219
|
return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
|
|
4950
5220
|
case 54:
|
|
4951
|
-
|
|
5221
|
+
_context37.next = 57;
|
|
4952
5222
|
break;
|
|
4953
5223
|
case 56:
|
|
4954
5224
|
if (this.isLocalPendingSubmitResult(result)) {
|
|
@@ -4957,14 +5227,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4957
5227
|
this.store.syncState = 'submitted';
|
|
4958
5228
|
}
|
|
4959
5229
|
case 57:
|
|
4960
|
-
return
|
|
5230
|
+
return _context37.abrupt("return", result);
|
|
4961
5231
|
case 58:
|
|
4962
5232
|
case "end":
|
|
4963
|
-
return
|
|
5233
|
+
return _context37.stop();
|
|
4964
5234
|
}
|
|
4965
|
-
},
|
|
5235
|
+
}, _callee34, this, [[26, 33]]);
|
|
4966
5236
|
}));
|
|
4967
|
-
function runSubmitTempOrder(
|
|
5237
|
+
function runSubmitTempOrder(_x44) {
|
|
4968
5238
|
return _runSubmitTempOrder.apply(this, arguments);
|
|
4969
5239
|
}
|
|
4970
5240
|
return runSubmitTempOrder;
|
|
@@ -4972,10 +5242,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4972
5242
|
}, {
|
|
4973
5243
|
key: "markLocalOrderSynced",
|
|
4974
5244
|
value: function () {
|
|
4975
|
-
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5245
|
+
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(orderId, remoteOrder) {
|
|
4976
5246
|
var tempOrder;
|
|
4977
|
-
return _regeneratorRuntime().wrap(function
|
|
4978
|
-
while (1) switch (
|
|
5247
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context38) {
|
|
5248
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
4979
5249
|
case 0:
|
|
4980
5250
|
tempOrder = this.ensureTempOrder();
|
|
4981
5251
|
tempOrder.order_id = orderId;
|
|
@@ -4983,15 +5253,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4983
5253
|
this.store.lastOrderInfo = remoteOrder;
|
|
4984
5254
|
this.store.syncState = 'submitted';
|
|
4985
5255
|
this.persistTempOrder();
|
|
4986
|
-
|
|
5256
|
+
_context38.next = 8;
|
|
4987
5257
|
return this.saveDraft();
|
|
4988
5258
|
case 8:
|
|
4989
5259
|
case "end":
|
|
4990
|
-
return
|
|
5260
|
+
return _context38.stop();
|
|
4991
5261
|
}
|
|
4992
|
-
},
|
|
5262
|
+
}, _callee35, this);
|
|
4993
5263
|
}));
|
|
4994
|
-
function markLocalOrderSynced(
|
|
5264
|
+
function markLocalOrderSynced(_x45, _x46) {
|
|
4995
5265
|
return _markLocalOrderSynced.apply(this, arguments);
|
|
4996
5266
|
}
|
|
4997
5267
|
return markLocalOrderSynced;
|
|
@@ -5034,10 +5304,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5034
5304
|
value: function extractSubmitErrorResponse(error) {
|
|
5035
5305
|
var _error$response,
|
|
5036
5306
|
_error$response2,
|
|
5037
|
-
|
|
5307
|
+
_this30 = this;
|
|
5038
5308
|
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];
|
|
5039
5309
|
return candidates.find(function (candidate) {
|
|
5040
|
-
return
|
|
5310
|
+
return _this30.isSubmitErrorResponse(candidate);
|
|
5041
5311
|
}) || null;
|
|
5042
5312
|
}
|
|
5043
5313
|
}, {
|
|
@@ -5064,14 +5334,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5064
5334
|
}, {
|
|
5065
5335
|
key: "syncPaymentsToOrder",
|
|
5066
5336
|
value: function () {
|
|
5067
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5068
|
-
var
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5337
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
|
|
5338
|
+
var _this31 = this,
|
|
5339
|
+
_params$confirmPendin;
|
|
5340
|
+
var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, submitResult;
|
|
5341
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context39) {
|
|
5342
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
5072
5343
|
case 0:
|
|
5073
5344
|
tempOrder = this.ensureTempOrder();
|
|
5074
|
-
|
|
5345
|
+
needsPaymentNumber = (params.payments || []).some(function (payment) {
|
|
5346
|
+
return String(payment.payment_number || '').trim() === '';
|
|
5347
|
+
});
|
|
5348
|
+
if (!needsPaymentNumber) {
|
|
5349
|
+
_context39.next = 8;
|
|
5350
|
+
break;
|
|
5351
|
+
}
|
|
5352
|
+
_context39.next = 5;
|
|
5353
|
+
return this.getPaymentNumberDevicePrefixAsync();
|
|
5354
|
+
case 5:
|
|
5355
|
+
_context39.t0 = _context39.sent;
|
|
5356
|
+
_context39.next = 9;
|
|
5357
|
+
break;
|
|
5358
|
+
case 8:
|
|
5359
|
+
_context39.t0 = 'LOCAL';
|
|
5360
|
+
case 9:
|
|
5361
|
+
devicePrefix = _context39.t0;
|
|
5362
|
+
mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
|
|
5363
|
+
return _this31.normalizePaymentSource(payment, {
|
|
5364
|
+
defaultPaid: false,
|
|
5365
|
+
devicePrefix: devicePrefix
|
|
5366
|
+
});
|
|
5367
|
+
}));
|
|
5075
5368
|
shouldConfirmPendingVoucherPayments = (_params$confirmPendin = params.confirmPendingVoucherPayments) !== null && _params$confirmPendin !== void 0 ? _params$confirmPendin : params.submitWhenPaid === true;
|
|
5076
5369
|
effectivePayments = shouldConfirmPendingVoucherPayments ? this.confirmPendingVoucherPaymentsInList(mappedPayments) : params.confirmPendingVoucherPayments === false ? this.discardPendingVoucherPaymentsFromList(mappedPayments) : mappedPayments;
|
|
5077
5370
|
completion = this.getPaymentCompletion(effectivePayments);
|
|
@@ -5080,24 +5373,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5080
5373
|
tempOrder.payments = effectivePayments;
|
|
5081
5374
|
tempOrder.payment_status = paymentStatus;
|
|
5082
5375
|
this.persistTempOrder();
|
|
5083
|
-
|
|
5376
|
+
_context39.next = 21;
|
|
5084
5377
|
return this.saveDraft();
|
|
5085
|
-
case
|
|
5378
|
+
case 21:
|
|
5086
5379
|
if (params.submitWhenPaid) {
|
|
5087
|
-
|
|
5380
|
+
_context39.next = 23;
|
|
5088
5381
|
break;
|
|
5089
5382
|
}
|
|
5090
|
-
return
|
|
5091
|
-
case
|
|
5383
|
+
return _context39.abrupt("return", completion);
|
|
5384
|
+
case 23:
|
|
5092
5385
|
if (!(this.store.syncState === 'submitting')) {
|
|
5093
|
-
|
|
5386
|
+
_context39.next = 25;
|
|
5094
5387
|
break;
|
|
5095
5388
|
}
|
|
5096
|
-
return
|
|
5097
|
-
case
|
|
5389
|
+
return _context39.abrupt("return", completion);
|
|
5390
|
+
case 25:
|
|
5098
5391
|
this.store.syncState = 'submitting';
|
|
5099
5392
|
paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
|
|
5100
|
-
|
|
5393
|
+
_context39.next = 29;
|
|
5101
5394
|
return this.submitTempOrder({
|
|
5102
5395
|
payments: effectivePayments,
|
|
5103
5396
|
paymentStatus: paymentStatus,
|
|
@@ -5112,18 +5405,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5112
5405
|
return nextPayload;
|
|
5113
5406
|
}
|
|
5114
5407
|
});
|
|
5115
|
-
case
|
|
5116
|
-
submitResult =
|
|
5117
|
-
return
|
|
5408
|
+
case 29:
|
|
5409
|
+
submitResult = _context39.sent;
|
|
5410
|
+
return _context39.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
|
|
5118
5411
|
submitResult: submitResult
|
|
5119
5412
|
}));
|
|
5120
|
-
case
|
|
5413
|
+
case 31:
|
|
5121
5414
|
case "end":
|
|
5122
|
-
return
|
|
5415
|
+
return _context39.stop();
|
|
5123
5416
|
}
|
|
5124
|
-
},
|
|
5417
|
+
}, _callee36, this);
|
|
5125
5418
|
}));
|
|
5126
|
-
function syncPaymentsToOrder(
|
|
5419
|
+
function syncPaymentsToOrder(_x47) {
|
|
5127
5420
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
5128
5421
|
}
|
|
5129
5422
|
return syncPaymentsToOrder;
|
|
@@ -5212,11 +5505,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5212
5505
|
}, {
|
|
5213
5506
|
key: "submitOrder",
|
|
5214
5507
|
value: function () {
|
|
5215
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5508
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(order) {
|
|
5216
5509
|
var _order$query$cartItem, _params$bookings, _params$relation_prod;
|
|
5217
5510
|
var url, query, fetchUrl, params;
|
|
5218
|
-
return _regeneratorRuntime().wrap(function
|
|
5219
|
-
while (1) switch (
|
|
5511
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context40) {
|
|
5512
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
5220
5513
|
case 0:
|
|
5221
5514
|
this.logInfo('submitOrder called', {
|
|
5222
5515
|
url: order.url,
|
|
@@ -5236,14 +5529,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5236
5529
|
relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
|
|
5237
5530
|
scheduleDate: params.schedule_date
|
|
5238
5531
|
});
|
|
5239
|
-
return
|
|
5532
|
+
return _context40.abrupt("return", this.request.post(fetchUrl, params));
|
|
5240
5533
|
case 6:
|
|
5241
5534
|
case "end":
|
|
5242
|
-
return
|
|
5535
|
+
return _context40.stop();
|
|
5243
5536
|
}
|
|
5244
|
-
},
|
|
5537
|
+
}, _callee37, this);
|
|
5245
5538
|
}));
|
|
5246
|
-
function submitOrder(
|
|
5539
|
+
function submitOrder(_x48) {
|
|
5247
5540
|
return _submitOrder.apply(this, arguments);
|
|
5248
5541
|
}
|
|
5249
5542
|
return submitOrder;
|
|
@@ -5251,13 +5544,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5251
5544
|
}, {
|
|
5252
5545
|
key: "cancelOrder",
|
|
5253
5546
|
value: function () {
|
|
5254
|
-
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5547
|
+
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
|
|
5255
5548
|
var payload;
|
|
5256
|
-
return _regeneratorRuntime().wrap(function
|
|
5257
|
-
while (1) switch (
|
|
5549
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context41) {
|
|
5550
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
5258
5551
|
case 0:
|
|
5259
5552
|
if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
|
|
5260
|
-
|
|
5553
|
+
_context41.next = 2;
|
|
5261
5554
|
break;
|
|
5262
5555
|
}
|
|
5263
5556
|
throw new Error('取消订单失败:order_ids 不能为空');
|
|
@@ -5273,16 +5566,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5273
5566
|
method: 'PUT',
|
|
5274
5567
|
orderIdsCount: params.order_ids.length
|
|
5275
5568
|
});
|
|
5276
|
-
return
|
|
5569
|
+
return _context41.abrupt("return", this.request.put('/order/update-status', payload, {
|
|
5277
5570
|
isShopApi: true
|
|
5278
5571
|
}));
|
|
5279
5572
|
case 5:
|
|
5280
5573
|
case "end":
|
|
5281
|
-
return
|
|
5574
|
+
return _context41.stop();
|
|
5282
5575
|
}
|
|
5283
|
-
},
|
|
5576
|
+
}, _callee38, this);
|
|
5284
5577
|
}));
|
|
5285
|
-
function cancelOrder(
|
|
5578
|
+
function cancelOrder(_x49) {
|
|
5286
5579
|
return _cancelOrder.apply(this, arguments);
|
|
5287
5580
|
}
|
|
5288
5581
|
return cancelOrder;
|
|
@@ -5290,19 +5583,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5290
5583
|
}, {
|
|
5291
5584
|
key: "changeBookingStatus",
|
|
5292
5585
|
value: function () {
|
|
5293
|
-
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5586
|
+
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
5294
5587
|
var url, payload;
|
|
5295
|
-
return _regeneratorRuntime().wrap(function
|
|
5296
|
-
while (1) switch (
|
|
5588
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context42) {
|
|
5589
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
5297
5590
|
case 0:
|
|
5298
5591
|
if (params.booking_id) {
|
|
5299
|
-
|
|
5592
|
+
_context42.next = 2;
|
|
5300
5593
|
break;
|
|
5301
5594
|
}
|
|
5302
5595
|
throw new Error('变更预约状态失败:booking_id 不能为空');
|
|
5303
5596
|
case 2:
|
|
5304
5597
|
if (params.appointment_status) {
|
|
5305
|
-
|
|
5598
|
+
_context42.next = 4;
|
|
5306
5599
|
break;
|
|
5307
5600
|
}
|
|
5308
5601
|
throw new Error('变更预约状态失败:appointment_status 不能为空');
|
|
@@ -5317,16 +5610,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5317
5610
|
bookingId: params.booking_id,
|
|
5318
5611
|
appointmentStatus: params.appointment_status
|
|
5319
5612
|
});
|
|
5320
|
-
return
|
|
5613
|
+
return _context42.abrupt("return", this.request.put(url, payload, {
|
|
5321
5614
|
isShopApi: true
|
|
5322
5615
|
}));
|
|
5323
5616
|
case 8:
|
|
5324
5617
|
case "end":
|
|
5325
|
-
return
|
|
5618
|
+
return _context42.stop();
|
|
5326
5619
|
}
|
|
5327
|
-
},
|
|
5620
|
+
}, _callee39, this);
|
|
5328
5621
|
}));
|
|
5329
|
-
function changeBookingStatus(
|
|
5622
|
+
function changeBookingStatus(_x50) {
|
|
5330
5623
|
return _changeBookingStatus.apply(this, arguments);
|
|
5331
5624
|
}
|
|
5332
5625
|
return changeBookingStatus;
|
|
@@ -5344,11 +5637,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5344
5637
|
}, {
|
|
5345
5638
|
key: "createOrderByCheckout",
|
|
5346
5639
|
value: (function () {
|
|
5347
|
-
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5640
|
+
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
|
|
5348
5641
|
var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
|
|
5349
5642
|
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;
|
|
5350
|
-
return _regeneratorRuntime().wrap(function
|
|
5351
|
-
while (1) switch (
|
|
5643
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context43) {
|
|
5644
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
5352
5645
|
case 0:
|
|
5353
5646
|
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
5354
5647
|
onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
@@ -5382,7 +5675,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5382
5675
|
relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
|
|
5383
5676
|
paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
|
|
5384
5677
|
});
|
|
5385
|
-
|
|
5678
|
+
_context43.prev = 4;
|
|
5386
5679
|
// 构建订单数据,设置默认值并允许 params 覆盖
|
|
5387
5680
|
orderData = _objectSpread({
|
|
5388
5681
|
sales_channel: 'my_pisel',
|
|
@@ -5444,13 +5737,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5444
5737
|
hasOrderId: !!orderData.order_id,
|
|
5445
5738
|
smallTicketDataFlag: orderData.small_ticket_data_flag
|
|
5446
5739
|
});
|
|
5447
|
-
|
|
5740
|
+
_context43.next = 12;
|
|
5448
5741
|
return this.request.post('/order/checkout', orderData, {
|
|
5449
5742
|
osServer: true,
|
|
5450
5743
|
customToast: function customToast() {}
|
|
5451
5744
|
});
|
|
5452
5745
|
case 12:
|
|
5453
|
-
response =
|
|
5746
|
+
response = _context43.sent;
|
|
5454
5747
|
this.logInfo('Order API called successfully', {
|
|
5455
5748
|
response: response
|
|
5456
5749
|
});
|
|
@@ -5458,22 +5751,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5458
5751
|
success: !!response,
|
|
5459
5752
|
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)
|
|
5460
5753
|
});
|
|
5461
|
-
return
|
|
5754
|
+
return _context43.abrupt("return", response);
|
|
5462
5755
|
case 18:
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
console.error('[Order] createOrderByCheckout 创建订单失败:',
|
|
5756
|
+
_context43.prev = 18;
|
|
5757
|
+
_context43.t0 = _context43["catch"](4);
|
|
5758
|
+
console.error('[Order] createOrderByCheckout 创建订单失败:', _context43.t0);
|
|
5466
5759
|
this.logInfo('Order API called failed', {
|
|
5467
|
-
error:
|
|
5760
|
+
error: _context43.t0 instanceof Error ? _context43.t0.message : String(_context43.t0)
|
|
5468
5761
|
});
|
|
5469
|
-
throw
|
|
5762
|
+
throw _context43.t0;
|
|
5470
5763
|
case 23:
|
|
5471
5764
|
case "end":
|
|
5472
|
-
return
|
|
5765
|
+
return _context43.stop();
|
|
5473
5766
|
}
|
|
5474
|
-
},
|
|
5767
|
+
}, _callee40, this, [[4, 18]]);
|
|
5475
5768
|
}));
|
|
5476
|
-
function createOrderByCheckout(
|
|
5769
|
+
function createOrderByCheckout(_x51) {
|
|
5477
5770
|
return _createOrderByCheckout.apply(this, arguments);
|
|
5478
5771
|
}
|
|
5479
5772
|
return createOrderByCheckout;
|
|
@@ -5481,24 +5774,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5481
5774
|
}, {
|
|
5482
5775
|
key: "submitSalesOrder",
|
|
5483
5776
|
value: function () {
|
|
5484
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5777
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
|
|
5485
5778
|
var url, query, fetchUrl;
|
|
5486
|
-
return _regeneratorRuntime().wrap(function
|
|
5487
|
-
while (1) switch (
|
|
5779
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context44) {
|
|
5780
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
5488
5781
|
case 0:
|
|
5489
5782
|
url = params.url, query = params.query;
|
|
5490
5783
|
fetchUrl = url || '/order/sales/checkout';
|
|
5491
|
-
return
|
|
5784
|
+
return _context44.abrupt("return", this.request.post(fetchUrl, query, {
|
|
5492
5785
|
osServer: true,
|
|
5493
5786
|
customToast: function customToast() {}
|
|
5494
5787
|
}));
|
|
5495
5788
|
case 3:
|
|
5496
5789
|
case "end":
|
|
5497
|
-
return
|
|
5790
|
+
return _context44.stop();
|
|
5498
5791
|
}
|
|
5499
|
-
},
|
|
5792
|
+
}, _callee41, this);
|
|
5500
5793
|
}));
|
|
5501
|
-
function submitSalesOrder(
|
|
5794
|
+
function submitSalesOrder(_x52) {
|
|
5502
5795
|
return _submitSalesOrder.apply(this, arguments);
|
|
5503
5796
|
}
|
|
5504
5797
|
return submitSalesOrder;
|
|
@@ -5512,37 +5805,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5512
5805
|
}, {
|
|
5513
5806
|
key: "sendCustomerPayLink",
|
|
5514
5807
|
value: (function () {
|
|
5515
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5808
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
|
|
5516
5809
|
var _params$emails;
|
|
5517
5810
|
var orderIds;
|
|
5518
|
-
return _regeneratorRuntime().wrap(function
|
|
5519
|
-
while (1) switch (
|
|
5811
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context45) {
|
|
5812
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
5520
5813
|
case 0:
|
|
5521
5814
|
orderIds = params.order_ids || params.orderIds || [];
|
|
5522
5815
|
if (orderIds.length) {
|
|
5523
|
-
|
|
5816
|
+
_context45.next = 3;
|
|
5524
5817
|
break;
|
|
5525
5818
|
}
|
|
5526
5819
|
throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
|
|
5527
5820
|
case 3:
|
|
5528
5821
|
if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
|
|
5529
|
-
|
|
5822
|
+
_context45.next = 5;
|
|
5530
5823
|
break;
|
|
5531
5824
|
}
|
|
5532
5825
|
throw new Error('发送支付链接需要至少一个邮箱');
|
|
5533
5826
|
case 5:
|
|
5534
|
-
return
|
|
5827
|
+
return _context45.abrupt("return", this.request.post('/order/batch-email', {
|
|
5535
5828
|
order_ids: orderIds,
|
|
5536
5829
|
notify_action: params.notify_action || 'order_payment_reminder',
|
|
5537
5830
|
emails: params.emails
|
|
5538
5831
|
}));
|
|
5539
5832
|
case 6:
|
|
5540
5833
|
case "end":
|
|
5541
|
-
return
|
|
5834
|
+
return _context45.stop();
|
|
5542
5835
|
}
|
|
5543
|
-
},
|
|
5836
|
+
}, _callee42, this);
|
|
5544
5837
|
}));
|
|
5545
|
-
function sendCustomerPayLink(
|
|
5838
|
+
function sendCustomerPayLink(_x53) {
|
|
5546
5839
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
5547
5840
|
}
|
|
5548
5841
|
return sendCustomerPayLink;
|
|
@@ -5550,14 +5843,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5550
5843
|
}, {
|
|
5551
5844
|
key: "getSalesOrderByLookup",
|
|
5552
5845
|
value: function () {
|
|
5553
|
-
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5846
|
+
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
|
|
5554
5847
|
var lookup, res;
|
|
5555
|
-
return _regeneratorRuntime().wrap(function
|
|
5556
|
-
while (1) switch (
|
|
5848
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context46) {
|
|
5849
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
5557
5850
|
case 0:
|
|
5558
5851
|
lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
|
|
5559
5852
|
if (lookup) {
|
|
5560
|
-
|
|
5853
|
+
_context46.next = 3;
|
|
5561
5854
|
break;
|
|
5562
5855
|
}
|
|
5563
5856
|
throw new Error('加载销售详情需要 lookup');
|
|
@@ -5566,27 +5859,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5566
5859
|
if (lookup.startsWith('LOCAL_')) {
|
|
5567
5860
|
params.forceRemote = false;
|
|
5568
5861
|
}
|
|
5569
|
-
|
|
5862
|
+
_context46.next = 6;
|
|
5570
5863
|
return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
|
|
5571
|
-
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info']
|
|
5864
|
+
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info', 'refunds']
|
|
5572
5865
|
}, params.forceRemote ? {
|
|
5573
5866
|
forceRemote: true
|
|
5574
5867
|
} : {}), {
|
|
5575
5868
|
osServer: true
|
|
5576
5869
|
});
|
|
5577
5870
|
case 6:
|
|
5578
|
-
res =
|
|
5871
|
+
res = _context46.sent;
|
|
5579
5872
|
if (res.code === 200) {
|
|
5580
5873
|
this.store.lastOrderInfo = res.data;
|
|
5581
5874
|
}
|
|
5582
|
-
return
|
|
5875
|
+
return _context46.abrupt("return", res);
|
|
5583
5876
|
case 9:
|
|
5584
5877
|
case "end":
|
|
5585
|
-
return
|
|
5878
|
+
return _context46.stop();
|
|
5586
5879
|
}
|
|
5587
|
-
},
|
|
5880
|
+
}, _callee43, this);
|
|
5588
5881
|
}));
|
|
5589
|
-
function getSalesOrderByLookup(
|
|
5882
|
+
function getSalesOrderByLookup(_x54) {
|
|
5590
5883
|
return _getSalesOrderByLookup.apply(this, arguments);
|
|
5591
5884
|
}
|
|
5592
5885
|
return getSalesOrderByLookup;
|
|
@@ -5600,11 +5893,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5600
5893
|
}, {
|
|
5601
5894
|
key: "hydrateTempOrderFromRecord",
|
|
5602
5895
|
value: (function () {
|
|
5603
|
-
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5604
|
-
var _this$store$
|
|
5605
|
-
var sourceRaw, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, nextTempOrder, rawSummary, summarySurcharges, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$
|
|
5606
|
-
return _regeneratorRuntime().wrap(function
|
|
5607
|
-
while (1) switch (
|
|
5896
|
+
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(record, options) {
|
|
5897
|
+
var _this$store$discount20;
|
|
5898
|
+
var sourceRaw, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, nextTempOrder, sourceLastOrderInfo, isDraftOrder, syntheticIdentityOptions, rawSummary, summarySurcharges, hadSyntheticDraftOrderId, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount21, _this$store$discount22;
|
|
5899
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context47) {
|
|
5900
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
5608
5901
|
case 0:
|
|
5609
5902
|
sourceRaw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
|
|
5610
5903
|
identityReadySource = this.seedAnonymousBookingUidsFromProducts(sourceRaw);
|
|
@@ -5629,7 +5922,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5629
5922
|
}
|
|
5630
5923
|
nextTempOrder = this.normalizeTempOrderForRuntime(raw, {
|
|
5631
5924
|
makeEditMark: true
|
|
5632
|
-
});
|
|
5925
|
+
}); // Server list compatibility may synthesize order_id from external_sale_number; tempOrder must not.
|
|
5926
|
+
sourceLastOrderInfo = raw.lastOrderInfo || raw;
|
|
5927
|
+
isDraftOrder = Number(nextTempOrder.is_draft_order || 0) === 1;
|
|
5928
|
+
syntheticIdentityOptions = {
|
|
5929
|
+
isDraftOrder: isDraftOrder,
|
|
5930
|
+
externalSaleNumber: nextTempOrder.external_sale_number
|
|
5931
|
+
};
|
|
5633
5932
|
rawSummary = raw.summary && _typeof(raw.summary) === 'object' ? raw.summary : {};
|
|
5634
5933
|
summarySurcharges = Array.isArray(rawSummary.surcharges) ? rawSummary.surcharges.map(function (s) {
|
|
5635
5934
|
return _objectSpread({}, s || {});
|
|
@@ -5649,12 +5948,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5649
5948
|
productFingerprint: this.buildOrderProductsFingerprint(nextTempOrder.products || [])
|
|
5650
5949
|
}
|
|
5651
5950
|
});
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5951
|
+
this.store.lastOrderInfo = this.withoutSyntheticDraftOrderIdForRuntime(sourceLastOrderInfo, syntheticIdentityOptions);
|
|
5952
|
+
hadSyntheticDraftOrderId = this.isSyntheticDraftOrderIdForRuntime(raw, syntheticIdentityOptions) || this.isSyntheticDraftOrderIdForRuntime(sourceLastOrderInfo, syntheticIdentityOptions);
|
|
5953
|
+
if (hadSyntheticDraftOrderId && this.store.syncState !== 'submitting') {
|
|
5954
|
+
this.store.syncState = 'local';
|
|
5955
|
+
}
|
|
5656
5956
|
hydratedEditDiscounts = this.collectHydratedEditDiscounts(nextTempOrder.products);
|
|
5657
|
-
currentDiscounts = typeof ((_this$store$
|
|
5957
|
+
currentDiscounts = typeof ((_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 ? void 0 : _this$store$discount20.getDiscountList) === 'function' ? this.store.discount.getDiscountList() || [] : [];
|
|
5658
5958
|
currentScanDiscounts = currentDiscounts.filter(function (discount) {
|
|
5659
5959
|
return discount === null || discount === void 0 ? void 0 : discount.isScan;
|
|
5660
5960
|
});
|
|
@@ -5667,34 +5967,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5667
5967
|
nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
|
|
5668
5968
|
shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
|
|
5669
5969
|
if (shouldSkipEmptyDiscountSync) {
|
|
5670
|
-
|
|
5970
|
+
_context47.next = 31;
|
|
5671
5971
|
break;
|
|
5672
5972
|
}
|
|
5673
5973
|
OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
|
|
5674
|
-
|
|
5675
|
-
return (_this$store$
|
|
5676
|
-
case
|
|
5677
|
-
|
|
5678
|
-
return (_this$store$
|
|
5679
|
-
case
|
|
5974
|
+
_context47.next = 29;
|
|
5975
|
+
return (_this$store$discount21 = this.store.discount) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.setOriginalDiscountList(nextDiscounts);
|
|
5976
|
+
case 29:
|
|
5977
|
+
_context47.next = 31;
|
|
5978
|
+
return (_this$store$discount22 = this.store.discount) === null || _this$store$discount22 === void 0 ? void 0 : _this$store$discount22.setDiscountList(nextDiscounts);
|
|
5979
|
+
case 31:
|
|
5680
5980
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
5681
|
-
|
|
5981
|
+
_context47.next = 34;
|
|
5682
5982
|
break;
|
|
5683
5983
|
}
|
|
5684
|
-
|
|
5984
|
+
_context47.next = 34;
|
|
5685
5985
|
return this.recalculateSummary({
|
|
5686
5986
|
createIfMissing: false
|
|
5687
5987
|
});
|
|
5688
|
-
case
|
|
5988
|
+
case 34:
|
|
5689
5989
|
this.persistTempOrder();
|
|
5690
|
-
return
|
|
5691
|
-
case
|
|
5990
|
+
return _context47.abrupt("return", nextTempOrder);
|
|
5991
|
+
case 36:
|
|
5692
5992
|
case "end":
|
|
5693
|
-
return
|
|
5993
|
+
return _context47.stop();
|
|
5694
5994
|
}
|
|
5695
|
-
},
|
|
5995
|
+
}, _callee44, this);
|
|
5696
5996
|
}));
|
|
5697
|
-
function hydrateTempOrderFromRecord(
|
|
5997
|
+
function hydrateTempOrderFromRecord(_x55, _x56) {
|
|
5698
5998
|
return _hydrateTempOrderFromRecord.apply(this, arguments);
|
|
5699
5999
|
}
|
|
5700
6000
|
return hydrateTempOrderFromRecord;
|
|
@@ -5808,11 +6108,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5808
6108
|
}, {
|
|
5809
6109
|
key: "normalizeTempOrderForRuntime",
|
|
5810
6110
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
5811
|
-
var
|
|
5812
|
-
var
|
|
6111
|
+
var _this32 = this;
|
|
6112
|
+
var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
|
|
6113
|
+
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
|
|
5813
6114
|
// ES 列表详情使用 id 表示订单主键;OS 详情态统一依赖 order_id 驱动操作按钮。
|
|
5814
|
-
if ((nextTempOrder.order_id === undefined || nextTempOrder.order_id === null) && (
|
|
5815
|
-
nextTempOrder.order_id =
|
|
6115
|
+
if ((nextTempOrder.order_id === undefined || nextTempOrder.order_id === null) && (runtimeRaw === null || runtimeRaw === void 0 ? void 0 : runtimeRaw.id) !== undefined && (runtimeRaw === null || runtimeRaw === void 0 ? void 0 : runtimeRaw.id) !== null) {
|
|
6116
|
+
nextTempOrder.order_id = runtimeRaw.id;
|
|
5816
6117
|
}
|
|
5817
6118
|
delete nextTempOrder.summary;
|
|
5818
6119
|
delete nextTempOrder.lastOrderInfo;
|
|
@@ -5831,12 +6132,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5831
6132
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
5832
6133
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
5833
6134
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
5834
|
-
return
|
|
6135
|
+
return _this32.normalizeHydratedOrderProduct(p, {
|
|
5835
6136
|
makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
|
|
5836
6137
|
});
|
|
5837
6138
|
}) : [];
|
|
5838
6139
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
5839
|
-
var booking =
|
|
6140
|
+
var booking = _this32.normalizeHydratedBookingHolder(b || {});
|
|
5840
6141
|
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
5841
6142
|
is_all: normalizeBookingIsAll(booking),
|
|
5842
6143
|
sub_type: normalizeBookingSubType(booking)
|
|
@@ -5902,6 +6203,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5902
6203
|
nextTempOrder.vouchers = raw.vouchers || [];
|
|
5903
6204
|
return nextTempOrder;
|
|
5904
6205
|
}
|
|
6206
|
+
}, {
|
|
6207
|
+
key: "isSyntheticDraftOrderIdForRuntime",
|
|
6208
|
+
value: function isSyntheticDraftOrderIdForRuntime(record, options) {
|
|
6209
|
+
var _options$isDraftOrder, _record$external_sale;
|
|
6210
|
+
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;
|
|
6211
|
+
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;
|
|
6212
|
+
var orderId = record === null || record === void 0 ? void 0 : record.order_id;
|
|
6213
|
+
return Boolean(isDraftOrder && orderId !== undefined && orderId !== null && orderId !== '' && externalSaleNumber !== undefined && externalSaleNumber !== null && externalSaleNumber !== '' && String(orderId) === String(externalSaleNumber));
|
|
6214
|
+
}
|
|
6215
|
+
}, {
|
|
6216
|
+
key: "withoutSyntheticDraftOrderIdForRuntime",
|
|
6217
|
+
value: function withoutSyntheticDraftOrderIdForRuntime(record, options) {
|
|
6218
|
+
if (!this.isSyntheticDraftOrderIdForRuntime(record, options)) return record;
|
|
6219
|
+
return _objectSpread(_objectSpread({}, record), {}, {
|
|
6220
|
+
order_id: null
|
|
6221
|
+
});
|
|
6222
|
+
}
|
|
5905
6223
|
}, {
|
|
5906
6224
|
key: "hydrateLinkedBookingIdentity",
|
|
5907
6225
|
value: function hydrateLinkedBookingIdentity(tempOrder) {
|
|
@@ -6006,7 +6324,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6006
6324
|
}, {
|
|
6007
6325
|
key: "normalizeHydratedOrderProduct",
|
|
6008
6326
|
value: function normalizeHydratedOrderProduct(product, options) {
|
|
6009
|
-
var
|
|
6327
|
+
var _this33 = this;
|
|
6010
6328
|
var row = _objectSpread({}, product || {});
|
|
6011
6329
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
6012
6330
|
row.num = row.product_quantity;
|
|
@@ -6014,7 +6332,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6014
6332
|
var productSku = ensureProductSku(row);
|
|
6015
6333
|
row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
|
|
6016
6334
|
option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
|
|
6017
|
-
return
|
|
6335
|
+
return _this33.normalizeHydratedProductOptionItem(optionItem || {});
|
|
6018
6336
|
}))
|
|
6019
6337
|
});
|
|
6020
6338
|
delete row["product_".concat('option', "_item")];
|
|
@@ -6051,27 +6369,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6051
6369
|
}, {
|
|
6052
6370
|
key: "getOrderInfo",
|
|
6053
6371
|
value: function () {
|
|
6054
|
-
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6372
|
+
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(order_id) {
|
|
6055
6373
|
var res;
|
|
6056
|
-
return _regeneratorRuntime().wrap(function
|
|
6057
|
-
while (1) switch (
|
|
6374
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context48) {
|
|
6375
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
6058
6376
|
case 0:
|
|
6059
|
-
|
|
6377
|
+
_context48.next = 2;
|
|
6060
6378
|
return this.request.get("/order/sales/".concat(order_id), {
|
|
6061
6379
|
with: ['products', 'bookings']
|
|
6062
6380
|
}, {
|
|
6063
6381
|
osServer: true
|
|
6064
6382
|
});
|
|
6065
6383
|
case 2:
|
|
6066
|
-
res =
|
|
6067
|
-
return
|
|
6384
|
+
res = _context48.sent;
|
|
6385
|
+
return _context48.abrupt("return", res);
|
|
6068
6386
|
case 4:
|
|
6069
6387
|
case "end":
|
|
6070
|
-
return
|
|
6388
|
+
return _context48.stop();
|
|
6071
6389
|
}
|
|
6072
|
-
},
|
|
6390
|
+
}, _callee45, this);
|
|
6073
6391
|
}));
|
|
6074
|
-
function getOrderInfo(
|
|
6392
|
+
function getOrderInfo(_x57) {
|
|
6075
6393
|
return _getOrderInfo.apply(this, arguments);
|
|
6076
6394
|
}
|
|
6077
6395
|
return getOrderInfo;
|