@pisell/pisellos 2.2.268 → 2.2.269
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 +9 -0
- package/dist/model/strategy/adapter/promotion/type.d.ts +90 -2
- package/dist/model/strategy/adapter/promotion/type.js +45 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +12 -10
- 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 +813 -498
- 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 +146 -106
- package/dist/modules/SalesSummary/utils.js +7 -1
- package/dist/server/index.d.ts +16 -0
- package/dist/server/index.js +1940 -1043
- 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 +115 -6
- package/dist/solution/BaseSales/index.js +1847 -478
- 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 +90 -31
- 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 +9 -17
- 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/type.d.ts +90 -2
- package/lib/model/strategy/adapter/promotion/type.js +2 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +3 -1
- 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 +236 -71
- 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 +54 -21
- package/lib/modules/SalesSummary/utils.js +5 -1
- package/lib/server/index.d.ts +16 -0
- package/lib/server/index.js +670 -18
- 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 +115 -6
- package/lib/solution/BaseSales/index.js +896 -32
- 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 +63 -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 +9 -17
- 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,15 @@ 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
|
-
|
|
3884
|
+
_this26 = this;
|
|
3685
3885
|
var linked, productToAdd, incomingFingerprint, normalizedIncoming, isWeighingProduct, netWeight, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingBookingUid, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, insertAtIndex, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, targetIsManualProductDiscount, nextDiscountList, mergedProduct;
|
|
3686
|
-
return _regeneratorRuntime().wrap(function
|
|
3687
|
-
while (1) switch (
|
|
3886
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context22) {
|
|
3887
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
3688
3888
|
case 0:
|
|
3689
3889
|
linked = booking ? this.createLinkedProductAndBooking({
|
|
3690
3890
|
product: product,
|
|
@@ -3696,7 +3896,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3696
3896
|
isWeighingProduct = Number(((_normalizedIncoming$p = normalizedIncoming.product_sku) === null || _normalizedIncoming$p === void 0 ? void 0 : _normalizedIncoming$p.open_sold_weight) || 0) === 1;
|
|
3697
3897
|
netWeight = Number((_normalizedIncoming$p2 = normalizedIncoming.product_sku) === null || _normalizedIncoming$p2 === void 0 ? void 0 : _normalizedIncoming$p2.net_weight);
|
|
3698
3898
|
if (!(isWeighingProduct && (!Number.isFinite(netWeight) || netWeight <= 0))) {
|
|
3699
|
-
|
|
3899
|
+
_context22.next = 8;
|
|
3700
3900
|
break;
|
|
3701
3901
|
}
|
|
3702
3902
|
throw new Error('[Order] 称重商品净重必须大于 0');
|
|
@@ -3715,8 +3915,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3715
3915
|
shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid || isWeighingProduct;
|
|
3716
3916
|
matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
3717
3917
|
var _item$metadata3;
|
|
3718
|
-
if (
|
|
3719
|
-
if (
|
|
3918
|
+
if (_this26.hasGoodPassDiscount(item)) return false;
|
|
3919
|
+
if (_this26.hasOrderProductLineNote(item)) return false;
|
|
3720
3920
|
if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
|
|
3721
3921
|
if ((_item$metadata3 = item.metadata) !== null && _item$metadata3 !== void 0 && _item$metadata3.is_edit_for_runtime) return false;
|
|
3722
3922
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
@@ -3727,10 +3927,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3727
3927
|
matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
|
|
3728
3928
|
existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
|
|
3729
3929
|
if (!matchedProduct) {
|
|
3730
|
-
|
|
3930
|
+
_context22.next = 24;
|
|
3731
3931
|
break;
|
|
3732
3932
|
}
|
|
3733
|
-
|
|
3933
|
+
_context22.next = 21;
|
|
3734
3934
|
return this.shouldMergeProductToOrder({
|
|
3735
3935
|
incomingProduct: productToAdd,
|
|
3736
3936
|
normalizedIncoming: normalizedIncoming,
|
|
@@ -3742,13 +3942,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3742
3942
|
booking: booking
|
|
3743
3943
|
});
|
|
3744
3944
|
case 21:
|
|
3745
|
-
|
|
3746
|
-
|
|
3945
|
+
_context22.t0 = _context22.sent;
|
|
3946
|
+
_context22.next = 25;
|
|
3747
3947
|
break;
|
|
3748
3948
|
case 24:
|
|
3749
|
-
|
|
3949
|
+
_context22.t0 = false;
|
|
3750
3950
|
case 25:
|
|
3751
|
-
shouldMerge =
|
|
3951
|
+
shouldMerge = _context22.t0;
|
|
3752
3952
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
3753
3953
|
this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
3754
3954
|
if (linked) {
|
|
@@ -3810,11 +4010,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3810
4010
|
}
|
|
3811
4011
|
case 28:
|
|
3812
4012
|
case "end":
|
|
3813
|
-
return
|
|
4013
|
+
return _context22.stop();
|
|
3814
4014
|
}
|
|
3815
|
-
},
|
|
4015
|
+
}, _callee20, this);
|
|
3816
4016
|
}));
|
|
3817
|
-
function appendProductLineToTempOrder(
|
|
4017
|
+
function appendProductLineToTempOrder(_x22, _x23, _x24, _x25) {
|
|
3818
4018
|
return _appendProductLineToTempOrder.apply(this, arguments);
|
|
3819
4019
|
}
|
|
3820
4020
|
return appendProductLineToTempOrder;
|
|
@@ -3830,10 +4030,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3830
4030
|
}, {
|
|
3831
4031
|
key: "addProductToOrder",
|
|
3832
4032
|
value: (function () {
|
|
3833
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4033
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(product, booking, options) {
|
|
3834
4034
|
var tempOrder, insertAfterProductUid, anchorIndex, insertAtIndex, _ref61, _productRecord$num, productRecord, splitCount, i, singleLine;
|
|
3835
|
-
return _regeneratorRuntime().wrap(function
|
|
3836
|
-
while (1) switch (
|
|
4035
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context23) {
|
|
4036
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
3837
4037
|
case 0:
|
|
3838
4038
|
tempOrder = this.ensureTempOrder();
|
|
3839
4039
|
insertAfterProductUid = options === null || options === void 0 ? void 0 : options.insertAfterProductUid;
|
|
@@ -3844,25 +4044,25 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3844
4044
|
}) : -1;
|
|
3845
4045
|
insertAtIndex = anchorIndex >= 0 ? anchorIndex + 1 : undefined;
|
|
3846
4046
|
if (!booking) {
|
|
3847
|
-
|
|
4047
|
+
_context23.next = 22;
|
|
3848
4048
|
break;
|
|
3849
4049
|
}
|
|
3850
4050
|
productRecord = product;
|
|
3851
4051
|
splitCount = getSafeProductNum((_ref61 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref61 !== void 0 ? _ref61 : 1);
|
|
3852
4052
|
if (!(splitCount > 1)) {
|
|
3853
|
-
|
|
4053
|
+
_context23.next = 22;
|
|
3854
4054
|
break;
|
|
3855
4055
|
}
|
|
3856
4056
|
i = 0;
|
|
3857
4057
|
case 9:
|
|
3858
4058
|
if (!(i < splitCount)) {
|
|
3859
|
-
|
|
4059
|
+
_context23.next = 19;
|
|
3860
4060
|
break;
|
|
3861
4061
|
}
|
|
3862
4062
|
singleLine = cloneDeep(productRecord);
|
|
3863
4063
|
singleLine.num = 1;
|
|
3864
4064
|
delete singleLine.product_quantity;
|
|
3865
|
-
|
|
4065
|
+
_context23.next = 15;
|
|
3866
4066
|
return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking), {
|
|
3867
4067
|
insertAtIndex: insertAtIndex
|
|
3868
4068
|
});
|
|
@@ -3870,34 +4070,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3870
4070
|
if (insertAtIndex !== undefined) insertAtIndex += 1;
|
|
3871
4071
|
case 16:
|
|
3872
4072
|
i += 1;
|
|
3873
|
-
|
|
4073
|
+
_context23.next = 9;
|
|
3874
4074
|
break;
|
|
3875
4075
|
case 19:
|
|
3876
|
-
|
|
4076
|
+
_context23.next = 21;
|
|
3877
4077
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
3878
4078
|
case 21:
|
|
3879
|
-
return
|
|
4079
|
+
return _context23.abrupt("return", tempOrder.products);
|
|
3880
4080
|
case 22:
|
|
3881
|
-
|
|
4081
|
+
_context23.next = 24;
|
|
3882
4082
|
return this.appendProductLineToTempOrder(tempOrder, product, booking, {
|
|
3883
4083
|
insertAtIndex: insertAtIndex
|
|
3884
4084
|
});
|
|
3885
4085
|
case 24:
|
|
3886
|
-
|
|
4086
|
+
_context23.next = 26;
|
|
3887
4087
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
3888
4088
|
case 26:
|
|
3889
4089
|
this.logInfo('addProductToOrder success', {
|
|
3890
4090
|
product_id: product.product_id,
|
|
3891
4091
|
with_booking: !!booking
|
|
3892
4092
|
});
|
|
3893
|
-
return
|
|
4093
|
+
return _context23.abrupt("return", tempOrder.products);
|
|
3894
4094
|
case 28:
|
|
3895
4095
|
case "end":
|
|
3896
|
-
return
|
|
4096
|
+
return _context23.stop();
|
|
3897
4097
|
}
|
|
3898
|
-
},
|
|
4098
|
+
}, _callee21, this);
|
|
3899
4099
|
}));
|
|
3900
|
-
function addProductToOrder(
|
|
4100
|
+
function addProductToOrder(_x26, _x27, _x28) {
|
|
3901
4101
|
return _addProductToOrder.apply(this, arguments);
|
|
3902
4102
|
}
|
|
3903
4103
|
return addProductToOrder;
|
|
@@ -3915,93 +4115,93 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3915
4115
|
}, {
|
|
3916
4116
|
key: "addProductsToOrder",
|
|
3917
4117
|
value: (function () {
|
|
3918
|
-
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4118
|
+
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(items, options) {
|
|
3919
4119
|
var tempOrder, _iterator20, _step20, item, product, booking, _ref62, _productRecord$num2, productRecord, splitCount, i, singleLine;
|
|
3920
|
-
return _regeneratorRuntime().wrap(function
|
|
3921
|
-
while (1) switch (
|
|
4120
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context24) {
|
|
4121
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
3922
4122
|
case 0:
|
|
3923
4123
|
tempOrder = this.ensureTempOrder();
|
|
3924
4124
|
if (!(!Array.isArray(items) || items.length === 0)) {
|
|
3925
|
-
|
|
4125
|
+
_context24.next = 3;
|
|
3926
4126
|
break;
|
|
3927
4127
|
}
|
|
3928
|
-
return
|
|
4128
|
+
return _context24.abrupt("return", tempOrder.products);
|
|
3929
4129
|
case 3:
|
|
3930
4130
|
_iterator20 = _createForOfIteratorHelper(items || []);
|
|
3931
|
-
|
|
4131
|
+
_context24.prev = 4;
|
|
3932
4132
|
_iterator20.s();
|
|
3933
4133
|
case 6:
|
|
3934
4134
|
if ((_step20 = _iterator20.n()).done) {
|
|
3935
|
-
|
|
4135
|
+
_context24.next = 30;
|
|
3936
4136
|
break;
|
|
3937
4137
|
}
|
|
3938
4138
|
item = _step20.value;
|
|
3939
4139
|
product = item.product, booking = item.booking;
|
|
3940
4140
|
if (product) {
|
|
3941
|
-
|
|
4141
|
+
_context24.next = 11;
|
|
3942
4142
|
break;
|
|
3943
4143
|
}
|
|
3944
|
-
return
|
|
4144
|
+
return _context24.abrupt("continue", 28);
|
|
3945
4145
|
case 11:
|
|
3946
4146
|
if (!booking) {
|
|
3947
|
-
|
|
4147
|
+
_context24.next = 26;
|
|
3948
4148
|
break;
|
|
3949
4149
|
}
|
|
3950
4150
|
productRecord = product;
|
|
3951
4151
|
splitCount = getSafeProductNum((_ref62 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref62 !== void 0 ? _ref62 : 1);
|
|
3952
4152
|
if (!(splitCount > 1)) {
|
|
3953
|
-
|
|
4153
|
+
_context24.next = 26;
|
|
3954
4154
|
break;
|
|
3955
4155
|
}
|
|
3956
4156
|
i = 0;
|
|
3957
4157
|
case 16:
|
|
3958
4158
|
if (!(i < splitCount)) {
|
|
3959
|
-
|
|
4159
|
+
_context24.next = 25;
|
|
3960
4160
|
break;
|
|
3961
4161
|
}
|
|
3962
4162
|
singleLine = cloneDeep(productRecord);
|
|
3963
4163
|
singleLine.num = 1;
|
|
3964
4164
|
delete singleLine.product_quantity;
|
|
3965
|
-
|
|
4165
|
+
_context24.next = 22;
|
|
3966
4166
|
return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
|
|
3967
4167
|
case 22:
|
|
3968
4168
|
i += 1;
|
|
3969
|
-
|
|
4169
|
+
_context24.next = 16;
|
|
3970
4170
|
break;
|
|
3971
4171
|
case 25:
|
|
3972
|
-
return
|
|
4172
|
+
return _context24.abrupt("continue", 28);
|
|
3973
4173
|
case 26:
|
|
3974
|
-
|
|
4174
|
+
_context24.next = 28;
|
|
3975
4175
|
return this.appendProductLineToTempOrder(tempOrder, product, booking);
|
|
3976
4176
|
case 28:
|
|
3977
|
-
|
|
4177
|
+
_context24.next = 6;
|
|
3978
4178
|
break;
|
|
3979
4179
|
case 30:
|
|
3980
|
-
|
|
4180
|
+
_context24.next = 35;
|
|
3981
4181
|
break;
|
|
3982
4182
|
case 32:
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
_iterator20.e(
|
|
4183
|
+
_context24.prev = 32;
|
|
4184
|
+
_context24.t0 = _context24["catch"](4);
|
|
4185
|
+
_iterator20.e(_context24.t0);
|
|
3986
4186
|
case 35:
|
|
3987
|
-
|
|
4187
|
+
_context24.prev = 35;
|
|
3988
4188
|
_iterator20.f();
|
|
3989
|
-
return
|
|
4189
|
+
return _context24.finish(35);
|
|
3990
4190
|
case 38:
|
|
3991
|
-
|
|
4191
|
+
_context24.next = 40;
|
|
3992
4192
|
return this.finalizeProductOrderMutation(tempOrder, options);
|
|
3993
4193
|
case 40:
|
|
3994
4194
|
this.logInfo('addProductsToOrder success', {
|
|
3995
4195
|
itemsCount: items.length
|
|
3996
4196
|
});
|
|
3997
|
-
return
|
|
4197
|
+
return _context24.abrupt("return", tempOrder.products);
|
|
3998
4198
|
case 42:
|
|
3999
4199
|
case "end":
|
|
4000
|
-
return
|
|
4200
|
+
return _context24.stop();
|
|
4001
4201
|
}
|
|
4002
|
-
},
|
|
4202
|
+
}, _callee22, this, [[4, 32, 35, 38]]);
|
|
4003
4203
|
}));
|
|
4004
|
-
function addProductsToOrder(
|
|
4204
|
+
function addProductsToOrder(_x29, _x30) {
|
|
4005
4205
|
return _addProductsToOrder.apply(this, arguments);
|
|
4006
4206
|
}
|
|
4007
4207
|
return addProductsToOrder;
|
|
@@ -4035,17 +4235,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4035
4235
|
}, {
|
|
4036
4236
|
key: "preservePersistedBundlePriceFields",
|
|
4037
4237
|
value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
|
|
4038
|
-
var
|
|
4238
|
+
var _this27 = this;
|
|
4039
4239
|
if (!Array.isArray(nextBundles)) return nextBundles;
|
|
4040
4240
|
if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
|
|
4041
4241
|
var previousByIdentity = new Map();
|
|
4042
4242
|
previousBundles.forEach(function (bundle) {
|
|
4043
|
-
var identity =
|
|
4243
|
+
var identity = _this27.getBundleRuntimeIdentity(bundle);
|
|
4044
4244
|
if (identity) previousByIdentity.set(identity, bundle);
|
|
4045
4245
|
});
|
|
4046
4246
|
return nextBundles.map(function (bundle, index) {
|
|
4047
4247
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
4048
|
-
var previous = previousByIdentity.get(
|
|
4248
|
+
var previous = previousByIdentity.get(_this27.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
4049
4249
|
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
4050
4250
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
|
|
4051
4251
|
cover: previous.cover
|
|
@@ -4246,21 +4446,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4246
4446
|
}, {
|
|
4247
4447
|
key: "updateOrderProduct",
|
|
4248
4448
|
value: function () {
|
|
4249
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4449
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
|
|
4250
4450
|
var tempOrder, updatedProductUid;
|
|
4251
|
-
return _regeneratorRuntime().wrap(function
|
|
4252
|
-
while (1) switch (
|
|
4451
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context25) {
|
|
4452
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
4253
4453
|
case 0:
|
|
4254
4454
|
tempOrder = this.ensureTempOrder();
|
|
4255
4455
|
updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
4256
|
-
|
|
4456
|
+
_context25.next = 4;
|
|
4257
4457
|
return this.applyPromotion();
|
|
4258
4458
|
case 4:
|
|
4259
4459
|
this.applyDiscount({
|
|
4260
4460
|
reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
|
|
4261
4461
|
});
|
|
4262
4462
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4263
|
-
|
|
4463
|
+
_context25.next = 8;
|
|
4264
4464
|
return this.recalculateSummary({
|
|
4265
4465
|
createIfMissing: true
|
|
4266
4466
|
});
|
|
@@ -4269,14 +4469,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4269
4469
|
this.logInfo('updateOrderProduct success', {
|
|
4270
4470
|
params: params
|
|
4271
4471
|
});
|
|
4272
|
-
return
|
|
4472
|
+
return _context25.abrupt("return", tempOrder.products);
|
|
4273
4473
|
case 11:
|
|
4274
4474
|
case "end":
|
|
4275
|
-
return
|
|
4475
|
+
return _context25.stop();
|
|
4276
4476
|
}
|
|
4277
|
-
},
|
|
4477
|
+
}, _callee23, this);
|
|
4278
4478
|
}));
|
|
4279
|
-
function updateOrderProduct(
|
|
4479
|
+
function updateOrderProduct(_x31) {
|
|
4280
4480
|
return _updateOrderProduct.apply(this, arguments);
|
|
4281
4481
|
}
|
|
4282
4482
|
return updateOrderProduct;
|
|
@@ -4284,28 +4484,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4284
4484
|
}, {
|
|
4285
4485
|
key: "updateOrderProducts",
|
|
4286
4486
|
value: function () {
|
|
4287
|
-
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4288
|
-
var
|
|
4487
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(paramsList) {
|
|
4488
|
+
var _this28 = this;
|
|
4289
4489
|
var tempOrder, reapplyBookingDiscountProductUids;
|
|
4290
|
-
return _regeneratorRuntime().wrap(function
|
|
4291
|
-
while (1) switch (
|
|
4490
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context26) {
|
|
4491
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
4292
4492
|
case 0:
|
|
4293
4493
|
tempOrder = this.ensureTempOrder();
|
|
4294
4494
|
if (paramsList.length) {
|
|
4295
|
-
|
|
4495
|
+
_context26.next = 3;
|
|
4296
4496
|
break;
|
|
4297
4497
|
}
|
|
4298
|
-
return
|
|
4498
|
+
return _context26.abrupt("return", tempOrder.products);
|
|
4299
4499
|
case 3:
|
|
4300
4500
|
reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
|
|
4301
|
-
var updatedProductUid =
|
|
4501
|
+
var updatedProductUid = _this28.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
4302
4502
|
// 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
|
|
4303
4503
|
if (params.allow_booking_discount_reapply && updatedProductUid) {
|
|
4304
4504
|
acc.push(String(updatedProductUid));
|
|
4305
4505
|
}
|
|
4306
4506
|
return acc;
|
|
4307
4507
|
}, []);
|
|
4308
|
-
|
|
4508
|
+
_context26.next = 6;
|
|
4309
4509
|
return this.finalizeAfterProductsMutation(tempOrder, {
|
|
4310
4510
|
reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
|
|
4311
4511
|
});
|
|
@@ -4313,14 +4513,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4313
4513
|
this.logInfo('updateOrderProduct success', {
|
|
4314
4514
|
paramsList: paramsList
|
|
4315
4515
|
});
|
|
4316
|
-
return
|
|
4516
|
+
return _context26.abrupt("return", tempOrder.products);
|
|
4317
4517
|
case 8:
|
|
4318
4518
|
case "end":
|
|
4319
|
-
return
|
|
4519
|
+
return _context26.stop();
|
|
4320
4520
|
}
|
|
4321
|
-
},
|
|
4521
|
+
}, _callee24, this);
|
|
4322
4522
|
}));
|
|
4323
|
-
function updateOrderProducts(
|
|
4523
|
+
function updateOrderProducts(_x32) {
|
|
4324
4524
|
return _updateOrderProducts.apply(this, arguments);
|
|
4325
4525
|
}
|
|
4326
4526
|
return updateOrderProducts;
|
|
@@ -4328,11 +4528,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4328
4528
|
}, {
|
|
4329
4529
|
key: "updateOrderProductQuantity",
|
|
4330
4530
|
value: function () {
|
|
4331
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4531
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
|
|
4332
4532
|
var _targetProduct$metada17;
|
|
4333
4533
|
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 (
|
|
4534
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context27) {
|
|
4535
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
4336
4536
|
case 0:
|
|
4337
4537
|
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
4538
|
tempOrder = this.ensureTempOrder();
|
|
@@ -4361,7 +4561,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4361
4561
|
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
4362
4562
|
}
|
|
4363
4563
|
if (!(productIndex === -1)) {
|
|
4364
|
-
|
|
4564
|
+
_context27.next = 12;
|
|
4365
4565
|
break;
|
|
4366
4566
|
}
|
|
4367
4567
|
throw new Error('[Order] 目标商品不存在,无法更新数量');
|
|
@@ -4375,12 +4575,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4375
4575
|
}));
|
|
4376
4576
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
4377
4577
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
4378
|
-
|
|
4578
|
+
_context27.next = 18;
|
|
4379
4579
|
return this.applyPromotion();
|
|
4380
4580
|
case 18:
|
|
4381
4581
|
this.applyDiscount();
|
|
4382
4582
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4383
|
-
|
|
4583
|
+
_context27.next = 22;
|
|
4384
4584
|
return this.recalculateSummary({
|
|
4385
4585
|
createIfMissing: true
|
|
4386
4586
|
});
|
|
@@ -4389,14 +4589,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4389
4589
|
this.logInfo('updateOrderProductQuantity success', {
|
|
4390
4590
|
params: params
|
|
4391
4591
|
});
|
|
4392
|
-
return
|
|
4592
|
+
return _context27.abrupt("return", tempOrder.products);
|
|
4393
4593
|
case 25:
|
|
4394
4594
|
case "end":
|
|
4395
|
-
return
|
|
4595
|
+
return _context27.stop();
|
|
4396
4596
|
}
|
|
4397
|
-
},
|
|
4597
|
+
}, _callee25, this);
|
|
4398
4598
|
}));
|
|
4399
|
-
function updateOrderProductQuantity(
|
|
4599
|
+
function updateOrderProductQuantity(_x33) {
|
|
4400
4600
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
4401
4601
|
}
|
|
4402
4602
|
return updateOrderProductQuantity;
|
|
@@ -4437,19 +4637,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4437
4637
|
}, {
|
|
4438
4638
|
key: "finalizeAfterProductsMutation",
|
|
4439
4639
|
value: (function () {
|
|
4440
|
-
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4441
|
-
return _regeneratorRuntime().wrap(function
|
|
4442
|
-
while (1) switch (
|
|
4640
|
+
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(tempOrder, options) {
|
|
4641
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context28) {
|
|
4642
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
4443
4643
|
case 0:
|
|
4444
4644
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
4445
|
-
|
|
4645
|
+
_context28.next = 3;
|
|
4446
4646
|
return this.applyPromotion();
|
|
4447
4647
|
case 3:
|
|
4448
4648
|
this.applyDiscount({
|
|
4449
4649
|
reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
|
|
4450
4650
|
});
|
|
4451
4651
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4452
|
-
|
|
4652
|
+
_context28.next = 7;
|
|
4453
4653
|
return this.recalculateSummary({
|
|
4454
4654
|
createIfMissing: true
|
|
4455
4655
|
});
|
|
@@ -4457,11 +4657,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4457
4657
|
this.persistTempOrder();
|
|
4458
4658
|
case 8:
|
|
4459
4659
|
case "end":
|
|
4460
|
-
return
|
|
4660
|
+
return _context28.stop();
|
|
4461
4661
|
}
|
|
4462
|
-
},
|
|
4662
|
+
}, _callee26, this);
|
|
4463
4663
|
}));
|
|
4464
|
-
function finalizeAfterProductsMutation(
|
|
4664
|
+
function finalizeAfterProductsMutation(_x34, _x35) {
|
|
4465
4665
|
return _finalizeAfterProductsMutation.apply(this, arguments);
|
|
4466
4666
|
}
|
|
4467
4667
|
return finalizeAfterProductsMutation;
|
|
@@ -4476,18 +4676,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4476
4676
|
}, {
|
|
4477
4677
|
key: "removeProductsFromOrder",
|
|
4478
4678
|
value: (function () {
|
|
4479
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4480
|
-
var
|
|
4679
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(identities, options) {
|
|
4680
|
+
var _this29 = this;
|
|
4481
4681
|
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 (
|
|
4682
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context30) {
|
|
4683
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
4484
4684
|
case 0:
|
|
4485
4685
|
tempOrder = this.ensureTempOrder();
|
|
4486
4686
|
if (identities.length) {
|
|
4487
|
-
|
|
4687
|
+
_context30.next = 3;
|
|
4488
4688
|
break;
|
|
4489
4689
|
}
|
|
4490
|
-
return
|
|
4690
|
+
return _context30.abrupt("return", tempOrder.products);
|
|
4491
4691
|
case 3:
|
|
4492
4692
|
productsBeforeRemove = tempOrder.products || [];
|
|
4493
4693
|
bookingsBeforeRemove = tempOrder.bookings || [];
|
|
@@ -4517,29 +4717,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4517
4717
|
}
|
|
4518
4718
|
linkedBookingUidsToRemove = new Set();
|
|
4519
4719
|
_iterator21 = _createForOfIteratorHelper(matchedProducts);
|
|
4520
|
-
|
|
4720
|
+
_context30.prev = 14;
|
|
4521
4721
|
_loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
|
|
4522
4722
|
var _metadata11, _metadata12, _metadata13, _metadata14;
|
|
4523
4723
|
var product, productUid, productBookingUid, isAddTimeProduct;
|
|
4524
|
-
return _regeneratorRuntime().wrap(function _loop3$(
|
|
4525
|
-
while (1) switch (
|
|
4724
|
+
return _regeneratorRuntime().wrap(function _loop3$(_context29) {
|
|
4725
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
4526
4726
|
case 0:
|
|
4527
4727
|
product = _step21.value;
|
|
4528
4728
|
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
4729
|
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
4730
|
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
4731
|
if (!isAddTimeProduct) {
|
|
4532
|
-
|
|
4732
|
+
_context29.next = 6;
|
|
4533
4733
|
break;
|
|
4534
4734
|
}
|
|
4535
|
-
return
|
|
4735
|
+
return _context29.abrupt("return", 1);
|
|
4536
4736
|
case 6:
|
|
4537
4737
|
if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
|
|
4538
4738
|
linkedBookingUidsToRemove.add(String(productBookingUid));
|
|
4539
4739
|
}
|
|
4540
4740
|
if (productUid !== undefined && productUid !== null && productUid !== '') {
|
|
4541
4741
|
bookingsBeforeRemove.forEach(function (booking) {
|
|
4542
|
-
var bookingUid =
|
|
4742
|
+
var bookingUid = _this29.getBookingUniqueIdentificationNumber(booking);
|
|
4543
4743
|
if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
|
|
4544
4744
|
linkedBookingUidsToRemove.add(bookingUid);
|
|
4545
4745
|
}
|
|
@@ -4547,37 +4747,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4547
4747
|
}
|
|
4548
4748
|
case 8:
|
|
4549
4749
|
case "end":
|
|
4550
|
-
return
|
|
4750
|
+
return _context29.stop();
|
|
4551
4751
|
}
|
|
4552
4752
|
}, _loop3);
|
|
4553
4753
|
});
|
|
4554
4754
|
_iterator21.s();
|
|
4555
4755
|
case 17:
|
|
4556
4756
|
if ((_step21 = _iterator21.n()).done) {
|
|
4557
|
-
|
|
4757
|
+
_context30.next = 23;
|
|
4558
4758
|
break;
|
|
4559
4759
|
}
|
|
4560
|
-
return
|
|
4760
|
+
return _context30.delegateYield(_loop3(), "t0", 19);
|
|
4561
4761
|
case 19:
|
|
4562
|
-
if (!
|
|
4563
|
-
|
|
4762
|
+
if (!_context30.t0) {
|
|
4763
|
+
_context30.next = 21;
|
|
4564
4764
|
break;
|
|
4565
4765
|
}
|
|
4566
|
-
return
|
|
4766
|
+
return _context30.abrupt("continue", 21);
|
|
4567
4767
|
case 21:
|
|
4568
|
-
|
|
4768
|
+
_context30.next = 17;
|
|
4569
4769
|
break;
|
|
4570
4770
|
case 23:
|
|
4571
|
-
|
|
4771
|
+
_context30.next = 28;
|
|
4572
4772
|
break;
|
|
4573
4773
|
case 25:
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
_iterator21.e(
|
|
4774
|
+
_context30.prev = 25;
|
|
4775
|
+
_context30.t1 = _context30["catch"](14);
|
|
4776
|
+
_iterator21.e(_context30.t1);
|
|
4577
4777
|
case 28:
|
|
4578
|
-
|
|
4778
|
+
_context30.prev = 28;
|
|
4579
4779
|
_iterator21.f();
|
|
4580
|
-
return
|
|
4780
|
+
return _context30.finish(28);
|
|
4581
4781
|
case 31:
|
|
4582
4782
|
if (linkedBookingUidsToRemove.size > 0) {
|
|
4583
4783
|
// 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
|
|
@@ -4604,20 +4804,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4604
4804
|
tempOrder.products = nextProductIndex >= 0 ? [].concat(_toConsumableArray(productsWithoutRemaining.slice(0, nextProductIndex)), [remainingProduct], _toConsumableArray(productsWithoutRemaining.slice(nextProductIndex))) : [].concat(_toConsumableArray(productsWithoutRemaining), [remainingProduct]);
|
|
4605
4805
|
}
|
|
4606
4806
|
}
|
|
4607
|
-
|
|
4807
|
+
_context30.next = 35;
|
|
4608
4808
|
return this.finalizeAfterProductsMutation(tempOrder);
|
|
4609
4809
|
case 35:
|
|
4610
4810
|
this.logInfo('removeProductsFromOrder success', {
|
|
4611
4811
|
identities: identities
|
|
4612
4812
|
});
|
|
4613
|
-
return
|
|
4813
|
+
return _context30.abrupt("return", tempOrder.products);
|
|
4614
4814
|
case 37:
|
|
4615
4815
|
case "end":
|
|
4616
|
-
return
|
|
4816
|
+
return _context30.stop();
|
|
4617
4817
|
}
|
|
4618
|
-
},
|
|
4818
|
+
}, _callee27, this, [[14, 25, 28, 31]]);
|
|
4619
4819
|
}));
|
|
4620
|
-
function removeProductsFromOrder(
|
|
4820
|
+
function removeProductsFromOrder(_x36, _x37) {
|
|
4621
4821
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
4622
4822
|
}
|
|
4623
4823
|
return removeProductsFromOrder;
|
|
@@ -4625,18 +4825,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4625
4825
|
}, {
|
|
4626
4826
|
key: "removeProductFromOrder",
|
|
4627
4827
|
value: function () {
|
|
4628
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4629
|
-
return _regeneratorRuntime().wrap(function
|
|
4630
|
-
while (1) switch (
|
|
4828
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(identity, options) {
|
|
4829
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context31) {
|
|
4830
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
4631
4831
|
case 0:
|
|
4632
|
-
return
|
|
4832
|
+
return _context31.abrupt("return", this.removeProductsFromOrder([identity], options));
|
|
4633
4833
|
case 1:
|
|
4634
4834
|
case "end":
|
|
4635
|
-
return
|
|
4835
|
+
return _context31.stop();
|
|
4636
4836
|
}
|
|
4637
|
-
},
|
|
4837
|
+
}, _callee28, this);
|
|
4638
4838
|
}));
|
|
4639
|
-
function removeProductFromOrder(
|
|
4839
|
+
function removeProductFromOrder(_x38, _x39) {
|
|
4640
4840
|
return _removeProductFromOrder.apply(this, arguments);
|
|
4641
4841
|
}
|
|
4642
4842
|
return removeProductFromOrder;
|
|
@@ -4648,10 +4848,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4648
4848
|
}, {
|
|
4649
4849
|
key: "clearOrderCartLines",
|
|
4650
4850
|
value: (function () {
|
|
4651
|
-
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4851
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
|
|
4652
4852
|
var tempOrder;
|
|
4653
|
-
return _regeneratorRuntime().wrap(function
|
|
4654
|
-
while (1) switch (
|
|
4853
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context32) {
|
|
4854
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
4655
4855
|
case 0:
|
|
4656
4856
|
tempOrder = this.ensureTempOrder();
|
|
4657
4857
|
tempOrder.products = [];
|
|
@@ -4662,24 +4862,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4662
4862
|
productsByUid: {}
|
|
4663
4863
|
});
|
|
4664
4864
|
}
|
|
4665
|
-
|
|
4865
|
+
_context32.next = 7;
|
|
4666
4866
|
return this.applyPromotion();
|
|
4667
4867
|
case 7:
|
|
4668
4868
|
this.applyDiscount();
|
|
4669
4869
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4670
|
-
|
|
4870
|
+
_context32.next = 11;
|
|
4671
4871
|
return this.recalculateSummary({
|
|
4672
4872
|
createIfMissing: true
|
|
4673
4873
|
});
|
|
4674
4874
|
case 11:
|
|
4675
4875
|
this.persistTempOrder();
|
|
4676
4876
|
this.logInfo('clearOrderCartLines success', {});
|
|
4677
|
-
return
|
|
4877
|
+
return _context32.abrupt("return", tempOrder);
|
|
4678
4878
|
case 14:
|
|
4679
4879
|
case "end":
|
|
4680
|
-
return
|
|
4880
|
+
return _context32.stop();
|
|
4681
4881
|
}
|
|
4682
|
-
},
|
|
4882
|
+
}, _callee29, this);
|
|
4683
4883
|
}));
|
|
4684
4884
|
function clearOrderCartLines() {
|
|
4685
4885
|
return _clearOrderCartLines.apply(this, arguments);
|
|
@@ -4717,17 +4917,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4717
4917
|
}, {
|
|
4718
4918
|
key: "applyLocalPrintOrderNumbers",
|
|
4719
4919
|
value: function () {
|
|
4720
|
-
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4920
|
+
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(order) {
|
|
4721
4921
|
var tempOrder, shopOrderNumber, shopFullOrderNumber;
|
|
4722
|
-
return _regeneratorRuntime().wrap(function
|
|
4723
|
-
while (1) switch (
|
|
4922
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context33) {
|
|
4923
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
4724
4924
|
case 0:
|
|
4725
4925
|
tempOrder = this.ensureTempOrder();
|
|
4726
4926
|
if (!(!order || _typeof(order) !== 'object')) {
|
|
4727
|
-
|
|
4927
|
+
_context33.next = 3;
|
|
4728
4928
|
break;
|
|
4729
4929
|
}
|
|
4730
|
-
return
|
|
4930
|
+
return _context33.abrupt("return", tempOrder);
|
|
4731
4931
|
case 3:
|
|
4732
4932
|
shopOrderNumber = order.shop_order_number;
|
|
4733
4933
|
shopFullOrderNumber = order.shop_full_order_number;
|
|
@@ -4738,21 +4938,88 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4738
4938
|
tempOrder.shop_full_order_number = String(shopFullOrderNumber);
|
|
4739
4939
|
}
|
|
4740
4940
|
this.persistTempOrder();
|
|
4741
|
-
|
|
4941
|
+
_context33.next = 10;
|
|
4742
4942
|
return this.saveDraft();
|
|
4743
4943
|
case 10:
|
|
4744
|
-
return
|
|
4944
|
+
return _context33.abrupt("return", tempOrder);
|
|
4745
4945
|
case 11:
|
|
4746
4946
|
case "end":
|
|
4747
|
-
return
|
|
4947
|
+
return _context33.stop();
|
|
4748
4948
|
}
|
|
4749
|
-
},
|
|
4949
|
+
}, _callee30, this);
|
|
4750
4950
|
}));
|
|
4751
|
-
function applyLocalPrintOrderNumbers(
|
|
4951
|
+
function applyLocalPrintOrderNumbers(_x40) {
|
|
4752
4952
|
return _applyLocalPrintOrderNumbers.apply(this, arguments);
|
|
4753
4953
|
}
|
|
4754
4954
|
return applyLocalPrintOrderNumbers;
|
|
4755
4955
|
}()
|
|
4956
|
+
}, {
|
|
4957
|
+
key: "saveTempOrderAsDraft",
|
|
4958
|
+
value: function () {
|
|
4959
|
+
var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
4960
|
+
var _params$cacheId2, _this$otherParams6, _this$otherParams7, _this$otherParams8, _params$type, _this$otherParams9, _payload$products;
|
|
4961
|
+
var tempOrder, latestSummary, payload;
|
|
4962
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context34) {
|
|
4963
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
4964
|
+
case 0:
|
|
4965
|
+
tempOrder = this.ensureTempOrder();
|
|
4966
|
+
this.ensureExternalSaleNumber(tempOrder);
|
|
4967
|
+
this.persistTempOrder();
|
|
4968
|
+
_context34.next = 5;
|
|
4969
|
+
return this.recalculateSummary({
|
|
4970
|
+
createIfMissing: true
|
|
4971
|
+
});
|
|
4972
|
+
case 5:
|
|
4973
|
+
_context34.t1 = _context34.sent;
|
|
4974
|
+
if (_context34.t1) {
|
|
4975
|
+
_context34.next = 8;
|
|
4976
|
+
break;
|
|
4977
|
+
}
|
|
4978
|
+
_context34.t1 = this.store.summary;
|
|
4979
|
+
case 8:
|
|
4980
|
+
_context34.t0 = _context34.t1;
|
|
4981
|
+
if (_context34.t0) {
|
|
4982
|
+
_context34.next = 11;
|
|
4983
|
+
break;
|
|
4984
|
+
}
|
|
4985
|
+
_context34.t0 = createEmptySummary();
|
|
4986
|
+
case 11:
|
|
4987
|
+
latestSummary = _context34.t0;
|
|
4988
|
+
payload = buildSubmitPayload({
|
|
4989
|
+
tempOrder: tempOrder,
|
|
4990
|
+
cacheId: (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId,
|
|
4991
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform),
|
|
4992
|
+
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,
|
|
4993
|
+
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
4994
|
+
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,
|
|
4995
|
+
summary: latestSummary,
|
|
4996
|
+
enhance: params === null || params === void 0 ? void 0 : params.enhancePayload
|
|
4997
|
+
});
|
|
4998
|
+
if (!payload.created_at) {
|
|
4999
|
+
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
5000
|
+
}
|
|
5001
|
+
payload.need_sync = 0;
|
|
5002
|
+
payload.is_draft_order = 1;
|
|
5003
|
+
this.logInfo('saveTempOrderAsDraft calling sales draft', {
|
|
5004
|
+
orderId: payload.order_id,
|
|
5005
|
+
externalSaleNumber: payload.external_sale_number,
|
|
5006
|
+
productsCount: ((_payload$products = payload.products) === null || _payload$products === void 0 ? void 0 : _payload$products.length) || 0
|
|
5007
|
+
});
|
|
5008
|
+
return _context34.abrupt("return", this.request.post('/order/sales/draft', payload, {
|
|
5009
|
+
osServer: true,
|
|
5010
|
+
customToast: function customToast() {}
|
|
5011
|
+
}));
|
|
5012
|
+
case 18:
|
|
5013
|
+
case "end":
|
|
5014
|
+
return _context34.stop();
|
|
5015
|
+
}
|
|
5016
|
+
}, _callee31, this);
|
|
5017
|
+
}));
|
|
5018
|
+
function saveTempOrderAsDraft(_x41) {
|
|
5019
|
+
return _saveTempOrderAsDraft.apply(this, arguments);
|
|
5020
|
+
}
|
|
5021
|
+
return saveTempOrderAsDraft;
|
|
5022
|
+
}()
|
|
4756
5023
|
/**
|
|
4757
5024
|
* 提交当前 Sales tempOrder。
|
|
4758
5025
|
*
|
|
@@ -4762,18 +5029,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4762
5029
|
}, {
|
|
4763
5030
|
key: "submitTempOrder",
|
|
4764
5031
|
value: (function () {
|
|
4765
|
-
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4766
|
-
return _regeneratorRuntime().wrap(function
|
|
4767
|
-
while (1) switch (
|
|
5032
|
+
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
|
|
5033
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context35) {
|
|
5034
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
4768
5035
|
case 0:
|
|
4769
|
-
return
|
|
5036
|
+
return _context35.abrupt("return", this.runSubmitTempOrder(params));
|
|
4770
5037
|
case 1:
|
|
4771
5038
|
case "end":
|
|
4772
|
-
return
|
|
5039
|
+
return _context35.stop();
|
|
4773
5040
|
}
|
|
4774
|
-
},
|
|
5041
|
+
}, _callee32, this);
|
|
4775
5042
|
}));
|
|
4776
|
-
function submitTempOrder(
|
|
5043
|
+
function submitTempOrder(_x42) {
|
|
4777
5044
|
return _submitTempOrder.apply(this, arguments);
|
|
4778
5045
|
}
|
|
4779
5046
|
return submitTempOrder;
|
|
@@ -4781,20 +5048,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4781
5048
|
}, {
|
|
4782
5049
|
key: "submitTempOrderAsync",
|
|
4783
5050
|
value: function () {
|
|
4784
|
-
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4785
|
-
return _regeneratorRuntime().wrap(function
|
|
4786
|
-
while (1) switch (
|
|
5051
|
+
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
|
|
5052
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context36) {
|
|
5053
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
4787
5054
|
case 0:
|
|
4788
|
-
return
|
|
5055
|
+
return _context36.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
4789
5056
|
syncMode: true
|
|
4790
5057
|
})));
|
|
4791
5058
|
case 1:
|
|
4792
5059
|
case "end":
|
|
4793
|
-
return
|
|
5060
|
+
return _context36.stop();
|
|
4794
5061
|
}
|
|
4795
|
-
},
|
|
5062
|
+
}, _callee33, this);
|
|
4796
5063
|
}));
|
|
4797
|
-
function submitTempOrderAsync(
|
|
5064
|
+
function submitTempOrderAsync(_x43) {
|
|
4798
5065
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
4799
5066
|
}
|
|
4800
5067
|
return submitTempOrderAsync;
|
|
@@ -4802,11 +5069,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4802
5069
|
}, {
|
|
4803
5070
|
key: "runSubmitTempOrder",
|
|
4804
5071
|
value: function () {
|
|
4805
|
-
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4806
|
-
var _params$
|
|
5072
|
+
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
5073
|
+
var _params$cacheId3, _this$otherParams10, _ref74, _ref75, _submitSnapshot$busin, _this$otherParams11, _this$otherParams12, _submitSnapshot$type;
|
|
4807
5074
|
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 (
|
|
5075
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context37) {
|
|
5076
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
4810
5077
|
case 0:
|
|
4811
5078
|
tempOrder = this.ensureTempOrder();
|
|
4812
5079
|
shouldConfirmPendingVoucherPayments = (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== false;
|
|
@@ -4826,27 +5093,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4826
5093
|
}
|
|
4827
5094
|
}
|
|
4828
5095
|
this.persistTempOrder();
|
|
4829
|
-
|
|
5096
|
+
_context37.next = 8;
|
|
4830
5097
|
return this.recalculateSummary({
|
|
4831
5098
|
createIfMissing: true
|
|
4832
5099
|
});
|
|
4833
5100
|
case 8:
|
|
4834
|
-
|
|
4835
|
-
if (
|
|
4836
|
-
|
|
5101
|
+
_context37.t1 = _context37.sent;
|
|
5102
|
+
if (_context37.t1) {
|
|
5103
|
+
_context37.next = 11;
|
|
4837
5104
|
break;
|
|
4838
5105
|
}
|
|
4839
|
-
|
|
5106
|
+
_context37.t1 = this.store.summary;
|
|
4840
5107
|
case 11:
|
|
4841
|
-
|
|
4842
|
-
if (
|
|
4843
|
-
|
|
5108
|
+
_context37.t0 = _context37.t1;
|
|
5109
|
+
if (_context37.t0) {
|
|
5110
|
+
_context37.next = 14;
|
|
4844
5111
|
break;
|
|
4845
5112
|
}
|
|
4846
|
-
|
|
5113
|
+
_context37.t0 = createEmptySummary();
|
|
4847
5114
|
case 14:
|
|
4848
|
-
latestSummary =
|
|
4849
|
-
effectiveCacheId = (_params$
|
|
5115
|
+
latestSummary = _context37.t0;
|
|
5116
|
+
effectiveCacheId = (_params$cacheId3 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId3 !== void 0 ? _params$cacheId3 : this.cacheId;
|
|
4850
5117
|
hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
|
|
4851
5118
|
hasSmallTicketDataFlagOverride = (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined;
|
|
4852
5119
|
enhancePayload = hasPaymentOverride || hasPaymentStatusOverride || hasSmallTicketDataFlagOverride || params !== null && params !== void 0 && params.enhancePayload ? function (payload, ctx) {
|
|
@@ -4864,8 +5131,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4864
5131
|
payload = buildSubmitPayload({
|
|
4865
5132
|
tempOrder: tempOrder,
|
|
4866
5133
|
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$
|
|
5134
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.platform),
|
|
5135
|
+
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
5136
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
4870
5137
|
type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
|
|
4871
5138
|
summary: latestSummary,
|
|
@@ -4880,10 +5147,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4880
5147
|
if (!payload.created_at) {
|
|
4881
5148
|
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
4882
5149
|
}
|
|
4883
|
-
|
|
5150
|
+
_context37.next = 26;
|
|
4884
5151
|
return this.saveDraft();
|
|
4885
5152
|
case 26:
|
|
4886
|
-
|
|
5153
|
+
_context37.prev = 26;
|
|
4887
5154
|
this.logInfo('submitTempOrder calling sales checkout', {
|
|
4888
5155
|
orderId: payload.order_id,
|
|
4889
5156
|
externalSaleNumber: payload.external_sale_number,
|
|
@@ -4893,43 +5160,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4893
5160
|
smallTicketDataFlag: payload.small_ticket_data_flag,
|
|
4894
5161
|
syncMode: payload.sync_mode
|
|
4895
5162
|
});
|
|
4896
|
-
|
|
5163
|
+
_context37.next = 30;
|
|
4897
5164
|
return this.submitSalesOrder({
|
|
4898
5165
|
query: payload
|
|
4899
5166
|
});
|
|
4900
5167
|
case 30:
|
|
4901
|
-
result =
|
|
4902
|
-
|
|
5168
|
+
result = _context37.sent;
|
|
5169
|
+
_context37.next = 43;
|
|
4903
5170
|
break;
|
|
4904
5171
|
case 33:
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
backendErrorResponse = this.extractSubmitErrorResponse(
|
|
5172
|
+
_context37.prev = 33;
|
|
5173
|
+
_context37.t2 = _context37["catch"](26);
|
|
5174
|
+
backendErrorResponse = this.extractSubmitErrorResponse(_context37.t2);
|
|
4908
5175
|
if (!backendErrorResponse) {
|
|
4909
|
-
|
|
5176
|
+
_context37.next = 40;
|
|
4910
5177
|
break;
|
|
4911
5178
|
}
|
|
4912
5179
|
this.store.syncState = 'failed';
|
|
4913
5180
|
this.logSubmitBackendRejected(backendErrorResponse, payload);
|
|
4914
|
-
return
|
|
5181
|
+
return _context37.abrupt("return", backendErrorResponse);
|
|
4915
5182
|
case 40:
|
|
4916
5183
|
this.store.syncState = 'failed';
|
|
4917
5184
|
this.logError('submitTempOrder failed', {
|
|
4918
|
-
error:
|
|
5185
|
+
error: _context37.t2 instanceof Error ? _context37.t2.message : String(_context37.t2),
|
|
4919
5186
|
orderId: payload.order_id,
|
|
4920
5187
|
externalSaleNumber: payload.external_sale_number,
|
|
4921
5188
|
paymentStatus: payload.payment_status,
|
|
4922
5189
|
paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
|
|
4923
5190
|
});
|
|
4924
|
-
throw
|
|
5191
|
+
throw _context37.t2;
|
|
4925
5192
|
case 43:
|
|
4926
5193
|
if (!this.isSubmitResponseRejected(result)) {
|
|
4927
|
-
|
|
5194
|
+
_context37.next = 47;
|
|
4928
5195
|
break;
|
|
4929
5196
|
}
|
|
4930
5197
|
this.store.syncState = 'failed';
|
|
4931
5198
|
this.logSubmitBackendRejected(result, payload);
|
|
4932
|
-
return
|
|
5199
|
+
return _context37.abrupt("return", result);
|
|
4933
5200
|
case 47:
|
|
4934
5201
|
submittedOrderId = this.extractOrderIdFromSubmitResult(result);
|
|
4935
5202
|
this.logInfo('runSubmitTempOrder: 提交成功', {
|
|
@@ -4940,15 +5207,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4940
5207
|
})
|
|
4941
5208
|
});
|
|
4942
5209
|
if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
|
|
4943
|
-
|
|
5210
|
+
_context37.next = 56;
|
|
4944
5211
|
break;
|
|
4945
5212
|
}
|
|
4946
5213
|
tempOrder.order_id = submittedOrderId;
|
|
4947
5214
|
resultRecord = result;
|
|
4948
|
-
|
|
5215
|
+
_context37.next = 54;
|
|
4949
5216
|
return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
|
|
4950
5217
|
case 54:
|
|
4951
|
-
|
|
5218
|
+
_context37.next = 57;
|
|
4952
5219
|
break;
|
|
4953
5220
|
case 56:
|
|
4954
5221
|
if (this.isLocalPendingSubmitResult(result)) {
|
|
@@ -4957,14 +5224,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4957
5224
|
this.store.syncState = 'submitted';
|
|
4958
5225
|
}
|
|
4959
5226
|
case 57:
|
|
4960
|
-
return
|
|
5227
|
+
return _context37.abrupt("return", result);
|
|
4961
5228
|
case 58:
|
|
4962
5229
|
case "end":
|
|
4963
|
-
return
|
|
5230
|
+
return _context37.stop();
|
|
4964
5231
|
}
|
|
4965
|
-
},
|
|
5232
|
+
}, _callee34, this, [[26, 33]]);
|
|
4966
5233
|
}));
|
|
4967
|
-
function runSubmitTempOrder(
|
|
5234
|
+
function runSubmitTempOrder(_x44) {
|
|
4968
5235
|
return _runSubmitTempOrder.apply(this, arguments);
|
|
4969
5236
|
}
|
|
4970
5237
|
return runSubmitTempOrder;
|
|
@@ -4972,10 +5239,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4972
5239
|
}, {
|
|
4973
5240
|
key: "markLocalOrderSynced",
|
|
4974
5241
|
value: function () {
|
|
4975
|
-
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5242
|
+
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(orderId, remoteOrder) {
|
|
4976
5243
|
var tempOrder;
|
|
4977
|
-
return _regeneratorRuntime().wrap(function
|
|
4978
|
-
while (1) switch (
|
|
5244
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context38) {
|
|
5245
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
4979
5246
|
case 0:
|
|
4980
5247
|
tempOrder = this.ensureTempOrder();
|
|
4981
5248
|
tempOrder.order_id = orderId;
|
|
@@ -4983,15 +5250,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4983
5250
|
this.store.lastOrderInfo = remoteOrder;
|
|
4984
5251
|
this.store.syncState = 'submitted';
|
|
4985
5252
|
this.persistTempOrder();
|
|
4986
|
-
|
|
5253
|
+
_context38.next = 8;
|
|
4987
5254
|
return this.saveDraft();
|
|
4988
5255
|
case 8:
|
|
4989
5256
|
case "end":
|
|
4990
|
-
return
|
|
5257
|
+
return _context38.stop();
|
|
4991
5258
|
}
|
|
4992
|
-
},
|
|
5259
|
+
}, _callee35, this);
|
|
4993
5260
|
}));
|
|
4994
|
-
function markLocalOrderSynced(
|
|
5261
|
+
function markLocalOrderSynced(_x45, _x46) {
|
|
4995
5262
|
return _markLocalOrderSynced.apply(this, arguments);
|
|
4996
5263
|
}
|
|
4997
5264
|
return markLocalOrderSynced;
|
|
@@ -5034,10 +5301,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5034
5301
|
value: function extractSubmitErrorResponse(error) {
|
|
5035
5302
|
var _error$response,
|
|
5036
5303
|
_error$response2,
|
|
5037
|
-
|
|
5304
|
+
_this30 = this;
|
|
5038
5305
|
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
5306
|
return candidates.find(function (candidate) {
|
|
5040
|
-
return
|
|
5307
|
+
return _this30.isSubmitErrorResponse(candidate);
|
|
5041
5308
|
}) || null;
|
|
5042
5309
|
}
|
|
5043
5310
|
}, {
|
|
@@ -5064,14 +5331,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5064
5331
|
}, {
|
|
5065
5332
|
key: "syncPaymentsToOrder",
|
|
5066
5333
|
value: function () {
|
|
5067
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5068
|
-
var
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5334
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
|
|
5335
|
+
var _this31 = this,
|
|
5336
|
+
_params$confirmPendin;
|
|
5337
|
+
var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, submitResult;
|
|
5338
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context39) {
|
|
5339
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
5072
5340
|
case 0:
|
|
5073
5341
|
tempOrder = this.ensureTempOrder();
|
|
5074
|
-
|
|
5342
|
+
needsPaymentNumber = (params.payments || []).some(function (payment) {
|
|
5343
|
+
return String(payment.payment_number || '').trim() === '';
|
|
5344
|
+
});
|
|
5345
|
+
if (!needsPaymentNumber) {
|
|
5346
|
+
_context39.next = 8;
|
|
5347
|
+
break;
|
|
5348
|
+
}
|
|
5349
|
+
_context39.next = 5;
|
|
5350
|
+
return this.getPaymentNumberDevicePrefixAsync();
|
|
5351
|
+
case 5:
|
|
5352
|
+
_context39.t0 = _context39.sent;
|
|
5353
|
+
_context39.next = 9;
|
|
5354
|
+
break;
|
|
5355
|
+
case 8:
|
|
5356
|
+
_context39.t0 = 'LOCAL';
|
|
5357
|
+
case 9:
|
|
5358
|
+
devicePrefix = _context39.t0;
|
|
5359
|
+
mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
|
|
5360
|
+
return _this31.normalizePaymentSource(payment, {
|
|
5361
|
+
defaultPaid: false,
|
|
5362
|
+
devicePrefix: devicePrefix
|
|
5363
|
+
});
|
|
5364
|
+
}));
|
|
5075
5365
|
shouldConfirmPendingVoucherPayments = (_params$confirmPendin = params.confirmPendingVoucherPayments) !== null && _params$confirmPendin !== void 0 ? _params$confirmPendin : params.submitWhenPaid === true;
|
|
5076
5366
|
effectivePayments = shouldConfirmPendingVoucherPayments ? this.confirmPendingVoucherPaymentsInList(mappedPayments) : params.confirmPendingVoucherPayments === false ? this.discardPendingVoucherPaymentsFromList(mappedPayments) : mappedPayments;
|
|
5077
5367
|
completion = this.getPaymentCompletion(effectivePayments);
|
|
@@ -5080,24 +5370,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5080
5370
|
tempOrder.payments = effectivePayments;
|
|
5081
5371
|
tempOrder.payment_status = paymentStatus;
|
|
5082
5372
|
this.persistTempOrder();
|
|
5083
|
-
|
|
5373
|
+
_context39.next = 21;
|
|
5084
5374
|
return this.saveDraft();
|
|
5085
|
-
case
|
|
5375
|
+
case 21:
|
|
5086
5376
|
if (params.submitWhenPaid) {
|
|
5087
|
-
|
|
5377
|
+
_context39.next = 23;
|
|
5088
5378
|
break;
|
|
5089
5379
|
}
|
|
5090
|
-
return
|
|
5091
|
-
case
|
|
5380
|
+
return _context39.abrupt("return", completion);
|
|
5381
|
+
case 23:
|
|
5092
5382
|
if (!(this.store.syncState === 'submitting')) {
|
|
5093
|
-
|
|
5383
|
+
_context39.next = 25;
|
|
5094
5384
|
break;
|
|
5095
5385
|
}
|
|
5096
|
-
return
|
|
5097
|
-
case
|
|
5386
|
+
return _context39.abrupt("return", completion);
|
|
5387
|
+
case 25:
|
|
5098
5388
|
this.store.syncState = 'submitting';
|
|
5099
5389
|
paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
|
|
5100
|
-
|
|
5390
|
+
_context39.next = 29;
|
|
5101
5391
|
return this.submitTempOrder({
|
|
5102
5392
|
payments: effectivePayments,
|
|
5103
5393
|
paymentStatus: paymentStatus,
|
|
@@ -5112,18 +5402,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5112
5402
|
return nextPayload;
|
|
5113
5403
|
}
|
|
5114
5404
|
});
|
|
5115
|
-
case
|
|
5116
|
-
submitResult =
|
|
5117
|
-
return
|
|
5405
|
+
case 29:
|
|
5406
|
+
submitResult = _context39.sent;
|
|
5407
|
+
return _context39.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
|
|
5118
5408
|
submitResult: submitResult
|
|
5119
5409
|
}));
|
|
5120
|
-
case
|
|
5410
|
+
case 31:
|
|
5121
5411
|
case "end":
|
|
5122
|
-
return
|
|
5412
|
+
return _context39.stop();
|
|
5123
5413
|
}
|
|
5124
|
-
},
|
|
5414
|
+
}, _callee36, this);
|
|
5125
5415
|
}));
|
|
5126
|
-
function syncPaymentsToOrder(
|
|
5416
|
+
function syncPaymentsToOrder(_x47) {
|
|
5127
5417
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
5128
5418
|
}
|
|
5129
5419
|
return syncPaymentsToOrder;
|
|
@@ -5212,11 +5502,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5212
5502
|
}, {
|
|
5213
5503
|
key: "submitOrder",
|
|
5214
5504
|
value: function () {
|
|
5215
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5505
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(order) {
|
|
5216
5506
|
var _order$query$cartItem, _params$bookings, _params$relation_prod;
|
|
5217
5507
|
var url, query, fetchUrl, params;
|
|
5218
|
-
return _regeneratorRuntime().wrap(function
|
|
5219
|
-
while (1) switch (
|
|
5508
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context40) {
|
|
5509
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
5220
5510
|
case 0:
|
|
5221
5511
|
this.logInfo('submitOrder called', {
|
|
5222
5512
|
url: order.url,
|
|
@@ -5236,14 +5526,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5236
5526
|
relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
|
|
5237
5527
|
scheduleDate: params.schedule_date
|
|
5238
5528
|
});
|
|
5239
|
-
return
|
|
5529
|
+
return _context40.abrupt("return", this.request.post(fetchUrl, params));
|
|
5240
5530
|
case 6:
|
|
5241
5531
|
case "end":
|
|
5242
|
-
return
|
|
5532
|
+
return _context40.stop();
|
|
5243
5533
|
}
|
|
5244
|
-
},
|
|
5534
|
+
}, _callee37, this);
|
|
5245
5535
|
}));
|
|
5246
|
-
function submitOrder(
|
|
5536
|
+
function submitOrder(_x48) {
|
|
5247
5537
|
return _submitOrder.apply(this, arguments);
|
|
5248
5538
|
}
|
|
5249
5539
|
return submitOrder;
|
|
@@ -5251,13 +5541,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5251
5541
|
}, {
|
|
5252
5542
|
key: "cancelOrder",
|
|
5253
5543
|
value: function () {
|
|
5254
|
-
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5544
|
+
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
|
|
5255
5545
|
var payload;
|
|
5256
|
-
return _regeneratorRuntime().wrap(function
|
|
5257
|
-
while (1) switch (
|
|
5546
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context41) {
|
|
5547
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
5258
5548
|
case 0:
|
|
5259
5549
|
if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
|
|
5260
|
-
|
|
5550
|
+
_context41.next = 2;
|
|
5261
5551
|
break;
|
|
5262
5552
|
}
|
|
5263
5553
|
throw new Error('取消订单失败:order_ids 不能为空');
|
|
@@ -5273,16 +5563,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5273
5563
|
method: 'PUT',
|
|
5274
5564
|
orderIdsCount: params.order_ids.length
|
|
5275
5565
|
});
|
|
5276
|
-
return
|
|
5566
|
+
return _context41.abrupt("return", this.request.put('/order/update-status', payload, {
|
|
5277
5567
|
isShopApi: true
|
|
5278
5568
|
}));
|
|
5279
5569
|
case 5:
|
|
5280
5570
|
case "end":
|
|
5281
|
-
return
|
|
5571
|
+
return _context41.stop();
|
|
5282
5572
|
}
|
|
5283
|
-
},
|
|
5573
|
+
}, _callee38, this);
|
|
5284
5574
|
}));
|
|
5285
|
-
function cancelOrder(
|
|
5575
|
+
function cancelOrder(_x49) {
|
|
5286
5576
|
return _cancelOrder.apply(this, arguments);
|
|
5287
5577
|
}
|
|
5288
5578
|
return cancelOrder;
|
|
@@ -5290,19 +5580,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5290
5580
|
}, {
|
|
5291
5581
|
key: "changeBookingStatus",
|
|
5292
5582
|
value: function () {
|
|
5293
|
-
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5583
|
+
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
5294
5584
|
var url, payload;
|
|
5295
|
-
return _regeneratorRuntime().wrap(function
|
|
5296
|
-
while (1) switch (
|
|
5585
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context42) {
|
|
5586
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
5297
5587
|
case 0:
|
|
5298
5588
|
if (params.booking_id) {
|
|
5299
|
-
|
|
5589
|
+
_context42.next = 2;
|
|
5300
5590
|
break;
|
|
5301
5591
|
}
|
|
5302
5592
|
throw new Error('变更预约状态失败:booking_id 不能为空');
|
|
5303
5593
|
case 2:
|
|
5304
5594
|
if (params.appointment_status) {
|
|
5305
|
-
|
|
5595
|
+
_context42.next = 4;
|
|
5306
5596
|
break;
|
|
5307
5597
|
}
|
|
5308
5598
|
throw new Error('变更预约状态失败:appointment_status 不能为空');
|
|
@@ -5317,16 +5607,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5317
5607
|
bookingId: params.booking_id,
|
|
5318
5608
|
appointmentStatus: params.appointment_status
|
|
5319
5609
|
});
|
|
5320
|
-
return
|
|
5610
|
+
return _context42.abrupt("return", this.request.put(url, payload, {
|
|
5321
5611
|
isShopApi: true
|
|
5322
5612
|
}));
|
|
5323
5613
|
case 8:
|
|
5324
5614
|
case "end":
|
|
5325
|
-
return
|
|
5615
|
+
return _context42.stop();
|
|
5326
5616
|
}
|
|
5327
|
-
},
|
|
5617
|
+
}, _callee39, this);
|
|
5328
5618
|
}));
|
|
5329
|
-
function changeBookingStatus(
|
|
5619
|
+
function changeBookingStatus(_x50) {
|
|
5330
5620
|
return _changeBookingStatus.apply(this, arguments);
|
|
5331
5621
|
}
|
|
5332
5622
|
return changeBookingStatus;
|
|
@@ -5344,11 +5634,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5344
5634
|
}, {
|
|
5345
5635
|
key: "createOrderByCheckout",
|
|
5346
5636
|
value: (function () {
|
|
5347
|
-
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5637
|
+
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
|
|
5348
5638
|
var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
|
|
5349
5639
|
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 (
|
|
5640
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context43) {
|
|
5641
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
5352
5642
|
case 0:
|
|
5353
5643
|
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
5354
5644
|
onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
@@ -5382,7 +5672,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5382
5672
|
relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
|
|
5383
5673
|
paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
|
|
5384
5674
|
});
|
|
5385
|
-
|
|
5675
|
+
_context43.prev = 4;
|
|
5386
5676
|
// 构建订单数据,设置默认值并允许 params 覆盖
|
|
5387
5677
|
orderData = _objectSpread({
|
|
5388
5678
|
sales_channel: 'my_pisel',
|
|
@@ -5444,13 +5734,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5444
5734
|
hasOrderId: !!orderData.order_id,
|
|
5445
5735
|
smallTicketDataFlag: orderData.small_ticket_data_flag
|
|
5446
5736
|
});
|
|
5447
|
-
|
|
5737
|
+
_context43.next = 12;
|
|
5448
5738
|
return this.request.post('/order/checkout', orderData, {
|
|
5449
5739
|
osServer: true,
|
|
5450
5740
|
customToast: function customToast() {}
|
|
5451
5741
|
});
|
|
5452
5742
|
case 12:
|
|
5453
|
-
response =
|
|
5743
|
+
response = _context43.sent;
|
|
5454
5744
|
this.logInfo('Order API called successfully', {
|
|
5455
5745
|
response: response
|
|
5456
5746
|
});
|
|
@@ -5458,22 +5748,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5458
5748
|
success: !!response,
|
|
5459
5749
|
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
5750
|
});
|
|
5461
|
-
return
|
|
5751
|
+
return _context43.abrupt("return", response);
|
|
5462
5752
|
case 18:
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
console.error('[Order] createOrderByCheckout 创建订单失败:',
|
|
5753
|
+
_context43.prev = 18;
|
|
5754
|
+
_context43.t0 = _context43["catch"](4);
|
|
5755
|
+
console.error('[Order] createOrderByCheckout 创建订单失败:', _context43.t0);
|
|
5466
5756
|
this.logInfo('Order API called failed', {
|
|
5467
|
-
error:
|
|
5757
|
+
error: _context43.t0 instanceof Error ? _context43.t0.message : String(_context43.t0)
|
|
5468
5758
|
});
|
|
5469
|
-
throw
|
|
5759
|
+
throw _context43.t0;
|
|
5470
5760
|
case 23:
|
|
5471
5761
|
case "end":
|
|
5472
|
-
return
|
|
5762
|
+
return _context43.stop();
|
|
5473
5763
|
}
|
|
5474
|
-
},
|
|
5764
|
+
}, _callee40, this, [[4, 18]]);
|
|
5475
5765
|
}));
|
|
5476
|
-
function createOrderByCheckout(
|
|
5766
|
+
function createOrderByCheckout(_x51) {
|
|
5477
5767
|
return _createOrderByCheckout.apply(this, arguments);
|
|
5478
5768
|
}
|
|
5479
5769
|
return createOrderByCheckout;
|
|
@@ -5481,24 +5771,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5481
5771
|
}, {
|
|
5482
5772
|
key: "submitSalesOrder",
|
|
5483
5773
|
value: function () {
|
|
5484
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5774
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
|
|
5485
5775
|
var url, query, fetchUrl;
|
|
5486
|
-
return _regeneratorRuntime().wrap(function
|
|
5487
|
-
while (1) switch (
|
|
5776
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context44) {
|
|
5777
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
5488
5778
|
case 0:
|
|
5489
5779
|
url = params.url, query = params.query;
|
|
5490
5780
|
fetchUrl = url || '/order/sales/checkout';
|
|
5491
|
-
return
|
|
5781
|
+
return _context44.abrupt("return", this.request.post(fetchUrl, query, {
|
|
5492
5782
|
osServer: true,
|
|
5493
5783
|
customToast: function customToast() {}
|
|
5494
5784
|
}));
|
|
5495
5785
|
case 3:
|
|
5496
5786
|
case "end":
|
|
5497
|
-
return
|
|
5787
|
+
return _context44.stop();
|
|
5498
5788
|
}
|
|
5499
|
-
},
|
|
5789
|
+
}, _callee41, this);
|
|
5500
5790
|
}));
|
|
5501
|
-
function submitSalesOrder(
|
|
5791
|
+
function submitSalesOrder(_x52) {
|
|
5502
5792
|
return _submitSalesOrder.apply(this, arguments);
|
|
5503
5793
|
}
|
|
5504
5794
|
return submitSalesOrder;
|
|
@@ -5512,37 +5802,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5512
5802
|
}, {
|
|
5513
5803
|
key: "sendCustomerPayLink",
|
|
5514
5804
|
value: (function () {
|
|
5515
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5805
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
|
|
5516
5806
|
var _params$emails;
|
|
5517
5807
|
var orderIds;
|
|
5518
|
-
return _regeneratorRuntime().wrap(function
|
|
5519
|
-
while (1) switch (
|
|
5808
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context45) {
|
|
5809
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
5520
5810
|
case 0:
|
|
5521
5811
|
orderIds = params.order_ids || params.orderIds || [];
|
|
5522
5812
|
if (orderIds.length) {
|
|
5523
|
-
|
|
5813
|
+
_context45.next = 3;
|
|
5524
5814
|
break;
|
|
5525
5815
|
}
|
|
5526
5816
|
throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
|
|
5527
5817
|
case 3:
|
|
5528
5818
|
if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
|
|
5529
|
-
|
|
5819
|
+
_context45.next = 5;
|
|
5530
5820
|
break;
|
|
5531
5821
|
}
|
|
5532
5822
|
throw new Error('发送支付链接需要至少一个邮箱');
|
|
5533
5823
|
case 5:
|
|
5534
|
-
return
|
|
5824
|
+
return _context45.abrupt("return", this.request.post('/order/batch-email', {
|
|
5535
5825
|
order_ids: orderIds,
|
|
5536
5826
|
notify_action: params.notify_action || 'order_payment_reminder',
|
|
5537
5827
|
emails: params.emails
|
|
5538
5828
|
}));
|
|
5539
5829
|
case 6:
|
|
5540
5830
|
case "end":
|
|
5541
|
-
return
|
|
5831
|
+
return _context45.stop();
|
|
5542
5832
|
}
|
|
5543
|
-
},
|
|
5833
|
+
}, _callee42, this);
|
|
5544
5834
|
}));
|
|
5545
|
-
function sendCustomerPayLink(
|
|
5835
|
+
function sendCustomerPayLink(_x53) {
|
|
5546
5836
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
5547
5837
|
}
|
|
5548
5838
|
return sendCustomerPayLink;
|
|
@@ -5550,14 +5840,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5550
5840
|
}, {
|
|
5551
5841
|
key: "getSalesOrderByLookup",
|
|
5552
5842
|
value: function () {
|
|
5553
|
-
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5843
|
+
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(params) {
|
|
5554
5844
|
var lookup, res;
|
|
5555
|
-
return _regeneratorRuntime().wrap(function
|
|
5556
|
-
while (1) switch (
|
|
5845
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context46) {
|
|
5846
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
5557
5847
|
case 0:
|
|
5558
5848
|
lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
|
|
5559
5849
|
if (lookup) {
|
|
5560
|
-
|
|
5850
|
+
_context46.next = 3;
|
|
5561
5851
|
break;
|
|
5562
5852
|
}
|
|
5563
5853
|
throw new Error('加载销售详情需要 lookup');
|
|
@@ -5566,27 +5856,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5566
5856
|
if (lookup.startsWith('LOCAL_')) {
|
|
5567
5857
|
params.forceRemote = false;
|
|
5568
5858
|
}
|
|
5569
|
-
|
|
5859
|
+
_context46.next = 6;
|
|
5570
5860
|
return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
|
|
5571
|
-
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info']
|
|
5861
|
+
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info', 'refunds']
|
|
5572
5862
|
}, params.forceRemote ? {
|
|
5573
5863
|
forceRemote: true
|
|
5574
5864
|
} : {}), {
|
|
5575
5865
|
osServer: true
|
|
5576
5866
|
});
|
|
5577
5867
|
case 6:
|
|
5578
|
-
res =
|
|
5868
|
+
res = _context46.sent;
|
|
5579
5869
|
if (res.code === 200) {
|
|
5580
5870
|
this.store.lastOrderInfo = res.data;
|
|
5581
5871
|
}
|
|
5582
|
-
return
|
|
5872
|
+
return _context46.abrupt("return", res);
|
|
5583
5873
|
case 9:
|
|
5584
5874
|
case "end":
|
|
5585
|
-
return
|
|
5875
|
+
return _context46.stop();
|
|
5586
5876
|
}
|
|
5587
|
-
},
|
|
5877
|
+
}, _callee43, this);
|
|
5588
5878
|
}));
|
|
5589
|
-
function getSalesOrderByLookup(
|
|
5879
|
+
function getSalesOrderByLookup(_x54) {
|
|
5590
5880
|
return _getSalesOrderByLookup.apply(this, arguments);
|
|
5591
5881
|
}
|
|
5592
5882
|
return getSalesOrderByLookup;
|
|
@@ -5600,11 +5890,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5600
5890
|
}, {
|
|
5601
5891
|
key: "hydrateTempOrderFromRecord",
|
|
5602
5892
|
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 (
|
|
5893
|
+
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(record, options) {
|
|
5894
|
+
var _this$store$discount20;
|
|
5895
|
+
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;
|
|
5896
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context47) {
|
|
5897
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
5608
5898
|
case 0:
|
|
5609
5899
|
sourceRaw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
|
|
5610
5900
|
identityReadySource = this.seedAnonymousBookingUidsFromProducts(sourceRaw);
|
|
@@ -5629,7 +5919,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5629
5919
|
}
|
|
5630
5920
|
nextTempOrder = this.normalizeTempOrderForRuntime(raw, {
|
|
5631
5921
|
makeEditMark: true
|
|
5632
|
-
});
|
|
5922
|
+
}); // Server list compatibility may synthesize order_id from external_sale_number; tempOrder must not.
|
|
5923
|
+
sourceLastOrderInfo = raw.lastOrderInfo || raw;
|
|
5924
|
+
isDraftOrder = Number(nextTempOrder.is_draft_order || 0) === 1;
|
|
5925
|
+
syntheticIdentityOptions = {
|
|
5926
|
+
isDraftOrder: isDraftOrder,
|
|
5927
|
+
externalSaleNumber: nextTempOrder.external_sale_number
|
|
5928
|
+
};
|
|
5633
5929
|
rawSummary = raw.summary && _typeof(raw.summary) === 'object' ? raw.summary : {};
|
|
5634
5930
|
summarySurcharges = Array.isArray(rawSummary.surcharges) ? rawSummary.surcharges.map(function (s) {
|
|
5635
5931
|
return _objectSpread({}, s || {});
|
|
@@ -5649,12 +5945,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5649
5945
|
productFingerprint: this.buildOrderProductsFingerprint(nextTempOrder.products || [])
|
|
5650
5946
|
}
|
|
5651
5947
|
});
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5948
|
+
this.store.lastOrderInfo = this.withoutSyntheticDraftOrderIdForRuntime(sourceLastOrderInfo, syntheticIdentityOptions);
|
|
5949
|
+
hadSyntheticDraftOrderId = this.isSyntheticDraftOrderIdForRuntime(raw, syntheticIdentityOptions) || this.isSyntheticDraftOrderIdForRuntime(sourceLastOrderInfo, syntheticIdentityOptions);
|
|
5950
|
+
if (hadSyntheticDraftOrderId && this.store.syncState !== 'submitting') {
|
|
5951
|
+
this.store.syncState = 'local';
|
|
5952
|
+
}
|
|
5656
5953
|
hydratedEditDiscounts = this.collectHydratedEditDiscounts(nextTempOrder.products);
|
|
5657
|
-
currentDiscounts = typeof ((_this$store$
|
|
5954
|
+
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
5955
|
currentScanDiscounts = currentDiscounts.filter(function (discount) {
|
|
5659
5956
|
return discount === null || discount === void 0 ? void 0 : discount.isScan;
|
|
5660
5957
|
});
|
|
@@ -5667,34 +5964,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5667
5964
|
nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
|
|
5668
5965
|
shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
|
|
5669
5966
|
if (shouldSkipEmptyDiscountSync) {
|
|
5670
|
-
|
|
5967
|
+
_context47.next = 31;
|
|
5671
5968
|
break;
|
|
5672
5969
|
}
|
|
5673
5970
|
OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
|
|
5674
|
-
|
|
5675
|
-
return (_this$store$
|
|
5676
|
-
case
|
|
5677
|
-
|
|
5678
|
-
return (_this$store$
|
|
5679
|
-
case
|
|
5971
|
+
_context47.next = 29;
|
|
5972
|
+
return (_this$store$discount21 = this.store.discount) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.setOriginalDiscountList(nextDiscounts);
|
|
5973
|
+
case 29:
|
|
5974
|
+
_context47.next = 31;
|
|
5975
|
+
return (_this$store$discount22 = this.store.discount) === null || _this$store$discount22 === void 0 ? void 0 : _this$store$discount22.setDiscountList(nextDiscounts);
|
|
5976
|
+
case 31:
|
|
5680
5977
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
5681
|
-
|
|
5978
|
+
_context47.next = 34;
|
|
5682
5979
|
break;
|
|
5683
5980
|
}
|
|
5684
|
-
|
|
5981
|
+
_context47.next = 34;
|
|
5685
5982
|
return this.recalculateSummary({
|
|
5686
5983
|
createIfMissing: false
|
|
5687
5984
|
});
|
|
5688
|
-
case
|
|
5985
|
+
case 34:
|
|
5689
5986
|
this.persistTempOrder();
|
|
5690
|
-
return
|
|
5691
|
-
case
|
|
5987
|
+
return _context47.abrupt("return", nextTempOrder);
|
|
5988
|
+
case 36:
|
|
5692
5989
|
case "end":
|
|
5693
|
-
return
|
|
5990
|
+
return _context47.stop();
|
|
5694
5991
|
}
|
|
5695
|
-
},
|
|
5992
|
+
}, _callee44, this);
|
|
5696
5993
|
}));
|
|
5697
|
-
function hydrateTempOrderFromRecord(
|
|
5994
|
+
function hydrateTempOrderFromRecord(_x55, _x56) {
|
|
5698
5995
|
return _hydrateTempOrderFromRecord.apply(this, arguments);
|
|
5699
5996
|
}
|
|
5700
5997
|
return hydrateTempOrderFromRecord;
|
|
@@ -5808,11 +6105,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5808
6105
|
}, {
|
|
5809
6106
|
key: "normalizeTempOrderForRuntime",
|
|
5810
6107
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
5811
|
-
var
|
|
5812
|
-
var
|
|
6108
|
+
var _this32 = this;
|
|
6109
|
+
var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
|
|
6110
|
+
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
|
|
5813
6111
|
// ES 列表详情使用 id 表示订单主键;OS 详情态统一依赖 order_id 驱动操作按钮。
|
|
5814
|
-
if ((nextTempOrder.order_id === undefined || nextTempOrder.order_id === null) && (
|
|
5815
|
-
nextTempOrder.order_id =
|
|
6112
|
+
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) {
|
|
6113
|
+
nextTempOrder.order_id = runtimeRaw.id;
|
|
5816
6114
|
}
|
|
5817
6115
|
delete nextTempOrder.summary;
|
|
5818
6116
|
delete nextTempOrder.lastOrderInfo;
|
|
@@ -5831,12 +6129,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5831
6129
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
5832
6130
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
5833
6131
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
5834
|
-
return
|
|
6132
|
+
return _this32.normalizeHydratedOrderProduct(p, {
|
|
5835
6133
|
makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
|
|
5836
6134
|
});
|
|
5837
6135
|
}) : [];
|
|
5838
6136
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
5839
|
-
var booking =
|
|
6137
|
+
var booking = _this32.normalizeHydratedBookingHolder(b || {});
|
|
5840
6138
|
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
5841
6139
|
is_all: normalizeBookingIsAll(booking),
|
|
5842
6140
|
sub_type: normalizeBookingSubType(booking)
|
|
@@ -5902,6 +6200,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5902
6200
|
nextTempOrder.vouchers = raw.vouchers || [];
|
|
5903
6201
|
return nextTempOrder;
|
|
5904
6202
|
}
|
|
6203
|
+
}, {
|
|
6204
|
+
key: "isSyntheticDraftOrderIdForRuntime",
|
|
6205
|
+
value: function isSyntheticDraftOrderIdForRuntime(record, options) {
|
|
6206
|
+
var _options$isDraftOrder, _record$external_sale;
|
|
6207
|
+
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;
|
|
6208
|
+
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;
|
|
6209
|
+
var orderId = record === null || record === void 0 ? void 0 : record.order_id;
|
|
6210
|
+
return Boolean(isDraftOrder && orderId !== undefined && orderId !== null && orderId !== '' && externalSaleNumber !== undefined && externalSaleNumber !== null && externalSaleNumber !== '' && String(orderId) === String(externalSaleNumber));
|
|
6211
|
+
}
|
|
6212
|
+
}, {
|
|
6213
|
+
key: "withoutSyntheticDraftOrderIdForRuntime",
|
|
6214
|
+
value: function withoutSyntheticDraftOrderIdForRuntime(record, options) {
|
|
6215
|
+
if (!this.isSyntheticDraftOrderIdForRuntime(record, options)) return record;
|
|
6216
|
+
return _objectSpread(_objectSpread({}, record), {}, {
|
|
6217
|
+
order_id: null
|
|
6218
|
+
});
|
|
6219
|
+
}
|
|
5905
6220
|
}, {
|
|
5906
6221
|
key: "hydrateLinkedBookingIdentity",
|
|
5907
6222
|
value: function hydrateLinkedBookingIdentity(tempOrder) {
|
|
@@ -6006,7 +6321,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6006
6321
|
}, {
|
|
6007
6322
|
key: "normalizeHydratedOrderProduct",
|
|
6008
6323
|
value: function normalizeHydratedOrderProduct(product, options) {
|
|
6009
|
-
var
|
|
6324
|
+
var _this33 = this;
|
|
6010
6325
|
var row = _objectSpread({}, product || {});
|
|
6011
6326
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
6012
6327
|
row.num = row.product_quantity;
|
|
@@ -6014,7 +6329,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6014
6329
|
var productSku = ensureProductSku(row);
|
|
6015
6330
|
row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
|
|
6016
6331
|
option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
|
|
6017
|
-
return
|
|
6332
|
+
return _this33.normalizeHydratedProductOptionItem(optionItem || {});
|
|
6018
6333
|
}))
|
|
6019
6334
|
});
|
|
6020
6335
|
delete row["product_".concat('option', "_item")];
|
|
@@ -6051,27 +6366,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6051
6366
|
}, {
|
|
6052
6367
|
key: "getOrderInfo",
|
|
6053
6368
|
value: function () {
|
|
6054
|
-
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6369
|
+
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(order_id) {
|
|
6055
6370
|
var res;
|
|
6056
|
-
return _regeneratorRuntime().wrap(function
|
|
6057
|
-
while (1) switch (
|
|
6371
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context48) {
|
|
6372
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
6058
6373
|
case 0:
|
|
6059
|
-
|
|
6374
|
+
_context48.next = 2;
|
|
6060
6375
|
return this.request.get("/order/sales/".concat(order_id), {
|
|
6061
6376
|
with: ['products', 'bookings']
|
|
6062
6377
|
}, {
|
|
6063
6378
|
osServer: true
|
|
6064
6379
|
});
|
|
6065
6380
|
case 2:
|
|
6066
|
-
res =
|
|
6067
|
-
return
|
|
6381
|
+
res = _context48.sent;
|
|
6382
|
+
return _context48.abrupt("return", res);
|
|
6068
6383
|
case 4:
|
|
6069
6384
|
case "end":
|
|
6070
|
-
return
|
|
6385
|
+
return _context48.stop();
|
|
6071
6386
|
}
|
|
6072
|
-
},
|
|
6387
|
+
}, _callee45, this);
|
|
6073
6388
|
}));
|
|
6074
|
-
function getOrderInfo(
|
|
6389
|
+
function getOrderInfo(_x57) {
|
|
6075
6390
|
return _getOrderInfo.apply(this, arguments);
|
|
6076
6391
|
}
|
|
6077
6392
|
return getOrderInfo;
|