@pisell/pisellos 3.0.86 → 3.0.87

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;
@@ -1790,6 +1790,16 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1790
1790
  return true;
1791
1791
  }
1792
1792
  var ruleType = usageRules.type;
1793
+ // 套餐适用范围配置
1794
+ var packageScope = usageRules === null || usageRules === void 0 ? void 0 : usageRules.package_scope;
1795
+ var _ref8 = packageScope || {},
1796
+ scopeType = _ref8.type,
1797
+ _ref8$exclude_bundle_ = _ref8.exclude_bundle_product_ids,
1798
+ exclude_bundle_product_ids = _ref8$exclude_bundle_ === void 0 ? [] : _ref8$exclude_bundle_,
1799
+ _ref8$include_bundle_ = _ref8.include_bundle_product_ids,
1800
+ include_bundle_product_ids = _ref8$include_bundle_ === void 0 ? [] : _ref8$include_bundle_,
1801
+ _ref8$filter = _ref8.filter,
1802
+ filter = _ref8$filter === void 0 ? 0 : _ref8$filter;
1793
1803
  var isMainProduct = flatItem.type === 'main'; // 单独购买
1794
1804
  var isBundleItem = flatItem.type === 'bundle'; // 套餐中购买
1795
1805
 
@@ -1804,10 +1814,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1804
1814
  return true; // 单独购买时可用
1805
1815
  }
1806
1816
  if (isBundleItem) {
1807
- var _flatItem$bundleItem8, _flatItem$bundleItem9;
1817
+ var _flatItem$bundleItem8, _flatItem$bundleItem9, _flatItem$originProdu, _flatItem$parentProdu10;
1808
1818
  // 套餐中购买时,判断是否为原价
1809
1819
  var priceType = (_flatItem$bundleItem8 = flatItem.bundleItem) === null || _flatItem$bundleItem8 === void 0 ? void 0 : _flatItem$bundleItem8.price_type;
1810
1820
  var priceTypeExt = (_flatItem$bundleItem9 = flatItem.bundleItem) === null || _flatItem$bundleItem9 === void 0 ? void 0 : _flatItem$bundleItem9.price_type_ext;
1821
+ // 主商品id
1822
+ 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$parentProdu10 = flatItem.parentProduct) === null || _flatItem$parentProdu10 === void 0 ? void 0 : _flatItem$parentProdu10.id) || 0;
1811
1823
  // original_price 对应:
1812
1824
  // 1. price_type: "markup" && price_type_ext: "product_price"
1813
1825
  // markup_price 对应:
@@ -1819,16 +1831,43 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
1819
1831
 
1820
1832
  // 检查 rules
1821
1833
  if (rules.length > 0) {
1822
- // 检查原价
1823
- if (isOriginalPrice && rules.includes('original_price')) {
1824
- return true;
1834
+ var _isOriginalPrice = isOriginalPrice && rules.includes('original_price');
1835
+ var _isMarkupPrice = isMarkupPrice && rules.includes('markup_price');
1836
+ // 价格是否符合规则:原价或加价
1837
+ var isPriceValid = _isOriginalPrice || _isMarkupPrice;
1838
+ // 套餐适用范围校验
1839
+ var isScopeValid = false;
1840
+
1841
+ // 排除套餐判断
1842
+ if (scopeType === 'all_packages') {
1843
+ // 所有套餐可用
1844
+ if (!filter) {
1845
+ isScopeValid = true;
1846
+ } else {
1847
+ isScopeValid = !exclude_bundle_product_ids.includes(Number(mainProductId));
1848
+ }
1825
1849
  }
1826
1850
 
1827
- // 检查加价
1828
- if (isMarkupPrice && rules.includes('markup_price')) {
1851
+ // 包含套餐判断
1852
+ if (scopeType === 'specific_packages') {
1853
+ isScopeValid = include_bundle_product_ids.includes(Number(mainProductId));
1854
+ }
1855
+
1856
+ // 价格和套餐适用范围都符合,则可用
1857
+ if (isPriceValid && isScopeValid) {
1829
1858
  return true;
1830
1859
  }
1831
1860
 
1861
+ // 检查原价
1862
+ // if (isOriginalPrice && rules.includes('original_price')) {
1863
+ // return true;
1864
+ // }
1865
+
1866
+ // 检查加价
1867
+ // if (isMarkupPrice && rules.includes('markup_price')) {
1868
+ // return true;
1869
+ // }
1870
+
1832
1871
  // 如果都不匹配,则不可用
1833
1872
  return false;
1834
1873
  }
@@ -310,7 +310,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
310
310
  date: string;
311
311
  status: string;
312
312
  week: string;
313
- weekNum: 0 | 2 | 1 | 5 | 3 | 4 | 6;
313
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
314
314
  }[]>;
315
315
  submitTimeSlot(timeSlots: TimeSliceItem): void;
316
316
  private getScheduleDataByIds;
@@ -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;
@@ -1366,7 +1366,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1366
1366
  * @returns 是否可用
1367
1367
  */
1368
1368
  checkPackageSubItemUsageRules(discount, flatItem) {
1369
- var _a, _b, _c, _d;
1369
+ var _a, _b, _c, _d, _e, _f, _g;
1370
1370
  const limitedData = discount.limited_relation_product_data;
1371
1371
  const usageRules = limitedData == null ? void 0 : limitedData.package_sub_item_usage_rules;
1372
1372
  const rules = ["original_price", ...(usageRules == null ? void 0 : usageRules.rules) || []];
@@ -1374,6 +1374,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1374
1374
  return true;
1375
1375
  }
1376
1376
  const ruleType = usageRules.type;
1377
+ const packageScope = usageRules == null ? void 0 : usageRules.package_scope;
1378
+ const { type: scopeType, exclude_bundle_product_ids = [], include_bundle_product_ids = [], filter = 0 } = packageScope || {};
1377
1379
  const isMainProduct = flatItem.type === "main";
1378
1380
  const isBundleItem = flatItem.type === "bundle";
1379
1381
  if (isMainProduct) {
@@ -1386,13 +1388,25 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1386
1388
  if (isBundleItem) {
1387
1389
  const priceType = (_a = flatItem.bundleItem) == null ? void 0 : _a.price_type;
1388
1390
  const priceTypeExt = (_b = flatItem.bundleItem) == null ? void 0 : _b.price_type_ext;
1391
+ 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;
1389
1392
  const isOriginalPrice = priceType === "markup" && priceTypeExt === "product_price";
1390
1393
  const isMarkupPrice = priceType === "markup" && (priceTypeExt === "" || !priceTypeExt);
1391
1394
  if (rules.length > 0) {
1392
- if (isOriginalPrice && rules.includes("original_price")) {
1393
- return true;
1395
+ const _isOriginalPrice = isOriginalPrice && rules.includes("original_price");
1396
+ const _isMarkupPrice = isMarkupPrice && rules.includes("markup_price");
1397
+ const isPriceValid = _isOriginalPrice || _isMarkupPrice;
1398
+ let isScopeValid = false;
1399
+ if (scopeType === "all_packages") {
1400
+ if (!filter) {
1401
+ isScopeValid = true;
1402
+ } else {
1403
+ isScopeValid = !exclude_bundle_product_ids.includes(Number(mainProductId));
1404
+ }
1405
+ }
1406
+ if (scopeType === "specific_packages") {
1407
+ isScopeValid = include_bundle_product_ids.includes(Number(mainProductId));
1394
1408
  }
1395
- if (isMarkupPrice && rules.includes("markup_price")) {
1409
+ if (isPriceValid && isScopeValid) {
1396
1410
  return true;
1397
1411
  }
1398
1412
  return false;
@@ -1406,8 +1420,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1406
1420
  return false;
1407
1421
  }
1408
1422
  if (isBundleItem) {
1409
- const priceType = (_c = flatItem.bundleItem) == null ? void 0 : _c.price_type;
1410
- const priceTypeExt = (_d = flatItem.bundleItem) == null ? void 0 : _d.price_type_ext;
1423
+ const priceType = (_f = flatItem.bundleItem) == null ? void 0 : _f.price_type;
1424
+ const priceTypeExt = (_g = flatItem.bundleItem) == null ? void 0 : _g.price_type_ext;
1411
1425
  return priceType === "markup" && priceTypeExt === "product_price";
1412
1426
  }
1413
1427
  return false;
@@ -310,7 +310,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
310
310
  date: string;
311
311
  status: string;
312
312
  week: string;
313
- weekNum: 0 | 2 | 1 | 5 | 3 | 4 | 6;
313
+ weekNum: 0 | 2 | 1 | 3 | 4 | 5 | 6;
314
314
  }[]>;
315
315
  submitTimeSlot(timeSlots: TimeSliceItem): void;
316
316
  private getScheduleDataByIds;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "3.0.86",
4
+ "version": "3.0.87",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",