@pisell/pisellos 2.2.187 → 2.2.189
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +11 -4
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +11 -4
- package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
- package/dist/modules/BookingContext/utils/orderLineDisplay.js +36 -0
- package/dist/modules/Order/index.d.ts +5 -0
- package/dist/modules/Order/index.js +174 -70
- package/dist/modules/Order/types.d.ts +1 -0
- package/dist/modules/Order/utils.js +3 -1
- package/dist/modules/Rules/index.js +32 -21
- package/dist/solution/BaseSales/utils/cartPromotion.js +31 -11
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +15 -0
- package/dist/solution/BookingTicket/index.js +135 -10
- package/dist/solution/BookingTicket/types.d.ts +48 -0
- package/dist/solution/BookingTicket/types.js +5 -1
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +394 -0
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
- package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +56 -0
- package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
- package/dist/solution/BookingTicket/utils/scan/scanProductValues.js +150 -0
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -1
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +4 -0
- package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
- package/lib/modules/BookingContext/utils/orderLineDisplay.js +56 -0
- package/lib/modules/Order/index.d.ts +5 -0
- package/lib/modules/Order/index.js +99 -14
- package/lib/modules/Order/types.d.ts +1 -0
- package/lib/modules/Order/utils.js +1 -0
- package/lib/modules/Rules/index.js +88 -78
- package/lib/solution/BaseSales/utils/cartPromotion.js +22 -1
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +15 -0
- package/lib/solution/BookingTicket/index.js +75 -2
- package/lib/solution/BookingTicket/types.d.ts +48 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +166 -0
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
- package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +51 -0
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
- package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +127 -0
- package/package.json +1 -1
|
@@ -1121,15 +1121,21 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1121
1121
|
var _ref3, _ref4, _ref5, _result$data$order_id, _result$data, _result$data2;
|
|
1122
1122
|
return (_ref3 = (_ref4 = (_ref5 = (_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 && _ref5 !== void 0 ? _ref5 : result === null || result === void 0 || (_result$data2 = result.data) === null || _result$data2 === void 0 ? void 0 : _result$data2.id) !== null && _ref4 !== void 0 ? _ref4 : result === null || result === void 0 ? void 0 : result.id) !== null && _ref3 !== void 0 ? _ref3 : null;
|
|
1123
1123
|
}
|
|
1124
|
+
}, {
|
|
1125
|
+
key: "calculatePaymentEffectiveAmount",
|
|
1126
|
+
value: function calculatePaymentEffectiveAmount(payment) {
|
|
1127
|
+
var amount = new Decimal(payment.amount || 0).minus(new Decimal(payment.service_fee || 0));
|
|
1128
|
+
var rounding = new Decimal(payment.rounding_amount || 0);
|
|
1129
|
+
return amount.minus(rounding);
|
|
1130
|
+
}
|
|
1124
1131
|
}, {
|
|
1125
1132
|
key: "calculatePaymentTotal",
|
|
1126
1133
|
value: function calculatePaymentTotal(payments) {
|
|
1134
|
+
var _this3 = this;
|
|
1127
1135
|
return mapPaymentItemsToOrderPayments(payments, {
|
|
1128
1136
|
includeVoided: false
|
|
1129
1137
|
}).reduce(function (sum, payment) {
|
|
1130
|
-
|
|
1131
|
-
var rounding = new Decimal(payment.rounding_amount || 0);
|
|
1132
|
-
return sum.plus(amount.minus(rounding));
|
|
1138
|
+
return sum.plus(_this3.calculatePaymentEffectiveAmount(payment));
|
|
1133
1139
|
}, new Decimal(0));
|
|
1134
1140
|
}
|
|
1135
1141
|
}, {
|
|
@@ -1170,18 +1176,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1170
1176
|
}, {
|
|
1171
1177
|
key: "calculatePaidPaymentSummary",
|
|
1172
1178
|
value: function calculatePaidPaymentSummary(payments) {
|
|
1173
|
-
var
|
|
1179
|
+
var _this4 = this;
|
|
1174
1180
|
return (payments || []).reduce(function (summary, payment) {
|
|
1175
1181
|
var paymentRecord = payment;
|
|
1176
1182
|
if ((paymentRecord === null || paymentRecord === void 0 ? void 0 : paymentRecord.status) !== 'paid') return summary;
|
|
1177
1183
|
return {
|
|
1178
1184
|
customerPaidAmount: summary.customerPaidAmount.plus(paymentRecord.amount || 0),
|
|
1179
1185
|
orderPaidAmount: summary.orderPaidAmount.plus(paymentRecord.origin_amount || 0),
|
|
1180
|
-
|
|
1186
|
+
gapPaidAmount: summary.gapPaidAmount.plus(_this4.calculatePaymentEffectiveAmount(paymentRecord)),
|
|
1187
|
+
payServiceChargeAmount: summary.payServiceChargeAmount.plus(_this4.calculatePaymentServiceFee(paymentRecord))
|
|
1181
1188
|
};
|
|
1182
1189
|
}, {
|
|
1183
1190
|
customerPaidAmount: new Decimal(0),
|
|
1184
1191
|
orderPaidAmount: new Decimal(0),
|
|
1192
|
+
gapPaidAmount: new Decimal(0),
|
|
1185
1193
|
payServiceChargeAmount: new Decimal(0)
|
|
1186
1194
|
});
|
|
1187
1195
|
}
|
|
@@ -1565,9 +1573,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1565
1573
|
}, {
|
|
1566
1574
|
key: "findBookingIndexByUniqueIdentificationNumber",
|
|
1567
1575
|
value: function findBookingIndexByUniqueIdentificationNumber(tempOrder, uniqueIdentificationNumber) {
|
|
1568
|
-
var
|
|
1576
|
+
var _this5 = this;
|
|
1569
1577
|
return (tempOrder.bookings || []).findIndex(function (booking) {
|
|
1570
|
-
return
|
|
1578
|
+
return _this5.getBookingUniqueIdentificationNumber(booking) === uniqueIdentificationNumber;
|
|
1571
1579
|
});
|
|
1572
1580
|
}
|
|
1573
1581
|
}, {
|
|
@@ -1575,12 +1583,12 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1575
1583
|
value: function removeLinkedBookingsForProduct(tempOrder, product) {
|
|
1576
1584
|
var _product$metadata4,
|
|
1577
1585
|
_product$metadata5,
|
|
1578
|
-
|
|
1586
|
+
_this6 = this;
|
|
1579
1587
|
var productUid = (product === null || product === void 0 || (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4.unique_identification_number) || (product === null || product === void 0 ? void 0 : product.unique_identification_number);
|
|
1580
1588
|
var bookingUid = (product === null || product === void 0 ? void 0 : product.booking_uid) || (product === null || product === void 0 || (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.booking_uid);
|
|
1581
1589
|
if (!productUid && !bookingUid) return;
|
|
1582
1590
|
tempOrder.bookings = (tempOrder.bookings || []).filter(function (booking) {
|
|
1583
|
-
var currentBookingUid =
|
|
1591
|
+
var currentBookingUid = _this6.getBookingUniqueIdentificationNumber(booking);
|
|
1584
1592
|
if (bookingUid && currentBookingUid === String(bookingUid)) return false;
|
|
1585
1593
|
if (productUid && String((booking === null || booking === void 0 ? void 0 : booking.product_uid) || '') === String(productUid)) return false;
|
|
1586
1594
|
return true;
|
|
@@ -1623,7 +1631,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1623
1631
|
amount_gap: this.calculateSummaryAmountGap({
|
|
1624
1632
|
tempOrder: tempOrder,
|
|
1625
1633
|
summary: createEmptySummary(),
|
|
1626
|
-
orderPaidAmount: paidPaymentSummary.
|
|
1634
|
+
orderPaidAmount: paidPaymentSummary.gapPaidAmount
|
|
1627
1635
|
}),
|
|
1628
1636
|
pay_service_charge_amount: paidPaymentSummary.payServiceChargeAmount.toFixed(2)
|
|
1629
1637
|
});
|
|
@@ -1647,7 +1655,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1647
1655
|
amount_gap: this.calculateSummaryAmountGap({
|
|
1648
1656
|
tempOrder: tempOrder,
|
|
1649
1657
|
summary: salesSummaryResult,
|
|
1650
|
-
orderPaidAmount: paidPaymentSummary.
|
|
1658
|
+
orderPaidAmount: paidPaymentSummary.gapPaidAmount
|
|
1651
1659
|
}),
|
|
1652
1660
|
pay_service_charge_amount: paidPaymentSummary.payServiceChargeAmount.toFixed(2)
|
|
1653
1661
|
});
|
|
@@ -1952,7 +1960,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1952
1960
|
}, {
|
|
1953
1961
|
key: "addOrderPayment",
|
|
1954
1962
|
value: function addOrderPayment(payment) {
|
|
1955
|
-
var
|
|
1963
|
+
var _this7 = this;
|
|
1956
1964
|
this.logInfo('addOrderPayment', {
|
|
1957
1965
|
payment: payment
|
|
1958
1966
|
});
|
|
@@ -1965,7 +1973,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1965
1973
|
void this.recalculateSummary({
|
|
1966
1974
|
createIfMissing: true
|
|
1967
1975
|
}).catch(function (error) {
|
|
1968
|
-
|
|
1976
|
+
_this7.logError('recalculate summary after addOrderPayment failed', {
|
|
1969
1977
|
error: error instanceof Error ? error.message : String(error)
|
|
1970
1978
|
});
|
|
1971
1979
|
});
|
|
@@ -2030,10 +2038,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2030
2038
|
}, {
|
|
2031
2039
|
key: "updateVoucherOrderPayments",
|
|
2032
2040
|
value: function updateVoucherOrderPayments(payments) {
|
|
2033
|
-
var
|
|
2041
|
+
var _this8 = this;
|
|
2034
2042
|
var tempOrder = this.ensureTempOrder();
|
|
2035
2043
|
var mappedVouchers = mapPaymentItemsToOrderPayments(payments.map(function (payment) {
|
|
2036
|
-
return
|
|
2044
|
+
return _this8.normalizePaymentSource(payment, {
|
|
2037
2045
|
defaultPaid: false
|
|
2038
2046
|
});
|
|
2039
2047
|
})).filter(function (payment) {
|
|
@@ -2048,7 +2056,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2048
2056
|
void this.recalculateSummary({
|
|
2049
2057
|
createIfMissing: true
|
|
2050
2058
|
}).catch(function (error) {
|
|
2051
|
-
|
|
2059
|
+
_this8.logError('recalculate summary after updateVoucherOrderPayments failed', {
|
|
2052
2060
|
error: error instanceof Error ? error.message : String(error)
|
|
2053
2061
|
});
|
|
2054
2062
|
});
|
|
@@ -2104,7 +2112,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2104
2112
|
key: "addProductToOrder",
|
|
2105
2113
|
value: function () {
|
|
2106
2114
|
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(product, booking) {
|
|
2107
|
-
var
|
|
2115
|
+
var _this9 = this;
|
|
2108
2116
|
var tempOrder, linked, productToAdd, incomingFingerprint, normalizedIncoming, hasIncomingGoodPass, shouldForceNewLine, matchedIndex, matchedProduct, existedFingerprint, shouldMerge, _targetProduct$metada, targetProduct, targetUid, normalizedProduct;
|
|
2109
2117
|
return _regeneratorRuntime().wrap(function _callee16$(_context18) {
|
|
2110
2118
|
while (1) switch (_context18.prev = _context18.next) {
|
|
@@ -2122,7 +2130,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2122
2130
|
hasIncomingGoodPass = this.hasGoodPassDiscount(normalizedIncoming);
|
|
2123
2131
|
shouldForceNewLine = !!booking;
|
|
2124
2132
|
matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
2125
|
-
if (
|
|
2133
|
+
if (_this9.hasGoodPassDiscount(item)) return false;
|
|
2126
2134
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
2127
2135
|
if (item.product_variant_id !== productToAdd.product_variant_id) return false;
|
|
2128
2136
|
var existedFingerprint = buildProductLineFingerprint(item.product_option_item, item.product_bundle);
|
|
@@ -2229,8 +2237,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2229
2237
|
key: "updateOrderProduct",
|
|
2230
2238
|
value: function () {
|
|
2231
2239
|
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
|
|
2232
|
-
var _targetProduct$metada2, _metadata, _metadata2, _metadata3, _nextProduct$metadata, _targetProduct$
|
|
2233
|
-
var product_id, product_variant_id, updates, unique_identification_number, identity_key, product_option_item, product_bundle, booking, tempOrder, identityLookup, productIndex, targetUid, targetProduct, nextProduct, callerUpdatesTopPrice, callerUpdatesMainMeta, existedMeta, normalizedProduct, preservedBookingUid, _normalizedProduct$me, _targetProduct$
|
|
2240
|
+
var _targetProduct$metada2, _metadata, _metadata2, _metadata3, _metadata4, _metadata5, _metadata6, _nextProduct$metadata, _targetProduct$metada7, _tempOrder$products$p;
|
|
2241
|
+
var product_id, product_variant_id, updates, unique_identification_number, identity_key, product_option_item, product_bundle, booking, tempOrder, identityLookup, productIndex, targetUid, targetProduct, nextProduct, callerUpdatesTopPrice, callerUpdatesMainMeta, isPersistedOrderLine, callerUpdatesManualPrice, _targetProduct$metada3, _targetProduct$metada4, _targetProduct$metada5, _targetProduct$metada6, existedMeta, normalizedProduct, preservedBookingUid, _normalizedProduct$me, _targetProduct$metada8, productUid, linked;
|
|
2234
2242
|
return _regeneratorRuntime().wrap(function _callee17$(_context19) {
|
|
2235
2243
|
while (1) switch (_context19.prev = _context19.next) {
|
|
2236
2244
|
case 0:
|
|
@@ -2285,7 +2293,19 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2285
2293
|
// 如果 caller 走推荐路径(updates.metadata.* 显式指定主价),保留 metadata 由 normalize 认它。
|
|
2286
2294
|
callerUpdatesTopPrice = Object.prototype.hasOwnProperty.call(updates || {}, 'selling_price') || Object.prototype.hasOwnProperty.call(updates || {}, 'original_price');
|
|
2287
2295
|
callerUpdatesMainMeta = (updates === null || updates === void 0 || (_metadata = updates.metadata) === null || _metadata === void 0 ? void 0 : _metadata.main_product_selling_price) !== undefined || (updates === null || updates === void 0 || (_metadata2 = updates.metadata) === null || _metadata2 === void 0 ? void 0 : _metadata2.main_product_original_price) !== undefined || (updates === null || updates === void 0 || (_metadata3 = updates.metadata) === null || _metadata3 === void 0 ? void 0 : _metadata3.source_product_price) !== undefined;
|
|
2288
|
-
|
|
2296
|
+
isPersistedOrderLine = targetProduct.order_detail_id !== undefined && targetProduct.order_detail_id !== null;
|
|
2297
|
+
callerUpdatesManualPrice = (updates === null || updates === void 0 || (_metadata4 = updates.metadata) === null || _metadata4 === void 0 ? void 0 : _metadata4.price_override) !== undefined || (updates === null || updates === void 0 || (_metadata5 = updates.metadata) === null || _metadata5 === void 0 ? void 0 : _metadata5.is_manual_discount) !== undefined || (updates === null || updates === void 0 || (_metadata6 = updates.metadata) === null || _metadata6 === void 0 ? void 0 : _metadata6.product_discount_reason) !== undefined || Array.isArray(updates === null || updates === void 0 ? void 0 : updates.discount_list) && updates.discount_list.length > 0;
|
|
2298
|
+
if (isPersistedOrderLine && !callerUpdatesManualPrice) {
|
|
2299
|
+
nextProduct.selling_price = targetProduct.selling_price;
|
|
2300
|
+
nextProduct.original_price = targetProduct.original_price;
|
|
2301
|
+
nextProduct.payment_price = targetProduct.payment_price;
|
|
2302
|
+
nextProduct.metadata = _objectSpread(_objectSpread({}, nextProduct.metadata || {}), {}, {
|
|
2303
|
+
source_product_price: (_targetProduct$metada3 = targetProduct.metadata) === null || _targetProduct$metada3 === void 0 ? void 0 : _targetProduct$metada3.source_product_price,
|
|
2304
|
+
main_product_selling_price: (_targetProduct$metada4 = targetProduct.metadata) === null || _targetProduct$metada4 === void 0 ? void 0 : _targetProduct$metada4.main_product_selling_price,
|
|
2305
|
+
main_product_original_price: (_targetProduct$metada5 = targetProduct.metadata) === null || _targetProduct$metada5 === void 0 ? void 0 : _targetProduct$metada5.main_product_original_price,
|
|
2306
|
+
price_schema_version: (_targetProduct$metada6 = targetProduct.metadata) === null || _targetProduct$metada6 === void 0 ? void 0 : _targetProduct$metada6.price_schema_version
|
|
2307
|
+
});
|
|
2308
|
+
} else if (callerUpdatesTopPrice && !callerUpdatesMainMeta) {
|
|
2289
2309
|
existedMeta = nextProduct.metadata || {};
|
|
2290
2310
|
nextProduct.metadata = _objectSpread({}, existedMeta);
|
|
2291
2311
|
delete nextProduct.metadata.source_product_price;
|
|
@@ -2297,7 +2317,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2297
2317
|
// 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
|
|
2298
2318
|
normalizedProduct = mergeOrderProductDisplayFields(nextProduct, normalizeOrderProduct(nextProduct));
|
|
2299
2319
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
2300
|
-
preservedBookingUid = nextProduct.booking_uid || ((_nextProduct$metadata = nextProduct.metadata) === null || _nextProduct$metadata === void 0 ? void 0 : _nextProduct$metadata.booking_uid) || targetProduct.booking_uid || ((_targetProduct$
|
|
2320
|
+
preservedBookingUid = nextProduct.booking_uid || ((_nextProduct$metadata = nextProduct.metadata) === null || _nextProduct$metadata === void 0 ? void 0 : _nextProduct$metadata.booking_uid) || targetProduct.booking_uid || ((_targetProduct$metada7 = targetProduct.metadata) === null || _targetProduct$metada7 === void 0 ? void 0 : _targetProduct$metada7.booking_uid);
|
|
2301
2321
|
if (!booking && preservedBookingUid) {
|
|
2302
2322
|
normalizedProduct.booking_uid = preservedBookingUid;
|
|
2303
2323
|
normalizedProduct.metadata = _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
|
|
@@ -2305,7 +2325,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2305
2325
|
});
|
|
2306
2326
|
}
|
|
2307
2327
|
if (booking) {
|
|
2308
|
-
productUid = String(((_normalizedProduct$me = normalizedProduct.metadata) === null || _normalizedProduct$me === void 0 ? void 0 : _normalizedProduct$me.unique_identification_number) || ((_targetProduct$
|
|
2328
|
+
productUid = String(((_normalizedProduct$me = normalizedProduct.metadata) === null || _normalizedProduct$me === void 0 ? void 0 : _normalizedProduct$me.unique_identification_number) || ((_targetProduct$metada8 = targetProduct.metadata) === null || _targetProduct$metada8 === void 0 ? void 0 : _targetProduct$metada8.unique_identification_number) || unique_identification_number || createUuidV4());
|
|
2309
2329
|
normalizedProduct.metadata = _objectSpread(_objectSpread({}, normalizedProduct.metadata || {}), {}, {
|
|
2310
2330
|
unique_identification_number: productUid
|
|
2311
2331
|
});
|
|
@@ -2327,18 +2347,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2327
2347
|
}
|
|
2328
2348
|
tempOrder.products[productIndex] = normalizedProduct;
|
|
2329
2349
|
this.captureProductRuntime(tempOrder, updates, tempOrder.products[productIndex], (_tempOrder$products$p = tempOrder.products[productIndex].metadata) === null || _tempOrder$products$p === void 0 ? void 0 : _tempOrder$products$p.unique_identification_number);
|
|
2330
|
-
_context19.next =
|
|
2350
|
+
_context19.next = 29;
|
|
2331
2351
|
return this.applyPromotion();
|
|
2332
|
-
case
|
|
2352
|
+
case 29:
|
|
2333
2353
|
this.applyDiscount();
|
|
2334
|
-
_context19.next =
|
|
2354
|
+
_context19.next = 32;
|
|
2335
2355
|
return this.recalculateSummary({
|
|
2336
2356
|
createIfMissing: true
|
|
2337
2357
|
});
|
|
2338
|
-
case
|
|
2358
|
+
case 32:
|
|
2339
2359
|
this.persistTempOrder();
|
|
2340
2360
|
return _context19.abrupt("return", tempOrder.products);
|
|
2341
|
-
case
|
|
2361
|
+
case 34:
|
|
2342
2362
|
case "end":
|
|
2343
2363
|
return _context19.stop();
|
|
2344
2364
|
}
|
|
@@ -2353,7 +2373,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2353
2373
|
key: "updateOrderProductQuantity",
|
|
2354
2374
|
value: function () {
|
|
2355
2375
|
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params) {
|
|
2356
|
-
var _targetProduct$
|
|
2376
|
+
var _targetProduct$metada9;
|
|
2357
2377
|
var product_id, product_variant_id, num, unique_identification_number, identity_key, product_option_item, product_bundle, tempOrder, identityLookup, productIndex, targetUid, targetProduct, normalizedProduct;
|
|
2358
2378
|
return _regeneratorRuntime().wrap(function _callee18$(_context20) {
|
|
2359
2379
|
while (1) switch (_context20.prev = _context20.next) {
|
|
@@ -2394,7 +2414,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2394
2414
|
normalizedProduct = normalizeOrderProduct(_objectSpread(_objectSpread({}, targetProduct), {}, {
|
|
2395
2415
|
num: getSafeProductNum(num),
|
|
2396
2416
|
metadata: _objectSpread(_objectSpread({}, targetProduct.metadata || {}), {}, {
|
|
2397
|
-
unique_identification_number: ((_targetProduct$
|
|
2417
|
+
unique_identification_number: ((_targetProduct$metada9 = targetProduct.metadata) === null || _targetProduct$metada9 === void 0 ? void 0 : _targetProduct$metada9.unique_identification_number) || unique_identification_number
|
|
2398
2418
|
})
|
|
2399
2419
|
}));
|
|
2400
2420
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
@@ -2687,10 +2707,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2687
2707
|
value: function extractSubmitErrorResponse(error) {
|
|
2688
2708
|
var _error$response,
|
|
2689
2709
|
_error$response2,
|
|
2690
|
-
|
|
2710
|
+
_this10 = this;
|
|
2691
2711
|
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];
|
|
2692
2712
|
return candidates.find(function (candidate) {
|
|
2693
|
-
return
|
|
2713
|
+
return _this10.isSubmitErrorResponse(candidate);
|
|
2694
2714
|
}) || null;
|
|
2695
2715
|
}
|
|
2696
2716
|
}, {
|
|
@@ -3268,7 +3288,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3268
3288
|
}, {
|
|
3269
3289
|
key: "normalizeTempOrderForRuntime",
|
|
3270
3290
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
3271
|
-
var
|
|
3291
|
+
var _this11 = this;
|
|
3272
3292
|
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), raw || {});
|
|
3273
3293
|
delete nextTempOrder.summary;
|
|
3274
3294
|
delete nextTempOrder.lastOrderInfo;
|
|
@@ -3287,7 +3307,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3287
3307
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
3288
3308
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
3289
3309
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
3290
|
-
return
|
|
3310
|
+
return _this11.normalizeHydratedOrderProduct(p);
|
|
3291
3311
|
}) : [];
|
|
3292
3312
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
3293
3313
|
return _objectSpread(_objectSpread({}, b || {}), {}, {
|
|
@@ -3328,8 +3348,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3328
3348
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
3329
3349
|
var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
|
|
3330
3350
|
var origin = (_ref23 = (_ref24 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref24 !== void 0 ? _ref24 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref23 !== void 0 ? _ref23 : rawProduct;
|
|
3351
|
+
var originSnapshot = cloneDeep(origin);
|
|
3352
|
+
var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
|
|
3353
|
+
if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
|
|
3354
|
+
if (originSnapshot.product_option_string === undefined) {
|
|
3355
|
+
originSnapshot.product_option_string = productOptionString;
|
|
3356
|
+
}
|
|
3357
|
+
if (originSnapshot.product_options_stirng === undefined) {
|
|
3358
|
+
originSnapshot.product_options_stirng = productOptionString;
|
|
3359
|
+
}
|
|
3360
|
+
}
|
|
3331
3361
|
productsByUid[uid] = _objectSpread(_objectSpread({}, existed), {}, {
|
|
3332
|
-
origin:
|
|
3362
|
+
origin: originSnapshot
|
|
3333
3363
|
});
|
|
3334
3364
|
}
|
|
3335
3365
|
} catch (err) {
|
|
@@ -3344,6 +3374,44 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3344
3374
|
nextTempOrder.vouchers = raw.vouchers || [];
|
|
3345
3375
|
return nextTempOrder;
|
|
3346
3376
|
}
|
|
3377
|
+
}, {
|
|
3378
|
+
key: "pickHydratedDisplayText",
|
|
3379
|
+
value: function pickHydratedDisplayText(value) {
|
|
3380
|
+
if (value === undefined || value === null) return '';
|
|
3381
|
+
if (typeof value === 'string') return value;
|
|
3382
|
+
if (_typeof(value) !== 'object') return String(value);
|
|
3383
|
+
return value.auto || value.original || value.en || value['zh-CN'] || value['zh-HK'] || '';
|
|
3384
|
+
}
|
|
3385
|
+
}, {
|
|
3386
|
+
key: "formatHydratedNamePair",
|
|
3387
|
+
value: function formatHydratedNamePair(group, item) {
|
|
3388
|
+
var groupText = this.pickHydratedDisplayText(group);
|
|
3389
|
+
var itemText = this.pickHydratedDisplayText(item);
|
|
3390
|
+
if (groupText && itemText) return "".concat(groupText, ":").concat(itemText);
|
|
3391
|
+
return groupText || itemText;
|
|
3392
|
+
}
|
|
3393
|
+
}, {
|
|
3394
|
+
key: "buildHydratedProductOptionString",
|
|
3395
|
+
value: function buildHydratedProductOptionString(product) {
|
|
3396
|
+
var segments = [];
|
|
3397
|
+
var sku = (product === null || product === void 0 ? void 0 : product.product_sku) || {};
|
|
3398
|
+
if (Array.isArray(sku.variant)) {
|
|
3399
|
+
var _iterator9 = _createForOfIteratorHelper(sku.variant),
|
|
3400
|
+
_step9;
|
|
3401
|
+
try {
|
|
3402
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
3403
|
+
var variant = _step9.value;
|
|
3404
|
+
var segment = this.formatHydratedNamePair(variant === null || variant === void 0 ? void 0 : variant.group, variant === null || variant === void 0 ? void 0 : variant.item);
|
|
3405
|
+
if (segment) segments.push(segment);
|
|
3406
|
+
}
|
|
3407
|
+
} catch (err) {
|
|
3408
|
+
_iterator9.e(err);
|
|
3409
|
+
} finally {
|
|
3410
|
+
_iterator9.f();
|
|
3411
|
+
}
|
|
3412
|
+
}
|
|
3413
|
+
return segments.join(', ');
|
|
3414
|
+
}
|
|
3347
3415
|
}, {
|
|
3348
3416
|
key: "normalizeHydratedProductOptionItem",
|
|
3349
3417
|
value: function normalizeHydratedProductOptionItem(optionItem) {
|
|
@@ -3352,25 +3420,61 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3352
3420
|
var parsedNum = Number(rawNum);
|
|
3353
3421
|
var rawPrice = (_ref26 = (_optionItem$price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _optionItem$price !== void 0 ? _optionItem$price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _ref26 !== void 0 ? _ref26 : 0;
|
|
3354
3422
|
var parsedPrice = Number(rawPrice);
|
|
3355
|
-
|
|
3423
|
+
var normalized = {
|
|
3356
3424
|
option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
|
|
3357
3425
|
option_group_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_id,
|
|
3358
3426
|
num: Number.isFinite(parsedNum) && parsedNum > 0 ? parsedNum : 1,
|
|
3359
3427
|
price: Number.isFinite(parsedPrice) ? parsedPrice : 0
|
|
3360
3428
|
};
|
|
3429
|
+
if ((optionItem === null || optionItem === void 0 ? void 0 : optionItem.name) !== undefined) normalized.name = optionItem.name;
|
|
3430
|
+
if ((optionItem === null || optionItem === void 0 ? void 0 : optionItem.group_name) !== undefined) normalized.group_name = optionItem.group_name;
|
|
3431
|
+
if ((optionItem === null || optionItem === void 0 ? void 0 : optionItem.id) !== undefined) normalized.id = optionItem.id;
|
|
3432
|
+
return normalized;
|
|
3433
|
+
}
|
|
3434
|
+
}, {
|
|
3435
|
+
key: "mergeHydratedProductOptionDisplayFields",
|
|
3436
|
+
value: function mergeHydratedProductOptionDisplayFields(options, skuOptions) {
|
|
3437
|
+
if (!Array.isArray(skuOptions) || skuOptions.length === 0) return options;
|
|
3438
|
+
var displayByItemId = new Map();
|
|
3439
|
+
var _iterator10 = _createForOfIteratorHelper(skuOptions),
|
|
3440
|
+
_step10;
|
|
3441
|
+
try {
|
|
3442
|
+
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
3443
|
+
var option = _step10.value;
|
|
3444
|
+
var key = option === null || option === void 0 ? void 0 : option.option_group_item_id;
|
|
3445
|
+
if (key === undefined || key === null || key === '') continue;
|
|
3446
|
+
displayByItemId.set(String(key), option);
|
|
3447
|
+
}
|
|
3448
|
+
} catch (err) {
|
|
3449
|
+
_iterator10.e(err);
|
|
3450
|
+
} finally {
|
|
3451
|
+
_iterator10.f();
|
|
3452
|
+
}
|
|
3453
|
+
return options.map(function (option) {
|
|
3454
|
+
var _option$option_group_;
|
|
3455
|
+
var display = displayByItemId.get(String((_option$option_group_ = option === null || option === void 0 ? void 0 : option.option_group_item_id) !== null && _option$option_group_ !== void 0 ? _option$option_group_ : ''));
|
|
3456
|
+
if (!display) return option;
|
|
3457
|
+
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, option), option.name === undefined && display.name !== undefined ? {
|
|
3458
|
+
name: display.name
|
|
3459
|
+
} : {}), option.group_name === undefined && display.group_name !== undefined ? {
|
|
3460
|
+
group_name: display.group_name
|
|
3461
|
+
} : {}), option.id === undefined && display.id !== undefined ? {
|
|
3462
|
+
id: display.id
|
|
3463
|
+
} : {});
|
|
3464
|
+
});
|
|
3361
3465
|
}
|
|
3362
3466
|
}, {
|
|
3363
3467
|
key: "resolveHydratedProductOptions",
|
|
3364
3468
|
value: function resolveHydratedProductOptions(row) {
|
|
3365
3469
|
var _row$product_sku,
|
|
3366
|
-
|
|
3470
|
+
_this12 = this;
|
|
3471
|
+
var skuOptions = (_row$product_sku = row.product_sku) === null || _row$product_sku === void 0 ? void 0 : _row$product_sku.option;
|
|
3367
3472
|
if (Array.isArray(row.product_option_item) && row.product_option_item.length > 0) {
|
|
3368
|
-
return row.product_option_item;
|
|
3473
|
+
return this.mergeHydratedProductOptionDisplayFields(row.product_option_item, skuOptions);
|
|
3369
3474
|
}
|
|
3370
|
-
var skuOptions = (_row$product_sku = row.product_sku) === null || _row$product_sku === void 0 ? void 0 : _row$product_sku.option;
|
|
3371
3475
|
if (!Array.isArray(skuOptions)) return [];
|
|
3372
3476
|
return skuOptions.map(function (optionItem) {
|
|
3373
|
-
return
|
|
3477
|
+
return _this12.normalizeHydratedProductOptionItem(optionItem || {});
|
|
3374
3478
|
});
|
|
3375
3479
|
}
|
|
3376
3480
|
}, {
|
|
@@ -3448,67 +3552,67 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3448
3552
|
var amount = new Decimal(discount.amount || 0).times(qty).plus(((_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.product_discount_difference) || 0);
|
|
3449
3553
|
savedMap.set(discountKey, (savedMap.get(discountKey) || new Decimal(0)).plus(amount));
|
|
3450
3554
|
};
|
|
3451
|
-
var
|
|
3452
|
-
|
|
3555
|
+
var _iterator11 = _createForOfIteratorHelper(productList),
|
|
3556
|
+
_step11;
|
|
3453
3557
|
try {
|
|
3454
|
-
for (
|
|
3455
|
-
var product =
|
|
3558
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
3559
|
+
var product = _step11.value;
|
|
3456
3560
|
var qty = product.num || 1;
|
|
3457
|
-
var
|
|
3458
|
-
|
|
3561
|
+
var _iterator13 = _createForOfIteratorHelper(product.discount_list || []),
|
|
3562
|
+
_step13;
|
|
3459
3563
|
try {
|
|
3460
|
-
for (
|
|
3461
|
-
var pd =
|
|
3564
|
+
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
|
3565
|
+
var pd = _step13.value;
|
|
3462
3566
|
addDiscountAmount(pd, qty);
|
|
3463
3567
|
}
|
|
3464
3568
|
} catch (err) {
|
|
3465
|
-
|
|
3569
|
+
_iterator13.e(err);
|
|
3466
3570
|
} finally {
|
|
3467
|
-
|
|
3571
|
+
_iterator13.f();
|
|
3468
3572
|
}
|
|
3469
|
-
var
|
|
3470
|
-
|
|
3573
|
+
var _iterator14 = _createForOfIteratorHelper(product.product_bundle || []),
|
|
3574
|
+
_step14;
|
|
3471
3575
|
try {
|
|
3472
|
-
for (
|
|
3576
|
+
for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
|
|
3473
3577
|
var _ref27, _bundle$num;
|
|
3474
|
-
var bundle =
|
|
3578
|
+
var bundle = _step14.value;
|
|
3475
3579
|
var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref27 = (_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) !== null && _ref27 !== void 0 ? _ref27 : 1) || 1).toNumber();
|
|
3476
|
-
var
|
|
3477
|
-
|
|
3580
|
+
var _iterator15 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
|
|
3581
|
+
_step15;
|
|
3478
3582
|
try {
|
|
3479
|
-
for (
|
|
3480
|
-
var _pd =
|
|
3583
|
+
for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
|
|
3584
|
+
var _pd = _step15.value;
|
|
3481
3585
|
addDiscountAmount(_pd, bundleQty);
|
|
3482
3586
|
}
|
|
3483
3587
|
} catch (err) {
|
|
3484
|
-
|
|
3588
|
+
_iterator15.e(err);
|
|
3485
3589
|
} finally {
|
|
3486
|
-
|
|
3590
|
+
_iterator15.f();
|
|
3487
3591
|
}
|
|
3488
3592
|
}
|
|
3489
3593
|
} catch (err) {
|
|
3490
|
-
|
|
3594
|
+
_iterator14.e(err);
|
|
3491
3595
|
} finally {
|
|
3492
|
-
|
|
3596
|
+
_iterator14.f();
|
|
3493
3597
|
}
|
|
3494
3598
|
}
|
|
3495
3599
|
} catch (err) {
|
|
3496
|
-
|
|
3600
|
+
_iterator11.e(err);
|
|
3497
3601
|
} finally {
|
|
3498
|
-
|
|
3602
|
+
_iterator11.f();
|
|
3499
3603
|
}
|
|
3500
|
-
var
|
|
3501
|
-
|
|
3604
|
+
var _iterator12 = _createForOfIteratorHelper(discountList),
|
|
3605
|
+
_step12;
|
|
3502
3606
|
try {
|
|
3503
|
-
for (
|
|
3504
|
-
var d =
|
|
3607
|
+
for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
|
|
3608
|
+
var d = _step12.value;
|
|
3505
3609
|
var key = d.id;
|
|
3506
3610
|
d.savedAmount = d.isSelected && key != null && savedMap.has(key) ? savedMap.get(key).toNumber() : 0;
|
|
3507
3611
|
}
|
|
3508
3612
|
} catch (err) {
|
|
3509
|
-
|
|
3613
|
+
_iterator12.e(err);
|
|
3510
3614
|
} finally {
|
|
3511
|
-
|
|
3615
|
+
_iterator12.f();
|
|
3512
3616
|
}
|
|
3513
3617
|
}
|
|
3514
3618
|
}]);
|
|
@@ -825,7 +825,9 @@ export function mapPaymentItemToOrderPayment(paymentItem) {
|
|
|
825
825
|
metadata[key] = item[key];
|
|
826
826
|
}
|
|
827
827
|
}
|
|
828
|
-
return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
828
|
+
return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, item.order_payment_id !== undefined ? {
|
|
829
|
+
order_payment_id: item.order_payment_id
|
|
830
|
+
} : {}), {}, {
|
|
829
831
|
amount: String((_item$amount = item.amount) !== null && _item$amount !== void 0 ? _item$amount : '0.00'),
|
|
830
832
|
code: String(item.code || ''),
|
|
831
833
|
custom_payment_id: Number(customPaymentId !== null && customPaymentId !== void 0 ? customPaymentId : 0),
|