@pisell/pisellos 0.0.68 → 0.0.70

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.
@@ -144,6 +144,8 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
144
144
  end_date: end_date,
145
145
  resource_ids: resource_ids,
146
146
  front_end_cache_id: this.cacheId
147
+ }, {
148
+ useCache: true
147
149
  });
148
150
  case 11:
149
151
  res = _context3.sent;
@@ -277,34 +277,35 @@ export var RulesModule = /*#__PURE__*/function (_BaseModule) {
277
277
  }
278
278
 
279
279
  // 如果没有适用的优惠券,或者手动折扣,则不适用优惠券
280
- if (applicableDiscounts.length === 0 || isManualDiscount) {}
281
- if (product.isClient) {
282
- processedProductsMap.set(product._id, _this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {} : {
283
- origin_total: getProductOriginTotalPrice({
284
- product: {
285
- original_price: product.original_price
286
- },
287
- bundle: product.bundle,
288
- options: product.options
289
- }),
290
- total: getProductTotalPrice({
291
- product: {
292
- price: product.price
293
- },
294
- bundle: product.bundle,
295
- options: product.options
296
- }),
297
- price: product.price
298
- }), {}, {
299
- discount_list: []
300
- })));
301
- } else {
302
- processedProductsMap.set(product._id, _this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {} : {
303
- total: product.origin_total || product.total,
304
- price: product.price
305
- }), {}, {
306
- discount_list: []
307
- })));
280
+ if (applicableDiscounts.length === 0 || isManualDiscount) {
281
+ if (product.isClient) {
282
+ processedProductsMap.set(product._id, _this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {} : {
283
+ origin_total: getProductOriginTotalPrice({
284
+ product: {
285
+ original_price: product.original_price
286
+ },
287
+ bundle: product.bundle,
288
+ options: product.options
289
+ }),
290
+ total: getProductTotalPrice({
291
+ product: {
292
+ price: product.price
293
+ },
294
+ bundle: product.bundle,
295
+ options: product.options
296
+ }),
297
+ price: product.price
298
+ }), {}, {
299
+ discount_list: []
300
+ })));
301
+ } else {
302
+ processedProductsMap.set(product._id, _this3.hooks.setProduct(originProduct, _objectSpread(_objectSpread({}, isManualDiscount ? {} : {
303
+ total: product.origin_total || product.total,
304
+ price: product.price
305
+ }), {}, {
306
+ discount_list: []
307
+ })));
308
+ }
308
309
  return;
309
310
  }
310
311
  if (applicableDiscounts.length && product.booking_id && typeof selectedDiscount.isManualSelect === 'undefined') {
@@ -1216,6 +1216,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1216
1216
  return canUseTime;
1217
1217
  });
1218
1218
  });
1219
+ } else {
1220
+ productResources.forEach(function (item) {
1221
+ // 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
1222
+ item.renderList = item.renderList.filter(function (n) {
1223
+ var recordCount = n.capacity || 0;
1224
+ return recordCount >= currentCapacity;
1225
+ });
1226
+ });
1219
1227
  }
1220
1228
  arr.push({
1221
1229
  id: cartItem.id,
@@ -1510,6 +1518,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1510
1518
  _resources.forEach(function (n) {
1511
1519
  var _n$renderList;
1512
1520
  if ((_n$renderList = n.renderList) !== null && _n$renderList !== void 0 && _n$renderList.length) {
1521
+ // 过滤掉 capacity 小于 currentCapacity 的资源
1522
+ n.renderList = n.renderList.filter(function (m) {
1523
+ var recordCount = m.capacity || 0;
1524
+ return recordCount >= currentCapacity;
1525
+ });
1513
1526
  currentResourcesRenderList.push.apply(currentResourcesRenderList, _toConsumableArray(n.renderList || []));
1514
1527
  }
1515
1528
  });
@@ -483,21 +483,26 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
483
483
  });
484
484
  case 3:
485
485
  result = _context7.sent;
486
- if (result !== null && result !== void 0 && result.data) {
487
- _result$data = result.data, wallet_pass_list = _result$data.wallet_pass_list, customer = _objectWithoutProperties(_result$data, _excluded);
488
- this.setCustomer(customer);
486
+ if (!(result !== null && result !== void 0 && result.data)) {
487
+ _context7.next = 9;
488
+ break;
489
489
  }
490
- _context7.next = 10;
490
+ _result$data = result.data, wallet_pass_list = _result$data.wallet_pass_list, customer = _objectWithoutProperties(_result$data, _excluded);
491
+ this.setCustomer(customer);
492
+ _context7.next = 9;
493
+ return this.core.effects.emit(ShopDiscountHooks.onScanCustomerChange, customer);
494
+ case 9:
495
+ _context7.next = 14;
491
496
  break;
492
- case 7:
493
- _context7.prev = 7;
497
+ case 11:
498
+ _context7.prev = 11;
494
499
  _context7.t0 = _context7["catch"](0);
495
500
  console.error('[ShopDiscount] 获取客户钱包信息出错:', _context7.t0);
496
- case 10:
501
+ case 14:
497
502
  case "end":
498
503
  return _context7.stop();
499
504
  }
500
- }, _callee7, this, [[0, 7]]);
505
+ }, _callee7, this, [[0, 11]]);
501
506
  }));
502
507
  function getCustomerWallet(_x6) {
503
508
  return _getCustomerWallet.apply(this, arguments);
@@ -5,6 +5,7 @@ export declare enum ShopDiscountHooks {
5
5
  onDestroy = "shopDiscount:onDestroy",
6
6
  onLoadDiscountList = "shopDiscount:onLoadDiscountList",
7
7
  onCustomerChange = "shopDiscount:onCustomerChange",
8
+ onScanCustomerChange = "shopDiscount:onScanCustomerChange",
8
9
  onDiscountListChange = "shopDiscount:onDiscountListChange",
9
10
  onRulesListChange = "shopDiscount:onRulesListChange",
10
11
  onLoadPrepareCalcResult = "shopDiscount:onLoadPrepareCalcResult"
@@ -3,6 +3,7 @@ export var ShopDiscountHooks = /*#__PURE__*/function (ShopDiscountHooks) {
3
3
  ShopDiscountHooks["onDestroy"] = "shopDiscount:onDestroy";
4
4
  ShopDiscountHooks["onLoadDiscountList"] = "shopDiscount:onLoadDiscountList";
5
5
  ShopDiscountHooks["onCustomerChange"] = "shopDiscount:onCustomerChange";
6
+ ShopDiscountHooks["onScanCustomerChange"] = "shopDiscount:onScanCustomerChange";
6
7
  ShopDiscountHooks["onDiscountListChange"] = "shopDiscount:onDiscountListChange";
7
8
  ShopDiscountHooks["onRulesListChange"] = "shopDiscount:onRulesListChange";
8
9
  ShopDiscountHooks["onLoadPrepareCalcResult"] = "shopDiscount:onLoadPrepareCalcResult";
@@ -83,6 +83,8 @@ var DateModule = class extends import_BaseModule.BaseModule {
83
83
  end_date,
84
84
  resource_ids,
85
85
  front_end_cache_id: this.cacheId
86
+ }, {
87
+ useCache: true
86
88
  });
87
89
  if (!((_a = res == null ? void 0 : res.data) == null ? void 0 : _a.length)) {
88
90
  return (0, import_utils.disableAllDates)(dates);
@@ -175,42 +175,42 @@ var RulesModule = class extends import_BaseModule.BaseModule {
175
175
  isManualDiscount = false;
176
176
  }
177
177
  if (applicableDiscounts.length === 0 || isManualDiscount) {
178
- }
179
- if (product.isClient) {
180
- processedProductsMap.set(
181
- product._id,
182
- this.hooks.setProduct(originProduct, {
183
- ...isManualDiscount ? {} : {
184
- origin_total: (0, import_utils2.getProductOriginTotalPrice)({
185
- product: {
186
- original_price: product.original_price
187
- },
188
- bundle: product.bundle,
189
- options: product.options
190
- }),
191
- total: (0, import_utils2.getProductTotalPrice)({
192
- product: {
193
- price: product.price
194
- },
195
- bundle: product.bundle,
196
- options: product.options
197
- }),
198
- price: product.price
199
- },
200
- discount_list: []
201
- })
202
- );
203
- } else {
204
- processedProductsMap.set(
205
- product._id,
206
- this.hooks.setProduct(originProduct, {
207
- ...isManualDiscount ? {} : {
208
- total: product.origin_total || product.total,
209
- price: product.price
210
- },
211
- discount_list: []
212
- })
213
- );
178
+ if (product.isClient) {
179
+ processedProductsMap.set(
180
+ product._id,
181
+ this.hooks.setProduct(originProduct, {
182
+ ...isManualDiscount ? {} : {
183
+ origin_total: (0, import_utils2.getProductOriginTotalPrice)({
184
+ product: {
185
+ original_price: product.original_price
186
+ },
187
+ bundle: product.bundle,
188
+ options: product.options
189
+ }),
190
+ total: (0, import_utils2.getProductTotalPrice)({
191
+ product: {
192
+ price: product.price
193
+ },
194
+ bundle: product.bundle,
195
+ options: product.options
196
+ }),
197
+ price: product.price
198
+ },
199
+ discount_list: []
200
+ })
201
+ );
202
+ } else {
203
+ processedProductsMap.set(
204
+ product._id,
205
+ this.hooks.setProduct(originProduct, {
206
+ ...isManualDiscount ? {} : {
207
+ total: product.origin_total || product.total,
208
+ price: product.price
209
+ },
210
+ discount_list: []
211
+ })
212
+ );
213
+ }
214
214
  return;
215
215
  }
216
216
  if (applicableDiscounts.length && product.booking_id && typeof selectedDiscount.isManualSelect === "undefined") {
@@ -667,6 +667,13 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
667
667
  return canUseTime;
668
668
  });
669
669
  });
670
+ } else {
671
+ productResources.forEach((item) => {
672
+ item.renderList = item.renderList.filter((n) => {
673
+ const recordCount = n.capacity || 0;
674
+ return recordCount >= currentCapacity;
675
+ });
676
+ });
670
677
  }
671
678
  arr.push({
672
679
  id: cartItem.id,
@@ -918,6 +925,10 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
918
925
  resources2.forEach((n) => {
919
926
  var _a3;
920
927
  if ((_a3 = n.renderList) == null ? void 0 : _a3.length) {
928
+ n.renderList = n.renderList.filter((m) => {
929
+ const recordCount = m.capacity || 0;
930
+ return recordCount >= currentCapacity;
931
+ });
921
932
  currentResourcesRenderList.push(...n.renderList || []);
922
933
  }
923
934
  });
@@ -313,6 +313,10 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
313
313
  if (result == null ? void 0 : result.data) {
314
314
  const { wallet_pass_list, ...customer } = result.data;
315
315
  this.setCustomer(customer);
316
+ await this.core.effects.emit(
317
+ import_types.ShopDiscountHooks.onScanCustomerChange,
318
+ customer
319
+ );
316
320
  }
317
321
  } catch (error) {
318
322
  console.error("[ShopDiscount] 获取客户钱包信息出错:", error);
@@ -5,6 +5,7 @@ export declare enum ShopDiscountHooks {
5
5
  onDestroy = "shopDiscount:onDestroy",
6
6
  onLoadDiscountList = "shopDiscount:onLoadDiscountList",
7
7
  onCustomerChange = "shopDiscount:onCustomerChange",
8
+ onScanCustomerChange = "shopDiscount:onScanCustomerChange",
8
9
  onDiscountListChange = "shopDiscount:onDiscountListChange",
9
10
  onRulesListChange = "shopDiscount:onRulesListChange",
10
11
  onLoadPrepareCalcResult = "shopDiscount:onLoadPrepareCalcResult"
@@ -27,6 +27,7 @@ var ShopDiscountHooks = /* @__PURE__ */ ((ShopDiscountHooks2) => {
27
27
  ShopDiscountHooks2["onDestroy"] = "shopDiscount:onDestroy";
28
28
  ShopDiscountHooks2["onLoadDiscountList"] = "shopDiscount:onLoadDiscountList";
29
29
  ShopDiscountHooks2["onCustomerChange"] = "shopDiscount:onCustomerChange";
30
+ ShopDiscountHooks2["onScanCustomerChange"] = "shopDiscount:onScanCustomerChange";
30
31
  ShopDiscountHooks2["onDiscountListChange"] = "shopDiscount:onDiscountListChange";
31
32
  ShopDiscountHooks2["onRulesListChange"] = "shopDiscount:onRulesListChange";
32
33
  ShopDiscountHooks2["onLoadPrepareCalcResult"] = "shopDiscount:onLoadPrepareCalcResult";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.68",
4
+ "version": "0.0.70",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",