@pisell/pisellos 2.2.222 → 2.2.224
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 +0 -9
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -0
- package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +3 -0
- package/dist/modules/Customer/index.d.ts +7 -0
- package/dist/modules/Customer/index.js +16 -0
- package/dist/modules/OpenData/index.d.ts +7 -0
- package/dist/modules/OpenData/index.js +16 -1
- package/dist/modules/Order/index.d.ts +43 -0
- package/dist/modules/Order/index.js +296 -112
- package/dist/modules/Order/types.d.ts +16 -0
- package/dist/modules/Order/utils.js +7 -4
- package/dist/modules/Payment/index.d.ts +7 -0
- package/dist/modules/Payment/index.js +12 -0
- package/dist/modules/ProductList/index.d.ts +7 -0
- package/dist/modules/ProductList/index.js +11 -0
- package/dist/modules/SalesSummary/index.d.ts +7 -0
- package/dist/modules/SalesSummary/index.js +61 -26
- package/dist/modules/Schedule/index.d.ts +7 -0
- package/dist/modules/Schedule/index.js +16 -0
- package/dist/modules/Summary/index.js +2 -1
- package/dist/server/modules/order/types.d.ts +2 -0
- package/dist/server/modules/order/utils/filterBookings.js +25 -2
- package/dist/server/utils/small-ticket.js +160 -30
- package/dist/solution/BaseSales/index.d.ts +17 -0
- package/dist/solution/BaseSales/index.js +524 -439
- package/dist/solution/BaseSales/utils/cartPromotion.js +24 -7
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +0 -8
- package/dist/solution/BookingTicket/index.js +41 -75
- package/dist/types/index.d.ts +10 -0
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +1 -0
- package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +3 -0
- package/lib/modules/Customer/index.d.ts +7 -0
- package/lib/modules/Customer/index.js +12 -0
- package/lib/modules/OpenData/index.d.ts +7 -0
- package/lib/modules/OpenData/index.js +13 -1
- package/lib/modules/Order/index.d.ts +43 -0
- package/lib/modules/Order/index.js +145 -3
- package/lib/modules/Order/types.d.ts +16 -0
- package/lib/modules/Order/utils.js +6 -2
- package/lib/modules/Payment/index.d.ts +7 -0
- package/lib/modules/Payment/index.js +9 -0
- package/lib/modules/ProductList/index.d.ts +7 -0
- package/lib/modules/ProductList/index.js +9 -0
- package/lib/modules/SalesSummary/index.d.ts +7 -0
- package/lib/modules/SalesSummary/index.js +15 -1
- package/lib/modules/Schedule/index.d.ts +7 -0
- package/lib/modules/Schedule/index.js +12 -0
- package/lib/modules/Summary/index.js +2 -1
- package/lib/server/modules/order/types.d.ts +2 -0
- package/lib/server/modules/order/utils/filterBookings.js +17 -2
- package/lib/server/utils/small-ticket.js +141 -32
- package/lib/solution/BaseSales/index.d.ts +17 -0
- package/lib/solution/BaseSales/index.js +48 -10
- package/lib/solution/BaseSales/utils/cartPromotion.js +28 -2
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +0 -8
- package/lib/solution/BookingTicket/index.js +0 -12
- package/lib/types/index.d.ts +10 -0
- package/package.json +1 -1
|
@@ -164,7 +164,7 @@ function buildBaseData(params) {
|
|
|
164
164
|
function buildProducts(order, locale, productMap) {
|
|
165
165
|
var products = Array.isArray(order.products) ? order.products : [];
|
|
166
166
|
return products.map(function (product) {
|
|
167
|
-
var _ref, _ref2, _product$product_quan, _ref3, _ref4, _ref5, _product$original_pri, _ref6, _ref7, _product$selling_pric;
|
|
167
|
+
var _ref, _ref2, _product$product_quan, _ref3, _ref4, _ref5, _product$original_pri, _ref6, _ref7, _product$selling_pric, _product$product_id;
|
|
168
168
|
var quantity = toNumber((_ref = (_ref2 = (_product$product_quan = product.product_quantity) !== null && _product$product_quan !== void 0 ? _product$product_quan : product.quantity) !== null && _ref2 !== void 0 ? _ref2 : product.num) !== null && _ref !== void 0 ? _ref : 1, 1);
|
|
169
169
|
var originalPrice = (_ref3 = (_ref4 = (_ref5 = (_product$original_pri = product.original_price) !== null && _product$original_pri !== void 0 ? _product$original_pri : product.selling_price) !== null && _ref5 !== void 0 ? _ref5 : product.payment_price) !== null && _ref4 !== void 0 ? _ref4 : product.price) !== null && _ref3 !== void 0 ? _ref3 : 0;
|
|
170
170
|
var sellingPrice = (_ref6 = (_ref7 = (_product$selling_pric = product.selling_price) !== null && _product$selling_pric !== void 0 ? _product$selling_pric : product.payment_price) !== null && _ref7 !== void 0 ? _ref7 : product.price) !== null && _ref6 !== void 0 ? _ref6 : originalPrice;
|
|
@@ -173,17 +173,20 @@ function buildProducts(order, locale, productMap) {
|
|
|
173
173
|
productMap: productMap,
|
|
174
174
|
locale: locale
|
|
175
175
|
});
|
|
176
|
+
var parentProduct = resolveProductFromMap((_product$product_id = product.product_id) !== null && _product$product_id !== void 0 ? _product$product_id : product.id, productMap);
|
|
176
177
|
var currencySymbol = getCurrencySymbol(order, null);
|
|
177
178
|
var options = normalizeProductOptions({
|
|
178
179
|
product: product,
|
|
179
180
|
locale: locale,
|
|
180
|
-
currencySymbol: currencySymbol
|
|
181
|
+
currencySymbol: currencySymbol,
|
|
182
|
+
parentProduct: parentProduct
|
|
181
183
|
});
|
|
182
184
|
var combinations = normalizeProductCombinations({
|
|
183
185
|
product: product,
|
|
184
186
|
productMap: productMap,
|
|
185
187
|
locale: locale,
|
|
186
|
-
currencySymbol: currencySymbol
|
|
188
|
+
currencySymbol: currencySymbol,
|
|
189
|
+
parentProduct: parentProduct
|
|
187
190
|
});
|
|
188
191
|
return _objectSpread(_objectSpread(_objectSpread({
|
|
189
192
|
product_title: productTitle,
|
|
@@ -204,29 +207,36 @@ function buildProducts(order, locale, productMap) {
|
|
|
204
207
|
});
|
|
205
208
|
}
|
|
206
209
|
function resolveProductTitle(params) {
|
|
207
|
-
var _product$
|
|
210
|
+
var _product$product_id2;
|
|
208
211
|
var product = params.product,
|
|
209
212
|
productMap = params.productMap,
|
|
210
213
|
locale = params.locale;
|
|
211
|
-
var ownTitle =
|
|
212
|
-
if (ownTitle) return ownTitle;
|
|
213
|
-
|
|
214
|
-
var
|
|
215
|
-
|
|
216
|
-
|
|
214
|
+
var ownTitle = getProductTitleSource(product, locale);
|
|
215
|
+
// if (ownTitle) return ownTitle;
|
|
216
|
+
|
|
217
|
+
var productId = (_product$product_id2 = product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : product.id;
|
|
218
|
+
var fallbackProduct = resolveProductFromMap(productId, productMap);
|
|
219
|
+
if (!fallbackProduct) return ownTitle || '';
|
|
220
|
+
return getProductTitleSource(fallbackProduct, locale);
|
|
217
221
|
}
|
|
218
222
|
function normalizeProductOptions(params) {
|
|
219
223
|
var _product$product_sku;
|
|
220
224
|
var product = params.product,
|
|
221
225
|
locale = params.locale,
|
|
222
|
-
currencySymbol = params.currencySymbol
|
|
226
|
+
currencySymbol = params.currencySymbol,
|
|
227
|
+
parentProduct = params.parentProduct;
|
|
223
228
|
var rawOptions = Array.isArray(params.options) ? params.options : Array.isArray(product.options) ? product.options : Array.isArray((_product$product_sku = product.product_sku) === null || _product$product_sku === void 0 ? void 0 : _product$product_sku.option) ? product.product_sku.option : [];
|
|
224
229
|
return rawOptions.map(function (option) {
|
|
225
230
|
var _ref8, _option$original_pric, _ref9, _option$value, _option$num;
|
|
226
231
|
var price = (_ref8 = (_option$original_pric = option.original_price) !== null && _option$original_pric !== void 0 ? _option$original_pric : option.add_price) !== null && _ref8 !== void 0 ? _ref8 : option.price;
|
|
227
232
|
var value = (_ref9 = (_option$value = option.value) !== null && _option$value !== void 0 ? _option$value : option.option) !== null && _ref9 !== void 0 ? _ref9 : option.item;
|
|
233
|
+
var name = getProductTitleSource(option, locale) || resolveOptionTitleFromParentProduct({
|
|
234
|
+
option: option,
|
|
235
|
+
parentProduct: parentProduct,
|
|
236
|
+
locale: locale
|
|
237
|
+
});
|
|
228
238
|
return _objectSpread(_objectSpread(_objectSpread({
|
|
229
|
-
name:
|
|
239
|
+
name: name
|
|
230
240
|
}, option.num !== undefined || option.quantity !== undefined ? {
|
|
231
241
|
num: toNumber((_option$num = option.num) !== null && _option$num !== void 0 ? _option$num : option.quantity, 1)
|
|
232
242
|
} : {}), price !== undefined && price !== null && price !== '' ? {
|
|
@@ -240,7 +250,8 @@ function normalizeProductCombinations(params) {
|
|
|
240
250
|
var product = params.product,
|
|
241
251
|
productMap = params.productMap,
|
|
242
252
|
locale = params.locale,
|
|
243
|
-
currencySymbol = params.currencySymbol
|
|
253
|
+
currencySymbol = params.currencySymbol,
|
|
254
|
+
parentProduct = params.parentProduct;
|
|
244
255
|
var bundles = Array.isArray(product.product_bundle) ? product.product_bundle : [];
|
|
245
256
|
return bundles.map(function (bundle) {
|
|
246
257
|
var _ref10, _bundle$num;
|
|
@@ -248,12 +259,14 @@ function normalizeProductCombinations(params) {
|
|
|
248
259
|
product: {},
|
|
249
260
|
locale: locale,
|
|
250
261
|
currencySymbol: currencySymbol,
|
|
251
|
-
options: Array.isArray(bundle.option) ? bundle.option : []
|
|
262
|
+
options: Array.isArray(bundle.option) ? bundle.option : [],
|
|
263
|
+
parentProduct: parentProduct
|
|
252
264
|
});
|
|
253
265
|
var baseTitle = resolveBundleProductTitle({
|
|
254
266
|
bundle: bundle,
|
|
255
267
|
productMap: productMap,
|
|
256
|
-
locale: locale
|
|
268
|
+
locale: locale,
|
|
269
|
+
parentProduct: parentProduct
|
|
257
270
|
});
|
|
258
271
|
var optionTitle = buildOptionTitleSuffix(combinationsOptions);
|
|
259
272
|
return {
|
|
@@ -265,16 +278,135 @@ function normalizeProductCombinations(params) {
|
|
|
265
278
|
});
|
|
266
279
|
}
|
|
267
280
|
function resolveBundleProductTitle(params) {
|
|
268
|
-
var
|
|
281
|
+
var _ref11, _ref12, _bundle$bundle_produc;
|
|
269
282
|
var bundle = params.bundle,
|
|
270
283
|
productMap = params.productMap,
|
|
271
|
-
locale = params.locale
|
|
272
|
-
|
|
284
|
+
locale = params.locale,
|
|
285
|
+
parentProduct = params.parentProduct;
|
|
286
|
+
var ownTitle = getProductTitleSource(bundle, locale);
|
|
273
287
|
if (ownTitle) return ownTitle;
|
|
288
|
+
var parentBundleItem = resolveBundleItemFromParentProduct({
|
|
289
|
+
bundle: bundle,
|
|
290
|
+
parentProduct: parentProduct
|
|
291
|
+
});
|
|
292
|
+
var parentBundleTitle = parentBundleItem ? getProductTitleSource(parentBundleItem, locale) : '';
|
|
293
|
+
if (parentBundleTitle) return parentBundleTitle;
|
|
274
294
|
var productId = (_ref11 = (_ref12 = (_bundle$bundle_produc = bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle._bundle_product_id) !== null && _ref12 !== void 0 ? _ref12 : bundle.product_id) !== null && _ref11 !== void 0 ? _ref11 : bundle.id;
|
|
275
|
-
var fallbackProduct = productId
|
|
295
|
+
var fallbackProduct = resolveProductFromMap(productId, productMap);
|
|
276
296
|
if (!fallbackProduct) return '';
|
|
277
|
-
return
|
|
297
|
+
return getProductTitleSource(fallbackProduct, locale);
|
|
298
|
+
}
|
|
299
|
+
function resolveProductFromMap(productId, productMap) {
|
|
300
|
+
if (productId === undefined || productId === null || productId === '') return null;
|
|
301
|
+
return productMap[productId] || productMap[String(productId)] || null;
|
|
302
|
+
}
|
|
303
|
+
function getProductTitleSource(source, locale) {
|
|
304
|
+
if (!source || _typeof(source) !== 'object') return '';
|
|
305
|
+
return resolveTitleValue(source.product_title, locale) || resolveTitleValue(source.title, locale) || resolveTitleValue(source.name, locale);
|
|
306
|
+
}
|
|
307
|
+
function resolveTitleValue(value, locale) {
|
|
308
|
+
var _ref13, _ref14, _value$locale;
|
|
309
|
+
if (value === undefined || value === null) return '';
|
|
310
|
+
if (_typeof(value) !== 'object') return stringify(value);
|
|
311
|
+
var dashedLocale = locale.replace('_', '-');
|
|
312
|
+
var underscoredLocale = locale.replace('-', '_');
|
|
313
|
+
return stringify((_ref13 = (_ref14 = (_value$locale = value[locale]) !== null && _value$locale !== void 0 ? _value$locale : value[dashedLocale]) !== null && _ref14 !== void 0 ? _ref14 : value[underscoredLocale]) !== null && _ref13 !== void 0 ? _ref13 : '');
|
|
314
|
+
}
|
|
315
|
+
function resolveOptionTitleFromParentProduct(params) {
|
|
316
|
+
var option = params.option,
|
|
317
|
+
parentProduct = params.parentProduct,
|
|
318
|
+
locale = params.locale;
|
|
319
|
+
if (!parentProduct) return '';
|
|
320
|
+
var optionItems = flattenOptionItems(parentProduct);
|
|
321
|
+
var matchedOption = optionItems.find(function (item) {
|
|
322
|
+
return isOptionItemMatch(option, item);
|
|
323
|
+
});
|
|
324
|
+
return getProductTitleSource(matchedOption, locale);
|
|
325
|
+
}
|
|
326
|
+
function flattenOptionItems(parentProduct) {
|
|
327
|
+
var optionGroups = Array.isArray(parentProduct.option_group) ? parentProduct.option_group : [];
|
|
328
|
+
return optionGroups.flatMap(function (group) {
|
|
329
|
+
var items = normalizeArray(group.option_item || group.option_items || group.option || group.options || group.items || group.children || group.product_option_item);
|
|
330
|
+
return items.map(function (item) {
|
|
331
|
+
var _ref15, _item$option_group_id;
|
|
332
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
333
|
+
option_group_id: (_ref15 = (_item$option_group_id = item.option_group_id) !== null && _item$option_group_id !== void 0 ? _item$option_group_id : group.id) !== null && _ref15 !== void 0 ? _ref15 : group.option_group_id
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
function isOptionItemMatch(option, item) {
|
|
339
|
+
var _ref16, _option$option_group_, _ref17, _item$option_group_it, _option$option_group_2, _item$option_group_id2;
|
|
340
|
+
var optionItemId = (_ref16 = (_option$option_group_ = option.option_group_item_id) !== null && _option$option_group_ !== void 0 ? _option$option_group_ : option.product_option_item_id) !== null && _ref16 !== void 0 ? _ref16 : option.id;
|
|
341
|
+
var itemId = (_ref17 = (_item$option_group_it = item.option_group_item_id) !== null && _item$option_group_it !== void 0 ? _item$option_group_it : item.product_option_item_id) !== null && _ref17 !== void 0 ? _ref17 : item.id;
|
|
342
|
+
if (!isSameId(optionItemId, itemId)) return false;
|
|
343
|
+
var optionGroupId = (_option$option_group_2 = option.option_group_id) !== null && _option$option_group_2 !== void 0 ? _option$option_group_2 : option.group_id;
|
|
344
|
+
var itemGroupId = (_item$option_group_id2 = item.option_group_id) !== null && _item$option_group_id2 !== void 0 ? _item$option_group_id2 : item.group_id;
|
|
345
|
+
if (isPresentId(optionGroupId) && isPresentId(itemGroupId)) {
|
|
346
|
+
return isSameId(optionGroupId, itemGroupId);
|
|
347
|
+
}
|
|
348
|
+
return true;
|
|
349
|
+
}
|
|
350
|
+
function resolveBundleItemFromParentProduct(params) {
|
|
351
|
+
var _ref18, _bundle$bundle_varian, _bundle$bundle_id, _bundle$bundle_group_, _ref20, _bundle$bundle_produc2;
|
|
352
|
+
var bundle = params.bundle,
|
|
353
|
+
parentProduct = params.parentProduct;
|
|
354
|
+
if (!parentProduct) return null;
|
|
355
|
+
var bundleItems = flattenBundleItems(parentProduct);
|
|
356
|
+
var bundleVariantId = (_ref18 = (_bundle$bundle_varian = bundle.bundle_variant_id) !== null && _bundle$bundle_varian !== void 0 ? _bundle$bundle_varian : bundle.variant_id) !== null && _ref18 !== void 0 ? _ref18 : bundle.product_variant_id;
|
|
357
|
+
if (isNonZeroId(bundleVariantId)) {
|
|
358
|
+
var matchedByVariant = bundleItems.find(function (item) {
|
|
359
|
+
var _ref19, _item$bundle_variant_;
|
|
360
|
+
return isSameId((_ref19 = (_item$bundle_variant_ = item.bundle_variant_id) !== null && _item$bundle_variant_ !== void 0 ? _item$bundle_variant_ : item.variant_id) !== null && _ref19 !== void 0 ? _ref19 : item.product_variant_id, bundleVariantId);
|
|
361
|
+
});
|
|
362
|
+
if (matchedByVariant) return matchedByVariant;
|
|
363
|
+
}
|
|
364
|
+
var bundleId = (_bundle$bundle_id = bundle.bundle_id) !== null && _bundle$bundle_id !== void 0 ? _bundle$bundle_id : bundle.id;
|
|
365
|
+
if (isPresentId(bundleId)) {
|
|
366
|
+
var matchedByBundleId = bundleItems.find(function (item) {
|
|
367
|
+
var _item$id;
|
|
368
|
+
return isSameId((_item$id = item.id) !== null && _item$id !== void 0 ? _item$id : item.bundle_id, bundleId);
|
|
369
|
+
});
|
|
370
|
+
if (matchedByBundleId) return matchedByBundleId;
|
|
371
|
+
}
|
|
372
|
+
var bundleGroupId = (_bundle$bundle_group_ = bundle.bundle_group_id) !== null && _bundle$bundle_group_ !== void 0 ? _bundle$bundle_group_ : bundle.group_id;
|
|
373
|
+
var bundleProductId = (_ref20 = (_bundle$bundle_produc2 = bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle._bundle_product_id) !== null && _ref20 !== void 0 ? _ref20 : bundle.product_id;
|
|
374
|
+
if (isPresentId(bundleGroupId) && isPresentId(bundleProductId)) {
|
|
375
|
+
var matchedByGroupAndProduct = bundleItems.find(function (item) {
|
|
376
|
+
var _item$group_id, _ref21, _item$bundle_product_;
|
|
377
|
+
return isSameId((_item$group_id = item.group_id) !== null && _item$group_id !== void 0 ? _item$group_id : item.bundle_group_id, bundleGroupId) && isSameId((_ref21 = (_item$bundle_product_ = item.bundle_product_id) !== null && _item$bundle_product_ !== void 0 ? _item$bundle_product_ : item._bundle_product_id) !== null && _ref21 !== void 0 ? _ref21 : item.product_id, bundleProductId);
|
|
378
|
+
});
|
|
379
|
+
if (matchedByGroupAndProduct) return matchedByGroupAndProduct;
|
|
380
|
+
}
|
|
381
|
+
if (isPresentId(bundleProductId)) {
|
|
382
|
+
return bundleItems.find(function (item) {
|
|
383
|
+
var _ref22, _item$bundle_product_2;
|
|
384
|
+
return isSameId((_ref22 = (_item$bundle_product_2 = item.bundle_product_id) !== null && _item$bundle_product_2 !== void 0 ? _item$bundle_product_2 : item._bundle_product_id) !== null && _ref22 !== void 0 ? _ref22 : item.product_id, bundleProductId);
|
|
385
|
+
}) || null;
|
|
386
|
+
}
|
|
387
|
+
return null;
|
|
388
|
+
}
|
|
389
|
+
function flattenBundleItems(parentProduct) {
|
|
390
|
+
var bundleGroups = Array.isArray(parentProduct.bundle_group) ? parentProduct.bundle_group : [];
|
|
391
|
+
return bundleGroups.flatMap(function (group) {
|
|
392
|
+
var items = Array.isArray(group.bundle_item) ? group.bundle_item : [];
|
|
393
|
+
return items.map(function (item) {
|
|
394
|
+
var _ref23, _item$group_id2;
|
|
395
|
+
return _objectSpread(_objectSpread({}, item), {}, {
|
|
396
|
+
group_id: (_ref23 = (_item$group_id2 = item.group_id) !== null && _item$group_id2 !== void 0 ? _item$group_id2 : group.id) !== null && _ref23 !== void 0 ? _ref23 : group.group_id
|
|
397
|
+
});
|
|
398
|
+
});
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
function isNonZeroId(value) {
|
|
402
|
+
return isPresentId(value) && String(value) !== '0';
|
|
403
|
+
}
|
|
404
|
+
function isPresentId(value) {
|
|
405
|
+
return value !== undefined && value !== null && value !== '';
|
|
406
|
+
}
|
|
407
|
+
function isSameId(left, right) {
|
|
408
|
+
if (!isPresentId(left) || !isPresentId(right)) return false;
|
|
409
|
+
return String(left) === String(right);
|
|
278
410
|
}
|
|
279
411
|
function buildOptionTitleSuffix(options) {
|
|
280
412
|
var text = options.map(function (option) {
|
|
@@ -287,8 +419,8 @@ function buildOptionTitleSuffix(options) {
|
|
|
287
419
|
return text ? "(".concat(text, ")") : '';
|
|
288
420
|
}
|
|
289
421
|
function formatBundlePrice(bundle, currencySymbol) {
|
|
290
|
-
var
|
|
291
|
-
var value = (
|
|
422
|
+
var _ref24, _ref25, _bundle$bundle_sellin;
|
|
423
|
+
var value = (_ref24 = (_ref25 = (_bundle$bundle_sellin = bundle.bundle_selling_price) !== null && _bundle$bundle_sellin !== void 0 ? _bundle$bundle_sellin : bundle.bundle_sum_price) !== null && _ref25 !== void 0 ? _ref25 : bundle.price) !== null && _ref24 !== void 0 ? _ref24 : 0;
|
|
292
424
|
var amount = new Decimal(toMoneyNumber(value));
|
|
293
425
|
var isNegative = bundle.price_type === 'markdown' || bundle.price_type === 'markup' && bundle.price_type_ext === 'product_price';
|
|
294
426
|
if (isNegative) return "-".concat(currencySymbol).concat(amount.abs().toFixed(2));
|
|
@@ -303,9 +435,9 @@ function buildFees(params) {
|
|
|
303
435
|
currencySymbol = params.currencySymbol;
|
|
304
436
|
var fees = [];
|
|
305
437
|
for (var _i = 0, _normalizeArray = normalizeArray(order.surcharges || summary.surcharges); _i < _normalizeArray.length; _i++) {
|
|
306
|
-
var
|
|
438
|
+
var _ref26, _surcharge$amount;
|
|
307
439
|
var surcharge = _normalizeArray[_i];
|
|
308
|
-
var value = (
|
|
440
|
+
var value = (_ref26 = (_surcharge$amount = surcharge.amount) !== null && _surcharge$amount !== void 0 ? _surcharge$amount : surcharge.value) !== null && _ref26 !== void 0 ? _ref26 : surcharge.total_amount;
|
|
309
441
|
if (!isNonZero(value)) continue;
|
|
310
442
|
fees.push({
|
|
311
443
|
item: getLocalizedValue(surcharge.name || surcharge.title || surcharge.item, locale),
|
|
@@ -440,8 +572,8 @@ function buildPaymentData(params) {
|
|
|
440
572
|
currencySymbol: params.currencySymbol
|
|
441
573
|
})));
|
|
442
574
|
} else {
|
|
443
|
-
var
|
|
444
|
-
var remainingAmount = (
|
|
575
|
+
var _ref27, _payment$remaining_am, _payment$metadata;
|
|
576
|
+
var remainingAmount = (_ref27 = (_payment$remaining_am = payment.remaining_amount) !== null && _payment$remaining_am !== void 0 ? _payment$remaining_am : payment.balance) !== null && _ref27 !== void 0 ? _ref27 : (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.remaining_amount;
|
|
445
577
|
if (remainingAmount !== undefined && remainingAmount !== null) {
|
|
446
578
|
items.push({
|
|
447
579
|
item: label(params.locale, 'remainingAmount'),
|
|
@@ -549,13 +681,11 @@ function label(locale, key) {
|
|
|
549
681
|
return ((_LABELS$locale = LABELS[locale]) === null || _LABELS$locale === void 0 ? void 0 : _LABELS$locale[key]) || LABELS.en[key] || key;
|
|
550
682
|
}
|
|
551
683
|
function getLocalizedValue(value, locale) {
|
|
552
|
-
var
|
|
684
|
+
var _ref28, _ref29, _ref30, _value$locale2;
|
|
553
685
|
if (value === undefined || value === null) return '';
|
|
554
686
|
if (_typeof(value) !== 'object') return stringify(value);
|
|
555
687
|
var dashedLocale = locale.replace('_', '-');
|
|
556
|
-
return stringify((
|
|
557
|
-
return typeof item === 'string' || typeof item === 'number';
|
|
558
|
-
})) !== null && _ref17 !== void 0 ? _ref17 : '');
|
|
688
|
+
return stringify((_ref28 = (_ref29 = (_ref30 = (_value$locale2 = value[locale]) !== null && _value$locale2 !== void 0 ? _value$locale2 : value[dashedLocale]) !== null && _ref30 !== void 0 ? _ref30 : value.default) !== null && _ref29 !== void 0 ? _ref29 : value.en) !== null && _ref28 !== void 0 ? _ref28 : '');
|
|
559
689
|
}
|
|
560
690
|
function serviceTypeToLabelKey(serviceType) {
|
|
561
691
|
var normalized = serviceType.toLowerCase();
|
|
@@ -83,6 +83,23 @@ export declare class BaseSalesImpl extends BaseModule implements Module {
|
|
|
83
83
|
*/
|
|
84
84
|
protected createSubModule(moduleName: string): Module | null;
|
|
85
85
|
protected getSubModuleHooks(moduleName: string): any;
|
|
86
|
+
/**
|
|
87
|
+
* 构造传给 BaseSales 子模块的完整运行态参数,保证初始化和后续同步语义一致。
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* const params = this.buildSubModuleOtherParams();
|
|
91
|
+
* this.core.registerModule(orderModule, { otherParams: params });
|
|
92
|
+
*/
|
|
93
|
+
protected buildSubModuleOtherParams(): Record<string, any>;
|
|
94
|
+
/**
|
|
95
|
+
* 将父级 otherParams 的变更显式同步给已注册的子模块。
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* await this.syncOtherParamsToSubModules({ channel: 'pos' });
|
|
99
|
+
*/
|
|
100
|
+
protected syncOtherParamsToSubModules(changedParams: Record<string, any>, { cover }?: {
|
|
101
|
+
cover?: boolean;
|
|
102
|
+
}): Promise<void>;
|
|
86
103
|
/**
|
|
87
104
|
* 读取 sessionStorage[this.name][cacheId],作为子模块 initialState 的来源。
|
|
88
105
|
* sessionStorage 损坏时静默忽略,按空状态注册。
|