@pisell/pisellos 2.2.188 → 2.2.190
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/Order/index.d.ts +1 -0
- package/dist/modules/Order/index.js +53 -45
- package/dist/modules/Order/types.d.ts +2 -0
- package/dist/modules/Order/utils.js +3 -1
- package/dist/solution/BaseSales/index.js +61 -53
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +14 -2
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +16 -1
- package/dist/solution/BookingTicket/index.js +117 -6
- 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/Order/index.d.ts +1 -0
- package/lib/modules/Order/index.js +15 -10
- package/lib/modules/Order/types.d.ts +2 -0
- package/lib/modules/Order/utils.js +1 -0
- package/lib/solution/BaseSales/index.js +12 -4
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +11 -2
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +16 -1
- package/lib/solution/BookingTicket/index.js +56 -0
- 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
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// 导出评估器
|
|
2
|
+
export { PromotionEvaluator } from "./evaluator";
|
|
3
|
+
|
|
4
|
+
// 导出适配器
|
|
5
|
+
export { PromotionAdapter } from "./adapter";
|
|
6
|
+
export { default } from "./adapter";
|
|
7
|
+
|
|
8
|
+
// 导出策略配置示例常量
|
|
9
|
+
export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY } from "./examples";
|
|
@@ -143,6 +143,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
143
143
|
private saveDraftInBackground;
|
|
144
144
|
private hydrateTempOrderFromLocalRecord;
|
|
145
145
|
private extractOrderIdFromSubmitResult;
|
|
146
|
+
private calculatePaymentEffectiveAmount;
|
|
146
147
|
private calculatePaymentTotal;
|
|
147
148
|
private normalizePaymentSource;
|
|
148
149
|
private updateTempOrderPaymentStatus;
|
|
@@ -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,12 +2112,11 @@ 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) {
|
|
2111
2119
|
case 0:
|
|
2112
|
-
debugger;
|
|
2113
2120
|
tempOrder = this.ensureTempOrder();
|
|
2114
2121
|
linked = booking ? this.createLinkedProductAndBooking({
|
|
2115
2122
|
product: product,
|
|
@@ -2122,7 +2129,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2122
2129
|
hasIncomingGoodPass = this.hasGoodPassDiscount(normalizedIncoming);
|
|
2123
2130
|
shouldForceNewLine = !!booking;
|
|
2124
2131
|
matchedIndex = hasIncomingGoodPass || shouldForceNewLine ? -1 : tempOrder.products.findIndex(function (item) {
|
|
2125
|
-
if (
|
|
2132
|
+
if (_this9.hasGoodPassDiscount(item)) return false;
|
|
2126
2133
|
if (item.product_id !== productToAdd.product_id) return false;
|
|
2127
2134
|
if (item.product_variant_id !== productToAdd.product_variant_id) return false;
|
|
2128
2135
|
var existedFingerprint = buildProductLineFingerprint(item.product_option_item, item.product_bundle);
|
|
@@ -2131,10 +2138,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2131
2138
|
matchedProduct = matchedIndex === -1 ? null : tempOrder.products[matchedIndex];
|
|
2132
2139
|
existedFingerprint = matchedProduct ? buildProductLineFingerprint(matchedProduct.product_option_item, matchedProduct.product_bundle) : '';
|
|
2133
2140
|
if (!matchedProduct) {
|
|
2134
|
-
_context18.next =
|
|
2141
|
+
_context18.next = 17;
|
|
2135
2142
|
break;
|
|
2136
2143
|
}
|
|
2137
|
-
_context18.next =
|
|
2144
|
+
_context18.next = 14;
|
|
2138
2145
|
return this.shouldMergeProductToOrder({
|
|
2139
2146
|
incomingProduct: productToAdd,
|
|
2140
2147
|
normalizedIncoming: normalizedIncoming,
|
|
@@ -2145,13 +2152,13 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2145
2152
|
tempOrder: tempOrder,
|
|
2146
2153
|
booking: booking
|
|
2147
2154
|
});
|
|
2148
|
-
case
|
|
2155
|
+
case 14:
|
|
2149
2156
|
_context18.t0 = _context18.sent;
|
|
2150
|
-
_context18.next =
|
|
2157
|
+
_context18.next = 18;
|
|
2151
2158
|
break;
|
|
2152
|
-
case
|
|
2159
|
+
case 17:
|
|
2153
2160
|
_context18.t0 = false;
|
|
2154
|
-
case
|
|
2161
|
+
case 18:
|
|
2155
2162
|
shouldMerge = _context18.t0;
|
|
2156
2163
|
if (matchedIndex === -1 || !matchedProduct || !shouldMerge) {
|
|
2157
2164
|
this.captureProductRuntime(tempOrder, productToAdd, normalizedIncoming);
|
|
@@ -2184,18 +2191,18 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2184
2191
|
if (linked) {
|
|
2185
2192
|
tempOrder.bookings = [].concat(_toConsumableArray(tempOrder.bookings || []), [linked.booking]);
|
|
2186
2193
|
}
|
|
2187
|
-
_context18.next =
|
|
2194
|
+
_context18.next = 23;
|
|
2188
2195
|
return this.applyPromotion();
|
|
2189
|
-
case
|
|
2196
|
+
case 23:
|
|
2190
2197
|
this.applyDiscount();
|
|
2191
|
-
_context18.next =
|
|
2198
|
+
_context18.next = 26;
|
|
2192
2199
|
return this.recalculateSummary({
|
|
2193
2200
|
createIfMissing: true
|
|
2194
2201
|
});
|
|
2195
|
-
case
|
|
2202
|
+
case 26:
|
|
2196
2203
|
this.persistTempOrder();
|
|
2197
2204
|
return _context18.abrupt("return", tempOrder.products);
|
|
2198
|
-
case
|
|
2205
|
+
case 28:
|
|
2199
2206
|
case "end":
|
|
2200
2207
|
return _context18.stop();
|
|
2201
2208
|
}
|
|
@@ -2550,7 +2557,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2550
2557
|
key: "submitTempOrder",
|
|
2551
2558
|
value: function () {
|
|
2552
2559
|
var _submitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
|
|
2553
|
-
var _params$cacheId, _this$otherParams;
|
|
2560
|
+
var _params$cacheId, _this$otherParams, _ref23, _params$businessCode, _this$otherParams2, _this$otherParams3;
|
|
2554
2561
|
var tempOrder, effectiveCacheId, hasPaymentOverride, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
|
|
2555
2562
|
return _regeneratorRuntime().wrap(function _callee21$(_context23) {
|
|
2556
2563
|
while (1) switch (_context23.prev = _context23.next) {
|
|
@@ -2576,7 +2583,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2576
2583
|
tempOrder: tempOrder,
|
|
2577
2584
|
cacheId: effectiveCacheId,
|
|
2578
2585
|
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.platform),
|
|
2579
|
-
businessCode: params === null || params === void 0 ? void 0 : params.businessCode,
|
|
2586
|
+
businessCode: (_ref23 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.businessCode) !== null && _ref23 !== void 0 ? _ref23 : (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.business_code,
|
|
2580
2587
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
2581
2588
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
2582
2589
|
enhance: enhancePayload
|
|
@@ -2699,10 +2706,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2699
2706
|
value: function extractSubmitErrorResponse(error) {
|
|
2700
2707
|
var _error$response,
|
|
2701
2708
|
_error$response2,
|
|
2702
|
-
|
|
2709
|
+
_this10 = this;
|
|
2703
2710
|
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];
|
|
2704
2711
|
return candidates.find(function (candidate) {
|
|
2705
|
-
return
|
|
2712
|
+
return _this10.isSubmitErrorResponse(candidate);
|
|
2706
2713
|
}) || null;
|
|
2707
2714
|
}
|
|
2708
2715
|
}, {
|
|
@@ -2762,6 +2769,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2762
2769
|
payments: mappedPayments,
|
|
2763
2770
|
paymentStatus: paymentStatus,
|
|
2764
2771
|
smallTicketDataFlag: params.smallTicketDataFlag,
|
|
2772
|
+
businessCode: params.businessCode,
|
|
2765
2773
|
channel: params.channel,
|
|
2766
2774
|
enhancePayload: function enhancePayload(payload) {
|
|
2767
2775
|
var nextPayload = _objectSpread(_objectSpread({}, payload), {}, {
|
|
@@ -3280,7 +3288,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3280
3288
|
}, {
|
|
3281
3289
|
key: "normalizeTempOrderForRuntime",
|
|
3282
3290
|
value: function normalizeTempOrderForRuntime(raw, options) {
|
|
3283
|
-
var
|
|
3291
|
+
var _this11 = this;
|
|
3284
3292
|
var nextTempOrder = _objectSpread(_objectSpread({}, this.createDefaultTempOrderInstance()), raw || {});
|
|
3285
3293
|
delete nextTempOrder.summary;
|
|
3286
3294
|
delete nextTempOrder.lastOrderInfo;
|
|
@@ -3299,7 +3307,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3299
3307
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
3300
3308
|
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
3301
3309
|
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
3302
|
-
return
|
|
3310
|
+
return _this11.normalizeHydratedOrderProduct(p);
|
|
3303
3311
|
}) : [];
|
|
3304
3312
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
3305
3313
|
return _objectSpread(_objectSpread({}, b || {}), {}, {
|
|
@@ -3331,7 +3339,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3331
3339
|
_step8;
|
|
3332
3340
|
try {
|
|
3333
3341
|
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
3334
|
-
var _product$metadata6,
|
|
3342
|
+
var _product$metadata6, _ref24, _ref25, _existed$origin, _rawProduct$metadata;
|
|
3335
3343
|
var _step8$value = _slicedToArray(_step8.value, 2),
|
|
3336
3344
|
index = _step8$value[0],
|
|
3337
3345
|
product = _step8$value[1];
|
|
@@ -3339,7 +3347,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3339
3347
|
if (!uid) continue;
|
|
3340
3348
|
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
3341
3349
|
var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
|
|
3342
|
-
var origin = (
|
|
3350
|
+
var origin = (_ref24 = (_ref25 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref25 !== void 0 ? _ref25 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref24 !== void 0 ? _ref24 : rawProduct;
|
|
3343
3351
|
var originSnapshot = cloneDeep(origin);
|
|
3344
3352
|
var productOptionString = this.buildHydratedProductOptionString(rawProduct) || this.buildHydratedProductOptionString(product);
|
|
3345
3353
|
if (productOptionString && originSnapshot && _typeof(originSnapshot) === 'object') {
|
|
@@ -3407,10 +3415,10 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3407
3415
|
}, {
|
|
3408
3416
|
key: "normalizeHydratedProductOptionItem",
|
|
3409
3417
|
value: function normalizeHydratedProductOptionItem(optionItem) {
|
|
3410
|
-
var
|
|
3411
|
-
var rawNum = (
|
|
3418
|
+
var _ref26, _optionItem$num, _ref27, _optionItem$price;
|
|
3419
|
+
var rawNum = (_ref26 = (_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 && _ref26 !== void 0 ? _ref26 : 1;
|
|
3412
3420
|
var parsedNum = Number(rawNum);
|
|
3413
|
-
var rawPrice = (
|
|
3421
|
+
var rawPrice = (_ref27 = (_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 && _ref27 !== void 0 ? _ref27 : 0;
|
|
3414
3422
|
var parsedPrice = Number(rawPrice);
|
|
3415
3423
|
var normalized = {
|
|
3416
3424
|
option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
|
|
@@ -3459,14 +3467,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3459
3467
|
key: "resolveHydratedProductOptions",
|
|
3460
3468
|
value: function resolveHydratedProductOptions(row) {
|
|
3461
3469
|
var _row$product_sku,
|
|
3462
|
-
|
|
3470
|
+
_this12 = this;
|
|
3463
3471
|
var skuOptions = (_row$product_sku = row.product_sku) === null || _row$product_sku === void 0 ? void 0 : _row$product_sku.option;
|
|
3464
3472
|
if (Array.isArray(row.product_option_item) && row.product_option_item.length > 0) {
|
|
3465
3473
|
return this.mergeHydratedProductOptionDisplayFields(row.product_option_item, skuOptions);
|
|
3466
3474
|
}
|
|
3467
3475
|
if (!Array.isArray(skuOptions)) return [];
|
|
3468
3476
|
return skuOptions.map(function (optionItem) {
|
|
3469
|
-
return
|
|
3477
|
+
return _this12.normalizeHydratedProductOptionItem(optionItem || {});
|
|
3470
3478
|
});
|
|
3471
3479
|
}
|
|
3472
3480
|
}, {
|
|
@@ -3566,9 +3574,9 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3566
3574
|
_step14;
|
|
3567
3575
|
try {
|
|
3568
3576
|
for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
|
|
3569
|
-
var
|
|
3577
|
+
var _ref28, _bundle$num;
|
|
3570
3578
|
var bundle = _step14.value;
|
|
3571
|
-
var bundleQty = new Decimal(Number(qty) || 1).times(Number((
|
|
3579
|
+
var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref28 = (_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 && _ref28 !== void 0 ? _ref28 : 1) || 1).toNumber();
|
|
3572
3580
|
var _iterator15 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
|
|
3573
3581
|
_step15;
|
|
3574
3582
|
try {
|
|
@@ -439,6 +439,7 @@ export interface OrderPaymentMetadata {
|
|
|
439
439
|
[key: string]: any;
|
|
440
440
|
}
|
|
441
441
|
export interface OrderPaymentData {
|
|
442
|
+
order_payment_id?: number | string;
|
|
442
443
|
amount: string;
|
|
443
444
|
code: string;
|
|
444
445
|
custom_payment_id: number;
|
|
@@ -478,6 +479,7 @@ export interface SyncPaymentsToOrderParams {
|
|
|
478
479
|
paymentStatus?: SubmitSalesOrderParams['query']['payment_status'];
|
|
479
480
|
submitWhenPaid?: boolean;
|
|
480
481
|
smallTicketDataFlag?: number;
|
|
482
|
+
businessCode?: string;
|
|
481
483
|
channel?: string;
|
|
482
484
|
}
|
|
483
485
|
export interface SyncPaymentsToOrderResult<T = any> {
|
|
@@ -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),
|