@pisell/pisellos 2.1.58 → 2.1.59

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.
@@ -111,6 +111,8 @@ export interface Discount {
111
111
  data: any[];
112
112
  };
113
113
  num?: number;
114
+ start_date?: string;
115
+ start_time?: string;
114
116
  }
115
117
  export interface DiscountState {
116
118
  discountList: Discount[];
@@ -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(): "duration" | "session" | "normal";
52
+ getProductType(): "normal" | "duration" | "session";
53
53
  }
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
342
342
  };
343
343
  setOtherData(key: string, value: any): void;
344
344
  getOtherData(key: string): any;
345
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
345
+ getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
346
346
  /**
347
347
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
348
348
  *
@@ -115,7 +115,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
115
115
  * 获取当前的客户搜索条件
116
116
  * @returns 当前搜索条件
117
117
  */
118
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
118
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
119
119
  /**
120
120
  * 获取客户列表状态(包含滚动加载相关状态)
121
121
  * @returns 客户状态
@@ -442,10 +442,24 @@ export var filterDiscountListByBookingTime = function filterDiscountListByBookin
442
442
  return discountList;
443
443
  }
444
444
  return discountList.filter(function (discount) {
445
- var _discount$metadata2, _discount$metadata3, _discount$custom_sche;
446
- if (!(discount !== null && discount !== void 0 && (_discount$metadata2 = discount.metadata) !== null && _discount$metadata2 !== void 0 && _discount$metadata2.validity_type) || (discount === null || discount === void 0 || (_discount$metadata3 = discount.metadata) === null || _discount$metadata3 === void 0 ? void 0 : _discount$metadata3.validity_type) === "fixed_validity") {
445
+ var _discount$metadata2;
446
+ if ((discount === null || discount === void 0 || (_discount$metadata2 = discount.metadata) === null || _discount$metadata2 === void 0 ? void 0 : _discount$metadata2.validity_type) === "custom_schedule_validity") {
447
+ var _discount$custom_sche;
448
+ return getDateIsInSchedule(bookingTime, ((_discount$custom_sche = discount.custom_schedule_snapshot) === null || _discount$custom_sche === void 0 ? void 0 : _discount$custom_sche.data) || []);
449
+ }
450
+ try {
451
+ var isHasStart = !!discount.start_date && !!discount.start_time;
452
+ var startDate = dayjs("".concat(discount.start_date, " ").concat(discount.start_time));
453
+ var bookingTimeDayjs = dayjs(bookingTime);
454
+
455
+ // 判断预约时间是否在开始时间之后
456
+ var isAfterStart = isHasStart ? bookingTimeDayjs.isSameOrAfter(startDate) : true;
457
+
458
+ // 判断预约时间是否在过期时间之前(expire_time 为空时为长期有效)
459
+ var isBeforeExpire = discount.expire_time ? bookingTimeDayjs.isSameOrBefore(dayjs(discount.expire_time)) : true;
460
+ return isAfterStart && isBeforeExpire;
461
+ } catch (error) {
447
462
  return true;
448
463
  }
449
- return getDateIsInSchedule(bookingTime, ((_discount$custom_sche = discount.custom_schedule_snapshot) === null || _discount$custom_sche === void 0 ? void 0 : _discount$custom_sche.data) || []);
450
464
  });
451
465
  };
@@ -111,6 +111,8 @@ export interface Discount {
111
111
  data: any[];
112
112
  };
113
113
  num?: number;
114
+ start_date?: string;
115
+ start_time?: string;
114
116
  }
115
117
  export interface DiscountState {
116
118
  discountList: Discount[];
@@ -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(): "duration" | "session" | "normal";
52
+ getProductType(): "normal" | "duration" | "session";
53
53
  }
@@ -342,7 +342,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
342
342
  };
343
343
  setOtherData(key: string, value: any): void;
344
344
  getOtherData(key: string): any;
345
- getProductTypeById(id: number): Promise<"normal" | "duration" | "session">;
345
+ getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
346
346
  /**
347
347
  * 提供给 UI 的方法,减轻 UI 层的计算压力,UI 层只需要传递 cartItemId 和 resourceCode 即返回对应的 renderList
348
348
  *
@@ -115,7 +115,7 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
115
115
  * 获取当前的客户搜索条件
116
116
  * @returns 当前搜索条件
117
117
  */
118
- getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "skip" | "num">;
118
+ getCurrentCustomerSearchParams(): Omit<import("../../modules").ShopGetCustomerListParams, "num" | "skip">;
119
119
  /**
120
120
  * 获取客户列表状态(包含滚动加载相关状态)
121
121
  * @returns 客户状态
@@ -122,12 +122,6 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
122
122
  throw error;
123
123
  }
124
124
  }
125
- /**
126
- * 初始化外设扫码结果监听
127
- */
128
- initPeripheralsListener() {
129
- this.scan.initPeripheralsListener();
130
- }
131
125
  /**
132
126
  * 获取商品列表(不加载到模块中)
133
127
  * @returns 商品列表
@@ -290,11 +290,20 @@ var filterDiscountListByBookingTime = (discountList, bookingTime) => {
290
290
  return discountList;
291
291
  }
292
292
  return discountList.filter((discount) => {
293
- var _a, _b, _c;
294
- if (!((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.validity_type) || ((_b = discount == null ? void 0 : discount.metadata) == null ? void 0 : _b.validity_type) === "fixed_validity") {
293
+ var _a, _b;
294
+ if (((_a = discount == null ? void 0 : discount.metadata) == null ? void 0 : _a.validity_type) === "custom_schedule_validity") {
295
+ return getDateIsInSchedule(bookingTime, ((_b = discount.custom_schedule_snapshot) == null ? void 0 : _b.data) || []);
296
+ }
297
+ try {
298
+ const isHasStart = !!discount.start_date && !!discount.start_time;
299
+ const startDate = (0, import_dayjs.default)(`${discount.start_date} ${discount.start_time}`);
300
+ const bookingTimeDayjs = (0, import_dayjs.default)(bookingTime);
301
+ const isAfterStart = isHasStart ? bookingTimeDayjs.isSameOrAfter(startDate) : true;
302
+ const isBeforeExpire = discount.expire_time ? bookingTimeDayjs.isSameOrBefore((0, import_dayjs.default)(discount.expire_time)) : true;
303
+ return isAfterStart && isBeforeExpire;
304
+ } catch (error) {
295
305
  return true;
296
306
  }
297
- return getDateIsInSchedule(bookingTime, ((_c = discount.custom_schedule_snapshot) == null ? void 0 : _c.data) || []);
298
307
  });
299
308
  };
300
309
  // Annotate the CommonJS export names for ESM import in node:
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.1.58",
4
+ "version": "2.1.59",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",