@pisell/pisellos 0.0.43 → 0.0.45

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.
Files changed (127) hide show
  1. package/dist/modules/Account/index.d.ts +2 -6
  2. package/dist/modules/Account/index.js +21 -103
  3. package/dist/modules/Account/types.d.ts +12 -1
  4. package/dist/modules/AccountList/index.d.ts +19 -0
  5. package/dist/modules/AccountList/index.js +224 -70
  6. package/dist/modules/AccountList/types.d.ts +33 -1
  7. package/dist/modules/AccountList/types.js +8 -0
  8. package/dist/modules/AccountList/utils.d.ts +9 -0
  9. package/dist/modules/AccountList/utils.js +25 -0
  10. package/dist/modules/BaseModule.d.ts +2 -2
  11. package/dist/modules/BaseModule.js +1 -1
  12. package/dist/modules/Cart/index.d.ts +5 -5
  13. package/dist/modules/Cart/index.js +32 -19
  14. package/dist/modules/Cart/types.d.ts +18 -4
  15. package/dist/modules/Cart/utils.d.ts +29 -5
  16. package/dist/modules/Cart/utils.js +72 -26
  17. package/dist/modules/Date/index.d.ts +6 -6
  18. package/dist/modules/Date/index.js +41 -55
  19. package/dist/modules/Date/types.d.ts +22 -6
  20. package/dist/modules/Date/utils.d.ts +4 -3
  21. package/dist/modules/Date/utils.js +74 -23
  22. package/dist/modules/Discount/index.d.ts +4 -4
  23. package/dist/modules/Discount/index.js +11 -11
  24. package/dist/modules/Order/index.d.ts +11 -5
  25. package/dist/modules/Order/index.js +39 -18
  26. package/dist/modules/Order/types.d.ts +10 -3
  27. package/dist/modules/Product/index.d.ts +4 -1
  28. package/dist/modules/Product/index.js +22 -0
  29. package/dist/modules/Product/types.d.ts +7 -3
  30. package/dist/modules/ProductList/index.js +11 -5
  31. package/dist/modules/Resource/utils.js +1 -1
  32. package/dist/modules/Rules/index.d.ts +4 -4
  33. package/dist/modules/Rules/index.js +11 -11
  34. package/dist/modules/Rules/types.d.ts +1 -1
  35. package/dist/modules/Schedule/index.d.ts +8 -3
  36. package/dist/modules/Schedule/index.js +45 -5
  37. package/dist/modules/Schedule/type.d.ts +7 -7
  38. package/dist/modules/Schedule/types.d.ts +8 -8
  39. package/dist/modules/Schedule/utils.d.ts +9 -3
  40. package/dist/modules/Schedule/utils.js +77 -48
  41. package/dist/modules/Step/index.d.ts +14 -3
  42. package/dist/modules/Step/index.js +54 -2
  43. package/dist/modules/Summary/index.d.ts +5 -5
  44. package/dist/modules/Summary/index.js +7 -7
  45. package/dist/modules/Summary/types.d.ts +2 -2
  46. package/dist/modules/Summary/utils.d.ts +4 -4
  47. package/dist/modules/Summary/utils.js +3 -3
  48. package/dist/plugins/index.d.ts +3 -3
  49. package/dist/plugins/request.d.ts +3 -3
  50. package/dist/plugins/request.js +30 -30
  51. package/dist/plugins/shopStore.d.ts +1 -1
  52. package/dist/solution/BookingByStep/index.d.ts +65 -16
  53. package/dist/solution/BookingByStep/index.js +553 -216
  54. package/dist/solution/BookingByStep/types.d.ts +2 -2
  55. package/dist/solution/BookingByStep/types.js +9 -9
  56. package/dist/solution/BookingByStep/utils/products.d.ts +1 -1
  57. package/dist/solution/BookingByStep/utils/products.js +3 -0
  58. package/dist/solution/BookingByStep/utils/resources.d.ts +5 -5
  59. package/dist/solution/BookingByStep/utils/resources.js +11 -11
  60. package/dist/solution/ShopDiscount/index.d.ts +4 -4
  61. package/dist/solution/ShopDiscount/index.js +16 -16
  62. package/dist/solution/ShopDiscount/types.d.ts +2 -2
  63. package/dist/solution/ShopDiscount/utils.js +1 -1
  64. package/lib/core/index.js +7 -2
  65. package/lib/modules/Account/index.d.ts +2 -6
  66. package/lib/modules/Account/index.js +15 -30
  67. package/lib/modules/Account/types.d.ts +12 -1
  68. package/lib/modules/AccountList/index.d.ts +19 -0
  69. package/lib/modules/AccountList/index.js +109 -12
  70. package/lib/modules/AccountList/types.d.ts +33 -1
  71. package/lib/modules/AccountList/utils.d.ts +9 -0
  72. package/lib/modules/AccountList/utils.js +39 -0
  73. package/lib/modules/BaseModule.d.ts +2 -2
  74. package/lib/modules/BaseModule.js +14 -3
  75. package/lib/modules/Cart/index.d.ts +5 -5
  76. package/lib/modules/Cart/index.js +27 -6
  77. package/lib/modules/Cart/types.d.ts +18 -4
  78. package/lib/modules/Cart/utils.d.ts +29 -5
  79. package/lib/modules/Cart/utils.js +47 -3
  80. package/lib/modules/Date/index.d.ts +6 -6
  81. package/lib/modules/Date/index.js +6 -6
  82. package/lib/modules/Date/types.d.ts +22 -6
  83. package/lib/modules/Date/utils.d.ts +4 -3
  84. package/lib/modules/Date/utils.js +37 -6
  85. package/lib/modules/Discount/index.d.ts +4 -4
  86. package/lib/modules/Discount/index.js +9 -2
  87. package/lib/modules/Guests/index.js +4 -1
  88. package/lib/modules/Order/index.d.ts +11 -5
  89. package/lib/modules/Order/index.js +18 -3
  90. package/lib/modules/Order/types.d.ts +10 -3
  91. package/lib/modules/Payment/index.js +1 -6
  92. package/lib/modules/Product/index.d.ts +4 -1
  93. package/lib/modules/Product/index.js +16 -0
  94. package/lib/modules/Product/types.d.ts +7 -3
  95. package/lib/modules/ProductList/index.js +21 -7
  96. package/lib/modules/Resource/index.js +4 -1
  97. package/lib/modules/Resource/utils.js +7 -4
  98. package/lib/modules/Rules/index.d.ts +4 -4
  99. package/lib/modules/Rules/types.d.ts +1 -1
  100. package/lib/modules/Schedule/index.d.ts +8 -3
  101. package/lib/modules/Schedule/index.js +33 -2
  102. package/lib/modules/Schedule/type.d.ts +7 -7
  103. package/lib/modules/Schedule/types.d.ts +8 -8
  104. package/lib/modules/Schedule/utils.d.ts +9 -3
  105. package/lib/modules/Schedule/utils.js +32 -4
  106. package/lib/modules/Step/index.d.ts +14 -3
  107. package/lib/modules/Step/index.js +38 -1
  108. package/lib/modules/Summary/index.d.ts +5 -5
  109. package/lib/modules/Summary/types.d.ts +2 -2
  110. package/lib/modules/Summary/utils.d.ts +4 -4
  111. package/lib/plugins/index.d.ts +3 -3
  112. package/lib/plugins/request.d.ts +3 -3
  113. package/lib/plugins/request.js +48 -11
  114. package/lib/plugins/shopStore.d.ts +1 -1
  115. package/lib/solution/BookingByStep/index.d.ts +65 -16
  116. package/lib/solution/BookingByStep/index.js +351 -39
  117. package/lib/solution/BookingByStep/types.d.ts +2 -2
  118. package/lib/solution/BookingByStep/types.js +36 -9
  119. package/lib/solution/BookingByStep/utils/products.d.ts +1 -1
  120. package/lib/solution/BookingByStep/utils/products.js +3 -0
  121. package/lib/solution/BookingByStep/utils/resources.d.ts +5 -5
  122. package/lib/solution/BookingByStep/utils/resources.js +103 -52
  123. package/lib/solution/BuyTickets/index.js +34 -20
  124. package/lib/solution/ShopDiscount/index.d.ts +4 -4
  125. package/lib/solution/ShopDiscount/index.js +10 -2
  126. package/lib/solution/ShopDiscount/types.d.ts +2 -2
  127. package/package.json +4 -2
@@ -18,7 +18,7 @@ export type ScheduleItem = {
18
18
  repeat_rule: {
19
19
  end: {
20
20
  /** 截止类型 */
21
- type: "date" | "never";
21
+ type: 'date' | 'never';
22
22
  /** 结束时间 */
23
23
  end_date: string | null;
24
24
  occurrence: any | null;
@@ -28,13 +28,13 @@ export type ScheduleItem = {
28
28
  included_date: ExcIncDate[];
29
29
  frequency_date: number[];
30
30
  };
31
- repeat_type: "daily" | "none" | "weekly";
31
+ repeat_type: 'daily' | 'none' | 'weekly';
32
32
  /** 日程类型
33
33
  * standard: 标准日程
34
34
  * time-slots: 时间段日程
35
35
  * designation: 指定日期日程
36
36
  * */
37
- type: "standard" | "time-slots" | "designation";
37
+ type: 'standard' | 'time-slots' | 'designation';
38
38
  conflict?: boolean;
39
39
  time_slot: {
40
40
  start_time: string;
@@ -77,7 +77,7 @@ export type ScheduleFormOtherValue = {
77
77
  excludedStatus: boolean;
78
78
  /** 是否包含排除日期 */
79
79
  includeStatus: boolean;
80
- type: "standard" | "time-slots" | "designation";
80
+ type: 'standard' | 'time-slots' | 'designation';
81
81
  };
82
82
  export type ExcIncDate = {
83
83
  start: string;
@@ -89,15 +89,15 @@ export type ScheduleFormData = {
89
89
  /** 日程名称 */
90
90
  name: {
91
91
  en: string;
92
- "zh-CN": string;
93
- "zh-HK": string;
92
+ 'zh-CN': string;
93
+ 'zh-HK': string;
94
94
  original: string;
95
95
  } | string;
96
96
  /** 重复模式
97
97
  * 0:不重复
98
98
  * 1:按天重复
99
99
  * 2:按周重复 */
100
- repeat_type: "0" | "1" | "2";
100
+ repeat_type: '0' | '1' | '2';
101
101
  /** 备注 */
102
102
  note: string;
103
103
  /** 指定的开始时间结束时间 */
@@ -1,4 +1,4 @@
1
- import dayjs from "dayjs";
1
+ import dayjs from 'dayjs';
2
2
  export interface ScheduleState {
3
3
  scheduleList: ScheduleItem[];
4
4
  availabilityDateList: ScheduleAvailabilityDateItem[];
@@ -29,7 +29,7 @@ export type ScheduleItem = {
29
29
  repeat_rule: {
30
30
  end: {
31
31
  /** 截止类型 */
32
- type: "date" | "never";
32
+ type: 'date' | 'never';
33
33
  /** 结束时间 */
34
34
  end_date: string | null;
35
35
  occurrence: any | null;
@@ -39,13 +39,13 @@ export type ScheduleItem = {
39
39
  included_date: ExcIncDate[];
40
40
  frequency_date: number[];
41
41
  };
42
- repeat_type: "daily" | "none" | "weekly";
42
+ repeat_type: 'daily' | 'none' | 'weekly';
43
43
  /** 日程类型
44
44
  * standard: 标准日程
45
45
  * time-slots: 时间段日程
46
46
  * designation: 指定日期日程
47
47
  * */
48
- type: "standard" | "time-slots" | "designation";
48
+ type: 'standard' | 'time-slots' | 'designation';
49
49
  conflict?: boolean;
50
50
  time_slot: {
51
51
  start_time: string;
@@ -88,7 +88,7 @@ export type ScheduleFormOtherValue = {
88
88
  excludedStatus: boolean;
89
89
  /** 是否包含排除日期 */
90
90
  includeStatus: boolean;
91
- type: "standard" | "time-slots" | "designation";
91
+ type: 'standard' | 'time-slots' | 'designation';
92
92
  };
93
93
  export type ExcIncDate = {
94
94
  start: string;
@@ -100,15 +100,15 @@ export type ScheduleFormData = {
100
100
  /** 日程名称 */
101
101
  name: {
102
102
  en: string;
103
- "zh-CN": string;
104
- "zh-HK": string;
103
+ 'zh-CN': string;
104
+ 'zh-HK': string;
105
105
  original: string;
106
106
  } | string;
107
107
  /** 重复模式
108
108
  * 0:不重复
109
109
  * 1:按天重复
110
110
  * 2:按周重复 */
111
- repeat_type: "0" | "1" | "2";
111
+ repeat_type: '0' | '1' | '2';
112
112
  /** 备注 */
113
113
  note: string;
114
114
  /** 指定的开始时间结束时间 */
@@ -1,11 +1,11 @@
1
- import { ScheduleFormData, ScheduleFormOtherValue, ScheduleItem, ScheduleAllMap } from "./types";
1
+ import { ScheduleFormData, ScheduleFormOtherValue, ScheduleItem, ScheduleAllMap } from './types';
2
2
  /**
3
3
  * 根据日程配置生成日历数据
4
4
  * @param values
5
5
  * @param others
6
6
  * @param type
7
7
  */
8
- export declare const calcCalendarDataBySchedule: (values: ScheduleFormData, others: ScheduleFormOtherValue, type?: "standard" | "time-slots" | "designation") => any[];
8
+ export declare const calcCalendarDataBySchedule: (values: ScheduleFormData, others: ScheduleFormOtherValue, type?: 'standard' | 'time-slots' | 'designation') => any[];
9
9
  /**
10
10
  * 获取开始时间和结束时间之间的所有日期
11
11
  * @param startDate
@@ -46,7 +46,7 @@ export declare const formatScheduleResult: (schedule: ScheduleItem) => {
46
46
  };
47
47
  export declare const calcScheduleDateRange: (schedule: ScheduleItem) => any[];
48
48
  export declare const calcCalendarDataBySchedules: (schedules: ScheduleItem[]) => unknown[];
49
- export declare const calcMinTimeMaxTimeBySchedules: (schedules: ScheduleItem[], scheduleAllMap: ScheduleAllMap, selectDate?: string) => {};
49
+ export declare const calcMinTimeMaxTimeBySchedules: (schedules: ScheduleItem[], scheduleAllMap?: ScheduleAllMap, selectDate?: string) => {};
50
50
  /**
51
51
  * @title: 格式化日程数据
52
52
  * @description:
@@ -59,3 +59,9 @@ export declare const calcMinTimeMaxTimeBySchedules: (schedules: ScheduleItem[],
59
59
  * @Date: 2024-09-04 11:54
60
60
  */
61
61
  export declare const formatScheduleData: (relation: Array<any>, table_type?: string, item_type?: string, isExcluded?: boolean) => any;
62
+ export interface TimeRange {
63
+ start: string;
64
+ end: string;
65
+ count?: number;
66
+ }
67
+ export declare function getAllSortedDateRanges(schedules: Record<string, any>): TimeRange[];
@@ -39,6 +39,7 @@ __export(utils_exports, {
39
39
  calcScheduleDateRange: () => calcScheduleDateRange,
40
40
  formatScheduleData: () => formatScheduleData,
41
41
  formatScheduleResult: () => formatScheduleResult,
42
+ getAllSortedDateRanges: () => getAllSortedDateRanges,
42
43
  getDaysByStartEnd: () => getDaysByStartEnd,
43
44
  isAllDay: () => isAllDay
44
45
  });
@@ -490,7 +491,7 @@ var calcCalendarDataBySchedules = (schedules) => {
490
491
  var calcMinTimeMaxTimeBySchedules = (schedules, scheduleAllMap, selectDate) => {
491
492
  return schedules.reduce((pre, cur) => {
492
493
  var _a;
493
- let dateRange = ((_a = scheduleAllMap[cur.id]) == null ? void 0 : _a.dateRange) || calcScheduleDateRange(cur);
494
+ let dateRange = ((_a = scheduleAllMap == null ? void 0 : scheduleAllMap[cur.id]) == null ? void 0 : _a.dateRange) || calcScheduleDateRange(cur);
494
495
  let dateRangeFormat = [];
495
496
  if (selectDate) {
496
497
  const dateRangeTmp = [];
@@ -543,18 +544,44 @@ var calcMinTimeMaxTimeBySchedules = (schedules, scheduleAllMap, selectDate) => {
543
544
  var formatScheduleData = (relation, table_type, item_type, isExcluded) => {
544
545
  const _relation = relation || [];
545
546
  if (table_type && item_type && isExcluded) {
546
- return _relation.find((item) => (item == null ? void 0 : item.relation_table_type) === table_type && (item == null ? void 0 : item.item_type) !== item_type);
547
+ return _relation.find(
548
+ (item) => (item == null ? void 0 : item.relation_table_type) === table_type && (item == null ? void 0 : item.item_type) !== item_type
549
+ );
547
550
  }
548
551
  if (table_type && item_type) {
549
- return _relation.find((item) => (item == null ? void 0 : item.relation_table_type) === table_type && (item == null ? void 0 : item.item_type) === item_type);
552
+ return _relation.find(
553
+ (item) => (item == null ? void 0 : item.relation_table_type) === table_type && (item == null ? void 0 : item.item_type) === item_type
554
+ );
550
555
  }
551
556
  if (table_type) {
552
- return _relation.some((item) => (item == null ? void 0 : item.relation_table_type) === table_type);
557
+ return _relation.some(
558
+ (item) => (item == null ? void 0 : item.relation_table_type) === table_type
559
+ );
553
560
  }
554
561
  if (item_type) {
555
562
  return _relation.find((item) => (item == null ? void 0 : item.item_type) === item_type);
556
563
  }
557
564
  };
565
+ function getAllSortedDateRanges(schedules) {
566
+ const allDateRanges = [];
567
+ Object.values(schedules).forEach((schedule) => {
568
+ if (schedule.dateRange && Array.isArray(schedule.dateRange)) {
569
+ allDateRanges.push(...schedule.dateRange);
570
+ }
571
+ });
572
+ if (allDateRanges.length === 0) {
573
+ console.log("No dateRanges found in schedules:", schedules);
574
+ return [];
575
+ }
576
+ return allDateRanges.sort((a, b) => {
577
+ const startTimeCompare = (0, import_dayjs.default)(a.start).valueOf() - (0, import_dayjs.default)(b.start).valueOf();
578
+ if (startTimeCompare !== 0)
579
+ return startTimeCompare;
580
+ const durationA = (0, import_dayjs.default)(a.end).valueOf() - (0, import_dayjs.default)(a.start).valueOf();
581
+ const durationB = (0, import_dayjs.default)(b.end).valueOf() - (0, import_dayjs.default)(b.start).valueOf();
582
+ return durationA - durationB;
583
+ });
584
+ }
558
585
  // Annotate the CommonJS export names for ESM import in node:
559
586
  0 && (module.exports = {
560
587
  calcCalendarDataByDesignation,
@@ -567,6 +594,7 @@ var formatScheduleData = (relation, table_type, item_type, isExcluded) => {
567
594
  calcScheduleDateRange,
568
595
  formatScheduleData,
569
596
  formatScheduleResult,
597
+ getAllSortedDateRanges,
570
598
  getDaysByStartEnd,
571
599
  isAllDay
572
600
  });
@@ -1,6 +1,6 @@
1
- import { Module, PisellCore, ModuleOptions } from "../../types";
2
- import { BaseModule } from "../BaseModule";
3
- import { IStep, IStepModuleAPI } from "./tyeps";
1
+ import { Module, PisellCore, ModuleOptions } from '../../types';
2
+ import { BaseModule } from '../BaseModule';
3
+ import { IStep, IStepModuleAPI } from './tyeps';
4
4
  export declare class StepModule extends BaseModule implements Module, IStepModuleAPI {
5
5
  protected defaultName: string;
6
6
  protected defaultVersion: string;
@@ -19,5 +19,16 @@ export declare class StepModule extends BaseModule implements Module, IStepModul
19
19
  prevStep(): void;
20
20
  nextStep(): void;
21
21
  gotoStep(stepIndex: number): void;
22
+ /**
23
+ * 添加步骤
24
+ * @param step 步骤
25
+ * @param key 步骤的 key,如果存在则插入到该步骤之后,否则插入到当前步骤之后
26
+ */
27
+ addStep(step: IStep, key?: string): void;
28
+ /**
29
+ * 删除步骤
30
+ * @param key 步骤的 key
31
+ */
32
+ removeStep(key: string): void;
22
33
  storeChange(): void;
23
34
  }
@@ -83,9 +83,46 @@ var StepModule = class extends import_BaseModule.BaseModule {
83
83
  gotoStep(stepIndex) {
84
84
  this.setCurrentStep(stepIndex);
85
85
  }
86
+ /**
87
+ * 添加步骤
88
+ * @param step 步骤
89
+ * @param key 步骤的 key,如果存在则插入到该步骤之后,否则插入到当前步骤之后
90
+ */
91
+ addStep(step, key) {
92
+ let stepList = this.store.stepList;
93
+ const index = stepList.findIndex((n) => n.key === step.key);
94
+ if (index !== -1) {
95
+ console.log("[StepModule] 步骤已存在,添加失败");
96
+ return;
97
+ }
98
+ if (key) {
99
+ const index2 = this.store.stepList.findIndex((n) => n.key === key);
100
+ if (index2 !== -1) {
101
+ stepList.splice(index2 + 1, 0, step);
102
+ } else {
103
+ stepList = [...stepList, step];
104
+ }
105
+ } else {
106
+ stepList.splice(this.store.currentStepIndex + 1, 0, step);
107
+ }
108
+ this.store.stepList = [...stepList];
109
+ }
110
+ /**
111
+ * 删除步骤
112
+ * @param key 步骤的 key
113
+ */
114
+ removeStep(key) {
115
+ const newStepList = this.store.stepList.filter((n) => n.key !== key);
116
+ this.store.stepList = [...newStepList];
117
+ }
86
118
  storeChange() {
87
119
  if (this.openCache) {
88
- this.checkSaveCache({ cacheId: this.cacheId, fatherModule: this.fatherModule, store: this.store, cacheKey: ["currentStepIndex", "currentStep", "stepList"] });
120
+ this.checkSaveCache({
121
+ cacheId: this.cacheId,
122
+ fatherModule: this.fatherModule,
123
+ store: this.store,
124
+ cacheKey: ["currentStepIndex", "currentStep", "stepList"]
125
+ });
89
126
  }
90
127
  }
91
128
  };
@@ -1,7 +1,7 @@
1
- import { Module, PisellCore, ModuleOptions } from "../../types";
2
- import { BaseModule } from "../BaseModule";
3
- import { CartItem } from "../Cart/types";
4
- import { ISummaryState, ISummaryModuleAPI } from "./types";
1
+ import { Module, PisellCore, ModuleOptions } from '../../types';
2
+ import { BaseModule } from '../BaseModule';
3
+ import { CartItem } from '../Cart/types';
4
+ import { ISummaryState, ISummaryModuleAPI } from './types';
5
5
  export declare class SummaryModule extends BaseModule implements Module, ISummaryModuleAPI {
6
6
  protected defaultName: string;
7
7
  protected defaultVersion: string;
@@ -13,7 +13,7 @@ export declare class SummaryModule extends BaseModule implements Module, ISummar
13
13
  private fatherModule;
14
14
  constructor(name?: string, version?: string);
15
15
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
16
- getSummary(cartItems: CartItem[]): Promise<ISummaryState["summary"]>;
16
+ getSummary(cartItems: CartItem[]): Promise<ISummaryState['summary']>;
17
17
  /**
18
18
  * 获取协议
19
19
  * @param protocolId 协议ID
@@ -1,4 +1,4 @@
1
- import { CartItem } from "../Cart/types";
1
+ import { CartItem } from '../Cart/types';
2
2
  export interface ISummaryState {
3
3
  summary: {
4
4
  /** 商品总价 */
@@ -30,5 +30,5 @@ export interface IProtocol {
30
30
  id: string;
31
31
  }
32
32
  export interface ISummaryModuleAPI {
33
- getSummary(cartItems: CartItem[]): Promise<ISummaryState["summary"]>;
33
+ getSummary(cartItems: CartItem[]): Promise<ISummaryState['summary']>;
34
34
  }
@@ -1,7 +1,7 @@
1
- import Decimal from "decimal.js";
2
- import { CartItem } from "../Cart/types";
3
- import { ISummaryState } from "./types";
4
- export declare const calculatePriceDetails: (shopInfo: any, items: CartItem[]) => ISummaryState["summary"];
1
+ import Decimal from 'decimal.js';
2
+ import { CartItem } from '../Cart/types';
3
+ import { ISummaryState } from './types';
4
+ export declare const calculatePriceDetails: (shopInfo: any, items: CartItem[]) => ISummaryState['summary'];
5
5
  /**
6
6
  * 计算商品小计(不含其他费用)
7
7
  * @param items - 购物车商品数组
@@ -1,3 +1,3 @@
1
- export * from "./request";
2
- export * from "./window";
3
- export * from "./shopStore";
1
+ export * from './request';
2
+ export * from './window';
3
+ export * from './shopStore';
@@ -1,4 +1,4 @@
1
- import { Plugin } from "../types";
1
+ import { Plugin } from '../types';
2
2
  /**
3
3
  * RequestPlugin 接口定义
4
4
  */
@@ -40,13 +40,13 @@ export interface RequestPlugin extends Plugin {
40
40
  */
41
41
  export interface RequestOptions {
42
42
  url?: string;
43
- method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS";
43
+ method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
44
44
  headers?: Record<string, string>;
45
45
  data?: any;
46
46
  body?: any;
47
47
  params?: Record<string, string | number | boolean>;
48
48
  timeout?: number;
49
- responseType?: "json" | "text" | "arraybuffer" | "blob";
49
+ responseType?: 'json' | 'text' | 'arraybuffer' | 'blob';
50
50
  withCredentials?: boolean;
51
51
  useCache?: boolean;
52
52
  }
@@ -148,11 +148,16 @@ var RequestPluginImpl = class {
148
148
  try {
149
149
  config = await Promise.resolve(interceptor(config));
150
150
  } catch (error) {
151
- const requestError = error instanceof RequestError ? error : new RequestError(error instanceof Error ? error.message : "请求拦截器错误", config);
151
+ const requestError = error instanceof RequestError ? error : new RequestError(
152
+ error instanceof Error ? error.message : "请求拦截器错误",
153
+ config
154
+ );
152
155
  let processedError = requestError;
153
156
  for (const errorInterceptor of this.interceptors.error) {
154
157
  try {
155
- processedError = await Promise.resolve(errorInterceptor(processedError));
158
+ processedError = await Promise.resolve(
159
+ errorInterceptor(processedError)
160
+ );
156
161
  } catch (e) {
157
162
  }
158
163
  }
@@ -164,13 +169,22 @@ var RequestPluginImpl = class {
164
169
  let processedResponse = response;
165
170
  for (const interceptor of this.interceptors.response) {
166
171
  try {
167
- processedResponse = await Promise.resolve(interceptor(processedResponse));
172
+ processedResponse = await Promise.resolve(
173
+ interceptor(processedResponse)
174
+ );
168
175
  } catch (error) {
169
- const requestError = error instanceof RequestError ? error : new RequestError(error instanceof Error ? error.message : "响应拦截器错误", config, null, response);
176
+ const requestError = error instanceof RequestError ? error : new RequestError(
177
+ error instanceof Error ? error.message : "响应拦截器错误",
178
+ config,
179
+ null,
180
+ response
181
+ );
170
182
  let processedError = requestError;
171
183
  for (const errorInterceptor of this.interceptors.error) {
172
184
  try {
173
- processedError = await Promise.resolve(errorInterceptor(processedError));
185
+ processedError = await Promise.resolve(
186
+ errorInterceptor(processedError)
187
+ );
174
188
  } catch (e) {
175
189
  }
176
190
  }
@@ -179,11 +193,16 @@ var RequestPluginImpl = class {
179
193
  }
180
194
  return processedResponse.data;
181
195
  } catch (error) {
182
- const requestError = error instanceof RequestError ? error : new RequestError(error instanceof Error ? error.message : "请求错误", config);
196
+ const requestError = error instanceof RequestError ? error : new RequestError(
197
+ error instanceof Error ? error.message : "请求错误",
198
+ config
199
+ );
183
200
  let processedError = requestError;
184
201
  for (const errorInterceptor of this.interceptors.error) {
185
202
  try {
186
- processedError = await Promise.resolve(errorInterceptor(processedError));
203
+ processedError = await Promise.resolve(
204
+ errorInterceptor(processedError)
205
+ );
187
206
  } catch (e) {
188
207
  }
189
208
  }
@@ -195,13 +214,24 @@ var RequestPluginImpl = class {
195
214
  * 这里实现了一个基于 fetch API 的请求
196
215
  */
197
216
  async performRequest(config) {
198
- const { url, method, headers, data, params, timeout, responseType, withCredentials } = config;
217
+ const {
218
+ url,
219
+ method,
220
+ headers,
221
+ data,
222
+ params,
223
+ timeout,
224
+ responseType,
225
+ withCredentials
226
+ } = config;
199
227
  if (!url) {
200
228
  throw new RequestError("URL不能为空", config);
201
229
  }
202
230
  let fullUrl = url;
203
231
  if (params && Object.keys(params).length > 0) {
204
- const queryString = Object.entries(params).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`).join("&");
232
+ const queryString = Object.entries(params).map(
233
+ ([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`
234
+ ).join("&");
205
235
  fullUrl += (url.includes("?") ? "&" : "?") + queryString;
206
236
  }
207
237
  const fetchOptions = {
@@ -230,7 +260,9 @@ var RequestPluginImpl = class {
230
260
  }
231
261
  });
232
262
  try {
233
- const fetchPromise = typeof fetch !== "undefined" ? fetch(fullUrl, fetchOptions) : Promise.reject(new RequestError("当前环境不支持 fetch API", config));
263
+ const fetchPromise = typeof fetch !== "undefined" ? fetch(fullUrl, fetchOptions) : Promise.reject(
264
+ new RequestError("当前环境不支持 fetch API", config)
265
+ );
234
266
  const response = await Promise.race([fetchPromise, timeoutPromise]);
235
267
  const responseHeaders = {};
236
268
  response.headers.forEach((value, key) => {
@@ -264,7 +296,12 @@ var RequestPluginImpl = class {
264
296
  config
265
297
  };
266
298
  if (!response.ok) {
267
- throw new RequestError(`请求失败,状态码: ${response.status}`, config, fetchOptions, result);
299
+ throw new RequestError(
300
+ `请求失败,状态码: ${response.status}`,
301
+ config,
302
+ fetchOptions,
303
+ result
304
+ );
268
305
  }
269
306
  return result;
270
307
  } finally {
@@ -1,4 +1,4 @@
1
- import { Plugin } from "../types";
1
+ import { Plugin } from '../types';
2
2
  export interface ShopStorePlugin extends Plugin {
3
3
  get(model: string): any;
4
4
  }
@@ -1,12 +1,14 @@
1
- import { Module, PisellCore } from "../../types";
2
- import { BaseModule } from "../../modules/BaseModule";
3
- import { Response } from "../../plugins";
4
- import { BookingByStepState } from "./types";
5
- import { CartItem, IUpdateItemParams, ProductData } from "../../modules";
6
- import { Account } from "../../modules/Account/types";
7
- import { IStep } from "../../modules/Step/tyeps";
8
- import { TimeSliceItem } from "./utils/resources";
9
- import { ITime } from "../../modules/Date/types";
1
+ import { Module, PisellCore } from '../../types';
2
+ import { BaseModule } from '../../modules/BaseModule';
3
+ import { Response } from '../../plugins';
4
+ import { BookingByStepState } from './types';
5
+ import { CartItem, IUpdateItemParams, ProductData } from '../../modules';
6
+ import { Account } from '../../modules/Account/types';
7
+ import { IStep } from '../../modules/Step/tyeps';
8
+ import { TimeSliceItem } from './utils/resources';
9
+ import { ITime } from '../../modules/Date/types';
10
+ import dayjs from 'dayjs';
11
+ import { IHolder, IFetchHolderAccountsParams } from '../../modules/AccountList/types';
10
12
  export declare class BookingByStepImpl extends BaseModule implements Module {
11
13
  protected defaultName: string;
12
14
  protected defaultVersion: string;
@@ -17,6 +19,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
17
19
  private store;
18
20
  private otherParams;
19
21
  private cacheId;
22
+ private otherData;
20
23
  initialize(core: PisellCore, options: any): Promise<void>;
21
24
  initStep(stepList: (keyof BookingByStepState)[]): void;
22
25
  getCurrentStep(): {
@@ -27,26 +30,42 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
27
30
  back(): void;
28
31
  gotoStep(index: number): void;
29
32
  getStepList(): IStep[];
30
- loadProducts({ category_ids, product_ids, collection, schedule_ids }: {
33
+ /**
34
+ * 添加step
35
+ */
36
+ addStep(step: IStep, key?: string): void;
37
+ /**
38
+ * 删除step
39
+ */
40
+ removeStep(key: string): void;
41
+ loadProducts({ category_ids, product_ids, collection, schedule_ids, }: {
31
42
  category_ids?: number[];
32
43
  product_ids?: number[];
33
44
  collection?: number | string[];
34
45
  schedule_ids?: number[];
35
46
  }): Promise<any>;
36
- loadProductByScheduleDate(date: string): void;
47
+ loadProductByScheduleDate(date: string): Promise<any>;
37
48
  loadAllSchedule(): Promise<void>;
38
- loadAvailableDate({ startDate, endDate, custom_page_id }: {
49
+ loadScheduleAvailableDate({ startDate, endDate, custom_page_id, }: {
39
50
  startDate: string;
40
51
  endDate: string;
41
52
  custom_page_id?: number;
42
- }): Promise<void>;
53
+ }): Promise<ITime[]>;
43
54
  storeProduct(productData: ProductData): Promise<void>;
44
- addAccount(accounts: Account[]): Promise<void>;
55
+ addAccount(accounts: Account[] | IHolder[], extra?: {
56
+ type: 'account' | 'holder';
57
+ customerId: number;
58
+ }): Promise<void>;
45
59
  getAccounts(): Promise<(Account | null)[]>;
46
60
  checkHasLoginAccount(): boolean;
47
61
  setActiveAccount(id: string): void;
48
62
  getActiveAccount(): Account | null;
49
63
  removeAccount(id: string): void;
64
+ /**
65
+ * 获取holder类型账户列表
66
+ * @param params
67
+ */
68
+ fetchHolderAccountsAsync(params: IFetchHolderAccountsParams): Promise<void>;
50
69
  setDateRange(dateRange: ITime[]): Promise<void>;
51
70
  clearDateRange(): void;
52
71
  getDateRange(): Promise<ITime[]>;
@@ -55,6 +74,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
55
74
  products?: ProductData[];
56
75
  startDate?: string;
57
76
  endDate?: string;
77
+ type?: 'month' | 'day';
58
78
  }): Promise<ITime[]>;
59
79
  /**
60
80
  * 获取购物车汇总信息
@@ -78,6 +98,12 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
78
98
  setLoginAccount(accountId: string, accountInfo: Account): Promise<void>;
79
99
  generateCartData(): Promise<void>;
80
100
  getFreeProduct(id: string | number): Promise<Response<any>>;
101
+ /**
102
+ * 检查购物车提交订单前是否符合条件
103
+ * @param type 类型 "holder" | "account"
104
+ * @returns boolean
105
+ */
106
+ checkBeforeSubmitOrder(type: 'holder' | 'account'): boolean;
81
107
  submitOrder(): Promise<void>;
82
108
  pay(): Promise<void>;
83
109
  getPayInfo(): Promise<void>;
@@ -96,7 +122,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
96
122
  /**
97
123
  * 从购物车中按类别删除信息
98
124
  */
99
- deleteCartItemInfo(types: "resource" | "time"): void;
125
+ deleteCartItemInfo(types: 'resource' | 'time'): void;
100
126
  destroy(): void;
101
127
  getResourcesList(): any[];
102
128
  getResourcesListByCartItem(id: string | number): {
@@ -123,7 +149,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
123
149
  timeSlots: any[];
124
150
  selectedResource: any;
125
151
  } | undefined;
126
- autoSelectAccountResources({ holder_id, resources_code, timeSlots, countMap, capacity }: {
152
+ autoSelectAccountResources({ holder_id, resources_code, timeSlots, countMap, capacity, }: {
127
153
  holder_id: string;
128
154
  resources_code: string | number;
129
155
  timeSlots?: TimeSliceItem;
@@ -143,5 +169,28 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
143
169
  submitTimeSlot(timeSlots: TimeSliceItem): void;
144
170
  clearCache(): void;
145
171
  clearCacheByModule(module: string): void;
172
+ private getScheduleDataByIds;
146
173
  openProductDetail(productId: number): Promise<void>;
174
+ closeProductDetail(): void;
175
+ getTimeslotBySchedule({ date, scheduleIds, }: {
176
+ date: string;
177
+ scheduleIds: number[];
178
+ }): {
179
+ start_time: string;
180
+ end_time: string;
181
+ start_at: dayjs.Dayjs;
182
+ end_at: dayjs.Dayjs;
183
+ count: number;
184
+ }[];
185
+ addProductToCart({ product, date, account, }: {
186
+ product: ProductData;
187
+ date: {
188
+ startTime: string;
189
+ endTime: string;
190
+ };
191
+ account: Account;
192
+ }): void;
193
+ setOtherData(key: string, value: any): void;
194
+ getOtherData(key: string): any;
195
+ getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
147
196
  }