@pisell/pisellos 0.0.178 → 0.0.180

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.
@@ -54,6 +54,7 @@ export declare const getProductOriginTotalPrice: (params: {
54
54
  bundle?: any;
55
55
  options?: any;
56
56
  num?: number;
57
+ discounts?: any[];
57
58
  }) => number | undefined;
58
59
  /**
59
60
  * 格式化套餐规格信息
@@ -71,7 +71,8 @@ export var formatProductToCartItem = function formatProductToCartItem(params) {
71
71
  product: product,
72
72
  bundle: bundle,
73
73
  options: options,
74
- num: num
74
+ num: num,
75
+ discounts: discounts
75
76
  });
76
77
  cartItem.image = product === null || product === void 0 ? void 0 : product.cover;
77
78
  cartItem.like_status = 'common';
@@ -206,19 +207,11 @@ export var getProductTotalPrice = function getProductTotalPrice(params) {
206
207
  export var getProductOriginTotalPrice = function getProductOriginTotalPrice(params) {
207
208
  var product = params.product,
208
209
  bundle = params.bundle,
209
- options = params.options;
210
+ options = params.options,
211
+ discounts = params.discounts;
210
212
  var num = (params === null || params === void 0 ? void 0 : params.num) || 1;
211
213
  var price = Number(product.original_price);
212
-
213
- // if (product.discount_list?.length) {
214
- // price = product.discount_list.reduce((accumulator: any, currentValue: any) => {
215
- // return (
216
- // accumulator + Number(currentValue.price) * Number(currentValue.num)
217
- // );
218
- // }, price);
219
- // }
220
-
221
- if (isNaN(price) || price === 0) {
214
+ if ((isNaN(price) || price === 0) && !(discounts !== null && discounts !== void 0 && discounts.length)) {
222
215
  return undefined;
223
216
  }
224
217
  if (bundle !== null && bundle !== void 0 && bundle.length) {
@@ -1295,7 +1295,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1295
1295
  var originResource = allOriginResources.find(function (n) {
1296
1296
  return n.id === targetRes.id;
1297
1297
  });
1298
- var canUse = checkResourceCanUseByCapacity(currentResourcesCapacityMap[m.id], currentCapacity, originResource === null || originResource === void 0 ? void 0 : originResource.capacity);
1298
+ var canUse = checkResourceCanUseByCapacity(currentResourcesCapacityMap[m.id] || 0, currentCapacity, originResource === null || originResource === void 0 ? void 0 : originResource.capacity);
1299
1299
  if (canUse) currentResourcesCapacityMap[m.id] += currentCapacity;
1300
1300
  return !canUse;
1301
1301
  }
@@ -1425,7 +1425,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1425
1425
  var resources = [];
1426
1426
  if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
1427
1427
  dateRange.forEach(function (n) {
1428
- resources.push.apply(resources, _toConsumableArray(_this10.store.date.getResourcesListByDate(n.date) || []));
1428
+ if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
1429
1429
  });
1430
1430
  }
1431
1431
  var cartItems = this.store.cart.getItems().filter(function (n) {
@@ -54,6 +54,7 @@ export declare const getProductOriginTotalPrice: (params: {
54
54
  bundle?: any;
55
55
  options?: any;
56
56
  num?: number;
57
+ discounts?: any[];
57
58
  }) => number | undefined;
58
59
  /**
59
60
  * 格式化套餐规格信息
@@ -82,7 +82,8 @@ var formatProductToCartItem = (params) => {
82
82
  product,
83
83
  bundle,
84
84
  options,
85
- num
85
+ num,
86
+ discounts
86
87
  });
87
88
  cartItem.image = product == null ? void 0 : product.cover;
88
89
  cartItem.like_status = "common";
@@ -189,10 +190,10 @@ var getProductTotalPrice = (params) => {
189
190
  return price;
190
191
  };
191
192
  var getProductOriginTotalPrice = (params) => {
192
- const { product, bundle, options } = params;
193
+ const { product, bundle, options, discounts } = params;
193
194
  const num = (params == null ? void 0 : params.num) || 1;
194
195
  let price = Number(product.original_price);
195
- if (isNaN(price) || price === 0) {
196
+ if ((isNaN(price) || price === 0) && !(discounts == null ? void 0 : discounts.length)) {
196
197
  return void 0;
197
198
  }
198
199
  if (bundle == null ? void 0 : bundle.length) {
@@ -719,7 +719,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
719
719
  (n) => n.id === targetRes.id
720
720
  );
721
721
  const canUse = (0, import_capacity.checkResourceCanUseByCapacity)(
722
- currentResourcesCapacityMap[m.id],
722
+ currentResourcesCapacityMap[m.id] || 0,
723
723
  currentCapacity,
724
724
  originResource == null ? void 0 : originResource.capacity
725
725
  );
@@ -825,7 +825,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
825
825
  const resources = [];
826
826
  if (dateRange == null ? void 0 : dateRange.length) {
827
827
  dateRange.forEach((n) => {
828
- resources.push(...this.store.date.getResourcesListByDate(n.date) || []);
828
+ if (n.resource)
829
+ resources.push(...n.resource);
829
830
  });
830
831
  }
831
832
  const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils4.isNormalProduct)(n._productOrigin));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.178",
4
+ "version": "0.0.180",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",