@pisell/pisellos 1.0.73 → 1.0.75

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.
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "duration" | "session" | "normal";
53
53
  }
@@ -2690,41 +2690,35 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2690
2690
 
2691
2691
  // 与其他资源的时间段求交集
2692
2692
  var _loop2 = function _loop2() {
2693
- var currentResourceSlots = allTimeSlots[i];
2694
- var intersections = [];
2695
-
2696
- // 计算当前公共时间段与下一个资源时间段的交集
2697
- commonSlots.forEach(function (commonSlot) {
2698
- currentResourceSlots.forEach(function (currentSlot) {
2699
- var overlapStart = commonSlot.start.isAfter(currentSlot.start) ? commonSlot.start : currentSlot.start;
2700
- var overlapEnd = commonSlot.end.isBefore(currentSlot.end) ? commonSlot.end : currentSlot.end;
2701
-
2702
- // 如果有重叠时间且重叠时间大于0
2703
- if (overlapStart.isBefore(overlapEnd)) {
2704
- intersections.push({
2705
- start: overlapStart,
2706
- end: overlapEnd
2707
- });
2708
- }
2709
- });
2693
+ var currentResourceSlots = allTimeSlots[i];
2694
+ var intersections = [];
2695
+
2696
+ // 计算当前公共时间段与下一个资源时间段的交集
2697
+ commonSlots.forEach(function (commonSlot) {
2698
+ currentResourceSlots.forEach(function (currentSlot) {
2699
+ var overlapStart = commonSlot.start.isAfter(currentSlot.start) ? commonSlot.start : currentSlot.start;
2700
+ var overlapEnd = commonSlot.end.isBefore(currentSlot.end) ? commonSlot.end : currentSlot.end;
2701
+
2702
+ // 如果有重叠时间且重叠时间大于0
2703
+ if (overlapStart.isBefore(overlapEnd)) {
2704
+ intersections.push({
2705
+ start: overlapStart,
2706
+ end: overlapEnd
2707
+ });
2708
+ }
2710
2709
  });
2711
- commonSlots = intersections;
2712
- console.log("\u4E0E\u8D44\u6E90".concat(i, "\u6C42\u4EA4\u96C6\u540E\u7684\u516C\u5171\u65F6\u95F4\u6BB5:"), commonSlots.map(function (slot) {
2713
- return "".concat(slot.start.format('HH:mm'), "-").concat(slot.end.format('HH:mm'));
2714
- }));
2715
-
2716
- // 如果没有公共时间段,直接返回
2717
- if (commonSlots.length === 0) {
2718
- console.log('没有找到公共时间段');
2719
- return {
2720
- v: []
2721
- };
2722
- }
2723
- },
2724
- _ret2;
2710
+ });
2711
+ if (intersections.length === 0) {
2712
+ console.log("\u8D44\u6E90".concat(i, "\u4E0E\u5F53\u524D\u516C\u5171\u65F6\u95F4\u6BB5\u65E0\u4EA4\u96C6\uFF0C\u8DF3\u8FC7\u8BE5\u8D44\u6E90"));
2713
+ return 1; // continue
2714
+ }
2715
+ commonSlots = intersections;
2716
+ console.log("\u4E0E\u8D44\u6E90".concat(i, "\u6C42\u4EA4\u96C6\u540E\u7684\u516C\u5171\u65F6\u95F4\u6BB5:"), commonSlots.map(function (slot) {
2717
+ return "".concat(slot.start.format('HH:mm'), "-").concat(slot.end.format('HH:mm'));
2718
+ }));
2719
+ };
2725
2720
  for (var i = 1; i < allTimeSlots.length; i++) {
2726
- _ret2 = _loop2();
2727
- if (_ret2) return _ret2.v;
2721
+ if (_loop2()) continue;
2728
2722
  }
2729
2723
 
2730
2724
  // 格式化返回结果
@@ -2973,10 +2967,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
2973
2967
  }
2974
2968
  });
2975
2969
  },
2976
- _ret3;
2970
+ _ret2;
2977
2971
  for (var _i = 0, _Object$entries = Object.entries(itemsByResourceType); _i < _Object$entries.length; _i++) {
2978
- _ret3 = _loop3();
2979
- if (_ret3) return _ret3.v;
2972
+ _ret2 = _loop3();
2973
+ if (_ret2) return _ret2.v;
2980
2974
  }
2981
2975
 
2982
2976
  // 如果有容量问题,找出限制最严格的资源类型,返回其总容量
@@ -3073,11 +3067,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3073
3067
  };
3074
3068
  }
3075
3069
  },
3076
- _ret4;
3070
+ _ret3;
3077
3071
  for (var _i2 = 0, _Object$entries2 = Object.entries(cartItemsByTimeSlot); _i2 < _Object$entries2.length; _i2++) {
3078
- _ret4 = _loop4();
3079
- if (_ret4 === 0) continue;
3080
- if (_ret4) return _ret4.v;
3072
+ _ret3 = _loop4();
3073
+ if (_ret3 === 0) continue;
3074
+ if (_ret3) return _ret3.v;
3081
3075
  }
3082
3076
 
3083
3077
  // 全部通过检测,返回成功和最小可用数量
@@ -3404,10 +3398,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3404
3398
  }
3405
3399
  });
3406
3400
  },
3407
- _ret5;
3401
+ _ret4;
3408
3402
  for (var _i3 = 0, _Object$entries3 = Object.entries(itemsByResourceType); _i3 < _Object$entries3.length; _i3++) {
3409
- _ret5 = _loop5();
3410
- if (_ret5) return _ret5.v;
3403
+ _ret4 = _loop5();
3404
+ if (_ret4) return _ret4.v;
3411
3405
  }
3412
3406
 
3413
3407
  // 如果有容量问题,找出限制最严格的资源类型,返回其总容量
@@ -3504,11 +3498,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
3504
3498
  };
3505
3499
  }
3506
3500
  },
3507
- _ret6;
3501
+ _ret5;
3508
3502
  for (var _i4 = 0, _Object$entries4 = Object.entries(cartItemsByTimeSlot); _i4 < _Object$entries4.length; _i4++) {
3509
- _ret6 = _loop6();
3510
- if (_ret6 === 0) continue;
3511
- if (_ret6) return _ret6.v;
3503
+ _ret5 = _loop6();
3504
+ if (_ret5 === 0) continue;
3505
+ if (_ret5) return _ret5.v;
3512
3506
  }
3513
3507
 
3514
3508
  // 全部通过检测,返回成功和最小可用数量
@@ -320,7 +320,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
320
320
  key: "scanCode",
321
321
  value: function () {
322
322
  var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code, customerId) {
323
- var _this$store$discount3, resultDiscountList, rulesModule, withScanList, _ref2, newProductList, newDiscountList, isAvailable, _this$options$otherPa6;
323
+ var _this$store$discount3, resultDiscountList, rulesModule, withScanList, currentSelectedDiscountList, _ref2, newProductList, newDiscountList, isAvailable, _this$options$otherPa6;
324
324
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
325
325
  while (1) switch (_context5.prev = _context5.next) {
326
326
  case 0:
@@ -363,7 +363,25 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
363
363
  return _objectSpread(_objectSpread({}, item), {}, {
364
364
  isScan: true
365
365
  });
366
+ }); // 如果扫回来的券当前有选中的,则不进行计算
367
+ currentSelectedDiscountList = this.getDiscountList().filter(function (n) {
368
+ return n.isSelected;
366
369
  });
370
+ if (!(currentSelectedDiscountList.length && currentSelectedDiscountList.some(function (n) {
371
+ return withScanList.some(function (m) {
372
+ return m.id === n.id;
373
+ });
374
+ }))) {
375
+ _context5.next = 16;
376
+ break;
377
+ }
378
+ return _context5.abrupt("return", {
379
+ type: "clientCalc",
380
+ isAvailable: true,
381
+ productList: this.store.productList || [],
382
+ discountList: this.getDiscountList()
383
+ });
384
+ case 16:
367
385
  _ref2 = rulesModule.isDiscountListAvailable({
368
386
  productList: this.store.productList || [],
369
387
  oldDiscountList: this.getDiscountList(),
@@ -374,27 +392,27 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
374
392
  discountList: this.getDiscountList()
375
393
  }, newProductList = _ref2.productList, newDiscountList = _ref2.discountList, isAvailable = _ref2.isAvailable;
376
394
  if (!isAvailable) {
377
- _context5.next = 21;
395
+ _context5.next = 24;
378
396
  break;
379
397
  }
380
398
  this.setDiscountList(newDiscountList || []);
381
399
  this.store.originalDiscountList = newDiscountList || [];
382
400
  this.setProductList(newProductList || []);
383
401
  if (!(this.isWalkIn() && resultDiscountList.length && ((_this$options$otherPa6 = this.options.otherParams) === null || _this$options$otherPa6 === void 0 ? void 0 : _this$options$otherPa6.platform) === 'shop')) {
384
- _context5.next = 21;
402
+ _context5.next = 24;
385
403
  break;
386
404
  }
387
- _context5.next = 21;
405
+ _context5.next = 24;
388
406
  return this.getCustomerWallet(resultDiscountList[0].customer_id);
389
- case 21:
407
+ case 24:
390
408
  return _context5.abrupt("return", {
391
409
  type: "clientCalc",
392
410
  isAvailable: isAvailable || false,
393
411
  productList: newProductList || this.store.productList || [],
394
412
  discountList: newDiscountList || this.getDiscountList()
395
413
  });
396
- case 24:
397
- _context5.prev = 24;
414
+ case 27:
415
+ _context5.prev = 27;
398
416
  _context5.t1 = _context5["catch"](0);
399
417
  console.error('[ShopDiscount] 扫码出错:', _context5.t1);
400
418
  return _context5.abrupt("return", {
@@ -403,11 +421,11 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
403
421
  productList: this.store.productList || [],
404
422
  discountList: this.getDiscountList()
405
423
  });
406
- case 28:
424
+ case 31:
407
425
  case "end":
408
426
  return _context5.stop();
409
427
  }
410
- }, _callee5, this, [[0, 24]]);
428
+ }, _callee5, this, [[0, 27]]);
411
429
  }));
412
430
  function scanCode(_x4, _x5) {
413
431
  return _scanCode.apply(this, arguments);
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
49
49
  getCategories(): ProductCategory[];
50
50
  setOtherParams(key: string, value: any): void;
51
51
  getOtherParams(): any;
52
- getProductType(): "normal" | "duration" | "session";
52
+ getProductType(): "duration" | "session" | "normal";
53
53
  }
@@ -1908,12 +1908,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1908
1908
  }
1909
1909
  });
1910
1910
  });
1911
+ if (intersections.length === 0) {
1912
+ console.log(`资源${i}与当前公共时间段无交集,跳过该资源`);
1913
+ continue;
1914
+ }
1911
1915
  commonSlots = intersections;
1912
1916
  console.log(`与资源${i}求交集后的公共时间段:`, commonSlots.map((slot) => `${slot.start.format("HH:mm")}-${slot.end.format("HH:mm")}`));
1913
- if (commonSlots.length === 0) {
1914
- console.log("没有找到公共时间段");
1915
- return [];
1916
- }
1917
1917
  }
1918
1918
  const result = commonSlots.map((slot) => ({
1919
1919
  startTime: slot.start.format("HH:mm"),
@@ -233,6 +233,15 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
233
233
  isScan: true
234
234
  };
235
235
  });
236
+ const currentSelectedDiscountList = this.getDiscountList().filter((n) => n.isSelected);
237
+ if (currentSelectedDiscountList.length && currentSelectedDiscountList.some((n) => withScanList.some((m) => m.id === n.id))) {
238
+ return {
239
+ type: "clientCalc",
240
+ isAvailable: true,
241
+ productList: this.store.productList || [],
242
+ discountList: this.getDiscountList()
243
+ };
244
+ }
236
245
  const {
237
246
  productList: newProductList,
238
247
  discountList: newDiscountList,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "1.0.73",
4
+ "version": "1.0.75",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",