@pisell/pisellos 0.0.487 → 0.0.488

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;
@@ -23,7 +23,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
23
23
  */
24
24
  private logError;
25
25
  createOrder(params: CommitOrderParams['query']): {
26
- type: "appointment_booking" | "virtual";
26
+ type: "virtual" | "appointment_booking";
27
27
  platform: string;
28
28
  sales_channel: string;
29
29
  order_sales_channel: string;
@@ -2344,6 +2344,16 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2344
2344
  return true;
2345
2345
  }
2346
2346
  var ruleType = usageRules.type;
2347
+ // 套餐适用范围配置
2348
+ var packageScope = usageRules === null || usageRules === void 0 ? void 0 : usageRules.package_scope;
2349
+ var _ref14 = packageScope || {},
2350
+ scopeType = _ref14.type,
2351
+ _ref14$exclude_bundle = _ref14.exclude_bundle_product_ids,
2352
+ exclude_bundle_product_ids = _ref14$exclude_bundle === void 0 ? [] : _ref14$exclude_bundle,
2353
+ _ref14$include_bundle = _ref14.include_bundle_product_ids,
2354
+ include_bundle_product_ids = _ref14$include_bundle === void 0 ? [] : _ref14$include_bundle,
2355
+ _ref14$filter = _ref14.filter,
2356
+ filter = _ref14$filter === void 0 ? 0 : _ref14$filter;
2347
2357
  var isMainProduct = flatItem.type === 'main'; // 单独购买
2348
2358
  var isBundleItem = flatItem.type === 'bundle'; // 套餐中购买
2349
2359
 
@@ -2358,10 +2368,12 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2358
2368
  return true; // 单独购买时可用
2359
2369
  }
2360
2370
  if (isBundleItem) {
2361
- var _flatItem$bundleItem9, _flatItem$bundleItem10;
2371
+ var _flatItem$bundleItem9, _flatItem$bundleItem10, _flatItem$originProdu, _flatItem$originProdu2;
2362
2372
  // 套餐中购买时,判断是否为原价
2363
2373
  var priceType = (_flatItem$bundleItem9 = flatItem.bundleItem) === null || _flatItem$bundleItem9 === void 0 ? void 0 : _flatItem$bundleItem9.price_type;
2364
2374
  var priceTypeExt = (_flatItem$bundleItem10 = flatItem.bundleItem) === null || _flatItem$bundleItem10 === void 0 ? void 0 : _flatItem$bundleItem10.price_type_ext;
2375
+ // 主商品id
2376
+ var mainProductId = (flatItem === null || flatItem === void 0 || (_flatItem$originProdu = flatItem.originProduct) === null || _flatItem$originProdu === void 0 ? void 0 : _flatItem$originProdu.product_id) || (flatItem === null || flatItem === void 0 || (_flatItem$originProdu2 = flatItem.originProduct) === null || _flatItem$originProdu2 === void 0 ? void 0 : _flatItem$originProdu2.id);
2365
2377
  // original_price 对应:
2366
2378
  // 1. price_type: "markup" && price_type_ext: "product_price"
2367
2379
  // markup_price 对应:
@@ -2373,16 +2385,43 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2373
2385
 
2374
2386
  // 检查 rules
2375
2387
  if (rules.length > 0) {
2376
- // 检查原价
2377
- if (isOriginalPrice && rules.includes('original_price')) {
2378
- return true;
2388
+ var _isOriginalPrice = isOriginalPrice && rules.includes('original_price');
2389
+ var _isMarkupPrice = isMarkupPrice && rules.includes('markup_price');
2390
+ // 价格是否符合规则:原价或加价
2391
+ var isPriceValid = _isOriginalPrice || _isMarkupPrice;
2392
+ // 套餐适用范围校验
2393
+ var isScopeValid = false;
2394
+
2395
+ // 排除套餐判断
2396
+ if (scopeType === 'all_packages') {
2397
+ // 所有套餐可用
2398
+ if (!filter) {
2399
+ isScopeValid = true;
2400
+ } else {
2401
+ isScopeValid = !exclude_bundle_product_ids.includes(Number(mainProductId));
2402
+ }
2379
2403
  }
2380
2404
 
2381
- // 检查加价
2382
- if (isMarkupPrice && rules.includes('markup_price')) {
2405
+ // 包含套餐判断
2406
+ if (scopeType === 'specific_packages') {
2407
+ isScopeValid = include_bundle_product_ids.includes(Number(mainProductId));
2408
+ }
2409
+
2410
+ // 价格和套餐适用范围都符合,则可用
2411
+ if (isPriceValid && isScopeValid) {
2383
2412
  return true;
2384
2413
  }
2385
2414
 
2415
+ // 检查原价
2416
+ // if (isOriginalPrice && rules.includes('original_price')) {
2417
+ // return true;
2418
+ // }
2419
+
2420
+ // 检查加价
2421
+ // if (isMarkupPrice && rules.includes('markup_price')) {
2422
+ // return true;
2423
+ // }
2424
+
2386
2425
  // 如果都不匹配,则不可用
2387
2426
  return false;
2388
2427
  }
@@ -2409,19 +2448,19 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2409
2448
  // markup_price 对应:
2410
2449
  // price_type: "markup" && price_type_ext: ""
2411
2450
  /** 原价 */
2412
- var _isOriginalPrice = _priceType === 'markup' && _priceTypeExt === 'product_price';
2451
+ var _isOriginalPrice2 = _priceType === 'markup' && _priceTypeExt === 'product_price';
2413
2452
  /** 加价 */
2414
- var _isMarkupPrice = _priceType === 'markup' && (_priceTypeExt === '' || !_priceTypeExt);
2453
+ var _isMarkupPrice2 = _priceType === 'markup' && (_priceTypeExt === '' || !_priceTypeExt);
2415
2454
 
2416
2455
  // 检查 rules
2417
2456
  if (rules.length > 0) {
2418
2457
  // 检查原价
2419
- if (_isOriginalPrice && rules.includes('original_price')) {
2458
+ if (_isOriginalPrice2 && rules.includes('original_price')) {
2420
2459
  return true;
2421
2460
  }
2422
2461
 
2423
2462
  // 检查加价
2424
- if (_isMarkupPrice && rules.includes('markup_price')) {
2463
+ if (_isMarkupPrice2 && rules.includes('markup_price')) {
2425
2464
  return true;
2426
2465
  }
2427
2466
 
@@ -2430,7 +2469,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
2430
2469
  }
2431
2470
 
2432
2471
  // 原价包括:price_type: "markup" && price_type_ext: "product_price"
2433
- return _isOriginalPrice;
2472
+ return _isOriginalPrice2;
2434
2473
  }
2435
2474
  return false;
2436
2475
  }
@@ -358,7 +358,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
358
358
  };
359
359
  setOtherData(key: string, value: any): void;
360
360
  getOtherData(key: string): any;
361
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
361
+ getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
362
362
  /**
363
363
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
364
364
  *
@@ -131,7 +131,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
131
131
  * 获取当前的客户搜索条件
132
132
  * @returns 当前搜索条件
133
133
  */
134
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
134
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
135
135
  /**
136
136
  * 获取客户列表状态(包含滚动加载相关状态)
137
137
  * @returns 客户状态
@@ -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;
@@ -23,7 +23,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
23
23
  */
24
24
  private logError;
25
25
  createOrder(params: CommitOrderParams['query']): {
26
- type: "appointment_booking" | "virtual";
26
+ type: "virtual" | "appointment_booking";
27
27
  platform: string;
28
28
  sales_channel: string;
29
29
  order_sales_channel: string;
@@ -1892,7 +1892,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1892
1892
  * @returns 是否可用
1893
1893
  */
1894
1894
  checkPackageSubItemUsageRules(discount, flatItem) {
1895
- var _a, _b, _c, _d;
1895
+ var _a, _b, _c, _d, _e, _f;
1896
1896
  const limitedData = discount.limited_relation_product_data;
1897
1897
  const usageRules = limitedData == null ? void 0 : limitedData.package_sub_item_usage_rules;
1898
1898
  const rules = ["original_price", ...(usageRules == null ? void 0 : usageRules.rules) || []];
@@ -1900,6 +1900,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1900
1900
  return true;
1901
1901
  }
1902
1902
  const ruleType = usageRules.type;
1903
+ const packageScope = usageRules == null ? void 0 : usageRules.package_scope;
1904
+ const { type: scopeType, exclude_bundle_product_ids = [], include_bundle_product_ids = [], filter = 0 } = packageScope || {};
1903
1905
  const isMainProduct = flatItem.type === "main";
1904
1906
  const isBundleItem = flatItem.type === "bundle";
1905
1907
  if (isMainProduct) {
@@ -1912,13 +1914,25 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1912
1914
  if (isBundleItem) {
1913
1915
  const priceType = (_a = flatItem.bundleItem) == null ? void 0 : _a.price_type;
1914
1916
  const priceTypeExt = (_b = flatItem.bundleItem) == null ? void 0 : _b.price_type_ext;
1917
+ const mainProductId = ((_c = flatItem == null ? void 0 : flatItem.originProduct) == null ? void 0 : _c.product_id) || ((_d = flatItem == null ? void 0 : flatItem.originProduct) == null ? void 0 : _d.id);
1915
1918
  const isOriginalPrice = priceType === "markup" && priceTypeExt === "product_price";
1916
1919
  const isMarkupPrice = priceType === "markup" && (priceTypeExt === "" || !priceTypeExt);
1917
1920
  if (rules.length > 0) {
1918
- if (isOriginalPrice && rules.includes("original_price")) {
1919
- return true;
1921
+ const _isOriginalPrice = isOriginalPrice && rules.includes("original_price");
1922
+ const _isMarkupPrice = isMarkupPrice && rules.includes("markup_price");
1923
+ const isPriceValid = _isOriginalPrice || _isMarkupPrice;
1924
+ let isScopeValid = false;
1925
+ if (scopeType === "all_packages") {
1926
+ if (!filter) {
1927
+ isScopeValid = true;
1928
+ } else {
1929
+ isScopeValid = !exclude_bundle_product_ids.includes(Number(mainProductId));
1930
+ }
1920
1931
  }
1921
- if (isMarkupPrice && rules.includes("markup_price")) {
1932
+ if (scopeType === "specific_packages") {
1933
+ isScopeValid = include_bundle_product_ids.includes(Number(mainProductId));
1934
+ }
1935
+ if (isPriceValid && isScopeValid) {
1922
1936
  return true;
1923
1937
  }
1924
1938
  return false;
@@ -1932,8 +1946,8 @@ var RulesModule = class extends import_BaseModule.BaseModule {
1932
1946
  return false;
1933
1947
  }
1934
1948
  if (isBundleItem) {
1935
- const priceType = (_c = flatItem.bundleItem) == null ? void 0 : _c.price_type;
1936
- const priceTypeExt = (_d = flatItem.bundleItem) == null ? void 0 : _d.price_type_ext;
1949
+ const priceType = (_e = flatItem.bundleItem) == null ? void 0 : _e.price_type;
1950
+ const priceTypeExt = (_f = flatItem.bundleItem) == null ? void 0 : _f.price_type_ext;
1937
1951
  const isOriginalPrice = priceType === "markup" && priceTypeExt === "product_price";
1938
1952
  const isMarkupPrice = priceType === "markup" && (priceTypeExt === "" || !priceTypeExt);
1939
1953
  if (rules.length > 0) {
@@ -358,7 +358,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
358
358
  };
359
359
  setOtherData(key: string, value: any): void;
360
360
  getOtherData(key: string): any;
361
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
361
+ getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
362
362
  /**
363
363
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
364
364
  *
@@ -131,7 +131,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
131
131
  * 获取当前的客户搜索条件
132
132
  * @returns 当前搜索条件
133
133
  */
134
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
134
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
135
135
  /**
136
136
  * 获取客户列表状态(包含滚动加载相关状态)
137
137
  * @returns 客户状态
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.487",
4
+ "version": "0.0.488",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",