@pisell/pisellos 3.0.66 → 3.0.67

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.
@@ -15,8 +15,9 @@ export declare const formatDefaultCapacitys: ({ capacity, product_bundle, }: any
15
15
  * @return {*}
16
16
  * @Author: zhiwei.Wang
17
17
  */
18
- export declare const getSumCapacity: ({ capacity }: {
18
+ export declare const getSumCapacity: ({ capacity, num }: {
19
19
  capacity: CapacityItem[];
20
+ num: number;
20
21
  }) => number;
21
22
  /**
22
23
  * 给定购物车数据,返回对应的 capacity 信息和套餐 capacity
@@ -67,4 +68,8 @@ export declare function getResourcesIdsByProduct(product: any): number[];
67
68
  /**
68
69
  * 检查特定时间段的容量是否足够
69
70
  */
70
- export declare function checkTimeSlotCapacity(timeSlotStart: string, timeSlotEnd: string, cartItems: CartItem[], allResources: ResourceItem[]): boolean;
71
+ export declare function checkTimeSlotCapacity(timeSlotStart: string, timeSlotEnd: string, cartItems: CartItem[], allResources: ResourceItem[]): {
72
+ success: boolean;
73
+ required: number;
74
+ available: number;
75
+ };
@@ -60,7 +60,9 @@ export var formatDefaultCapacitys = function formatDefaultCapacitys(_ref) {
60
60
  * @Author: zhiwei.Wang
61
61
  */
62
62
  export var getSumCapacity = function getSumCapacity(_ref2) {
63
- var capacity = _ref2.capacity;
63
+ var capacity = _ref2.capacity,
64
+ _ref2$num = _ref2.num,
65
+ num = _ref2$num === void 0 ? 1 : _ref2$num;
64
66
  var sum = 0;
65
67
  var _iterator = _createForOfIteratorHelper(capacity || []),
66
68
  _step;
@@ -74,7 +76,7 @@ export var getSumCapacity = function getSumCapacity(_ref2) {
74
76
  } finally {
75
77
  _iterator.f();
76
78
  }
77
- return sum;
79
+ return sum * num;
78
80
  };
79
81
 
80
82
  /**
@@ -91,7 +93,8 @@ export function getCapacityInfoByCartItem(targetCartItem) {
91
93
  product_bundle: targetCartItem._origin.product.product_bundle
92
94
  });
93
95
  var currentCapacity = getSumCapacity({
94
- capacity: formatCapacity
96
+ capacity: formatCapacity,
97
+ num: (targetCartItem === null || targetCartItem === void 0 ? void 0 : targetCartItem.num) || 1
95
98
  });
96
99
  return {
97
100
  formatCapacity: formatCapacity,
@@ -262,7 +265,7 @@ export function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, all
262
265
  if (needsThisResourceType) {
263
266
  // 需要判断是单个预约还是多个预约,如果是单个预约,不用加 capacity,只用+1
264
267
  if (selectType === 'single') {
265
- requiredCapacityByType[formId] = (requiredCapacityByType[formId] || 0) + 1;
268
+ requiredCapacityByType[formId] = (requiredCapacityByType[formId] || 0) + ((cartItem === null || cartItem === void 0 ? void 0 : cartItem.num) || 1);
266
269
  } else {
267
270
  requiredCapacityByType[formId] = (requiredCapacityByType[formId] || 0) + currentCapacity;
268
271
  }
@@ -327,7 +330,11 @@ export function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, all
327
330
  if (totalAvailableCapacity < requiredCapacity) {
328
331
  console.log("\u8D44\u6E90\u7C7B\u578B ".concat(formId, " \u5BB9\u91CF\u4E0D\u8DB3: \u9700\u8981 ").concat(requiredCapacity, ", \u53EF\u7528 ").concat(totalAvailableCapacity));
329
332
  return {
330
- v: false
333
+ v: {
334
+ success: false,
335
+ required: requiredCapacity,
336
+ available: totalAvailableCapacity
337
+ }
331
338
  };
332
339
  }
333
340
  } else {
@@ -336,7 +343,8 @@ export function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, all
336
343
  resourcesInType.forEach(function (resource) {
337
344
  // 过滤出在时间段内的资源时间片
338
345
  var availableTimes = resource.times.filter(function (time) {
339
- return !dayjs(time.start_at).isAfter(dayjs(timeSlotStart), 'minute') && !dayjs(time.end_at).isBefore(dayjs(timeSlotEnd), 'minute') || dayjs(time.start_at).isBefore(dayjs(timeSlotEnd), 'minute') && dayjs(time.end_at).isAfter(dayjs(timeSlotStart), 'minute');
346
+ var _time$event_list;
347
+ return !dayjs(time.start_at).isAfter(dayjs(timeSlotStart), 'minute') && !dayjs(time.end_at).isBefore(dayjs(timeSlotEnd), 'minute') || dayjs(time.start_at).isBefore(dayjs(timeSlotEnd), 'minute') && dayjs(time.end_at).isAfter(dayjs(timeSlotStart), 'minute') && ((_time$event_list = time.event_list) === null || _time$event_list === void 0 ? void 0 : _time$event_list.length) === 0;
340
348
  });
341
349
  if (availableTimes.length > 0) {
342
350
  availableResourceCount++;
@@ -346,7 +354,11 @@ export function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, all
346
354
  if (availableResourceCount < requiredCapacity) {
347
355
  console.log("\u8D44\u6E90\u7C7B\u578B ".concat(formId, " \u6570\u91CF\u4E0D\u8DB3: \u9700\u8981 ").concat(requiredCapacity, ", \u53EF\u7528 ").concat(availableResourceCount));
348
356
  return {
349
- v: false
357
+ v: {
358
+ success: false,
359
+ required: requiredCapacity,
360
+ available: availableResourceCount
361
+ }
350
362
  };
351
363
  }
352
364
  }
@@ -357,5 +369,9 @@ export function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, all
357
369
  if (_ret === 0) continue;
358
370
  if (_ret) return _ret.v;
359
371
  }
360
- return true;
372
+ return {
373
+ success: true,
374
+ required: 0,
375
+ available: 0
376
+ };
361
377
  }
@@ -305,7 +305,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
305
305
  key: "scanCode",
306
306
  value: function () {
307
307
  var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code, customerId) {
308
- var _this$store$discount3, resultDiscountList, rulesModule, withScanList, _ref3, newProductList, newDiscountList, isAvailable, _this$options$otherPa6;
308
+ var _this$store$discount3, resultDiscountList, rulesModule, withScanList, currentSelectedDiscountList, _ref3, newProductList, newDiscountList, isAvailable, _this$options$otherPa6;
309
309
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
310
310
  while (1) switch (_context5.prev = _context5.next) {
311
311
  case 0:
@@ -348,7 +348,25 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
348
348
  return _objectSpread(_objectSpread({}, item), {}, {
349
349
  isScan: true
350
350
  });
351
+ }); // 如果扫回来的券当前有选中的,则不进行计算
352
+ currentSelectedDiscountList = this.getDiscountList().filter(function (n) {
353
+ return n.isSelected;
351
354
  });
355
+ if (!(currentSelectedDiscountList.length && currentSelectedDiscountList.some(function (n) {
356
+ return withScanList.some(function (m) {
357
+ return m.id === n.id;
358
+ });
359
+ }))) {
360
+ _context5.next = 16;
361
+ break;
362
+ }
363
+ return _context5.abrupt("return", {
364
+ type: "clientCalc",
365
+ isAvailable: true,
366
+ productList: this.store.productList || [],
367
+ discountList: this.getDiscountList()
368
+ });
369
+ case 16:
352
370
  _ref3 = rulesModule.isDiscountListAvailable({
353
371
  productList: this.store.productList || [],
354
372
  oldDiscountList: this.getDiscountList(),
@@ -359,26 +377,26 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
359
377
  discountList: this.getDiscountList()
360
378
  }, newProductList = _ref3.productList, newDiscountList = _ref3.discountList, isAvailable = _ref3.isAvailable;
361
379
  if (!isAvailable) {
362
- _context5.next = 20;
380
+ _context5.next = 23;
363
381
  break;
364
382
  }
365
383
  this.setDiscountList(newDiscountList || []);
366
384
  this.setProductList(newProductList || []);
367
385
  if (!(this.isWalkIn() && resultDiscountList.length && ((_this$options$otherPa6 = this.options.otherParams) === null || _this$options$otherPa6 === void 0 ? void 0 : _this$options$otherPa6.platform) === 'shop')) {
368
- _context5.next = 20;
386
+ _context5.next = 23;
369
387
  break;
370
388
  }
371
- _context5.next = 20;
389
+ _context5.next = 23;
372
390
  return this.getCustomerWallet(resultDiscountList[0].customer_id);
373
- case 20:
391
+ case 23:
374
392
  return _context5.abrupt("return", {
375
393
  type: "clientCalc",
376
394
  isAvailable: isAvailable || false,
377
395
  productList: newProductList || this.store.productList || [],
378
396
  discountList: newDiscountList || this.getDiscountList()
379
397
  });
380
- case 23:
381
- _context5.prev = 23;
398
+ case 26:
399
+ _context5.prev = 26;
382
400
  _context5.t1 = _context5["catch"](0);
383
401
  console.error('[ShopDiscount] 扫码出错:', _context5.t1);
384
402
  return _context5.abrupt("return", {
@@ -387,11 +405,11 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
387
405
  productList: this.store.productList || [],
388
406
  discountList: this.getDiscountList()
389
407
  });
390
- case 27:
408
+ case 30:
391
409
  case "end":
392
410
  return _context5.stop();
393
411
  }
394
- }, _callee5, this, [[0, 23]]);
412
+ }, _callee5, this, [[0, 26]]);
395
413
  }));
396
414
  function scanCode(_x4, _x5) {
397
415
  return _scanCode.apply(this, arguments);
@@ -89,11 +89,19 @@ var ProductList = class extends import_BaseModule.BaseModule {
89
89
  front_end_cache_id: cacheId,
90
90
  // client_schedule_ids: schedule_ids,
91
91
  schedule_date,
92
- application_code: (_b = this.otherParams) == null ? void 0 : _b.channel
92
+ application_code: (_b = this.otherParams) == null ? void 0 : _b.channel,
93
+ is_eject: 1
93
94
  },
94
95
  { useCache: true }
95
96
  );
96
97
  const sortedList = (productsData.data.list || []).slice().sort((a, b) => Number(b.sort) - Number(a.sort));
98
+ if (sortedList.length) {
99
+ sortedList.forEach((n) => {
100
+ if (n.is_eject !== 1 && n["schedule.ids"] && n["schedule.ids"].length) {
101
+ n.is_eject = 1;
102
+ }
103
+ });
104
+ }
97
105
  this.addProduct(sortedList);
98
106
  return sortedList;
99
107
  }
@@ -324,6 +324,22 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
324
324
  success: boolean;
325
325
  minAvailableCount: number;
326
326
  };
327
+ /**
328
+ * 将 ProductData 转换为 CartItem,但不添加到购物车
329
+ * 参考 addProductToCart 方法的实现
330
+ */
331
+ private convertProductToCartItem;
332
+ checkMaxDurationCapacityForDetailNums({ product, date, account, }: {
333
+ product: ProductData;
334
+ date?: {
335
+ startTime: string;
336
+ endTime: string;
337
+ } | null;
338
+ account?: Account | null;
339
+ }): {
340
+ success: boolean;
341
+ minAvailableCount: number;
342
+ };
327
343
  setOtherData(key: string, value: any): void;
328
344
  getOtherData(key: string): any;
329
345
  getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;