@pisell/pisellos 0.0.125 → 0.0.126

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.
@@ -69,8 +69,10 @@ export interface CartItem {
69
69
  name?: string;
70
70
  /** 商品价格 */
71
71
  price?: number | string;
72
- /** 商品总价 */
72
+ /** 单个商品包括商品本身价格+套餐价格+规格等价格得出来的 */
73
73
  total?: number | string;
74
+ /** 基于 total 乘以 商品数量的价格 */
75
+ summaryTotal?: number | string;
74
76
  /** 商品原价总价,排除原始价格为0的场景 */
75
77
  origin_total?: number | string;
76
78
  /** 商品数量 */
@@ -61,6 +61,7 @@ export var formatProductToCartItem = function formatProductToCartItem(params) {
61
61
  options: options,
62
62
  num: num
63
63
  });
64
+ cartItem.summaryTotal = cartItem.total * (num || 1);
64
65
  cartItem.origin_total = getProductOriginTotalPrice({
65
66
  product: product,
66
67
  bundle: bundle,
@@ -161,7 +162,7 @@ export var getProductTotalPrice = function getProductTotalPrice(params) {
161
162
  var product = params.product,
162
163
  bundle = params.bundle,
163
164
  options = params.options;
164
- var num = params.num || 1;
165
+ // const num = params.num || 1;
165
166
  var price = Number(product.price);
166
167
  if (bundle !== null && bundle !== void 0 && bundle.length) {
167
168
  price = bundle.reduce(function (accumulator, currentValue) {
@@ -175,7 +176,7 @@ export var getProductTotalPrice = function getProductTotalPrice(params) {
175
176
  return accumulator + Number(currentValue.price) * Number(currentValue.num);
176
177
  }, price);
177
178
  }
178
- return price * num;
179
+ return price;
179
180
  };
180
181
 
181
182
  /**
@@ -28,7 +28,7 @@ export var calculateSubtotal = function calculateSubtotal(items) {
28
28
  return '0.00';
29
29
  }
30
30
  var subtotal = items.reduce(function (sum, item) {
31
- var cartItemTotalPrice = new Decimal(item.total || 0);
31
+ var cartItemTotalPrice = new Decimal(item.summaryTotal || 0);
32
32
  return sum.plus(cartItemTotalPrice);
33
33
  }, new Decimal(0));
34
34
  return subtotal.toFixed(2);
@@ -50,7 +50,7 @@ export var calculateTaxFee = function calculateTaxFee(shopInfo, items) {
50
50
  is_price_include_tax = _ref.is_price_include_tax,
51
51
  tax_rate = _ref.tax_rate;
52
52
  var totalTaxFee = items.reduce(function (sum, item) {
53
- var cartItemTotalPrice = new Decimal(item.total || 0);
53
+ var cartItemTotalPrice = new Decimal(item.summaryTotal || 0);
54
54
  var taxRate = new Decimal(tax_rate || 0).div(100);
55
55
  var productTaxRate = cartItemTotalPrice.times(taxRate).times((item === null || item === void 0 ? void 0 : item.is_charge_tax) || 0).div(taxRate.times(is_price_include_tax || 0).plus(1));
56
56
  return sum.plus(productTaxRate);
@@ -2468,8 +2468,13 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2468
2468
  // m.times 需要做个过滤,假设 timeSlice.start_at 是 09:30 timeSlice.end_at 是 11:30
2469
2469
  // time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
2470
2470
  // 需要判断 time 的开始结束时间 是否包含timeSlice的开始结束时间
2471
+
2472
+ // n.start_at 是 2025-06-30 15:00 end_at 2025-06-30 17:00
2473
+ // item.start 是 2025-06-30 16:00 item.end 是 2025-06-30 19:00
2474
+ // 需要判断 n.start_at 和 n.end_at 是否在 item.start 和 item.end 之间
2475
+ // 如果 n.start_at 和 n.end_at 在 item.start 和 item.end 有交集,则此时间需要计算
2471
2476
  var mTimes = m.times.filter(function (n) {
2472
- return !dayjs(n.start_at).isAfter(dayjs(item.start), 'minute') && !dayjs(n.end_at).isBefore(dayjs(item.end), 'minute');
2477
+ return !dayjs(n.start_at).isAfter(dayjs(item.start), 'minute') && !dayjs(n.end_at).isBefore(dayjs(item.end), 'minute') || dayjs(n.start_at).isBefore(dayjs(item.end), 'minute') && dayjs(n.end_at).isAfter(dayjs(item.start), 'minute');
2473
2478
  });
2474
2479
  // 如果在这个区间的时间一个都没有,可以直接认为这个资源不可用
2475
2480
  if (mTimes.length === 0) {
@@ -69,8 +69,10 @@ export interface CartItem {
69
69
  name?: string;
70
70
  /** 商品价格 */
71
71
  price?: number | string;
72
- /** 商品总价 */
72
+ /** 单个商品包括商品本身价格+套餐价格+规格等价格得出来的 */
73
73
  total?: number | string;
74
+ /** 基于 total 乘以 商品数量的价格 */
75
+ summaryTotal?: number | string;
74
76
  /** 商品原价总价,排除原始价格为0的场景 */
75
77
  origin_total?: number | string;
76
78
  /** 商品数量 */
@@ -74,6 +74,7 @@ var formatProductToCartItem = (params) => {
74
74
  cartItem.price = product == null ? void 0 : product.price;
75
75
  cartItem.num = num;
76
76
  cartItem.total = getProductTotalPrice({ product, bundle, options, num });
77
+ cartItem.summaryTotal = cartItem.total * (num || 1);
77
78
  cartItem.origin_total = getProductOriginTotalPrice({
78
79
  product,
79
80
  bundle,
@@ -163,7 +164,6 @@ var formatProductToCartItemOrigin = (params) => {
163
164
  };
164
165
  var getProductTotalPrice = (params) => {
165
166
  const { product, bundle, options } = params;
166
- const num = params.num || 1;
167
167
  let price = Number(product.price);
168
168
  if (bundle == null ? void 0 : bundle.length) {
169
169
  price = bundle.reduce((accumulator, currentValue) => {
@@ -175,7 +175,7 @@ var getProductTotalPrice = (params) => {
175
175
  return accumulator + Number(currentValue.price) * Number(currentValue.num);
176
176
  }, price);
177
177
  }
178
- return price * num;
178
+ return price;
179
179
  };
180
180
  var getProductOriginTotalPrice = (params) => {
181
181
  const { product, bundle, options } = params;
@@ -55,7 +55,7 @@ var calculateSubtotal = (items) => {
55
55
  return "0.00";
56
56
  }
57
57
  const subtotal = items.reduce((sum, item) => {
58
- const cartItemTotalPrice = new import_decimal.default(item.total || 0);
58
+ const cartItemTotalPrice = new import_decimal.default(item.summaryTotal || 0);
59
59
  return sum.plus(cartItemTotalPrice);
60
60
  }, new import_decimal.default(0));
61
61
  return subtotal.toFixed(2);
@@ -66,7 +66,7 @@ var calculateTaxFee = (shopInfo, items) => {
66
66
  }
67
67
  const { is_price_include_tax, tax_rate } = shopInfo || {};
68
68
  const totalTaxFee = items.reduce((sum, item) => {
69
- const cartItemTotalPrice = new import_decimal.default(item.total || 0);
69
+ const cartItemTotalPrice = new import_decimal.default(item.summaryTotal || 0);
70
70
  const taxRate = new import_decimal.default(tax_rate || 0).div(100);
71
71
  const productTaxRate = cartItemTotalPrice.times(taxRate).times((item == null ? void 0 : item.is_charge_tax) || 0).div(taxRate.times(is_price_include_tax || 0).plus(1));
72
72
  return sum.plus(productTaxRate);
@@ -1703,7 +1703,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1703
1703
  let currentResourcesCount = 0;
1704
1704
  const currentResourcesTimeSlotCanUsedArr = [];
1705
1705
  const mTimes = m.times.filter((n) => {
1706
- return !(0, import_dayjs.default)(n.start_at).isAfter((0, import_dayjs.default)(item.start), "minute") && !(0, import_dayjs.default)(n.end_at).isBefore((0, import_dayjs.default)(item.end), "minute");
1706
+ return !(0, import_dayjs.default)(n.start_at).isAfter((0, import_dayjs.default)(item.start), "minute") && !(0, import_dayjs.default)(n.end_at).isBefore((0, import_dayjs.default)(item.end), "minute") || (0, import_dayjs.default)(n.start_at).isBefore((0, import_dayjs.default)(item.end), "minute") && (0, import_dayjs.default)(n.end_at).isAfter((0, import_dayjs.default)(item.start), "minute");
1707
1707
  });
1708
1708
  if (mTimes.length === 0) {
1709
1709
  return;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.125",
4
+ "version": "0.0.126",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -22,7 +22,7 @@
22
22
  "docs": "typedoc --out docs src/index.ts",
23
23
  "sync": "node sync.js",
24
24
  "prepublishOnly": "npm run build",
25
- "deploy": "yarn run build && yarn run changeset && yarn run version && npm run release"
25
+ "deploy": "npm run build && npm run changeset && npm run version && npm run release"
26
26
  },
27
27
  "repository": {
28
28
  "type": "git",
@@ -67,4 +67,4 @@
67
67
  "publishConfig": {
68
68
  "access": "public"
69
69
  }
70
- }
70
+ }