@pisell/pisellos 2.2.120 → 2.2.122

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.
@@ -18,6 +18,14 @@ interface Formattitle {
18
18
  interface PackageSubItemUsageRules {
19
19
  type: 'universal_discount' | 'package_exclusive' | 'single_item_promo' | 'custom_usage_rules';
20
20
  rules: ("original_price" | "markup_price")[];
21
+ package_scope?: {
22
+ type: 'all_packages' | 'specific_packages';
23
+ exclude_bundle_product_ids: number[];
24
+ include_bundle_product_ids: number[];
25
+ filter: 0 | 1;
26
+ rule: any[];
27
+ rule_type: 'and' | 'or';
28
+ };
21
29
  }
22
30
  interface Limitedrelationproductdata {
23
31
  id: number;
@@ -1958,6 +1958,16 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1958
1958
  return true;
1959
1959
  }
1960
1960
  var ruleType = usageRules.type;
1961
+ // 套餐适用范围配置
1962
+ var packageScope = usageRules === null || usageRules === void 0 ? void 0 : usageRules.package_scope;
1963
+ var _ref13 = packageScope || {},
1964
+ scopeType = _ref13.type,
1965
+ _ref13$exclude_bundle = _ref13.exclude_bundle_product_ids,
1966
+ exclude_bundle_product_ids = _ref13$exclude_bundle === void 0 ? [] : _ref13$exclude_bundle,
1967
+ _ref13$include_bundle = _ref13.include_bundle_product_ids,
1968
+ include_bundle_product_ids = _ref13$include_bundle === void 0 ? [] : _ref13$include_bundle,
1969
+ _ref13$filter = _ref13.filter,
1970
+ filter = _ref13$filter === void 0 ? 0 : _ref13$filter;
1961
1971
  var isMainProduct = flatItem.type === 'main'; // 单独购买
1962
1972
  var isBundleItem = flatItem.type === 'bundle'; // 套餐中购买
1963
1973
 
@@ -1972,10 +1982,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1972
1982
  return true; // 单独购买时可用
1973
1983
  }
1974
1984
  if (isBundleItem) {
1975
- var _flatItem$bundleItem9, _flatItem$bundleItem10;
1985
+ var _flatItem$bundleItem9, _flatItem$bundleItem10, _flatItem$originProdu, _flatItem$parentProdu9;
1976
1986
  // 套餐中购买时,判断是否为原价
1977
1987
  var priceType = (_flatItem$bundleItem9 = flatItem.bundleItem) === null || _flatItem$bundleItem9 === void 0 ? void 0 : _flatItem$bundleItem9.price_type;
1978
1988
  var priceTypeExt = (_flatItem$bundleItem10 = flatItem.bundleItem) === null || _flatItem$bundleItem10 === void 0 ? void 0 : _flatItem$bundleItem10.price_type_ext;
1989
+ // 主商品id
1990
+ var mainProductId = (flatItem === null || flatItem === void 0 || (_flatItem$originProdu = flatItem.originProduct) === null || _flatItem$originProdu === void 0 || (_flatItem$originProdu = _flatItem$originProdu._productOrigin) === null || _flatItem$originProdu === void 0 ? void 0 : _flatItem$originProdu.id) || (flatItem === null || flatItem === void 0 || (_flatItem$parentProdu9 = flatItem.parentProduct) === null || _flatItem$parentProdu9 === void 0 ? void 0 : _flatItem$parentProdu9.id) || 0;
1979
1991
  // original_price 对应:
1980
1992
  // 1. price_type: "markup" && price_type_ext: "product_price"
1981
1993
  // markup_price 对应:
@@ -1987,16 +1999,43 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1987
1999
 
1988
2000
  // 检查 rules
1989
2001
  if (rules.length > 0) {
1990
- // 检查原价
1991
- if (isOriginalPrice && rules.includes('original_price')) {
1992
- return true;
2002
+ var _isOriginalPrice = isOriginalPrice && rules.includes('original_price');
2003
+ var _isMarkupPrice = isMarkupPrice && rules.includes('markup_price');
2004
+ // 价格是否符合规则:原价或加价
2005
+ var isPriceValid = _isOriginalPrice || _isMarkupPrice;
2006
+ // 套餐适用范围校验
2007
+ var isScopeValid = false;
2008
+
2009
+ // 排除套餐判断
2010
+ if (scopeType === 'all_packages') {
2011
+ // 所有套餐可用
2012
+ if (!filter) {
2013
+ isScopeValid = true;
2014
+ } else {
2015
+ isScopeValid = !exclude_bundle_product_ids.includes(Number(mainProductId));
2016
+ }
1993
2017
  }
1994
2018
 
1995
- // 检查加价
1996
- if (isMarkupPrice && rules.includes('markup_price')) {
2019
+ // 包含套餐判断
2020
+ if (scopeType === 'specific_packages') {
2021
+ isScopeValid = include_bundle_product_ids.includes(Number(mainProductId));
2022
+ }
2023
+
2024
+ // 价格和套餐适用范围都符合,则可用
2025
+ if (isPriceValid && isScopeValid) {
1997
2026
  return true;
1998
2027
  }
1999
2028
 
2029
+ // 检查原价
2030
+ // if (isOriginalPrice && rules.includes('original_price')) {
2031
+ // return true;
2032
+ // }
2033
+
2034
+ // 检查加价
2035
+ // if (isMarkupPrice && rules.includes('markup_price')) {
2036
+ // return true;
2037
+ // }
2038
+
2000
2039
  // 如果都不匹配,则不可用
2001
2040
  return false;
2002
2041
  }
@@ -2023,19 +2062,19 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2023
2062
  // markup_price 对应:
2024
2063
  // price_type: "markup" && price_type_ext: ""
2025
2064
  /** 原价 */
2026
- var _isOriginalPrice = _priceType === 'markup' && _priceTypeExt === 'product_price';
2065
+ var _isOriginalPrice2 = _priceType === 'markup' && _priceTypeExt === 'product_price';
2027
2066
  /** 加价 */
2028
- var _isMarkupPrice = _priceType === 'markup' && (_priceTypeExt === '' || !_priceTypeExt);
2067
+ var _isMarkupPrice2 = _priceType === 'markup' && (_priceTypeExt === '' || !_priceTypeExt);
2029
2068
 
2030
2069
  // 检查 rules
2031
2070
  if (rules.length > 0) {
2032
2071
  // 检查原价
2033
- if (_isOriginalPrice && rules.includes('original_price')) {
2072
+ if (_isOriginalPrice2 && rules.includes('original_price')) {
2034
2073
  return true;
2035
2074
  }
2036
2075
 
2037
2076
  // 检查加价
2038
- if (_isMarkupPrice && rules.includes('markup_price')) {
2077
+ if (_isMarkupPrice2 && rules.includes('markup_price')) {
2039
2078
  return true;
2040
2079
  }
2041
2080
 
@@ -2044,7 +2083,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2044
2083
  }
2045
2084
 
2046
2085
  // 原价包括:price_type: "markup" && price_type_ext: "product_price"
2047
- return _isOriginalPrice;
2086
+ return _isOriginalPrice2;
2048
2087
  }
2049
2088
  return false;
2050
2089
  }
@@ -18,6 +18,14 @@ interface Formattitle {
18
18
  interface PackageSubItemUsageRules {
19
19
  type: 'universal_discount' | 'package_exclusive' | 'single_item_promo' | 'custom_usage_rules';
20
20
  rules: ("original_price" | "markup_price")[];
21
+ package_scope?: {
22
+ type: 'all_packages' | 'specific_packages';
23
+ exclude_bundle_product_ids: number[];
24
+ include_bundle_product_ids: number[];
25
+ filter: 0 | 1;
26
+ rule: any[];
27
+ rule_type: 'and' | 'or';
28
+ };
21
29
  }
22
30
  interface Limitedrelationproductdata {
23
31
  id: number;
@@ -1591,7 +1591,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1591
1591
  * @returns 是否可用
1592
1592
  */
1593
1593
  checkPackageSubItemUsageRules(discount, flatItem) {
1594
- var _a, _b, _c, _d;
1594
+ var _a, _b, _c, _d, _e, _f, _g;
1595
1595
  const limitedData = discount.limited_relation_product_data;
1596
1596
  const usageRules = limitedData == null ? void 0 : limitedData.package_sub_item_usage_rules;
1597
1597
  const rules = ["original_price", ...(usageRules == null ? void 0 : usageRules.rules) || []];
@@ -1599,6 +1599,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1599
1599
  return true;
1600
1600
  }
1601
1601
  const ruleType = usageRules.type;
1602
+ const packageScope = usageRules == null ? void 0 : usageRules.package_scope;
1603
+ const { type: scopeType, exclude_bundle_product_ids = [], include_bundle_product_ids = [], filter = 0 } = packageScope || {};
1602
1604
  const isMainProduct = flatItem.type === "main";
1603
1605
  const isBundleItem = flatItem.type === "bundle";
1604
1606
  if (isMainProduct) {
@@ -1611,13 +1613,25 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1611
1613
  if (isBundleItem) {
1612
1614
  const priceType = (_a = flatItem.bundleItem) == null ? void 0 : _a.price_type;
1613
1615
  const priceTypeExt = (_b = flatItem.bundleItem) == null ? void 0 : _b.price_type_ext;
1616
+ const mainProductId = ((_d = (_c = flatItem == null ? void 0 : flatItem.originProduct) == null ? void 0 : _c._productOrigin) == null ? void 0 : _d.id) || ((_e = flatItem == null ? void 0 : flatItem.parentProduct) == null ? void 0 : _e.id) || 0;
1614
1617
  const isOriginalPrice = priceType === "markup" && priceTypeExt === "product_price";
1615
1618
  const isMarkupPrice = priceType === "markup" && (priceTypeExt === "" || !priceTypeExt);
1616
1619
  if (rules.length > 0) {
1617
- if (isOriginalPrice && rules.includes("original_price")) {
1618
- return true;
1620
+ const _isOriginalPrice = isOriginalPrice && rules.includes("original_price");
1621
+ const _isMarkupPrice = isMarkupPrice && rules.includes("markup_price");
1622
+ const isPriceValid = _isOriginalPrice || _isMarkupPrice;
1623
+ let isScopeValid = false;
1624
+ if (scopeType === "all_packages") {
1625
+ if (!filter) {
1626
+ isScopeValid = true;
1627
+ } else {
1628
+ isScopeValid = !exclude_bundle_product_ids.includes(Number(mainProductId));
1629
+ }
1619
1630
  }
1620
- if (isMarkupPrice && rules.includes("markup_price")) {
1631
+ if (scopeType === "specific_packages") {
1632
+ isScopeValid = include_bundle_product_ids.includes(Number(mainProductId));
1633
+ }
1634
+ if (isPriceValid && isScopeValid) {
1621
1635
  return true;
1622
1636
  }
1623
1637
  return false;
@@ -1631,8 +1645,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1631
1645
  return false;
1632
1646
  }
1633
1647
  if (isBundleItem) {
1634
- const priceType = (_c = flatItem.bundleItem) == null ? void 0 : _c.price_type;
1635
- const priceTypeExt = (_d = flatItem.bundleItem) == null ? void 0 : _d.price_type_ext;
1648
+ const priceType = (_f = flatItem.bundleItem) == null ? void 0 : _f.price_type;
1649
+ const priceTypeExt = (_g = flatItem.bundleItem) == null ? void 0 : _g.price_type_ext;
1636
1650
  const isOriginalPrice = priceType === "markup" && priceTypeExt === "product_price";
1637
1651
  const isMarkupPrice = priceType === "markup" && (priceTypeExt === "" || !priceTypeExt);
1638
1652
  if (rules.length > 0) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.2.120",
4
+ "version": "2.2.122",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",