@pisell/pisellos 0.0.412 → 0.0.414

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.
@@ -675,7 +675,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
675
675
  // 收集该折扣卡适用的商品(排除被其他专属折扣卡占用的商品)
676
676
  var applicableProducts = [];
677
677
  sortedFlattenedList.forEach(function (flatItem) {
678
- var _flatItem$parentProdu2;
678
+ var _flatItem$parentProdu2, _product$price, _ref5, _flatItem$original_pr;
679
679
  // 🔥 检查该商品是否被其他专属折扣卡占用
680
680
  var occupyingDiscountId = occupiedItems.get(flatItem._id);
681
681
  if (occupyingDiscountId !== undefined && occupyingDiscountId !== discount.id) {
@@ -701,10 +701,14 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
701
701
  // 对于 bundle 子商品,quantity 需要乘以主商品的购买数量
702
702
  var quantity = flatItem.type === 'main' ? product.quantity || 1 : (product.num || 1) * (((_flatItem$parentProdu2 = flatItem.parentProduct) === null || _flatItem$parentProdu2 === void 0 ? void 0 : _flatItem$parentProdu2.quantity) || 1);
703
703
 
704
+ // 对于主商品:使用 price
705
+ // 对于子商品:优先使用 flatItem.original_price,否则使用 flatItem.price
706
+ var originalAmount = flatItem.type === 'main' ? Number((_product$price = product.price) !== null && _product$price !== void 0 ? _product$price : 0) : Number((_ref5 = (_flatItem$original_pr = flatItem.original_price) !== null && _flatItem$original_pr !== void 0 ? _flatItem$original_pr : flatItem.price) !== null && _ref5 !== void 0 ? _ref5 : 0);
707
+
704
708
  // 传递 parentQuantity 用于差值处理时判断是否是真正的"数量为1"
705
709
  var productData = {
706
710
  productId: flatItem._id,
707
- amount: Number(product.price || 0),
711
+ amount: originalAmount,
708
712
  quantity: quantity
709
713
  };
710
714
 
@@ -947,8 +951,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
947
951
  var _product$discount_lis5, _product11, _product11$every;
948
952
  // 主商品:判断自身是否手动折扣
949
953
  isManualDiscount = typeof product.isManualDiscount === 'boolean' ? product.isManualDiscount : product.total != product.origin_total && (product.bundle || []).every(function (item) {
950
- var _ref5;
951
- return !((_ref5 = item.discount_list || []) !== null && _ref5 !== void 0 && _ref5.length);
954
+ var _ref6;
955
+ return !((_ref6 = item.discount_list || []) !== null && _ref6 !== void 0 && _ref6.length);
952
956
  }) && (!((_product$discount_lis5 = product.discount_list) !== null && _product$discount_lis5 !== void 0 && _product$discount_lis5.length) || ((_product11 = product) === null || _product11 === void 0 || (_product11 = _product11.discount_list) === null || _product11 === void 0 || (_product11$every = _product11.every) === null || _product11$every === void 0 ? void 0 : _product11$every.call(_product11, function (item) {
953
957
  return item.type === 'product';
954
958
  })));
@@ -958,8 +962,8 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
958
962
  if (parentProduct) {
959
963
  var _parentProduct$discou, _parentProduct$discou2, _parentProduct$discou3;
960
964
  isManualDiscount = typeof parentProduct.isManualDiscount === 'boolean' ? parentProduct.isManualDiscount : parentProduct.total != parentProduct.origin_total && (parentProduct.bundle || []).every(function (item) {
961
- var _ref6;
962
- return !((_ref6 = item.discount_list || []) !== null && _ref6 !== void 0 && _ref6.length);
965
+ var _ref7;
966
+ return !((_ref7 = item.discount_list || []) !== null && _ref7 !== void 0 && _ref7.length);
963
967
  }) && (!((_parentProduct$discou = parentProduct.discount_list) !== null && _parentProduct$discou !== void 0 && _parentProduct$discou.length) || (parentProduct === null || parentProduct === void 0 || (_parentProduct$discou2 = parentProduct.discount_list) === null || _parentProduct$discou2 === void 0 || (_parentProduct$discou3 = _parentProduct$discou2.every) === null || _parentProduct$discou3 === void 0 ? void 0 : _parentProduct$discou3.call(_parentProduct$discou2, function (item) {
964
968
  return item.type === 'product';
965
969
  })));
@@ -1024,12 +1024,12 @@ export var getSurcharge = function getSurcharge(_ref10, options) {
1024
1024
  var productCount = matchedItems.reduce(function (total, item) {
1025
1025
  if (item.isMain) {
1026
1026
  // 主商品和addons商品
1027
- return total + (item.num || 1);
1027
+ return total + (item.num || item.quantity || 1);
1028
1028
  } else {
1029
1029
  // 子商品(bundle item)和加时商品
1030
1030
  // 加时商品的 mainQuantity = 1,所以不受影响
1031
1031
  // bundle item 的 mainQuantity = 主商品数量,需要乘以实际数量
1032
- return total + (item.num || 1) * (item.mainQuantity || 1);
1032
+ return total + (item.num || item.quantity || 1) * (item.mainQuantity || 1);
1033
1033
  }
1034
1034
  }, 0);
1035
1035
 
@@ -357,7 +357,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
357
357
  };
358
358
  setOtherData(key: string, value: any): void;
359
359
  getOtherData(key: string): any;
360
- getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
360
+ getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
361
361
  /**
362
362
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
363
363
  *
@@ -487,9 +487,10 @@ var RulesModule = class extends import_BaseModule.BaseModule {
487
487
  };
488
488
  }
489
489
  const quantity = flatItem.type === "main" ? product.quantity || 1 : (product.num || 1) * (((_a = flatItem.parentProduct) == null ? void 0 : _a.quantity) || 1);
490
+ const originalAmount = flatItem.type === "main" ? Number(product.price ?? 0) : Number(flatItem.original_price ?? flatItem.price ?? 0);
490
491
  const productData = {
491
492
  productId: flatItem._id,
492
- amount: Number(product.price || 0),
493
+ amount: originalAmount,
493
494
  quantity
494
495
  };
495
496
  if (flatItem.type === "bundle") {
@@ -634,9 +634,9 @@ var getSurcharge = ({ service, addons, bookingDetail, bookingId }, options) => {
634
634
  let finalAmount = 0;
635
635
  const productCount = matchedItems.reduce((total, item) => {
636
636
  if (item.isMain) {
637
- return total + (item.num || 1);
637
+ return total + (item.num || item.quantity || 1);
638
638
  } else {
639
- return total + (item.num || 1) * (item.mainQuantity || 1);
639
+ return total + (item.num || item.quantity || 1) * (item.mainQuantity || 1);
640
640
  }
641
641
  }, 0);
642
642
  let fixedTotal = new import_decimal.default(0);
@@ -357,7 +357,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
357
357
  };
358
358
  setOtherData(key: string, value: any): void;
359
359
  getOtherData(key: string): any;
360
- getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
360
+ getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
361
361
  /**
362
362
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
363
363
  *
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.412",
4
+ "version": "0.0.414",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",