@pisell/pisellos 2.1.161 → 2.1.162
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.
|
@@ -33,6 +33,8 @@ interface Limitedrelationproductdata {
|
|
|
33
33
|
product_ids: number[];
|
|
34
34
|
product_collection_id: number[];
|
|
35
35
|
package_sub_item_usage_rules?: PackageSubItemUsageRules;
|
|
36
|
+
exclude_product_ids?: number[];
|
|
37
|
+
filter?: 0 | 1;
|
|
36
38
|
}
|
|
37
39
|
interface ApplicableProductDetails {
|
|
38
40
|
amount: string;
|
|
@@ -538,6 +538,15 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
538
538
|
return priceB.minus(priceA).toNumber();
|
|
539
539
|
});
|
|
540
540
|
|
|
541
|
+
// 检查商品是否被排除(全品类)
|
|
542
|
+
var isProductIncludedByLimitedData = function isProductIncludedByLimitedData(limitedData, productId) {
|
|
543
|
+
var excludedIds = (limitedData === null || limitedData === void 0 ? void 0 : limitedData.exclude_product_ids) || [];
|
|
544
|
+
var isExcluded = (limitedData === null || limitedData === void 0 ? void 0 : limitedData.filter) === 1 && excludedIds.some(function (id) {
|
|
545
|
+
return String(id) === String(productId);
|
|
546
|
+
});
|
|
547
|
+
return !isExcluded;
|
|
548
|
+
};
|
|
549
|
+
|
|
541
550
|
/**
|
|
542
551
|
// 对productList按价格降序排序(用于应用优惠券时优先选择高价商品) 价格相同时使用quantity 排序
|
|
543
552
|
const sortedProductList = [...productList].sort((a, b) => {
|
|
@@ -926,6 +935,10 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
926
935
|
|
|
927
936
|
// 判断优惠券是否适用于该商品
|
|
928
937
|
if (limitedData.type === 'product_all') {
|
|
938
|
+
if (!isProductIncludedByLimitedData(limitedData, product.id)) {
|
|
939
|
+
return false;
|
|
940
|
+
}
|
|
941
|
+
|
|
929
942
|
// 检查 package_sub_item_usage_rules
|
|
930
943
|
if (!_this3.checkPackageSubItemUsageRules(discount, flatItem)) {
|
|
931
944
|
return false;
|
|
@@ -595,6 +595,27 @@ export var calculateTaxFee = function calculateTaxFee(shopInfo, items) {
|
|
|
595
595
|
}, new Decimal(0));
|
|
596
596
|
return totalTaxFee;
|
|
597
597
|
};
|
|
598
|
+
var getCartItemDepositData = function getCartItemDepositData(item) {
|
|
599
|
+
var _target$_productOrigi, _target$_origin, _target$_origin2;
|
|
600
|
+
var target = item;
|
|
601
|
+
return (target === null || target === void 0 || (_target$_productOrigi = target._productOrigin) === null || _target$_productOrigi === void 0 ? void 0 : _target$_productOrigi.custom_deposit_data) || (target === null || target === void 0 || (_target$_origin = target._origin) === null || _target$_origin === void 0 ? void 0 : _target$_origin.custom_deposit_data) || (target === null || target === void 0 || (_target$_origin2 = target._origin) === null || _target$_origin2 === void 0 || (_target$_origin2 = _target$_origin2.product) === null || _target$_origin2 === void 0 ? void 0 : _target$_origin2.custom_deposit_data);
|
|
602
|
+
};
|
|
603
|
+
var getCartItemQuantity = function getCartItemQuantity(item) {
|
|
604
|
+
return new Decimal((item === null || item === void 0 ? void 0 : item.num) || 1);
|
|
605
|
+
};
|
|
606
|
+
var calculateCartItemDepositTotal = function calculateCartItemDepositTotal(item) {
|
|
607
|
+
var _item$deposit;
|
|
608
|
+
var depositData = getCartItemDepositData(item);
|
|
609
|
+
if ((depositData === null || depositData === void 0 ? void 0 : depositData.has_deposit) == 1 && typeof (depositData === null || depositData === void 0 ? void 0 : depositData.deposit_fixed) === 'string' && typeof (depositData === null || depositData === void 0 ? void 0 : depositData.deposit_percentage) === 'string') {
|
|
610
|
+
var _ref7, _summaryTotal;
|
|
611
|
+
var lineTotal = new Decimal((_ref7 = (_summaryTotal = item.summaryTotal) !== null && _summaryTotal !== void 0 ? _summaryTotal : item.total) !== null && _ref7 !== void 0 ? _ref7 : 0);
|
|
612
|
+
var quantity = getCartItemQuantity(item);
|
|
613
|
+
var fixedTotal = new Decimal(depositData.deposit_fixed || 0).times(quantity);
|
|
614
|
+
var percentageTotal = new Decimal(depositData.deposit_percentage || 0).times(lineTotal);
|
|
615
|
+
return fixedTotal.plus(percentageTotal);
|
|
616
|
+
}
|
|
617
|
+
return new Decimal((item === null || item === void 0 || (_item$deposit = item.deposit) === null || _item$deposit === void 0 ? void 0 : _item$deposit.total) || 0);
|
|
618
|
+
};
|
|
598
619
|
|
|
599
620
|
/**
|
|
600
621
|
* @title: 计算定金
|
|
@@ -609,9 +630,9 @@ export var calculateDeposit = function calculateDeposit(items) {
|
|
|
609
630
|
var hasDeposit = false;
|
|
610
631
|
var total = items.reduce(function (sum, item) {
|
|
611
632
|
if (item !== null && item !== void 0 && item.deposit) {
|
|
612
|
-
var _item$
|
|
633
|
+
var _item$deposit2;
|
|
613
634
|
hasDeposit = true;
|
|
614
|
-
var cartItemTotalPrice =
|
|
635
|
+
var cartItemTotalPrice = calculateCartItemDepositTotal(item);
|
|
615
636
|
// 将协议数据去重合并
|
|
616
637
|
item === null || item === void 0 || (_item$deposit2 = item.deposit) === null || _item$deposit2 === void 0 || (_item$deposit2 = _item$deposit2.protocols) === null || _item$deposit2 === void 0 || _item$deposit2.forEach(function (protocol) {
|
|
617
638
|
if (protocols.findIndex(function (p) {
|
|
@@ -648,9 +669,9 @@ export var calculateDeposit = function calculateDeposit(items) {
|
|
|
648
669
|
* @param options.isEdit 是否处于“编辑中”。`false` 时会优先走后端金额直取逻辑(若存在)
|
|
649
670
|
* @returns 订单附加费金额(number,金额单位与商品价格一致)
|
|
650
671
|
*/
|
|
651
|
-
export var getSurchargeAmount = function getSurchargeAmount(
|
|
652
|
-
var bookingDetail =
|
|
653
|
-
bookingId =
|
|
672
|
+
export var getSurchargeAmount = function getSurchargeAmount(_ref8, surcharge, options) {
|
|
673
|
+
var bookingDetail = _ref8.bookingDetail,
|
|
674
|
+
bookingId = _ref8.bookingId;
|
|
654
675
|
var isEdit = options.isEdit;
|
|
655
676
|
// 订单未变更过
|
|
656
677
|
if (!isEdit) {
|
|
@@ -695,17 +716,17 @@ var getDiscountAmount = function getDiscountAmount(discounts) {
|
|
|
695
716
|
* 获取主商品加价减价后的总价 (主商品价格 + 子商品加价减价)
|
|
696
717
|
*/
|
|
697
718
|
var getMainProductTotal = function getMainProductTotal(item) {
|
|
698
|
-
var
|
|
719
|
+
var _ref9, _ref10, _item$main_product_se, _item$metadata, _item$metadata2, _item$metadata3, _item$metadata4;
|
|
699
720
|
// 新语义 v2 下 `main_product_selling_price` / `metadata.main_product_selling_price`
|
|
700
721
|
// 已经是"含 option、含主商品折扣"的主价,直接作为主商品基准,无需再减折扣或加 option。
|
|
701
722
|
// 仅需叠加 markup / markdown 类 bundle(原价 bundle 的税费单独处理)。
|
|
702
|
-
var total = new Decimal((
|
|
723
|
+
var total = new Decimal((_ref9 = (_ref10 = (_item$main_product_se = item === null || item === void 0 ? void 0 : item.main_product_selling_price) !== null && _item$main_product_se !== void 0 ? _item$main_product_se : item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata.main_product_selling_price) !== null && _ref10 !== void 0 ? _ref10 : item === null || item === void 0 || (_item$metadata2 = item.metadata) === null || _item$metadata2 === void 0 ? void 0 : _item$metadata2.main_product_original_price) !== null && _ref9 !== void 0 ? _ref9 : 0);
|
|
703
724
|
|
|
704
725
|
// 做个兜底 如果新语义价格字段都没有,则切换回老逻辑
|
|
705
726
|
var hasMainProductPrice = (item === null || item === void 0 ? void 0 : item.main_product_selling_price) != null || (item === null || item === void 0 || (_item$metadata3 = item.metadata) === null || _item$metadata3 === void 0 ? void 0 : _item$metadata3.main_product_selling_price) != null || (item === null || item === void 0 || (_item$metadata4 = item.metadata) === null || _item$metadata4 === void 0 ? void 0 : _item$metadata4.main_product_original_price) != null;
|
|
706
727
|
if (!hasMainProductPrice) {
|
|
707
|
-
var
|
|
708
|
-
total = new Decimal((
|
|
728
|
+
var _ref11, _ref12, _item$main_product_se2, _item$metadata5, _item$_origin3, _item$_originData;
|
|
729
|
+
total = new Decimal((_ref11 = (_ref12 = (_item$main_product_se2 = item === null || item === void 0 ? void 0 : item.main_product_selling_price) !== null && _item$main_product_se2 !== void 0 ? _item$main_product_se2 : item === null || item === void 0 || (_item$metadata5 = item.metadata) === null || _item$metadata5 === void 0 ? void 0 : _item$metadata5.main_product_selling_price) !== null && _ref12 !== void 0 ? _ref12 : item.price) !== null && _ref11 !== void 0 ? _ref11 : 0);
|
|
709
730
|
var discount = (item === null || item === void 0 || (_item$_origin3 = item._origin) === null || _item$_origin3 === void 0 || (_item$_origin3 = _item$_origin3.product) === null || _item$_origin3 === void 0 ? void 0 : _item$_origin3.discount_list) || (item === null || item === void 0 || (_item$_originData = item._originData) === null || _item$_originData === void 0 || (_item$_originData = _item$_originData.product) === null || _item$_originData === void 0 || (_item$_originData = _item$_originData.discount_list) === null || _item$_originData === void 0 ? void 0 : _item$_originData.filter(function (item) {
|
|
710
731
|
var _item$metadata6;
|
|
711
732
|
return !(item !== null && item !== void 0 && (_item$metadata6 = item.metadata) !== null && _item$metadata6 !== void 0 && _item$metadata6.custom_product_bundle_map_id);
|
|
@@ -726,9 +747,9 @@ var getMainProductTotal = function getMainProductTotal(item) {
|
|
|
726
747
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
727
748
|
var bundleItem = _step4.value;
|
|
728
749
|
if (getBundleItemIsMarkupOrDiscountPrice(bundleItem)) {
|
|
729
|
-
var
|
|
750
|
+
var _ref13, _bundleItem$bundle_se2;
|
|
730
751
|
// IMPORTANT: 套餐子商品如果应用了 discount,bundle_selling_price 和 price 其实都已经是折后价格了,不需要单独再减一次
|
|
731
|
-
var bundleItemTotal = new Decimal((
|
|
752
|
+
var bundleItemTotal = new Decimal((_ref13 = (_bundleItem$bundle_se2 = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se2 !== void 0 ? _bundleItem$bundle_se2 : bundleItem.price) !== null && _ref13 !== void 0 ? _ref13 : 0);
|
|
732
753
|
total = total.add(bundleItemTotal);
|
|
733
754
|
}
|
|
734
755
|
}
|
|
@@ -848,12 +869,12 @@ var isProductMatchSurchargeCondition = function isProductMatchSurchargeCondition
|
|
|
848
869
|
* @param options.scheduleById schedule 映射表:`{ [scheduleId]: schedule }`(用于根据配置的 `available_schedule_ids` 做日程匹配)
|
|
849
870
|
* @returns 附加费列表(仅返回金额 > 0 的项)
|
|
850
871
|
*/
|
|
851
|
-
export var getSurcharge = function getSurcharge(
|
|
872
|
+
export var getSurcharge = function getSurcharge(_ref14, options) {
|
|
852
873
|
var _service$filter;
|
|
853
|
-
var service =
|
|
854
|
-
addons =
|
|
855
|
-
bookingDetail =
|
|
856
|
-
bookingId =
|
|
874
|
+
var service = _ref14.service,
|
|
875
|
+
addons = _ref14.addons,
|
|
876
|
+
bookingDetail = _ref14.bookingDetail,
|
|
877
|
+
bookingId = _ref14.bookingId;
|
|
857
878
|
var isEdit = options.isEdit,
|
|
858
879
|
isInScheduleByDate = options.isInScheduleByDate,
|
|
859
880
|
surcharge_list = options.surcharge_list,
|
|
@@ -975,11 +996,11 @@ export var getSurcharge = function getSurcharge(_ref13, options) {
|
|
|
975
996
|
scheduleById: scheduleById || {},
|
|
976
997
|
isInScheduleByDate: isInScheduleByDate
|
|
977
998
|
})) {
|
|
978
|
-
var
|
|
999
|
+
var _ref15, _bundleItem$bundle_se3;
|
|
979
1000
|
var _mainQuantity = item.num || 1;
|
|
980
1001
|
matchedItems.push({
|
|
981
1002
|
isMain: false,
|
|
982
|
-
total: Number((
|
|
1003
|
+
total: Number((_ref15 = (_bundleItem$bundle_se3 = bundleItem.bundle_selling_price) !== null && _bundleItem$bundle_se3 !== void 0 ? _bundleItem$bundle_se3 : bundleItem.price) !== null && _ref15 !== void 0 ? _ref15 : 0),
|
|
983
1004
|
quantity: bundleItem.num || bundleItem.quantity || 1,
|
|
984
1005
|
item: bundleItem,
|
|
985
1006
|
mainQuantity: _mainQuantity // 子商品的mainQuantity是所属主商品的quantity
|
|
@@ -1195,9 +1216,9 @@ export var getSurcharge = function getSurcharge(_ref13, options) {
|
|
|
1195
1216
|
}
|
|
1196
1217
|
return surchargeWithAmount;
|
|
1197
1218
|
};
|
|
1198
|
-
function resetItemsSurchargeSideEffects(
|
|
1199
|
-
var service =
|
|
1200
|
-
addons =
|
|
1219
|
+
function resetItemsSurchargeSideEffects(_ref16) {
|
|
1220
|
+
var service = _ref16.service,
|
|
1221
|
+
addons = _ref16.addons;
|
|
1201
1222
|
var resetItem = function resetItem(item) {
|
|
1202
1223
|
if (!item) return;
|
|
1203
1224
|
item.surcharge_fee = 0;
|
|
@@ -33,6 +33,8 @@ interface Limitedrelationproductdata {
|
|
|
33
33
|
product_ids: number[];
|
|
34
34
|
product_collection_id: number[];
|
|
35
35
|
package_sub_item_usage_rules?: PackageSubItemUsageRules;
|
|
36
|
+
exclude_product_ids?: number[];
|
|
37
|
+
filter?: 0 | 1;
|
|
36
38
|
}
|
|
37
39
|
interface ApplicableProductDetails {
|
|
38
40
|
amount: string;
|
|
@@ -362,6 +362,11 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
362
362
|
}
|
|
363
363
|
return priceB.minus(priceA).toNumber();
|
|
364
364
|
});
|
|
365
|
+
const isProductIncludedByLimitedData = (limitedData, productId) => {
|
|
366
|
+
const excludedIds = (limitedData == null ? void 0 : limitedData.exclude_product_ids) || [];
|
|
367
|
+
const isExcluded = (limitedData == null ? void 0 : limitedData.filter) === 1 && excludedIds.some((id) => String(id) === String(productId));
|
|
368
|
+
return !isExcluded;
|
|
369
|
+
};
|
|
365
370
|
const usedDiscounts = /* @__PURE__ */ new Map();
|
|
366
371
|
const discountApplicability = /* @__PURE__ */ new Map();
|
|
367
372
|
const discountApplicableProducts = /* @__PURE__ */ new Map();
|
|
@@ -632,6 +637,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
632
637
|
return false;
|
|
633
638
|
}
|
|
634
639
|
if (limitedData.type === "product_all") {
|
|
640
|
+
if (!isProductIncludedByLimitedData(limitedData, product.id)) {
|
|
641
|
+
return false;
|
|
642
|
+
}
|
|
635
643
|
if (!this.checkPackageSubItemUsageRules(discount, flatItem)) {
|
|
636
644
|
return false;
|
|
637
645
|
}
|
|
@@ -373,6 +373,26 @@ var calculateTaxFee = (shopInfo, items) => {
|
|
|
373
373
|
}, new import_decimal.default(0));
|
|
374
374
|
return totalTaxFee;
|
|
375
375
|
};
|
|
376
|
+
var getCartItemDepositData = (item) => {
|
|
377
|
+
var _a, _b, _c, _d;
|
|
378
|
+
const target = item;
|
|
379
|
+
return ((_a = target == null ? void 0 : target._productOrigin) == null ? void 0 : _a.custom_deposit_data) || ((_b = target == null ? void 0 : target._origin) == null ? void 0 : _b.custom_deposit_data) || ((_d = (_c = target == null ? void 0 : target._origin) == null ? void 0 : _c.product) == null ? void 0 : _d.custom_deposit_data);
|
|
380
|
+
};
|
|
381
|
+
var getCartItemQuantity = (item) => {
|
|
382
|
+
return new import_decimal.default((item == null ? void 0 : item.num) || 1);
|
|
383
|
+
};
|
|
384
|
+
var calculateCartItemDepositTotal = (item) => {
|
|
385
|
+
var _a;
|
|
386
|
+
const depositData = getCartItemDepositData(item);
|
|
387
|
+
if ((depositData == null ? void 0 : depositData.has_deposit) == 1 && typeof (depositData == null ? void 0 : depositData.deposit_fixed) === "string" && typeof (depositData == null ? void 0 : depositData.deposit_percentage) === "string") {
|
|
388
|
+
const lineTotal = new import_decimal.default(item.summaryTotal ?? item.total ?? 0);
|
|
389
|
+
const quantity = getCartItemQuantity(item);
|
|
390
|
+
const fixedTotal = new import_decimal.default(depositData.deposit_fixed || 0).times(quantity);
|
|
391
|
+
const percentageTotal = new import_decimal.default(depositData.deposit_percentage || 0).times(lineTotal);
|
|
392
|
+
return fixedTotal.plus(percentageTotal);
|
|
393
|
+
}
|
|
394
|
+
return new import_decimal.default(((_a = item == null ? void 0 : item.deposit) == null ? void 0 : _a.total) || 0);
|
|
395
|
+
};
|
|
376
396
|
var calculateDeposit = (items) => {
|
|
377
397
|
if (!(items == null ? void 0 : items.length)) {
|
|
378
398
|
return void 0;
|
|
@@ -380,11 +400,11 @@ var calculateDeposit = (items) => {
|
|
|
380
400
|
const protocols = [];
|
|
381
401
|
let hasDeposit = false;
|
|
382
402
|
const total = items.reduce((sum, item) => {
|
|
383
|
-
var _a, _b
|
|
403
|
+
var _a, _b;
|
|
384
404
|
if (item == null ? void 0 : item.deposit) {
|
|
385
405
|
hasDeposit = true;
|
|
386
|
-
const cartItemTotalPrice =
|
|
387
|
-
(
|
|
406
|
+
const cartItemTotalPrice = calculateCartItemDepositTotal(item);
|
|
407
|
+
(_b = (_a = item == null ? void 0 : item.deposit) == null ? void 0 : _a.protocols) == null ? void 0 : _b.forEach((protocol) => {
|
|
388
408
|
if (protocols.findIndex((p) => p.id === protocol.id) === -1) {
|
|
389
409
|
protocols.push(protocol);
|
|
390
410
|
}
|