@pisell/pisellos 2.3.55 → 2.3.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/index.js +0 -1
- package/dist/modules/BookingContext/utils/productExtend.js +5 -9
- package/dist/modules/BookingContext/utils/timeSlices.js +24 -3
- package/dist/modules/Order/index.d.ts +8 -2
- package/dist/modules/Order/index.js +636 -645
- 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 +46 -5
- package/dist/solution/BaseSales/index.js +53 -34
- package/dist/solution/BaseSales/utils/cartPromotion.js +19 -1
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -1
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +1 -4
- package/lib/core/index.js +0 -1
- package/lib/model/strategy/adapter/promotion/index.js +0 -51
- package/lib/modules/BookingContext/utils/productExtend.js +4 -3
- package/lib/modules/BookingContext/utils/timeSlices.js +18 -3
- package/lib/modules/Order/index.d.ts +8 -2
- package/lib/modules/Order/index.js +161 -118
- 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 +47 -3
- package/lib/solution/BaseSales/index.js +26 -6
- package/lib/solution/BaseSales/utils/cartPromotion.js +18 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +1 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +1 -4
- package/package.json +1 -1
|
@@ -42,6 +42,7 @@ import { buildProductLineFingerprint, getProductIdentityIndex, getSafeProductNum
|
|
|
42
42
|
import { syncManualProductDiscountProductNum } from "./utils/manualProductDiscount";
|
|
43
43
|
import { expandHydratedProductsForDiscountCollection, restoreHydratedBundleDiscounts } from "./utils/bundleDiscountHydration";
|
|
44
44
|
import { getOrderCollectionPersistentId, getOrderCollectionUid, normalizeOrderCollections, 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";
|
|
@@ -159,7 +160,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
159
160
|
_step2;
|
|
160
161
|
try {
|
|
161
162
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
162
|
-
var _item$type2, _ref, _ref2, _item$discount$resour, _item$discount, _item$discount$title, _item$discount2, _item$amount, _ref3, _item$discount$origin, _item$
|
|
163
|
+
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;
|
|
163
164
|
var item = _step2.value;
|
|
164
165
|
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;
|
|
165
166
|
if (!type || type === 'product') continue;
|
|
@@ -170,12 +171,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
170
171
|
var key = Number.isFinite(id) ? id : String(resourceId);
|
|
171
172
|
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 : {};
|
|
172
173
|
var amount = Number((item === null || item === void 0 ? void 0 : item.amount) || 0);
|
|
174
|
+
var discountCardType = item === null || item === void 0 || (_item$discount3 = item.discount) === null || _item$discount3 === void 0 ? void 0 : _item$discount3.discount_card_type;
|
|
175
|
+
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';
|
|
173
176
|
var detail = {
|
|
174
177
|
amount: String((_item$amount = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount !== void 0 ? _item$amount : '0'),
|
|
175
178
|
type: type,
|
|
176
179
|
resource_id: key,
|
|
177
180
|
title: title,
|
|
178
|
-
original_amount: String((_ref3 = (_item$discount$origin = item === null || item === void 0 || (_item$
|
|
181
|
+
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'),
|
|
179
182
|
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,
|
|
180
183
|
metadata: item === null || item === void 0 ? void 0 : item.metadata,
|
|
181
184
|
discount: item === null || item === void 0 ? void 0 : item.discount,
|
|
@@ -205,9 +208,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
205
208
|
encoded: '',
|
|
206
209
|
code: '',
|
|
207
210
|
tag: type,
|
|
208
|
-
product_id: (_ref8 = (_item$discount$discou = item === null || item === void 0 || (_item$
|
|
211
|
+
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,
|
|
209
212
|
relation_type: '',
|
|
210
|
-
par_value: String(
|
|
213
|
+
par_value: String(parValue !== null && parValue !== void 0 ? parValue : '0'),
|
|
211
214
|
used_par_value: String((_item$amount2 = item === null || item === void 0 ? void 0 : item.amount) !== null && _item$amount2 !== void 0 ? _item$amount2 : '0'),
|
|
212
215
|
limit_status: 'enable',
|
|
213
216
|
limited_relation_product_data: {
|
|
@@ -226,7 +229,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
226
229
|
id: (_product$product_id = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : 0,
|
|
227
230
|
title: '',
|
|
228
231
|
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,
|
|
229
|
-
base_price: String((
|
|
232
|
+
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')
|
|
230
233
|
},
|
|
231
234
|
type: type,
|
|
232
235
|
resource_id: key,
|
|
@@ -238,8 +241,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
238
241
|
amount: amount,
|
|
239
242
|
discount: _objectSpread(_objectSpread({}, (item === null || item === void 0 ? void 0 : item.discount) || {}), {}, {
|
|
240
243
|
resource_id: key,
|
|
241
|
-
discount_product_id: (
|
|
242
|
-
discount_calculation_mode: (_item$discount$discou3 = item === null || item === void 0 || (_item$
|
|
244
|
+
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,
|
|
245
|
+
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'
|
|
243
246
|
}),
|
|
244
247
|
applicableProductDetails: [detail],
|
|
245
248
|
appliedProductDetails: [detail]
|
|
@@ -287,10 +290,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
287
290
|
}
|
|
288
291
|
if (Array.isArray(product.product_bundle)) {
|
|
289
292
|
product.product_bundle = product.product_bundle.map(function (bundle) {
|
|
290
|
-
var
|
|
293
|
+
var _ref11, _bundle$original_pric;
|
|
291
294
|
var hasBundleDiscount = Array.isArray(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) && bundle.discount_list.length > 0;
|
|
292
295
|
if (hasBundleDiscount) return bundle;
|
|
293
|
-
var restoredPrice = (
|
|
296
|
+
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;
|
|
294
297
|
if (restoredPrice === undefined || restoredPrice === null || restoredPrice === '') return bundle;
|
|
295
298
|
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
296
299
|
price: restoredPrice,
|
|
@@ -683,7 +686,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
683
686
|
value: function () {
|
|
684
687
|
var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(code, customerId) {
|
|
685
688
|
var _this$store$discount11, _tempOrder$holder, _this$store$summary;
|
|
686
|
-
var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders,
|
|
689
|
+
var resultDiscountWithReason, resultDiscountList, unavailableReasonKey, rulesModule, withScanList, currentSelected, tempOrder, holders, _ref12, isAvailable, newDiscountList, evaluatedDiscountList, unavailableReason, shouldRetainForLater, normalizedNewDiscountList, retainedDiscountList, resolvedDiscountList, _this$store$discount12, _this$store$discount13;
|
|
687
690
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
688
691
|
while (1) switch (_context6.prev = _context6.next) {
|
|
689
692
|
case 0:
|
|
@@ -760,7 +763,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
760
763
|
case 18:
|
|
761
764
|
tempOrder = this.store.tempOrder;
|
|
762
765
|
holders = (tempOrder === null || tempOrder === void 0 || (_tempOrder$holder = tempOrder.holder) === null || _tempOrder$holder === void 0 ? void 0 : _tempOrder$holder.form_record) || [];
|
|
763
|
-
|
|
766
|
+
_ref12 = rulesModule.isDiscountListAvailable({
|
|
764
767
|
productList: (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || [],
|
|
765
768
|
oldDiscountList: this.getDiscountList(),
|
|
766
769
|
newDiscountList: withScanList,
|
|
@@ -772,7 +775,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
772
775
|
}) || {
|
|
773
776
|
isAvailable: false,
|
|
774
777
|
discountList: this.getDiscountList()
|
|
775
|
-
}, isAvailable =
|
|
778
|
+
}, isAvailable = _ref12.isAvailable, newDiscountList = _ref12.discountList, evaluatedDiscountList = _ref12.evaluatedDiscountList, unavailableReason = _ref12.unavailableReason;
|
|
776
779
|
shouldRetainForLater = !isAvailable && unavailableReason === UnavailableReason.ProductNotApplicable && withScanList.some(isCustomerPromotionDiscount);
|
|
777
780
|
normalizedNewDiscountList = newDiscountList ? markScannedDiscounts(newDiscountList, withScanList) : undefined;
|
|
778
781
|
retainedDiscountList = evaluatedDiscountList ? markScannedDiscounts(evaluatedDiscountList, withScanList) : normalizedNewDiscountList;
|
|
@@ -855,9 +858,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
855
858
|
if (result !== null && result !== void 0 && result.productList) {
|
|
856
859
|
var previousProductsByUid = indexOrderProductsByUid(tempOrder.products);
|
|
857
860
|
tempOrder.products = this.applyProductDiscountPrices((result.productList || []).map(function (product, index) {
|
|
858
|
-
var
|
|
861
|
+
var _ref13;
|
|
859
862
|
var uid = getOrderProductLineUid(product);
|
|
860
|
-
var previous = (
|
|
863
|
+
var previous = (_ref13 = uid ? previousProductsByUid.get(uid) : undefined) !== null && _ref13 !== void 0 ? _ref13 : previousProductsByUid.get("__index__:".concat(index));
|
|
861
864
|
if (isManualProductDiscountProduct(previous)) {
|
|
862
865
|
return previous;
|
|
863
866
|
}
|
|
@@ -866,6 +869,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
866
869
|
discount_list: normalizeOrderProductDiscountList(syncManualProductDiscountProductNum(mergedProduct.discount_list, mergedProduct.num))
|
|
867
870
|
});
|
|
868
871
|
}));
|
|
872
|
+
ensureUniqueProductLineUids(tempOrder);
|
|
873
|
+
consolidateDiscountFreeProductLines(tempOrder);
|
|
869
874
|
}
|
|
870
875
|
if (result !== null && result !== void 0 && result.discountList) {
|
|
871
876
|
var _this$store$discount15;
|
|
@@ -1392,15 +1397,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1392
1397
|
}, {
|
|
1393
1398
|
key: "extractOrderIdFromSubmitResult",
|
|
1394
1399
|
value: function extractOrderIdFromSubmitResult(result) {
|
|
1395
|
-
var _ref15, _ref16,
|
|
1396
|
-
return (
|
|
1400
|
+
var _ref14, _ref15, _ref16, _result$data$order_id, _result$data, _result$data2;
|
|
1401
|
+
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;
|
|
1397
1402
|
}
|
|
1398
1403
|
}, {
|
|
1399
1404
|
key: "calculatePaymentEffectiveAmount",
|
|
1400
1405
|
value: function calculatePaymentEffectiveAmount(payment) {
|
|
1401
|
-
var
|
|
1406
|
+
var _ref17, _payment$origin_amoun;
|
|
1402
1407
|
var amount = new Decimal(payment.amount || 0);
|
|
1403
|
-
var originAmount = new Decimal((
|
|
1408
|
+
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);
|
|
1404
1409
|
var serviceFee = new Decimal(payment.service_fee || 0);
|
|
1405
1410
|
// TODO: 后端允许 amount 表示顾客实际支付总额后,移除这个兼容分支。
|
|
1406
1411
|
var effectiveAmount = serviceFee.gt(0) && amount.eq(originAmount) ? amount.plus(serviceFee) : amount;
|
|
@@ -1600,12 +1605,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1600
1605
|
}, {
|
|
1601
1606
|
key: "normalizePaymentSource",
|
|
1602
1607
|
value: function normalizePaymentSource(payment, options) {
|
|
1603
|
-
var
|
|
1608
|
+
var _ref18, _paymentRecord$origin;
|
|
1604
1609
|
var paymentRecord = payment;
|
|
1605
1610
|
var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
|
|
1606
1611
|
var normalized = ensureOrderPaymentNumber(_objectSpread(_objectSpread({}, paymentRecord), {}, {
|
|
1607
1612
|
metadata: metadata,
|
|
1608
|
-
origin_amount: (
|
|
1613
|
+
origin_amount: (_ref18 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref18 !== void 0 ? _ref18 : '0.00'
|
|
1609
1614
|
}), (options === null || options === void 0 ? void 0 : options.devicePrefix) || this.getPaymentNumberDevicePrefixSync(), createUuidV4);
|
|
1610
1615
|
if (paymentRecord.status !== undefined) {
|
|
1611
1616
|
normalized.status = paymentRecord.status;
|
|
@@ -1956,7 +1961,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1956
1961
|
_product$payment_pric,
|
|
1957
1962
|
_sku$code,
|
|
1958
1963
|
_sku$barcode,
|
|
1959
|
-
|
|
1964
|
+
_ref19,
|
|
1960
1965
|
_sku$variant_id,
|
|
1961
1966
|
_this11 = this;
|
|
1962
1967
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
@@ -1983,24 +1988,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1983
1988
|
product_sku: this.normalizeFingerprintValue({
|
|
1984
1989
|
code: (_sku$code = sku.code) !== null && _sku$code !== void 0 ? _sku$code : '',
|
|
1985
1990
|
barcode: (_sku$barcode = sku.barcode) !== null && _sku$barcode !== void 0 ? _sku$barcode : '',
|
|
1986
|
-
variant_id: (
|
|
1991
|
+
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,
|
|
1987
1992
|
variant: sku.variant || [],
|
|
1988
1993
|
option: getProductSkuOptions(product || {}).map(function (option) {
|
|
1989
|
-
var
|
|
1994
|
+
var _ref20, _option$id, _option$option_group_, _ref21, _option$option_group_2, _option$num, _option$add_price;
|
|
1990
1995
|
return {
|
|
1991
|
-
id: (
|
|
1996
|
+
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,
|
|
1992
1997
|
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,
|
|
1993
|
-
option_group_item_id: (
|
|
1998
|
+
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,
|
|
1994
1999
|
num: Number((_option$num = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num !== void 0 ? _option$num : 1) || 1,
|
|
1995
2000
|
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)
|
|
1996
2001
|
};
|
|
1997
2002
|
})
|
|
1998
2003
|
}),
|
|
1999
2004
|
product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
|
|
2000
|
-
var
|
|
2005
|
+
var _ref22, _ref23, _bundle$bundle_produc, _ref24, _bundle$bundle_varian, _bundle$num, _bundle$price_type, _bundle$price_type_ex;
|
|
2001
2006
|
return {
|
|
2002
|
-
bundle_product_id: (
|
|
2003
|
-
bundle_variant_id: (
|
|
2007
|
+
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,
|
|
2008
|
+
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,
|
|
2004
2009
|
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),
|
|
2005
2010
|
price: _this11.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.price),
|
|
2006
2011
|
bundle_selling_price: _this11.normalizeFingerprintMoney(bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price),
|
|
@@ -2009,10 +2014,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2009
2014
|
};
|
|
2010
2015
|
})),
|
|
2011
2016
|
discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
2012
|
-
var
|
|
2017
|
+
var _ref25, _discount$type2, _ref26, _ref27, _discount$discount_id, _discount$discount;
|
|
2013
2018
|
return {
|
|
2014
|
-
type: (
|
|
2015
|
-
discount_id: (
|
|
2019
|
+
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 : '',
|
|
2020
|
+
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,
|
|
2016
2021
|
amount: _this11.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2017
2022
|
};
|
|
2018
2023
|
}))
|
|
@@ -2036,14 +2041,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2036
2041
|
var _product$product_id3,
|
|
2037
2042
|
_product$product_vari2,
|
|
2038
2043
|
_product$num2,
|
|
2039
|
-
|
|
2044
|
+
_ref28,
|
|
2040
2045
|
_metadata$unique_iden,
|
|
2041
2046
|
_metadata$price_overr,
|
|
2042
2047
|
_metadata$is_manual_d,
|
|
2043
2048
|
_metadata$product_dis,
|
|
2044
2049
|
_sku$code2,
|
|
2045
2050
|
_sku$barcode2,
|
|
2046
|
-
|
|
2051
|
+
_ref29,
|
|
2047
2052
|
_sku$variant_id2,
|
|
2048
2053
|
_this13 = this;
|
|
2049
2054
|
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
@@ -2059,7 +2064,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2059
2064
|
extension_type: extensionType,
|
|
2060
2065
|
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),
|
|
2061
2066
|
metadata: {
|
|
2062
|
-
unique_identification_number: (
|
|
2067
|
+
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 : '',
|
|
2063
2068
|
price_override: (_metadata$price_overr = metadata.price_override) !== null && _metadata$price_overr !== void 0 ? _metadata$price_overr : '',
|
|
2064
2069
|
is_manual_discount: (_metadata$is_manual_d = metadata.is_manual_discount) !== null && _metadata$is_manual_d !== void 0 ? _metadata$is_manual_d : '',
|
|
2065
2070
|
product_discount_reason: (_metadata$product_dis = metadata.product_discount_reason) !== null && _metadata$product_dis !== void 0 ? _metadata$product_dis : ''
|
|
@@ -2067,35 +2072,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2067
2072
|
product_sku: this.normalizeFingerprintValue({
|
|
2068
2073
|
code: (_sku$code2 = sku.code) !== null && _sku$code2 !== void 0 ? _sku$code2 : '',
|
|
2069
2074
|
barcode: (_sku$barcode2 = sku.barcode) !== null && _sku$barcode2 !== void 0 ? _sku$barcode2 : '',
|
|
2070
|
-
variant_id: (
|
|
2075
|
+
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,
|
|
2071
2076
|
variant: sku.variant || [],
|
|
2072
2077
|
option: getProductSkuOptions(product || {}).map(function (option) {
|
|
2073
|
-
var
|
|
2078
|
+
var _ref30, _option$id2, _option$option_group_3, _ref31, _option$option_group_4, _option$num2, _option$add_price2;
|
|
2074
2079
|
return {
|
|
2075
|
-
id: (
|
|
2080
|
+
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,
|
|
2076
2081
|
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,
|
|
2077
|
-
option_group_item_id: (
|
|
2082
|
+
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,
|
|
2078
2083
|
num: Number((_option$num2 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num2 !== void 0 ? _option$num2 : 1) || 1,
|
|
2079
2084
|
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)
|
|
2080
2085
|
};
|
|
2081
2086
|
})
|
|
2082
2087
|
}),
|
|
2083
2088
|
product_bundle: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.product_bundle) || []).map(function (bundle) {
|
|
2084
|
-
var
|
|
2089
|
+
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;
|
|
2085
2090
|
return {
|
|
2086
|
-
bundle_id: (
|
|
2087
|
-
bundle_group_id: (
|
|
2088
|
-
bundle_product_id: (
|
|
2089
|
-
bundle_variant_id: (
|
|
2091
|
+
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,
|
|
2092
|
+
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,
|
|
2093
|
+
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,
|
|
2094
|
+
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,
|
|
2090
2095
|
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),
|
|
2091
2096
|
price_type: (_bundle$price_type2 = bundle === null || bundle === void 0 ? void 0 : bundle.price_type) !== null && _bundle$price_type2 !== void 0 ? _bundle$price_type2 : '',
|
|
2092
2097
|
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 : '',
|
|
2093
2098
|
option: _this13.normalizeFingerprintValue(((bundle === null || bundle === void 0 ? void 0 : bundle.option) || []).map(function (option) {
|
|
2094
|
-
var
|
|
2099
|
+
var _ref37, _option$id3, _option$option_group_5, _ref38, _option$option_group_6, _option$num3, _option$add_price3;
|
|
2095
2100
|
return {
|
|
2096
|
-
id: (
|
|
2101
|
+
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,
|
|
2097
2102
|
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,
|
|
2098
|
-
option_group_item_id: (
|
|
2103
|
+
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,
|
|
2099
2104
|
num: Number((_option$num3 = option === null || option === void 0 ? void 0 : option.num) !== null && _option$num3 !== void 0 ? _option$num3 : 1) || 1,
|
|
2100
2105
|
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)
|
|
2101
2106
|
};
|
|
@@ -2103,10 +2108,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2103
2108
|
};
|
|
2104
2109
|
})),
|
|
2105
2110
|
discount_list: this.normalizeFingerprintValue(((product === null || product === void 0 ? void 0 : product.discount_list) || []).map(function (discount) {
|
|
2106
|
-
var
|
|
2111
|
+
var _ref39, _discount$type4, _ref40, _ref41, _discount$discount_id2, _discount$discount2;
|
|
2107
2112
|
return {
|
|
2108
|
-
type: (
|
|
2109
|
-
discount_id: (
|
|
2113
|
+
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 : '',
|
|
2114
|
+
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,
|
|
2110
2115
|
amount: _this13.normalizeFingerprintMoney(discount === null || discount === void 0 ? void 0 : discount.amount)
|
|
2111
2116
|
};
|
|
2112
2117
|
}))
|
|
@@ -2409,11 +2414,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2409
2414
|
}, {
|
|
2410
2415
|
key: "getOrderIdentity",
|
|
2411
2416
|
value: function getOrderIdentity() {
|
|
2412
|
-
var
|
|
2417
|
+
var _ref42, _ref43, _tempOrder$order_id, _tempOrder$_extend6;
|
|
2413
2418
|
var tempOrder = this.store.tempOrder;
|
|
2414
2419
|
if (!tempOrder) return null;
|
|
2415
2420
|
var lastOrderInfo = this.store.lastOrderInfo || {};
|
|
2416
|
-
var orderId = (
|
|
2421
|
+
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;
|
|
2417
2422
|
return {
|
|
2418
2423
|
localId: this.cacheId || ((_tempOrder$_extend6 = tempOrder._extend) === null || _tempOrder$_extend6 === void 0 ? void 0 : _tempOrder$_extend6.localId),
|
|
2419
2424
|
orderId: orderId,
|
|
@@ -2549,6 +2554,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2549
2554
|
tempOrder.products = (tempOrder.products || []).map(function (product) {
|
|
2550
2555
|
return _this15.sanitizeOrderProductForTempOrder(product);
|
|
2551
2556
|
});
|
|
2557
|
+
ensureUniqueProductLineUids(tempOrder);
|
|
2552
2558
|
}
|
|
2553
2559
|
}, {
|
|
2554
2560
|
key: "ensureExtend",
|
|
@@ -2566,11 +2572,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2566
2572
|
}, {
|
|
2567
2573
|
key: "captureProductRuntime",
|
|
2568
2574
|
value: function captureProductRuntime(tempOrder, rawProduct, normalizedProduct, existedUid) {
|
|
2569
|
-
var _extend$productsByUid,
|
|
2575
|
+
var _extend$productsByUid, _ref44, _rawProduct$_origin;
|
|
2570
2576
|
var uid = existedUid || this.getProductUid(normalizedProduct);
|
|
2571
2577
|
var extend = this.ensureExtend(tempOrder);
|
|
2572
2578
|
var existed = ((_extend$productsByUid = extend.productsByUid) === null || _extend$productsByUid === void 0 ? void 0 : _extend$productsByUid[uid]) || {};
|
|
2573
|
-
var origin = (
|
|
2579
|
+
var origin = (_ref44 = (_rawProduct$_origin = rawProduct._origin) !== null && _rawProduct$_origin !== void 0 ? _rawProduct$_origin : normalizedProduct._origin) !== null && _ref44 !== void 0 ? _ref44 : existed.origin;
|
|
2574
2580
|
extend.productsByUid[uid] = _objectSpread(_objectSpread({}, existed), origin !== undefined ? {
|
|
2575
2581
|
origin: origin
|
|
2576
2582
|
} : {});
|
|
@@ -2713,7 +2719,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2713
2719
|
}, {
|
|
2714
2720
|
key: "buildTempOrderHolderFromBookings",
|
|
2715
2721
|
value: function buildTempOrderHolderFromBookings(tempOrder) {
|
|
2716
|
-
var _baseHolder$customer_, _baseHolder,
|
|
2722
|
+
var _baseHolder$customer_, _baseHolder, _ref45, _baseHolder$form_id, _baseHolder2, _tempOrder$holder2, _baseHolder3, _this$otherParams;
|
|
2717
2723
|
var holderRecords = [];
|
|
2718
2724
|
var holderNames = [];
|
|
2719
2725
|
var baseHolder = null;
|
|
@@ -2760,7 +2766,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2760
2766
|
}
|
|
2761
2767
|
var nextHolder = {
|
|
2762
2768
|
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,
|
|
2763
|
-
form_id: (
|
|
2769
|
+
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,
|
|
2764
2770
|
form_record: holderRecords
|
|
2765
2771
|
};
|
|
2766
2772
|
if (holderNames.length) {
|
|
@@ -2865,7 +2871,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2865
2871
|
key: "recalculateSummary",
|
|
2866
2872
|
value: function () {
|
|
2867
2873
|
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(options) {
|
|
2868
|
-
var _this$otherParams2,
|
|
2874
|
+
var _this$otherParams2, _ref46, _salesSummaryResult$e;
|
|
2869
2875
|
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;
|
|
2870
2876
|
return _regeneratorRuntime().wrap(function _callee12$(_context14) {
|
|
2871
2877
|
while (1) switch (_context14.prev = _context14.next) {
|
|
@@ -2943,7 +2949,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2943
2949
|
roundingAmount = paidPaymentSummary.roundingAmount;
|
|
2944
2950
|
payServiceChargeAmount = paidPaymentSummary.payServiceChargeAmount;
|
|
2945
2951
|
hasSalesSummaryAmount = salesSummaryResult.expect_amount !== undefined || salesSummaryResult.total_amount !== undefined;
|
|
2946
|
-
expectAmount = hasSalesSummaryAmount ? new Decimal((
|
|
2952
|
+
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;
|
|
2947
2953
|
amountPaymentPatch = hasSalesSummaryAmount || !roundingAmount.eq(0) || !payServiceChargeAmount.eq(0) ? _objectSpread({
|
|
2948
2954
|
rounding_amount: roundingAmount.toFixed(2)
|
|
2949
2955
|
}, expectAmount ? {
|
|
@@ -3121,17 +3127,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3121
3127
|
}, {
|
|
3122
3128
|
key: "buildTempOrderCustomer",
|
|
3123
3129
|
value: function buildTempOrderCustomer(params) {
|
|
3124
|
-
var _ref48, _ref49,
|
|
3130
|
+
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;
|
|
3125
3131
|
if (!params.customerId) return null;
|
|
3126
3132
|
var source = params.source ? cloneDeep(params.source) : {};
|
|
3127
|
-
var name = (
|
|
3128
|
-
var customerName = (
|
|
3133
|
+
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;
|
|
3134
|
+
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;
|
|
3129
3135
|
return _objectSpread(_objectSpread({}, source), {}, {
|
|
3130
3136
|
id: (_source$id = source.id) !== null && _source$id !== void 0 ? _source$id : params.customerId,
|
|
3131
3137
|
customer_id: (_source$customer_id = source.customer_id) !== null && _source$customer_id !== void 0 ? _source$customer_id : params.customerId,
|
|
3132
3138
|
name: String(name || ''),
|
|
3133
3139
|
customer_name: String(customerName || ''),
|
|
3134
|
-
country_calling_code: String((
|
|
3140
|
+
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),
|
|
3135
3141
|
phone: String((_source$phone = source.phone) !== null && _source$phone !== void 0 ? _source$phone : params.phone),
|
|
3136
3142
|
email: String((_source$email = source.email) !== null && _source$email !== void 0 ? _source$email : params.email)
|
|
3137
3143
|
});
|
|
@@ -3235,14 +3241,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3235
3241
|
}, {
|
|
3236
3242
|
key: "updateTempOrderCustomer",
|
|
3237
3243
|
value: function updateTempOrderCustomer(customer) {
|
|
3238
|
-
var _tempOrder$customer_i2,
|
|
3244
|
+
var _tempOrder$customer_i2, _ref54, _ref55, _customer$customer_id, _ref56, _ref57, _ref58, _customer$customer_na, _ref59, _customer$country_cal, _tempOrder$customer_i3;
|
|
3239
3245
|
var tempOrder = this.ensureTempOrder();
|
|
3240
3246
|
var previousCustomerId = (_tempOrder$customer_i2 = tempOrder.customer_id) !== null && _tempOrder$customer_i2 !== void 0 ? _tempOrder$customer_i2 : null;
|
|
3241
|
-
var customerId = (
|
|
3242
|
-
var customerName = (
|
|
3247
|
+
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;
|
|
3248
|
+
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 : '';
|
|
3243
3249
|
tempOrder.customer_id = customerId === null || customerId === undefined || customerId === '' ? null : Number(customerId);
|
|
3244
3250
|
tempOrder.customer_name = String(customerName || '');
|
|
3245
|
-
tempOrder.country_calling_code = String((
|
|
3251
|
+
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 : '');
|
|
3246
3252
|
tempOrder.phone = String(customer.phone || '');
|
|
3247
3253
|
tempOrder.email = String(customer.email || '');
|
|
3248
3254
|
tempOrder.customer = this.buildTempOrderCustomer({
|
|
@@ -3338,6 +3344,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3338
3344
|
if (tempOrder._extend) delete tempOrder._extend.customerSnapshot;
|
|
3339
3345
|
this.store.availableWalletIds = [];
|
|
3340
3346
|
this.clearCustomerBoundDiscounts(tempOrder);
|
|
3347
|
+
this.applyDiscount();
|
|
3341
3348
|
this.persistTempOrder();
|
|
3342
3349
|
this.saveDraftInBackground();
|
|
3343
3350
|
this.core.effects.emit(OrderHooks.OnOrderCustomerChange, null);
|
|
@@ -3756,52 +3763,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3756
3763
|
}
|
|
3757
3764
|
return updateVoucherOrderPaymentsAsync;
|
|
3758
3765
|
}()
|
|
3766
|
+
}, {
|
|
3767
|
+
key: "normalizeShouldMergeProductResult",
|
|
3768
|
+
value: function normalizeShouldMergeProductResult(result) {
|
|
3769
|
+
if (typeof result === 'boolean') return result;
|
|
3770
|
+
if (result && _typeof(result) === 'object' && typeof result.shouldMerge === 'boolean') {
|
|
3771
|
+
return result.shouldMerge;
|
|
3772
|
+
}
|
|
3773
|
+
return true;
|
|
3774
|
+
}
|
|
3759
3775
|
}, {
|
|
3760
3776
|
key: "shouldMergeProductToOrder",
|
|
3761
|
-
value: function () {
|
|
3762
|
-
var
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
|
|
3769
|
-
if (onBeforeMergeProductToOrder) {
|
|
3770
|
-
_context20.next = 3;
|
|
3771
|
-
break;
|
|
3772
|
-
}
|
|
3773
|
-
return _context20.abrupt("return", true);
|
|
3774
|
-
case 3:
|
|
3775
|
-
_context20.next = 5;
|
|
3776
|
-
return onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
3777
|
-
defaultShouldMerge: true
|
|
3778
|
-
}));
|
|
3779
|
-
case 5:
|
|
3780
|
-
result = _context20.sent;
|
|
3781
|
-
if (!(typeof result === 'boolean')) {
|
|
3782
|
-
_context20.next = 8;
|
|
3783
|
-
break;
|
|
3784
|
-
}
|
|
3785
|
-
return _context20.abrupt("return", result);
|
|
3786
|
-
case 8:
|
|
3787
|
-
if (!(result && _typeof(result) === 'object' && typeof result.shouldMerge === 'boolean')) {
|
|
3788
|
-
_context20.next = 10;
|
|
3789
|
-
break;
|
|
3790
|
-
}
|
|
3791
|
-
return _context20.abrupt("return", result.shouldMerge);
|
|
3792
|
-
case 10:
|
|
3793
|
-
return _context20.abrupt("return", true);
|
|
3794
|
-
case 11:
|
|
3795
|
-
case "end":
|
|
3796
|
-
return _context20.stop();
|
|
3797
|
-
}
|
|
3798
|
-
}, _callee18, this);
|
|
3777
|
+
value: function shouldMergeProductToOrder(params) {
|
|
3778
|
+
var _this$orderHooks,
|
|
3779
|
+
_this26 = this;
|
|
3780
|
+
var onBeforeMergeProductToOrder = (_this$orderHooks = this.orderHooks) === null || _this$orderHooks === void 0 ? void 0 : _this$orderHooks.onBeforeMergeProductToOrder;
|
|
3781
|
+
if (!onBeforeMergeProductToOrder) return true;
|
|
3782
|
+
var result = onBeforeMergeProductToOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
3783
|
+
defaultShouldMerge: true
|
|
3799
3784
|
}));
|
|
3800
|
-
|
|
3801
|
-
return
|
|
3785
|
+
if (result && _typeof(result) === 'object' && typeof result.then === 'function') {
|
|
3786
|
+
return Promise.resolve(result).then(function (resolved) {
|
|
3787
|
+
return _this26.normalizeShouldMergeProductResult(resolved);
|
|
3788
|
+
});
|
|
3802
3789
|
}
|
|
3803
|
-
return
|
|
3804
|
-
}
|
|
3790
|
+
return this.normalizeShouldMergeProductResult(result);
|
|
3791
|
+
}
|
|
3805
3792
|
}, {
|
|
3806
3793
|
key: "hasOrderProductLineNote",
|
|
3807
3794
|
value: function hasOrderProductLineNote(product) {
|
|
@@ -3833,30 +3820,30 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3833
3820
|
}, {
|
|
3834
3821
|
key: "finalizeProductOrderMutation",
|
|
3835
3822
|
value: function () {
|
|
3836
|
-
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3837
|
-
return _regeneratorRuntime().wrap(function
|
|
3838
|
-
while (1) switch (
|
|
3823
|
+
var _finalizeProductOrderMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(tempOrder, options) {
|
|
3824
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context20) {
|
|
3825
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
3839
3826
|
case 0:
|
|
3840
3827
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
3841
3828
|
if (options !== null && options !== void 0 && options.skipEditDiscountConfigRefresh) {
|
|
3842
|
-
|
|
3829
|
+
_context20.next = 4;
|
|
3843
3830
|
break;
|
|
3844
3831
|
}
|
|
3845
|
-
|
|
3832
|
+
_context20.next = 4;
|
|
3846
3833
|
return this.ensureEditDiscountConfigForProductChange(tempOrder);
|
|
3847
3834
|
case 4:
|
|
3848
3835
|
if (options !== null && options !== void 0 && options.skipDiscountRecalculation) {
|
|
3849
|
-
|
|
3836
|
+
_context20.next = 7;
|
|
3850
3837
|
break;
|
|
3851
3838
|
}
|
|
3852
|
-
|
|
3839
|
+
_context20.next = 7;
|
|
3853
3840
|
return this.applyPromotion();
|
|
3854
3841
|
case 7:
|
|
3855
3842
|
if (!(options !== null && options !== void 0 && options.skipDiscountRecalculation)) {
|
|
3856
3843
|
this.applyDiscount();
|
|
3857
3844
|
}
|
|
3858
3845
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
3859
|
-
|
|
3846
|
+
_context20.next = 11;
|
|
3860
3847
|
return this.recalculateSummary({
|
|
3861
3848
|
createIfMissing: true
|
|
3862
3849
|
});
|
|
@@ -3864,11 +3851,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3864
3851
|
this.persistTempOrder();
|
|
3865
3852
|
case 12:
|
|
3866
3853
|
case "end":
|
|
3867
|
-
return
|
|
3854
|
+
return _context20.stop();
|
|
3868
3855
|
}
|
|
3869
|
-
},
|
|
3856
|
+
}, _callee18, this);
|
|
3870
3857
|
}));
|
|
3871
|
-
function finalizeProductOrderMutation(
|
|
3858
|
+
function finalizeProductOrderMutation(_x19, _x20) {
|
|
3872
3859
|
return _finalizeProductOrderMutation.apply(this, arguments);
|
|
3873
3860
|
}
|
|
3874
3861
|
return finalizeProductOrderMutation;
|
|
@@ -3878,157 +3865,143 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3878
3865
|
* 带 booking 且 num>1 时由 `addProductToOrder` 拆成多次本方法调用(每次 num=1)。
|
|
3879
3866
|
*
|
|
3880
3867
|
* @example
|
|
3881
|
-
*
|
|
3868
|
+
* const pending = this.appendProductLineToTempOrder(
|
|
3869
|
+
* tempOrder,
|
|
3870
|
+
* { product_id: 1, num: 1 },
|
|
3871
|
+
* booking,
|
|
3872
|
+
* );
|
|
3873
|
+
* if (pending) await pending;
|
|
3882
3874
|
*/
|
|
3883
3875
|
}, {
|
|
3884
3876
|
key: "appendProductLineToTempOrder",
|
|
3885
|
-
value:
|
|
3886
|
-
var
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
if (!matchedProduct) {
|
|
3940
|
-
_context22.next = 25;
|
|
3941
|
-
break;
|
|
3942
|
-
}
|
|
3943
|
-
_context22.next = 22;
|
|
3944
|
-
return this.shouldMergeProductToOrder({
|
|
3945
|
-
incomingProduct: productToAdd,
|
|
3946
|
-
normalizedIncoming: normalizedIncoming,
|
|
3947
|
-
matchedProduct: matchedProduct,
|
|
3948
|
-
matchedIndex: matchedIndex,
|
|
3949
|
-
incomingFingerprint: incomingFingerprint,
|
|
3950
|
-
existedFingerprint: existedFingerprint,
|
|
3951
|
-
tempOrder: tempOrder,
|
|
3952
|
-
booking: booking
|
|
3953
|
-
});
|
|
3954
|
-
case 22:
|
|
3955
|
-
_context22.t0 = _context22.sent;
|
|
3956
|
-
_context22.next = 26;
|
|
3957
|
-
break;
|
|
3958
|
-
case 25:
|
|
3959
|
-
_context22.t0 = false;
|
|
3960
|
-
case 26:
|
|
3961
|
-
shouldMerge = _context22.t0;
|
|
3962
|
-
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
3963
|
-
this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
3964
|
-
if (linked) {
|
|
3965
|
-
normalizedIncoming.booking_uid = linked.bookingUid;
|
|
3966
|
-
normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, {
|
|
3967
|
-
booking_uid: linked.bookingUid
|
|
3968
|
-
});
|
|
3969
|
-
}
|
|
3970
|
-
insertAtIndex = options === null || options === void 0 ? void 0 : options.insertAtIndex;
|
|
3971
|
-
if (Number.isInteger(insertAtIndex) && Number(insertAtIndex) >= 0 && Number(insertAtIndex) < tempOrder.products.length) {
|
|
3972
|
-
tempOrder.products = [].concat(_toConsumableArray(tempOrder.products.slice(0, insertAtIndex)), [normalizedIncoming], _toConsumableArray(tempOrder.products.slice(insertAtIndex)));
|
|
3973
|
-
} else {
|
|
3974
|
-
tempOrder.products = [].concat(_toConsumableArray(tempOrder.products), [normalizedIncoming]);
|
|
3975
|
-
}
|
|
3976
|
-
} else {
|
|
3977
|
-
targetProduct = matchedProduct;
|
|
3978
|
-
targetUid = (_targetProduct$metada = targetProduct.metadata) === null || _targetProduct$metada === void 0 ? void 0 : _targetProduct$metada.unique_identification_number;
|
|
3979
|
-
normalizedProduct = mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
|
|
3980
|
-
metadata: _objectSpread(_objectSpread({}, productToAdd.metadata || {}), {}, {
|
|
3981
|
-
unique_identification_number: targetUid
|
|
3982
|
-
})
|
|
3983
|
-
})));
|
|
3984
|
-
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
3985
|
-
nextNum = getSafeProductNum(targetProduct.num + normalizedProduct.num);
|
|
3986
|
-
targetIsManualProductDiscount = isManualProductDiscountProduct(targetProduct);
|
|
3987
|
-
nextDiscountList = targetIsManualProductDiscount ? normalizeOrderProductDiscountList(syncManualProductDiscountProductNum(targetProduct.discount_list, nextNum)) : normalizedProduct.discount_list;
|
|
3988
|
-
tempOrder.products[matchedIndex] = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, targetProduct), normalizedProduct), {}, {
|
|
3989
|
-
discount_list: nextDiscountList,
|
|
3990
|
-
metadata: _objectSpread(_objectSpread(_objectSpread({}, targetProduct.metadata || {}), normalizedProduct.metadata || {}), {}, {
|
|
3991
|
-
unique_identification_number: targetUid
|
|
3992
|
-
}),
|
|
3993
|
-
product_sku: _objectSpread(_objectSpread(_objectSpread({}, targetProduct.product_sku || {
|
|
3994
|
-
option: []
|
|
3995
|
-
}), normalizedProduct.product_sku || {
|
|
3996
|
-
option: []
|
|
3997
|
-
}), {}, {
|
|
3998
|
-
option: getProductSkuOptions(normalizedProduct)
|
|
3999
|
-
})
|
|
4000
|
-
}, targetIsManualProductDiscount ? {
|
|
4001
|
-
selling_price: targetProduct.selling_price,
|
|
4002
|
-
original_price: targetProduct.original_price,
|
|
4003
|
-
payment_price: targetProduct.payment_price,
|
|
4004
|
-
metadata: _objectSpread(_objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), targetProduct.metadata || {}), {}, {
|
|
4005
|
-
unique_identification_number: targetUid
|
|
4006
|
-
})
|
|
4007
|
-
} : {}), {}, {
|
|
4008
|
-
note: targetProduct.note,
|
|
4009
|
-
order_detail_id: targetProduct.order_detail_id,
|
|
4010
|
-
num: nextNum
|
|
4011
|
-
});
|
|
4012
|
-
this.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
|
|
4013
|
-
if (matchedIndex !== tempOrder.products.length - 1) {
|
|
4014
|
-
mergedProduct = tempOrder.products[matchedIndex];
|
|
4015
|
-
tempOrder.products = [].concat(_toConsumableArray(tempOrder.products.slice(0, matchedIndex)), _toConsumableArray(tempOrder.products.slice(matchedIndex + 1)), [mergedProduct]);
|
|
4016
|
-
}
|
|
4017
|
-
}
|
|
4018
|
-
if (linked) {
|
|
4019
|
-
tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
|
|
4020
|
-
}
|
|
4021
|
-
case 29:
|
|
4022
|
-
case "end":
|
|
4023
|
-
return _context22.stop();
|
|
3877
|
+
value: function appendProductLineToTempOrder(tempOrder, product, booking, options) {
|
|
3878
|
+
var _normalizedIncoming$p,
|
|
3879
|
+
_normalizedIncoming$p2,
|
|
3880
|
+
_booking_uid,
|
|
3881
|
+
_metadata,
|
|
3882
|
+
_productToAdd$metadat,
|
|
3883
|
+
_origin,
|
|
3884
|
+
_this27 = this;
|
|
3885
|
+
var linked = booking ? this.createLinkedProductAndBooking({
|
|
3886
|
+
product: product,
|
|
3887
|
+
booking: booking
|
|
3888
|
+
}) : null;
|
|
3889
|
+
var productToAdd = (linked === null || linked === void 0 ? void 0 : linked.product) || product;
|
|
3890
|
+
var incomingFingerprint = buildProductLineFingerprint(getProductSkuOptions(productToAdd), productToAdd.product_bundle);
|
|
3891
|
+
var normalizedIncoming = mergeOrderProductDisplayFields(productToAdd, normalizeOrderProduct(productToAdd));
|
|
3892
|
+
var isWeighingProduct = Number(((_normalizedIncoming$p = normalizedIncoming.product_sku) === null || _normalizedIncoming$p === void 0 ? void 0 : _normalizedIncoming$p.open_sold_weight) || 0) === 1;
|
|
3893
|
+
var netWeight = Number((_normalizedIncoming$p2 = normalizedIncoming.product_sku) === null || _normalizedIncoming$p2 === void 0 ? void 0 : _normalizedIncoming$p2.net_weight);
|
|
3894
|
+
if (isWeighingProduct && (!Number.isFinite(netWeight) || netWeight <= 0)) {
|
|
3895
|
+
throw new Error('[Order] 称重商品净重必须大于 0');
|
|
3896
|
+
}
|
|
3897
|
+
var 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;
|
|
3898
|
+
if (incomingBookingUid !== undefined && incomingBookingUid !== null && String(incomingBookingUid) !== '') {
|
|
3899
|
+
normalizedIncoming.booking_uid = String(incomingBookingUid);
|
|
3900
|
+
normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, {
|
|
3901
|
+
booking_uid: String(incomingBookingUid)
|
|
3902
|
+
});
|
|
3903
|
+
}
|
|
3904
|
+
normalizedIncoming.discount_list = normalizeOrderProductDiscountList(normalizedIncoming.discount_list);
|
|
3905
|
+
var hasIncomingGoodPass = this.hasGoodPassDiscount(normalizedIncoming);
|
|
3906
|
+
var hasIncomingProductNote = this.hasOrderProductLineNote(normalizedIncoming);
|
|
3907
|
+
var hasIncomingBookingUid = this.hasLinkedBookingUid(productToAdd) || this.hasLinkedBookingUid(normalizedIncoming);
|
|
3908
|
+
var isIncomingCustomItem = ((_productToAdd$metadat = productToAdd.metadata) === null || _productToAdd$metadat === void 0 || (_productToAdd$metadat = _productToAdd$metadat.origin) === null || _productToAdd$metadat === void 0 ? void 0 : _productToAdd$metadat.isCustomItem) === true || ((_origin = productToAdd._origin) === null || _origin === void 0 ? void 0 : _origin.isCustomItem) === true;
|
|
3909
|
+
var shouldForceNewLine = !!booking || hasIncomingProductNote || hasIncomingBookingUid || isIncomingCustomItem || isWeighingProduct;
|
|
3910
|
+
var matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
3911
|
+
var _item$metadata3;
|
|
3912
|
+
if (_this27.hasGoodPassDiscount(item)) return false;
|
|
3913
|
+
if (_this27.hasOrderProductLineNote(item)) return false;
|
|
3914
|
+
if (item.order_detail_id !== undefined && item.order_detail_id !== null) return false;
|
|
3915
|
+
if ((_item$metadata3 = item.metadata) !== null && _item$metadata3 !== void 0 && _item$metadata3.is_edit_for_runtime) return false;
|
|
3916
|
+
if (item.product_id !== productToAdd.product_id) return false;
|
|
3917
|
+
if (item.product_variant_id !== productToAdd.product_variant_id) return false;
|
|
3918
|
+
var existedFingerprint = buildProductLineFingerprint(getProductSkuOptions(item), item.product_bundle);
|
|
3919
|
+
return existedFingerprint === incomingFingerprint;
|
|
3920
|
+
});
|
|
3921
|
+
var matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
|
|
3922
|
+
var existedFingerprint = matchedProduct ? buildProductLineFingerprint(getProductSkuOptions(matchedProduct), matchedProduct.product_bundle) : '';
|
|
3923
|
+
var commitProductLine = function commitProductLine(shouldMerge) {
|
|
3924
|
+
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
3925
|
+
_this27.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
3926
|
+
if (linked) {
|
|
3927
|
+
normalizedIncoming.booking_uid = linked.bookingUid;
|
|
3928
|
+
normalizedIncoming.metadata = _objectSpread(_objectSpread({}, normalizedIncoming.metadata || {}), {}, {
|
|
3929
|
+
booking_uid: linked.bookingUid
|
|
3930
|
+
});
|
|
4024
3931
|
}
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
3932
|
+
var insertAtIndex = options === null || options === void 0 ? void 0 : options.insertAtIndex;
|
|
3933
|
+
if (Number.isInteger(insertAtIndex) && Number(insertAtIndex) >= 0 && Number(insertAtIndex) < tempOrder.products.length) {
|
|
3934
|
+
tempOrder.products = [].concat(_toConsumableArray(tempOrder.products.slice(0, insertAtIndex)), [normalizedIncoming], _toConsumableArray(tempOrder.products.slice(insertAtIndex)));
|
|
3935
|
+
} else {
|
|
3936
|
+
tempOrder.products = [].concat(_toConsumableArray(tempOrder.products), [normalizedIncoming]);
|
|
3937
|
+
}
|
|
3938
|
+
} else {
|
|
3939
|
+
var _targetProduct$metada;
|
|
3940
|
+
var targetProduct = matchedProduct;
|
|
3941
|
+
var targetUid = (_targetProduct$metada = targetProduct.metadata) === null || _targetProduct$metada === void 0 ? void 0 : _targetProduct$metada.unique_identification_number;
|
|
3942
|
+
var normalizedProduct = mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
|
|
3943
|
+
metadata: _objectSpread(_objectSpread({}, productToAdd.metadata || {}), {}, {
|
|
3944
|
+
unique_identification_number: targetUid
|
|
3945
|
+
})
|
|
3946
|
+
})));
|
|
3947
|
+
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
3948
|
+
var nextNum = getSafeProductNum(targetProduct.num + normalizedProduct.num);
|
|
3949
|
+
var targetIsManualProductDiscount = isManualProductDiscountProduct(targetProduct);
|
|
3950
|
+
var nextDiscountList = targetIsManualProductDiscount ? normalizeOrderProductDiscountList(syncManualProductDiscountProductNum(targetProduct.discount_list, nextNum)) : normalizedProduct.discount_list;
|
|
3951
|
+
tempOrder.products[matchedIndex] = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, targetProduct), normalizedProduct), {}, {
|
|
3952
|
+
discount_list: nextDiscountList,
|
|
3953
|
+
metadata: _objectSpread(_objectSpread(_objectSpread({}, targetProduct.metadata || {}), normalizedProduct.metadata || {}), {}, {
|
|
3954
|
+
unique_identification_number: targetUid
|
|
3955
|
+
}),
|
|
3956
|
+
product_sku: _objectSpread(_objectSpread(_objectSpread({}, targetProduct.product_sku || {
|
|
3957
|
+
option: []
|
|
3958
|
+
}), normalizedProduct.product_sku || {
|
|
3959
|
+
option: []
|
|
3960
|
+
}), {}, {
|
|
3961
|
+
option: getProductSkuOptions(normalizedProduct)
|
|
3962
|
+
})
|
|
3963
|
+
}, targetIsManualProductDiscount ? {
|
|
3964
|
+
selling_price: targetProduct.selling_price,
|
|
3965
|
+
original_price: targetProduct.original_price,
|
|
3966
|
+
payment_price: targetProduct.payment_price,
|
|
3967
|
+
metadata: _objectSpread(_objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), targetProduct.metadata || {}), {}, {
|
|
3968
|
+
unique_identification_number: targetUid
|
|
3969
|
+
})
|
|
3970
|
+
} : {}), {}, {
|
|
3971
|
+
note: targetProduct.note,
|
|
3972
|
+
order_detail_id: targetProduct.order_detail_id,
|
|
3973
|
+
num: nextNum
|
|
3974
|
+
});
|
|
3975
|
+
_this27.captureProductRuntime(tempOrder, productToAdd, tempOrder.products[matchedIndex], targetUid);
|
|
3976
|
+
if (matchedIndex !== tempOrder.products.length - 1) {
|
|
3977
|
+
var mergedProduct = tempOrder.products[matchedIndex];
|
|
3978
|
+
tempOrder.products = [].concat(_toConsumableArray(tempOrder.products.slice(0, matchedIndex)), _toConsumableArray(tempOrder.products.slice(matchedIndex + 1)), [mergedProduct]);
|
|
3979
|
+
}
|
|
3980
|
+
}
|
|
3981
|
+
if (linked) {
|
|
3982
|
+
tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
|
|
3983
|
+
}
|
|
3984
|
+
};
|
|
3985
|
+
if (!matchedProduct) {
|
|
3986
|
+
commitProductLine(false);
|
|
3987
|
+
return;
|
|
4029
3988
|
}
|
|
4030
|
-
|
|
4031
|
-
|
|
3989
|
+
var shouldMerge = this.shouldMergeProductToOrder({
|
|
3990
|
+
incomingProduct: productToAdd,
|
|
3991
|
+
normalizedIncoming: normalizedIncoming,
|
|
3992
|
+
matchedProduct: matchedProduct,
|
|
3993
|
+
matchedIndex: matchedIndex,
|
|
3994
|
+
incomingFingerprint: incomingFingerprint,
|
|
3995
|
+
existedFingerprint: existedFingerprint,
|
|
3996
|
+
tempOrder: tempOrder,
|
|
3997
|
+
booking: booking
|
|
3998
|
+
});
|
|
3999
|
+
if (shouldMerge && _typeof(shouldMerge) === 'object' && typeof shouldMerge.then === 'function') {
|
|
4000
|
+
return Promise.resolve(shouldMerge).then(commitProductLine);
|
|
4001
|
+
}
|
|
4002
|
+
commitProductLine(shouldMerge);
|
|
4003
|
+
}
|
|
4004
|
+
|
|
4032
4005
|
/**
|
|
4033
4006
|
* 添加商品行。带 booking 时强制独立行;num>1 时拆成多条 num=1 的 product+booking(对齐 BookingByStep / ticketBooking addService)。
|
|
4034
4007
|
*
|
|
@@ -4036,14 +4009,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4036
4009
|
* await order.addProductToOrder({ product_id: 1, num: 3 }, { start_time: '10:00' });
|
|
4037
4010
|
* // → tempOrder.products 新增 3 行,每行 num=1,bookings 3 条
|
|
4038
4011
|
*/
|
|
4039
|
-
)
|
|
4040
4012
|
}, {
|
|
4041
4013
|
key: "addProductToOrder",
|
|
4042
4014
|
value: (function () {
|
|
4043
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4044
|
-
var tempOrder, insertAfterProductUid, anchorIndex, insertAtIndex,
|
|
4045
|
-
return _regeneratorRuntime().wrap(function
|
|
4046
|
-
while (1) switch (
|
|
4015
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(product, booking, options) {
|
|
4016
|
+
var tempOrder, insertAfterProductUid, anchorIndex, insertAtIndex, _ref60, _productRecord$num, productRecord, splitCount, i, singleLine, _appendResult, appendResult;
|
|
4017
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context21) {
|
|
4018
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
4047
4019
|
case 0:
|
|
4048
4020
|
tempOrder = this.ensureTempOrder();
|
|
4049
4021
|
insertAfterProductUid = options === null || options === void 0 ? void 0 : options.insertAfterProductUid;
|
|
@@ -4054,60 +4026,70 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4054
4026
|
}) : -1;
|
|
4055
4027
|
insertAtIndex = anchorIndex >= 0 ? anchorIndex + 1 : undefined;
|
|
4056
4028
|
if (!booking) {
|
|
4057
|
-
|
|
4029
|
+
_context21.next = 24;
|
|
4058
4030
|
break;
|
|
4059
4031
|
}
|
|
4060
4032
|
productRecord = product;
|
|
4061
|
-
splitCount = getSafeProductNum((
|
|
4033
|
+
splitCount = getSafeProductNum((_ref60 = (_productRecord$num = productRecord.num) !== null && _productRecord$num !== void 0 ? _productRecord$num : productRecord.product_quantity) !== null && _ref60 !== void 0 ? _ref60 : 1);
|
|
4062
4034
|
if (!(splitCount > 1)) {
|
|
4063
|
-
|
|
4035
|
+
_context21.next = 24;
|
|
4064
4036
|
break;
|
|
4065
4037
|
}
|
|
4066
4038
|
i = 0;
|
|
4067
4039
|
case 9:
|
|
4068
4040
|
if (!(i < splitCount)) {
|
|
4069
|
-
|
|
4041
|
+
_context21.next = 21;
|
|
4070
4042
|
break;
|
|
4071
4043
|
}
|
|
4072
4044
|
singleLine = cloneDeep(productRecord);
|
|
4073
4045
|
singleLine.num = 1;
|
|
4074
4046
|
delete singleLine.product_quantity;
|
|
4075
|
-
|
|
4076
|
-
return this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking), {
|
|
4047
|
+
_appendResult = this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking), {
|
|
4077
4048
|
insertAtIndex: insertAtIndex
|
|
4078
4049
|
});
|
|
4079
|
-
|
|
4050
|
+
if (!_appendResult) {
|
|
4051
|
+
_context21.next = 17;
|
|
4052
|
+
break;
|
|
4053
|
+
}
|
|
4054
|
+
_context21.next = 17;
|
|
4055
|
+
return _appendResult;
|
|
4056
|
+
case 17:
|
|
4080
4057
|
if (insertAtIndex !== undefined) insertAtIndex += 1;
|
|
4081
|
-
case
|
|
4058
|
+
case 18:
|
|
4082
4059
|
i += 1;
|
|
4083
|
-
|
|
4060
|
+
_context21.next = 9;
|
|
4084
4061
|
break;
|
|
4085
|
-
case 19:
|
|
4086
|
-
_context23.next = 21;
|
|
4087
|
-
return this.finalizeProductOrderMutation(tempOrder);
|
|
4088
4062
|
case 21:
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
return
|
|
4063
|
+
_context21.next = 23;
|
|
4064
|
+
return this.finalizeProductOrderMutation(tempOrder);
|
|
4065
|
+
case 23:
|
|
4066
|
+
return _context21.abrupt("return", tempOrder.products);
|
|
4067
|
+
case 24:
|
|
4068
|
+
appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking, {
|
|
4093
4069
|
insertAtIndex: insertAtIndex
|
|
4094
4070
|
});
|
|
4095
|
-
|
|
4096
|
-
|
|
4071
|
+
if (!appendResult) {
|
|
4072
|
+
_context21.next = 28;
|
|
4073
|
+
break;
|
|
4074
|
+
}
|
|
4075
|
+
_context21.next = 28;
|
|
4076
|
+
return appendResult;
|
|
4077
|
+
case 28:
|
|
4078
|
+
_context21.next = 30;
|
|
4097
4079
|
return this.finalizeProductOrderMutation(tempOrder);
|
|
4098
|
-
case
|
|
4080
|
+
case 30:
|
|
4099
4081
|
this.logInfo('addProductToOrder success', {
|
|
4100
4082
|
product_id: product.product_id,
|
|
4101
4083
|
with_booking: !!booking
|
|
4102
4084
|
});
|
|
4103
|
-
return
|
|
4104
|
-
case
|
|
4085
|
+
return _context21.abrupt("return", tempOrder.products);
|
|
4086
|
+
case 32:
|
|
4105
4087
|
case "end":
|
|
4106
|
-
return
|
|
4088
|
+
return _context21.stop();
|
|
4107
4089
|
}
|
|
4108
|
-
},
|
|
4090
|
+
}, _callee19, this);
|
|
4109
4091
|
}));
|
|
4110
|
-
function addProductToOrder(
|
|
4092
|
+
function addProductToOrder(_x21, _x22, _x23) {
|
|
4111
4093
|
return _addProductToOrder.apply(this, arguments);
|
|
4112
4094
|
}
|
|
4113
4095
|
return addProductToOrder;
|
|
@@ -4125,93 +4107,103 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4125
4107
|
}, {
|
|
4126
4108
|
key: "addProductsToOrder",
|
|
4127
4109
|
value: (function () {
|
|
4128
|
-
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4129
|
-
var tempOrder, _iterator20, _step20, item, product, booking,
|
|
4130
|
-
return _regeneratorRuntime().wrap(function
|
|
4131
|
-
while (1) switch (
|
|
4110
|
+
var _addProductsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(items, options) {
|
|
4111
|
+
var tempOrder, _iterator20, _step20, item, product, booking, _ref61, _productRecord$num2, productRecord, splitCount, i, singleLine, _appendResult2, appendResult;
|
|
4112
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context22) {
|
|
4113
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
4132
4114
|
case 0:
|
|
4133
4115
|
tempOrder = this.ensureTempOrder();
|
|
4134
4116
|
if (!(!Array.isArray(items) || items.length === 0)) {
|
|
4135
|
-
|
|
4117
|
+
_context22.next = 3;
|
|
4136
4118
|
break;
|
|
4137
4119
|
}
|
|
4138
|
-
return
|
|
4120
|
+
return _context22.abrupt("return", tempOrder.products);
|
|
4139
4121
|
case 3:
|
|
4140
4122
|
_iterator20 = _createForOfIteratorHelper(items || []);
|
|
4141
|
-
|
|
4123
|
+
_context22.prev = 4;
|
|
4142
4124
|
_iterator20.s();
|
|
4143
4125
|
case 6:
|
|
4144
4126
|
if ((_step20 = _iterator20.n()).done) {
|
|
4145
|
-
|
|
4127
|
+
_context22.next = 34;
|
|
4146
4128
|
break;
|
|
4147
4129
|
}
|
|
4148
4130
|
item = _step20.value;
|
|
4149
4131
|
product = item.product, booking = item.booking;
|
|
4150
4132
|
if (product) {
|
|
4151
|
-
|
|
4133
|
+
_context22.next = 11;
|
|
4152
4134
|
break;
|
|
4153
4135
|
}
|
|
4154
|
-
return
|
|
4136
|
+
return _context22.abrupt("continue", 32);
|
|
4155
4137
|
case 11:
|
|
4156
4138
|
if (!booking) {
|
|
4157
|
-
|
|
4139
|
+
_context22.next = 28;
|
|
4158
4140
|
break;
|
|
4159
4141
|
}
|
|
4160
4142
|
productRecord = product;
|
|
4161
|
-
splitCount = getSafeProductNum((
|
|
4143
|
+
splitCount = getSafeProductNum((_ref61 = (_productRecord$num2 = productRecord.num) !== null && _productRecord$num2 !== void 0 ? _productRecord$num2 : productRecord.product_quantity) !== null && _ref61 !== void 0 ? _ref61 : 1);
|
|
4162
4144
|
if (!(splitCount > 1)) {
|
|
4163
|
-
|
|
4145
|
+
_context22.next = 28;
|
|
4164
4146
|
break;
|
|
4165
4147
|
}
|
|
4166
4148
|
i = 0;
|
|
4167
4149
|
case 16:
|
|
4168
4150
|
if (!(i < splitCount)) {
|
|
4169
|
-
|
|
4151
|
+
_context22.next = 27;
|
|
4170
4152
|
break;
|
|
4171
4153
|
}
|
|
4172
4154
|
singleLine = cloneDeep(productRecord);
|
|
4173
4155
|
singleLine.num = 1;
|
|
4174
4156
|
delete singleLine.product_quantity;
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4157
|
+
_appendResult2 = this.appendProductLineToTempOrder(tempOrder, singleLine, cloneDeep(booking));
|
|
4158
|
+
if (!_appendResult2) {
|
|
4159
|
+
_context22.next = 24;
|
|
4160
|
+
break;
|
|
4161
|
+
}
|
|
4162
|
+
_context22.next = 24;
|
|
4163
|
+
return _appendResult2;
|
|
4164
|
+
case 24:
|
|
4178
4165
|
i += 1;
|
|
4179
|
-
|
|
4166
|
+
_context22.next = 16;
|
|
4180
4167
|
break;
|
|
4181
|
-
case
|
|
4182
|
-
return
|
|
4183
|
-
case 26:
|
|
4184
|
-
_context24.next = 28;
|
|
4185
|
-
return this.appendProductLineToTempOrder(tempOrder, product, booking);
|
|
4168
|
+
case 27:
|
|
4169
|
+
return _context22.abrupt("continue", 32);
|
|
4186
4170
|
case 28:
|
|
4187
|
-
|
|
4171
|
+
appendResult = this.appendProductLineToTempOrder(tempOrder, product, booking);
|
|
4172
|
+
if (!appendResult) {
|
|
4173
|
+
_context22.next = 32;
|
|
4174
|
+
break;
|
|
4175
|
+
}
|
|
4176
|
+
_context22.next = 32;
|
|
4177
|
+
return appendResult;
|
|
4178
|
+
case 32:
|
|
4179
|
+
_context22.next = 6;
|
|
4188
4180
|
break;
|
|
4189
|
-
case
|
|
4190
|
-
|
|
4181
|
+
case 34:
|
|
4182
|
+
_context22.next = 39;
|
|
4191
4183
|
break;
|
|
4192
|
-
case
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
_iterator20.e(
|
|
4196
|
-
case
|
|
4197
|
-
|
|
4184
|
+
case 36:
|
|
4185
|
+
_context22.prev = 36;
|
|
4186
|
+
_context22.t0 = _context22["catch"](4);
|
|
4187
|
+
_iterator20.e(_context22.t0);
|
|
4188
|
+
case 39:
|
|
4189
|
+
_context22.prev = 39;
|
|
4198
4190
|
_iterator20.f();
|
|
4199
|
-
return
|
|
4200
|
-
case
|
|
4201
|
-
|
|
4191
|
+
return _context22.finish(39);
|
|
4192
|
+
case 42:
|
|
4193
|
+
_context22.next = 44;
|
|
4202
4194
|
return this.finalizeProductOrderMutation(tempOrder, options);
|
|
4203
|
-
case
|
|
4195
|
+
case 44:
|
|
4204
4196
|
this.logInfo('addProductsToOrder success', {
|
|
4205
4197
|
itemsCount: items.length
|
|
4206
4198
|
});
|
|
4207
|
-
return
|
|
4208
|
-
case
|
|
4199
|
+
return _context22.abrupt("return", tempOrder.products);
|
|
4200
|
+
case 46:
|
|
4209
4201
|
case "end":
|
|
4210
|
-
return
|
|
4202
|
+
return _context22.stop();
|
|
4211
4203
|
}
|
|
4212
|
-
},
|
|
4204
|
+
}, _callee20, this, [[4, 36, 39, 42]]);
|
|
4213
4205
|
}));
|
|
4214
|
-
function addProductsToOrder(
|
|
4206
|
+
function addProductsToOrder(_x24, _x25) {
|
|
4215
4207
|
return _addProductsToOrder.apply(this, arguments);
|
|
4216
4208
|
}
|
|
4217
4209
|
return addProductsToOrder;
|
|
@@ -4238,24 +4230,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4238
4230
|
}, {
|
|
4239
4231
|
key: "getBundleRuntimeIdentity",
|
|
4240
4232
|
value: function getBundleRuntimeIdentity(bundle) {
|
|
4241
|
-
var
|
|
4233
|
+
var _ref62, _bundle$bundle_id2, _ref63, _bundle$bundle_group_2, _ref64, _ref65, _bundle$bundle_produc3, _ref66, _bundle$bundle_varian3;
|
|
4242
4234
|
if (!bundle || _typeof(bundle) !== 'object') return '';
|
|
4243
|
-
return [(
|
|
4235
|
+
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('|');
|
|
4244
4236
|
}
|
|
4245
4237
|
}, {
|
|
4246
4238
|
key: "preservePersistedBundlePriceFields",
|
|
4247
4239
|
value: function preservePersistedBundlePriceFields(previousBundles, nextBundles) {
|
|
4248
|
-
var
|
|
4240
|
+
var _this28 = this;
|
|
4249
4241
|
if (!Array.isArray(nextBundles)) return nextBundles;
|
|
4250
4242
|
if (!Array.isArray(previousBundles) || previousBundles.length === 0) return nextBundles;
|
|
4251
4243
|
var previousByIdentity = new Map();
|
|
4252
4244
|
previousBundles.forEach(function (bundle) {
|
|
4253
|
-
var identity =
|
|
4245
|
+
var identity = _this28.getBundleRuntimeIdentity(bundle);
|
|
4254
4246
|
if (identity) previousByIdentity.set(identity, bundle);
|
|
4255
4247
|
});
|
|
4256
4248
|
return nextBundles.map(function (bundle, index) {
|
|
4257
4249
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
4258
|
-
var previous = previousByIdentity.get(
|
|
4250
|
+
var previous = previousByIdentity.get(_this28.getBundleRuntimeIdentity(bundle)) || previousBundles[index];
|
|
4259
4251
|
if (!previous || _typeof(previous) !== 'object') return bundle;
|
|
4260
4252
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), (bundle.cover === undefined || bundle.cover === null || bundle.cover === '') && previous.cover !== undefined && previous.cover !== null && previous.cover !== '' ? {
|
|
4261
4253
|
cover: previous.cover
|
|
@@ -4391,13 +4383,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4391
4383
|
delete nextProduct.metadata.main_product_original_price;
|
|
4392
4384
|
delete nextProduct.metadata.price_schema_version;
|
|
4393
4385
|
} else if (callerChangesLineConfiguration && !callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
4394
|
-
var
|
|
4386
|
+
var _ref67, _targetProduct$metada10, _targetProduct$metada11, _ref68, _targetProduct$metada12, _targetProduct$metada13, _targetProduct$metada14;
|
|
4395
4387
|
// 仅 option / bundle 变化时,保留历史 source 和主商品折扣金额,
|
|
4396
4388
|
// 但必须让 original 与 selling 一起随新的 option 金额移动。
|
|
4397
4389
|
var previousOptionSum = sumOptionUnitPrice(getProductSkuOptions(targetProduct));
|
|
4398
4390
|
var nextOptionSum = sumOptionUnitPrice(getProductSkuOptions(nextProduct));
|
|
4399
|
-
var _previousMainOriginal = new Decimal(Number((
|
|
4400
|
-
var _previousMainSelling = new Decimal(Number((
|
|
4391
|
+
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);
|
|
4392
|
+
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);
|
|
4401
4393
|
var _preservedDiscount = _previousMainOriginal.minus(_previousMainSelling);
|
|
4402
4394
|
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);
|
|
4403
4395
|
var _nextMainOriginal = previousSource.plus(nextOptionSum);
|
|
@@ -4456,21 +4448,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4456
4448
|
}, {
|
|
4457
4449
|
key: "updateOrderProduct",
|
|
4458
4450
|
value: function () {
|
|
4459
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4451
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
|
|
4460
4452
|
var tempOrder, updatedProductUid;
|
|
4461
|
-
return _regeneratorRuntime().wrap(function
|
|
4462
|
-
while (1) switch (
|
|
4453
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context23) {
|
|
4454
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
4463
4455
|
case 0:
|
|
4464
4456
|
tempOrder = this.ensureTempOrder();
|
|
4465
4457
|
updatedProductUid = this.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
4466
|
-
|
|
4458
|
+
_context23.next = 4;
|
|
4467
4459
|
return this.applyPromotion();
|
|
4468
4460
|
case 4:
|
|
4469
4461
|
this.applyDiscount({
|
|
4470
4462
|
reapplyBookingDiscountProductUids: params.allow_booking_discount_reapply && updatedProductUid ? [String(updatedProductUid)] : undefined
|
|
4471
4463
|
});
|
|
4472
4464
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4473
|
-
|
|
4465
|
+
_context23.next = 8;
|
|
4474
4466
|
return this.recalculateSummary({
|
|
4475
4467
|
createIfMissing: true
|
|
4476
4468
|
});
|
|
@@ -4479,14 +4471,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4479
4471
|
this.logInfo('updateOrderProduct success', {
|
|
4480
4472
|
params: params
|
|
4481
4473
|
});
|
|
4482
|
-
return
|
|
4474
|
+
return _context23.abrupt("return", tempOrder.products);
|
|
4483
4475
|
case 11:
|
|
4484
4476
|
case "end":
|
|
4485
|
-
return
|
|
4477
|
+
return _context23.stop();
|
|
4486
4478
|
}
|
|
4487
|
-
},
|
|
4479
|
+
}, _callee21, this);
|
|
4488
4480
|
}));
|
|
4489
|
-
function updateOrderProduct(
|
|
4481
|
+
function updateOrderProduct(_x26) {
|
|
4490
4482
|
return _updateOrderProduct.apply(this, arguments);
|
|
4491
4483
|
}
|
|
4492
4484
|
return updateOrderProduct;
|
|
@@ -4494,28 +4486,28 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4494
4486
|
}, {
|
|
4495
4487
|
key: "updateOrderProducts",
|
|
4496
4488
|
value: function () {
|
|
4497
|
-
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4498
|
-
var
|
|
4489
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(paramsList) {
|
|
4490
|
+
var _this29 = this;
|
|
4499
4491
|
var tempOrder, reapplyBookingDiscountProductUids;
|
|
4500
|
-
return _regeneratorRuntime().wrap(function
|
|
4501
|
-
while (1) switch (
|
|
4492
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context24) {
|
|
4493
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
4502
4494
|
case 0:
|
|
4503
4495
|
tempOrder = this.ensureTempOrder();
|
|
4504
4496
|
if (paramsList.length) {
|
|
4505
|
-
|
|
4497
|
+
_context24.next = 3;
|
|
4506
4498
|
break;
|
|
4507
4499
|
}
|
|
4508
|
-
return
|
|
4500
|
+
return _context24.abrupt("return", tempOrder.products);
|
|
4509
4501
|
case 3:
|
|
4510
4502
|
reapplyBookingDiscountProductUids = paramsList.reduce(function (acc, params) {
|
|
4511
|
-
var updatedProductUid =
|
|
4503
|
+
var updatedProductUid = _this29.applyOrderProductUpdateToTempOrder(tempOrder, params);
|
|
4512
4504
|
// 批量改预约时间时,延迟到最后一次折扣计算里统一恢复已选预约折扣卡。
|
|
4513
4505
|
if (params.allow_booking_discount_reapply && updatedProductUid) {
|
|
4514
4506
|
acc.push(String(updatedProductUid));
|
|
4515
4507
|
}
|
|
4516
4508
|
return acc;
|
|
4517
4509
|
}, []);
|
|
4518
|
-
|
|
4510
|
+
_context24.next = 6;
|
|
4519
4511
|
return this.finalizeAfterProductsMutation(tempOrder, {
|
|
4520
4512
|
reapplyBookingDiscountProductUids: reapplyBookingDiscountProductUids.length ? reapplyBookingDiscountProductUids : undefined
|
|
4521
4513
|
});
|
|
@@ -4523,14 +4515,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4523
4515
|
this.logInfo('updateOrderProduct success', {
|
|
4524
4516
|
paramsList: paramsList
|
|
4525
4517
|
});
|
|
4526
|
-
return
|
|
4518
|
+
return _context24.abrupt("return", tempOrder.products);
|
|
4527
4519
|
case 8:
|
|
4528
4520
|
case "end":
|
|
4529
|
-
return
|
|
4521
|
+
return _context24.stop();
|
|
4530
4522
|
}
|
|
4531
|
-
},
|
|
4523
|
+
}, _callee22, this);
|
|
4532
4524
|
}));
|
|
4533
|
-
function updateOrderProducts(
|
|
4525
|
+
function updateOrderProducts(_x27) {
|
|
4534
4526
|
return _updateOrderProducts.apply(this, arguments);
|
|
4535
4527
|
}
|
|
4536
4528
|
return updateOrderProducts;
|
|
@@ -4538,11 +4530,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4538
4530
|
}, {
|
|
4539
4531
|
key: "updateOrderProductQuantity",
|
|
4540
4532
|
value: function () {
|
|
4541
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4533
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
|
|
4542
4534
|
var _targetProduct$metada17;
|
|
4543
4535
|
var product_id, product_variant_id, num, unique_identification_number, identity_key, product_sku, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
|
|
4544
|
-
return _regeneratorRuntime().wrap(function
|
|
4545
|
-
while (1) switch (
|
|
4536
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context25) {
|
|
4537
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
4546
4538
|
case 0:
|
|
4547
4539
|
product_id = params.product_id, product_variant_id = params.product_variant_id, num = params.num, unique_identification_number = params.unique_identification_number, identity_key = params.identity_key, product_sku = params.product_sku, product_bundle = params.product_bundle;
|
|
4548
4540
|
tempOrder = this.ensureTempOrder();
|
|
@@ -4571,7 +4563,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4571
4563
|
productIndex = getProductIdentityIndex(tempOrder.products, identityLookup);
|
|
4572
4564
|
}
|
|
4573
4565
|
if (!(productIndex === -1)) {
|
|
4574
|
-
|
|
4566
|
+
_context25.next = 12;
|
|
4575
4567
|
break;
|
|
4576
4568
|
}
|
|
4577
4569
|
throw new Error('[Order] 目标商品不存在,无法更新数量');
|
|
@@ -4585,12 +4577,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4585
4577
|
}));
|
|
4586
4578
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
4587
4579
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
4588
|
-
|
|
4580
|
+
_context25.next = 18;
|
|
4589
4581
|
return this.applyPromotion();
|
|
4590
4582
|
case 18:
|
|
4591
4583
|
this.applyDiscount();
|
|
4592
4584
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4593
|
-
|
|
4585
|
+
_context25.next = 22;
|
|
4594
4586
|
return this.recalculateSummary({
|
|
4595
4587
|
createIfMissing: true
|
|
4596
4588
|
});
|
|
@@ -4599,14 +4591,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4599
4591
|
this.logInfo('updateOrderProductQuantity success', {
|
|
4600
4592
|
params: params
|
|
4601
4593
|
});
|
|
4602
|
-
return
|
|
4594
|
+
return _context25.abrupt("return", tempOrder.products);
|
|
4603
4595
|
case 25:
|
|
4604
4596
|
case "end":
|
|
4605
|
-
return
|
|
4597
|
+
return _context25.stop();
|
|
4606
4598
|
}
|
|
4607
|
-
},
|
|
4599
|
+
}, _callee23, this);
|
|
4608
4600
|
}));
|
|
4609
|
-
function updateOrderProductQuantity(
|
|
4601
|
+
function updateOrderProductQuantity(_x28) {
|
|
4610
4602
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
4611
4603
|
}
|
|
4612
4604
|
return updateOrderProductQuantity;
|
|
@@ -4647,19 +4639,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4647
4639
|
}, {
|
|
4648
4640
|
key: "finalizeAfterProductsMutation",
|
|
4649
4641
|
value: (function () {
|
|
4650
|
-
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4651
|
-
return _regeneratorRuntime().wrap(function
|
|
4652
|
-
while (1) switch (
|
|
4642
|
+
var _finalizeAfterProductsMutation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(tempOrder, options) {
|
|
4643
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context26) {
|
|
4644
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
4653
4645
|
case 0:
|
|
4654
4646
|
this.syncTempOrderHolderFromBookings(tempOrder);
|
|
4655
|
-
|
|
4647
|
+
_context26.next = 3;
|
|
4656
4648
|
return this.applyPromotion();
|
|
4657
4649
|
case 3:
|
|
4658
4650
|
this.applyDiscount({
|
|
4659
4651
|
reapplyBookingDiscountProductUids: options === null || options === void 0 ? void 0 : options.reapplyBookingDiscountProductUids
|
|
4660
4652
|
});
|
|
4661
4653
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4662
|
-
|
|
4654
|
+
_context26.next = 7;
|
|
4663
4655
|
return this.recalculateSummary({
|
|
4664
4656
|
createIfMissing: true
|
|
4665
4657
|
});
|
|
@@ -4667,11 +4659,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4667
4659
|
this.persistTempOrder();
|
|
4668
4660
|
case 8:
|
|
4669
4661
|
case "end":
|
|
4670
|
-
return
|
|
4662
|
+
return _context26.stop();
|
|
4671
4663
|
}
|
|
4672
|
-
},
|
|
4664
|
+
}, _callee24, this);
|
|
4673
4665
|
}));
|
|
4674
|
-
function finalizeAfterProductsMutation(
|
|
4666
|
+
function finalizeAfterProductsMutation(_x29, _x30) {
|
|
4675
4667
|
return _finalizeAfterProductsMutation.apply(this, arguments);
|
|
4676
4668
|
}
|
|
4677
4669
|
return finalizeAfterProductsMutation;
|
|
@@ -4686,18 +4678,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4686
4678
|
}, {
|
|
4687
4679
|
key: "removeProductsFromOrder",
|
|
4688
4680
|
value: (function () {
|
|
4689
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4690
|
-
var
|
|
4681
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(identities, options) {
|
|
4682
|
+
var _this30 = this;
|
|
4691
4683
|
var tempOrder, productsBeforeRemove, bookingsBeforeRemove, preserveDisplayPosition, anchorIndex, productsAfterAnchor, matchedProducts, removedProducts, _i2, _removedProducts, product, linkedBookingUidsToRemove, _iterator21, _step21, _loop3, remainingProductIndex, remainingProduct, nextProduct, productsWithoutRemaining, nextProductIndex;
|
|
4692
|
-
return _regeneratorRuntime().wrap(function
|
|
4693
|
-
while (1) switch (
|
|
4684
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context28) {
|
|
4685
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
4694
4686
|
case 0:
|
|
4695
4687
|
tempOrder = this.ensureTempOrder();
|
|
4696
4688
|
if (identities.length) {
|
|
4697
|
-
|
|
4689
|
+
_context28.next = 3;
|
|
4698
4690
|
break;
|
|
4699
4691
|
}
|
|
4700
|
-
return
|
|
4692
|
+
return _context28.abrupt("return", tempOrder.products);
|
|
4701
4693
|
case 3:
|
|
4702
4694
|
productsBeforeRemove = tempOrder.products || [];
|
|
4703
4695
|
bookingsBeforeRemove = tempOrder.bookings || [];
|
|
@@ -4727,29 +4719,29 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4727
4719
|
}
|
|
4728
4720
|
linkedBookingUidsToRemove = new Set();
|
|
4729
4721
|
_iterator21 = _createForOfIteratorHelper(matchedProducts);
|
|
4730
|
-
|
|
4722
|
+
_context28.prev = 14;
|
|
4731
4723
|
_loop3 = /*#__PURE__*/_regeneratorRuntime().mark(function _loop3() {
|
|
4732
4724
|
var _metadata11, _metadata12, _metadata13, _metadata14;
|
|
4733
4725
|
var product, productUid, productBookingUid, isAddTimeProduct;
|
|
4734
|
-
return _regeneratorRuntime().wrap(function _loop3$(
|
|
4735
|
-
while (1) switch (
|
|
4726
|
+
return _regeneratorRuntime().wrap(function _loop3$(_context27) {
|
|
4727
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
4736
4728
|
case 0:
|
|
4737
4729
|
product = _step21.value;
|
|
4738
4730
|
productUid = (product === null || product === void 0 || (_metadata11 = product.metadata) === null || _metadata11 === void 0 ? void 0 : _metadata11.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
4739
4731
|
productBookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_metadata12 = product.metadata) === null || _metadata12 === void 0 ? void 0 : _metadata12.booking_uid);
|
|
4740
4732
|
isAddTimeProduct = (product === null || product === void 0 || (_metadata13 = product.metadata) === null || _metadata13 === void 0 ? void 0 : _metadata13.product_add_schedule_time) !== undefined && (product === null || product === void 0 || (_metadata14 = product.metadata) === null || _metadata14 === void 0 ? void 0 : _metadata14.product_add_schedule_time) !== null;
|
|
4741
4733
|
if (!isAddTimeProduct) {
|
|
4742
|
-
|
|
4734
|
+
_context27.next = 6;
|
|
4743
4735
|
break;
|
|
4744
4736
|
}
|
|
4745
|
-
return
|
|
4737
|
+
return _context27.abrupt("return", 1);
|
|
4746
4738
|
case 6:
|
|
4747
4739
|
if (productBookingUid !== undefined && productBookingUid !== null && productBookingUid !== '') {
|
|
4748
4740
|
linkedBookingUidsToRemove.add(String(productBookingUid));
|
|
4749
4741
|
}
|
|
4750
4742
|
if (productUid !== undefined && productUid !== null && productUid !== '') {
|
|
4751
4743
|
bookingsBeforeRemove.forEach(function (booking) {
|
|
4752
|
-
var bookingUid =
|
|
4744
|
+
var bookingUid = _this30.getBookingUniqueIdentificationNumber(booking);
|
|
4753
4745
|
if (bookingUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) {
|
|
4754
4746
|
linkedBookingUidsToRemove.add(bookingUid);
|
|
4755
4747
|
}
|
|
@@ -4757,37 +4749,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4757
4749
|
}
|
|
4758
4750
|
case 8:
|
|
4759
4751
|
case "end":
|
|
4760
|
-
return
|
|
4752
|
+
return _context27.stop();
|
|
4761
4753
|
}
|
|
4762
4754
|
}, _loop3);
|
|
4763
4755
|
});
|
|
4764
4756
|
_iterator21.s();
|
|
4765
4757
|
case 17:
|
|
4766
4758
|
if ((_step21 = _iterator21.n()).done) {
|
|
4767
|
-
|
|
4759
|
+
_context28.next = 23;
|
|
4768
4760
|
break;
|
|
4769
4761
|
}
|
|
4770
|
-
return
|
|
4762
|
+
return _context28.delegateYield(_loop3(), "t0", 19);
|
|
4771
4763
|
case 19:
|
|
4772
|
-
if (!
|
|
4773
|
-
|
|
4764
|
+
if (!_context28.t0) {
|
|
4765
|
+
_context28.next = 21;
|
|
4774
4766
|
break;
|
|
4775
4767
|
}
|
|
4776
|
-
return
|
|
4768
|
+
return _context28.abrupt("continue", 21);
|
|
4777
4769
|
case 21:
|
|
4778
|
-
|
|
4770
|
+
_context28.next = 17;
|
|
4779
4771
|
break;
|
|
4780
4772
|
case 23:
|
|
4781
|
-
|
|
4773
|
+
_context28.next = 28;
|
|
4782
4774
|
break;
|
|
4783
4775
|
case 25:
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
_iterator21.e(
|
|
4776
|
+
_context28.prev = 25;
|
|
4777
|
+
_context28.t1 = _context28["catch"](14);
|
|
4778
|
+
_iterator21.e(_context28.t1);
|
|
4787
4779
|
case 28:
|
|
4788
|
-
|
|
4780
|
+
_context28.prev = 28;
|
|
4789
4781
|
_iterator21.f();
|
|
4790
|
-
return
|
|
4782
|
+
return _context28.finish(28);
|
|
4791
4783
|
case 31:
|
|
4792
4784
|
if (linkedBookingUidsToRemove.size > 0) {
|
|
4793
4785
|
// 删除主预约商品时,同步移除挂在同一 booking_uid 下的加时商品,避免残留孤儿行。
|
|
@@ -4814,20 +4806,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4814
4806
|
tempOrder.products = nextProductIndex >= 0 ? [].concat(_toConsumableArray(productsWithoutRemaining.slice(0, nextProductIndex)), [remainingProduct], _toConsumableArray(productsWithoutRemaining.slice(nextProductIndex))) : [].concat(_toConsumableArray(productsWithoutRemaining), [remainingProduct]);
|
|
4815
4807
|
}
|
|
4816
4808
|
}
|
|
4817
|
-
|
|
4809
|
+
_context28.next = 35;
|
|
4818
4810
|
return this.finalizeAfterProductsMutation(tempOrder);
|
|
4819
4811
|
case 35:
|
|
4820
4812
|
this.logInfo('removeProductsFromOrder success', {
|
|
4821
4813
|
identities: identities
|
|
4822
4814
|
});
|
|
4823
|
-
return
|
|
4815
|
+
return _context28.abrupt("return", tempOrder.products);
|
|
4824
4816
|
case 37:
|
|
4825
4817
|
case "end":
|
|
4826
|
-
return
|
|
4818
|
+
return _context28.stop();
|
|
4827
4819
|
}
|
|
4828
|
-
},
|
|
4820
|
+
}, _callee25, this, [[14, 25, 28, 31]]);
|
|
4829
4821
|
}));
|
|
4830
|
-
function removeProductsFromOrder(
|
|
4822
|
+
function removeProductsFromOrder(_x31, _x32) {
|
|
4831
4823
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
4832
4824
|
}
|
|
4833
4825
|
return removeProductsFromOrder;
|
|
@@ -4835,18 +4827,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4835
4827
|
}, {
|
|
4836
4828
|
key: "removeProductFromOrder",
|
|
4837
4829
|
value: function () {
|
|
4838
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4839
|
-
return _regeneratorRuntime().wrap(function
|
|
4840
|
-
while (1) switch (
|
|
4830
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(identity, options) {
|
|
4831
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context29) {
|
|
4832
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
4841
4833
|
case 0:
|
|
4842
|
-
return
|
|
4834
|
+
return _context29.abrupt("return", this.removeProductsFromOrder([identity], options));
|
|
4843
4835
|
case 1:
|
|
4844
4836
|
case "end":
|
|
4845
|
-
return
|
|
4837
|
+
return _context29.stop();
|
|
4846
4838
|
}
|
|
4847
|
-
},
|
|
4839
|
+
}, _callee26, this);
|
|
4848
4840
|
}));
|
|
4849
|
-
function removeProductFromOrder(
|
|
4841
|
+
function removeProductFromOrder(_x33, _x34) {
|
|
4850
4842
|
return _removeProductFromOrder.apply(this, arguments);
|
|
4851
4843
|
}
|
|
4852
4844
|
return removeProductFromOrder;
|
|
@@ -4858,10 +4850,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4858
4850
|
}, {
|
|
4859
4851
|
key: "clearOrderCartLines",
|
|
4860
4852
|
value: (function () {
|
|
4861
|
-
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4853
|
+
var _clearOrderCartLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
|
|
4862
4854
|
var tempOrder;
|
|
4863
|
-
return _regeneratorRuntime().wrap(function
|
|
4864
|
-
while (1) switch (
|
|
4855
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context30) {
|
|
4856
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
4865
4857
|
case 0:
|
|
4866
4858
|
tempOrder = this.ensureTempOrder();
|
|
4867
4859
|
tempOrder.products = [];
|
|
@@ -4872,24 +4864,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4872
4864
|
productsByUid: {}
|
|
4873
4865
|
});
|
|
4874
4866
|
}
|
|
4875
|
-
|
|
4867
|
+
_context30.next = 7;
|
|
4876
4868
|
return this.applyPromotion();
|
|
4877
4869
|
case 7:
|
|
4878
4870
|
this.applyDiscount();
|
|
4879
4871
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
4880
|
-
|
|
4872
|
+
_context30.next = 11;
|
|
4881
4873
|
return this.recalculateSummary({
|
|
4882
4874
|
createIfMissing: true
|
|
4883
4875
|
});
|
|
4884
4876
|
case 11:
|
|
4885
4877
|
this.persistTempOrder();
|
|
4886
4878
|
this.logInfo('clearOrderCartLines success', {});
|
|
4887
|
-
return
|
|
4879
|
+
return _context30.abrupt("return", tempOrder);
|
|
4888
4880
|
case 14:
|
|
4889
4881
|
case "end":
|
|
4890
|
-
return
|
|
4882
|
+
return _context30.stop();
|
|
4891
4883
|
}
|
|
4892
|
-
},
|
|
4884
|
+
}, _callee27, this);
|
|
4893
4885
|
}));
|
|
4894
4886
|
function clearOrderCartLines() {
|
|
4895
4887
|
return _clearOrderCartLines.apply(this, arguments);
|
|
@@ -4900,23 +4892,23 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4900
4892
|
}, {
|
|
4901
4893
|
key: "buildCurrentSubmitPayloadForLocalPrint",
|
|
4902
4894
|
value: function buildCurrentSubmitPayloadForLocalPrint(params) {
|
|
4903
|
-
var _params$cacheId, _this$otherParams3,
|
|
4895
|
+
var _params$cacheId, _this$otherParams3, _ref69, _params$businessCode, _this$otherParams4, _this$otherParams5;
|
|
4904
4896
|
var tempOrder = this.ensureTempOrder();
|
|
4905
4897
|
this.persistTempOrder();
|
|
4906
4898
|
var payload = buildSubmitPayload({
|
|
4907
4899
|
tempOrder: tempOrder,
|
|
4908
4900
|
cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
|
|
4909
4901
|
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.platform),
|
|
4910
|
-
businessCode: (
|
|
4902
|
+
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,
|
|
4911
4903
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
4912
4904
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
4913
4905
|
summary: this.store.summary || createEmptySummary(),
|
|
4914
4906
|
enhance: function enhance(nextPayload) {
|
|
4915
|
-
var
|
|
4907
|
+
var _ref70, _tempOrder$order_numb, _ref71, _tempOrder$shop_order, _ref72, _tempOrder$shop_full_;
|
|
4916
4908
|
return _objectSpread(_objectSpread({}, nextPayload), {}, {
|
|
4917
|
-
order_number: (
|
|
4918
|
-
shop_order_number: (
|
|
4919
|
-
shop_full_order_number: (
|
|
4909
|
+
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,
|
|
4910
|
+
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,
|
|
4911
|
+
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,
|
|
4920
4912
|
small_ticket_data_flag: 1
|
|
4921
4913
|
});
|
|
4922
4914
|
}
|
|
@@ -4927,17 +4919,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4927
4919
|
}, {
|
|
4928
4920
|
key: "applyLocalPrintOrderNumbers",
|
|
4929
4921
|
value: function () {
|
|
4930
|
-
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4922
|
+
var _applyLocalPrintOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(order) {
|
|
4931
4923
|
var tempOrder, shopOrderNumber, shopFullOrderNumber;
|
|
4932
|
-
return _regeneratorRuntime().wrap(function
|
|
4933
|
-
while (1) switch (
|
|
4924
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context31) {
|
|
4925
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
4934
4926
|
case 0:
|
|
4935
4927
|
tempOrder = this.ensureTempOrder();
|
|
4936
4928
|
if (!(!order || _typeof(order) !== 'object')) {
|
|
4937
|
-
|
|
4929
|
+
_context31.next = 3;
|
|
4938
4930
|
break;
|
|
4939
4931
|
}
|
|
4940
|
-
return
|
|
4932
|
+
return _context31.abrupt("return", tempOrder);
|
|
4941
4933
|
case 3:
|
|
4942
4934
|
shopOrderNumber = order.shop_order_number;
|
|
4943
4935
|
shopFullOrderNumber = order.shop_full_order_number;
|
|
@@ -4948,17 +4940,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4948
4940
|
tempOrder.shop_full_order_number = String(shopFullOrderNumber);
|
|
4949
4941
|
}
|
|
4950
4942
|
this.persistTempOrder();
|
|
4951
|
-
|
|
4943
|
+
_context31.next = 10;
|
|
4952
4944
|
return this.saveDraft();
|
|
4953
4945
|
case 10:
|
|
4954
|
-
return
|
|
4946
|
+
return _context31.abrupt("return", tempOrder);
|
|
4955
4947
|
case 11:
|
|
4956
4948
|
case "end":
|
|
4957
|
-
return
|
|
4949
|
+
return _context31.stop();
|
|
4958
4950
|
}
|
|
4959
|
-
},
|
|
4951
|
+
}, _callee28, this);
|
|
4960
4952
|
}));
|
|
4961
|
-
function applyLocalPrintOrderNumbers(
|
|
4953
|
+
function applyLocalPrintOrderNumbers(_x35) {
|
|
4962
4954
|
return _applyLocalPrintOrderNumbers.apply(this, arguments);
|
|
4963
4955
|
}
|
|
4964
4956
|
return applyLocalPrintOrderNumbers;
|
|
@@ -4966,35 +4958,35 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4966
4958
|
}, {
|
|
4967
4959
|
key: "saveTempOrderAsDraft",
|
|
4968
4960
|
value: function () {
|
|
4969
|
-
var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4961
|
+
var _saveTempOrderAsDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
4970
4962
|
var _params$cacheId2, _this$otherParams6, _this$otherParams7, _this$otherParams8, _params$type, _this$otherParams9, _payload$products;
|
|
4971
4963
|
var tempOrder, latestSummary, payload;
|
|
4972
|
-
return _regeneratorRuntime().wrap(function
|
|
4973
|
-
while (1) switch (
|
|
4964
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context32) {
|
|
4965
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
4974
4966
|
case 0:
|
|
4975
4967
|
tempOrder = this.ensureTempOrder();
|
|
4976
4968
|
this.ensureExternalSaleNumber(tempOrder);
|
|
4977
4969
|
this.persistTempOrder();
|
|
4978
|
-
|
|
4970
|
+
_context32.next = 5;
|
|
4979
4971
|
return this.recalculateSummary({
|
|
4980
4972
|
createIfMissing: true
|
|
4981
4973
|
});
|
|
4982
4974
|
case 5:
|
|
4983
|
-
|
|
4984
|
-
if (
|
|
4985
|
-
|
|
4975
|
+
_context32.t1 = _context32.sent;
|
|
4976
|
+
if (_context32.t1) {
|
|
4977
|
+
_context32.next = 8;
|
|
4986
4978
|
break;
|
|
4987
4979
|
}
|
|
4988
|
-
|
|
4980
|
+
_context32.t1 = this.store.summary;
|
|
4989
4981
|
case 8:
|
|
4990
|
-
|
|
4991
|
-
if (
|
|
4992
|
-
|
|
4982
|
+
_context32.t0 = _context32.t1;
|
|
4983
|
+
if (_context32.t0) {
|
|
4984
|
+
_context32.next = 11;
|
|
4993
4985
|
break;
|
|
4994
4986
|
}
|
|
4995
|
-
|
|
4987
|
+
_context32.t0 = createEmptySummary();
|
|
4996
4988
|
case 11:
|
|
4997
|
-
latestSummary =
|
|
4989
|
+
latestSummary = _context32.t0;
|
|
4998
4990
|
payload = buildSubmitPayload({
|
|
4999
4991
|
tempOrder: tempOrder,
|
|
5000
4992
|
cacheId: (_params$cacheId2 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId2 !== void 0 ? _params$cacheId2 : this.cacheId,
|
|
@@ -5015,17 +5007,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5015
5007
|
externalSaleNumber: payload.external_sale_number,
|
|
5016
5008
|
productsCount: ((_payload$products = payload.products) === null || _payload$products === void 0 ? void 0 : _payload$products.length) || 0
|
|
5017
5009
|
});
|
|
5018
|
-
return
|
|
5010
|
+
return _context32.abrupt("return", this.request.post('/order/sales/draft', payload, {
|
|
5019
5011
|
osServer: true,
|
|
5020
5012
|
customToast: function customToast() {}
|
|
5021
5013
|
}));
|
|
5022
5014
|
case 18:
|
|
5023
5015
|
case "end":
|
|
5024
|
-
return
|
|
5016
|
+
return _context32.stop();
|
|
5025
5017
|
}
|
|
5026
|
-
},
|
|
5018
|
+
}, _callee29, this);
|
|
5027
5019
|
}));
|
|
5028
|
-
function saveTempOrderAsDraft(
|
|
5020
|
+
function saveTempOrderAsDraft(_x36) {
|
|
5029
5021
|
return _saveTempOrderAsDraft.apply(this, arguments);
|
|
5030
5022
|
}
|
|
5031
5023
|
return saveTempOrderAsDraft;
|
|
@@ -5039,18 +5031,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5039
5031
|
}, {
|
|
5040
5032
|
key: "submitTempOrder",
|
|
5041
5033
|
value: (function () {
|
|
5042
|
-
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5043
|
-
return _regeneratorRuntime().wrap(function
|
|
5044
|
-
while (1) switch (
|
|
5034
|
+
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
|
|
5035
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context33) {
|
|
5036
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
5045
5037
|
case 0:
|
|
5046
|
-
return
|
|
5038
|
+
return _context33.abrupt("return", this.runSubmitTempOrder(params));
|
|
5047
5039
|
case 1:
|
|
5048
5040
|
case "end":
|
|
5049
|
-
return
|
|
5041
|
+
return _context33.stop();
|
|
5050
5042
|
}
|
|
5051
|
-
},
|
|
5043
|
+
}, _callee30, this);
|
|
5052
5044
|
}));
|
|
5053
|
-
function submitTempOrder(
|
|
5045
|
+
function submitTempOrder(_x37) {
|
|
5054
5046
|
return _submitTempOrder.apply(this, arguments);
|
|
5055
5047
|
}
|
|
5056
5048
|
return submitTempOrder;
|
|
@@ -5058,20 +5050,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5058
5050
|
}, {
|
|
5059
5051
|
key: "submitTempOrderAsync",
|
|
5060
5052
|
value: function () {
|
|
5061
|
-
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5062
|
-
return _regeneratorRuntime().wrap(function
|
|
5063
|
-
while (1) switch (
|
|
5053
|
+
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(params) {
|
|
5054
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context34) {
|
|
5055
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
5064
5056
|
case 0:
|
|
5065
|
-
return
|
|
5057
|
+
return _context34.abrupt("return", this.runSubmitTempOrder(_objectSpread(_objectSpread({}, params), {}, {
|
|
5066
5058
|
syncMode: true
|
|
5067
5059
|
})));
|
|
5068
5060
|
case 1:
|
|
5069
5061
|
case "end":
|
|
5070
|
-
return
|
|
5062
|
+
return _context34.stop();
|
|
5071
5063
|
}
|
|
5072
|
-
},
|
|
5064
|
+
}, _callee31, this);
|
|
5073
5065
|
}));
|
|
5074
|
-
function submitTempOrderAsync(
|
|
5066
|
+
function submitTempOrderAsync(_x38) {
|
|
5075
5067
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
5076
5068
|
}
|
|
5077
5069
|
return submitTempOrderAsync;
|
|
@@ -5079,11 +5071,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5079
5071
|
}, {
|
|
5080
5072
|
key: "runSubmitTempOrder",
|
|
5081
5073
|
value: function () {
|
|
5082
|
-
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5083
|
-
var _params$cacheId3, _this$otherParams10,
|
|
5074
|
+
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
|
|
5075
|
+
var _params$cacheId3, _this$otherParams10, _ref73, _ref74, _submitSnapshot$busin, _this$otherParams11, _this$otherParams12, _submitSnapshot$type;
|
|
5084
5076
|
var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
|
|
5085
|
-
return _regeneratorRuntime().wrap(function
|
|
5086
|
-
while (1) switch (
|
|
5077
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context35) {
|
|
5078
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
5087
5079
|
case 0:
|
|
5088
5080
|
tempOrder = this.ensureTempOrder();
|
|
5089
5081
|
shouldConfirmPendingVoucherPayments = (params === null || params === void 0 ? void 0 : params.confirmPendingVoucherPayments) !== false;
|
|
@@ -5103,26 +5095,26 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5103
5095
|
}
|
|
5104
5096
|
}
|
|
5105
5097
|
this.persistTempOrder();
|
|
5106
|
-
|
|
5098
|
+
_context35.next = 8;
|
|
5107
5099
|
return this.recalculateSummary({
|
|
5108
5100
|
createIfMissing: true
|
|
5109
5101
|
});
|
|
5110
5102
|
case 8:
|
|
5111
|
-
|
|
5112
|
-
if (
|
|
5113
|
-
|
|
5103
|
+
_context35.t1 = _context35.sent;
|
|
5104
|
+
if (_context35.t1) {
|
|
5105
|
+
_context35.next = 11;
|
|
5114
5106
|
break;
|
|
5115
5107
|
}
|
|
5116
|
-
|
|
5108
|
+
_context35.t1 = this.store.summary;
|
|
5117
5109
|
case 11:
|
|
5118
|
-
|
|
5119
|
-
if (
|
|
5120
|
-
|
|
5110
|
+
_context35.t0 = _context35.t1;
|
|
5111
|
+
if (_context35.t0) {
|
|
5112
|
+
_context35.next = 14;
|
|
5121
5113
|
break;
|
|
5122
5114
|
}
|
|
5123
|
-
|
|
5115
|
+
_context35.t0 = createEmptySummary();
|
|
5124
5116
|
case 14:
|
|
5125
|
-
latestSummary =
|
|
5117
|
+
latestSummary = _context35.t0;
|
|
5126
5118
|
effectiveCacheId = (_params$cacheId3 = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId3 !== void 0 ? _params$cacheId3 : this.cacheId;
|
|
5127
5119
|
hasPaymentStatusOverride = (params === null || params === void 0 ? void 0 : params.paymentStatus) !== undefined;
|
|
5128
5120
|
hasSmallTicketDataFlagOverride = (params === null || params === void 0 ? void 0 : params.smallTicketDataFlag) !== undefined;
|
|
@@ -5142,7 +5134,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5142
5134
|
tempOrder: tempOrder,
|
|
5143
5135
|
cacheId: effectiveCacheId,
|
|
5144
5136
|
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.platform),
|
|
5145
|
-
businessCode: (
|
|
5137
|
+
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,
|
|
5146
5138
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
5147
5139
|
type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
|
|
5148
5140
|
summary: latestSummary,
|
|
@@ -5157,10 +5149,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5157
5149
|
if (!payload.created_at) {
|
|
5158
5150
|
payload.created_at = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
5159
5151
|
}
|
|
5160
|
-
|
|
5152
|
+
_context35.next = 26;
|
|
5161
5153
|
return this.saveDraft();
|
|
5162
5154
|
case 26:
|
|
5163
|
-
|
|
5155
|
+
_context35.prev = 26;
|
|
5164
5156
|
this.logInfo('submitTempOrder calling sales checkout', {
|
|
5165
5157
|
orderId: payload.order_id,
|
|
5166
5158
|
externalSaleNumber: payload.external_sale_number,
|
|
@@ -5170,43 +5162,43 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5170
5162
|
smallTicketDataFlag: payload.small_ticket_data_flag,
|
|
5171
5163
|
syncMode: payload.sync_mode
|
|
5172
5164
|
});
|
|
5173
|
-
|
|
5165
|
+
_context35.next = 30;
|
|
5174
5166
|
return this.submitSalesOrder({
|
|
5175
5167
|
query: payload
|
|
5176
5168
|
});
|
|
5177
5169
|
case 30:
|
|
5178
|
-
result =
|
|
5179
|
-
|
|
5170
|
+
result = _context35.sent;
|
|
5171
|
+
_context35.next = 43;
|
|
5180
5172
|
break;
|
|
5181
5173
|
case 33:
|
|
5182
|
-
|
|
5183
|
-
|
|
5184
|
-
backendErrorResponse = this.extractSubmitErrorResponse(
|
|
5174
|
+
_context35.prev = 33;
|
|
5175
|
+
_context35.t2 = _context35["catch"](26);
|
|
5176
|
+
backendErrorResponse = this.extractSubmitErrorResponse(_context35.t2);
|
|
5185
5177
|
if (!backendErrorResponse) {
|
|
5186
|
-
|
|
5178
|
+
_context35.next = 40;
|
|
5187
5179
|
break;
|
|
5188
5180
|
}
|
|
5189
5181
|
this.store.syncState = 'failed';
|
|
5190
5182
|
this.logSubmitBackendRejected(backendErrorResponse, payload);
|
|
5191
|
-
return
|
|
5183
|
+
return _context35.abrupt("return", backendErrorResponse);
|
|
5192
5184
|
case 40:
|
|
5193
5185
|
this.store.syncState = 'failed';
|
|
5194
5186
|
this.logError('submitTempOrder failed', {
|
|
5195
|
-
error:
|
|
5187
|
+
error: _context35.t2 instanceof Error ? _context35.t2.message : String(_context35.t2),
|
|
5196
5188
|
orderId: payload.order_id,
|
|
5197
5189
|
externalSaleNumber: payload.external_sale_number,
|
|
5198
5190
|
paymentStatus: payload.payment_status,
|
|
5199
5191
|
paymentsCount: ((_payload$payments2 = payload.payments) === null || _payload$payments2 === void 0 ? void 0 : _payload$payments2.length) || 0
|
|
5200
5192
|
});
|
|
5201
|
-
throw
|
|
5193
|
+
throw _context35.t2;
|
|
5202
5194
|
case 43:
|
|
5203
5195
|
if (!this.isSubmitResponseRejected(result)) {
|
|
5204
|
-
|
|
5196
|
+
_context35.next = 47;
|
|
5205
5197
|
break;
|
|
5206
5198
|
}
|
|
5207
5199
|
this.store.syncState = 'failed';
|
|
5208
5200
|
this.logSubmitBackendRejected(result, payload);
|
|
5209
|
-
return
|
|
5201
|
+
return _context35.abrupt("return", result);
|
|
5210
5202
|
case 47:
|
|
5211
5203
|
submittedOrderId = this.extractOrderIdFromSubmitResult(result);
|
|
5212
5204
|
this.logInfo('runSubmitTempOrder: 提交成功', {
|
|
@@ -5217,15 +5209,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5217
5209
|
})
|
|
5218
5210
|
});
|
|
5219
5211
|
if (!(submittedOrderId !== null && submittedOrderId !== undefined)) {
|
|
5220
|
-
|
|
5212
|
+
_context35.next = 56;
|
|
5221
5213
|
break;
|
|
5222
5214
|
}
|
|
5223
5215
|
tempOrder.order_id = submittedOrderId;
|
|
5224
5216
|
resultRecord = result;
|
|
5225
|
-
|
|
5217
|
+
_context35.next = 54;
|
|
5226
5218
|
return this.markLocalOrderSynced(submittedOrderId, (resultRecord === null || resultRecord === void 0 ? void 0 : resultRecord.data) || resultRecord || {});
|
|
5227
5219
|
case 54:
|
|
5228
|
-
|
|
5220
|
+
_context35.next = 57;
|
|
5229
5221
|
break;
|
|
5230
5222
|
case 56:
|
|
5231
5223
|
if (this.isLocalPendingSubmitResult(result)) {
|
|
@@ -5234,14 +5226,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5234
5226
|
this.store.syncState = 'submitted';
|
|
5235
5227
|
}
|
|
5236
5228
|
case 57:
|
|
5237
|
-
return
|
|
5229
|
+
return _context35.abrupt("return", result);
|
|
5238
5230
|
case 58:
|
|
5239
5231
|
case "end":
|
|
5240
|
-
return
|
|
5232
|
+
return _context35.stop();
|
|
5241
5233
|
}
|
|
5242
|
-
},
|
|
5234
|
+
}, _callee32, this, [[26, 33]]);
|
|
5243
5235
|
}));
|
|
5244
|
-
function runSubmitTempOrder(
|
|
5236
|
+
function runSubmitTempOrder(_x39) {
|
|
5245
5237
|
return _runSubmitTempOrder.apply(this, arguments);
|
|
5246
5238
|
}
|
|
5247
5239
|
return runSubmitTempOrder;
|
|
@@ -5249,10 +5241,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5249
5241
|
}, {
|
|
5250
5242
|
key: "markLocalOrderSynced",
|
|
5251
5243
|
value: function () {
|
|
5252
|
-
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5244
|
+
var _markLocalOrderSynced = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(orderId, remoteOrder) {
|
|
5253
5245
|
var tempOrder;
|
|
5254
|
-
return _regeneratorRuntime().wrap(function
|
|
5255
|
-
while (1) switch (
|
|
5246
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context36) {
|
|
5247
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
5256
5248
|
case 0:
|
|
5257
5249
|
tempOrder = this.ensureTempOrder();
|
|
5258
5250
|
tempOrder.order_id = orderId;
|
|
@@ -5260,15 +5252,15 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5260
5252
|
this.store.lastOrderInfo = remoteOrder;
|
|
5261
5253
|
this.store.syncState = 'submitted';
|
|
5262
5254
|
this.persistTempOrder();
|
|
5263
|
-
|
|
5255
|
+
_context36.next = 8;
|
|
5264
5256
|
return this.saveDraft();
|
|
5265
5257
|
case 8:
|
|
5266
5258
|
case "end":
|
|
5267
|
-
return
|
|
5259
|
+
return _context36.stop();
|
|
5268
5260
|
}
|
|
5269
|
-
},
|
|
5261
|
+
}, _callee33, this);
|
|
5270
5262
|
}));
|
|
5271
|
-
function markLocalOrderSynced(
|
|
5263
|
+
function markLocalOrderSynced(_x40, _x41) {
|
|
5272
5264
|
return _markLocalOrderSynced.apply(this, arguments);
|
|
5273
5265
|
}
|
|
5274
5266
|
return markLocalOrderSynced;
|
|
@@ -5311,10 +5303,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5311
5303
|
value: function extractSubmitErrorResponse(error) {
|
|
5312
5304
|
var _error$response,
|
|
5313
5305
|
_error$response2,
|
|
5314
|
-
|
|
5306
|
+
_this31 = this;
|
|
5315
5307
|
var candidates = [error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.body, error === null || error === void 0 ? void 0 : error.body];
|
|
5316
5308
|
return candidates.find(function (candidate) {
|
|
5317
|
-
return
|
|
5309
|
+
return _this31.isSubmitErrorResponse(candidate);
|
|
5318
5310
|
}) || null;
|
|
5319
5311
|
}
|
|
5320
5312
|
}, {
|
|
@@ -5341,33 +5333,33 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5341
5333
|
}, {
|
|
5342
5334
|
key: "syncPaymentsToOrder",
|
|
5343
5335
|
value: function () {
|
|
5344
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5345
|
-
var
|
|
5336
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
5337
|
+
var _this32 = this,
|
|
5346
5338
|
_params$confirmPendin;
|
|
5347
5339
|
var tempOrder, needsPaymentNumber, devicePrefix, mappedPayments, shouldConfirmPendingVoucherPayments, effectivePayments, completion, orderPaidPaymentTotal, paymentStatus, paymentSyncIdempotencyToken, submitParams, submitResult;
|
|
5348
|
-
return _regeneratorRuntime().wrap(function
|
|
5349
|
-
while (1) switch (
|
|
5340
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context37) {
|
|
5341
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
5350
5342
|
case 0:
|
|
5351
5343
|
tempOrder = this.ensureTempOrder();
|
|
5352
5344
|
needsPaymentNumber = (params.payments || []).some(function (payment) {
|
|
5353
5345
|
return String(payment.payment_number || '').trim() === '';
|
|
5354
5346
|
});
|
|
5355
5347
|
if (!needsPaymentNumber) {
|
|
5356
|
-
|
|
5348
|
+
_context37.next = 8;
|
|
5357
5349
|
break;
|
|
5358
5350
|
}
|
|
5359
|
-
|
|
5351
|
+
_context37.next = 5;
|
|
5360
5352
|
return this.getPaymentNumberDevicePrefixAsync();
|
|
5361
5353
|
case 5:
|
|
5362
|
-
|
|
5363
|
-
|
|
5354
|
+
_context37.t0 = _context37.sent;
|
|
5355
|
+
_context37.next = 9;
|
|
5364
5356
|
break;
|
|
5365
5357
|
case 8:
|
|
5366
|
-
|
|
5358
|
+
_context37.t0 = 'LOCAL';
|
|
5367
5359
|
case 9:
|
|
5368
|
-
devicePrefix =
|
|
5360
|
+
devicePrefix = _context37.t0;
|
|
5369
5361
|
mappedPayments = mapPaymentItemsToOrderPayments((params.payments || []).map(function (payment) {
|
|
5370
|
-
return
|
|
5362
|
+
return _this32.normalizePaymentSource(payment, {
|
|
5371
5363
|
defaultPaid: false,
|
|
5372
5364
|
devicePrefix: devicePrefix
|
|
5373
5365
|
});
|
|
@@ -5380,20 +5372,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5380
5372
|
tempOrder.payments = effectivePayments;
|
|
5381
5373
|
tempOrder.payment_status = paymentStatus;
|
|
5382
5374
|
this.persistTempOrder();
|
|
5383
|
-
|
|
5375
|
+
_context37.next = 21;
|
|
5384
5376
|
return this.saveDraft();
|
|
5385
5377
|
case 21:
|
|
5386
5378
|
if (params.submitWhenPaid) {
|
|
5387
|
-
|
|
5379
|
+
_context37.next = 23;
|
|
5388
5380
|
break;
|
|
5389
5381
|
}
|
|
5390
|
-
return
|
|
5382
|
+
return _context37.abrupt("return", completion);
|
|
5391
5383
|
case 23:
|
|
5392
5384
|
if (!(this.store.syncState === 'submitting')) {
|
|
5393
|
-
|
|
5385
|
+
_context37.next = 25;
|
|
5394
5386
|
break;
|
|
5395
5387
|
}
|
|
5396
|
-
return
|
|
5388
|
+
return _context37.abrupt("return", completion);
|
|
5397
5389
|
case 25:
|
|
5398
5390
|
this.store.syncState = 'submitting';
|
|
5399
5391
|
paymentSyncIdempotencyToken = this.buildPaymentSyncIdempotencyToken(tempOrder, effectivePayments);
|
|
@@ -5412,32 +5404,32 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5412
5404
|
}
|
|
5413
5405
|
};
|
|
5414
5406
|
if (!(params.checkoutSyncTaskEnabled === false)) {
|
|
5415
|
-
|
|
5407
|
+
_context37.next = 34;
|
|
5416
5408
|
break;
|
|
5417
5409
|
}
|
|
5418
|
-
|
|
5410
|
+
_context37.next = 31;
|
|
5419
5411
|
return this.submitTempOrderAsync(submitParams);
|
|
5420
5412
|
case 31:
|
|
5421
|
-
|
|
5422
|
-
|
|
5413
|
+
_context37.t1 = _context37.sent;
|
|
5414
|
+
_context37.next = 37;
|
|
5423
5415
|
break;
|
|
5424
5416
|
case 34:
|
|
5425
|
-
|
|
5417
|
+
_context37.next = 36;
|
|
5426
5418
|
return this.submitTempOrder(submitParams);
|
|
5427
5419
|
case 36:
|
|
5428
|
-
|
|
5420
|
+
_context37.t1 = _context37.sent;
|
|
5429
5421
|
case 37:
|
|
5430
|
-
submitResult =
|
|
5431
|
-
return
|
|
5422
|
+
submitResult = _context37.t1;
|
|
5423
|
+
return _context37.abrupt("return", _objectSpread(_objectSpread({}, completion), {}, {
|
|
5432
5424
|
submitResult: submitResult
|
|
5433
5425
|
}));
|
|
5434
5426
|
case 39:
|
|
5435
5427
|
case "end":
|
|
5436
|
-
return
|
|
5428
|
+
return _context37.stop();
|
|
5437
5429
|
}
|
|
5438
|
-
},
|
|
5430
|
+
}, _callee34, this);
|
|
5439
5431
|
}));
|
|
5440
|
-
function syncPaymentsToOrder(
|
|
5432
|
+
function syncPaymentsToOrder(_x42) {
|
|
5441
5433
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
5442
5434
|
}
|
|
5443
5435
|
return syncPaymentsToOrder;
|
|
@@ -5445,7 +5437,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5445
5437
|
}, {
|
|
5446
5438
|
key: "createOrder",
|
|
5447
5439
|
value: function createOrder(params) {
|
|
5448
|
-
var
|
|
5440
|
+
var _this33 = this;
|
|
5449
5441
|
var order = _objectSpread({
|
|
5450
5442
|
type: (params === null || params === void 0 ? void 0 : params.type) || 'appointment_booking',
|
|
5451
5443
|
// 要从外面拿,virtual
|
|
@@ -5477,7 +5469,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5477
5469
|
|
|
5478
5470
|
// 为预约补齐 holder 信息
|
|
5479
5471
|
if (params !== null && params !== void 0 && (_params$extraData = params.extraData) !== null && _params$extraData !== void 0 && _params$extraData.is_add_holder_info) {
|
|
5480
|
-
ensureCartItemOriginHolder(item,
|
|
5472
|
+
ensureCartItemOriginHolder(item, _this33.window);
|
|
5481
5473
|
}
|
|
5482
5474
|
|
|
5483
5475
|
// 购物车是否为普通商品
|
|
@@ -5534,11 +5526,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5534
5526
|
}, {
|
|
5535
5527
|
key: "submitOrder",
|
|
5536
5528
|
value: function () {
|
|
5537
|
-
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5529
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(order) {
|
|
5538
5530
|
var _order$query$cartItem, _params$bookings, _params$relation_prod;
|
|
5539
5531
|
var url, query, fetchUrl, params;
|
|
5540
|
-
return _regeneratorRuntime().wrap(function
|
|
5541
|
-
while (1) switch (
|
|
5532
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context38) {
|
|
5533
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
5542
5534
|
case 0:
|
|
5543
5535
|
this.logInfo('submitOrder called', {
|
|
5544
5536
|
url: order.url,
|
|
@@ -5558,14 +5550,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5558
5550
|
relationProductsCount: ((_params$relation_prod = params.relation_products) === null || _params$relation_prod === void 0 ? void 0 : _params$relation_prod.length) || 0,
|
|
5559
5551
|
scheduleDate: params.schedule_date
|
|
5560
5552
|
});
|
|
5561
|
-
return
|
|
5553
|
+
return _context38.abrupt("return", this.request.post(fetchUrl, params));
|
|
5562
5554
|
case 6:
|
|
5563
5555
|
case "end":
|
|
5564
|
-
return
|
|
5556
|
+
return _context38.stop();
|
|
5565
5557
|
}
|
|
5566
|
-
},
|
|
5558
|
+
}, _callee35, this);
|
|
5567
5559
|
}));
|
|
5568
|
-
function submitOrder(
|
|
5560
|
+
function submitOrder(_x43) {
|
|
5569
5561
|
return _submitOrder.apply(this, arguments);
|
|
5570
5562
|
}
|
|
5571
5563
|
return submitOrder;
|
|
@@ -5573,13 +5565,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5573
5565
|
}, {
|
|
5574
5566
|
key: "cancelOrder",
|
|
5575
5567
|
value: function () {
|
|
5576
|
-
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5568
|
+
var _cancelOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
|
|
5577
5569
|
var payload;
|
|
5578
|
-
return _regeneratorRuntime().wrap(function
|
|
5579
|
-
while (1) switch (
|
|
5570
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context39) {
|
|
5571
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
5580
5572
|
case 0:
|
|
5581
5573
|
if (!(!Array.isArray(params.order_ids) || params.order_ids.length === 0)) {
|
|
5582
|
-
|
|
5574
|
+
_context39.next = 2;
|
|
5583
5575
|
break;
|
|
5584
5576
|
}
|
|
5585
5577
|
throw new Error('取消订单失败:order_ids 不能为空');
|
|
@@ -5595,16 +5587,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5595
5587
|
method: 'PUT',
|
|
5596
5588
|
orderIdsCount: params.order_ids.length
|
|
5597
5589
|
});
|
|
5598
|
-
return
|
|
5590
|
+
return _context39.abrupt("return", this.request.put('/order/update-status', payload, {
|
|
5599
5591
|
isShopApi: true
|
|
5600
5592
|
}));
|
|
5601
5593
|
case 5:
|
|
5602
5594
|
case "end":
|
|
5603
|
-
return
|
|
5595
|
+
return _context39.stop();
|
|
5604
5596
|
}
|
|
5605
|
-
},
|
|
5597
|
+
}, _callee36, this);
|
|
5606
5598
|
}));
|
|
5607
|
-
function cancelOrder(
|
|
5599
|
+
function cancelOrder(_x44) {
|
|
5608
5600
|
return _cancelOrder.apply(this, arguments);
|
|
5609
5601
|
}
|
|
5610
5602
|
return cancelOrder;
|
|
@@ -5612,19 +5604,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5612
5604
|
}, {
|
|
5613
5605
|
key: "changeBookingStatus",
|
|
5614
5606
|
value: function () {
|
|
5615
|
-
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5607
|
+
var _changeBookingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(params) {
|
|
5616
5608
|
var url, payload;
|
|
5617
|
-
return _regeneratorRuntime().wrap(function
|
|
5618
|
-
while (1) switch (
|
|
5609
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context40) {
|
|
5610
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
5619
5611
|
case 0:
|
|
5620
5612
|
if (params.booking_id) {
|
|
5621
|
-
|
|
5613
|
+
_context40.next = 2;
|
|
5622
5614
|
break;
|
|
5623
5615
|
}
|
|
5624
5616
|
throw new Error('变更预约状态失败:booking_id 不能为空');
|
|
5625
5617
|
case 2:
|
|
5626
5618
|
if (params.appointment_status) {
|
|
5627
|
-
|
|
5619
|
+
_context40.next = 4;
|
|
5628
5620
|
break;
|
|
5629
5621
|
}
|
|
5630
5622
|
throw new Error('变更预约状态失败:appointment_status 不能为空');
|
|
@@ -5639,16 +5631,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5639
5631
|
bookingId: params.booking_id,
|
|
5640
5632
|
appointmentStatus: params.appointment_status
|
|
5641
5633
|
});
|
|
5642
|
-
return
|
|
5634
|
+
return _context40.abrupt("return", this.request.put(url, payload, {
|
|
5643
5635
|
isShopApi: true
|
|
5644
5636
|
}));
|
|
5645
5637
|
case 8:
|
|
5646
5638
|
case "end":
|
|
5647
|
-
return
|
|
5639
|
+
return _context40.stop();
|
|
5648
5640
|
}
|
|
5649
|
-
},
|
|
5641
|
+
}, _callee37, this);
|
|
5650
5642
|
}));
|
|
5651
|
-
function changeBookingStatus(
|
|
5643
|
+
function changeBookingStatus(_x45) {
|
|
5652
5644
|
return _changeBookingStatus.apply(this, arguments);
|
|
5653
5645
|
}
|
|
5654
5646
|
return changeBookingStatus;
|
|
@@ -5666,11 +5658,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5666
5658
|
}, {
|
|
5667
5659
|
key: "createOrderByCheckout",
|
|
5668
5660
|
value: (function () {
|
|
5669
|
-
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5661
|
+
var _createOrderByCheckout = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(params) {
|
|
5670
5662
|
var _params$payments, _params$bookings2, _params$relation_prod2, _params$payments2, _params$payments3, _params$bookings3, _params$relation_prod3, _params$payments4;
|
|
5671
5663
|
var onlineStorePaymentCodeList, _orderData$payments, _orderData$bookings, _orderData$relation_p, _orderData$payments2, _orderData$payments3, _orderData$bookings2, _orderData$relation_p2, _orderData$payments4, _orderData$payments5, _response$data, orderData, response;
|
|
5672
|
-
return _regeneratorRuntime().wrap(function
|
|
5673
|
-
while (1) switch (
|
|
5664
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context41) {
|
|
5665
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
5674
5666
|
case 0:
|
|
5675
5667
|
// 过滤掉由在线店铺下单的 payment 支付数据
|
|
5676
5668
|
onlineStorePaymentCodeList = ['WXPAY', 'WECHAT', 'ALIPAY', 'APPLE_PAY', 'CREDIT_CARD_3DS', 'CREDIT_CARD_TOKEN', 'GOOGLE_PAY', 'GOOGLE_PAY_3DS', 'CREDIT_CARD'];
|
|
@@ -5704,7 +5696,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5704
5696
|
relationProductsCount: ((_params$relation_prod3 = params.relation_products) === null || _params$relation_prod3 === void 0 ? void 0 : _params$relation_prod3.length) || 0,
|
|
5705
5697
|
paymentsCount: ((_params$payments4 = params.payments) === null || _params$payments4 === void 0 ? void 0 : _params$payments4.length) || 0
|
|
5706
5698
|
});
|
|
5707
|
-
|
|
5699
|
+
_context41.prev = 4;
|
|
5708
5700
|
// 构建订单数据,设置默认值并允许 params 覆盖
|
|
5709
5701
|
orderData = _objectSpread({
|
|
5710
5702
|
sales_channel: 'my_pisel',
|
|
@@ -5766,13 +5758,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5766
5758
|
hasOrderId: !!orderData.order_id,
|
|
5767
5759
|
smallTicketDataFlag: orderData.small_ticket_data_flag
|
|
5768
5760
|
});
|
|
5769
|
-
|
|
5761
|
+
_context41.next = 12;
|
|
5770
5762
|
return this.request.post('/order/checkout', orderData, {
|
|
5771
5763
|
osServer: true,
|
|
5772
5764
|
customToast: function customToast() {}
|
|
5773
5765
|
});
|
|
5774
5766
|
case 12:
|
|
5775
|
-
response =
|
|
5767
|
+
response = _context41.sent;
|
|
5776
5768
|
this.logInfo('Order API called successfully', {
|
|
5777
5769
|
response: response
|
|
5778
5770
|
});
|
|
@@ -5780,22 +5772,22 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5780
5772
|
success: !!response,
|
|
5781
5773
|
hasOrderId: !!(response !== null && response !== void 0 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data.order_id || response !== null && response !== void 0 && response.order_id)
|
|
5782
5774
|
});
|
|
5783
|
-
return
|
|
5775
|
+
return _context41.abrupt("return", response);
|
|
5784
5776
|
case 18:
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
console.error('[Order] createOrderByCheckout 创建订单失败:',
|
|
5777
|
+
_context41.prev = 18;
|
|
5778
|
+
_context41.t0 = _context41["catch"](4);
|
|
5779
|
+
console.error('[Order] createOrderByCheckout 创建订单失败:', _context41.t0);
|
|
5788
5780
|
this.logInfo('Order API called failed', {
|
|
5789
|
-
error:
|
|
5781
|
+
error: _context41.t0 instanceof Error ? _context41.t0.message : String(_context41.t0)
|
|
5790
5782
|
});
|
|
5791
|
-
throw
|
|
5783
|
+
throw _context41.t0;
|
|
5792
5784
|
case 23:
|
|
5793
5785
|
case "end":
|
|
5794
|
-
return
|
|
5786
|
+
return _context41.stop();
|
|
5795
5787
|
}
|
|
5796
|
-
},
|
|
5788
|
+
}, _callee38, this, [[4, 18]]);
|
|
5797
5789
|
}));
|
|
5798
|
-
function createOrderByCheckout(
|
|
5790
|
+
function createOrderByCheckout(_x46) {
|
|
5799
5791
|
return _createOrderByCheckout.apply(this, arguments);
|
|
5800
5792
|
}
|
|
5801
5793
|
return createOrderByCheckout;
|
|
@@ -5803,24 +5795,24 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5803
5795
|
}, {
|
|
5804
5796
|
key: "submitSalesOrder",
|
|
5805
5797
|
value: function () {
|
|
5806
|
-
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5798
|
+
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
|
|
5807
5799
|
var url, query, fetchUrl;
|
|
5808
|
-
return _regeneratorRuntime().wrap(function
|
|
5809
|
-
while (1) switch (
|
|
5800
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context42) {
|
|
5801
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
5810
5802
|
case 0:
|
|
5811
5803
|
url = params.url, query = params.query;
|
|
5812
5804
|
fetchUrl = url || '/order/sales/checkout';
|
|
5813
|
-
return
|
|
5805
|
+
return _context42.abrupt("return", this.request.post(fetchUrl, query, {
|
|
5814
5806
|
osServer: true,
|
|
5815
5807
|
customToast: function customToast() {}
|
|
5816
5808
|
}));
|
|
5817
5809
|
case 3:
|
|
5818
5810
|
case "end":
|
|
5819
|
-
return
|
|
5811
|
+
return _context42.stop();
|
|
5820
5812
|
}
|
|
5821
|
-
},
|
|
5813
|
+
}, _callee39, this);
|
|
5822
5814
|
}));
|
|
5823
|
-
function submitSalesOrder(
|
|
5815
|
+
function submitSalesOrder(_x47) {
|
|
5824
5816
|
return _submitSalesOrder.apply(this, arguments);
|
|
5825
5817
|
}
|
|
5826
5818
|
return submitSalesOrder;
|
|
@@ -5834,37 +5826,37 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5834
5826
|
}, {
|
|
5835
5827
|
key: "sendCustomerPayLink",
|
|
5836
5828
|
value: (function () {
|
|
5837
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5829
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
|
|
5838
5830
|
var _params$emails;
|
|
5839
5831
|
var orderIds;
|
|
5840
|
-
return _regeneratorRuntime().wrap(function
|
|
5841
|
-
while (1) switch (
|
|
5832
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context43) {
|
|
5833
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
5842
5834
|
case 0:
|
|
5843
5835
|
orderIds = params.order_ids || params.orderIds || [];
|
|
5844
5836
|
if (orderIds.length) {
|
|
5845
|
-
|
|
5837
|
+
_context43.next = 3;
|
|
5846
5838
|
break;
|
|
5847
5839
|
}
|
|
5848
5840
|
throw new Error('发送支付链接前必须先提交本地订单并取得订单 ID');
|
|
5849
5841
|
case 3:
|
|
5850
5842
|
if ((_params$emails = params.emails) !== null && _params$emails !== void 0 && _params$emails.length) {
|
|
5851
|
-
|
|
5843
|
+
_context43.next = 5;
|
|
5852
5844
|
break;
|
|
5853
5845
|
}
|
|
5854
5846
|
throw new Error('发送支付链接需要至少一个邮箱');
|
|
5855
5847
|
case 5:
|
|
5856
|
-
return
|
|
5848
|
+
return _context43.abrupt("return", this.request.post('/order/batch-email', {
|
|
5857
5849
|
order_ids: orderIds,
|
|
5858
5850
|
notify_action: params.notify_action || 'order_payment_reminder',
|
|
5859
5851
|
emails: params.emails
|
|
5860
5852
|
}));
|
|
5861
5853
|
case 6:
|
|
5862
5854
|
case "end":
|
|
5863
|
-
return
|
|
5855
|
+
return _context43.stop();
|
|
5864
5856
|
}
|
|
5865
|
-
},
|
|
5857
|
+
}, _callee40, this);
|
|
5866
5858
|
}));
|
|
5867
|
-
function sendCustomerPayLink(
|
|
5859
|
+
function sendCustomerPayLink(_x48) {
|
|
5868
5860
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
5869
5861
|
}
|
|
5870
5862
|
return sendCustomerPayLink;
|
|
@@ -5872,14 +5864,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5872
5864
|
}, {
|
|
5873
5865
|
key: "getSalesOrderByLookup",
|
|
5874
5866
|
value: function () {
|
|
5875
|
-
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5867
|
+
var _getSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
|
|
5876
5868
|
var lookup, res;
|
|
5877
|
-
return _regeneratorRuntime().wrap(function
|
|
5878
|
-
while (1) switch (
|
|
5869
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context44) {
|
|
5870
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
5879
5871
|
case 0:
|
|
5880
5872
|
lookup = params.lookup === undefined || params.lookup === null ? '' : String(params.lookup).trim();
|
|
5881
5873
|
if (lookup) {
|
|
5882
|
-
|
|
5874
|
+
_context44.next = 3;
|
|
5883
5875
|
break;
|
|
5884
5876
|
}
|
|
5885
5877
|
throw new Error('加载销售详情需要 lookup');
|
|
@@ -5888,7 +5880,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5888
5880
|
if (lookup.startsWith('LOCAL_')) {
|
|
5889
5881
|
params.forceRemote = false;
|
|
5890
5882
|
}
|
|
5891
|
-
|
|
5883
|
+
_context44.next = 6;
|
|
5892
5884
|
return this.request.get("/order/sales/".concat(encodeURIComponent(lookup)), _objectSpread({
|
|
5893
5885
|
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info', 'refunds']
|
|
5894
5886
|
}, params.forceRemote ? {
|
|
@@ -5897,18 +5889,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5897
5889
|
osServer: true
|
|
5898
5890
|
});
|
|
5899
5891
|
case 6:
|
|
5900
|
-
res =
|
|
5892
|
+
res = _context44.sent;
|
|
5901
5893
|
if (res.code === 200) {
|
|
5902
5894
|
this.store.lastOrderInfo = res.data;
|
|
5903
5895
|
}
|
|
5904
|
-
return
|
|
5896
|
+
return _context44.abrupt("return", res);
|
|
5905
5897
|
case 9:
|
|
5906
5898
|
case "end":
|
|
5907
|
-
return
|
|
5899
|
+
return _context44.stop();
|
|
5908
5900
|
}
|
|
5909
|
-
},
|
|
5901
|
+
}, _callee41, this);
|
|
5910
5902
|
}));
|
|
5911
|
-
function getSalesOrderByLookup(
|
|
5903
|
+
function getSalesOrderByLookup(_x49) {
|
|
5912
5904
|
return _getSalesOrderByLookup.apply(this, arguments);
|
|
5913
5905
|
}
|
|
5914
5906
|
return getSalesOrderByLookup;
|
|
@@ -5922,11 +5914,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5922
5914
|
}, {
|
|
5923
5915
|
key: "hydrateTempOrderFromRecord",
|
|
5924
5916
|
value: (function () {
|
|
5925
|
-
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5917
|
+
var _hydrateTempOrderFromRecord = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(record, options) {
|
|
5926
5918
|
var _this$store$discount20;
|
|
5927
5919
|
var sourceRaw, identityReadySource, normalizedCollections, raw, hasIdentityChanges, identityLogMetadata, hasIdentityWarnings, nextTempOrder, sourceLastOrderInfo, isDraftOrder, syntheticIdentityOptions, rawSummary, summarySurcharges, hadSyntheticDraftOrderId, hydratedEditDiscounts, currentDiscounts, currentScanDiscounts, hydratedDiscountIds, retainedScanDiscounts, nextDiscounts, shouldSkipEmptyDiscountSync, _this$store$discount21, _this$store$discount22;
|
|
5928
|
-
return _regeneratorRuntime().wrap(function
|
|
5929
|
-
while (1) switch (
|
|
5920
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context45) {
|
|
5921
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
5930
5922
|
case 0:
|
|
5931
5923
|
sourceRaw = record && _typeof(record) === 'object' && record.data && record.order_id == null ? record.data : record || {};
|
|
5932
5924
|
identityReadySource = this.seedAnonymousBookingUidsFromProducts(sourceRaw);
|
|
@@ -5996,34 +5988,34 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5996
5988
|
nextDiscounts = [].concat(_toConsumableArray(hydratedEditDiscounts), _toConsumableArray(retainedScanDiscounts));
|
|
5997
5989
|
shouldSkipEmptyDiscountSync = nextDiscounts.length === 0 && currentDiscounts.length === 0;
|
|
5998
5990
|
if (shouldSkipEmptyDiscountSync) {
|
|
5999
|
-
|
|
5991
|
+
_context45.next = 31;
|
|
6000
5992
|
break;
|
|
6001
5993
|
}
|
|
6002
5994
|
OrderModule.populateSavedAmounts(nextTempOrder.products, nextDiscounts);
|
|
6003
|
-
|
|
5995
|
+
_context45.next = 29;
|
|
6004
5996
|
return (_this$store$discount21 = this.store.discount) === null || _this$store$discount21 === void 0 ? void 0 : _this$store$discount21.setOriginalDiscountList(nextDiscounts);
|
|
6005
5997
|
case 29:
|
|
6006
|
-
|
|
5998
|
+
_context45.next = 31;
|
|
6007
5999
|
return (_this$store$discount22 = this.store.discount) === null || _this$store$discount22 === void 0 ? void 0 : _this$store$discount22.setDiscountList(nextDiscounts);
|
|
6008
6000
|
case 31:
|
|
6009
6001
|
if (!(options !== null && options !== void 0 && options.recalcOnHydrate)) {
|
|
6010
|
-
|
|
6002
|
+
_context45.next = 34;
|
|
6011
6003
|
break;
|
|
6012
6004
|
}
|
|
6013
|
-
|
|
6005
|
+
_context45.next = 34;
|
|
6014
6006
|
return this.recalculateSummary({
|
|
6015
6007
|
createIfMissing: false
|
|
6016
6008
|
});
|
|
6017
6009
|
case 34:
|
|
6018
6010
|
this.persistTempOrder();
|
|
6019
|
-
return
|
|
6011
|
+
return _context45.abrupt("return", nextTempOrder);
|
|
6020
6012
|
case 36:
|
|
6021
6013
|
case "end":
|
|
6022
|
-
return
|
|
6014
|
+
return _context45.stop();
|
|
6023
6015
|
}
|
|
6024
|
-
},
|
|
6016
|
+
}, _callee42, this);
|
|
6025
6017
|
}));
|
|
6026
|
-
function hydrateTempOrderFromRecord(
|
|
6018
|
+
function hydrateTempOrderFromRecord(_x50, _x51) {
|
|
6027
6019
|
return _hydrateTempOrderFromRecord.apply(this, arguments);
|
|
6028
6020
|
}
|
|
6029
6021
|
return hydrateTempOrderFromRecord;
|
|
@@ -6137,7 +6129,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6137
6129
|
}, {
|
|
6138
6130
|
key: "normalizeTempOrderForRuntime",
|
|
6139
6131
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
6140
|
-
var
|
|
6132
|
+
var _this34 = this;
|
|
6141
6133
|
var runtimeRaw = this.withoutSyntheticDraftOrderIdForRuntime(raw);
|
|
6142
6134
|
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), runtimeRaw || {});
|
|
6143
6135
|
// ES 列表详情使用 id 表示订单主键;OS 详情态统一依赖 order_id 驱动操作按钮。
|
|
@@ -6161,12 +6153,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6161
6153
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
6162
6154
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
6163
6155
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
6164
|
-
return
|
|
6156
|
+
return _this34.normalizeHydratedOrderProduct(p, {
|
|
6165
6157
|
makeEditMark: options === null || options === void 0 ? void 0 : options.makeEditMark
|
|
6166
6158
|
});
|
|
6167
6159
|
}) : [];
|
|
6168
6160
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
6169
|
-
var booking =
|
|
6161
|
+
var booking = _this34.normalizeHydratedBookingHolder(b || {});
|
|
6170
6162
|
return _objectSpread(_objectSpread({}, booking), {}, {
|
|
6171
6163
|
is_all: normalizeBookingIsAll(booking),
|
|
6172
6164
|
sub_type: normalizeBookingSubType(booking)
|
|
@@ -6196,7 +6188,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6196
6188
|
_step24;
|
|
6197
6189
|
try {
|
|
6198
6190
|
for (_iterator24.s(); !(_step24 = _iterator24.n()).done;) {
|
|
6199
|
-
var _product$metadata11,
|
|
6191
|
+
var _product$metadata11, _ref75, _ref76, _existed$origin, _rawProduct$metadata;
|
|
6200
6192
|
var _step24$value = _slicedToArray(_step24.value, 2),
|
|
6201
6193
|
index = _step24$value[0],
|
|
6202
6194
|
product = _step24$value[1];
|
|
@@ -6204,7 +6196,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6204
6196
|
if (!uid) continue;
|
|
6205
6197
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
6206
6198
|
var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
|
|
6207
|
-
var origin = (
|
|
6199
|
+
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;
|
|
6208
6200
|
var originSnapshot = cloneDeep(origin);
|
|
6209
6201
|
var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
|
|
6210
6202
|
if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
|
|
@@ -6333,10 +6325,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6333
6325
|
}, {
|
|
6334
6326
|
key: "normalizeHydratedProductOptionItem",
|
|
6335
6327
|
value: function normalizeHydratedProductOptionItem(optionItem) {
|
|
6336
|
-
var
|
|
6337
|
-
var rawNum = (
|
|
6328
|
+
var _ref77, _optionItem$num, _ref78, _optionItem$add_price;
|
|
6329
|
+
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;
|
|
6338
6330
|
var parsedNum = Number(rawNum);
|
|
6339
|
-
var rawPrice = (
|
|
6331
|
+
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;
|
|
6340
6332
|
var parsedPrice = Number(rawPrice);
|
|
6341
6333
|
var normalized = _objectSpread(_objectSpread({}, optionItem), {}, {
|
|
6342
6334
|
option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
|
|
@@ -6353,7 +6345,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6353
6345
|
}, {
|
|
6354
6346
|
key: "normalizeHydratedOrderProduct",
|
|
6355
6347
|
value: function normalizeHydratedOrderProduct(product, options) {
|
|
6356
|
-
var
|
|
6348
|
+
var _this35 = this;
|
|
6357
6349
|
var row = _objectSpread({}, product || {});
|
|
6358
6350
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
6359
6351
|
row.num = row.product_quantity;
|
|
@@ -6361,7 +6353,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6361
6353
|
var productSku = ensureProductSku(row);
|
|
6362
6354
|
row.product_sku = _objectSpread(_objectSpread({}, productSku), {}, {
|
|
6363
6355
|
option: normalizeProductSkuOptions(productSku.option.map(function (optionItem) {
|
|
6364
|
-
return
|
|
6356
|
+
return _this35.normalizeHydratedProductOptionItem(optionItem || {});
|
|
6365
6357
|
}))
|
|
6366
6358
|
});
|
|
6367
6359
|
delete row["product_".concat('option', "_item")];
|
|
@@ -6398,27 +6390,27 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6398
6390
|
}, {
|
|
6399
6391
|
key: "getOrderInfo",
|
|
6400
6392
|
value: function () {
|
|
6401
|
-
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6393
|
+
var _getOrderInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(order_id) {
|
|
6402
6394
|
var res;
|
|
6403
|
-
return _regeneratorRuntime().wrap(function
|
|
6404
|
-
while (1) switch (
|
|
6395
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context46) {
|
|
6396
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
6405
6397
|
case 0:
|
|
6406
|
-
|
|
6398
|
+
_context46.next = 2;
|
|
6407
6399
|
return this.request.get("/order/sales/".concat(order_id), {
|
|
6408
6400
|
with: ['products', 'bookings']
|
|
6409
6401
|
}, {
|
|
6410
6402
|
osServer: true
|
|
6411
6403
|
});
|
|
6412
6404
|
case 2:
|
|
6413
|
-
res =
|
|
6414
|
-
return
|
|
6405
|
+
res = _context46.sent;
|
|
6406
|
+
return _context46.abrupt("return", res);
|
|
6415
6407
|
case 4:
|
|
6416
6408
|
case "end":
|
|
6417
|
-
return
|
|
6409
|
+
return _context46.stop();
|
|
6418
6410
|
}
|
|
6419
|
-
},
|
|
6411
|
+
}, _callee43, this);
|
|
6420
6412
|
}));
|
|
6421
|
-
function getOrderInfo(
|
|
6413
|
+
function getOrderInfo(_x52) {
|
|
6422
6414
|
return _getOrderInfo.apply(this, arguments);
|
|
6423
6415
|
}
|
|
6424
6416
|
return getOrderInfo;
|
|
@@ -6477,10 +6469,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
6477
6469
|
_step29;
|
|
6478
6470
|
try {
|
|
6479
6471
|
for (_iterator29.s(); !(_step29 = _iterator29.n()).done;) {
|
|
6480
|
-
var _ref80, _bundle$num3;
|
|
6481
6472
|
var bundle = _step29.value;
|
|
6482
6473
|
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));
|
|
6483
|
-
var bundleQty =
|
|
6474
|
+
var bundleQty = Number(qty) || 1;
|
|
6484
6475
|
var _iterator30 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
|
|
6485
6476
|
_step30;
|
|
6486
6477
|
try {
|