@pisell/pisellos 2.3.6 → 2.3.7
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 +17 -13
- package/dist/modules/Order/index.js +146 -113
- package/dist/modules/Order/utils.d.ts +4 -0
- package/dist/modules/Order/utils.js +31 -0
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Rules/index.d.ts +3 -3
- package/dist/modules/Rules/index.js +8 -3
- package/dist/modules/Rules/types.d.ts +2 -1
- package/dist/server/index.js +1 -0
- package/dist/server/modules/order/index.d.ts +4 -4
- package/dist/server/modules/order/index.js +4 -4
- package/dist/solution/BaseSales/index.js +60 -53
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +4 -2
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +11 -1
- package/lib/modules/Order/index.js +54 -17
- package/lib/modules/Order/utils.d.ts +4 -0
- package/lib/modules/Order/utils.js +39 -0
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Rules/index.d.ts +3 -3
- package/lib/modules/Rules/index.js +4 -3
- package/lib/modules/Rules/types.d.ts +2 -1
- package/lib/server/modules/order/index.d.ts +4 -4
- package/lib/server/modules/order/index.js +4 -4
- package/lib/solution/BaseSales/index.js +20 -13
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +4 -5
- package/package.json +1 -1
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
4
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
5
1
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
2
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
3
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -132,6 +128,14 @@ function resolveMainProductPrice(product, fallback) {
|
|
|
132
128
|
var parsed = Number(value);
|
|
133
129
|
return Number.isFinite(parsed) ? parsed : fallback;
|
|
134
130
|
}
|
|
131
|
+
function mapOrderBundleToOtherBundle(bundle) {
|
|
132
|
+
return bundle.map(function (item) {
|
|
133
|
+
var _ref6, _item$original_price;
|
|
134
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
135
|
+
original_price: (_ref6 = (_item$original_price = item.original_price) !== null && _item$original_price !== void 0 ? _item$original_price : item.bundle_selling_price) !== null && _ref6 !== void 0 ? _ref6 : item.price
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
}
|
|
135
139
|
|
|
136
140
|
/**
|
|
137
141
|
* catalog 缺 product_resource 时,从 booking.resources 反推最小 product_resource 结构,
|
|
@@ -159,10 +163,10 @@ function synthesizeProductResourceFromBooking(booking) {
|
|
|
159
163
|
});
|
|
160
164
|
if (relationIdsByForm.size === 0) return undefined;
|
|
161
165
|
return {
|
|
162
|
-
resources: Array.from(relationIdsByForm.entries()).map(function (
|
|
163
|
-
var
|
|
164
|
-
formId =
|
|
165
|
-
relationIds =
|
|
166
|
+
resources: Array.from(relationIdsByForm.entries()).map(function (_ref7) {
|
|
167
|
+
var _ref8 = _slicedToArray(_ref7, 2),
|
|
168
|
+
formId = _ref8[0],
|
|
169
|
+
relationIds = _ref8[1];
|
|
166
170
|
return {
|
|
167
171
|
id: formId,
|
|
168
172
|
status: 1,
|
|
@@ -182,7 +186,7 @@ function synthesizeProductResourceFromBooking(booking) {
|
|
|
182
186
|
* 调用方须传入与该行关联的 booking(通常 bookings[].product_uid === product.metadata.unique_identification_number)。
|
|
183
187
|
*/
|
|
184
188
|
export function buildCacheItemFromOrderLine(input) {
|
|
185
|
-
var _product$product_id, _product$selling_pric, _product$original_pri, _booking$metadata$hol, _booking$metadata2, _product$product_vari, _product$num,
|
|
189
|
+
var _product$product_id, _product$selling_pric, _product$original_pri, _booking$metadata$hol, _booking$metadata2, _product$product_vari, _product$num, _ref9, _product$note, _booking$detail2, _product$metadata, _product$metadata2, _ref10, _extension_type, _booking$product2, _booking$product3, _price, _product$order_detail, _ref11, _booking$id;
|
|
186
190
|
var product = input.product,
|
|
187
191
|
booking = input.booking,
|
|
188
192
|
sourceProduct = input.sourceProduct;
|
|
@@ -202,7 +206,7 @@ export function buildCacheItemFromOrderLine(input) {
|
|
|
202
206
|
var other = {
|
|
203
207
|
product_variant_id: (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : 0,
|
|
204
208
|
option: getProductSkuOptions(product),
|
|
205
|
-
bundle: Array.isArray(product.product_bundle) ?
|
|
209
|
+
bundle: mapOrderBundleToOtherBundle(Array.isArray(product.product_bundle) ? product.product_bundle : [])
|
|
206
210
|
};
|
|
207
211
|
var extend = _objectSpread({
|
|
208
212
|
start_date: startDate ? dayjs(startDate) : undefined,
|
|
@@ -215,7 +219,7 @@ export function buildCacheItemFromOrderLine(input) {
|
|
|
215
219
|
sub_type: booking.sub_type,
|
|
216
220
|
quantity: (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : 1,
|
|
217
221
|
product_name: productTitle,
|
|
218
|
-
note: (
|
|
222
|
+
note: (_ref9 = (_product$note = product.note) !== null && _product$note !== void 0 ? _product$note : booking === null || booking === void 0 || (_booking$detail2 = booking.detail) === null || _booking$detail2 === void 0 ? void 0 : _booking$detail2.note) !== null && _ref9 !== void 0 ? _ref9 : '',
|
|
219
223
|
price: mainProductPrice,
|
|
220
224
|
total: selling,
|
|
221
225
|
origin_total: original,
|
|
@@ -250,7 +254,7 @@ export function buildCacheItemFromOrderLine(input) {
|
|
|
250
254
|
var base = _objectSpread(_objectSpread(_objectSpread({}, sourceProduct || {}), {}, {
|
|
251
255
|
id: resolvedId,
|
|
252
256
|
product_id: resolvedId,
|
|
253
|
-
extension_type: (
|
|
257
|
+
extension_type: (_ref10 = (_extension_type = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type) !== null && _extension_type !== void 0 ? _extension_type : booking === null || booking === void 0 || (_booking$product2 = booking.product) === null || _booking$product2 === void 0 ? void 0 : _booking$product2.extension_type) !== null && _ref10 !== void 0 ? _ref10 : sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.extension_type,
|
|
254
258
|
title: productTitle || (sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.title) || (booking === null || booking === void 0 || (_booking$product3 = booking.product) === null || _booking$product3 === void 0 ? void 0 : _booking$product3.title),
|
|
255
259
|
price: (_price = sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.price) !== null && _price !== void 0 ? _price : selling,
|
|
256
260
|
selling_price: product.selling_price,
|
|
@@ -262,7 +266,7 @@ export function buildCacheItemFromOrderLine(input) {
|
|
|
262
266
|
new: 0,
|
|
263
267
|
autoClose: false,
|
|
264
268
|
order_detail_id: (_product$order_detail = product.order_detail_id) !== null && _product$order_detail !== void 0 ? _product$order_detail : null,
|
|
265
|
-
booking_id: (
|
|
269
|
+
booking_id: (_ref11 = (_booking$id = booking.id) !== null && _booking$id !== void 0 ? _booking$id : booking.booking_id) !== null && _ref11 !== void 0 ? _ref11 : 0
|
|
266
270
|
});
|
|
267
271
|
if ((sourceProduct === null || sourceProduct === void 0 ? void 0 : sourceProduct.capacity) !== undefined) {
|
|
268
272
|
base.capacity = sourceProduct.capacity;
|