@pisell/pisellos 0.0.511 → 0.0.513
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/Order/index.d.ts +1 -1
- package/dist/modules/Order/index.js +79 -58
- package/dist/modules/Order/types.d.ts +11 -0
- package/dist/modules/Order/utils.d.ts +63 -11
- package/dist/modules/Order/utils.js +242 -43
- package/dist/modules/SalesSummary/utils.js +36 -69
- package/dist/modules/Summary/utils.js +6 -21
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -1
- package/dist/solution/ScanOrder/index.d.ts +3 -0
- package/dist/solution/ScanOrder/index.js +558 -498
- package/dist/solution/ScanOrder/types.d.ts +29 -2
- package/dist/solution/ScanOrder/utils.d.ts +18 -2
- package/dist/solution/ScanOrder/utils.js +111 -29
- package/dist/solution/VenueBooking/index.js +35 -27
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Order/index.js +20 -7
- package/lib/modules/Order/types.d.ts +11 -0
- package/lib/modules/Order/utils.d.ts +63 -11
- package/lib/modules/Order/utils.js +149 -17
- package/lib/modules/SalesSummary/utils.js +16 -48
- package/lib/modules/Summary/utils.js +4 -18
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -1
- package/lib/solution/ScanOrder/index.d.ts +3 -0
- package/lib/solution/ScanOrder/index.js +30 -4
- package/lib/solution/ScanOrder/types.d.ts +29 -2
- package/lib/solution/ScanOrder/utils.d.ts +18 -2
- package/lib/solution/ScanOrder/utils.js +66 -15
- package/lib/solution/VenueBooking/index.js +13 -6
- package/package.json +1 -1
|
@@ -61,6 +61,7 @@ __export(utils_exports, {
|
|
|
61
61
|
});
|
|
62
62
|
module.exports = __toCommonJS(utils_exports);
|
|
63
63
|
var import_dayjs = __toESM(require("dayjs"));
|
|
64
|
+
var import_decimal = __toESM(require("decimal.js"));
|
|
64
65
|
var import_utils = require("../../modules/Order/utils");
|
|
65
66
|
function createEmptySummary() {
|
|
66
67
|
return {
|
|
@@ -405,31 +406,81 @@ function normalizeOrderProduct(product) {
|
|
|
405
406
|
if (!metadata.unique_identification_number) {
|
|
406
407
|
metadata.unique_identification_number = resolvedIdentityKey;
|
|
407
408
|
}
|
|
408
|
-
const resolvedSellingPrice = product.selling_price || "0.00";
|
|
409
|
-
const resolvedOriginalPrice = product.original_price || resolvedSellingPrice;
|
|
410
|
-
if (metadata.main_product_original_price === void 0) {
|
|
411
|
-
metadata.main_product_original_price = resolvedOriginalPrice;
|
|
412
|
-
}
|
|
413
|
-
if (metadata.main_product_selling_price === void 0) {
|
|
414
|
-
metadata.main_product_selling_price = resolvedSellingPrice;
|
|
415
|
-
}
|
|
416
|
-
if (metadata.source_product_price === void 0) {
|
|
417
|
-
metadata.source_product_price = ((_a = product._origin) == null ? void 0 : _a.price) ?? ((_b = product._origin) == null ? void 0 : _b.base_price) ?? resolvedSellingPrice;
|
|
418
|
-
}
|
|
419
409
|
const normalizedBundle = (product.product_bundle || []).map((item) => ({
|
|
420
410
|
...item,
|
|
421
411
|
bundle_selling_price: item.bundle_selling_price ?? item.price ?? "0.00",
|
|
422
412
|
custom_price: item.custom_price ?? item.bundle_selling_price ?? item.price ?? "0.00"
|
|
423
413
|
}));
|
|
414
|
+
const normalizedOptions = product.product_option_item || [];
|
|
415
|
+
const optionSum = (0, import_utils.sumOptionUnitPrice)(normalizedOptions);
|
|
416
|
+
const isV2 = metadata.price_schema_version === 2 || metadata.price_schema_version === "2";
|
|
417
|
+
const variantId = Number(product.product_variant_id || 0);
|
|
418
|
+
const variantList = variantId ? (_a = metadata == null ? void 0 : metadata.origin) == null ? void 0 : _a.variant : null;
|
|
419
|
+
const variantPrice = Array.isArray(variantList) ? (_b = variantList.find((v) => Number(v == null ? void 0 : v.id) === variantId)) == null ? void 0 : _b.price : void 0;
|
|
420
|
+
const resolvedSource = (() => {
|
|
421
|
+
var _a2, _b2;
|
|
422
|
+
if (metadata.source_product_price !== void 0) {
|
|
423
|
+
return String(metadata.source_product_price);
|
|
424
|
+
}
|
|
425
|
+
if (variantPrice !== void 0 && variantPrice !== null) {
|
|
426
|
+
return String(variantPrice);
|
|
427
|
+
}
|
|
428
|
+
const originPrice = (_a2 = product._origin) == null ? void 0 : _a2.price;
|
|
429
|
+
if (originPrice !== void 0 && originPrice !== null) {
|
|
430
|
+
return String(originPrice);
|
|
431
|
+
}
|
|
432
|
+
const originBasePrice = (_b2 = product._origin) == null ? void 0 : _b2.base_price;
|
|
433
|
+
if (originBasePrice !== void 0 && originBasePrice !== null) {
|
|
434
|
+
return String(originBasePrice);
|
|
435
|
+
}
|
|
436
|
+
if (!isV2 && metadata.main_product_original_price !== void 0) {
|
|
437
|
+
return String(metadata.main_product_original_price);
|
|
438
|
+
}
|
|
439
|
+
return product.original_price ?? product.selling_price ?? "0.00";
|
|
440
|
+
})();
|
|
441
|
+
const mainOriginalDec = new import_decimal.default(Number(resolvedSource) || 0).plus(optionSum);
|
|
442
|
+
const mainOriginalStr = mainOriginalDec.toDecimalPlaces(2).toFixed(2);
|
|
443
|
+
let mainSellingDec;
|
|
444
|
+
if (isV2 && metadata.main_product_selling_price != null) {
|
|
445
|
+
mainSellingDec = new import_decimal.default(Number(metadata.main_product_selling_price) || 0);
|
|
446
|
+
} else if (metadata.main_product_selling_price != null && metadata.main_product_original_price != null) {
|
|
447
|
+
const legacyOriginal = new import_decimal.default(Number(metadata.main_product_original_price) || 0);
|
|
448
|
+
const legacySelling = new import_decimal.default(Number(metadata.main_product_selling_price) || 0);
|
|
449
|
+
const legacyDiscount = legacyOriginal.minus(legacySelling);
|
|
450
|
+
mainSellingDec = mainOriginalDec.minus(legacyDiscount);
|
|
451
|
+
} else if (product.original_price != null && product.selling_price != null && new import_decimal.default(Number(product.original_price) || 0).greaterThan(
|
|
452
|
+
new import_decimal.default(Number(product.selling_price) || 0)
|
|
453
|
+
)) {
|
|
454
|
+
const topOriginal = new import_decimal.default(Number(product.original_price) || 0);
|
|
455
|
+
const topSelling = new import_decimal.default(Number(product.selling_price) || 0);
|
|
456
|
+
const legacyDiscount = topOriginal.minus(topSelling);
|
|
457
|
+
mainSellingDec = mainOriginalDec.minus(legacyDiscount);
|
|
458
|
+
} else {
|
|
459
|
+
mainSellingDec = mainOriginalDec;
|
|
460
|
+
}
|
|
461
|
+
const mainSellingStr = mainSellingDec.toDecimalPlaces(2).toFixed(2);
|
|
462
|
+
metadata.source_product_price = resolvedSource;
|
|
463
|
+
metadata.main_product_original_price = mainOriginalStr;
|
|
464
|
+
metadata.main_product_selling_price = mainSellingStr;
|
|
465
|
+
metadata.price_schema_version = 2;
|
|
466
|
+
const composedSellingPrice = (0, import_utils.composeLinePrice)({
|
|
467
|
+
mainPrice: mainSellingStr,
|
|
468
|
+
bundle: normalizedBundle
|
|
469
|
+
});
|
|
470
|
+
const composedOriginalPrice = (0, import_utils.composeLinePrice)({
|
|
471
|
+
mainPrice: mainOriginalStr,
|
|
472
|
+
bundle: normalizedBundle,
|
|
473
|
+
useOriginalBundle: true
|
|
474
|
+
});
|
|
424
475
|
return {
|
|
425
476
|
order_detail_id: product.order_detail_id || null,
|
|
426
477
|
product_id: product.product_id,
|
|
427
478
|
num: getSafeProductNum(product.num),
|
|
428
479
|
product_variant_id: product.product_variant_id,
|
|
429
480
|
identity_key: resolvedIdentityKey,
|
|
430
|
-
product_option_item:
|
|
431
|
-
selling_price:
|
|
432
|
-
original_price:
|
|
481
|
+
product_option_item: normalizedOptions,
|
|
482
|
+
selling_price: composedSellingPrice,
|
|
483
|
+
original_price: composedOriginalPrice,
|
|
433
484
|
tax_fee: product.tax_fee || "0.00",
|
|
434
485
|
is_charge_tax: product.is_charge_tax ?? 0,
|
|
435
486
|
discount_list: product.discount_list || [],
|
|
@@ -497,7 +548,7 @@ function computeResourceIsFull(params) {
|
|
|
497
548
|
occupied += pax;
|
|
498
549
|
}
|
|
499
550
|
}
|
|
500
|
-
return occupied
|
|
551
|
+
return occupied >= totalCapacity;
|
|
501
552
|
}
|
|
502
553
|
function pickFirstCustomCapacityPaxBounds(products) {
|
|
503
554
|
for (const p of products) {
|
|
@@ -1244,7 +1244,7 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1244
1244
|
}
|
|
1245
1245
|
/** 勾选/取消勾选某张折扣券,重新计算折扣并持久化 */
|
|
1246
1246
|
async setDiscountSelected(params) {
|
|
1247
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1247
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1248
1248
|
this.logMethodStart("setDiscountSelected", params);
|
|
1249
1249
|
try {
|
|
1250
1250
|
if (!this.store.order)
|
|
@@ -1311,11 +1311,18 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1311
1311
|
(sum, pd) => sum + (pd.amount || 0),
|
|
1312
1312
|
0
|
|
1313
1313
|
);
|
|
1314
|
-
const
|
|
1315
|
-
product.
|
|
1314
|
+
const optionSum = (0, import_utils3.sumOptionUnitPrice)(product.product_option_item);
|
|
1315
|
+
const sourcePrice = ((_d = product.metadata) == null ? void 0 : _d.source_product_price) ?? (((_e = product.metadata) == null ? void 0 : _e.main_product_original_price) != null ? new import_decimal.default(Number(product.metadata.main_product_original_price) || 0).minus(optionSum).toFixed(2) : product.original_price ?? "0");
|
|
1316
|
+
const newSourceSellingPrice = new import_decimal.default(Number(sourcePrice) || 0).minus(totalPerUnitDiscount).toDecimalPlaces(2).toString();
|
|
1317
|
+
const newMainSellingPrice = new import_decimal.default(Number(newSourceSellingPrice) || 0).plus(optionSum).toDecimalPlaces(2).toFixed(2);
|
|
1316
1318
|
if (product.metadata) {
|
|
1317
|
-
product.metadata.main_product_selling_price =
|
|
1319
|
+
product.metadata.main_product_selling_price = newMainSellingPrice;
|
|
1320
|
+
product.metadata.price_schema_version = 2;
|
|
1318
1321
|
}
|
|
1322
|
+
product.selling_price = (0, import_utils3.composeLinePrice)({
|
|
1323
|
+
mainPrice: newMainSellingPrice,
|
|
1324
|
+
bundle: product.product_bundle
|
|
1325
|
+
});
|
|
1319
1326
|
}
|
|
1320
1327
|
import_Order.OrderModule.populateSavedAmounts(tempOrder.products, nextDiscountList);
|
|
1321
1328
|
await (discountModule == null ? void 0 : discountModule.setDiscountList(nextDiscountList));
|
|
@@ -1323,8 +1330,8 @@ var _VenueBookingImpl = class extends import_BaseModule.BaseModule {
|
|
|
1323
1330
|
const afterApplyTarget = this.store.order.getDiscountList().find((d) => d.id === params.discountId) || null;
|
|
1324
1331
|
await this.store.order.recalculateSummary({ createIfMissing: true });
|
|
1325
1332
|
this.store.order.persistTempOrder();
|
|
1326
|
-
const finalSummary = ((
|
|
1327
|
-
const finalProduct = ((
|
|
1333
|
+
const finalSummary = ((_f = this.store.order.getTempOrder()) == null ? void 0 : _f.summary) || null;
|
|
1334
|
+
const finalProduct = ((_h = (_g = this.store.order.getTempOrder()) == null ? void 0 : _g.products) == null ? void 0 : _h[0]) || null;
|
|
1328
1335
|
this.logMethodSuccess("setDiscountSelected", params);
|
|
1329
1336
|
const finalTarget = this.store.order.getDiscountList().find((d) => d.id === params.discountId) || null;
|
|
1330
1337
|
return this.store.order.getDiscountList();
|