@pisell/pisellos 0.0.425 → 0.0.427

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.
@@ -358,7 +358,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
358
358
  };
359
359
  setOtherData(key: string, value: any): void;
360
360
  getOtherData(key: string): any;
361
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
361
+ getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
362
362
  /**
363
363
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
364
364
  *
@@ -4259,12 +4259,28 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
4259
4259
  // 总量=每个资源在每个时间片内资源总量之和
4260
4260
  var isAllResourceTypesUseable = true;
4261
4261
  openResources.forEach(function (resource) {
4262
+ var _resource$renderList;
4262
4263
  // if (!isAllResourceTypesUseable) return;
4263
4264
 
4264
4265
  // 获取当前资源类型的资源列表
4265
4266
  var currentResourcesList = allProductResources.filter(function (n) {
4266
4267
  return n.form_id === resource.resource_type_id;
4267
4268
  });
4269
+ // 如果resource.renderList里含有 onlyComputed 的数据,需要把 currentResourcesList 的数据也修正回来
4270
+ (_resource$renderList = resource.renderList) === null || _resource$renderList === void 0 || _resource$renderList.forEach(function (item) {
4271
+ if (item.onlyComputed) {
4272
+ var targetIndex = currentResourcesList.findIndex(function (n) {
4273
+ return n.id === item.id;
4274
+ });
4275
+ if (targetIndex && targetIndex !== -1) {
4276
+ currentResourcesList[targetIndex].onlyComputed = true;
4277
+ }
4278
+ }
4279
+ });
4280
+ // currentResourcesList 排序,onlyComputed 的资源排在前面先计算
4281
+ currentResourcesList.sort(function (a, b) {
4282
+ return a.onlyComputed ? -1 : 1;
4283
+ });
4268
4284
  var isAnyResourceUseableInType = false;
4269
4285
  currentResourcesList === null || currentResourcesList === void 0 || currentResourcesList.forEach(function (m) {
4270
4286
  // 遍历所有资源的上工时间片
@@ -4278,10 +4294,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
4278
4294
  // 如果在这个区间的时间一个都没有,可以直接认为这个资源不可用
4279
4295
  if (mTimes.length === 0) return;
4280
4296
  // 如果资源可用则把他的容量纳入总计
4281
- if (resource.type === 'multiple') {
4282
- summaryCount += m.capacity;
4283
- } else {
4284
- summaryCount += 1;
4297
+ if (!m.onlyComputed) {
4298
+ if (resource.type === 'multiple') {
4299
+ summaryCount += m.capacity;
4300
+ } else {
4301
+ summaryCount += 1;
4302
+ }
4285
4303
  }
4286
4304
  var isAnyTimeSliceUseable = false;
4287
4305
  mTimes.forEach(function (childTiem) {
@@ -33,9 +33,14 @@ export var formatDefaultCapacitys = function formatDefaultCapacitys(_ref) {
33
33
  window.sendWarningLog({
34
34
  title: '未找到套餐 capacity 配置',
35
35
  content: [{
36
- product_id: id,
37
- variant_id: variantId,
38
- package: JSON.stringify((capacity === null || capacity === void 0 ? void 0 : capacity.package) || [])
36
+ key: 'product_id',
37
+ value: id
38
+ }, {
39
+ key: 'variant_id',
40
+ value: variantId
41
+ }, {
42
+ key: 'package',
43
+ value: JSON.stringify((capacity === null || capacity === void 0 ? void 0 : capacity.package) || [])
39
44
  }]
40
45
  });
41
46
  }
@@ -444,6 +444,10 @@ export var getTimeSlicesByResource = function getTimeSlicesByResource(_ref5) {
444
444
  // 解析开始和结束时间
445
445
  var startTime = dayjs("".concat(time.start_at));
446
446
  var endTime = dayjs("".concat(time.end_at));
447
+ // 结束时间要做修复,如果time.end_at 是超过了 currentDate 的那一天,则把 end_at 设置为 currentDate 那一天的 23:59:59
448
+ if (endTime.isAfter(dayjs(currentDate).endOf('day'))) {
449
+ endTime = dayjs(currentDate).endOf('day');
450
+ }
447
451
 
448
452
  // 当前切片的开始时间
449
453
  var currentStart = startTime;
@@ -123,7 +123,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
123
123
  * 获取当前的客户搜索条件
124
124
  * @returns 当前搜索条件
125
125
  */
126
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
126
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
127
127
  /**
128
128
  * 获取客户列表状态(包含滚动加载相关状态)
129
129
  * @returns 客户状态
@@ -485,7 +485,6 @@ export var filterDiscountListByBookingTime = function filterDiscountListByBookin
485
485
  }
486
486
  });
487
487
  };
488
-
489
488
  /**
490
489
  * 判断是否是订单级别的固定金额折扣卡
491
490
  * @param discount 折扣
@@ -358,7 +358,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
358
358
  };
359
359
  setOtherData(key: string, value: any): void;
360
360
  getOtherData(key: string): any;
361
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
361
+ getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
362
362
  /**
363
363
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
364
364
  *
@@ -2983,9 +2983,21 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2983
2983
  const resourcesUseableMap = {};
2984
2984
  let isAllResourceTypesUseable = true;
2985
2985
  openResources.forEach((resource) => {
2986
+ var _a2;
2986
2987
  const currentResourcesList = allProductResources.filter(
2987
2988
  (n) => n.form_id === resource.resource_type_id
2988
2989
  );
2990
+ (_a2 = resource.renderList) == null ? void 0 : _a2.forEach((item2) => {
2991
+ if (item2.onlyComputed) {
2992
+ const targetIndex = currentResourcesList.findIndex((n) => n.id === item2.id);
2993
+ if (targetIndex && targetIndex !== -1) {
2994
+ currentResourcesList[targetIndex].onlyComputed = true;
2995
+ }
2996
+ }
2997
+ });
2998
+ currentResourcesList.sort((a, b) => {
2999
+ return a.onlyComputed ? -1 : 1;
3000
+ });
2989
3001
  let isAnyResourceUseableInType = false;
2990
3002
  currentResourcesList == null ? void 0 : currentResourcesList.forEach((m) => {
2991
3003
  const mTimes = m.times.filter((n) => {
@@ -2993,10 +3005,12 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2993
3005
  });
2994
3006
  if (mTimes.length === 0)
2995
3007
  return;
2996
- if (resource.type === "multiple") {
2997
- summaryCount += m.capacity;
2998
- } else {
2999
- summaryCount += 1;
3008
+ if (!m.onlyComputed) {
3009
+ if (resource.type === "multiple") {
3010
+ summaryCount += m.capacity;
3011
+ } else {
3012
+ summaryCount += 1;
3013
+ }
3000
3014
  }
3001
3015
  let isAnyTimeSliceUseable = false;
3002
3016
  mTimes.forEach((childTiem) => {
@@ -54,7 +54,20 @@ var formatDefaultCapacitys = ({
54
54
  if (!item && (window == null ? void 0 : window.sendWarningLog)) {
55
55
  window.sendWarningLog({
56
56
  title: "未找到套餐 capacity 配置",
57
- content: [{ product_id: id, variant_id: variantId, package: JSON.stringify((capacity == null ? void 0 : capacity.package) || []) }]
57
+ content: [
58
+ {
59
+ key: "product_id",
60
+ value: id
61
+ },
62
+ {
63
+ key: "variant_id",
64
+ value: variantId
65
+ },
66
+ {
67
+ key: "package",
68
+ value: JSON.stringify((capacity == null ? void 0 : capacity.package) || [])
69
+ }
70
+ ]
58
71
  });
59
72
  }
60
73
  return {
@@ -353,7 +353,10 @@ var getTimeSlicesByResource = ({
353
353
  });
354
354
  times.forEach((time) => {
355
355
  const startTime = (0, import_dayjs.default)(`${time.start_at}`);
356
- const endTime = (0, import_dayjs.default)(`${time.end_at}`);
356
+ let endTime = (0, import_dayjs.default)(`${time.end_at}`);
357
+ if (endTime.isAfter((0, import_dayjs.default)(currentDate).endOf("day"))) {
358
+ endTime = (0, import_dayjs.default)(currentDate).endOf("day");
359
+ }
357
360
  let currentStart = startTime;
358
361
  while (true) {
359
362
  const currentEnd = currentStart.add(duration, "minute");
@@ -123,7 +123,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
123
123
  * 获取当前的客户搜索条件
124
124
  * @returns 当前搜索条件
125
125
  */
126
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
126
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
127
127
  /**
128
128
  * 获取客户列表状态(包含滚动加载相关状态)
129
129
  * @returns 客户状态
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.425",
4
+ "version": "0.0.427",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",