@pisell/pisellos 0.10.49 → 0.10.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/Discount/types.d.ts +2 -0
- package/dist/modules/FulfillmentTiming/index.d.ts +11 -0
- package/dist/modules/FulfillmentTiming/index.js +407 -0
- package/dist/modules/FulfillmentTiming/types.d.ts +67 -0
- package/dist/modules/FulfillmentTiming/types.js +1 -0
- package/dist/modules/OpenData/types.d.ts +6 -0
- package/dist/modules/Order/index.d.ts +19 -1
- package/dist/modules/Order/index.js +362 -217
- package/dist/modules/Order/pickupTiming.d.ts +46 -0
- package/dist/modules/Order/pickupTiming.js +53 -0
- package/dist/modules/Order/types.d.ts +11 -1
- package/dist/modules/Order/utils.d.ts +10 -0
- package/dist/modules/Order/utils.js +145 -85
- package/dist/modules/Rules/index.js +45 -26
- package/dist/modules/Rules/types.d.ts +4 -0
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +1 -0
- package/dist/server/modules/order/index.d.ts +8 -0
- package/dist/server/modules/order/index.js +506 -453
- package/dist/server/modules/order/types.d.ts +1 -0
- package/dist/server/utils/small-ticket.js +173 -95
- package/dist/solution/BaseSales/index.d.ts +23 -0
- package/dist/solution/BaseSales/index.js +1216 -1031
- package/dist/solution/BaseSales/pickupTiming.d.ts +37 -0
- package/dist/solution/BaseSales/pickupTiming.js +482 -0
- package/dist/solution/BaseSales/utils/parseSalesResponse.js +3 -0
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/utils/cartView.js +3 -1
- package/dist/solution/UnifiedBookingSales/index.d.ts +2 -0
- package/dist/solution/UnifiedBookingSales/index.js +583 -531
- package/lib/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/modules/Discount/types.d.ts +2 -0
- package/lib/modules/FulfillmentTiming/index.d.ts +11 -0
- package/lib/modules/FulfillmentTiming/index.js +359 -0
- package/lib/modules/FulfillmentTiming/types.d.ts +67 -0
- package/lib/modules/FulfillmentTiming/types.js +5 -0
- package/lib/modules/OpenData/types.d.ts +6 -0
- package/lib/modules/Order/index.d.ts +19 -1
- package/lib/modules/Order/index.js +120 -7
- package/lib/modules/Order/pickupTiming.d.ts +46 -0
- package/lib/modules/Order/pickupTiming.js +61 -0
- package/lib/modules/Order/types.d.ts +11 -1
- package/lib/modules/Order/utils.d.ts +10 -0
- package/lib/modules/Order/utils.js +58 -4
- package/lib/modules/Rules/index.js +24 -13
- package/lib/modules/Rules/types.d.ts +4 -0
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +11 -0
- package/lib/server/modules/order/index.d.ts +8 -0
- package/lib/server/modules/order/index.js +19 -0
- package/lib/server/modules/order/types.d.ts +1 -0
- package/lib/server/utils/small-ticket.js +93 -22
- package/lib/solution/BaseSales/index.d.ts +23 -0
- package/lib/solution/BaseSales/index.js +104 -1
- package/lib/solution/BaseSales/pickupTiming.d.ts +37 -0
- package/lib/solution/BaseSales/pickupTiming.js +222 -0
- package/lib/solution/BaseSales/utils/parseSalesResponse.js +3 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/utils/cartView.js +3 -1
- package/lib/solution/UnifiedBookingSales/index.d.ts +2 -0
- package/lib/solution/UnifiedBookingSales/index.js +20 -0
- package/package.json +1 -1
|
@@ -32,8 +32,9 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
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); }
|
|
33
33
|
import { BaseModule } from "../BaseModule";
|
|
34
34
|
import { OrderHooks } from "./types";
|
|
35
|
-
import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, ensureCartItemOriginHolder, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeOrderMetaList, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit,
|
|
35
|
+
import { composeLinePrice, generateDuration, getAllDiscountList, mergeRelationForms, ensureCartItemOriginHolder, buildSubmitPayload, createDefaultTempOrder, createDefaultOrderRulesHooks, createEmptySummary, createUuidV4, formatDateTime, isTempOrder, normalizeOrderMetaList, normalizeBookingIsAll, normalizeBookingSubType, mapPaymentItemsToOrderPayments, normalizeOrderProductDiscountList, resolveEffectivePerUnitDiscount, ensureProductSku, getProductSkuOptions, normalizeProductSkuOptions, sumOptionUnitPrice, clearTempOrderHolderAssignments, getOrderProductLineUid, indexOrderProductsByUid, calculateOrderProductsDeposit, collectPointCardSnapshotCodeCandidates, mergePointCardSnapshotCodes as _mergePointCardSnapshotCodes, buildVirtualCurrencySnapshotFromList, mergeOrderProductDisplayFields, resolveIsFormSubject, isMarkdownBundle } from "./utils";
|
|
36
36
|
import { isNormalProduct } from "../Product/utils";
|
|
37
|
+
import { buildPickupTimingBooking, isFulfillmentTimingBooking } from "./pickupTiming";
|
|
37
38
|
import dayjs from 'dayjs';
|
|
38
39
|
import { getDiscountLifecycleReason } from "../Discount/availability";
|
|
39
40
|
import { stripOsPrivatePayloadFields } from "../../utils/os-private-payload";
|
|
@@ -170,6 +171,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
170
171
|
_defineProperty(_assertThisInitialized(_this), "sessionStorageRestoreRecord", null);
|
|
171
172
|
/** 只允许当前订单最新的 prepare/config 请求回写客户资产态。 */
|
|
172
173
|
_defineProperty(_assertThisInitialized(_this), "customerWalletPrepareConfigEpoch", 0);
|
|
174
|
+
/** Payment 可能早于 prepare/config 返回;先按实例 ID 暂存卡号等待 Snapshot。 */
|
|
175
|
+
_defineProperty(_assertThisInitialized(_this), "pointCardSnapshotCodeCandidates", new Map());
|
|
173
176
|
_defineProperty(_assertThisInitialized(_this), "salesSummaryModuleName", void 0);
|
|
174
177
|
_defineProperty(_assertThisInitialized(_this), "rulesHooksOverride", void 0);
|
|
175
178
|
_defineProperty(_assertThisInitialized(_this), "moduleHooksOverride", void 0);
|
|
@@ -210,7 +213,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
210
213
|
_step2;
|
|
211
214
|
try {
|
|
212
215
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
213
|
-
var _item$type2, _ref, _ref2, _item$discount$resour, _item$discount, _item$discount$title, _item$discount2, _item$discount3, _item$discount$fixed_, _item$
|
|
216
|
+
var _item$type2, _ref, _ref2, _item$discount$resour, _item$discount, _item$discount$title, _item$discount2, _item$metadata, _item$discount3, _item$discount4, _item$discount$fixed_, _item$discount5, _item$discount6, _item$amount, _ref3, _item$discount$origin, _item$discount7, _ref4, _ref5, _item$metadata$num, _item$metadata2, _item$discount$produc, _item$discount8, _ref6, _ref7, _item$metadata$num2, _item$metadata3, _item$discount9, _ref8, _item$discount$discou, _item$discount10, _item$amount2, _item$amount3, _product$product_id, _product$is_charge_ta, _ref9, _product$original_pri, _ref10, _item$discount$discou2, _item$discount11, _item$discount$discou3, _item$discount12;
|
|
214
217
|
var item = _step2.value;
|
|
215
218
|
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;
|
|
216
219
|
if (!type || type === 'product') continue;
|
|
@@ -221,24 +224,31 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
221
224
|
var key = Number.isFinite(id) ? id : String(resourceId);
|
|
222
225
|
var title = (_item$discount$title = item === null || item === void 0 || (_item$discount2 = item.discount) === null || _item$discount2 === void 0 ? void 0 : _item$discount2.title) !== null && _item$discount$title !== void 0 ? _item$discount$title : {};
|
|
223
226
|
var amount = Number((item === null || item === void 0 ? void 0 : item.amount) || 0);
|
|
224
|
-
var
|
|
225
|
-
var
|
|
227
|
+
var encoded = (item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.encoded) || (item === null || item === void 0 ? void 0 : item.encoded) || (item === null || item === void 0 || (_item$discount3 = item.discount) === null || _item$discount3 === void 0 ? void 0 : _item$discount3.encoded) || '';
|
|
228
|
+
var discountCardType = item === null || item === void 0 || (_item$discount4 = item.discount) === null || _item$discount4 === void 0 ? void 0 : _item$discount4.discount_card_type;
|
|
229
|
+
var parValue = isDiscountCard ? discountCardType === 'fixed_amount' ? (_item$discount$fixed_ = item === null || item === void 0 || (_item$discount5 = item.discount) === null || _item$discount5 === void 0 ? void 0 : _item$discount5.fixed_amount) !== null && _item$discount$fixed_ !== void 0 ? _item$discount$fixed_ : item === null || item === void 0 ? void 0 : item.amount : item === null || item === void 0 || (_item$discount6 = item.discount) === null || _item$discount6 === void 0 ? void 0 : _item$discount6.percent : '0';
|
|
226
230
|
var detail = {
|
|
227
231
|
amount: String((_item$amount = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount !== void 0 ? _item$amount : '0'),
|
|
228
232
|
type: type,
|
|
229
233
|
resource_id: key,
|
|
230
234
|
title: title,
|
|
231
|
-
original_amount: String((_ref3 = (_item$discount$origin = item === null || item === void 0 || (_item$
|
|
232
|
-
num: Number((_ref4 = (_ref5 = (_item$metadata$num = item === null || item === void 0 || (_item$
|
|
235
|
+
original_amount: String((_ref3 = (_item$discount$origin = item === null || item === void 0 || (_item$discount7 = item.discount) === null || _item$discount7 === void 0 ? void 0 : _item$discount7.original_amount) !== null && _item$discount$origin !== void 0 ? _item$discount$origin : item === null || item === void 0 ? void 0 : item.amount) !== null && _ref3 !== void 0 ? _ref3 : '0'),
|
|
236
|
+
num: Number((_ref4 = (_ref5 = (_item$metadata$num = item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.num) !== null && _item$metadata$num !== void 0 ? _item$metadata$num : product === null || product === void 0 ? void 0 : product.num) !== null && _ref5 !== void 0 ? _ref5 : product === null || product === void 0 ? void 0 : product.product_quantity) !== null && _ref4 !== void 0 ? _ref4 : 1) || 1,
|
|
233
237
|
metadata: item === null || item === void 0 ? void 0 : item.metadata,
|
|
234
238
|
discount: _objectSpread(_objectSpread({}, (item === null || item === void 0 ? void 0 : item.discount) || {}), {}, {
|
|
235
|
-
product_id: (_item$discount$produc = item === null || item === void 0 || (_item$
|
|
239
|
+
product_id: (_item$discount$produc = item === null || item === void 0 || (_item$discount8 = item.discount) === null || _item$discount8 === void 0 ? void 0 : _item$discount8.product_id) !== null && _item$discount$produc !== void 0 ? _item$discount$produc : product === null || product === void 0 ? void 0 : product.product_id
|
|
236
240
|
}),
|
|
237
|
-
_num: Number((_ref6 = (_ref7 = (_item$metadata$num2 = item === null || item === void 0 || (_item$
|
|
241
|
+
_num: Number((_ref6 = (_ref7 = (_item$metadata$num2 = item === null || item === void 0 || (_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.num) !== null && _item$metadata$num2 !== void 0 ? _item$metadata$num2 : product === null || product === void 0 ? void 0 : product.num) !== null && _ref7 !== void 0 ? _ref7 : product === null || product === void 0 ? void 0 : product.product_quantity) !== null && _ref6 !== void 0 ? _ref6 : 1) || 1
|
|
238
242
|
};
|
|
239
243
|
var existed = discountMap.get(key);
|
|
240
244
|
if (existed) {
|
|
241
245
|
var _existed$limited_rela;
|
|
246
|
+
if (!existed.encoded && encoded) {
|
|
247
|
+
existed.encoded = encoded;
|
|
248
|
+
existed.metadata = _objectSpread(_objectSpread({}, existed.metadata), {}, {
|
|
249
|
+
encoded: encoded
|
|
250
|
+
});
|
|
251
|
+
}
|
|
242
252
|
existed.amount = Number(existed.amount || 0) + amount;
|
|
243
253
|
existed.used_par_value = String(Number(existed.used_par_value || 0) + amount);
|
|
244
254
|
if (!isDiscountCard) {
|
|
@@ -257,10 +267,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
257
267
|
discountMap.set(key, {
|
|
258
268
|
id: key,
|
|
259
269
|
product_name: '',
|
|
260
|
-
encoded:
|
|
261
|
-
code: '',
|
|
270
|
+
encoded: encoded,
|
|
271
|
+
code: (item === null || item === void 0 ? void 0 : item.code) || (item === null || item === void 0 || (_item$discount9 = item.discount) === null || _item$discount9 === void 0 ? void 0 : _item$discount9.code) || '',
|
|
272
|
+
metadata: {
|
|
273
|
+
encoded: encoded
|
|
274
|
+
},
|
|
262
275
|
tag: type,
|
|
263
|
-
product_id: (_ref8 = (_item$discount$discou = item === null || item === void 0 || (_item$
|
|
276
|
+
product_id: (_ref8 = (_item$discount$discou = item === null || item === void 0 || (_item$discount10 = item.discount) === null || _item$discount10 === void 0 ? void 0 : _item$discount10.discount_product_id) !== null && _item$discount$discou !== void 0 ? _item$discount$discou : product === null || product === void 0 ? void 0 : product.product_id) !== null && _ref8 !== void 0 ? _ref8 : 0,
|
|
264
277
|
relation_type: '',
|
|
265
278
|
par_value: String(parValue !== null && parValue !== void 0 ? parValue : '0'),
|
|
266
279
|
used_par_value: String((_item$amount2 = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount2 !== void 0 ? _item$amount2 : '0'),
|
|
@@ -293,8 +306,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
293
306
|
amount: amount,
|
|
294
307
|
discount: _objectSpread(_objectSpread({}, (item === null || item === void 0 ? void 0 : item.discount) || {}), {}, {
|
|
295
308
|
resource_id: key,
|
|
296
|
-
discount_product_id: (_ref10 = (_item$discount$discou2 = item === null || item === void 0 || (_item$
|
|
297
|
-
discount_calculation_mode: (_item$discount$discou3 = item === null || item === void 0 || (_item$
|
|
309
|
+
discount_product_id: (_ref10 = (_item$discount$discou2 = item === null || item === void 0 || (_item$discount11 = item.discount) === null || _item$discount11 === void 0 ? void 0 : _item$discount11.discount_product_id) !== null && _item$discount$discou2 !== void 0 ? _item$discount$discou2 : product === null || product === void 0 ? void 0 : product.product_id) !== null && _ref10 !== void 0 ? _ref10 : 0,
|
|
310
|
+
discount_calculation_mode: (_item$discount$discou3 = item === null || item === void 0 || (_item$discount12 = item.discount) === null || _item$discount12 === void 0 ? void 0 : _item$discount12.discount_calculation_mode) !== null && _item$discount$discou3 !== void 0 ? _item$discount$discou3 : 'item_level'
|
|
298
311
|
}),
|
|
299
312
|
applicableProductDetails: [detail],
|
|
300
313
|
appliedProductDetails: [detail]
|
|
@@ -1004,7 +1017,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1004
1017
|
_context6.next = 31;
|
|
1005
1018
|
return (_this$store$discount12 = this.store.discount) === null || _this$store$discount12 === void 0 ? void 0 : _this$store$discount12.setDiscountList(normalizedNewDiscountList);
|
|
1006
1019
|
case 31:
|
|
1007
|
-
|
|
1020
|
+
// 实际写回商品时沿用扫码试算的优先级,避免旧商品行的选卡覆盖本次扫码。
|
|
1021
|
+
this.applyDiscount({
|
|
1022
|
+
preferredEntitlementPassIds: withScanList.filter(function (discount) {
|
|
1023
|
+
return isEntitlementPass(discount);
|
|
1024
|
+
}).map(function (discount) {
|
|
1025
|
+
return discount.id;
|
|
1026
|
+
})
|
|
1027
|
+
});
|
|
1008
1028
|
_context6.next = 34;
|
|
1009
1029
|
return this.syncScannedDiscountsToOriginalDiscountList(this.getDiscountList());
|
|
1010
1030
|
case 34:
|
|
@@ -1093,7 +1113,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1093
1113
|
},
|
|
1094
1114
|
orderTotalAmount: Number(((_this$store$summary2 = this.store.summary) === null || _this$store$summary2 === void 0 ? void 0 : _this$store$summary2.total_amount) || 0)
|
|
1095
1115
|
}, {
|
|
1096
|
-
reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
|
|
1116
|
+
reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids,
|
|
1117
|
+
preferredEntitlementPassIds: options === null || options === void 0 ? void 0 : options.preferredEntitlementPassIds
|
|
1097
1118
|
});
|
|
1098
1119
|
if (result !== null && result !== void 0 && result.productList) {
|
|
1099
1120
|
var previousProductsByUid = indexOrderProductsByUid(tempOrder.products);
|
|
@@ -1698,9 +1719,59 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1698
1719
|
key: "clearCustomerWalletRuntimeState",
|
|
1699
1720
|
value: function clearCustomerWalletRuntimeState() {
|
|
1700
1721
|
this.customerWalletPrepareConfigEpoch += 1;
|
|
1722
|
+
this.pointCardSnapshotCodeCandidates.clear();
|
|
1701
1723
|
this.store.availableWalletIds = [];
|
|
1702
1724
|
this.store.virtualCurrencyList = [];
|
|
1703
1725
|
}
|
|
1726
|
+
}, {
|
|
1727
|
+
key: "rememberPointCardSnapshotCodeCandidates",
|
|
1728
|
+
value: function rememberPointCardSnapshotCodeCandidates(value) {
|
|
1729
|
+
var _this6 = this;
|
|
1730
|
+
collectPointCardSnapshotCodeCandidates(value).forEach(function (_ref18) {
|
|
1731
|
+
var id = _ref18.id,
|
|
1732
|
+
code = _ref18.code;
|
|
1733
|
+
if (!_this6.pointCardSnapshotCodeCandidates.has(id)) {
|
|
1734
|
+
_this6.pointCardSnapshotCodeCandidates.set(id, code);
|
|
1735
|
+
}
|
|
1736
|
+
});
|
|
1737
|
+
}
|
|
1738
|
+
}, {
|
|
1739
|
+
key: "getRememberedPointCardSnapshotCodeCandidates",
|
|
1740
|
+
value: function getRememberedPointCardSnapshotCodeCandidates() {
|
|
1741
|
+
return _toConsumableArray(this.pointCardSnapshotCodeCandidates).map(function (_ref19) {
|
|
1742
|
+
var _ref20 = _slicedToArray(_ref19, 2),
|
|
1743
|
+
id = _ref20[0],
|
|
1744
|
+
code = _ref20[1];
|
|
1745
|
+
return {
|
|
1746
|
+
id: id,
|
|
1747
|
+
code: code
|
|
1748
|
+
};
|
|
1749
|
+
});
|
|
1750
|
+
}
|
|
1751
|
+
}, {
|
|
1752
|
+
key: "getPointCardSnapshotOrderIdentityKey",
|
|
1753
|
+
value: function getPointCardSnapshotOrderIdentityKey(identity) {
|
|
1754
|
+
if (identity !== null && identity !== void 0 && identity.externalSaleNumber) {
|
|
1755
|
+
return "external:".concat(identity.externalSaleNumber);
|
|
1756
|
+
}
|
|
1757
|
+
if ((identity === null || identity === void 0 ? void 0 : identity.orderId) !== undefined && identity.orderId !== null) {
|
|
1758
|
+
return "order:".concat(identity.orderId);
|
|
1759
|
+
}
|
|
1760
|
+
if (identity !== null && identity !== void 0 && identity.localId) return "local:".concat(identity.localId);
|
|
1761
|
+
if (identity !== null && identity !== void 0 && identity.orderNumber) return "number:".concat(identity.orderNumber);
|
|
1762
|
+
return '';
|
|
1763
|
+
}
|
|
1764
|
+
}, {
|
|
1765
|
+
key: "isPointCardSnapshotMergeContextCurrent",
|
|
1766
|
+
value: function isPointCardSnapshotMergeContextCurrent(context) {
|
|
1767
|
+
var _context$customerId, _this$store$tempOrder4, _this$store$tempOrder5;
|
|
1768
|
+
if (!context) return true;
|
|
1769
|
+
if (context.customerId !== undefined && String((_context$customerId = context.customerId) !== null && _context$customerId !== void 0 ? _context$customerId : '') !== String((_this$store$tempOrder4 = (_this$store$tempOrder5 = this.store.tempOrder) === null || _this$store$tempOrder5 === void 0 ? void 0 : _this$store$tempOrder5.customer_id) !== null && _this$store$tempOrder4 !== void 0 ? _this$store$tempOrder4 : '')) {
|
|
1770
|
+
return false;
|
|
1771
|
+
}
|
|
1772
|
+
var expectedOrderKey = this.getPointCardSnapshotOrderIdentityKey(context.orderIdentity);
|
|
1773
|
+
return !expectedOrderKey || expectedOrderKey === this.getPointCardSnapshotOrderIdentityKey(this.getOrderIdentity());
|
|
1774
|
+
}
|
|
1704
1775
|
}, {
|
|
1705
1776
|
key: "writeCustomerWalletSnapshotsFromPrepareConfig",
|
|
1706
1777
|
value: function writeCustomerWalletSnapshotsFromPrepareConfig(params) {
|
|
@@ -1708,9 +1779,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1708
1779
|
var tempOrder = this.store.tempOrder;
|
|
1709
1780
|
if (!tempOrder) return;
|
|
1710
1781
|
if (String((_tempOrder$customer_i = tempOrder.customer_id) !== null && _tempOrder$customer_i !== void 0 ? _tempOrder$customer_i : '') !== String(params.customerId)) return;
|
|
1782
|
+
var currentOrderMetaList = normalizeOrderMetaList(tempOrder.order_meta_list);
|
|
1711
1783
|
var virtualCurrencyList = Array.isArray(params.virtualCurrencyList) ? params.virtualCurrencyList : [];
|
|
1712
|
-
|
|
1713
|
-
|
|
1784
|
+
var snapshotsWithExistingCodes = _mergePointCardSnapshotCodes(params.availableWalletPassList, currentOrderMetaList === null || currentOrderMetaList === void 0 ? void 0 : currentOrderMetaList.point_cards_snapshot);
|
|
1785
|
+
tempOrder.order_meta_list = _objectSpread(_objectSpread({}, currentOrderMetaList || {}), {}, {
|
|
1786
|
+
point_cards_snapshot: _mergePointCardSnapshotCodes(snapshotsWithExistingCodes, this.getRememberedPointCardSnapshotCodeCandidates()),
|
|
1714
1787
|
virtual_currency_snapshot: buildVirtualCurrencySnapshotFromList(virtualCurrencyList)
|
|
1715
1788
|
});
|
|
1716
1789
|
this.store.availableWalletIds = _toConsumableArray(params.availableWalletIds);
|
|
@@ -1718,6 +1791,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1718
1791
|
this.persistTempOrder();
|
|
1719
1792
|
this.saveDraftInBackground();
|
|
1720
1793
|
}
|
|
1794
|
+
|
|
1795
|
+
/**
|
|
1796
|
+
* 将 Payment WalletPass 返回的实例 code 回填到当前订单 Snapshot。
|
|
1797
|
+
* 这里只按资产 ID 补空值,不新增卡、不覆盖 prepare/config 冻结的余额。
|
|
1798
|
+
*/
|
|
1799
|
+
}, {
|
|
1800
|
+
key: "mergePointCardSnapshotCodes",
|
|
1801
|
+
value: function mergePointCardSnapshotCodes(walletPassList, context) {
|
|
1802
|
+
var tempOrder = this.store.tempOrder;
|
|
1803
|
+
var currentOrderMetaList = normalizeOrderMetaList(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.order_meta_list);
|
|
1804
|
+
var currentSnapshots = (currentOrderMetaList === null || currentOrderMetaList === void 0 ? void 0 : currentOrderMetaList.point_cards_snapshot) || [];
|
|
1805
|
+
if (!tempOrder || !this.isPointCardSnapshotMergeContextCurrent(context)) {
|
|
1806
|
+
return currentSnapshots;
|
|
1807
|
+
}
|
|
1808
|
+
this.rememberPointCardSnapshotCodeCandidates(walletPassList);
|
|
1809
|
+
if (!currentSnapshots.length) return currentSnapshots;
|
|
1810
|
+
var nextSnapshots = _mergePointCardSnapshotCodes(currentSnapshots, this.getRememberedPointCardSnapshotCodeCandidates());
|
|
1811
|
+
var hasChanged = nextSnapshots.some(function (snapshot, index) {
|
|
1812
|
+
var _currentSnapshots$ind;
|
|
1813
|
+
return snapshot.code !== ((_currentSnapshots$ind = currentSnapshots[index]) === null || _currentSnapshots$ind === void 0 ? void 0 : _currentSnapshots$ind.code);
|
|
1814
|
+
});
|
|
1815
|
+
if (!hasChanged) return currentSnapshots;
|
|
1816
|
+
tempOrder.order_meta_list = _objectSpread(_objectSpread({}, currentOrderMetaList || {}), {}, {
|
|
1817
|
+
point_cards_snapshot: nextSnapshots
|
|
1818
|
+
});
|
|
1819
|
+
this.persistTempOrder();
|
|
1820
|
+
this.saveDraftInBackground();
|
|
1821
|
+
return nextSnapshots;
|
|
1822
|
+
}
|
|
1721
1823
|
}, {
|
|
1722
1824
|
key: "createExternalSaleNumber",
|
|
1723
1825
|
value: function createExternalSaleNumber() {
|
|
@@ -1818,15 +1920,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1818
1920
|
}, {
|
|
1819
1921
|
key: "extractOrderIdFromSubmitResult",
|
|
1820
1922
|
value: function extractOrderIdFromSubmitResult(result) {
|
|
1821
|
-
var
|
|
1822
|
-
return (
|
|
1923
|
+
var _ref21, _ref22, _ref23, _result$data$order_id, _result$data, _result$data2;
|
|
1924
|
+
return (_ref21 = (_ref22 = (_ref23 = (_result$data$order_id = result === null || result === void 0 || (_result$data = result.data) === null || _result$data === void 0 ? void 0 : _result$data.order_id) !== null && _result$data$order_id !== void 0 ? _result$data$order_id : result === null || result === void 0 ? void 0 : result.order_id) !== null && _ref23 !== void 0 ? _ref23 : result === null || result === void 0 || (_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2.id) !== null && _ref22 !== void 0 ? _ref22 : result === null || result === void 0 ? void 0 : result.id) !== null && _ref21 !== void 0 ? _ref21 : null;
|
|
1823
1925
|
}
|
|
1824
1926
|
}, {
|
|
1825
1927
|
key: "calculatePaymentEffectiveAmount",
|
|
1826
1928
|
value: function calculatePaymentEffectiveAmount(payment) {
|
|
1827
|
-
var
|
|
1929
|
+
var _ref24, _payment$origin_amoun;
|
|
1828
1930
|
var amount = new Decimal(payment.amount || 0);
|
|
1829
|
-
var originAmount = new Decimal((
|
|
1931
|
+
var originAmount = new Decimal((_ref24 = (_payment$origin_amoun = payment.origin_amount) !== null && _payment$origin_amoun !== void 0 ? _payment$origin_amoun : payment.amount) !== null && _ref24 !== void 0 ? _ref24 : 0);
|
|
1830
1932
|
var serviceFee = new Decimal(payment.service_fee || 0);
|
|
1831
1933
|
// TODO: 后端允许 amount 表示顾客实际支付总额后,移除这个兼容分支。
|
|
1832
1934
|
var effectiveAmount = serviceFee.gt(0) && amount.eq(originAmount) ? amount.plus(serviceFee) : amount;
|
|
@@ -1836,23 +1938,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1836
1938
|
}, {
|
|
1837
1939
|
key: "calculatePaymentTotal",
|
|
1838
1940
|
value: function calculatePaymentTotal(payments) {
|
|
1839
|
-
var
|
|
1941
|
+
var _this7 = this;
|
|
1840
1942
|
return mapPaymentItemsToOrderPayments(payments, {
|
|
1841
1943
|
includeVoided: false
|
|
1842
1944
|
}).reduce(function (sum, payment) {
|
|
1843
1945
|
if (!isPaidPaymentRecord(payment)) return sum;
|
|
1844
|
-
return sum.plus(
|
|
1946
|
+
return sum.plus(_this7.calculatePaymentEffectiveAmount(payment));
|
|
1845
1947
|
}, new Decimal(0));
|
|
1846
1948
|
}
|
|
1847
1949
|
}, {
|
|
1848
1950
|
key: "calculateOrderPaidPaymentTotal",
|
|
1849
1951
|
value: function calculateOrderPaidPaymentTotal(payments) {
|
|
1850
|
-
var
|
|
1952
|
+
var _this8 = this;
|
|
1851
1953
|
return mapPaymentItemsToOrderPayments(payments, {
|
|
1852
1954
|
includeVoided: false
|
|
1853
1955
|
}).reduce(function (sum, payment) {
|
|
1854
1956
|
if (!isPaidPaymentRecord(payment)) return sum;
|
|
1855
|
-
return sum.plus(
|
|
1957
|
+
return sum.plus(_this8.calculatePaymentGapAmount(payment));
|
|
1856
1958
|
}, new Decimal(0));
|
|
1857
1959
|
}
|
|
1858
1960
|
}, {
|
|
@@ -1988,13 +2090,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1988
2090
|
}, {
|
|
1989
2091
|
key: "calculateDepositPaidAmount",
|
|
1990
2092
|
value: function calculateDepositPaidAmount(payments) {
|
|
1991
|
-
var
|
|
2093
|
+
var _this9 = this;
|
|
1992
2094
|
return (payments || []).reduce(function (sum, payment) {
|
|
1993
2095
|
var paymentRecord = payment;
|
|
1994
2096
|
if (!isPaidPaymentRecord(paymentRecord)) return sum;
|
|
1995
2097
|
var isDepositPayment = paymentRecord.type === 'deposit' || paymentRecord.order_payment_type === 'deposit';
|
|
1996
2098
|
if (!isDepositPayment) return sum;
|
|
1997
|
-
return sum.plus(
|
|
2099
|
+
return sum.plus(_this9.calculatePaymentGapAmount(paymentRecord));
|
|
1998
2100
|
}, new Decimal(0));
|
|
1999
2101
|
}
|
|
2000
2102
|
}, {
|
|
@@ -2031,28 +2133,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2031
2133
|
}, {
|
|
2032
2134
|
key: "getPaymentNumberDevicePrefixSync",
|
|
2033
2135
|
value: function getPaymentNumberDevicePrefixSync() {
|
|
2034
|
-
var
|
|
2136
|
+
var _this10 = this;
|
|
2035
2137
|
return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
|
|
2036
|
-
return
|
|
2138
|
+
return _this10.getPaymentNumberAppData(key);
|
|
2037
2139
|
});
|
|
2038
2140
|
}
|
|
2039
2141
|
}, {
|
|
2040
2142
|
key: "getPaymentNumberDevicePrefixAsync",
|
|
2041
2143
|
value: function getPaymentNumberDevicePrefixAsync() {
|
|
2042
|
-
var
|
|
2144
|
+
var _this11 = this;
|
|
2043
2145
|
return resolvePaymentNumberDevicePrefix(function (key) {
|
|
2044
|
-
return
|
|
2146
|
+
return _this11.getPaymentNumberAppData(key);
|
|
2045
2147
|
});
|
|
2046
2148
|
}
|
|
2047
2149
|
}, {
|
|
2048
2150
|
key: "normalizePaymentSource",
|
|
2049
2151
|
value: function normalizePaymentSource(payment, options) {
|
|
2050
|
-
var
|
|
2152
|
+
var _ref25, _paymentRecord$origin;
|
|
2051
2153
|
var paymentRecord = payment;
|
|
2052
2154
|
var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
|
|
2053
2155
|
var normalized = ensureOrderPaymentNumber(_objectSpread(_objectSpread({}, paymentRecord), {}, {
|
|
2054
2156
|
metadata: metadata,
|
|
2055
|
-
origin_amount: (
|
|
2157
|
+
origin_amount: (_ref25 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref25 !== void 0 ? _ref25 : '0.00'
|
|
2056
2158
|
}), (options === null || options === void 0 ? void 0 : options.devicePrefix) || this.getPaymentNumberDevicePrefixSync(), createUuidV4);
|
|
2057
2159
|
if (paymentRecord.status !== undefined) {
|
|
2058
2160
|
normalized.status = paymentRecord.status;
|
|
@@ -2171,16 +2273,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2171
2273
|
}, {
|
|
2172
2274
|
key: "calculatePaidPaymentSummary",
|
|
2173
2275
|
value: function calculatePaidPaymentSummary(payments) {
|
|
2174
|
-
var
|
|
2276
|
+
var _this12 = this;
|
|
2175
2277
|
return (payments || []).reduce(function (summary, payment) {
|
|
2176
2278
|
var paymentRecord = payment;
|
|
2177
2279
|
if (!isPaidPaymentRecord(paymentRecord)) return summary;
|
|
2178
2280
|
return {
|
|
2179
2281
|
customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
|
|
2180
|
-
orderPaidAmount: summary.orderPaidAmount.plus(
|
|
2181
|
-
gapPaidAmount: summary.gapPaidAmount.plus(
|
|
2182
|
-
payServiceChargeAmount: summary.payServiceChargeAmount.plus(
|
|
2183
|
-
roundingAmount: summary.roundingAmount.plus(
|
|
2282
|
+
orderPaidAmount: summary.orderPaidAmount.plus(_this12.calculatePaymentOrderAmount(paymentRecord)),
|
|
2283
|
+
gapPaidAmount: summary.gapPaidAmount.plus(_this12.calculatePaymentGapAmount(paymentRecord)),
|
|
2284
|
+
payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this12.calculatePaymentServiceFee(paymentRecord)),
|
|
2285
|
+
roundingAmount: summary.roundingAmount.plus(_this12.calculatePaymentRoundingAmount(paymentRecord))
|
|
2184
2286
|
};
|
|
2185
2287
|
}, {
|
|
2186
2288
|
customerPaidAmount: new Decimal(0),
|
|
@@ -2387,15 +2489,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2387
2489
|
}, {
|
|
2388
2490
|
key: "normalizeFingerprintValue",
|
|
2389
2491
|
value: function normalizeFingerprintValue(value) {
|
|
2390
|
-
var
|
|
2492
|
+
var _this13 = this;
|
|
2391
2493
|
if (Array.isArray(value)) {
|
|
2392
2494
|
return value.map(function (item) {
|
|
2393
|
-
return
|
|
2495
|
+
return _this13.normalizeFingerprintValue(item);
|
|
2394
2496
|
});
|
|
2395
2497
|
}
|
|
2396
2498
|
if (!value || _typeof(value) !== 'object') return value !== null && value !== void 0 ? value : '';
|
|
2397
2499
|
return Object.keys(value).sort().reduce(function (result, key) {
|
|
2398
|
-
result[key] =
|
|
2500
|
+
result[key] = _this13.normalizeFingerprintValue(value[key]);
|
|
2399
2501
|
return result;
|
|
2400
2502
|
}, {});
|
|
2401
2503
|
}
|
|
@@ -2408,9 +2510,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2408
2510
|
_product$payment_pric,
|
|
2409
2511
|
_sku$code,
|
|
2410
2512
|
_sku$barcode,
|
|
2411
|
-
|
|
2513
|
+
_ref26,
|
|
2412
2514
|
_sku$variant_id,
|
|
2413
|
-
|
|
2515
|
+
_this14 = this;
|
|
2414
2516
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
2415
2517
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
2416
2518
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -2438,37 +2540,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2438
2540
|
product_sku: this.normalizeFingerprintValue({
|
|
2439
2541
|
code: (_sku$code = sku.code) !== null && _sku$code !== void 0 ? _sku$code : '',
|
|
2440
2542
|
barcode: (_sku$barcode = sku.barcode) !== null && _sku$barcode !== void 0 ? _sku$barcode : '',
|
|
2441
|
-
variant_id: (
|
|
2543
|
+
variant_id: (_ref26 = (_sku$variant_id = sku.variant_id) !== null && _sku$variant_id !== void 0 ? _sku$variant_id : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref26 !== void 0 ? _ref26 : 0,
|
|
2442
2544
|
variant: sku.variant || [],
|
|
2443
2545
|
option: getProductSkuOptions(product || {}).map(function (option) {
|
|
2444
|
-
var
|
|
2546
|
+
var _ref27, _option$id, _option$option_group_, _ref28, _option$option_group_2, _option$num, _option$add_price;
|
|
2445
2547
|
return {
|
|
2446
|
-
id: (
|
|
2548
|
+
id: (_ref27 = (_option$id = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id !== void 0 ? _option$id : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref27 !== void 0 ? _ref27 : null,
|
|
2447
2549
|
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,
|
|
2448
|
-
option_group_item_id: (
|
|
2550
|
+
option_group_item_id: (_ref28 = (_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 && _ref28 !== void 0 ? _ref28 : null,
|
|
2449
2551
|
num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
|
|
2450
|
-
add_price:
|
|
2552
|
+
add_price: _this14.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)
|
|
2451
2553
|
};
|
|
2452
2554
|
})
|
|
2453
2555
|
}),
|
|
2454
2556
|
product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
|
|
2455
|
-
var
|
|
2557
|
+
var _ref29, _ref30, _bundle$bundle_produc, _ref31, _bundle$bundle_varian, _bundle$num, _bundle$price_type, _bundle$price_type_ex;
|
|
2456
2558
|
return {
|
|
2457
|
-
bundle_product_id: (
|
|
2458
|
-
bundle_variant_id: (
|
|
2559
|
+
bundle_product_id: (_ref29 = (_ref30 = (_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 && _ref30 !== void 0 ? _ref30 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref29 !== void 0 ? _ref29 : null,
|
|
2560
|
+
bundle_variant_id: (_ref31 = (_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 && _ref31 !== void 0 ? _ref31 : 0,
|
|
2459
2561
|
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),
|
|
2460
|
-
price:
|
|
2461
|
-
bundle_selling_price:
|
|
2562
|
+
price: _this14.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
|
|
2563
|
+
bundle_selling_price: _this14.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
|
|
2462
2564
|
price_type: (_bundle$price_type = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type !== void 0 ? _bundle$price_type : '',
|
|
2463
2565
|
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 : ''
|
|
2464
2566
|
};
|
|
2465
2567
|
})),
|
|
2466
2568
|
discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
2467
|
-
var
|
|
2569
|
+
var _ref32, _discount$type2, _ref33, _ref34, _discount$discount_id, _discount$discount;
|
|
2468
2570
|
return {
|
|
2469
|
-
type: (
|
|
2470
|
-
discount_id: (
|
|
2471
|
-
amount:
|
|
2571
|
+
type: (_ref32 = (_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 && _ref32 !== void 0 ? _ref32 : '',
|
|
2572
|
+
discount_id: (_ref33 = (_ref34 = (_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 && _ref34 !== void 0 ? _ref34 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref33 !== void 0 ? _ref33 : null,
|
|
2573
|
+
amount: _this14.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2472
2574
|
};
|
|
2473
2575
|
}))
|
|
2474
2576
|
};
|
|
@@ -2476,9 +2578,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2476
2578
|
}, {
|
|
2477
2579
|
key: "buildOrderProductsFingerprint",
|
|
2478
2580
|
value: function buildOrderProductsFingerprint(products) {
|
|
2479
|
-
var
|
|
2581
|
+
var _this15 = this;
|
|
2480
2582
|
var items = (products || []).map(function (product) {
|
|
2481
|
-
return
|
|
2583
|
+
return _this15.buildProductFingerprintItem(product);
|
|
2482
2584
|
});
|
|
2483
2585
|
items.sort(function (left, right) {
|
|
2484
2586
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -2491,16 +2593,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2491
2593
|
var _product$product_id3,
|
|
2492
2594
|
_product$product_vari2,
|
|
2493
2595
|
_product$num2,
|
|
2494
|
-
|
|
2596
|
+
_ref35,
|
|
2495
2597
|
_metadata$unique_iden,
|
|
2496
2598
|
_metadata$price_overr,
|
|
2497
2599
|
_metadata$is_manual_d,
|
|
2498
2600
|
_metadata$product_dis,
|
|
2499
2601
|
_sku$code2,
|
|
2500
2602
|
_sku$barcode2,
|
|
2501
|
-
|
|
2603
|
+
_ref36,
|
|
2502
2604
|
_sku$variant_id2,
|
|
2503
|
-
|
|
2605
|
+
_this16 = this;
|
|
2504
2606
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
2505
2607
|
var metadata = (product === null || product === void 0 ? void 0 : product.metadata) || {};
|
|
2506
2608
|
var discountTypes = ((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
@@ -2517,7 +2619,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2517
2619
|
extension_type: extensionType,
|
|
2518
2620
|
num: getSafeProductNum((_product$num2 = product === null || product === void 0 ? void 0 : product.num) !== null && _product$num2 !== void 0 ? _product$num2 : product === null || product === void 0 ? void 0 : product.product_quantity),
|
|
2519
2621
|
metadata: {
|
|
2520
|
-
unique_identification_number: (
|
|
2622
|
+
unique_identification_number: (_ref35 = (_metadata$unique_iden = metadata.unique_identification_number) !== null && _metadata$unique_iden !== void 0 ? _metadata$unique_iden : product === null || product === void 0 ? void 0 : product.unique_identification_number) !== null && _ref35 !== void 0 ? _ref35 : '',
|
|
2521
2623
|
price_override: (_metadata$price_overr = metadata.price_override) !== null && _metadata$price_overr !== void 0 ? _metadata$price_overr : '',
|
|
2522
2624
|
is_manual_discount: (_metadata$is_manual_d = metadata.is_manual_discount) !== null && _metadata$is_manual_d !== void 0 ? _metadata$is_manual_d : '',
|
|
2523
2625
|
product_discount_reason: (_metadata$product_dis = metadata.product_discount_reason) !== null && _metadata$product_dis !== void 0 ? _metadata$product_dis : ''
|
|
@@ -2525,47 +2627,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2525
2627
|
product_sku: this.normalizeFingerprintValue({
|
|
2526
2628
|
code: (_sku$code2 = sku.code) !== null && _sku$code2 !== void 0 ? _sku$code2 : '',
|
|
2527
2629
|
barcode: (_sku$barcode2 = sku.barcode) !== null && _sku$barcode2 !== void 0 ? _sku$barcode2 : '',
|
|
2528
|
-
variant_id: (
|
|
2630
|
+
variant_id: (_ref36 = (_sku$variant_id2 = sku.variant_id) !== null && _sku$variant_id2 !== void 0 ? _sku$variant_id2 : product === null || product === void 0 ? void 0 : product.product_variant_id) !== null && _ref36 !== void 0 ? _ref36 : 0,
|
|
2529
2631
|
variant: sku.variant || [],
|
|
2530
2632
|
option: getProductSkuOptions(product || {}).map(function (option) {
|
|
2531
|
-
var
|
|
2633
|
+
var _ref37, _option$id2, _option$option_group_3, _ref38, _option$option_group_4, _option$num2, _option$add_price2;
|
|
2532
2634
|
return {
|
|
2533
|
-
id: (
|
|
2635
|
+
id: (_ref37 = (_option$id2 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id2 !== void 0 ? _option$id2 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref37 !== void 0 ? _ref37 : null,
|
|
2534
2636
|
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,
|
|
2535
|
-
option_group_item_id: (
|
|
2637
|
+
option_group_item_id: (_ref38 = (_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 && _ref38 !== void 0 ? _ref38 : null,
|
|
2536
2638
|
num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
|
|
2537
|
-
add_price:
|
|
2639
|
+
add_price: _this16.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)
|
|
2538
2640
|
};
|
|
2539
2641
|
})
|
|
2540
2642
|
}),
|
|
2541
2643
|
product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
|
|
2542
|
-
var
|
|
2644
|
+
var _ref39, _bundle$bundle_id, _ref40, _bundle$bundle_group_, _ref41, _ref42, _bundle$bundle_produc2, _ref43, _bundle$bundle_varian2, _bundle$num2, _bundle$price_type2, _bundle$price_type_ex2;
|
|
2543
2645
|
return {
|
|
2544
|
-
bundle_id: (
|
|
2545
|
-
bundle_group_id: (
|
|
2546
|
-
bundle_product_id: (
|
|
2547
|
-
bundle_variant_id: (
|
|
2646
|
+
bundle_id: (_ref39 = (_bundle$bundle_id = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle === null || bundle === void 0 ? void 0 : bundle.id) !== null && _ref39 !== void 0 ? _ref39 : null,
|
|
2647
|
+
bundle_group_id: (_ref40 = (_bundle$bundle_group_ = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle === null || bundle === void 0 ? void 0 : bundle.group_id) !== null && _ref40 !== void 0 ? _ref40 : null,
|
|
2648
|
+
bundle_product_id: (_ref41 = (_ref42 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref42 !== void 0 ? _ref42 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref41 !== void 0 ? _ref41 : null,
|
|
2649
|
+
bundle_variant_id: (_ref43 = (_bundle$bundle_varian2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian2 !== void 0 ? _bundle$bundle_varian2 : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref43 !== void 0 ? _ref43 : 0,
|
|
2548
2650
|
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),
|
|
2549
2651
|
price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
|
|
2550
2652
|
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 : '',
|
|
2551
|
-
option:
|
|
2552
|
-
var
|
|
2653
|
+
option: _this16.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
|
|
2654
|
+
var _ref44, _option$id3, _option$option_group_5, _ref45, _option$option_group_6, _option$num3, _option$add_price3;
|
|
2553
2655
|
return {
|
|
2554
|
-
id: (
|
|
2656
|
+
id: (_ref44 = (_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 && _ref44 !== void 0 ? _ref44 : null,
|
|
2555
2657
|
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,
|
|
2556
|
-
option_group_item_id: (
|
|
2658
|
+
option_group_item_id: (_ref45 = (_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 && _ref45 !== void 0 ? _ref45 : null,
|
|
2557
2659
|
num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
|
|
2558
|
-
add_price:
|
|
2660
|
+
add_price: _this16.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)
|
|
2559
2661
|
};
|
|
2560
2662
|
}))
|
|
2561
2663
|
};
|
|
2562
2664
|
})),
|
|
2563
2665
|
discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
2564
|
-
var
|
|
2666
|
+
var _ref46, _discount$type4, _ref47, _ref48, _discount$discount_id2, _discount$discount2;
|
|
2565
2667
|
return {
|
|
2566
|
-
type: (
|
|
2567
|
-
discount_id: (
|
|
2568
|
-
amount:
|
|
2668
|
+
type: (_ref46 = (_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 && _ref46 !== void 0 ? _ref46 : '',
|
|
2669
|
+
discount_id: (_ref47 = (_ref48 = (_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 && _ref48 !== void 0 ? _ref48 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref47 !== void 0 ? _ref47 : null,
|
|
2670
|
+
amount: _this16.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2569
2671
|
};
|
|
2570
2672
|
}))
|
|
2571
2673
|
};
|
|
@@ -2573,9 +2675,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2573
2675
|
}, {
|
|
2574
2676
|
key: "buildOrderProductsStructuralFingerprint",
|
|
2575
2677
|
value: function buildOrderProductsStructuralFingerprint(products) {
|
|
2576
|
-
var
|
|
2678
|
+
var _this17 = this;
|
|
2577
2679
|
var items = (products || []).map(function (product) {
|
|
2578
|
-
return
|
|
2680
|
+
return _this17.buildProductStructuralFingerprintItem(product);
|
|
2579
2681
|
});
|
|
2580
2682
|
items.sort(function (left, right) {
|
|
2581
2683
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
@@ -2891,11 +2993,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2891
2993
|
}, {
|
|
2892
2994
|
key: "getOrderIdentity",
|
|
2893
2995
|
value: function getOrderIdentity() {
|
|
2894
|
-
var
|
|
2996
|
+
var _ref49, _ref50, _tempOrder$order_id, _tempOrder$_extend7;
|
|
2895
2997
|
var tempOrder = this.store.tempOrder;
|
|
2896
2998
|
if (!tempOrder) return null;
|
|
2897
2999
|
var lastOrderInfo = this.store.lastOrderInfo || {};
|
|
2898
|
-
var orderId = (
|
|
3000
|
+
var orderId = (_ref49 = (_ref50 = (_tempOrder$order_id = tempOrder.order_id) !== null && _tempOrder$order_id !== void 0 ? _tempOrder$order_id : lastOrderInfo.order_id) !== null && _ref50 !== void 0 ? _ref50 : lastOrderInfo.id) !== null && _ref49 !== void 0 ? _ref49 : null;
|
|
2899
3001
|
return {
|
|
2900
3002
|
localId: this.cacheId || ((_tempOrder$_extend7 = tempOrder._extend) === null || _tempOrder$_extend7 === void 0 ? void 0 : _tempOrder$_extend7.localId),
|
|
2901
3003
|
orderId: orderId,
|
|
@@ -3027,9 +3129,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3027
3129
|
}, {
|
|
3028
3130
|
key: "sanitizeTempOrderProducts",
|
|
3029
3131
|
value: function sanitizeTempOrderProducts(tempOrder) {
|
|
3030
|
-
var
|
|
3132
|
+
var _this18 = this;
|
|
3031
3133
|
tempOrder.products = (tempOrder.products || []).map(function (product) {
|
|
3032
|
-
return
|
|
3134
|
+
return _this18.sanitizeOrderProductForTempOrder(_this18.normalizeVirtualSettlementProductIfEnabled(product));
|
|
3033
3135
|
});
|
|
3034
3136
|
this.syncTempOrderSettlementState(tempOrder);
|
|
3035
3137
|
ensureUniqueProductLineUids(tempOrder);
|
|
@@ -3065,11 +3167,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3065
3167
|
}, {
|
|
3066
3168
|
key: "captureProductRuntime",
|
|
3067
3169
|
value: function captureProductRuntime(tempOrder, rawProduct, normalizedProduct, existedUid) {
|
|
3068
|
-
var _extend$productsByUid,
|
|
3170
|
+
var _extend$productsByUid, _ref51, _rawProduct$_origin;
|
|
3069
3171
|
var uid = existedUid || this.getProductUid(normalizedProduct);
|
|
3070
3172
|
var extend = this.ensureExtend(tempOrder);
|
|
3071
3173
|
var existed = ((_extend$productsByUid = extend.productsByUid) === null || _extend$productsByUid === void 0 ? void 0 : _extend$productsByUid[uid]) || {};
|
|
3072
|
-
var origin = (
|
|
3174
|
+
var origin = (_ref51 = (_rawProduct$_origin = rawProduct._origin) !== null && _rawProduct$_origin !== void 0 ? _rawProduct$_origin : normalizedProduct._origin) !== null && _ref51 !== void 0 ? _ref51 : existed.origin;
|
|
3073
3175
|
extend.productsByUid[uid] = _objectSpread(_objectSpread({}, existed), origin !== undefined ? {
|
|
3074
3176
|
origin: origin
|
|
3075
3177
|
} : {});
|
|
@@ -3149,7 +3251,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3149
3251
|
}, {
|
|
3150
3252
|
key: "syncLinkedBookingHoldersToProducts",
|
|
3151
3253
|
value: function syncLinkedBookingHoldersToProducts(tempOrder) {
|
|
3152
|
-
var
|
|
3254
|
+
var _this19 = this;
|
|
3153
3255
|
var bookings = tempOrder.bookings || [];
|
|
3154
3256
|
var products = tempOrder.products || [];
|
|
3155
3257
|
if (!bookings.length || !products.length) return;
|
|
@@ -3158,6 +3260,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3158
3260
|
bookings.forEach(function (booking) {
|
|
3159
3261
|
var _booking$metadata2, _booking$metadata3;
|
|
3160
3262
|
if (!booking || _typeof(booking) !== 'object') return;
|
|
3263
|
+
if (isFulfillmentTimingBooking(booking)) return;
|
|
3161
3264
|
var productUid = booking.product_uid || ((_booking$metadata2 = booking.metadata) === null || _booking$metadata2 === void 0 ? void 0 : _booking$metadata2.product_uid);
|
|
3162
3265
|
if (productUid !== undefined && productUid !== null && String(productUid) !== '') {
|
|
3163
3266
|
bookingByProductUid.set(String(productUid), booking);
|
|
@@ -3174,7 +3277,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3174
3277
|
var bookingUid = product.booking_uid || ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.booking_uid);
|
|
3175
3278
|
var linkedBooking = (productUid !== undefined && productUid !== null && String(productUid) !== '' ? bookingByProductUid.get(String(productUid)) : undefined) || (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '' ? bookingByBookingUid.get(String(bookingUid)) : undefined);
|
|
3176
3279
|
if (linkedBooking) {
|
|
3177
|
-
|
|
3280
|
+
_this19.setProductHolderFromBooking(product, linkedBooking);
|
|
3178
3281
|
}
|
|
3179
3282
|
});
|
|
3180
3283
|
}
|
|
@@ -3212,7 +3315,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3212
3315
|
}, {
|
|
3213
3316
|
key: "buildTempOrderHolderFromBookings",
|
|
3214
3317
|
value: function buildTempOrderHolderFromBookings(tempOrder) {
|
|
3215
|
-
var _baseHolder$customer_, _baseHolder,
|
|
3318
|
+
var _baseHolder$customer_, _baseHolder, _ref52, _baseHolder$form_id, _baseHolder2, _tempOrder$holder2, _baseHolder3, _this$otherParams2;
|
|
3216
3319
|
var holderRecords = [];
|
|
3217
3320
|
var holderNames = [];
|
|
3218
3321
|
var baseHolder = null;
|
|
@@ -3222,6 +3325,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3222
3325
|
try {
|
|
3223
3326
|
for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
|
|
3224
3327
|
var booking = _step18.value;
|
|
3328
|
+
if (isFulfillmentTimingBooking(booking)) continue;
|
|
3225
3329
|
var holder = booking !== null && booking !== void 0 && booking.holder && _typeof(booking.holder) === 'object' ? booking.holder : null;
|
|
3226
3330
|
if (!baseHolder && holder) {
|
|
3227
3331
|
baseHolder = holder;
|
|
@@ -3259,7 +3363,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3259
3363
|
}
|
|
3260
3364
|
var nextHolder = {
|
|
3261
3365
|
customer_id: (_baseHolder$customer_ = (_baseHolder = baseHolder) === null || _baseHolder === void 0 ? void 0 : _baseHolder.customer_id) !== null && _baseHolder$customer_ !== void 0 ? _baseHolder$customer_ : tempOrder.customer_id,
|
|
3262
|
-
form_id: (
|
|
3366
|
+
form_id: (_ref52 = (_baseHolder$form_id = (_baseHolder2 = baseHolder) === null || _baseHolder2 === void 0 ? void 0 : _baseHolder2.form_id) !== null && _baseHolder$form_id !== void 0 ? _baseHolder$form_id : (_tempOrder$holder2 = tempOrder.holder) === null || _tempOrder$holder2 === void 0 ? void 0 : _tempOrder$holder2.form_id) !== null && _ref52 !== void 0 ? _ref52 : 0,
|
|
3263
3367
|
form_record: holderRecords
|
|
3264
3368
|
};
|
|
3265
3369
|
if (holderNames.length) {
|
|
@@ -3280,7 +3384,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3280
3384
|
}, {
|
|
3281
3385
|
key: "syncTempOrderHolderFromBookings",
|
|
3282
3386
|
value: function syncTempOrderHolderFromBookings(tempOrder) {
|
|
3283
|
-
var bookings = tempOrder.bookings || []
|
|
3387
|
+
var bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
3388
|
+
return !isFulfillmentTimingBooking(booking);
|
|
3389
|
+
});
|
|
3284
3390
|
var hasHolderSource = bookings.some(function (booking) {
|
|
3285
3391
|
var _booking$metadata4;
|
|
3286
3392
|
return (booking === null || booking === void 0 ? void 0 : booking.holder) !== undefined || (booking === null || booking === void 0 || (_booking$metadata4 = booking.metadata) === null || _booking$metadata4 === void 0 ? void 0 : _booking$metadata4.holder_id) !== undefined;
|
|
@@ -3302,9 +3408,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3302
3408
|
}, {
|
|
3303
3409
|
key: "findBookingIndexByUniqueIdentificationNumber",
|
|
3304
3410
|
value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
|
|
3305
|
-
var
|
|
3411
|
+
var _this20 = this;
|
|
3306
3412
|
return (tempOrder.bookings || []).findIndex(function (booking) {
|
|
3307
|
-
return
|
|
3413
|
+
return _this20.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
|
|
3308
3414
|
});
|
|
3309
3415
|
}
|
|
3310
3416
|
}, {
|
|
@@ -3312,12 +3418,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3312
3418
|
value: function removeLinkedBookingsForProduct(tempOrder, product) {
|
|
3313
3419
|
var _product$metadata5,
|
|
3314
3420
|
_product$metadata6,
|
|
3315
|
-
|
|
3421
|
+
_this21 = this;
|
|
3316
3422
|
var productUid = (product === null || product === void 0 || (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
3317
3423
|
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid);
|
|
3318
3424
|
if (!productUid && !bookingUid) return;
|
|
3319
3425
|
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
3320
|
-
|
|
3426
|
+
if (isFulfillmentTimingBooking(booking)) return true;
|
|
3427
|
+
var currentBookingUid = _this21.getBookingUniqueIdentificationNumber(booking);
|
|
3321
3428
|
if (bookingUid && currentBookingUid === String(bookingUid)) return false;
|
|
3322
3429
|
if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
|
|
3323
3430
|
return true;
|
|
@@ -3364,7 +3471,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3364
3471
|
key: "recalculateSummary",
|
|
3365
3472
|
value: function () {
|
|
3366
3473
|
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(options) {
|
|
3367
|
-
var _this$otherParams3,
|
|
3474
|
+
var _this$otherParams3, _ref53, _salesSummaryResult$e;
|
|
3368
3475
|
var tempOrder, originalSnapshot, hasShopDiscountChanged, shouldReuseOriginalSnapshot, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummaryBase, emptySummaryWithDeposit, emptySummary, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
|
|
3369
3476
|
return _regeneratorRuntime().wrap(function _callee13$(_context15) {
|
|
3370
3477
|
while (1) switch (_context15.prev = _context15.next) {
|
|
@@ -3443,7 +3550,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3443
3550
|
roundingAmount = paidPaymentSummary.roundingAmount;
|
|
3444
3551
|
payServiceChargeAmount = paidPaymentSummary.payServiceChargeAmount;
|
|
3445
3552
|
hasSalesSummaryAmount = salesSummaryResult.expect_amount !== undefined || salesSummaryResult.total_amount !== undefined;
|
|
3446
|
-
expectAmount = hasSalesSummaryAmount ? new Decimal((
|
|
3553
|
+
expectAmount = hasSalesSummaryAmount ? new Decimal((_ref53 = (_salesSummaryResult$e = salesSummaryResult.expect_amount) !== null && _salesSummaryResult$e !== void 0 ? _salesSummaryResult$e : salesSummaryResult.total_amount) !== null && _ref53 !== void 0 ? _ref53 : 0) : null;
|
|
3447
3554
|
amountPaymentPatch = hasSalesSummaryAmount || !roundingAmount.eq(0) || !payServiceChargeAmount.eq(0) ? _objectSpread({
|
|
3448
3555
|
rounding_amount: roundingAmount.toFixed(2)
|
|
3449
3556
|
}, expectAmount ? {
|
|
@@ -3566,8 +3673,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3566
3673
|
}, {
|
|
3567
3674
|
key: "getTempOrderNote",
|
|
3568
3675
|
value: function getTempOrderNote() {
|
|
3569
|
-
var _this$store$
|
|
3570
|
-
return ((_this$store$
|
|
3676
|
+
var _this$store$tempOrder6;
|
|
3677
|
+
return ((_this$store$tempOrder6 = this.store.tempOrder) === null || _this$store$tempOrder6 === void 0 ? void 0 : _this$store$tempOrder6.note) || '';
|
|
3571
3678
|
}
|
|
3572
3679
|
}, {
|
|
3573
3680
|
key: "ensureSalesNotesRuntimeState",
|
|
@@ -3619,7 +3726,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3619
3726
|
}, {
|
|
3620
3727
|
key: "removeSalesNotesForMissingProductLines",
|
|
3621
3728
|
value: function removeSalesNotesForMissingProductLines(tempOrder) {
|
|
3622
|
-
var
|
|
3729
|
+
var _this22 = this;
|
|
3623
3730
|
var state = this.ensureSalesNotesRuntimeState(tempOrder);
|
|
3624
3731
|
if (!state.loaded || !Array.isArray(tempOrder.notes) || tempOrder.notes.length === 0) {
|
|
3625
3732
|
return;
|
|
@@ -3631,7 +3738,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3631
3738
|
return typeof uid === 'string' && uid.length > 0;
|
|
3632
3739
|
}));
|
|
3633
3740
|
var nextNotes = tempOrder.notes.filter(function (note) {
|
|
3634
|
-
var primary =
|
|
3741
|
+
var primary = _this22.getSalesNotePrimaryRelation(note);
|
|
3635
3742
|
if (!primary || primary.target_type !== 'order_detail') return true;
|
|
3636
3743
|
return remainingProductUids.has(primary.target_uuid);
|
|
3637
3744
|
});
|
|
@@ -3643,7 +3750,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3643
3750
|
key: "setSalesNoteOnTempOrder",
|
|
3644
3751
|
value: function setSalesNoteOnTempOrder(tempOrder, input) {
|
|
3645
3752
|
var _input$target,
|
|
3646
|
-
|
|
3753
|
+
_this23 = this,
|
|
3647
3754
|
_tempOrder$shop_order;
|
|
3648
3755
|
this.ensureSalesNotesLoadedForMutation(tempOrder);
|
|
3649
3756
|
var note_type = String(input.note_type || '').trim();
|
|
@@ -3667,7 +3774,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3667
3774
|
var notes = tempOrder.notes || [];
|
|
3668
3775
|
// 当前 allergy policy 固定同一商品行只保留一条;业务调用方不参与去重规则。
|
|
3669
3776
|
var existingIndex = policy.uniquePerPrimaryTarget ? notes.findIndex(function (note) {
|
|
3670
|
-
var primary =
|
|
3777
|
+
var primary = _this23.getSalesNotePrimaryRelation(note);
|
|
3671
3778
|
return note.note_type === note_type && (primary === null || primary === void 0 ? void 0 : primary.target_type) === 'order_detail' && primary.target_uuid === target_uuid;
|
|
3672
3779
|
}) : -1;
|
|
3673
3780
|
var existing = existingIndex >= 0 ? notes[existingIndex] : null;
|
|
@@ -3904,10 +4011,47 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3904
4011
|
}, {
|
|
3905
4012
|
key: "updateTempOrderServiceType",
|
|
3906
4013
|
value: function updateTempOrderServiceType(serviceType) {
|
|
4014
|
+
if (serviceType !== 'pick_up') {
|
|
4015
|
+
var tempOrder = this.ensureTempOrder();
|
|
4016
|
+
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
4017
|
+
return !isFulfillmentTimingBooking(booking);
|
|
4018
|
+
});
|
|
4019
|
+
}
|
|
3907
4020
|
return this.updateTempOrderShopServiceData({
|
|
3908
4021
|
service_type: serviceType
|
|
3909
4022
|
});
|
|
3910
4023
|
}
|
|
4024
|
+
}, {
|
|
4025
|
+
key: "getPickupTimingBooking",
|
|
4026
|
+
value: function getPickupTimingBooking() {
|
|
4027
|
+
var _this$store$tempOrder7;
|
|
4028
|
+
return (((_this$store$tempOrder7 = this.store.tempOrder) === null || _this$store$tempOrder7 === void 0 ? void 0 : _this$store$tempOrder7.bookings) || []).find(isFulfillmentTimingBooking) || null;
|
|
4029
|
+
}
|
|
4030
|
+
}, {
|
|
4031
|
+
key: "setPickupTimingBooking",
|
|
4032
|
+
value: function setPickupTimingBooking(input) {
|
|
4033
|
+
var tempOrder = this.ensureTempOrder();
|
|
4034
|
+
var bookings = tempOrder.bookings || [];
|
|
4035
|
+
var firstIndex = bookings.findIndex(isFulfillmentTimingBooking);
|
|
4036
|
+
var nextBooking = buildPickupTimingBooking(input, bookings[firstIndex]);
|
|
4037
|
+
// Keep the first row's identity and position; repair duplicate marked rows only.
|
|
4038
|
+
tempOrder.bookings = firstIndex === -1 ? [].concat(_toConsumableArray(bookings), [nextBooking]) : bookings.flatMap(function (booking, index) {
|
|
4039
|
+
return index === firstIndex ? [nextBooking] : isFulfillmentTimingBooking(booking) ? [] : [booking];
|
|
4040
|
+
});
|
|
4041
|
+
this.notifyTempOrderChanged();
|
|
4042
|
+
return nextBooking;
|
|
4043
|
+
}
|
|
4044
|
+
}, {
|
|
4045
|
+
key: "clearPickupTimingBooking",
|
|
4046
|
+
value: function clearPickupTimingBooking() {
|
|
4047
|
+
var _tempOrder$bookings;
|
|
4048
|
+
var tempOrder = this.store.tempOrder;
|
|
4049
|
+
if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$bookings = tempOrder.bookings) !== null && _tempOrder$bookings !== void 0 && _tempOrder$bookings.some(isFulfillmentTimingBooking))) return;
|
|
4050
|
+
tempOrder.bookings = tempOrder.bookings.filter(function (booking) {
|
|
4051
|
+
return !isFulfillmentTimingBooking(booking);
|
|
4052
|
+
});
|
|
4053
|
+
this.notifyTempOrderChanged();
|
|
4054
|
+
}
|
|
3911
4055
|
}, {
|
|
3912
4056
|
key: "updateTempOrderContactsInfo",
|
|
3913
4057
|
value: function updateTempOrderContactsInfo(contactsInfo) {
|
|
@@ -3919,17 +4063,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3919
4063
|
}, {
|
|
3920
4064
|
key: "buildTempOrderCustomer",
|
|
3921
4065
|
value: function buildTempOrderCustomer(params) {
|
|
3922
|
-
var
|
|
4066
|
+
var _ref54, _ref55, _ref56, _source$name, _ref57, _ref58, _ref59, _source$customer_name, _source$id, _source$customer_id, _ref60, _source$country_calli, _source$phone, _source$email;
|
|
3923
4067
|
if (!params.customerId) return null;
|
|
3924
4068
|
var source = params.source ? cloneDeep(params.source) : {};
|
|
3925
|
-
var name = (
|
|
3926
|
-
var customerName = (
|
|
4069
|
+
var name = (_ref54 = (_ref55 = (_ref56 = (_source$name = source.name) !== null && _source$name !== void 0 ? _source$name : source.display_name) !== null && _ref56 !== void 0 ? _ref56 : source.customerName) !== null && _ref55 !== void 0 ? _ref55 : source.customer_name) !== null && _ref54 !== void 0 ? _ref54 : params.customerName;
|
|
4070
|
+
var customerName = (_ref57 = (_ref58 = (_ref59 = (_source$customer_name = source.customer_name) !== null && _source$customer_name !== void 0 ? _source$customer_name : source.customerName) !== null && _ref59 !== void 0 ? _ref59 : source.display_name) !== null && _ref58 !== void 0 ? _ref58 : source.name) !== null && _ref57 !== void 0 ? _ref57 : params.customerName;
|
|
3927
4071
|
return _objectSpread(_objectSpread({}, source), {}, {
|
|
3928
4072
|
id: (_source$id = source.id) !== null && _source$id !== void 0 ? _source$id : params.customerId,
|
|
3929
4073
|
customer_id: (_source$customer_id = source.customer_id) !== null && _source$customer_id !== void 0 ? _source$customer_id : params.customerId,
|
|
3930
4074
|
name: String(name || ''),
|
|
3931
4075
|
customer_name: String(customerName || ''),
|
|
3932
|
-
country_calling_code: String((
|
|
4076
|
+
country_calling_code: String((_ref60 = (_source$country_calli = source.country_calling_code) !== null && _source$country_calli !== void 0 ? _source$country_calli : source.countryCallingCode) !== null && _ref60 !== void 0 ? _ref60 : params.countryCallingCode),
|
|
3933
4077
|
phone: String((_source$phone = source.phone) !== null && _source$phone !== void 0 ? _source$phone : params.phone),
|
|
3934
4078
|
email: String((_source$email = source.email) !== null && _source$email !== void 0 ? _source$email : params.email)
|
|
3935
4079
|
});
|
|
@@ -3949,15 +4093,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3949
4093
|
}, {
|
|
3950
4094
|
key: "productHasCustomerBoundDiscount",
|
|
3951
4095
|
value: function productHasCustomerBoundDiscount(product) {
|
|
3952
|
-
var
|
|
4096
|
+
var _this24 = this;
|
|
3953
4097
|
if (((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (discount) {
|
|
3954
|
-
return
|
|
4098
|
+
return _this24.isCustomerBoundDiscount(discount);
|
|
3955
4099
|
})) {
|
|
3956
4100
|
return true;
|
|
3957
4101
|
}
|
|
3958
4102
|
return ((product === null || product === void 0 ? void 0 : product.product_bundle) || []).some(function (bundle) {
|
|
3959
4103
|
return ((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []).some(function (discount) {
|
|
3960
|
-
return
|
|
4104
|
+
return _this24.isCustomerBoundDiscount(discount);
|
|
3961
4105
|
});
|
|
3962
4106
|
});
|
|
3963
4107
|
}
|
|
@@ -3966,18 +4110,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3966
4110
|
value: function shouldSkipDiscountCalculation(tempOrder) {
|
|
3967
4111
|
var _this$store$discount20,
|
|
3968
4112
|
_this$store$discount21,
|
|
3969
|
-
|
|
4113
|
+
_this25 = this;
|
|
3970
4114
|
if (this.hasActiveCustomerBoundDiscount) return false;
|
|
3971
4115
|
var discountList = ((_this$store$discount20 = this.store.discount) === null || _this$store$discount20 === void 0 || (_this$store$discount21 = _this$store$discount20.getDiscountList) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.call(_this$store$discount20)) || [];
|
|
3972
4116
|
if (discountList.length > 0) return false;
|
|
3973
4117
|
return !(tempOrder.products || []).some(function (product) {
|
|
3974
|
-
return
|
|
4118
|
+
return _this25.productHasCustomerBoundDiscount(product);
|
|
3975
4119
|
});
|
|
3976
4120
|
}
|
|
3977
4121
|
}, {
|
|
3978
4122
|
key: "clearCustomerBoundDiscounts",
|
|
3979
4123
|
value: function clearCustomerBoundDiscounts(tempOrder) {
|
|
3980
|
-
var
|
|
4124
|
+
var _this26 = this,
|
|
3981
4125
|
_discountModule$getDi,
|
|
3982
4126
|
_discountModule$getOr,
|
|
3983
4127
|
_discountModule$setDi,
|
|
@@ -3986,7 +4130,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3986
4130
|
var filterDiscountList = function filterDiscountList(discountList) {
|
|
3987
4131
|
if (!Array.isArray(discountList)) return [];
|
|
3988
4132
|
return discountList.filter(function (discount) {
|
|
3989
|
-
var shouldRemove =
|
|
4133
|
+
var shouldRemove = _this26.isCustomerBoundDiscount(discount);
|
|
3990
4134
|
if (shouldRemove) didRemoveCustomerBoundDiscount = true;
|
|
3991
4135
|
return !shouldRemove;
|
|
3992
4136
|
});
|
|
@@ -4013,12 +4157,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4013
4157
|
var currentDiscounts = ((_discountModule$getDi = discountModule.getDiscountList) === null || _discountModule$getDi === void 0 ? void 0 : _discountModule$getDi.call(discountModule)) || [];
|
|
4014
4158
|
var currentOriginalDiscounts = ((_discountModule$getOr = discountModule.getOriginalDiscountList) === null || _discountModule$getOr === void 0 ? void 0 : _discountModule$getOr.call(discountModule)) || [];
|
|
4015
4159
|
var nextDiscounts = currentDiscounts.filter(function (discount) {
|
|
4016
|
-
if (
|
|
4017
|
-
return !
|
|
4160
|
+
if (_this26.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
4161
|
+
return !_this26.isCustomerBoundDiscount(discount);
|
|
4018
4162
|
});
|
|
4019
4163
|
var nextOriginalDiscounts = currentOriginalDiscounts.filter(function (discount) {
|
|
4020
|
-
if (
|
|
4021
|
-
return !
|
|
4164
|
+
if (_this26.shouldKeepCustomerBoundDiscountAfterCustomerChange(discount)) return true;
|
|
4165
|
+
return !_this26.isCustomerBoundDiscount(discount);
|
|
4022
4166
|
});
|
|
4023
4167
|
void ((_discountModule$setDi = discountModule.setDiscountList) === null || _discountModule$setDi === void 0 ? void 0 : _discountModule$setDi.call(discountModule, nextDiscounts));
|
|
4024
4168
|
void ((_discountModule$setOr = discountModule.setOriginalDiscountList) === null || _discountModule$setOr === void 0 ? void 0 : _discountModule$setOr.call(discountModule, nextOriginalDiscounts));
|
|
@@ -4033,14 +4177,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4033
4177
|
}, {
|
|
4034
4178
|
key: "updateTempOrderCustomer",
|
|
4035
4179
|
value: function updateTempOrderCustomer(customer) {
|
|
4036
|
-
var _tempOrder$customer_i3,
|
|
4180
|
+
var _tempOrder$customer_i3, _ref61, _ref62, _customer$customer_id, _ref63, _ref64, _ref65, _customer$customer_na, _ref66, _customer$country_cal, _tempOrder$customer_i4;
|
|
4037
4181
|
var tempOrder = this.ensureTempOrder();
|
|
4038
4182
|
var previousCustomerId = (_tempOrder$customer_i3 = tempOrder.customer_id) !== null && _tempOrder$customer_i3 !== void 0 ? _tempOrder$customer_i3 : null;
|
|
4039
|
-
var customerId = (
|
|
4040
|
-
var customerName = (
|
|
4183
|
+
var customerId = (_ref61 = (_ref62 = (_customer$customer_id = customer.customer_id) !== null && _customer$customer_id !== void 0 ? _customer$customer_id : customer.customerId) !== null && _ref62 !== void 0 ? _ref62 : customer.id) !== null && _ref61 !== void 0 ? _ref61 : null;
|
|
4184
|
+
var customerName = (_ref63 = (_ref64 = (_ref65 = (_customer$customer_na = customer.customer_name) !== null && _customer$customer_na !== void 0 ? _customer$customer_na : customer.customerName) !== null && _ref65 !== void 0 ? _ref65 : customer.display_name) !== null && _ref64 !== void 0 ? _ref64 : customer.name) !== null && _ref63 !== void 0 ? _ref63 : '';
|
|
4041
4185
|
tempOrder.customer_id = customerId === null || customerId === undefined || customerId === '' ? null : Number(customerId);
|
|
4042
4186
|
tempOrder.customer_name = String(customerName || '');
|
|
4043
|
-
tempOrder.country_calling_code = String((
|
|
4187
|
+
tempOrder.country_calling_code = String((_ref66 = (_customer$country_cal = customer.country_calling_code) !== null && _customer$country_cal !== void 0 ? _customer$country_cal : customer.countryCallingCode) !== null && _ref66 !== void 0 ? _ref66 : '');
|
|
4044
4188
|
tempOrder.phone = String(customer.phone || '');
|
|
4045
4189
|
tempOrder.email = String(customer.email || '');
|
|
4046
4190
|
tempOrder.customer = this.buildTempOrderCustomer({
|
|
@@ -4121,8 +4265,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4121
4265
|
}, {
|
|
4122
4266
|
key: "getOrderCustomerSnapshot",
|
|
4123
4267
|
value: function getOrderCustomerSnapshot() {
|
|
4124
|
-
var _this$store$
|
|
4125
|
-
var snapshot = (_this$store$
|
|
4268
|
+
var _this$store$tempOrder8;
|
|
4269
|
+
var snapshot = (_this$store$tempOrder8 = this.store.tempOrder) === null || _this$store$tempOrder8 === void 0 || (_this$store$tempOrder8 = _this$store$tempOrder8._extend) === null || _this$store$tempOrder8 === void 0 ? void 0 : _this$store$tempOrder8.customerSnapshot;
|
|
4126
4270
|
return snapshot ? cloneDeep(snapshot) : null;
|
|
4127
4271
|
}
|
|
4128
4272
|
}, {
|
|
@@ -4182,10 +4326,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4182
4326
|
}, {
|
|
4183
4327
|
key: "setOrderPayments",
|
|
4184
4328
|
value: function setOrderPayments(payments) {
|
|
4185
|
-
var
|
|
4329
|
+
var _this27 = this;
|
|
4186
4330
|
var tempOrder = this.ensureTempOrder();
|
|
4187
4331
|
tempOrder.payments = mapPaymentItemsToOrderPayments((payments || []).map(function (payment) {
|
|
4188
|
-
return
|
|
4332
|
+
return _this27.normalizePaymentSource(payment, {
|
|
4189
4333
|
defaultPaid: false
|
|
4190
4334
|
});
|
|
4191
4335
|
}));
|
|
@@ -4240,7 +4384,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4240
4384
|
}, {
|
|
4241
4385
|
key: "addOrderPaymentWithDevicePrefix",
|
|
4242
4386
|
value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
|
|
4243
|
-
var
|
|
4387
|
+
var _this28 = this;
|
|
4244
4388
|
this.logInfo('addOrderPayment', {
|
|
4245
4389
|
payment: payment
|
|
4246
4390
|
});
|
|
@@ -4258,7 +4402,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4258
4402
|
void this.recalculateSummary({
|
|
4259
4403
|
createIfMissing: true
|
|
4260
4404
|
}).catch(function (error) {
|
|
4261
|
-
|
|
4405
|
+
_this28.logError('recalculate summary after addOrderPayment failed', {
|
|
4262
4406
|
error: error instanceof Error ? error.message : String(error)
|
|
4263
4407
|
});
|
|
4264
4408
|
});
|
|
@@ -4371,7 +4515,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4371
4515
|
}, {
|
|
4372
4516
|
key: "applyPaymentLifecycleChange",
|
|
4373
4517
|
value: function applyPaymentLifecycleChange(tempOrder, options) {
|
|
4374
|
-
var
|
|
4518
|
+
var _this29 = this;
|
|
4375
4519
|
this.updateTempOrderPaymentStatus(tempOrder);
|
|
4376
4520
|
if ((options === null || options === void 0 ? void 0 : options.persist) !== false) {
|
|
4377
4521
|
this.persistTempOrder();
|
|
@@ -4381,7 +4525,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4381
4525
|
void this.recalculateSummary({
|
|
4382
4526
|
createIfMissing: true
|
|
4383
4527
|
}).catch(function (error) {
|
|
4384
|
-
|
|
4528
|
+
_this29.logError("recalculate summary after ".concat(logContext, " failed"), {
|
|
4385
4529
|
error: error instanceof Error ? error.message : String(error)
|
|
4386
4530
|
});
|
|
4387
4531
|
});
|
|
@@ -4425,7 +4569,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4425
4569
|
}, {
|
|
4426
4570
|
key: "updateVoucherOrderPayments",
|
|
4427
4571
|
value: function updateVoucherOrderPayments(payments, options) {
|
|
4428
|
-
var
|
|
4572
|
+
var _this30 = this;
|
|
4429
4573
|
var tempOrder = this.ensureTempOrder();
|
|
4430
4574
|
var isOrderPaymentType = function isOrderPaymentType(value) {
|
|
4431
4575
|
return value === 'normal' || value === 'deposit';
|
|
@@ -4460,7 +4604,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4460
4604
|
});
|
|
4461
4605
|
};
|
|
4462
4606
|
var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
|
|
4463
|
-
return
|
|
4607
|
+
return _this30.normalizePaymentSource(normalizeVoucherPaymentStatus(withVoucherPaymentType(payment)), {
|
|
4464
4608
|
defaultPaid: false,
|
|
4465
4609
|
devicePrefix: options === null || options === void 0 ? void 0 : options.devicePrefix
|
|
4466
4610
|
});
|
|
@@ -4513,7 +4657,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4513
4657
|
void this.recalculateSummary({
|
|
4514
4658
|
createIfMissing: true
|
|
4515
4659
|
}).catch(function (error) {
|
|
4516
|
-
|
|
4660
|
+
_this30.logError('recalculate summary after updateVoucherOrderPayments failed', {
|
|
4517
4661
|
error: error instanceof Error ? error.message : String(error)
|
|
4518
4662
|
});
|
|
4519
4663
|
});
|
|
@@ -4571,7 +4715,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4571
4715
|
key: "shouldMergeProductToOrder",
|
|
4572
4716
|
value: function shouldMergeProductToOrder(params) {
|
|
4573
4717
|
var _this$orderHooks,
|
|
4574
|
-
|
|
4718
|
+
_this31 = this;
|
|
4575
4719
|
var onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
|
|
4576
4720
|
if (!onBeforeMergeProductToOrder) return true;
|
|
4577
4721
|
var result = onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
@@ -4579,7 +4723,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4579
4723
|
}));
|
|
4580
4724
|
if (result && _typeof(result) === 'object' && typeof result.then === 'function') {
|
|
4581
4725
|
return Promise.resolve(result).then(function (resolved) {
|
|
4582
|
-
return
|
|
4726
|
+
return _this31.normalizeShouldMergeProductResult(resolved);
|
|
4583
4727
|
});
|
|
4584
4728
|
}
|
|
4585
4729
|
return this.normalizeShouldMergeProductResult(result);
|
|
@@ -4628,7 +4772,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4628
4772
|
}, {
|
|
4629
4773
|
key: "assertAndLockProductSettlement",
|
|
4630
4774
|
value: function assertAndLockProductSettlement(tempOrder, product) {
|
|
4631
|
-
var
|
|
4775
|
+
var _ref67, _ref68, _product$selling_pric;
|
|
4632
4776
|
if (!this.isMultiCurrencySettlementEnabled()) return;
|
|
4633
4777
|
var currentKey = getTempOrderSettlementKey(tempOrder);
|
|
4634
4778
|
var incomingKey = getSettlementKey(getSelectedSettlementSnapshot(product)) || 'legal_currency';
|
|
@@ -4655,7 +4799,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4655
4799
|
}
|
|
4656
4800
|
applyTempOrderSettlementState(tempOrder, snapshot || {
|
|
4657
4801
|
settlement_type: 'legal_currency',
|
|
4658
|
-
price: (
|
|
4802
|
+
price: (_ref67 = (_ref68 = (_product$selling_pric = product.selling_price) !== null && _product$selling_pric !== void 0 ? _product$selling_pric : product.original_price) !== null && _ref68 !== void 0 ? _ref68 : product.payment_price) !== null && _ref67 !== void 0 ? _ref67 : 0,
|
|
4659
4803
|
unit_label: tempOrder.currency_code,
|
|
4660
4804
|
symbol: tempOrder.currency_symbol,
|
|
4661
4805
|
amount_format: tempOrder.currency_format
|
|
@@ -4780,7 +4924,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4780
4924
|
_metadata,
|
|
4781
4925
|
_productToAdd$metadat,
|
|
4782
4926
|
_origin,
|
|
4783
|
-
|
|
4927
|
+
_this32 = this;
|
|
4784
4928
|
var linked = booking ? this.createLinkedProductAndBooking({
|
|
4785
4929
|
product: product,
|
|
4786
4930
|
booking: booking
|
|
@@ -4816,26 +4960,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4816
4960
|
var isIncomingCustomItem = ((_productToAdd$metadat = productToAdd.metadata) === null || _productToAdd$metadat === void 0 || (_productToAdd$metadat = _productToAdd$metadat.origin) === null || _productToAdd$metadat === void 0 ? void 0 : _productToAdd$metadat.isCustomItem) === true || ((_origin = productToAdd._origin) === null || _origin === void 0 ? void 0 : _origin.isCustomItem) === true;
|
|
4817
4961
|
var shouldForceNewLine = disableMerge || !!booking || hasIncomingGoodPass || isIncomingPersistedEntitlementPass || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
|
|
4818
4962
|
var matchedIndex = shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
4819
|
-
if (
|
|
4820
|
-
var isRuntimeEntitlementPass =
|
|
4963
|
+
if (_this32.hasGoodPassDiscount(item)) return false;
|
|
4964
|
+
var isRuntimeEntitlementPass = _this32.isRuntimeEntitlementAppend(item, tempOrder);
|
|
4821
4965
|
if (isIncomingEntitlementAppend !== isRuntimeEntitlementPass) {
|
|
4822
4966
|
return false;
|
|
4823
4967
|
}
|
|
4824
|
-
if (isIncomingEntitlementAppend &&
|
|
4968
|
+
if (isIncomingEntitlementAppend && _this32.isPersistedProductLine(item)) {
|
|
4825
4969
|
return false;
|
|
4826
4970
|
}
|
|
4827
|
-
var hasExistingProductNote =
|
|
4971
|
+
var hasExistingProductNote = _this32.hasOrderProductLineNote(item);
|
|
4828
4972
|
if ((hasIncomingProductNote || hasExistingProductNote) && (!isRuntimeEntitlementPass || String(normalizedIncoming.note || '').trim() !== String(item.note || '').trim())) {
|
|
4829
4973
|
return false;
|
|
4830
4974
|
}
|
|
4831
4975
|
var hasExistingManualProductDiscount = isManualProductDiscountProduct(item);
|
|
4832
|
-
if (isRuntimeEntitlementPass && !
|
|
4976
|
+
if (isRuntimeEntitlementPass && !_this32.hasSameEntitlementMergePriceConfig(normalizedIncoming, item)) {
|
|
4833
4977
|
return false;
|
|
4834
4978
|
}
|
|
4835
4979
|
if ((hasIncomingManualProductDiscount || hasExistingManualProductDiscount) && !isRuntimeEntitlementPass) {
|
|
4836
4980
|
return false;
|
|
4837
4981
|
}
|
|
4838
|
-
if (
|
|
4982
|
+
if (_this32.isPersistedProductLine(item)) return false;
|
|
4839
4983
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
4840
4984
|
if (item.product_variant_id !== productToAdd.product_variant_id) return false;
|
|
4841
4985
|
var existedFingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
|
|
@@ -4846,7 +4990,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4846
4990
|
var commitProductLine = function commitProductLine(shouldMerge) {
|
|
4847
4991
|
var committedProduct;
|
|
4848
4992
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
4849
|
-
|
|
4993
|
+
_this32.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
4850
4994
|
if (linked) {
|
|
4851
4995
|
normalizedIncoming.booking_uid = linked.bookingUid;
|
|
4852
4996
|
normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, {
|
|
@@ -4864,7 +5008,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4864
5008
|
var _targetProduct$metada;
|
|
4865
5009
|
var targetProduct = matchedProduct;
|
|
4866
5010
|
var targetUid = (_targetProduct$metada = targetProduct.metadata) === null || _targetProduct$metada === void 0 ? void 0 : _targetProduct$metada.unique_identification_number;
|
|
4867
|
-
var normalizedProduct =
|
|
5011
|
+
var normalizedProduct = _this32.normalizeVirtualSettlementProductIfEnabled(mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
|
|
4868
5012
|
metadata: _objectSpread(_objectSpread({}, productToAdd.metadata || {}), {}, {
|
|
4869
5013
|
unique_identification_number: targetUid
|
|
4870
5014
|
})
|
|
@@ -4887,7 +5031,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4887
5031
|
order_detail_id: targetProduct.order_detail_id,
|
|
4888
5032
|
num: nextNum
|
|
4889
5033
|
});
|
|
4890
|
-
|
|
5034
|
+
_this32.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
|
|
4891
5035
|
committedProduct = tempOrder.products[matchedIndex];
|
|
4892
5036
|
if (matchedIndex !== tempOrder.products.length - 1) {
|
|
4893
5037
|
var mergedProduct = tempOrder.products[matchedIndex];
|
|
@@ -4925,14 +5069,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4925
5069
|
}, {
|
|
4926
5070
|
key: "createSplitBookingLine",
|
|
4927
5071
|
value: function createSplitBookingLine(product, booking, index, splitCount) {
|
|
4928
|
-
var _booking$metadata6,
|
|
5072
|
+
var _booking$metadata6, _ref69, _ref70, _bookingHolder$form_r, _booking$metadata7, _product$metadata10, _bookingHolder$name, _singleBooking$metada;
|
|
4929
5073
|
var singleLine = cloneDeep(product);
|
|
4930
5074
|
singleLine.num = 1;
|
|
4931
5075
|
delete singleLine.product_quantity;
|
|
4932
5076
|
var singleBooking = cloneDeep(booking);
|
|
4933
5077
|
var bookingHolder = booking !== null && booking !== void 0 && booking.holder && _typeof(booking.holder) === 'object' ? booking.holder : null;
|
|
4934
5078
|
var metadataHolder = booking !== null && booking !== void 0 && (_booking$metadata6 = booking.metadata) !== null && _booking$metadata6 !== void 0 && _booking$metadata6.holder && _typeof(booking.metadata.holder) === 'object' ? booking.metadata.holder : null;
|
|
4935
|
-
var rawHolderIds = (
|
|
5079
|
+
var rawHolderIds = (_ref69 = (_ref70 = (_bookingHolder$form_r = bookingHolder === null || bookingHolder === void 0 ? void 0 : bookingHolder.form_record) !== null && _bookingHolder$form_r !== void 0 ? _bookingHolder$form_r : booking === null || booking === void 0 || (_booking$metadata7 = booking.metadata) === null || _booking$metadata7 === void 0 ? void 0 : _booking$metadata7.holder_id) !== null && _ref70 !== void 0 ? _ref70 : metadataHolder === null || metadataHolder === void 0 ? void 0 : metadataHolder.form_record) !== null && _ref69 !== void 0 ? _ref69 : product === null || product === void 0 || (_product$metadata10 = product.metadata) === null || _product$metadata10 === void 0 ? void 0 : _product$metadata10.holder_id;
|
|
4936
5080
|
var holderIds = (Array.isArray(rawHolderIds) ? rawHolderIds : [rawHolderIds]).map(function (holderId) {
|
|
4937
5081
|
return holderId && _typeof(holderId) === 'object' ? holderId.form_record_id : holderId;
|
|
4938
5082
|
}).filter(function (holderId) {
|
|
@@ -4997,8 +5141,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4997
5141
|
key: "addProductToOrder",
|
|
4998
5142
|
value: (function () {
|
|
4999
5143
|
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(product, booking, options) {
|
|
5000
|
-
var
|
|
5001
|
-
var tempOrder, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex,
|
|
5144
|
+
var _this33 = this;
|
|
5145
|
+
var tempOrder, salesNoteDrafts, mutationSnapshot, attachSalesNoteDrafts, rollbackProductAndNotesMutation, insertAfterProductUid, anchorIndex, insertAtIndex, _ref71, _productRecord$num, productRecord, splitCount, i, splitLine, committedProduct, _committedProduct, _committedProduct2;
|
|
5002
5146
|
return _regeneratorRuntime().wrap(function _callee23$(_context25) {
|
|
5003
5147
|
while (1) switch (_context25.prev = _context25.next) {
|
|
5004
5148
|
case 0:
|
|
@@ -5026,7 +5170,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5026
5170
|
throw new Error('[Order Notes] 商品行缺少 unique_identification_number');
|
|
5027
5171
|
}
|
|
5028
5172
|
salesNoteDrafts.forEach(function (draft) {
|
|
5029
|
-
|
|
5173
|
+
_this33.setSalesNoteOnTempOrder(tempOrder, {
|
|
5030
5174
|
note_type: draft.note_type,
|
|
5031
5175
|
target: {
|
|
5032
5176
|
target_type: 'order_detail',
|
|
@@ -5056,7 +5200,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5056
5200
|
break;
|
|
5057
5201
|
}
|
|
5058
5202
|
productRecord = product;
|
|
5059
|
-
splitCount = getSafeProductNum((
|
|
5203
|
+
splitCount = getSafeProductNum((_ref71 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref71 !== void 0 ? _ref71 : 1);
|
|
5060
5204
|
if (!(splitCount > 1)) {
|
|
5061
5205
|
_context25.next = 27;
|
|
5062
5206
|
break;
|
|
@@ -5161,7 +5305,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5161
5305
|
key: "addProductsToOrder",
|
|
5162
5306
|
value: (function () {
|
|
5163
5307
|
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(items, options) {
|
|
5164
|
-
var tempOrder, _iterator20, _step20, item, product, booking,
|
|
5308
|
+
var tempOrder, _iterator20, _step20, item, product, booking, _ref72, _productRecord$num2, productRecord, splitCount, i, splitLine, _appendResult, appendResult;
|
|
5165
5309
|
return _regeneratorRuntime().wrap(function _callee24$(_context26) {
|
|
5166
5310
|
while (1) switch (_context26.prev = _context26.next) {
|
|
5167
5311
|
case 0:
|
|
@@ -5193,7 +5337,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5193
5337
|
break;
|
|
5194
5338
|
}
|
|
5195
5339
|
productRecord = product;
|
|
5196
|
-
splitCount = getSafeProductNum((
|
|
5340
|
+
splitCount = getSafeProductNum((_ref72 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref72 !== void 0 ? _ref72 : 1);
|
|
5197
5341
|
if (!(splitCount > 1)) {
|
|
5198
5342
|
_context26.next = 26;
|
|
5199
5343
|
break;
|
|
@@ -5306,26 +5450,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5306
5450
|
}, {
|
|
5307
5451
|
key: "hasSameEntitlementMergePriceConfig",
|
|
5308
5452
|
value: function hasSameEntitlementMergePriceConfig(incoming, existing) {
|
|
5309
|
-
var
|
|
5453
|
+
var _this34 = this;
|
|
5310
5454
|
var buildPriceConfig = function buildPriceConfig(product) {
|
|
5311
5455
|
var metadata = product.metadata || {};
|
|
5312
5456
|
var bundle = (product.product_bundle || []).map(function (item) {
|
|
5313
|
-
var
|
|
5457
|
+
var _ref73, _item$bundle_id, _ref74, _ref75, _item$bundle_product_, _ref76, _item$bundle_variant_, _ref77, _item$price_type, _ref78, _item$price_type_ext;
|
|
5314
5458
|
return {
|
|
5315
|
-
bundle_id: (
|
|
5316
|
-
bundle_product_id: (
|
|
5317
|
-
bundle_variant_id: (
|
|
5318
|
-
price_type: (
|
|
5319
|
-
price_type_ext: (
|
|
5459
|
+
bundle_id: (_ref73 = (_item$bundle_id = item.bundle_id) !== null && _item$bundle_id !== void 0 ? _item$bundle_id : item.id) !== null && _ref73 !== void 0 ? _ref73 : null,
|
|
5460
|
+
bundle_product_id: (_ref74 = (_ref75 = (_item$bundle_product_ = item.bundle_product_id) !== null && _item$bundle_product_ !== void 0 ? _item$bundle_product_ : item._bundle_product_id) !== null && _ref75 !== void 0 ? _ref75 : item.product_id) !== null && _ref74 !== void 0 ? _ref74 : null,
|
|
5461
|
+
bundle_variant_id: (_ref76 = (_item$bundle_variant_ = item.bundle_variant_id) !== null && _item$bundle_variant_ !== void 0 ? _item$bundle_variant_ : item.product_variant_id) !== null && _ref76 !== void 0 ? _ref76 : 0,
|
|
5462
|
+
price_type: (_ref77 = (_item$price_type = item.price_type) !== null && _item$price_type !== void 0 ? _item$price_type : item.custom_price_type) !== null && _ref77 !== void 0 ? _ref77 : '',
|
|
5463
|
+
price_type_ext: (_ref78 = (_item$price_type_ext = item.price_type_ext) !== null && _item$price_type_ext !== void 0 ? _item$price_type_ext : item.custom_price_type_ext) !== null && _ref78 !== void 0 ? _ref78 : ''
|
|
5320
5464
|
};
|
|
5321
5465
|
}).sort(function (left, right) {
|
|
5322
5466
|
return JSON.stringify(left).localeCompare(JSON.stringify(right));
|
|
5323
5467
|
});
|
|
5324
5468
|
return JSON.stringify({
|
|
5325
|
-
original_price:
|
|
5326
|
-
source_product_price:
|
|
5327
|
-
main_product_original_price:
|
|
5328
|
-
price_override:
|
|
5469
|
+
original_price: _this34.normalizeFingerprintMoney(product.original_price),
|
|
5470
|
+
source_product_price: _this34.normalizeFingerprintMoney(metadata.source_product_price),
|
|
5471
|
+
main_product_original_price: _this34.normalizeFingerprintMoney(metadata.main_product_original_price),
|
|
5472
|
+
price_override: _this34.normalizeFingerprintMoney(metadata.price_override),
|
|
5329
5473
|
is_manual_discount: Boolean(metadata.is_manual_discount),
|
|
5330
5474
|
bundle: bundle
|
|
5331
5475
|
});
|
|
@@ -5335,24 +5479,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5335
5479
|
}, {
|
|
5336
5480
|
key: "getBundleRuntimeIdentity",
|
|
5337
5481
|
value: function getBundleRuntimeIdentity(bundle) {
|
|
5338
|
-
var
|
|
5482
|
+
var _ref79, _bundle$bundle_id2, _ref80, _bundle$bundle_group_2, _ref81, _ref82, _bundle$bundle_produc3, _ref83, _bundle$bundle_varian3;
|
|
5339
5483
|
if (!bundle || _typeof(bundle) !== 'object') return '';
|
|
5340
|
-
return [(
|
|
5484
|
+
return [(_ref79 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref79 !== void 0 ? _ref79 : '', (_ref80 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref80 !== void 0 ? _ref80 : '', (_ref81 = (_ref82 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref82 !== void 0 ? _ref82 : bundle.product_id) !== null && _ref81 !== void 0 ? _ref81 : '', (_ref83 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref83 !== void 0 ? _ref83 : 0].join('|');
|
|
5341
5485
|
}
|
|
5342
5486
|
}, {
|
|
5343
5487
|
key: "preservePersistedBundlePriceFields",
|
|
5344
5488
|
value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
|
|
5345
|
-
var
|
|
5489
|
+
var _this35 = this;
|
|
5346
5490
|
if (!Array.isArray(nextBundles)) return nextBundles;
|
|
5347
5491
|
if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
|
|
5348
5492
|
var previousByIdentity = new Map();
|
|
5349
5493
|
previousBundles.forEach(function (bundle) {
|
|
5350
|
-
var identity =
|
|
5494
|
+
var identity = _this35.getBundleRuntimeIdentity(bundle);
|
|
5351
5495
|
if (identity) previousByIdentity.set(identity, bundle);
|
|
5352
5496
|
});
|
|
5353
5497
|
return nextBundles.map(function (bundle, index) {
|
|
5354
5498
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
5355
|
-
var previous = previousByIdentity.get(
|
|
5499
|
+
var previous = previousByIdentity.get(_this35.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
5356
5500
|
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
5357
5501
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
|
|
5358
5502
|
cover: previous.cover
|
|
@@ -5397,8 +5541,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5397
5541
|
if (unique_identification_number !== undefined) {
|
|
5398
5542
|
var targetUid = String(unique_identification_number);
|
|
5399
5543
|
productIndex = tempOrder.products.findIndex(function (item) {
|
|
5400
|
-
var _item$
|
|
5401
|
-
return String(((_item$
|
|
5544
|
+
var _item$metadata4;
|
|
5545
|
+
return String(((_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.unique_identification_number) || item.unique_identification_number || '') === targetUid;
|
|
5402
5546
|
});
|
|
5403
5547
|
}
|
|
5404
5548
|
if (productIndex === -1) {
|
|
@@ -5488,13 +5632,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5488
5632
|
delete nextProduct.metadata.main_product_original_price;
|
|
5489
5633
|
delete nextProduct.metadata.price_schema_version;
|
|
5490
5634
|
} else if (callerChangesLineConfiguration && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
5491
|
-
var
|
|
5635
|
+
var _ref84, _targetProduct$metada10, _targetProduct$metada11, _ref85, _targetProduct$metada12, _targetProduct$metada13, _targetProduct$metada14;
|
|
5492
5636
|
// 仅 option / bundle 变化时,保留历史 source 和主商品折扣金额,
|
|
5493
5637
|
// 但必须让 original 与 selling 一起随新的 option 金额移动。
|
|
5494
5638
|
var previousOptionSum = sumOptionUnitPrice(getProductSkuOptions(targetProduct));
|
|
5495
5639
|
var nextOptionSum = sumOptionUnitPrice(getProductSkuOptions(nextProduct));
|
|
5496
|
-
var _previousMainOriginal = new Decimal(Number((
|
|
5497
|
-
var _previousMainSelling = new Decimal(Number((
|
|
5640
|
+
var _previousMainOriginal = new Decimal(Number((_ref84 = (_targetProduct$metada10 = (_targetProduct$metada11 = targetProduct.metadata) === null || _targetProduct$metada11 === void 0 ? void 0 : _targetProduct$metada11.main_product_original_price) !== null && _targetProduct$metada10 !== void 0 ? _targetProduct$metada10 : targetProduct.original_price) !== null && _ref84 !== void 0 ? _ref84 : 0) || 0);
|
|
5641
|
+
var _previousMainSelling = new Decimal(Number((_ref85 = (_targetProduct$metada12 = (_targetProduct$metada13 = targetProduct.metadata) === null || _targetProduct$metada13 === void 0 ? void 0 : _targetProduct$metada13.main_product_selling_price) !== null && _targetProduct$metada12 !== void 0 ? _targetProduct$metada12 : targetProduct.selling_price) !== null && _ref85 !== void 0 ? _ref85 : _previousMainOriginal.toNumber()) || 0);
|
|
5498
5642
|
var _preservedDiscount = _previousMainOriginal.minus(_previousMainSelling);
|
|
5499
5643
|
var previousSource = ((_targetProduct$metada14 = targetProduct.metadata) === null || _targetProduct$metada14 === void 0 ? void 0 : _targetProduct$metada14.source_product_price) != null ? new Decimal(Number(targetProduct.metadata.source_product_price) || 0) : _previousMainOriginal.minus(previousOptionSum);
|
|
5500
5644
|
var _nextMainOriginal = previousSource.plus(nextOptionSum);
|
|
@@ -5594,7 +5738,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5594
5738
|
key: "updateOrderProducts",
|
|
5595
5739
|
value: function () {
|
|
5596
5740
|
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(paramsList) {
|
|
5597
|
-
var
|
|
5741
|
+
var _this36 = this;
|
|
5598
5742
|
var tempOrder, reapplyBookingDiscountProductUids;
|
|
5599
5743
|
return _regeneratorRuntime().wrap(function _callee26$(_context28) {
|
|
5600
5744
|
while (1) switch (_context28.prev = _context28.next) {
|
|
@@ -5607,7 +5751,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5607
5751
|
return _context28.abrupt("return", tempOrder.products);
|
|
5608
5752
|
case 3:
|
|
5609
5753
|
reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
|
|
5610
|
-
var updatedProductUid =
|
|
5754
|
+
var updatedProductUid = _this36.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
5611
5755
|
// 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
|
|
5612
5756
|
if (params.allow_booking_discount_reapply && updatedProductUid) {
|
|
5613
5757
|
acc.push(String(updatedProductUid));
|
|
@@ -5663,8 +5807,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5663
5807
|
if (unique_identification_number !== undefined) {
|
|
5664
5808
|
targetUid = String(unique_identification_number);
|
|
5665
5809
|
productIndex = tempOrder.products.findIndex(function (item) {
|
|
5666
|
-
var _item$
|
|
5667
|
-
return String(((_item$
|
|
5810
|
+
var _item$metadata5;
|
|
5811
|
+
return String(((_item$metadata5 = item.metadata) === null || _item$metadata5 === void 0 ? void 0 : _item$metadata5.unique_identification_number) || item.unique_identification_number || '') === targetUid;
|
|
5668
5812
|
});
|
|
5669
5813
|
}
|
|
5670
5814
|
if (productIndex === -1) {
|
|
@@ -5834,7 +5978,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5834
5978
|
key: "removeProductsFromOrder",
|
|
5835
5979
|
value: (function () {
|
|
5836
5980
|
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(identities, options) {
|
|
5837
|
-
var
|
|
5981
|
+
var _this37 = this;
|
|
5838
5982
|
var tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
|
|
5839
5983
|
return _regeneratorRuntime().wrap(function _callee29$(_context32) {
|
|
5840
5984
|
while (1) switch (_context32.prev = _context32.next) {
|
|
@@ -5853,8 +5997,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5853
5997
|
bookingsBeforeRemove = tempOrder.bookings || [];
|
|
5854
5998
|
preserveDisplayPosition = options === null || options === void 0 ? void 0 : options.preserveDisplayPosition;
|
|
5855
5999
|
anchorIndex = preserveDisplayPosition ? productsBeforeRemove.findIndex(function (item) {
|
|
5856
|
-
var _item$
|
|
5857
|
-
var uid = ((_item$
|
|
6000
|
+
var _item$metadata6;
|
|
6001
|
+
var uid = ((_item$metadata6 = item.metadata) === null || _item$metadata6 === void 0 ? void 0 : _item$metadata6.unique_identification_number) || item.unique_identification_number;
|
|
5858
6002
|
return uid !== undefined && uid !== null && String(uid) === String(preserveDisplayPosition.anchorProductUid);
|
|
5859
6003
|
}) : -1;
|
|
5860
6004
|
productsAfterAnchor = anchorIndex >= 0 ? productsBeforeRemove.slice(anchorIndex + 1) : [];
|
|
@@ -5899,7 +6043,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5899
6043
|
}
|
|
5900
6044
|
if (productUid !== undefined && productUid !== null && productUid !== '') {
|
|
5901
6045
|
bookingsBeforeRemove.forEach(function (booking) {
|
|
5902
|
-
var bookingUid =
|
|
6046
|
+
var bookingUid = _this37.getBookingUniqueIdentificationNumber(booking);
|
|
5903
6047
|
if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
|
|
5904
6048
|
linkedBookingUidsToRemove.add(bookingUid);
|
|
5905
6049
|
}
|
|
@@ -5950,8 +6094,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5950
6094
|
}
|
|
5951
6095
|
if (preserveDisplayPosition && anchorIndex >= 0) {
|
|
5952
6096
|
remainingProductIndex = tempOrder.products.findIndex(function (item) {
|
|
5953
|
-
var _item$
|
|
5954
|
-
var uid = ((_item$
|
|
6097
|
+
var _item$metadata7;
|
|
6098
|
+
var uid = ((_item$metadata7 = item.metadata) === null || _item$metadata7 === void 0 ? void 0 : _item$metadata7.unique_identification_number) || item.unique_identification_number;
|
|
5955
6099
|
return uid !== undefined && uid !== null && String(uid) === String(preserveDisplayPosition.remainingProductUid);
|
|
5956
6100
|
});
|
|
5957
6101
|
if (remainingProductIndex >= 0) {
|
|
@@ -6114,23 +6258,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6114
6258
|
}, {
|
|
6115
6259
|
key: "buildCurrentSubmitPayloadForLocalPrint",
|
|
6116
6260
|
value: function buildCurrentSubmitPayloadForLocalPrint(params) {
|
|
6117
|
-
var _params$cacheId, _this$otherParams5,
|
|
6261
|
+
var _params$cacheId, _this$otherParams5, _ref86, _params$businessCode, _this$otherParams6, _this$otherParams7;
|
|
6118
6262
|
var tempOrder = this.ensureTempOrder();
|
|
6119
6263
|
this.persistTempOrder();
|
|
6120
6264
|
var payload = buildSubmitPayload({
|
|
6121
6265
|
tempOrder: tempOrder,
|
|
6122
6266
|
cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
|
|
6123
6267
|
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.platform),
|
|
6124
|
-
businessCode: (
|
|
6268
|
+
businessCode: (_ref86 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode) !== null && _ref86 !== void 0 ? _ref86 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code,
|
|
6125
6269
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
6126
6270
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
6127
6271
|
summary: this.store.summary || createEmptySummary(),
|
|
6128
6272
|
enhance: function enhance(nextPayload) {
|
|
6129
|
-
var
|
|
6273
|
+
var _ref87, _tempOrder$order_numb, _ref88, _tempOrder$shop_order2, _ref89, _tempOrder$shop_full_;
|
|
6130
6274
|
return _objectSpread(_objectSpread({}, nextPayload), {}, {
|
|
6131
|
-
order_number: (
|
|
6132
|
-
shop_order_number: (
|
|
6133
|
-
shop_full_order_number: (
|
|
6275
|
+
order_number: (_ref87 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref87 !== void 0 ? _ref87 : null,
|
|
6276
|
+
shop_order_number: (_ref88 = (_tempOrder$shop_order2 = tempOrder.shop_order_number) !== null && _tempOrder$shop_order2 !== void 0 ? _tempOrder$shop_order2 : nextPayload.shop_order_number) !== null && _ref88 !== void 0 ? _ref88 : null,
|
|
6277
|
+
shop_full_order_number: (_ref89 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref89 !== void 0 ? _ref89 : null,
|
|
6134
6278
|
small_ticket_data_flag: 1
|
|
6135
6279
|
});
|
|
6136
6280
|
}
|
|
@@ -6294,7 +6438,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6294
6438
|
key: "runSubmitTempOrder",
|
|
6295
6439
|
value: function () {
|
|
6296
6440
|
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
|
|
6297
|
-
var _params$cacheId3, _this$otherParams12,
|
|
6441
|
+
var _params$cacheId3, _this$otherParams12, _ref90, _ref91, _submitSnapshot$busin, _this$otherParams13, _this$otherParams14, _submitSnapshot$type;
|
|
6298
6442
|
var tempOrder, isOnlineStorePlatform, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, shouldOverridePaymentStatus, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, isLocalPendingSubmit, salesNotesState, submittedOrderId, resultRecord;
|
|
6299
6443
|
return _regeneratorRuntime().wrap(function _callee37$(_context40) {
|
|
6300
6444
|
while (1) switch (_context40.prev = _context40.next) {
|
|
@@ -6361,7 +6505,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6361
6505
|
tempOrder: tempOrder,
|
|
6362
6506
|
cacheId: effectiveCacheId,
|
|
6363
6507
|
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.platform),
|
|
6364
|
-
businessCode: (
|
|
6508
|
+
businessCode: (_ref90 = (_ref91 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref91 !== void 0 ? _ref91 : (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.businessCode) !== null && _ref90 !== void 0 ? _ref90 : (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.business_code,
|
|
6365
6509
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
6366
6510
|
type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
|
|
6367
6511
|
summary: latestSummary,
|
|
@@ -6531,10 +6675,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6531
6675
|
value: function extractSubmitErrorResponse(error) {
|
|
6532
6676
|
var _error$response,
|
|
6533
6677
|
_error$response2,
|
|
6534
|
-
|
|
6678
|
+
_this38 = this;
|
|
6535
6679
|
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];
|
|
6536
6680
|
return candidates.find(function (candidate) {
|
|
6537
|
-
return
|
|
6681
|
+
return _this38.isSubmitErrorResponse(candidate);
|
|
6538
6682
|
}) || null;
|
|
6539
6683
|
}
|
|
6540
6684
|
}, {
|
|
@@ -6562,7 +6706,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6562
6706
|
key: "syncPaymentsToOrder",
|
|
6563
6707
|
value: function () {
|
|
6564
6708
|
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
6565
|
-
var
|
|
6709
|
+
var _this39 = this,
|
|
6566
6710
|
_params$confirmPendin;
|
|
6567
6711
|
var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, enhancePayload, submitParams, submitResult;
|
|
6568
6712
|
return _regeneratorRuntime().wrap(function _callee39$(_context42) {
|
|
@@ -6587,7 +6731,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6587
6731
|
case 9:
|
|
6588
6732
|
devicePrefix = _context42.t0;
|
|
6589
6733
|
mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
|
|
6590
|
-
return
|
|
6734
|
+
return _this39.normalizePaymentSource(payment, {
|
|
6591
6735
|
defaultPaid: false,
|
|
6592
6736
|
devicePrefix: devicePrefix
|
|
6593
6737
|
});
|
|
@@ -6666,7 +6810,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6666
6810
|
}, {
|
|
6667
6811
|
key: "createOrder",
|
|
6668
6812
|
value: function createOrder(params) {
|
|
6669
|
-
var
|
|
6813
|
+
var _this40 = this;
|
|
6670
6814
|
var order = _objectSpread({
|
|
6671
6815
|
type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
|
|
6672
6816
|
// 要从外面拿,virtual
|
|
@@ -6698,7 +6842,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6698
6842
|
|
|
6699
6843
|
// 为预约补齐 holder 信息
|
|
6700
6844
|
if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
|
|
6701
|
-
ensureCartItemOriginHolder(item,
|
|
6845
|
+
ensureCartItemOriginHolder(item, _this40.window);
|
|
6702
6846
|
}
|
|
6703
6847
|
|
|
6704
6848
|
// 购物车是否为普通商品
|
|
@@ -7401,7 +7545,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7401
7545
|
}, {
|
|
7402
7546
|
key: "normalizeTempOrderForRuntime",
|
|
7403
7547
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
7404
|
-
var
|
|
7548
|
+
var _this41 = this,
|
|
7405
7549
|
_raw$_extend;
|
|
7406
7550
|
var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
|
|
7407
7551
|
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
|
|
@@ -7426,12 +7570,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7426
7570
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
7427
7571
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
7428
7572
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
7429
|
-
return
|
|
7573
|
+
return _this41.normalizeHydratedOrderProduct(p, {
|
|
7430
7574
|
makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
|
|
7431
7575
|
});
|
|
7432
7576
|
}) : [];
|
|
7433
7577
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
7434
|
-
var booking =
|
|
7578
|
+
var booking = _this41.normalizeHydratedBookingHolder(b || {});
|
|
7435
7579
|
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
7436
7580
|
is_all: normalizeBookingIsAll(booking),
|
|
7437
7581
|
sub_type: normalizeBookingSubType(booking)
|
|
@@ -7481,7 +7625,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7481
7625
|
_step24;
|
|
7482
7626
|
try {
|
|
7483
7627
|
for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
|
|
7484
|
-
var _product$metadata14,
|
|
7628
|
+
var _product$metadata14, _ref92, _ref93, _existed$origin, _rawProduct$metadata;
|
|
7485
7629
|
var _step24$value = _slicedToArray(_step24.value, 2),
|
|
7486
7630
|
index = _step24$value[0],
|
|
7487
7631
|
product = _step24$value[1];
|
|
@@ -7489,7 +7633,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7489
7633
|
if (!uid) continue;
|
|
7490
7634
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
7491
7635
|
var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
|
|
7492
|
-
var origin = (
|
|
7636
|
+
var origin = (_ref92 = (_ref93 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref93 !== void 0 ? _ref93 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref92 !== void 0 ? _ref92 : rawProduct;
|
|
7493
7637
|
var originSnapshot = cloneDeep(origin);
|
|
7494
7638
|
var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
|
|
7495
7639
|
if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
|
|
@@ -7618,10 +7762,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7618
7762
|
}, {
|
|
7619
7763
|
key: "normalizeHydratedProductOptionItem",
|
|
7620
7764
|
value: function normalizeHydratedProductOptionItem(optionItem) {
|
|
7621
|
-
var
|
|
7622
|
-
var rawNum = (
|
|
7765
|
+
var _ref94, _optionItem$num, _ref95, _optionItem$add_price;
|
|
7766
|
+
var rawNum = (_ref94 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref94 !== void 0 ? _ref94 : 1;
|
|
7623
7767
|
var parsedNum = Number(rawNum);
|
|
7624
|
-
var rawPrice = (
|
|
7768
|
+
var rawPrice = (_ref95 = (_optionItem$add_price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _optionItem$add_price !== void 0 ? _optionItem$add_price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _ref95 !== void 0 ? _ref95 : 0;
|
|
7625
7769
|
var parsedPrice = Number(rawPrice);
|
|
7626
7770
|
var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
|
|
7627
7771
|
option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
|
|
@@ -7638,7 +7782,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7638
7782
|
}, {
|
|
7639
7783
|
key: "normalizeHydratedOrderProduct",
|
|
7640
7784
|
value: function normalizeHydratedOrderProduct(product, options) {
|
|
7641
|
-
var
|
|
7785
|
+
var _this42 = this;
|
|
7642
7786
|
var row = _objectSpread({}, product || {});
|
|
7643
7787
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
7644
7788
|
row.num = row.product_quantity;
|
|
@@ -7646,7 +7790,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7646
7790
|
var productSku = ensureProductSku(row);
|
|
7647
7791
|
row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
|
|
7648
7792
|
option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
|
|
7649
|
-
return
|
|
7793
|
+
return _this42.normalizeHydratedProductOptionItem(optionItem || {});
|
|
7650
7794
|
}))
|
|
7651
7795
|
});
|
|
7652
7796
|
delete row["product_".concat('option', "_item")];
|
|
@@ -7734,8 +7878,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7734
7878
|
}, {
|
|
7735
7879
|
key: "getVouchers",
|
|
7736
7880
|
value: function getVouchers() {
|
|
7737
|
-
var _this$store$
|
|
7738
|
-
return ((_this$store$
|
|
7881
|
+
var _this$store$tempOrder9;
|
|
7882
|
+
return ((_this$store$tempOrder9 = this.store.tempOrder) === null || _this$store$tempOrder9 === void 0 ? void 0 : _this$store$tempOrder9.vouchers) || [];
|
|
7739
7883
|
}
|
|
7740
7884
|
}], [{
|
|
7741
7885
|
key: "populateSavedAmounts",
|
|
@@ -7829,4 +7973,5 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
7829
7973
|
}
|
|
7830
7974
|
}]);
|
|
7831
7975
|
return OrderModule;
|
|
7832
|
-
}(BaseModule);
|
|
7976
|
+
}(BaseModule);
|
|
7977
|
+
export { isFulfillmentTimingBooking } from "./pickupTiming";
|