@pisell/pisellos 0.0.83 → 0.0.85

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.
@@ -44,6 +44,7 @@ export interface Discount {
44
44
  balance: string;
45
45
  format_title: Formattitle;
46
46
  product: Product;
47
+ type: "product" | 'good_pass';
47
48
  resource_id?: number;
48
49
  savedAmount?: number;
49
50
  isEditMode?: boolean;
@@ -214,7 +214,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
214
214
 
215
215
  // 编辑的商品 使用了优惠券不可用
216
216
  var isAvailableProduct = !(product !== null && product !== void 0 && product.booking_id && product !== null && product !== void 0 && (_product$discount_lis = product.discount_list) !== null && _product$discount_lis !== void 0 && _product$discount_lis.length && product !== null && product !== void 0 && (_product$discount_lis2 = product.discount_list) !== null && _product$discount_lis2 !== void 0 && _product$discount_lis2.every(function (discount) {
217
- return discount.id;
217
+ return discount.id && discount.type === 'good_pass';
218
218
  }));
219
219
 
220
220
  // 判断优惠券是否适用于该商品
@@ -244,7 +244,7 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
244
244
  var _product$discount_lis3, _product$discount_lis4, _product$discount_lis5;
245
245
  var product = _this3.hooks.getProduct(originProduct);
246
246
  if (product !== null && product !== void 0 && product.booking_id && (_product$discount_lis3 = product.discount_list) !== null && _product$discount_lis3 !== void 0 && _product$discount_lis3.length && product !== null && product !== void 0 && (_product$discount_lis4 = product.discount_list) !== null && _product$discount_lis4 !== void 0 && _product$discount_lis4.every(function (discount) {
247
- return discount.id;
247
+ return discount.id && discount.type === 'good_pass';
248
248
  })) {
249
249
  processedProductsMap.set(product._id, originProduct);
250
250
  return;
@@ -2177,7 +2177,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2177
2177
  // 在已经选定时间的情况下,只要canUseTime如果有一个 false 那就不可用
2178
2178
  if (!currentResourcesTimeSlotCanUsedArr.some(function (n) {
2179
2179
  return n === false;
2180
- })) {
2180
+ }) && currentResourcesCount >= count) {
2181
2181
  count = currentResourcesCount;
2182
2182
  }
2183
2183
  });
@@ -110,7 +110,10 @@ var checkCapacity = function checkCapacity(_ref) {
110
110
  resource = _ref.resource,
111
111
  _ref$currentCount = _ref.currentCount,
112
112
  currentCount = _ref$currentCount === void 0 ? 1 : _ref$currentCount;
113
- if (currentCount > resource.capacity) {
113
+ // 单个预约:如果当前资源容量不足以满足需求的容量,且当前资源是没有被占用的,返回资源不可用标记,但在外部运算会通过 reason=capacityOnly 来处理组合资源可用
114
+ // 多个预约:只需判断容量是否足够
115
+ var isMultipleBooking = resource.resourceType === 'multiple';
116
+ if (currentCount > resource.capacity && (isMultipleBooking || !isMultipleBooking && event_list.length === 0)) {
114
117
  return {
115
118
  status: false,
116
119
  capacity: resource.capacity,
@@ -434,7 +434,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
434
434
  productList.forEach(function (item) {
435
435
  if (item.booking_id) {
436
436
  (item.discount_list || []).forEach(function (discount) {
437
- if (discount.id) {
437
+ if (discount.id && discount.type === 'good_pass') {
438
438
  var _discount$discount, _discount$discount2, _discount$discount3;
439
439
  editModeDiscountList.push(_objectSpread(_objectSpread({}, discount), {}, {
440
440
  isEditMode: true,
@@ -44,6 +44,7 @@ export interface Discount {
44
44
  balance: string;
45
45
  format_title: Formattitle;
46
46
  product: Product;
47
+ type: "product" | 'good_pass';
47
48
  resource_id?: number;
48
49
  savedAmount?: number;
49
50
  isEditMode?: boolean;
@@ -134,7 +134,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
134
134
  var _a, _b, _c;
135
135
  const limitedData = discount == null ? void 0 : discount.limited_relation_product_data;
136
136
  const isLimitedProduct = limitedData.type === "product_all" || limitedData.product_ids && limitedData.product_ids.includes(product.id);
137
- const isAvailableProduct = !((product == null ? void 0 : product.booking_id) && ((_a = product == null ? void 0 : product.discount_list) == null ? void 0 : _a.length) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.every((discount2) => discount2.id)));
137
+ const isAvailableProduct = !((product == null ? void 0 : product.booking_id) && ((_a = product == null ? void 0 : product.discount_list) == null ? void 0 : _a.length) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.every((discount2) => discount2.id && discount2.type === "good_pass")));
138
138
  if (isAvailableProduct && isLimitedProduct) {
139
139
  (_c = discountApplicability.get(discount.id)) == null ? void 0 : _c.push(product.id);
140
140
  const applicableProducts = discountApplicableProducts.get(discount.id) || [];
@@ -154,7 +154,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
154
154
  sortedProductList.forEach((originProduct) => {
155
155
  var _a, _b, _c;
156
156
  const product = this.hooks.getProduct(originProduct);
157
- if ((product == null ? void 0 : product.booking_id) && ((_a = product.discount_list) == null ? void 0 : _a.length) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.every((discount) => discount.id))) {
157
+ if ((product == null ? void 0 : product.booking_id) && ((_a = product.discount_list) == null ? void 0 : _a.length) && ((_b = product == null ? void 0 : product.discount_list) == null ? void 0 : _b.every((discount) => discount.id && discount.type === "good_pass"))) {
158
158
  processedProductsMap.set(product._id, originProduct);
159
159
  return;
160
160
  }
@@ -1516,7 +1516,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1516
1516
  }
1517
1517
  currentResourcesTimeSlotCanUsedArr.push(res.usable);
1518
1518
  });
1519
- if (!currentResourcesTimeSlotCanUsedArr.some((n) => n === false)) {
1519
+ if (!currentResourcesTimeSlotCanUsedArr.some((n) => n === false) && currentResourcesCount >= count) {
1520
1520
  count = currentResourcesCount;
1521
1521
  }
1522
1522
  });
@@ -82,7 +82,8 @@ var checkCapacity = ({
82
82
  resource,
83
83
  currentCount = 1
84
84
  }) => {
85
- if (currentCount > resource.capacity) {
85
+ const isMultipleBooking = resource.resourceType === "multiple";
86
+ if (currentCount > resource.capacity && (isMultipleBooking || !isMultipleBooking && event_list.length === 0)) {
86
87
  return {
87
88
  status: false,
88
89
  capacity: resource.capacity,
@@ -271,7 +271,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
271
271
  if (item.booking_id) {
272
272
  (item.discount_list || []).forEach((discount) => {
273
273
  var _a2, _b, _c;
274
- if (discount.id) {
274
+ if (discount.id && discount.type === "good_pass") {
275
275
  editModeDiscountList.push({
276
276
  ...discount,
277
277
  isEditMode: true,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.83",
4
+ "version": "0.0.85",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",