@pisell/pisellos 0.10.7 → 0.10.8
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/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +12 -10
- package/dist/modules/Order/index.d.ts +12 -5
- package/dist/modules/Order/index.js +310 -210
- package/dist/modules/Order/types.d.ts +26 -3
- package/dist/modules/Order/types.js +11 -0
- package/dist/modules/Order/utils/discountProductLineIdentity.d.ts +45 -0
- package/dist/modules/Order/utils/discountProductLineIdentity.js +227 -0
- package/dist/modules/Rules/index.js +125 -52
- package/dist/modules/SalesSummary/utils.js +7 -1
- package/dist/server/index.d.ts +6 -0
- package/dist/server/index.js +810 -729
- package/dist/server/modules/order/index.d.ts +1 -0
- package/dist/server/modules/order/index.js +9 -2
- package/dist/server/modules/order/types.d.ts +1 -1
- package/dist/solution/BaseSales/index.d.ts +15 -5
- package/dist/solution/BaseSales/index.js +211 -159
- package/dist/solution/BaseSales/utils/cartPromotion.js +26 -3
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -1
- package/dist/solution/BaseSales/utils.js +31 -20
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +1 -4
- package/dist/solution/BookingTicket/types.d.ts +3 -0
- package/dist/solution/BookingTicket/utils/cartView.js +44 -32
- package/dist/solution/Sales/index.d.ts +1 -0
- package/dist/solution/Sales/index.js +16 -2
- package/dist/solution/ScanOrder/utils.js +31 -20
- package/dist/solution/UnifiedBookingSales/index.d.ts +5 -4
- package/dist/solution/UnifiedBookingSales/index.js +51 -39
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +3 -1
- package/lib/modules/Order/index.d.ts +12 -5
- package/lib/modules/Order/index.js +148 -43
- package/lib/modules/Order/types.d.ts +26 -3
- package/lib/modules/Order/utils/discountProductLineIdentity.d.ts +45 -0
- package/lib/modules/Order/utils/discountProductLineIdentity.js +170 -0
- package/lib/modules/Rules/index.js +100 -20
- package/lib/modules/SalesSummary/utils.js +5 -1
- package/lib/server/index.d.ts +6 -0
- package/lib/server/index.js +51 -0
- package/lib/server/modules/order/index.d.ts +1 -0
- package/lib/server/modules/order/index.js +9 -3
- package/lib/server/modules/order/types.d.ts +1 -1
- package/lib/solution/BaseSales/index.d.ts +15 -5
- package/lib/solution/BaseSales/index.js +64 -16
- package/lib/solution/BaseSales/utils/cartPromotion.js +26 -2
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -1
- package/lib/solution/BaseSales/utils.js +29 -18
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +1 -4
- package/lib/solution/BookingTicket/types.d.ts +3 -0
- package/lib/solution/BookingTicket/utils/cartView.js +43 -30
- package/lib/solution/Sales/index.d.ts +1 -0
- package/lib/solution/Sales/index.js +15 -3
- package/lib/solution/ScanOrder/utils.js +29 -18
- package/lib/solution/UnifiedBookingSales/index.d.ts +5 -4
- package/lib/solution/UnifiedBookingSales/index.js +35 -26
- package/package.json +1 -1
|
@@ -39,9 +39,10 @@ import { ensureOrderPaymentNumber, mergeOrderPaymentRecord, resolveOrderPaymentI
|
|
|
39
39
|
import { resolvePaymentNumberDevicePrefix, resolvePaymentNumberDevicePrefixFromDeviceId } from "../../utils/payment-number";
|
|
40
40
|
import { processCartPromotion, appendPromotionTags as _appendPromotionTags, getOrderProductUid as getPromotionUid } from "../../solution/BaseSales/utils/cartPromotion";
|
|
41
41
|
import { buildProductLineFingerprint, getProductIdentityIndex, getSafeProductNum, isIdentityMatch, normalizeOrderProduct } from "../../solution/ScanOrder/utils";
|
|
42
|
-
import { syncManualProductDiscountProductNum } from "./utils/manualProductDiscount";
|
|
42
|
+
import { hasManualProductDiscountFlag, syncManualProductDiscountProductNum } from "./utils/manualProductDiscount";
|
|
43
43
|
import { expandHydratedProductsForDiscountCollection, restoreHydratedBundleDiscounts } from "./utils/bundleDiscountHydration";
|
|
44
44
|
import { getOrderCollectionPersistentId, getOrderCollectionUid, normalizeOrderCollections, repairDuplicateProductLineIdentities as repairDuplicateOrderProductLineIdentities, setOrderCollectionUid } from "./utils/orderCollectionIdentity";
|
|
45
|
+
import { consolidateDiscountFreeProductLines, ensureUniqueProductLineUids } from "./utils/discountProductLineIdentity";
|
|
45
46
|
import { DiscountModule } from "../Discount";
|
|
46
47
|
import { RulesModule } from "../Rules";
|
|
47
48
|
import { UnavailableReason } from "../Rules/types";
|
|
@@ -63,8 +64,7 @@ function isSameDiscountList(left, right) {
|
|
|
63
64
|
return JSON.stringify(normalizeDiscountListSignature(left)) === JSON.stringify(normalizeDiscountListSignature(right));
|
|
64
65
|
}
|
|
65
66
|
function isManualProductDiscountProduct(product) {
|
|
66
|
-
|
|
67
|
-
return (product === null || product === void 0 || (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.is_manual_discount) === true || (product === null || product === void 0 || (_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.is_manual_discount) === 1 || ((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (item) {
|
|
67
|
+
return hasManualProductDiscountFlag(product === null || product === void 0 ? void 0 : product.metadata) || ((product === null || product === void 0 ? void 0 : product.discount_list) || []).some(function (item) {
|
|
68
68
|
return (item === null || item === void 0 ? void 0 : item.type) === 'product';
|
|
69
69
|
});
|
|
70
70
|
}
|
|
@@ -163,7 +163,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
163
163
|
_step2;
|
|
164
164
|
try {
|
|
165
165
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
166
|
-
var _item$type2, _ref, _ref2, _item$discount$resour, _item$discount, _item$discount$title, _item$discount2, _item$amount, _ref3, _item$discount$origin, _item$
|
|
166
|
+
var _item$type2, _ref, _ref2, _item$discount$resour, _item$discount, _item$discount$title, _item$discount2, _item$discount3, _item$discount$fixed_, _item$discount4, _item$discount5, _item$amount, _ref3, _item$discount$origin, _item$discount6, _ref4, _ref5, _item$metadata$num, _item$metadata, _ref6, _ref7, _item$metadata$num2, _item$metadata2, _ref8, _item$discount$discou, _item$discount7, _item$amount2, _item$amount3, _product$product_id, _product$is_charge_ta, _ref9, _product$original_pri, _ref10, _item$discount$discou2, _item$discount8, _item$discount$discou3, _item$discount9;
|
|
167
167
|
var item = _step2.value;
|
|
168
168
|
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;
|
|
169
169
|
if (!type || type === 'product') continue;
|
|
@@ -174,12 +174,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
174
174
|
var key = Number.isFinite(id) ? id : String(resourceId);
|
|
175
175
|
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 : {};
|
|
176
176
|
var amount = Number((item === null || item === void 0 ? void 0 : item.amount) || 0);
|
|
177
|
+
var discountCardType = item === null || item === void 0 || (_item$discount3 = item.discount) === null || _item$discount3 === void 0 ? void 0 : _item$discount3.discount_card_type;
|
|
178
|
+
var parValue = isDiscountCard ? discountCardType === 'fixed_amount' ? (_item$discount$fixed_ = item === null || item === void 0 || (_item$discount4 = item.discount) === null || _item$discount4 === void 0 ? void 0 : _item$discount4.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$discount5 = item.discount) === null || _item$discount5 === void 0 ? void 0 : _item$discount5.percent : '0';
|
|
177
179
|
var detail = {
|
|
178
180
|
amount: String((_item$amount = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount !== void 0 ? _item$amount : '0'),
|
|
179
181
|
type: type,
|
|
180
182
|
resource_id: key,
|
|
181
183
|
title: title,
|
|
182
|
-
original_amount: String((_ref3 = (_item$discount$origin = item === null || item === void 0 || (_item$
|
|
184
|
+
original_amount: String((_ref3 = (_item$discount$origin = item === null || item === void 0 || (_item$discount6 = item.discount) === null || _item$discount6 === void 0 ? void 0 : _item$discount6.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'),
|
|
183
185
|
num: Number((_ref4 = (_ref5 = (_item$metadata$num = item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.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,
|
|
184
186
|
metadata: item === null || item === void 0 ? void 0 : item.metadata,
|
|
185
187
|
discount: item === null || item === void 0 ? void 0 : item.discount,
|
|
@@ -209,9 +211,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
209
211
|
encoded: '',
|
|
210
212
|
code: '',
|
|
211
213
|
tag: type,
|
|
212
|
-
product_id: (_ref8 = (_item$discount$discou = item === null || item === void 0 || (_item$
|
|
214
|
+
product_id: (_ref8 = (_item$discount$discou = item === null || item === void 0 || (_item$discount7 = item.discount) === null || _item$discount7 === void 0 ? void 0 : _item$discount7.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,
|
|
213
215
|
relation_type: '',
|
|
214
|
-
par_value: String(
|
|
216
|
+
par_value: String(parValue !== null && parValue !== void 0 ? parValue : '0'),
|
|
215
217
|
used_par_value: String((_item$amount2 = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount2 !== void 0 ? _item$amount2 : '0'),
|
|
216
218
|
limit_status: 'enable',
|
|
217
219
|
limited_relation_product_data: {
|
|
@@ -230,7 +232,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
230
232
|
id: (_product$product_id = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : 0,
|
|
231
233
|
title: '',
|
|
232
234
|
is_charge_tax: (_product$is_charge_ta = product === null || product === void 0 ? void 0 : product.is_charge_tax) !== null && _product$is_charge_ta !== void 0 ? _product$is_charge_ta : 0,
|
|
233
|
-
base_price: String((
|
|
235
|
+
base_price: String((_ref9 = (_product$original_pri = product === null || product === void 0 ? void 0 : product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : product === null || product === void 0 ? void 0 : product.selling_price) !== null && _ref9 !== void 0 ? _ref9 : '0')
|
|
234
236
|
},
|
|
235
237
|
type: type,
|
|
236
238
|
resource_id: key,
|
|
@@ -242,8 +244,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
242
244
|
amount: amount,
|
|
243
245
|
discount: _objectSpread(_objectSpread({}, (item === null || item === void 0 ? void 0 : item.discount) || {}), {}, {
|
|
244
246
|
resource_id: key,
|
|
245
|
-
discount_product_id: (
|
|
246
|
-
discount_calculation_mode: (_item$discount$discou3 = item === null || item === void 0 || (_item$
|
|
247
|
+
discount_product_id: (_ref10 = (_item$discount$discou2 = item === null || item === void 0 || (_item$discount8 = item.discount) === null || _item$discount8 === void 0 ? void 0 : _item$discount8.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,
|
|
248
|
+
discount_calculation_mode: (_item$discount$discou3 = item === null || item === void 0 || (_item$discount9 = item.discount) === null || _item$discount9 === void 0 ? void 0 : _item$discount9.discount_calculation_mode) !== null && _item$discount$discou3 !== void 0 ? _item$discount$discou3 : 'item_level'
|
|
247
249
|
}),
|
|
248
250
|
applicableProductDetails: [detail],
|
|
249
251
|
appliedProductDetails: [detail]
|
|
@@ -271,7 +273,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
271
273
|
key: "applyProductDiscountPrices",
|
|
272
274
|
value: function applyProductDiscountPrices(products) {
|
|
273
275
|
return (products || []).map(function (product) {
|
|
274
|
-
var _product$metadata$sou, _product$
|
|
276
|
+
var _product$metadata$sou, _product$metadata, _product$metadata2, _product$original_pri2;
|
|
275
277
|
if (isManualProductDiscountProduct(product)) return product;
|
|
276
278
|
var discountItems = Array.isArray(product.discount_list) ? product.discount_list : [];
|
|
277
279
|
var hasOnlyPersistedDiscountSnapshots = product.order_detail_id !== undefined && product.order_detail_id !== null && discountItems.length > 0 && discountItems.every(function (discount) {
|
|
@@ -282,7 +284,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
282
284
|
}
|
|
283
285
|
var totalPerUnitDiscount = resolveEffectivePerUnitDiscount(product);
|
|
284
286
|
var optionSum = sumOptionUnitPrice(getProductSkuOptions(product));
|
|
285
|
-
var sourcePrice = (_product$metadata$sou = (_product$
|
|
287
|
+
var sourcePrice = (_product$metadata$sou = (_product$metadata = product.metadata) === null || _product$metadata === void 0 ? void 0 : _product$metadata.source_product_price) !== null && _product$metadata$sou !== void 0 ? _product$metadata$sou : ((_product$metadata2 = product.metadata) === null || _product$metadata2 === void 0 ? void 0 : _product$metadata2.main_product_original_price) != null ? new Decimal(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : (_product$original_pri2 = product.original_price) !== null && _product$original_pri2 !== void 0 ? _product$original_pri2 : '0';
|
|
286
288
|
var newSourceSellingPrice = new Decimal(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
287
289
|
var newMainSellingPrice = new Decimal(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
288
290
|
if (product.metadata) {
|
|
@@ -291,10 +293,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
291
293
|
}
|
|
292
294
|
if (Array.isArray(product.product_bundle)) {
|
|
293
295
|
product.product_bundle = product.product_bundle.map(function (bundle) {
|
|
294
|
-
var
|
|
296
|
+
var _ref11, _bundle$original_pric;
|
|
295
297
|
var hasBundleDiscount = Array.isArray(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) && bundle.discount_list.length > 0;
|
|
296
298
|
if (hasBundleDiscount) return bundle;
|
|
297
|
-
var restoredPrice = (
|
|
299
|
+
var restoredPrice = (_ref11 = (_bundle$original_pric = bundle === null || bundle === void 0 ? void 0 : bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle === null || bundle === void 0 ? void 0 : bundle.product_price) !== null && _ref11 !== void 0 ? _ref11 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
|
|
298
300
|
if (restoredPrice === undefined || restoredPrice === null || restoredPrice === '') return bundle;
|
|
299
301
|
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
300
302
|
price: restoredPrice,
|
|
@@ -707,7 +709,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
707
709
|
value: function () {
|
|
708
710
|
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(code, customerId) {
|
|
709
711
|
var _this$store$discount11, _tempOrder$holder, _this$store$summary;
|
|
710
|
-
var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders,
|
|
712
|
+
var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref12, isAvailable, newDiscountList, evaluatedDiscountList, unavailableReason, shouldRetainForLater, normalizedNewDiscountList, retainedDiscountList, resolvedDiscountList, _this$store$discount12, _this$store$discount13;
|
|
711
713
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
712
714
|
while (1) switch (_context6.prev = _context6.next) {
|
|
713
715
|
case 0:
|
|
@@ -784,7 +786,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
784
786
|
case 18:
|
|
785
787
|
tempOrder = this.store.tempOrder;
|
|
786
788
|
holders = (tempOrder === null || tempOrder === void 0 || (_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.form_record) || [];
|
|
787
|
-
|
|
789
|
+
_ref12 = rulesModule.isDiscountListAvailable({
|
|
788
790
|
productList: (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || [],
|
|
789
791
|
oldDiscountList: this.getDiscountList(),
|
|
790
792
|
newDiscountList: withScanList,
|
|
@@ -796,7 +798,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
796
798
|
}) || {
|
|
797
799
|
isAvailable: false,
|
|
798
800
|
discountList: this.getDiscountList()
|
|
799
|
-
}, isAvailable =
|
|
801
|
+
}, isAvailable = _ref12.isAvailable, newDiscountList = _ref12.discountList, evaluatedDiscountList = _ref12.evaluatedDiscountList, unavailableReason = _ref12.unavailableReason;
|
|
800
802
|
shouldRetainForLater = !isAvailable && unavailableReason === UnavailableReason.ProductNotApplicable && withScanList.some(isCustomerPromotionDiscount);
|
|
801
803
|
normalizedNewDiscountList = newDiscountList ? markScannedDiscounts(newDiscountList, withScanList) : undefined;
|
|
802
804
|
retainedDiscountList = evaluatedDiscountList ? markScannedDiscounts(evaluatedDiscountList, withScanList) : normalizedNewDiscountList;
|
|
@@ -879,9 +881,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
879
881
|
if (result !== null && result !== void 0 && result.productList) {
|
|
880
882
|
var previousProductsByUid = indexOrderProductsByUid(tempOrder.products);
|
|
881
883
|
tempOrder.products = this.applyProductDiscountPrices((result.productList || []).map(function (product, index) {
|
|
882
|
-
var
|
|
884
|
+
var _ref13;
|
|
883
885
|
var uid = getOrderProductLineUid(product);
|
|
884
|
-
var previous = (
|
|
886
|
+
var previous = (_ref13 = uid ? previousProductsByUid.get(uid) : undefined) !== null && _ref13 !== void 0 ? _ref13 : previousProductsByUid.get("__index__:".concat(index));
|
|
885
887
|
if (isManualProductDiscountProduct(previous)) {
|
|
886
888
|
return previous;
|
|
887
889
|
}
|
|
@@ -890,7 +892,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
890
892
|
discount_list: normalizeOrderProductDiscountList(syncManualProductDiscountProductNum(mergedProduct.discount_list, mergedProduct.num))
|
|
891
893
|
});
|
|
892
894
|
}));
|
|
893
|
-
|
|
895
|
+
ensureUniqueProductLineUids(tempOrder);
|
|
896
|
+
consolidateDiscountFreeProductLines(tempOrder);
|
|
894
897
|
}
|
|
895
898
|
if (result !== null && result !== void 0 && result.discountList) {
|
|
896
899
|
var _this$store$discount15;
|
|
@@ -1310,6 +1313,53 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1310
1313
|
cacheKey: ['tempOrder']
|
|
1311
1314
|
});
|
|
1312
1315
|
}
|
|
1316
|
+
|
|
1317
|
+
/**
|
|
1318
|
+
* 终止当前模块实例的 sessionStorage 订单恢复会话。
|
|
1319
|
+
*
|
|
1320
|
+
* 支付跳转等终态场景需要同时删除当前 cacheId 的 tempOrder 快照,并关闭
|
|
1321
|
+
* 本实例后续异步任务的再次写入;新模块实例初始化时会按 otherParams 重新启用。
|
|
1322
|
+
*/
|
|
1323
|
+
}, {
|
|
1324
|
+
key: "clearSessionStoragePersistedTempOrder",
|
|
1325
|
+
value: function clearSessionStoragePersistedTempOrder() {
|
|
1326
|
+
var _this$window;
|
|
1327
|
+
this.sessionStorageRestoreRecord = null;
|
|
1328
|
+
if (!this.sessionStoragePersistEnabled) return;
|
|
1329
|
+
this.sessionStoragePersistEnabled = false;
|
|
1330
|
+
if (!this.cacheId || !this.fatherModule || !((_this$window = this.window) !== null && _this$window !== void 0 && _this$window.sessionStorage)) {
|
|
1331
|
+
return;
|
|
1332
|
+
}
|
|
1333
|
+
var sessionStorage = this.window.sessionStorage;
|
|
1334
|
+
var rawCacheData = sessionStorage.getItem(this.fatherModule);
|
|
1335
|
+
if (!rawCacheData) return;
|
|
1336
|
+
var parsedCacheData;
|
|
1337
|
+
try {
|
|
1338
|
+
parsedCacheData = JSON.parse(rawCacheData);
|
|
1339
|
+
} catch (_unused2) {
|
|
1340
|
+
return;
|
|
1341
|
+
}
|
|
1342
|
+
if (!parsedCacheData || _typeof(parsedCacheData) !== 'object' || Array.isArray(parsedCacheData)) {
|
|
1343
|
+
return;
|
|
1344
|
+
}
|
|
1345
|
+
var cacheRoot = parsedCacheData;
|
|
1346
|
+
var cacheBucket = cacheRoot[this.cacheId];
|
|
1347
|
+
if (!cacheBucket || _typeof(cacheBucket) !== 'object' || Array.isArray(cacheBucket)) {
|
|
1348
|
+
return;
|
|
1349
|
+
}
|
|
1350
|
+
var moduleBucket = cacheBucket[this.name];
|
|
1351
|
+
if (!moduleBucket || _typeof(moduleBucket) !== 'object' || Array.isArray(moduleBucket)) {
|
|
1352
|
+
return;
|
|
1353
|
+
}
|
|
1354
|
+
delete moduleBucket.tempOrder;
|
|
1355
|
+
if (Object.keys(moduleBucket).length === 0) {
|
|
1356
|
+
delete cacheBucket[this.name];
|
|
1357
|
+
}
|
|
1358
|
+
if (Object.keys(cacheBucket).length === 0) {
|
|
1359
|
+
delete cacheRoot[this.cacheId];
|
|
1360
|
+
}
|
|
1361
|
+
sessionStorage.setItem(this.fatherModule, JSON.stringify(cacheRoot));
|
|
1362
|
+
}
|
|
1313
1363
|
}, {
|
|
1314
1364
|
key: "consumeSessionStorageRestore",
|
|
1315
1365
|
value: function consumeSessionStorageRestore() {
|
|
@@ -1436,15 +1486,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1436
1486
|
}, {
|
|
1437
1487
|
key: "extractOrderIdFromSubmitResult",
|
|
1438
1488
|
value: function extractOrderIdFromSubmitResult(result) {
|
|
1439
|
-
var _ref15, _ref16,
|
|
1440
|
-
return (
|
|
1489
|
+
var _ref14, _ref15, _ref16, _result$data$order_id, _result$data, _result$data2;
|
|
1490
|
+
return (_ref14 = (_ref15 = (_ref16 = (_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 && _ref16 !== void 0 ? _ref16 : result === null || result === void 0 || (_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2.id) !== null && _ref15 !== void 0 ? _ref15 : result === null || result === void 0 ? void 0 : result.id) !== null && _ref14 !== void 0 ? _ref14 : null;
|
|
1441
1491
|
}
|
|
1442
1492
|
}, {
|
|
1443
1493
|
key: "calculatePaymentEffectiveAmount",
|
|
1444
1494
|
value: function calculatePaymentEffectiveAmount(payment) {
|
|
1445
|
-
var
|
|
1495
|
+
var _ref17, _payment$origin_amoun;
|
|
1446
1496
|
var amount = new Decimal(payment.amount || 0);
|
|
1447
|
-
var originAmount = new Decimal((
|
|
1497
|
+
var originAmount = new Decimal((_ref17 = (_payment$origin_amoun = payment.origin_amount) !== null && _payment$origin_amoun !== void 0 ? _payment$origin_amoun : payment.amount) !== null && _ref17 !== void 0 ? _ref17 : 0);
|
|
1448
1498
|
var serviceFee = new Decimal(payment.service_fee || 0);
|
|
1449
1499
|
// TODO: 后端允许 amount 表示顾客实际支付总额后,移除这个兼容分支。
|
|
1450
1500
|
var effectiveAmount = serviceFee.gt(0) && amount.eq(originAmount) ? amount.plus(serviceFee) : amount;
|
|
@@ -1644,12 +1694,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1644
1694
|
}, {
|
|
1645
1695
|
key: "normalizePaymentSource",
|
|
1646
1696
|
value: function normalizePaymentSource(payment, options) {
|
|
1647
|
-
var
|
|
1697
|
+
var _ref18, _paymentRecord$origin;
|
|
1648
1698
|
var paymentRecord = payment;
|
|
1649
1699
|
var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
|
|
1650
1700
|
var normalized = ensureOrderPaymentNumber(_objectSpread(_objectSpread({}, paymentRecord), {}, {
|
|
1651
1701
|
metadata: metadata,
|
|
1652
|
-
origin_amount: (
|
|
1702
|
+
origin_amount: (_ref18 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref18 !== void 0 ? _ref18 : '0.00'
|
|
1653
1703
|
}), (options === null || options === void 0 ? void 0 : options.devicePrefix) || this.getPaymentNumberDevicePrefixSync(), createUuidV4);
|
|
1654
1704
|
if (paymentRecord.status !== undefined) {
|
|
1655
1705
|
normalized.status = paymentRecord.status;
|
|
@@ -1972,7 +2022,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1972
2022
|
try {
|
|
1973
2023
|
var parsed = new Decimal(String(value || 0));
|
|
1974
2024
|
return parsed.toFixed(4);
|
|
1975
|
-
} catch (
|
|
2025
|
+
} catch (_unused3) {
|
|
1976
2026
|
return String(value);
|
|
1977
2027
|
}
|
|
1978
2028
|
}
|
|
@@ -2000,7 +2050,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2000
2050
|
_product$payment_pric,
|
|
2001
2051
|
_sku$code,
|
|
2002
2052
|
_sku$barcode,
|
|
2003
|
-
|
|
2053
|
+
_ref19,
|
|
2004
2054
|
_sku$variant_id,
|
|
2005
2055
|
_this11 = this;
|
|
2006
2056
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
@@ -2027,24 +2077,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2027
2077
|
product_sku: this.normalizeFingerprintValue({
|
|
2028
2078
|
code: (_sku$code = sku.code) !== null && _sku$code !== void 0 ? _sku$code : '',
|
|
2029
2079
|
barcode: (_sku$barcode = sku.barcode) !== null && _sku$barcode !== void 0 ? _sku$barcode : '',
|
|
2030
|
-
variant_id: (
|
|
2080
|
+
variant_id: (_ref19 = (_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 && _ref19 !== void 0 ? _ref19 : 0,
|
|
2031
2081
|
variant: sku.variant || [],
|
|
2032
2082
|
option: getProductSkuOptions(product || {}).map(function (option) {
|
|
2033
|
-
var
|
|
2083
|
+
var _ref20, _option$id, _option$option_group_, _ref21, _option$option_group_2, _option$num, _option$add_price;
|
|
2034
2084
|
return {
|
|
2035
|
-
id: (
|
|
2085
|
+
id: (_ref20 = (_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 && _ref20 !== void 0 ? _ref20 : null,
|
|
2036
2086
|
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,
|
|
2037
|
-
option_group_item_id: (
|
|
2087
|
+
option_group_item_id: (_ref21 = (_option$option_group_2 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_2 !== void 0 ? _option$option_group_2 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref21 !== void 0 ? _ref21 : null,
|
|
2038
2088
|
num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
|
|
2039
2089
|
add_price: _this11.normalizeFingerprintMoney((_option$add_price = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price !== void 0 ? _option$add_price : option === null || option === void 0 ? void 0 : option.price)
|
|
2040
2090
|
};
|
|
2041
2091
|
})
|
|
2042
2092
|
}),
|
|
2043
2093
|
product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
|
|
2044
|
-
var
|
|
2094
|
+
var _ref22, _ref23, _bundle$bundle_produc, _ref24, _bundle$bundle_varian, _bundle$num, _bundle$price_type, _bundle$price_type_ex;
|
|
2045
2095
|
return {
|
|
2046
|
-
bundle_product_id: (
|
|
2047
|
-
bundle_variant_id: (
|
|
2096
|
+
bundle_product_id: (_ref22 = (_ref23 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref23 !== void 0 ? _ref23 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref22 !== void 0 ? _ref22 : null,
|
|
2097
|
+
bundle_variant_id: (_ref24 = (_bundle$bundle_varian = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle === null || bundle === void 0 ? void 0 : bundle.product_variant_id) !== null && _ref24 !== void 0 ? _ref24 : 0,
|
|
2048
2098
|
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),
|
|
2049
2099
|
price: _this11.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
|
|
2050
2100
|
bundle_selling_price: _this11.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
|
|
@@ -2053,10 +2103,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2053
2103
|
};
|
|
2054
2104
|
})),
|
|
2055
2105
|
discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
2056
|
-
var
|
|
2106
|
+
var _ref25, _discount$type2, _ref26, _ref27, _discount$discount_id, _discount$discount;
|
|
2057
2107
|
return {
|
|
2058
|
-
type: (
|
|
2059
|
-
discount_id: (
|
|
2108
|
+
type: (_ref25 = (_discount$type2 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type2 !== void 0 ? _discount$type2 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref25 !== void 0 ? _ref25 : '',
|
|
2109
|
+
discount_id: (_ref26 = (_ref27 = (_discount$discount_id = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id !== void 0 ? _discount$discount_id : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref27 !== void 0 ? _ref27 : discount === null || discount === void 0 || (_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) !== null && _ref26 !== void 0 ? _ref26 : null,
|
|
2060
2110
|
amount: _this11.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2061
2111
|
};
|
|
2062
2112
|
}))
|
|
@@ -2080,14 +2130,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2080
2130
|
var _product$product_id3,
|
|
2081
2131
|
_product$product_vari2,
|
|
2082
2132
|
_product$num2,
|
|
2083
|
-
|
|
2133
|
+
_ref28,
|
|
2084
2134
|
_metadata$unique_iden,
|
|
2085
2135
|
_metadata$price_overr,
|
|
2086
2136
|
_metadata$is_manual_d,
|
|
2087
2137
|
_metadata$product_dis,
|
|
2088
2138
|
_sku$code2,
|
|
2089
2139
|
_sku$barcode2,
|
|
2090
|
-
|
|
2140
|
+
_ref29,
|
|
2091
2141
|
_sku$variant_id2,
|
|
2092
2142
|
_this13 = this;
|
|
2093
2143
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
@@ -2103,7 +2153,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2103
2153
|
extension_type: extensionType,
|
|
2104
2154
|
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),
|
|
2105
2155
|
metadata: {
|
|
2106
|
-
unique_identification_number: (
|
|
2156
|
+
unique_identification_number: (_ref28 = (_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 && _ref28 !== void 0 ? _ref28 : '',
|
|
2107
2157
|
price_override: (_metadata$price_overr = metadata.price_override) !== null && _metadata$price_overr !== void 0 ? _metadata$price_overr : '',
|
|
2108
2158
|
is_manual_discount: (_metadata$is_manual_d = metadata.is_manual_discount) !== null && _metadata$is_manual_d !== void 0 ? _metadata$is_manual_d : '',
|
|
2109
2159
|
product_discount_reason: (_metadata$product_dis = metadata.product_discount_reason) !== null && _metadata$product_dis !== void 0 ? _metadata$product_dis : ''
|
|
@@ -2111,35 +2161,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2111
2161
|
product_sku: this.normalizeFingerprintValue({
|
|
2112
2162
|
code: (_sku$code2 = sku.code) !== null && _sku$code2 !== void 0 ? _sku$code2 : '',
|
|
2113
2163
|
barcode: (_sku$barcode2 = sku.barcode) !== null && _sku$barcode2 !== void 0 ? _sku$barcode2 : '',
|
|
2114
|
-
variant_id: (
|
|
2164
|
+
variant_id: (_ref29 = (_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 && _ref29 !== void 0 ? _ref29 : 0,
|
|
2115
2165
|
variant: sku.variant || [],
|
|
2116
2166
|
option: getProductSkuOptions(product || {}).map(function (option) {
|
|
2117
|
-
var
|
|
2167
|
+
var _ref30, _option$id2, _option$option_group_3, _ref31, _option$option_group_4, _option$num2, _option$add_price2;
|
|
2118
2168
|
return {
|
|
2119
|
-
id: (
|
|
2169
|
+
id: (_ref30 = (_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 && _ref30 !== void 0 ? _ref30 : null,
|
|
2120
2170
|
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,
|
|
2121
|
-
option_group_item_id: (
|
|
2171
|
+
option_group_item_id: (_ref31 = (_option$option_group_4 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_4 !== void 0 ? _option$option_group_4 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref31 !== void 0 ? _ref31 : null,
|
|
2122
2172
|
num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
|
|
2123
2173
|
add_price: _this13.normalizeFingerprintMoney((_option$add_price2 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price2 !== void 0 ? _option$add_price2 : option === null || option === void 0 ? void 0 : option.price)
|
|
2124
2174
|
};
|
|
2125
2175
|
})
|
|
2126
2176
|
}),
|
|
2127
2177
|
product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
|
|
2128
|
-
var
|
|
2178
|
+
var _ref32, _bundle$bundle_id, _ref33, _bundle$bundle_group_, _ref34, _ref35, _bundle$bundle_produc2, _ref36, _bundle$bundle_varian2, _bundle$num2, _bundle$price_type2, _bundle$price_type_ex2;
|
|
2129
2179
|
return {
|
|
2130
|
-
bundle_id: (
|
|
2131
|
-
bundle_group_id: (
|
|
2132
|
-
bundle_product_id: (
|
|
2133
|
-
bundle_variant_id: (
|
|
2180
|
+
bundle_id: (_ref32 = (_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 && _ref32 !== void 0 ? _ref32 : null,
|
|
2181
|
+
bundle_group_id: (_ref33 = (_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 && _ref33 !== void 0 ? _ref33 : null,
|
|
2182
|
+
bundle_product_id: (_ref34 = (_ref35 = (_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 && _ref35 !== void 0 ? _ref35 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id) !== null && _ref34 !== void 0 ? _ref34 : null,
|
|
2183
|
+
bundle_variant_id: (_ref36 = (_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 && _ref36 !== void 0 ? _ref36 : 0,
|
|
2134
2184
|
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),
|
|
2135
2185
|
price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
|
|
2136
2186
|
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 : '',
|
|
2137
2187
|
option: _this13.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
|
|
2138
|
-
var
|
|
2188
|
+
var _ref37, _option$id3, _option$option_group_5, _ref38, _option$option_group_6, _option$num3, _option$add_price3;
|
|
2139
2189
|
return {
|
|
2140
|
-
id: (
|
|
2190
|
+
id: (_ref37 = (_option$id3 = option === null || option === void 0 ? void 0 : option.id) !== null && _option$id3 !== void 0 ? _option$id3 : option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _ref37 !== void 0 ? _ref37 : null,
|
|
2141
2191
|
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,
|
|
2142
|
-
option_group_item_id: (
|
|
2192
|
+
option_group_item_id: (_ref38 = (_option$option_group_6 = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_6 !== void 0 ? _option$option_group_6 : option === null || option === void 0 ? void 0 : option.id) !== null && _ref38 !== void 0 ? _ref38 : null,
|
|
2143
2193
|
num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
|
|
2144
2194
|
add_price: _this13.normalizeFingerprintMoney((_option$add_price3 = option === null || option === void 0 ? void 0 : option.add_price) !== null && _option$add_price3 !== void 0 ? _option$add_price3 : option === null || option === void 0 ? void 0 : option.price)
|
|
2145
2195
|
};
|
|
@@ -2147,10 +2197,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2147
2197
|
};
|
|
2148
2198
|
})),
|
|
2149
2199
|
discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
2150
|
-
var
|
|
2200
|
+
var _ref39, _discount$type4, _ref40, _ref41, _discount$discount_id2, _discount$discount2;
|
|
2151
2201
|
return {
|
|
2152
|
-
type: (
|
|
2153
|
-
discount_id: (
|
|
2202
|
+
type: (_ref39 = (_discount$type4 = discount === null || discount === void 0 ? void 0 : discount.type) !== null && _discount$type4 !== void 0 ? _discount$type4 : discount === null || discount === void 0 ? void 0 : discount.tag) !== null && _ref39 !== void 0 ? _ref39 : '',
|
|
2203
|
+
discount_id: (_ref40 = (_ref41 = (_discount$discount_id2 = discount === null || discount === void 0 ? void 0 : discount.discount_id) !== null && _discount$discount_id2 !== void 0 ? _discount$discount_id2 : discount === null || discount === void 0 ? void 0 : discount.order_discount_id) !== null && _ref41 !== void 0 ? _ref41 : discount === null || discount === void 0 || (_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) !== null && _ref40 !== void 0 ? _ref40 : null,
|
|
2154
2204
|
amount: _this13.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2155
2205
|
};
|
|
2156
2206
|
}))
|
|
@@ -2455,11 +2505,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2455
2505
|
}, {
|
|
2456
2506
|
key: "getOrderIdentity",
|
|
2457
2507
|
value: function getOrderIdentity() {
|
|
2458
|
-
var
|
|
2508
|
+
var _ref42, _ref43, _tempOrder$order_id, _tempOrder$_extend6;
|
|
2459
2509
|
var tempOrder = this.store.tempOrder;
|
|
2460
2510
|
if (!tempOrder) return null;
|
|
2461
2511
|
var lastOrderInfo = this.store.lastOrderInfo || {};
|
|
2462
|
-
var orderId = (
|
|
2512
|
+
var orderId = (_ref42 = (_ref43 = (_tempOrder$order_id = tempOrder.order_id) !== null && _tempOrder$order_id !== void 0 ? _tempOrder$order_id : lastOrderInfo.order_id) !== null && _ref43 !== void 0 ? _ref43 : lastOrderInfo.id) !== null && _ref42 !== void 0 ? _ref42 : null;
|
|
2463
2513
|
return {
|
|
2464
2514
|
localId: this.cacheId || ((_tempOrder$_extend6 = tempOrder._extend) === null || _tempOrder$_extend6 === void 0 ? void 0 : _tempOrder$_extend6.localId),
|
|
2465
2515
|
orderId: orderId,
|
|
@@ -2595,6 +2645,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2595
2645
|
tempOrder.products = (tempOrder.products || []).map(function (product) {
|
|
2596
2646
|
return _this15.sanitizeOrderProductForTempOrder(product);
|
|
2597
2647
|
});
|
|
2648
|
+
ensureUniqueProductLineUids(tempOrder);
|
|
2598
2649
|
}
|
|
2599
2650
|
}, {
|
|
2600
2651
|
key: "ensureExtend",
|
|
@@ -2627,11 +2678,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2627
2678
|
}, {
|
|
2628
2679
|
key: "captureProductRuntime",
|
|
2629
2680
|
value: function captureProductRuntime(tempOrder, rawProduct, normalizedProduct, existedUid) {
|
|
2630
|
-
var _extend$productsByUid,
|
|
2681
|
+
var _extend$productsByUid, _ref44, _rawProduct$_origin;
|
|
2631
2682
|
var uid = existedUid || this.getProductUid(normalizedProduct);
|
|
2632
2683
|
var extend = this.ensureExtend(tempOrder);
|
|
2633
2684
|
var existed = ((_extend$productsByUid = extend.productsByUid) === null || _extend$productsByUid === void 0 ? void 0 : _extend$productsByUid[uid]) || {};
|
|
2634
|
-
var origin = (
|
|
2685
|
+
var origin = (_ref44 = (_rawProduct$_origin = rawProduct._origin) !== null && _rawProduct$_origin !== void 0 ? _rawProduct$_origin : normalizedProduct._origin) !== null && _ref44 !== void 0 ? _ref44 : existed.origin;
|
|
2635
2686
|
extend.productsByUid[uid] = _objectSpread(_objectSpread({}, existed), origin !== undefined ? {
|
|
2636
2687
|
origin: origin
|
|
2637
2688
|
} : {});
|
|
@@ -2730,10 +2781,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2730
2781
|
}
|
|
2731
2782
|
});
|
|
2732
2783
|
products.forEach(function (product) {
|
|
2733
|
-
var _product$
|
|
2784
|
+
var _product$metadata3, _product$metadata4;
|
|
2734
2785
|
if (!product || _typeof(product) !== 'object') return;
|
|
2735
|
-
var productUid = ((_product$
|
|
2736
|
-
var bookingUid = product.booking_uid || ((_product$
|
|
2786
|
+
var productUid = ((_product$metadata3 = product.metadata) === null || _product$metadata3 === void 0 ? void 0 : _product$metadata3.unique_identification_number) || product.unique_identification_number;
|
|
2787
|
+
var bookingUid = product.booking_uid || ((_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.booking_uid);
|
|
2737
2788
|
var linkedBooking = (productUid !== undefined && productUid !== null && String(productUid) !== '' ? bookingByProductUid.get(String(productUid)) : undefined) || (bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '' ? bookingByBookingUid.get(String(bookingUid)) : undefined);
|
|
2738
2789
|
if (linkedBooking) {
|
|
2739
2790
|
_this16.setProductHolderFromBooking(product, linkedBooking);
|
|
@@ -2774,7 +2825,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2774
2825
|
}, {
|
|
2775
2826
|
key: "buildTempOrderHolderFromBookings",
|
|
2776
2827
|
value: function buildTempOrderHolderFromBookings(tempOrder) {
|
|
2777
|
-
var _baseHolder$customer_, _baseHolder,
|
|
2828
|
+
var _baseHolder$customer_, _baseHolder, _ref45, _baseHolder$form_id, _baseHolder2, _tempOrder$holder2, _baseHolder3, _this$otherParams;
|
|
2778
2829
|
var holderRecords = [];
|
|
2779
2830
|
var holderNames = [];
|
|
2780
2831
|
var baseHolder = null;
|
|
@@ -2821,7 +2872,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2821
2872
|
}
|
|
2822
2873
|
var nextHolder = {
|
|
2823
2874
|
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,
|
|
2824
|
-
form_id: (
|
|
2875
|
+
form_id: (_ref45 = (_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 && _ref45 !== void 0 ? _ref45 : 0,
|
|
2825
2876
|
form_record: holderRecords
|
|
2826
2877
|
};
|
|
2827
2878
|
if (holderNames.length) {
|
|
@@ -2872,11 +2923,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2872
2923
|
}, {
|
|
2873
2924
|
key: "removeLinkedBookingsForProduct",
|
|
2874
2925
|
value: function removeLinkedBookingsForProduct(tempOrder, product) {
|
|
2875
|
-
var _product$
|
|
2876
|
-
_product$
|
|
2926
|
+
var _product$metadata5,
|
|
2927
|
+
_product$metadata6,
|
|
2877
2928
|
_this18 = this;
|
|
2878
|
-
var productUid = (product === null || product === void 0 || (_product$
|
|
2879
|
-
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$
|
|
2929
|
+
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);
|
|
2930
|
+
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);
|
|
2880
2931
|
if (!productUid && !bookingUid) return;
|
|
2881
2932
|
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
2882
2933
|
var currentBookingUid = _this18.getBookingUniqueIdentificationNumber(booking);
|
|
@@ -2926,7 +2977,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2926
2977
|
key: "recalculateSummary",
|
|
2927
2978
|
value: function () {
|
|
2928
2979
|
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(options) {
|
|
2929
|
-
var _this$otherParams2,
|
|
2980
|
+
var _this$otherParams2, _ref46, _salesSummaryResult$e;
|
|
2930
2981
|
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;
|
|
2931
2982
|
return _regeneratorRuntime().wrap(function _callee12$(_context14) {
|
|
2932
2983
|
while (1) switch (_context14.prev = _context14.next) {
|
|
@@ -3004,7 +3055,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3004
3055
|
roundingAmount = paidPaymentSummary.roundingAmount;
|
|
3005
3056
|
payServiceChargeAmount = paidPaymentSummary.payServiceChargeAmount;
|
|
3006
3057
|
hasSalesSummaryAmount = salesSummaryResult.expect_amount !== undefined || salesSummaryResult.total_amount !== undefined;
|
|
3007
|
-
expectAmount = hasSalesSummaryAmount ? new Decimal((
|
|
3058
|
+
expectAmount = hasSalesSummaryAmount ? new Decimal((_ref46 = (_salesSummaryResult$e = salesSummaryResult.expect_amount) !== null && _salesSummaryResult$e !== void 0 ? _salesSummaryResult$e : salesSummaryResult.total_amount) !== null && _ref46 !== void 0 ? _ref46 : 0) : null;
|
|
3008
3059
|
amountPaymentPatch = hasSalesSummaryAmount || !roundingAmount.eq(0) || !payServiceChargeAmount.eq(0) ? _objectSpread({
|
|
3009
3060
|
rounding_amount: roundingAmount.toFixed(2)
|
|
3010
3061
|
}, expectAmount ? {
|
|
@@ -3182,17 +3233,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3182
3233
|
}, {
|
|
3183
3234
|
key: "buildTempOrderCustomer",
|
|
3184
3235
|
value: function buildTempOrderCustomer(params) {
|
|
3185
|
-
var _ref48, _ref49,
|
|
3236
|
+
var _ref47, _ref48, _ref49, _source$name, _ref50, _ref51, _ref52, _source$customer_name, _source$id, _source$customer_id, _ref53, _source$country_calli, _source$phone, _source$email;
|
|
3186
3237
|
if (!params.customerId) return null;
|
|
3187
3238
|
var source = params.source ? cloneDeep(params.source) : {};
|
|
3188
|
-
var name = (
|
|
3189
|
-
var customerName = (
|
|
3239
|
+
var name = (_ref47 = (_ref48 = (_ref49 = (_source$name = source.name) !== null && _source$name !== void 0 ? _source$name : source.display_name) !== null && _ref49 !== void 0 ? _ref49 : source.customerName) !== null && _ref48 !== void 0 ? _ref48 : source.customer_name) !== null && _ref47 !== void 0 ? _ref47 : params.customerName;
|
|
3240
|
+
var customerName = (_ref50 = (_ref51 = (_ref52 = (_source$customer_name = source.customer_name) !== null && _source$customer_name !== void 0 ? _source$customer_name : source.customerName) !== null && _ref52 !== void 0 ? _ref52 : source.display_name) !== null && _ref51 !== void 0 ? _ref51 : source.name) !== null && _ref50 !== void 0 ? _ref50 : params.customerName;
|
|
3190
3241
|
return _objectSpread(_objectSpread({}, source), {}, {
|
|
3191
3242
|
id: (_source$id = source.id) !== null && _source$id !== void 0 ? _source$id : params.customerId,
|
|
3192
3243
|
customer_id: (_source$customer_id = source.customer_id) !== null && _source$customer_id !== void 0 ? _source$customer_id : params.customerId,
|
|
3193
3244
|
name: String(name || ''),
|
|
3194
3245
|
customer_name: String(customerName || ''),
|
|
3195
|
-
country_calling_code: String((
|
|
3246
|
+
country_calling_code: String((_ref53 = (_source$country_calli = source.country_calling_code) !== null && _source$country_calli !== void 0 ? _source$country_calli : source.countryCallingCode) !== null && _ref53 !== void 0 ? _ref53 : params.countryCallingCode),
|
|
3196
3247
|
phone: String((_source$phone = source.phone) !== null && _source$phone !== void 0 ? _source$phone : params.phone),
|
|
3197
3248
|
email: String((_source$email = source.email) !== null && _source$email !== void 0 ? _source$email : params.email)
|
|
3198
3249
|
});
|
|
@@ -3296,14 +3347,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3296
3347
|
}, {
|
|
3297
3348
|
key: "updateTempOrderCustomer",
|
|
3298
3349
|
value: function updateTempOrderCustomer(customer) {
|
|
3299
|
-
var _tempOrder$customer_i2,
|
|
3350
|
+
var _tempOrder$customer_i2, _ref54, _ref55, _customer$customer_id, _ref56, _ref57, _ref58, _customer$customer_na, _ref59, _customer$country_cal, _tempOrder$customer_i3;
|
|
3300
3351
|
var tempOrder = this.ensureTempOrder();
|
|
3301
3352
|
var previousCustomerId = (_tempOrder$customer_i2 = tempOrder.customer_id) !== null && _tempOrder$customer_i2 !== void 0 ? _tempOrder$customer_i2 : null;
|
|
3302
|
-
var customerId = (
|
|
3303
|
-
var customerName = (
|
|
3353
|
+
var customerId = (_ref54 = (_ref55 = (_customer$customer_id = customer.customer_id) !== null && _customer$customer_id !== void 0 ? _customer$customer_id : customer.customerId) !== null && _ref55 !== void 0 ? _ref55 : customer.id) !== null && _ref54 !== void 0 ? _ref54 : null;
|
|
3354
|
+
var customerName = (_ref56 = (_ref57 = (_ref58 = (_customer$customer_na = customer.customer_name) !== null && _customer$customer_na !== void 0 ? _customer$customer_na : customer.customerName) !== null && _ref58 !== void 0 ? _ref58 : customer.display_name) !== null && _ref57 !== void 0 ? _ref57 : customer.name) !== null && _ref56 !== void 0 ? _ref56 : '';
|
|
3304
3355
|
tempOrder.customer_id = customerId === null || customerId === undefined || customerId === '' ? null : Number(customerId);
|
|
3305
3356
|
tempOrder.customer_name = String(customerName || '');
|
|
3306
|
-
tempOrder.country_calling_code = String((
|
|
3357
|
+
tempOrder.country_calling_code = String((_ref59 = (_customer$country_cal = customer.country_calling_code) !== null && _customer$country_cal !== void 0 ? _customer$country_cal : customer.countryCallingCode) !== null && _ref59 !== void 0 ? _ref59 : '');
|
|
3307
3358
|
tempOrder.phone = String(customer.phone || '');
|
|
3308
3359
|
tempOrder.email = String(customer.email || '');
|
|
3309
3360
|
tempOrder.customer = this.buildTempOrderCustomer({
|
|
@@ -3399,6 +3450,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3399
3450
|
if (tempOrder._extend) delete tempOrder._extend.customerSnapshot;
|
|
3400
3451
|
this.store.availableWalletIds = [];
|
|
3401
3452
|
this.clearCustomerBoundDiscounts(tempOrder);
|
|
3453
|
+
this.applyDiscount();
|
|
3402
3454
|
this.persistTempOrder();
|
|
3403
3455
|
this.saveDraftInBackground();
|
|
3404
3456
|
this.core.effects.emit(OrderHooks.OnOrderCustomerChange, null);
|
|
@@ -3878,8 +3930,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3878
3930
|
}, {
|
|
3879
3931
|
key: "hasLinkedBookingUid",
|
|
3880
3932
|
value: function hasLinkedBookingUid(product) {
|
|
3881
|
-
var _product$booking_uid, _product$
|
|
3882
|
-
var bookingUid = (_product$booking_uid = product === null || product === void 0 ? void 0 : product.booking_uid) !== null && _product$booking_uid !== void 0 ? _product$booking_uid : product === null || product === void 0 || (_product$
|
|
3933
|
+
var _product$booking_uid, _product$metadata7;
|
|
3934
|
+
var bookingUid = (_product$booking_uid = product === null || product === void 0 ? void 0 : product.booking_uid) !== null && _product$booking_uid !== void 0 ? _product$booking_uid : product === null || product === void 0 || (_product$metadata7 = product.metadata) === null || _product$metadata7 === void 0 ? void 0 : _product$metadata7.booking_uid;
|
|
3883
3935
|
return bookingUid !== undefined && bookingUid !== null && String(bookingUid) !== '';
|
|
3884
3936
|
}
|
|
3885
3937
|
|
|
@@ -3944,11 +3996,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3944
3996
|
}, {
|
|
3945
3997
|
key: "appendProductLineToTempOrder",
|
|
3946
3998
|
value: (function () {
|
|
3947
|
-
var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(tempOrder, product, booking) {
|
|
3948
|
-
var
|
|
3999
|
+
var _appendProductLineToTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(tempOrder, product, booking, options) {
|
|
4000
|
+
var _normalizedIncoming$p,
|
|
4001
|
+
_normalizedIncoming$p2,
|
|
4002
|
+
_booking_uid,
|
|
3949
4003
|
_metadata,
|
|
4004
|
+
_productToAdd$metadat,
|
|
4005
|
+
_origin,
|
|
3950
4006
|
_this26 = this;
|
|
3951
|
-
var linked, productToAdd, incomingFingerprint, normalizedIncoming, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingBookingUid, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum,
|
|
4007
|
+
var linked, productToAdd, incomingFingerprint, normalizedIncoming, isWeighingProduct, netWeight, incomingBookingUid, hasIncomingGoodPass, hasIncomingProductNote, hasIncomingManualProductDiscount, hasIncomingBookingUid, isIncomingCustomItem, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, insertAtIndex, _targetProduct$metada, targetProduct, targetUid, normalizedProduct, nextNum, mergedProduct;
|
|
3952
4008
|
return _regeneratorRuntime().wrap(function _callee20$(_context22) {
|
|
3953
4009
|
while (1) switch (_context22.prev = _context22.next) {
|
|
3954
4010
|
case 0:
|
|
@@ -3959,6 +4015,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3959
4015
|
productToAdd = (linked === null || linked === void 0 ? void 0 : linked.product) || product;
|
|
3960
4016
|
incomingFingerprint = buildProductLineFingerprint(getProductSkuOptions(productToAdd), productToAdd.product_bundle);
|
|
3961
4017
|
normalizedIncoming = mergeOrderProductDisplayFields(productToAdd, normalizeOrderProduct(productToAdd));
|
|
4018
|
+
isWeighingProduct = Number(((_normalizedIncoming$p = normalizedIncoming.product_sku) === null || _normalizedIncoming$p === void 0 ? void 0 : _normalizedIncoming$p.open_sold_weight) || 0) === 1;
|
|
4019
|
+
netWeight = Number((_normalizedIncoming$p2 = normalizedIncoming.product_sku) === null || _normalizedIncoming$p2 === void 0 ? void 0 : _normalizedIncoming$p2.net_weight);
|
|
4020
|
+
if (!(isWeighingProduct && (!Number.isFinite(netWeight) || netWeight <= 0))) {
|
|
4021
|
+
_context22.next = 8;
|
|
4022
|
+
break;
|
|
4023
|
+
}
|
|
4024
|
+
throw new Error('[Order] 称重商品净重必须大于 0');
|
|
4025
|
+
case 8:
|
|
3962
4026
|
incomingBookingUid = (_booking_uid = productToAdd.booking_uid) !== null && _booking_uid !== void 0 ? _booking_uid : (_metadata = productToAdd.metadata) === null || _metadata === void 0 ? void 0 : _metadata.booking_uid;
|
|
3963
4027
|
if (incomingBookingUid !== undefined && incomingBookingUid !== null && String(incomingBookingUid) !== '') {
|
|
3964
4028
|
normalizedIncoming.booking_uid = String(incomingBookingUid);
|
|
@@ -3969,12 +4033,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3969
4033
|
normalizedIncoming.discount_list = normalizeOrderProductDiscountList(normalizedIncoming.discount_list);
|
|
3970
4034
|
hasIncomingGoodPass = this.hasGoodPassDiscount(normalizedIncoming);
|
|
3971
4035
|
hasIncomingProductNote = this.hasOrderProductLineNote(normalizedIncoming);
|
|
4036
|
+
hasIncomingManualProductDiscount = isManualProductDiscountProduct(normalizedIncoming);
|
|
3972
4037
|
hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
|
|
3973
|
-
|
|
4038
|
+
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;
|
|
4039
|
+
shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingManualProductDiscount || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
|
|
3974
4040
|
matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
3975
4041
|
var _item$metadata3;
|
|
3976
4042
|
if (_this26.hasGoodPassDiscount(item)) return false;
|
|
3977
4043
|
if (_this26.hasOrderProductLineNote(item)) return false;
|
|
4044
|
+
if (isManualProductDiscountProduct(item)) return false;
|
|
3978
4045
|
if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
|
|
3979
4046
|
if ((_item$metadata3 = item.metadata) !== null && _item$metadata3 !== void 0 && _item$metadata3.is_edit_for_runtime) return false;
|
|
3980
4047
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
@@ -3985,10 +4052,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3985
4052
|
matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
|
|
3986
4053
|
existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
|
|
3987
4054
|
if (!matchedProduct) {
|
|
3988
|
-
_context22.next =
|
|
4055
|
+
_context22.next = 26;
|
|
3989
4056
|
break;
|
|
3990
4057
|
}
|
|
3991
|
-
_context22.next =
|
|
4058
|
+
_context22.next = 23;
|
|
3992
4059
|
return this.shouldMergeProductToOrder({
|
|
3993
4060
|
incomingProduct: productToAdd,
|
|
3994
4061
|
normalizedIncoming: normalizedIncoming,
|
|
@@ -3999,13 +4066,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3999
4066
|
tempOrder: tempOrder,
|
|
4000
4067
|
booking: booking
|
|
4001
4068
|
});
|
|
4002
|
-
case
|
|
4069
|
+
case 23:
|
|
4003
4070
|
_context22.t0 = _context22.sent;
|
|
4004
|
-
_context22.next =
|
|
4071
|
+
_context22.next = 27;
|
|
4005
4072
|
break;
|
|
4006
|
-
case
|
|
4073
|
+
case 26:
|
|
4007
4074
|
_context22.t0 = false;
|
|
4008
|
-
case
|
|
4075
|
+
case 27:
|
|
4009
4076
|
shouldMerge = _context22.t0;
|
|
4010
4077
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
4011
4078
|
this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
@@ -4015,8 +4082,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4015
4082
|
booking_uid: linked.bookingUid
|
|
4016
4083
|
});
|
|
4017
4084
|
}
|
|
4018
|
-
|
|
4019
|
-
|
|
4085
|
+
insertAtIndex = options === null || options === void 0 ? void 0 : options.insertAtIndex;
|
|
4086
|
+
if (Number.isInteger(insertAtIndex) && Number(insertAtIndex) >= 0 && Number(insertAtIndex) < tempOrder.products.length) {
|
|
4087
|
+
tempOrder.products = [].concat(_toConsumableArray(tempOrder.products.slice(0, insertAtIndex)), [normalizedIncoming], _toConsumableArray(tempOrder.products.slice(insertAtIndex)));
|
|
4088
|
+
} else {
|
|
4089
|
+
tempOrder.products = [].concat(_toConsumableArray(tempOrder.products), [normalizedIncoming]);
|
|
4090
|
+
}
|
|
4020
4091
|
} else {
|
|
4021
4092
|
targetProduct = matchedProduct;
|
|
4022
4093
|
targetUid = (_targetProduct$metada = targetProduct.metadata) === null || _targetProduct$metada === void 0 ? void 0 : _targetProduct$metada.unique_identification_number;
|
|
@@ -4027,10 +4098,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4027
4098
|
})));
|
|
4028
4099
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
4029
4100
|
nextNum = getSafeProductNum(targetProduct.num + normalizedProduct.num);
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
tempOrder.products[matchedIndex] = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, targetProduct), normalizedProduct), {}, {
|
|
4033
|
-
discount_list: nextDiscountList,
|
|
4101
|
+
tempOrder.products[matchedIndex] = _objectSpread(_objectSpread(_objectSpread({}, targetProduct), normalizedProduct), {}, {
|
|
4102
|
+
discount_list: normalizedProduct.discount_list,
|
|
4034
4103
|
metadata: _objectSpread(_objectSpread(_objectSpread({}, targetProduct.metadata || {}), normalizedProduct.metadata || {}), {}, {
|
|
4035
4104
|
unique_identification_number: targetUid
|
|
4036
4105
|
}),
|
|
@@ -4040,31 +4109,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4040
4109
|
option: []
|
|
4041
4110
|
}), {}, {
|
|
4042
4111
|
option: getProductSkuOptions(normalizedProduct)
|
|
4043
|
-
})
|
|
4044
|
-
}, targetIsManualProductDiscount ? {
|
|
4045
|
-
selling_price: targetProduct.selling_price,
|
|
4046
|
-
original_price: targetProduct.original_price,
|
|
4047
|
-
payment_price: targetProduct.payment_price,
|
|
4048
|
-
metadata: _objectSpread(_objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), targetProduct.metadata || {}), {}, {
|
|
4049
|
-
unique_identification_number: targetUid
|
|
4050
|
-
})
|
|
4051
|
-
} : {}), {}, {
|
|
4112
|
+
}),
|
|
4052
4113
|
note: targetProduct.note,
|
|
4053
4114
|
order_detail_id: targetProduct.order_detail_id,
|
|
4054
4115
|
num: nextNum
|
|
4055
4116
|
});
|
|
4056
4117
|
this.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
|
|
4118
|
+
if (matchedIndex !== tempOrder.products.length - 1) {
|
|
4119
|
+
mergedProduct = tempOrder.products[matchedIndex];
|
|
4120
|
+
tempOrder.products = [].concat(_toConsumableArray(tempOrder.products.slice(0, matchedIndex)), _toConsumableArray(tempOrder.products.slice(matchedIndex + 1)), [mergedProduct]);
|
|
4121
|
+
}
|
|
4057
4122
|
}
|
|
4058
4123
|
if (linked) {
|
|
4059
4124
|
tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
|
|
4060
4125
|
}
|
|
4061
|
-
case
|
|
4126
|
+
case 30:
|
|
4062
4127
|
case "end":
|
|
4063
4128
|
return _context22.stop();
|
|
4064
4129
|
}
|
|
4065
4130
|
}, _callee20, this);
|
|
4066
4131
|
}));
|
|
4067
|
-
function appendProductLineToTempOrder(_x22, _x23, _x24) {
|
|
4132
|
+
function appendProductLineToTempOrder(_x22, _x23, _x24, _x25) {
|
|
4068
4133
|
return _appendProductLineToTempOrder.apply(this, arguments);
|
|
4069
4134
|
}
|
|
4070
4135
|
return appendProductLineToTempOrder;
|
|
@@ -4080,61 +4145,74 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4080
4145
|
}, {
|
|
4081
4146
|
key: "addProductToOrder",
|
|
4082
4147
|
value: (function () {
|
|
4083
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(product, booking) {
|
|
4084
|
-
var tempOrder,
|
|
4148
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(product, booking, options) {
|
|
4149
|
+
var tempOrder, insertAfterProductUid, anchorIndex, insertAtIndex, _ref60, _productRecord$num, productRecord, splitCount, i, singleLine;
|
|
4085
4150
|
return _regeneratorRuntime().wrap(function _callee21$(_context23) {
|
|
4086
4151
|
while (1) switch (_context23.prev = _context23.next) {
|
|
4087
4152
|
case 0:
|
|
4088
4153
|
tempOrder = this.ensureTempOrder();
|
|
4154
|
+
insertAfterProductUid = options === null || options === void 0 ? void 0 : options.insertAfterProductUid;
|
|
4155
|
+
anchorIndex = booking && insertAfterProductUid ? tempOrder.products.findIndex(function (line) {
|
|
4156
|
+
var _line$metadata;
|
|
4157
|
+
var uid = ((_line$metadata = line.metadata) === null || _line$metadata === void 0 ? void 0 : _line$metadata.unique_identification_number) || line.unique_identification_number;
|
|
4158
|
+
return uid !== undefined && uid !== null && String(uid) === String(insertAfterProductUid);
|
|
4159
|
+
}) : -1;
|
|
4160
|
+
insertAtIndex = anchorIndex >= 0 ? anchorIndex + 1 : undefined;
|
|
4089
4161
|
if (!booking) {
|
|
4090
|
-
_context23.next =
|
|
4162
|
+
_context23.next = 22;
|
|
4091
4163
|
break;
|
|
4092
4164
|
}
|
|
4093
4165
|
productRecord = product;
|
|
4094
|
-
splitCount = getSafeProductNum((
|
|
4166
|
+
splitCount = getSafeProductNum((_ref60 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref60 !== void 0 ? _ref60 : 1);
|
|
4095
4167
|
if (!(splitCount > 1)) {
|
|
4096
|
-
_context23.next =
|
|
4168
|
+
_context23.next = 22;
|
|
4097
4169
|
break;
|
|
4098
4170
|
}
|
|
4099
4171
|
i = 0;
|
|
4100
|
-
case
|
|
4172
|
+
case 9:
|
|
4101
4173
|
if (!(i < splitCount)) {
|
|
4102
|
-
_context23.next =
|
|
4174
|
+
_context23.next = 19;
|
|
4103
4175
|
break;
|
|
4104
4176
|
}
|
|
4105
4177
|
singleLine = cloneDeep(productRecord);
|
|
4106
4178
|
singleLine.num = 1;
|
|
4107
4179
|
delete singleLine.product_quantity;
|
|
4108
|
-
_context23.next =
|
|
4109
|
-
return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking)
|
|
4110
|
-
|
|
4180
|
+
_context23.next = 15;
|
|
4181
|
+
return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking), {
|
|
4182
|
+
insertAtIndex: insertAtIndex
|
|
4183
|
+
});
|
|
4184
|
+
case 15:
|
|
4185
|
+
if (insertAtIndex !== undefined) insertAtIndex += 1;
|
|
4186
|
+
case 16:
|
|
4111
4187
|
i += 1;
|
|
4112
|
-
_context23.next =
|
|
4188
|
+
_context23.next = 9;
|
|
4113
4189
|
break;
|
|
4114
|
-
case
|
|
4115
|
-
_context23.next =
|
|
4190
|
+
case 19:
|
|
4191
|
+
_context23.next = 21;
|
|
4116
4192
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
4117
|
-
case
|
|
4193
|
+
case 21:
|
|
4118
4194
|
return _context23.abrupt("return", tempOrder.products);
|
|
4119
|
-
case 18:
|
|
4120
|
-
_context23.next = 20;
|
|
4121
|
-
return this.appendProductLineToTempOrder(tempOrder, product, booking);
|
|
4122
|
-
case 20:
|
|
4123
|
-
_context23.next = 22;
|
|
4124
|
-
return this.finalizeProductOrderMutation(tempOrder);
|
|
4125
4195
|
case 22:
|
|
4196
|
+
_context23.next = 24;
|
|
4197
|
+
return this.appendProductLineToTempOrder(tempOrder, product, booking, {
|
|
4198
|
+
insertAtIndex: insertAtIndex
|
|
4199
|
+
});
|
|
4200
|
+
case 24:
|
|
4201
|
+
_context23.next = 26;
|
|
4202
|
+
return this.finalizeProductOrderMutation(tempOrder);
|
|
4203
|
+
case 26:
|
|
4126
4204
|
this.logInfo('addProductToOrder success', {
|
|
4127
4205
|
product_id: product.product_id,
|
|
4128
4206
|
with_booking: !!booking
|
|
4129
4207
|
});
|
|
4130
4208
|
return _context23.abrupt("return", tempOrder.products);
|
|
4131
|
-
case
|
|
4209
|
+
case 28:
|
|
4132
4210
|
case "end":
|
|
4133
4211
|
return _context23.stop();
|
|
4134
4212
|
}
|
|
4135
4213
|
}, _callee21, this);
|
|
4136
4214
|
}));
|
|
4137
|
-
function addProductToOrder(
|
|
4215
|
+
function addProductToOrder(_x26, _x27, _x28) {
|
|
4138
4216
|
return _addProductToOrder.apply(this, arguments);
|
|
4139
4217
|
}
|
|
4140
4218
|
return addProductToOrder;
|
|
@@ -4153,7 +4231,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4153
4231
|
key: "addProductsToOrder",
|
|
4154
4232
|
value: (function () {
|
|
4155
4233
|
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(items, options) {
|
|
4156
|
-
var tempOrder, _iterator20, _step20, item, product, booking,
|
|
4234
|
+
var tempOrder, _iterator20, _step20, item, product, booking, _ref61, _productRecord$num2, productRecord, splitCount, i, singleLine;
|
|
4157
4235
|
return _regeneratorRuntime().wrap(function _callee22$(_context24) {
|
|
4158
4236
|
while (1) switch (_context24.prev = _context24.next) {
|
|
4159
4237
|
case 0:
|
|
@@ -4185,7 +4263,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4185
4263
|
break;
|
|
4186
4264
|
}
|
|
4187
4265
|
productRecord = product;
|
|
4188
|
-
splitCount = getSafeProductNum((
|
|
4266
|
+
splitCount = getSafeProductNum((_ref61 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref61 !== void 0 ? _ref61 : 1);
|
|
4189
4267
|
if (!(splitCount > 1)) {
|
|
4190
4268
|
_context24.next = 26;
|
|
4191
4269
|
break;
|
|
@@ -4238,7 +4316,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4238
4316
|
}
|
|
4239
4317
|
}, _callee22, this, [[4, 32, 35, 38]]);
|
|
4240
4318
|
}));
|
|
4241
|
-
function addProductsToOrder(
|
|
4319
|
+
function addProductsToOrder(_x29, _x30) {
|
|
4242
4320
|
return _addProductsToOrder.apply(this, arguments);
|
|
4243
4321
|
}
|
|
4244
4322
|
return addProductsToOrder;
|
|
@@ -4265,9 +4343,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4265
4343
|
}, {
|
|
4266
4344
|
key: "getBundleRuntimeIdentity",
|
|
4267
4345
|
value: function getBundleRuntimeIdentity(bundle) {
|
|
4268
|
-
var
|
|
4346
|
+
var _ref62, _bundle$bundle_id2, _ref63, _bundle$bundle_group_2, _ref64, _ref65, _bundle$bundle_produc3, _ref66, _bundle$bundle_varian3;
|
|
4269
4347
|
if (!bundle || _typeof(bundle) !== 'object') return '';
|
|
4270
|
-
return [(
|
|
4348
|
+
return [(_ref62 = (_bundle$bundle_id2 = bundle.bundle_id) !== null && _bundle$bundle_id2 !== void 0 ? _bundle$bundle_id2 : bundle.id) !== null && _ref62 !== void 0 ? _ref62 : '', (_ref63 = (_bundle$bundle_group_2 = bundle.bundle_group_id) !== null && _bundle$bundle_group_2 !== void 0 ? _bundle$bundle_group_2 : bundle.group_id) !== null && _ref63 !== void 0 ? _ref63 : '', (_ref64 = (_ref65 = (_bundle$bundle_produc3 = bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle._bundle_product_id) !== null && _ref65 !== void 0 ? _ref65 : bundle.product_id) !== null && _ref64 !== void 0 ? _ref64 : '', (_ref66 = (_bundle$bundle_varian3 = bundle.bundle_variant_id) !== null && _bundle$bundle_varian3 !== void 0 ? _bundle$bundle_varian3 : bundle.product_variant_id) !== null && _ref66 !== void 0 ? _ref66 : 0].join('|');
|
|
4271
4349
|
}
|
|
4272
4350
|
}, {
|
|
4273
4351
|
key: "preservePersistedBundlePriceFields",
|
|
@@ -4418,13 +4496,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4418
4496
|
delete nextProduct.metadata.main_product_original_price;
|
|
4419
4497
|
delete nextProduct.metadata.price_schema_version;
|
|
4420
4498
|
} else if (callerChangesLineConfiguration && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
4421
|
-
var
|
|
4499
|
+
var _ref67, _targetProduct$metada10, _targetProduct$metada11, _ref68, _targetProduct$metada12, _targetProduct$metada13, _targetProduct$metada14;
|
|
4422
4500
|
// 仅 option / bundle 变化时,保留历史 source 和主商品折扣金额,
|
|
4423
4501
|
// 但必须让 original 与 selling 一起随新的 option 金额移动。
|
|
4424
4502
|
var previousOptionSum = sumOptionUnitPrice(getProductSkuOptions(targetProduct));
|
|
4425
4503
|
var nextOptionSum = sumOptionUnitPrice(getProductSkuOptions(nextProduct));
|
|
4426
|
-
var _previousMainOriginal = new Decimal(Number((
|
|
4427
|
-
var _previousMainSelling = new Decimal(Number((
|
|
4504
|
+
var _previousMainOriginal = new Decimal(Number((_ref67 = (_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 && _ref67 !== void 0 ? _ref67 : 0) || 0);
|
|
4505
|
+
var _previousMainSelling = new Decimal(Number((_ref68 = (_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 && _ref68 !== void 0 ? _ref68 : _previousMainOriginal.toNumber()) || 0);
|
|
4428
4506
|
var _preservedDiscount = _previousMainOriginal.minus(_previousMainSelling);
|
|
4429
4507
|
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);
|
|
4430
4508
|
var _nextMainOriginal = previousSource.plus(nextOptionSum);
|
|
@@ -4513,7 +4591,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4513
4591
|
}
|
|
4514
4592
|
}, _callee23, this);
|
|
4515
4593
|
}));
|
|
4516
|
-
function updateOrderProduct(
|
|
4594
|
+
function updateOrderProduct(_x31) {
|
|
4517
4595
|
return _updateOrderProduct.apply(this, arguments);
|
|
4518
4596
|
}
|
|
4519
4597
|
return updateOrderProduct;
|
|
@@ -4557,7 +4635,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4557
4635
|
}
|
|
4558
4636
|
}, _callee24, this);
|
|
4559
4637
|
}));
|
|
4560
|
-
function updateOrderProducts(
|
|
4638
|
+
function updateOrderProducts(_x32) {
|
|
4561
4639
|
return _updateOrderProducts.apply(this, arguments);
|
|
4562
4640
|
}
|
|
4563
4641
|
return updateOrderProducts;
|
|
@@ -4634,7 +4712,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4634
4712
|
}
|
|
4635
4713
|
}, _callee25, this);
|
|
4636
4714
|
}));
|
|
4637
|
-
function updateOrderProductQuantity(
|
|
4715
|
+
function updateOrderProductQuantity(_x33) {
|
|
4638
4716
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
4639
4717
|
}
|
|
4640
4718
|
return updateOrderProductQuantity;
|
|
@@ -4699,7 +4777,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4699
4777
|
}
|
|
4700
4778
|
}, _callee26, this);
|
|
4701
4779
|
}));
|
|
4702
|
-
function finalizeAfterProductsMutation(
|
|
4780
|
+
function finalizeAfterProductsMutation(_x34, _x35) {
|
|
4703
4781
|
return _finalizeAfterProductsMutation.apply(this, arguments);
|
|
4704
4782
|
}
|
|
4705
4783
|
return finalizeAfterProductsMutation;
|
|
@@ -4714,9 +4792,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4714
4792
|
}, {
|
|
4715
4793
|
key: "removeProductsFromOrder",
|
|
4716
4794
|
value: (function () {
|
|
4717
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(identities) {
|
|
4795
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(identities, options) {
|
|
4718
4796
|
var _this29 = this;
|
|
4719
|
-
var tempOrder, productsBeforeRemove, bookingsBeforeRemove, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3;
|
|
4797
|
+
var tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
|
|
4720
4798
|
return _regeneratorRuntime().wrap(function _callee27$(_context30) {
|
|
4721
4799
|
while (1) switch (_context30.prev = _context30.next) {
|
|
4722
4800
|
case 0:
|
|
@@ -4730,6 +4808,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4730
4808
|
case 4:
|
|
4731
4809
|
productsBeforeRemove = tempOrder.products || [];
|
|
4732
4810
|
bookingsBeforeRemove = tempOrder.bookings || [];
|
|
4811
|
+
preserveDisplayPosition = options === null || options === void 0 ? void 0 : options.preserveDisplayPosition;
|
|
4812
|
+
anchorIndex = preserveDisplayPosition ? productsBeforeRemove.findIndex(function (item) {
|
|
4813
|
+
var _item$metadata6;
|
|
4814
|
+
var uid = ((_item$metadata6 = item.metadata) === null || _item$metadata6 === void 0 ? void 0 : _item$metadata6.unique_identification_number) || item.unique_identification_number;
|
|
4815
|
+
return uid !== undefined && uid !== null && String(uid) === String(preserveDisplayPosition.anchorProductUid);
|
|
4816
|
+
}) : -1;
|
|
4817
|
+
productsAfterAnchor = anchorIndex >= 0 ? productsBeforeRemove.slice(anchorIndex + 1) : [];
|
|
4733
4818
|
matchedProducts = productsBeforeRemove.filter(function (item) {
|
|
4734
4819
|
return identities.some(function (identity) {
|
|
4735
4820
|
return isIdentityMatch(item, identity);
|
|
@@ -4749,7 +4834,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4749
4834
|
}
|
|
4750
4835
|
linkedBookingUidsToRemove = new Set();
|
|
4751
4836
|
_iterator21 = _createForOfIteratorHelper(matchedProducts);
|
|
4752
|
-
_context30.prev =
|
|
4837
|
+
_context30.prev = 15;
|
|
4753
4838
|
_loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
|
|
4754
4839
|
var _metadata11, _metadata12, _metadata13, _metadata14;
|
|
4755
4840
|
var product, productUid, productBookingUid, isAddTimeProduct;
|
|
@@ -4784,56 +4869,72 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4784
4869
|
}, _loop3);
|
|
4785
4870
|
});
|
|
4786
4871
|
_iterator21.s();
|
|
4787
|
-
case
|
|
4872
|
+
case 18:
|
|
4788
4873
|
if ((_step21 = _iterator21.n()).done) {
|
|
4789
|
-
_context30.next =
|
|
4874
|
+
_context30.next = 24;
|
|
4790
4875
|
break;
|
|
4791
4876
|
}
|
|
4792
|
-
return _context30.delegateYield(_loop3(), "t0",
|
|
4793
|
-
case
|
|
4877
|
+
return _context30.delegateYield(_loop3(), "t0", 20);
|
|
4878
|
+
case 20:
|
|
4794
4879
|
if (!_context30.t0) {
|
|
4795
|
-
_context30.next =
|
|
4880
|
+
_context30.next = 22;
|
|
4796
4881
|
break;
|
|
4797
4882
|
}
|
|
4798
|
-
return _context30.abrupt("continue",
|
|
4799
|
-
case
|
|
4800
|
-
_context30.next =
|
|
4883
|
+
return _context30.abrupt("continue", 22);
|
|
4884
|
+
case 22:
|
|
4885
|
+
_context30.next = 18;
|
|
4801
4886
|
break;
|
|
4802
|
-
case
|
|
4803
|
-
_context30.next =
|
|
4887
|
+
case 24:
|
|
4888
|
+
_context30.next = 29;
|
|
4804
4889
|
break;
|
|
4805
|
-
case 23:
|
|
4806
|
-
_context30.prev = 23;
|
|
4807
|
-
_context30.t1 = _context30["catch"](12);
|
|
4808
|
-
_iterator21.e(_context30.t1);
|
|
4809
4890
|
case 26:
|
|
4810
4891
|
_context30.prev = 26;
|
|
4811
|
-
|
|
4812
|
-
|
|
4892
|
+
_context30.t1 = _context30["catch"](15);
|
|
4893
|
+
_iterator21.e(_context30.t1);
|
|
4813
4894
|
case 29:
|
|
4895
|
+
_context30.prev = 29;
|
|
4896
|
+
_iterator21.f();
|
|
4897
|
+
return _context30.finish(29);
|
|
4898
|
+
case 32:
|
|
4814
4899
|
if (linkedBookingUidsToRemove.size > 0) {
|
|
4815
4900
|
// 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
|
|
4816
4901
|
tempOrder.products = (tempOrder.products || []).filter(function (line) {
|
|
4817
|
-
var _line$
|
|
4818
|
-
var lineBookingUid = (line === null || line === void 0 || (_line$
|
|
4819
|
-
var isAddTimeProduct = (line === null || line === void 0 || (_line$
|
|
4902
|
+
var _line$metadata2, _line$metadata3, _line$metadata4;
|
|
4903
|
+
var lineBookingUid = (line === null || line === void 0 || (_line$metadata2 = line.metadata) === null || _line$metadata2 === void 0 ? void 0 : _line$metadata2.booking_uid) || (line === null || line === void 0 ? void 0 : line.booking_uid);
|
|
4904
|
+
var isAddTimeProduct = (line === null || line === void 0 || (_line$metadata3 = line.metadata) === null || _line$metadata3 === void 0 ? void 0 : _line$metadata3.product_add_schedule_time) !== undefined && (line === null || line === void 0 || (_line$metadata4 = line.metadata) === null || _line$metadata4 === void 0 ? void 0 : _line$metadata4.product_add_schedule_time) !== null;
|
|
4820
4905
|
return !(isAddTimeProduct && lineBookingUid !== undefined && lineBookingUid !== null && linkedBookingUidsToRemove.has(String(lineBookingUid)));
|
|
4821
4906
|
});
|
|
4822
4907
|
}
|
|
4823
|
-
|
|
4908
|
+
if (preserveDisplayPosition && anchorIndex >= 0) {
|
|
4909
|
+
remainingProductIndex = tempOrder.products.findIndex(function (item) {
|
|
4910
|
+
var _item$metadata7;
|
|
4911
|
+
var uid = ((_item$metadata7 = item.metadata) === null || _item$metadata7 === void 0 ? void 0 : _item$metadata7.unique_identification_number) || item.unique_identification_number;
|
|
4912
|
+
return uid !== undefined && uid !== null && String(uid) === String(preserveDisplayPosition.remainingProductUid);
|
|
4913
|
+
});
|
|
4914
|
+
if (remainingProductIndex >= 0) {
|
|
4915
|
+
remainingProduct = tempOrder.products[remainingProductIndex];
|
|
4916
|
+
nextProduct = productsAfterAnchor.find(function (item) {
|
|
4917
|
+
return tempOrder.products.includes(item);
|
|
4918
|
+
});
|
|
4919
|
+
productsWithoutRemaining = [].concat(_toConsumableArray(tempOrder.products.slice(0, remainingProductIndex)), _toConsumableArray(tempOrder.products.slice(remainingProductIndex + 1)));
|
|
4920
|
+
nextProductIndex = nextProduct ? productsWithoutRemaining.indexOf(nextProduct) : -1;
|
|
4921
|
+
tempOrder.products = nextProductIndex >= 0 ? [].concat(_toConsumableArray(productsWithoutRemaining.slice(0, nextProductIndex)), [remainingProduct], _toConsumableArray(productsWithoutRemaining.slice(nextProductIndex))) : [].concat(_toConsumableArray(productsWithoutRemaining), [remainingProduct]);
|
|
4922
|
+
}
|
|
4923
|
+
}
|
|
4924
|
+
_context30.next = 36;
|
|
4824
4925
|
return this.finalizeAfterProductsMutation(tempOrder);
|
|
4825
|
-
case
|
|
4926
|
+
case 36:
|
|
4826
4927
|
this.logInfo('removeProductsFromOrder success', {
|
|
4827
4928
|
identities: identities
|
|
4828
4929
|
});
|
|
4829
4930
|
return _context30.abrupt("return", tempOrder.products);
|
|
4830
|
-
case
|
|
4931
|
+
case 38:
|
|
4831
4932
|
case "end":
|
|
4832
4933
|
return _context30.stop();
|
|
4833
4934
|
}
|
|
4834
|
-
}, _callee27, this, [[
|
|
4935
|
+
}, _callee27, this, [[15, 26, 29, 32]]);
|
|
4835
4936
|
}));
|
|
4836
|
-
function removeProductsFromOrder(
|
|
4937
|
+
function removeProductsFromOrder(_x36, _x37) {
|
|
4837
4938
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
4838
4939
|
}
|
|
4839
4940
|
return removeProductsFromOrder;
|
|
@@ -4841,18 +4942,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4841
4942
|
}, {
|
|
4842
4943
|
key: "removeProductFromOrder",
|
|
4843
4944
|
value: function () {
|
|
4844
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(identity) {
|
|
4945
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(identity, options) {
|
|
4845
4946
|
return _regeneratorRuntime().wrap(function _callee28$(_context31) {
|
|
4846
4947
|
while (1) switch (_context31.prev = _context31.next) {
|
|
4847
4948
|
case 0:
|
|
4848
|
-
return _context31.abrupt("return", this.removeProductsFromOrder([identity]));
|
|
4949
|
+
return _context31.abrupt("return", this.removeProductsFromOrder([identity], options));
|
|
4849
4950
|
case 1:
|
|
4850
4951
|
case "end":
|
|
4851
4952
|
return _context31.stop();
|
|
4852
4953
|
}
|
|
4853
4954
|
}, _callee28, this);
|
|
4854
4955
|
}));
|
|
4855
|
-
function removeProductFromOrder(
|
|
4956
|
+
function removeProductFromOrder(_x38, _x39) {
|
|
4856
4957
|
return _removeProductFromOrder.apply(this, arguments);
|
|
4857
4958
|
}
|
|
4858
4959
|
return removeProductFromOrder;
|
|
@@ -4906,23 +5007,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4906
5007
|
}, {
|
|
4907
5008
|
key: "buildCurrentSubmitPayloadForLocalPrint",
|
|
4908
5009
|
value: function buildCurrentSubmitPayloadForLocalPrint(params) {
|
|
4909
|
-
var _params$cacheId, _this$otherParams3,
|
|
5010
|
+
var _params$cacheId, _this$otherParams3, _ref69, _params$businessCode, _this$otherParams4, _this$otherParams5;
|
|
4910
5011
|
var tempOrder = this.ensureTempOrder();
|
|
4911
5012
|
this.persistTempOrder();
|
|
4912
5013
|
var payload = buildSubmitPayload({
|
|
4913
5014
|
tempOrder: tempOrder,
|
|
4914
5015
|
cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
|
|
4915
5016
|
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.platform),
|
|
4916
|
-
businessCode: (
|
|
5017
|
+
businessCode: (_ref69 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.businessCode) !== null && _ref69 !== void 0 ? _ref69 : (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.business_code,
|
|
4917
5018
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
4918
5019
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
4919
5020
|
summary: this.store.summary || createEmptySummary(),
|
|
4920
5021
|
enhance: function enhance(nextPayload) {
|
|
4921
|
-
var
|
|
5022
|
+
var _ref70, _tempOrder$order_numb, _ref71, _tempOrder$shop_order, _ref72, _tempOrder$shop_full_;
|
|
4922
5023
|
return _objectSpread(_objectSpread({}, nextPayload), {}, {
|
|
4923
|
-
order_number: (
|
|
4924
|
-
shop_order_number: (
|
|
4925
|
-
shop_full_order_number: (
|
|
5024
|
+
order_number: (_ref70 = (_tempOrder$order_numb = tempOrder.order_number) !== null && _tempOrder$order_numb !== void 0 ? _tempOrder$order_numb : nextPayload.order_number) !== null && _ref70 !== void 0 ? _ref70 : null,
|
|
5025
|
+
shop_order_number: (_ref71 = (_tempOrder$shop_order = tempOrder.shop_order_number) !== null && _tempOrder$shop_order !== void 0 ? _tempOrder$shop_order : nextPayload.shop_order_number) !== null && _ref71 !== void 0 ? _ref71 : null,
|
|
5026
|
+
shop_full_order_number: (_ref72 = (_tempOrder$shop_full_ = tempOrder.shop_full_order_number) !== null && _tempOrder$shop_full_ !== void 0 ? _tempOrder$shop_full_ : nextPayload.shop_full_order_number) !== null && _ref72 !== void 0 ? _ref72 : null,
|
|
4926
5027
|
small_ticket_data_flag: 1
|
|
4927
5028
|
});
|
|
4928
5029
|
}
|
|
@@ -4964,7 +5065,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4964
5065
|
}
|
|
4965
5066
|
}, _callee30, this);
|
|
4966
5067
|
}));
|
|
4967
|
-
function applyLocalPrintOrderNumbers(
|
|
5068
|
+
function applyLocalPrintOrderNumbers(_x40) {
|
|
4968
5069
|
return _applyLocalPrintOrderNumbers.apply(this, arguments);
|
|
4969
5070
|
}
|
|
4970
5071
|
return applyLocalPrintOrderNumbers;
|
|
@@ -5031,7 +5132,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5031
5132
|
}
|
|
5032
5133
|
}, _callee31, this);
|
|
5033
5134
|
}));
|
|
5034
|
-
function saveTempOrderAsDraft(
|
|
5135
|
+
function saveTempOrderAsDraft(_x41) {
|
|
5035
5136
|
return _saveTempOrderAsDraft.apply(this, arguments);
|
|
5036
5137
|
}
|
|
5037
5138
|
return saveTempOrderAsDraft;
|
|
@@ -5056,7 +5157,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5056
5157
|
}
|
|
5057
5158
|
}, _callee32, this);
|
|
5058
5159
|
}));
|
|
5059
|
-
function submitTempOrder(
|
|
5160
|
+
function submitTempOrder(_x42) {
|
|
5060
5161
|
return _submitTempOrder.apply(this, arguments);
|
|
5061
5162
|
}
|
|
5062
5163
|
return submitTempOrder;
|
|
@@ -5077,7 +5178,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5077
5178
|
}
|
|
5078
5179
|
}, _callee33, this);
|
|
5079
5180
|
}));
|
|
5080
|
-
function submitTempOrderAsync(
|
|
5181
|
+
function submitTempOrderAsync(_x43) {
|
|
5081
5182
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
5082
5183
|
}
|
|
5083
5184
|
return submitTempOrderAsync;
|
|
@@ -5086,7 +5187,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5086
5187
|
key: "runSubmitTempOrder",
|
|
5087
5188
|
value: function () {
|
|
5088
5189
|
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
5089
|
-
var _params$cacheId3, _this$otherParams10,
|
|
5190
|
+
var _params$cacheId3, _this$otherParams10, _ref73, _ref74, _submitSnapshot$busin, _this$otherParams11, _this$otherParams12, _submitSnapshot$type;
|
|
5090
5191
|
var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
|
|
5091
5192
|
return _regeneratorRuntime().wrap(function _callee34$(_context37) {
|
|
5092
5193
|
while (1) switch (_context37.prev = _context37.next) {
|
|
@@ -5148,7 +5249,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5148
5249
|
tempOrder: tempOrder,
|
|
5149
5250
|
cacheId: effectiveCacheId,
|
|
5150
5251
|
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.platform),
|
|
5151
|
-
businessCode: (
|
|
5252
|
+
businessCode: (_ref73 = (_ref74 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref74 !== void 0 ? _ref74 : (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) !== null && _ref73 !== void 0 ? _ref73 : (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.business_code,
|
|
5152
5253
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
5153
5254
|
type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
|
|
5154
5255
|
summary: latestSummary,
|
|
@@ -5247,7 +5348,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5247
5348
|
}
|
|
5248
5349
|
}, _callee34, this, [[26, 33]]);
|
|
5249
5350
|
}));
|
|
5250
|
-
function runSubmitTempOrder(
|
|
5351
|
+
function runSubmitTempOrder(_x44) {
|
|
5251
5352
|
return _runSubmitTempOrder.apply(this, arguments);
|
|
5252
5353
|
}
|
|
5253
5354
|
return runSubmitTempOrder;
|
|
@@ -5274,7 +5375,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5274
5375
|
}
|
|
5275
5376
|
}, _callee35, this);
|
|
5276
5377
|
}));
|
|
5277
|
-
function markLocalOrderSynced(
|
|
5378
|
+
function markLocalOrderSynced(_x45, _x46) {
|
|
5278
5379
|
return _markLocalOrderSynced.apply(this, arguments);
|
|
5279
5380
|
}
|
|
5280
5381
|
return markLocalOrderSynced;
|
|
@@ -5443,7 +5544,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5443
5544
|
}
|
|
5444
5545
|
}, _callee36, this);
|
|
5445
5546
|
}));
|
|
5446
|
-
function syncPaymentsToOrder(
|
|
5547
|
+
function syncPaymentsToOrder(_x47) {
|
|
5447
5548
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
5448
5549
|
}
|
|
5449
5550
|
return syncPaymentsToOrder;
|
|
@@ -5571,7 +5672,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5571
5672
|
}
|
|
5572
5673
|
}, _callee37, this);
|
|
5573
5674
|
}));
|
|
5574
|
-
function submitOrder(
|
|
5675
|
+
function submitOrder(_x48) {
|
|
5575
5676
|
return _submitOrder.apply(this, arguments);
|
|
5576
5677
|
}
|
|
5577
5678
|
return submitOrder;
|
|
@@ -5610,7 +5711,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5610
5711
|
}
|
|
5611
5712
|
}, _callee38, this);
|
|
5612
5713
|
}));
|
|
5613
|
-
function cancelOrder(
|
|
5714
|
+
function cancelOrder(_x49) {
|
|
5614
5715
|
return _cancelOrder.apply(this, arguments);
|
|
5615
5716
|
}
|
|
5616
5717
|
return cancelOrder;
|
|
@@ -5654,7 +5755,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5654
5755
|
}
|
|
5655
5756
|
}, _callee39, this);
|
|
5656
5757
|
}));
|
|
5657
|
-
function changeBookingStatus(
|
|
5758
|
+
function changeBookingStatus(_x50) {
|
|
5658
5759
|
return _changeBookingStatus.apply(this, arguments);
|
|
5659
5760
|
}
|
|
5660
5761
|
return changeBookingStatus;
|
|
@@ -5801,7 +5902,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5801
5902
|
}
|
|
5802
5903
|
}, _callee40, this, [[4, 18]]);
|
|
5803
5904
|
}));
|
|
5804
|
-
function createOrderByCheckout(
|
|
5905
|
+
function createOrderByCheckout(_x51) {
|
|
5805
5906
|
return _createOrderByCheckout.apply(this, arguments);
|
|
5806
5907
|
}
|
|
5807
5908
|
return createOrderByCheckout;
|
|
@@ -5826,7 +5927,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5826
5927
|
}
|
|
5827
5928
|
}, _callee41, this);
|
|
5828
5929
|
}));
|
|
5829
|
-
function submitSalesOrder(
|
|
5930
|
+
function submitSalesOrder(_x52) {
|
|
5830
5931
|
return _submitSalesOrder.apply(this, arguments);
|
|
5831
5932
|
}
|
|
5832
5933
|
return submitSalesOrder;
|
|
@@ -5870,7 +5971,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5870
5971
|
}
|
|
5871
5972
|
}, _callee42, this);
|
|
5872
5973
|
}));
|
|
5873
|
-
function sendCustomerPayLink(
|
|
5974
|
+
function sendCustomerPayLink(_x53) {
|
|
5874
5975
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
5875
5976
|
}
|
|
5876
5977
|
return sendCustomerPayLink;
|
|
@@ -5914,7 +6015,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5914
6015
|
}
|
|
5915
6016
|
}, _callee43, this);
|
|
5916
6017
|
}));
|
|
5917
|
-
function getSalesOrderByLookup(
|
|
6018
|
+
function getSalesOrderByLookup(_x54) {
|
|
5918
6019
|
return _getSalesOrderByLookup.apply(this, arguments);
|
|
5919
6020
|
}
|
|
5920
6021
|
return getSalesOrderByLookup;
|
|
@@ -6075,7 +6176,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6075
6176
|
}
|
|
6076
6177
|
}, _callee44, this);
|
|
6077
6178
|
}));
|
|
6078
|
-
function hydrateTempOrderFromRecord(
|
|
6179
|
+
function hydrateTempOrderFromRecord(_x55, _x56) {
|
|
6079
6180
|
return _hydrateTempOrderFromRecord.apply(this, arguments);
|
|
6080
6181
|
}
|
|
6081
6182
|
return hydrateTempOrderFromRecord;
|
|
@@ -6128,10 +6229,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6128
6229
|
_step22;
|
|
6129
6230
|
try {
|
|
6130
6231
|
for (_iterator22.s(); !(_step22 = _iterator22.n()).done;) {
|
|
6131
|
-
var _product$
|
|
6232
|
+
var _product$metadata8;
|
|
6132
6233
|
var product = _step22.value;
|
|
6133
6234
|
var productUid = getOrderCollectionUid('product', product);
|
|
6134
|
-
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$
|
|
6235
|
+
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata8 = product.metadata) === null || _product$metadata8 === void 0 ? void 0 : _product$metadata8.booking_uid);
|
|
6135
6236
|
if (!productUid || bookingUid === undefined || bookingUid === null || bookingUid === '') {
|
|
6136
6237
|
continue;
|
|
6137
6238
|
}
|
|
@@ -6248,15 +6349,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6248
6349
|
_step24;
|
|
6249
6350
|
try {
|
|
6250
6351
|
for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
|
|
6251
|
-
var _product$
|
|
6352
|
+
var _product$metadata9, _ref75, _ref76, _existed$origin, _rawProduct$metadata;
|
|
6252
6353
|
var _step24$value = _slicedToArray(_step24.value, 2),
|
|
6253
6354
|
index = _step24$value[0],
|
|
6254
6355
|
product = _step24$value[1];
|
|
6255
|
-
var uid = (_product$
|
|
6356
|
+
var uid = (_product$metadata9 = product.metadata) === null || _product$metadata9 === void 0 ? void 0 : _product$metadata9.unique_identification_number;
|
|
6256
6357
|
if (!uid) continue;
|
|
6257
6358
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
6258
6359
|
var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
|
|
6259
|
-
var origin = (
|
|
6360
|
+
var origin = (_ref75 = (_ref76 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref76 !== void 0 ? _ref76 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref75 !== void 0 ? _ref75 : rawProduct;
|
|
6260
6361
|
var originSnapshot = cloneDeep(origin);
|
|
6261
6362
|
var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
|
|
6262
6363
|
if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
|
|
@@ -6307,8 +6408,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6307
6408
|
var bookingUidByProductUid = new Map();
|
|
6308
6409
|
var productByUid = new Map();
|
|
6309
6410
|
(tempOrder.products || []).forEach(function (product) {
|
|
6310
|
-
var _product$
|
|
6311
|
-
var productUid = (product === null || product === void 0 || (_product$
|
|
6411
|
+
var _product$metadata10;
|
|
6412
|
+
var productUid = (product === null || product === void 0 || (_product$metadata10 = product.metadata) === null || _product$metadata10 === void 0 ? void 0 : _product$metadata10.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
6312
6413
|
if (productUid !== undefined && productUid !== null && String(productUid) !== '') {
|
|
6313
6414
|
productByUid.set(String(productUid), product);
|
|
6314
6415
|
}
|
|
@@ -6329,8 +6430,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6329
6430
|
bookingUidByProductUid.set(String(productUid), bookingUid);
|
|
6330
6431
|
});
|
|
6331
6432
|
(tempOrder.products || []).forEach(function (product) {
|
|
6332
|
-
var _product$
|
|
6333
|
-
var productUid = (product === null || product === void 0 || (_product$
|
|
6433
|
+
var _product$metadata11;
|
|
6434
|
+
var productUid = (product === null || product === void 0 || (_product$metadata11 = product.metadata) === null || _product$metadata11 === void 0 ? void 0 : _product$metadata11.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
6334
6435
|
if (productUid === undefined || productUid === null || String(productUid) === '') return;
|
|
6335
6436
|
var bookingUid = bookingUidByProductUid.get(String(productUid));
|
|
6336
6437
|
if (!bookingUid) return;
|
|
@@ -6385,10 +6486,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6385
6486
|
}, {
|
|
6386
6487
|
key: "normalizeHydratedProductOptionItem",
|
|
6387
6488
|
value: function normalizeHydratedProductOptionItem(optionItem) {
|
|
6388
|
-
var
|
|
6389
|
-
var rawNum = (
|
|
6489
|
+
var _ref77, _optionItem$num, _ref78, _optionItem$add_price;
|
|
6490
|
+
var rawNum = (_ref77 = (_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 && _ref77 !== void 0 ? _ref77 : 1;
|
|
6390
6491
|
var parsedNum = Number(rawNum);
|
|
6391
|
-
var rawPrice = (
|
|
6492
|
+
var rawPrice = (_ref78 = (_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 && _ref78 !== void 0 ? _ref78 : 0;
|
|
6392
6493
|
var parsedPrice = Number(rawPrice);
|
|
6393
6494
|
var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
|
|
6394
6495
|
option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
|
|
@@ -6470,7 +6571,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6470
6571
|
}
|
|
6471
6572
|
}, _callee45, this);
|
|
6472
6573
|
}));
|
|
6473
|
-
function getOrderInfo(
|
|
6574
|
+
function getOrderInfo(_x57) {
|
|
6474
6575
|
return _getOrderInfo.apply(this, arguments);
|
|
6475
6576
|
}
|
|
6476
6577
|
return getOrderInfo;
|
|
@@ -6529,10 +6630,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6529
6630
|
_step29;
|
|
6530
6631
|
try {
|
|
6531
6632
|
for (_iterator29.s(); !(_step29 = _iterator29.n()).done;) {
|
|
6532
|
-
var _ref80, _bundle$num3;
|
|
6533
6633
|
var bundle = _step29.value;
|
|
6534
6634
|
var isPersistedBundleProduct = isPersistedProduct || Boolean((bundle === null || bundle === void 0 ? void 0 : bundle.order_detail_id) || (bundle === null || bundle === void 0 ? void 0 : bundle.orderDetailId) || (bundle === null || bundle === void 0 ? void 0 : bundle.booking_id));
|
|
6535
|
-
var bundleQty =
|
|
6635
|
+
var bundleQty = Number(qty) || 1;
|
|
6536
6636
|
var _iterator30 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
|
|
6537
6637
|
_step30;
|
|
6538
6638
|
try {
|