@pisell/pisellos 0.0.44 → 0.0.46

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 +20 -1
  5. package/dist/modules/AccountList/index.js +243 -75
  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 +33 -19
  14. package/dist/modules/Cart/types.d.ts +21 -7
  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 +10 -5
  25. package/dist/modules/Order/index.js +32 -16
  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 +71 -16
  53. package/dist/solution/BookingByStep/index.js +643 -227
  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 +6 -5
  59. package/dist/solution/BookingByStep/utils/resources.js +37 -19
  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 +20 -1
  69. package/lib/modules/AccountList/index.js +122 -13
  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 +28 -6
  77. package/lib/modules/Cart/types.d.ts +21 -7
  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 +10 -5
  89. package/lib/modules/Order/index.js +11 -1
  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 +71 -16
  116. package/lib/solution/BookingByStep/index.js +396 -48
  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 +6 -5
  122. package/lib/solution/BookingByStep/utils/resources.js +128 -58
  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
@@ -36,6 +36,8 @@ __export(utils_exports, {
36
36
  formatAccountToCartItemOrigin: () => formatAccountToCartItemOrigin,
37
37
  formatBundle: () => formatBundle,
38
38
  formatBundleToOrigin: () => formatBundleToOrigin,
39
+ formatDateToCartItem: () => formatDateToCartItem,
40
+ formatDateToCartItemOrigin: () => formatDateToCartItemOrigin,
39
41
  formatDiscountToCartItem: () => formatDiscountToCartItem,
40
42
  formatDiscountToCartItemOrigin: () => formatDiscountToCartItemOrigin,
41
43
  formatNoteToCartItem: () => formatNoteToCartItem,
@@ -112,7 +114,12 @@ var formatProductToCartItem = (params) => {
112
114
  cartItem.price = product == null ? void 0 : product.price;
113
115
  cartItem.num = num;
114
116
  cartItem.total = getProductTotalPrice({ product, bundle, options, num });
115
- cartItem.origin_total = getProductOriginTotalPrice({ product, bundle, options, num });
117
+ cartItem.origin_total = getProductOriginTotalPrice({
118
+ product,
119
+ bundle,
120
+ options,
121
+ num
122
+ });
116
123
  cartItem.image = product == null ? void 0 : product.cover;
117
124
  cartItem.like_status = "common";
118
125
  cartItem.duration = product == null ? void 0 : product.duration;
@@ -126,7 +133,13 @@ var formatProductToCartItem = (params) => {
126
133
  cartItem.options = formatOptions(options);
127
134
  }
128
135
  if (((_a = product == null ? void 0 : product.custom_deposit_data) == null ? void 0 : _a.has_deposit) == 1) {
129
- cartItem.deposit = getProductDeposit({ cartItem, product, bundle, options, num });
136
+ cartItem.deposit = getProductDeposit({
137
+ cartItem,
138
+ product,
139
+ bundle,
140
+ options,
141
+ num
142
+ });
130
143
  }
131
144
  const oringin = formatProductToCartItemOrigin(params);
132
145
  cartItem._origin = oringin;
@@ -187,7 +200,16 @@ var formatAccountToCartItemOrigin = (params) => {
187
200
  const { cartItem, account } = params;
188
201
  let origin = cartItem._origin;
189
202
  if (account) {
190
- origin.metadata.account = account;
203
+ if ((account == null ? void 0 : account.type) === "holder") {
204
+ const { customer_id, form_id, form_record_id } = (account == null ? void 0 : account._origin) || {};
205
+ origin.holder = {
206
+ customer_id,
207
+ form_id,
208
+ form_record: form_record_id ? [form_record_id] : null
209
+ };
210
+ } else {
211
+ origin.metadata.account = account;
212
+ }
191
213
  }
192
214
  return origin;
193
215
  };
@@ -265,6 +287,26 @@ var formatResourceToCartItemOrigin = (params) => {
265
287
  }
266
288
  return origin;
267
289
  };
290
+ var formatDateToCartItem = (params) => {
291
+ const { cartItem, date } = params;
292
+ cartItem.start_date = (0, import_dayjs.default)(date.startTime).format("YYYY-MM-DD");
293
+ cartItem.start_time = (0, import_dayjs.default)(date.startTime).format("HH:mm");
294
+ cartItem.end_date = (0, import_dayjs.default)(date.endTime).format("YYYY-MM-DD");
295
+ cartItem.end_time = (0, import_dayjs.default)(date.endTime).format("HH:mm");
296
+ const oringin = formatDateToCartItemOrigin(params);
297
+ cartItem._origin = oringin;
298
+ return cartItem;
299
+ };
300
+ var formatDateToCartItemOrigin = (params) => {
301
+ const { cartItem, date } = params;
302
+ const origin = cartItem._origin;
303
+ origin.select_date = (0, import_dayjs.default)(date.startTime).format("YYYY-MM-DD");
304
+ origin.start_date = (0, import_dayjs.default)(date.startTime).format("YYYY-MM-DD");
305
+ origin.start_time = (0, import_dayjs.default)(date.startTime).format("HH:mm");
306
+ origin.end_date = (0, import_dayjs.default)(date.endTime).format("YYYY-MM-DD");
307
+ origin.end_time = (0, import_dayjs.default)(date.endTime).format("HH:mm");
308
+ return origin;
309
+ };
268
310
  var deleteResourceFromCartItem = (cartItem) => {
269
311
  cartItem.resource_id = void 0;
270
312
  cartItem.relation_form_name = void 0;
@@ -464,6 +506,8 @@ var handleProductDeposit = (params) => {
464
506
  formatAccountToCartItemOrigin,
465
507
  formatBundle,
466
508
  formatBundleToOrigin,
509
+ formatDateToCartItem,
510
+ formatDateToCartItemOrigin,
467
511
  formatDiscountToCartItem,
468
512
  formatDiscountToCartItemOrigin,
469
513
  formatNoteToCartItem,
@@ -1,6 +1,6 @@
1
- import { Module, PisellCore, ModuleOptions } from "../../types";
2
- import { BaseModule } from "../BaseModule";
3
- import { DateModuleAPI, IGetAvailableTimeListParams, ITime } from "./types";
1
+ import { Module, PisellCore, ModuleOptions } from '../../types';
2
+ import { BaseModule } from '../BaseModule';
3
+ import { DateModuleAPI, IGetAvailableTimeListParams, ITime } from './types';
4
4
  export declare class DateModule extends BaseModule implements Module, DateModuleAPI {
5
5
  protected defaultName: string;
6
6
  protected defaultVersion: string;
@@ -13,9 +13,9 @@ export declare class DateModule extends BaseModule implements Module, DateModule
13
13
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
14
14
  setDateRange(dateRange: ITime[]): void;
15
15
  getDateRange(): ITime[];
16
- getMonthDates(params: IGetAvailableTimeListParams): Promise<ITime[]>;
17
- getDateList(): Promise<ITime[]>;
18
- getAvailableTimeList(params: IGetAvailableTimeListParams): Promise<ITime[]>;
16
+ getResourceDates(params: IGetAvailableTimeListParams): Promise<ITime[]>;
17
+ getDateList(): ITime[];
18
+ getResourceAvailableTimeList(params: IGetAvailableTimeListParams): Promise<ITime[]>;
19
19
  clearDateRange(): void;
20
20
  storeChange(): void;
21
21
  }
@@ -68,23 +68,23 @@ var DateModule = class extends import_BaseModule.BaseModule {
68
68
  getDateRange() {
69
69
  return this.store.dateRange;
70
70
  }
71
- async getMonthDates(params) {
72
- const dates = await this.getAvailableTimeList(params);
71
+ async getResourceDates(params) {
72
+ const dates = await this.getResourceAvailableTimeList(params);
73
73
  this.store.dateList = dates;
74
74
  return dates;
75
75
  }
76
- async getDateList() {
76
+ getDateList() {
77
77
  return this.store.dateList;
78
78
  }
79
- async getAvailableTimeList(params) {
79
+ async getResourceAvailableTimeList(params) {
80
80
  var _a;
81
- const { url, query, rules } = params;
81
+ const { url, query, rules, type } = params;
82
82
  const fetchUrl = url || "/schedule/resource/list";
83
83
  const { start_date, end_date, resource_ids } = query || {};
84
84
  if (!start_date || !end_date) {
85
85
  return [];
86
86
  }
87
- let dates = (0, import_utils.generateMonthDates)(start_date, end_date);
87
+ let dates = (0, import_utils.generateMonthDates)(start_date, end_date, type);
88
88
  if (!(resource_ids == null ? void 0 : resource_ids.length) || (0, import_dayjs.default)(end_date).isBefore((0, import_dayjs.default)())) {
89
89
  return (0, import_utils.disableAllDates)(dates);
90
90
  }
@@ -20,33 +20,39 @@ export interface ITime {
20
20
  date: string;
21
21
  week: string;
22
22
  weekNum: number;
23
- status: "unavailable" | "available";
23
+ status: 'unavailable' | 'available';
24
24
  resource?: any[];
25
+ color?: string[];
25
26
  }
26
27
  /**
27
28
  * 日期模块 API
28
29
  */
29
30
  export interface DateModuleAPI {
30
31
  /**
31
- * 获取可用时间列表
32
+ * 获取资源可用时间列表
32
33
  */
33
- getAvailableTimeList: (params: IGetAvailableTimeListParams) => Promise<ITime[]>;
34
+ getResourceAvailableTimeList: (params: IGetAvailableTimeListParams) => Promise<ITime[]>;
34
35
  /**
35
36
  * 设置日期范围
36
37
  */
37
38
  setDateRange: (range: ITime[]) => void;
38
39
  /**
39
- * 获取月份日期
40
+ * 获取资源日期
40
41
  */
41
- getMonthDates: (params: IGetAvailableTimeListParams) => Promise<ITime[]>;
42
+ getResourceDates: (params: IGetAvailableTimeListParams) => Promise<ITime[]>;
42
43
  }
43
44
  export interface IGetAvailableTimeListParams {
44
45
  url?: string;
46
+ /** 查询参数 */
45
47
  query?: {
48
+ /** 开始日期 */
46
49
  start_date: string;
50
+ /** 结束日期 */
47
51
  end_date: string;
52
+ /** 资源ID */
48
53
  resource_ids?: Array<number | string>;
49
54
  };
55
+ /** 规则 */
50
56
  rules?: Array<{
51
57
  /**
52
58
  * 提前量
@@ -54,11 +60,21 @@ export interface IGetAvailableTimeListParams {
54
60
  cut_off_time?: {
55
61
  future_day?: number;
56
62
  unit?: number;
57
- unit_type?: "minutes" | "hours" | "days";
63
+ unit_type?: 'minutes' | 'hours' | 'days';
58
64
  };
59
65
  /**
60
66
  * 资源ID
61
67
  */
62
68
  resourceFormIds?: number[];
69
+ /**
70
+ * 日程ID
71
+ */
72
+ schedule?: {
73
+ date: string;
74
+ color?: string[];
75
+ isExcluded: boolean;
76
+ }[];
63
77
  }>;
78
+ /** 类型:按月查 | 按日查 */
79
+ type?: 'month' | 'day';
64
80
  }
@@ -1,11 +1,12 @@
1
- import { IGetAvailableTimeListParams, ITime } from "./types";
1
+ import { IGetAvailableTimeListParams, ITime } from './types';
2
2
  /**
3
3
  * 生成当前月份的所有日期
4
4
  * @param startDate 开始日期
5
5
  * @param endDate 结束日期
6
+ * @param type 类型:按月查 | 按周查
6
7
  * @returns 日期列表
7
8
  */
8
- export declare const generateMonthDates: (startDate: string, endDate: string) => ITime[];
9
+ export declare const generateMonthDates: (startDate: string, endDate: string, type?: 'month' | 'day') => ITime[];
9
10
  /**
10
11
  * 禁用所有日期
11
12
  * @param dates 日期列表
@@ -32,4 +33,4 @@ export declare const handleAvailableDateByResource: (resources: any[], dates: IT
32
33
  * @param rules 提前量规则
33
34
  * @returns 日期列表
34
35
  */
35
- export declare const handleAvailableDatesByRules: (dates: ITime[], rules: IGetAvailableTimeListParams["rules"]) => ITime[];
36
+ export declare const handleAvailableDatesByRules: (dates: ITime[], rules: IGetAvailableTimeListParams['rules']) => ITime[];
@@ -37,8 +37,8 @@ __export(utils_exports, {
37
37
  });
38
38
  module.exports = __toCommonJS(utils_exports);
39
39
  var import_dayjs = __toESM(require("dayjs"));
40
- var generateMonthDates = (startDate, endDate) => {
41
- const start = (0, import_dayjs.default)(startDate).format("YYYY-MM-01");
40
+ var generateMonthDates = (startDate, endDate, type) => {
41
+ const start = type === "day" ? (0, import_dayjs.default)(startDate).format("YYYY-MM-DD") : (0, import_dayjs.default)(startDate).format("YYYY-MM-01");
42
42
  const end = (0, import_dayjs.default)(endDate).format("YYYY-MM-DD");
43
43
  const dates = [];
44
44
  let currentDate = (0, import_dayjs.default)(start);
@@ -100,11 +100,29 @@ var handleAvailableDatesByRules = (dates, rules) => {
100
100
  if (!(rules == null ? void 0 : rules.length)) {
101
101
  return newDates;
102
102
  }
103
+ let scheduleMap = {};
103
104
  let latestStartDate = "";
104
105
  let earliestEndDate = "";
105
106
  let resourceFormIds = [];
106
107
  rules.forEach((rule) => {
107
- var _a;
108
+ var _a, _b;
109
+ if ((_a = rule == null ? void 0 : rule.schedule) == null ? void 0 : _a.length) {
110
+ for (const item of rule.schedule) {
111
+ if ((0, import_dayjs.default)(item.date).isBefore((0, import_dayjs.default)(newDates[0].date))) {
112
+ continue;
113
+ }
114
+ if ((0, import_dayjs.default)(item.date).isAfter((0, import_dayjs.default)(newDates[newDates.length - 1].date))) {
115
+ break;
116
+ }
117
+ if (!scheduleMap[item.date]) {
118
+ scheduleMap[item.date] = item;
119
+ } else {
120
+ if (!item.isExcluded) {
121
+ scheduleMap[item.date].isExcluded = false;
122
+ }
123
+ }
124
+ }
125
+ }
108
126
  const { future_day, unit, unit_type } = (rule == null ? void 0 : rule.cut_off_time) || {};
109
127
  if (future_day) {
110
128
  const endDate = (0, import_dayjs.default)().add(future_day, "day");
@@ -118,18 +136,31 @@ var handleAvailableDatesByRules = (dates, rules) => {
118
136
  }
119
137
  }
120
138
  if (unit && unit_type) {
121
- const startDate = (0, import_dayjs.default)((0, import_dayjs.default)().add(unit, unit_type).format("YYYY-MM-DD"));
139
+ const startDate = (0, import_dayjs.default)(
140
+ (0, import_dayjs.default)().add(unit, unit_type).format("YYYY-MM-DD")
141
+ );
122
142
  if (!latestStartDate || startDate.isAfter((0, import_dayjs.default)(latestStartDate))) {
123
143
  latestStartDate = startDate.format("YYYY-MM-DD");
124
144
  }
125
145
  }
126
- if ((_a = rule == null ? void 0 : rule.resourceFormIds) == null ? void 0 : _a.length) {
127
- resourceFormIds = [.../* @__PURE__ */ new Set([...resourceFormIds, ...rule == null ? void 0 : rule.resourceFormIds])];
146
+ if ((_b = rule == null ? void 0 : rule.resourceFormIds) == null ? void 0 : _b.length) {
147
+ resourceFormIds = [
148
+ .../* @__PURE__ */ new Set([...resourceFormIds, ...rule == null ? void 0 : rule.resourceFormIds])
149
+ ];
128
150
  }
129
151
  });
130
152
  newDates = newDates.map((date) => {
131
153
  var _a;
132
154
  const disabledDate = { ...date, status: "unavailable" };
155
+ if (Object.keys(scheduleMap).length) {
156
+ const schedule = scheduleMap[date.date];
157
+ if (!schedule || (schedule == null ? void 0 : schedule.isExcluded)) {
158
+ return { ...date, color: schedule == null ? void 0 : schedule.color, status: "unavailable" };
159
+ } else {
160
+ date.color = schedule == null ? void 0 : schedule.color;
161
+ disabledDate.color = schedule == null ? void 0 : schedule.color;
162
+ }
163
+ }
133
164
  if (!((_a = date == null ? void 0 : date.resource) == null ? void 0 : _a.length)) {
134
165
  return disabledDate;
135
166
  }
@@ -1,6 +1,6 @@
1
- import { Module, PisellCore, ModuleOptions } from "../../types";
2
- import { BaseModule } from "../BaseModule";
3
- import { Discount, DiscountModuleAPI } from "./types";
1
+ import { Module, PisellCore, ModuleOptions } from '../../types';
2
+ import { BaseModule } from '../BaseModule';
3
+ import { Discount, DiscountModuleAPI } from './types';
4
4
  export declare class DiscountModule extends BaseModule implements Module, DiscountModuleAPI {
5
5
  protected defaultName: string;
6
6
  protected defaultVersion: string;
@@ -15,7 +15,7 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
15
15
  setDiscountList(discountList: Discount[]): Promise<void>;
16
16
  getDiscountList(): Discount[];
17
17
  loadPrepareConfig(params: {
18
- action?: "create";
18
+ action?: 'create';
19
19
  with_good_pass: 0 | 1;
20
20
  customer_id: number;
21
21
  }): Promise<Discount[]>;
@@ -88,7 +88,9 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
88
88
  available: 1,
89
89
  relation_product: 1
90
90
  });
91
- const resultDiscountList = this.uniqueByProductId(this.filterEnabledDiscountList((result == null ? void 0 : result.data) || []) || []) || [];
91
+ const resultDiscountList = this.uniqueByProductId(
92
+ this.filterEnabledDiscountList((result == null ? void 0 : result.data) || []) || []
93
+ ) || [];
92
94
  return resultDiscountList;
93
95
  }
94
96
  filterEnabledDiscountList(discountList) {
@@ -129,7 +131,12 @@ var DiscountModule = class extends import_BaseModule.BaseModule {
129
131
  }
130
132
  storeChange() {
131
133
  if (this.openCache) {
132
- this.checkSaveCache({ cacheId: this.cacheId, fatherModule: this.fatherModule, store: this.store, cacheKey: ["discountList"] });
134
+ this.checkSaveCache({
135
+ cacheId: this.cacheId,
136
+ fatherModule: this.fatherModule,
137
+ store: this.store,
138
+ cacheKey: ["discountList"]
139
+ });
133
140
  }
134
141
  }
135
142
  };
@@ -52,7 +52,10 @@ var GuestListModule = class extends import_BaseModule.BaseModule {
52
52
  ...this.state.list[index],
53
53
  ...updates
54
54
  };
55
- await this.core.effects.emit(import_types.GuestHooks.OnGuestUpdate, this.state.list[index]);
55
+ await this.core.effects.emit(
56
+ import_types.GuestHooks.OnGuestUpdate,
57
+ this.state.list[index]
58
+ );
56
59
  await this.core.effects.emit(import_types.GuestHooks.OnGuestChange, this.state.list);
57
60
  }
58
61
  async removeGuest(id) {
@@ -1,6 +1,7 @@
1
- import { Module, PisellCore, ModuleOptions } from "../../types";
2
- import { BaseModule } from "../BaseModule";
3
- import { OrderModuleAPI, CommitOrderParams } from "./types";
1
+ import { Module, PisellCore, ModuleOptions } from '../../types';
2
+ import { BaseModule } from '../BaseModule';
3
+ import { OrderModuleAPI, CommitOrderParams } from './types';
4
+ import { CartItem } from '../Cart/types';
4
5
  export declare class OrderModule extends BaseModule implements Module, OrderModuleAPI {
5
6
  protected defaultName: string;
6
7
  protected defaultVersion: string;
@@ -8,7 +9,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
8
9
  private request;
9
10
  constructor(name?: string, version?: string);
10
11
  initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
11
- createOrder(params: CommitOrderParams["query"]): {
12
+ createOrder(params: CommitOrderParams['query']): {
12
13
  type: string;
13
14
  platform: string;
14
15
  sales_channel: string;
@@ -18,5 +19,9 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
18
19
  schedule_date: string;
19
20
  is_deposit: number;
20
21
  };
21
- commitOrder(order: CommitOrderParams): Promise<void>;
22
+ checkBeforeSubmitOrder(params: {
23
+ cartItems: CartItem[];
24
+ type: 'holder' | 'account';
25
+ }): boolean;
26
+ submitOrder(order: CommitOrderParams): Promise<void>;
22
27
  }
@@ -59,7 +59,17 @@ var OrderModule = class extends import_BaseModule.BaseModule {
59
59
  }
60
60
  return order;
61
61
  }
62
- async commitOrder(order) {
62
+ checkBeforeSubmitOrder(params) {
63
+ const { cartItems, type } = params;
64
+ if (type === "holder") {
65
+ const hasNoHolderId = cartItems.some((item) => !item.holder_id);
66
+ if (hasNoHolderId) {
67
+ return false;
68
+ }
69
+ }
70
+ return true;
71
+ }
72
+ async submitOrder(order) {
63
73
  const { url, query } = order;
64
74
  const fetchUrl = url || "/order/appointment";
65
75
  const params = this.createOrder(query);
@@ -1,4 +1,4 @@
1
- import { CartItem } from "../Cart/types";
1
+ import { CartItem } from '../Cart/types';
2
2
  export declare enum OrderHooks {
3
3
  OnOrderCreate = "order:onOrderCreate",
4
4
  OnOrderUpdate = "order:onOrderUpdate",
@@ -25,10 +25,17 @@ export interface OrderModuleAPI {
25
25
  * @param params 订单信息
26
26
  * @returns 订单信息
27
27
  */
28
- createOrder: (params: CommitOrderParams["query"]) => any;
28
+ createOrder: (params: CommitOrderParams['query']) => any;
29
+ /**
30
+ * 检查购物车提交订单前是否符合条件
31
+ */
32
+ checkBeforeSubmitOrder: (params: {
33
+ cartItems: CartItem[];
34
+ type: 'holder' | 'account';
35
+ }) => boolean;
29
36
  /**
30
37
  * 提交订单
31
38
  * @param params 订单信息
32
39
  */
33
- commitOrder: (params: CommitOrderParams) => Promise<void>;
40
+ submitOrder: (params: CommitOrderParams) => Promise<void>;
34
41
  }
@@ -72,12 +72,7 @@ var PaymentModule = class extends import_BaseModule.BaseModule {
72
72
  await this.core.effects.emit(import_types.PaymentHooks.OnPaymentRefund, payment);
73
73
  }
74
74
  getAvailablePaymentMethods() {
75
- return [
76
- "credit_card",
77
- "debit_card",
78
- "alipay",
79
- "wechat_pay"
80
- ];
75
+ return ["credit_card", "debit_card", "alipay", "wechat_pay"];
81
76
  }
82
77
  async checkPaymentStatus(paymentId) {
83
78
  const payment = this.state.paymentHistory.find((p) => p.id === paymentId);
@@ -21,7 +21,7 @@ export declare class Product extends BaseModule implements Module {
21
21
  /**
22
22
  * 获取商品数据
23
23
  */
24
- getData(): ProductData | null;
24
+ getData(): ProductData;
25
25
  /**
26
26
  * 获取商品ID
27
27
  */
@@ -46,4 +46,7 @@ export declare class Product extends BaseModule implements Module {
46
46
  * 获取商品分类
47
47
  */
48
48
  getCategories(): ProductCategory[];
49
+ setOtherParams(key: string, value: any): void;
50
+ getOtherParams(): any;
51
+ getProductType(): "duration" | "session" | "normal";
49
52
  }
@@ -82,6 +82,22 @@ var Product = class extends import_BaseModule.BaseModule {
82
82
  getCategories() {
83
83
  return this.store.categories;
84
84
  }
85
+ setOtherParams(key, value) {
86
+ this.otherParams[key] = value;
87
+ }
88
+ getOtherParams() {
89
+ return this.otherParams;
90
+ }
91
+ getProductType() {
92
+ var _a;
93
+ if (this.store.duration) {
94
+ return "duration";
95
+ }
96
+ if ((_a = this.store["schedule.ids"]) == null ? void 0 : _a.length) {
97
+ return "session";
98
+ }
99
+ return "normal";
100
+ }
85
101
  };
86
102
  // Annotate the CommonJS export names for ESM import in node:
87
103
  0 && (module.exports = {
@@ -17,7 +17,7 @@ export interface ProductData {
17
17
  /** 商品slug */
18
18
  slug: string;
19
19
  /** draft:草稿;published:已发布;pending:待发布;archived:已归档 */
20
- status: "draft" | "published" | "pending" | "archived";
20
+ status: 'draft' | 'published' | 'pending' | 'archived';
21
21
  /** 库存数量 */
22
22
  stock_quantity: number;
23
23
  /** 销售数量 */
@@ -156,6 +156,10 @@ export interface ProductData {
156
156
  capacity?: any;
157
157
  /** 商品套餐 */
158
158
  product_bundle?: any;
159
+ /** 日程ids */
160
+ 'schedule.ids'?: number[];
161
+ /** 商品日程信息,前端临时用,随时需要回收的 */
162
+ _schedule?: any;
159
163
  /** 商品定金信息 */
160
164
  custom_deposit_data?: {
161
165
  /** 商品是否包含定金 1:是 0:否 */
@@ -434,7 +438,7 @@ export interface ProductResourceItem {
434
438
  /** 资源标题 */
435
439
  title: string;
436
440
  /** 资源编码 */
437
- code: "resource";
441
+ code: 'resource';
438
442
  /** 默认资源 */
439
443
  default_resource?: number[];
440
444
  /** 可选资源 */
@@ -443,7 +447,7 @@ export interface ProductResourceItem {
443
447
  resource_type_id: number;
444
448
  /** 选择类型 */
445
449
  select_type?: {
446
- type: "single";
450
+ type: 'single';
447
451
  min: 1;
448
452
  max: 1;
449
453
  };
@@ -35,29 +35,43 @@ var ProductList = class extends import_BaseModule.BaseModule {
35
35
  this.defaultVersion = "1.0.0";
36
36
  }
37
37
  async initialize(core, options) {
38
+ var _a;
38
39
  this.core = core;
39
40
  this.store = options.store;
40
- this.store.productMap = /* @__PURE__ */ new Map();
41
- this.store.list = [];
42
- this.store.selectProducts = [];
43
- this.storeChange();
41
+ if (Array.isArray((_a = options.initialState) == null ? void 0 : _a.list)) {
42
+ this.store.list = options.initialState.list;
43
+ this.core.effects.emit(`${this.name}:changed`, this.store.list);
44
+ this.storeChange();
45
+ } else {
46
+ this.store.list = [];
47
+ this.store.productMap = /* @__PURE__ */ new Map();
48
+ this.store.selectProducts = [];
49
+ }
44
50
  }
45
51
  async storeChange(path, value) {
46
52
  var _a;
47
53
  (_a = this.store.list) == null ? void 0 : _a.forEach((product) => {
48
54
  if (!this.store.productMap.has(`product-${product.id}`)) {
49
- const newProductModule = new import_Product.Product(`product_${product.id.toString()}`);
55
+ const newProductModule = new import_Product.Product(
56
+ `product_${product.id.toString()}`
57
+ );
50
58
  this.core.registerModule(newProductModule, { initialState: product });
51
59
  this.store.productMap.set(product.id.toString(), newProductModule);
52
60
  }
53
61
  });
54
62
  }
55
63
  async getProducts() {
56
- await this.core.effects.emit(import_types.ProductListHooks.onGetProducts, this.store.list);
64
+ await this.core.effects.emit(
65
+ import_types.ProductListHooks.onGetProducts,
66
+ this.store.list
67
+ );
57
68
  return (0, import_lodash_es.cloneDeep)(this.store.list);
58
69
  }
59
70
  async getProduct(id) {
60
- await this.core.effects.emit(import_types.ProductListHooks.onGetProduct, this.store.list);
71
+ await this.core.effects.emit(
72
+ import_types.ProductListHooks.onGetProduct,
73
+ this.store.list
74
+ );
61
75
  const product = this.store.productMap.get(`${id}`);
62
76
  if (product)
63
77
  return product;
@@ -78,7 +78,10 @@ var ResourceListModule = class extends import_BaseModule.BaseModule {
78
78
  ...this.store.list[index],
79
79
  ...updates
80
80
  };
81
- await this.core.effects.emit(import_types.ResourceHooks.OnResourceChange, this.store.list[index]);
81
+ await this.core.effects.emit(
82
+ import_types.ResourceHooks.OnResourceChange,
83
+ this.store.list[index]
84
+ );
82
85
  }
83
86
  };
84
87
  // Annotate the CommonJS export names for ESM import in node:
@@ -24,10 +24,13 @@ __export(utils_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(utils_exports);
26
26
  var getResourcesMap = (resourceList) => {
27
- return resourceList.reduce((pre, item) => {
28
- pre[item.id] = item;
29
- return pre;
30
- }, {});
27
+ return resourceList.reduce(
28
+ (pre, item) => {
29
+ pre[item.id] = item;
30
+ return pre;
31
+ },
32
+ {}
33
+ );
31
34
  };
32
35
  var getResourcesByIds = (resourcesMap, ids) => {
33
36
  return (ids || []).map((id) => resourcesMap[id]);
@@ -1,7 +1,7 @@
1
- import { Module, PisellCore, ModuleOptions } from "../../types";
2
- import { BaseModule } from "../BaseModule";
3
- import { Rules, RulesModuleAPI, DiscountResult } from "./types";
4
- import { Discount } from "../Discount/types";
1
+ import { Module, PisellCore, ModuleOptions } from '../../types';
2
+ import { BaseModule } from '../BaseModule';
3
+ import { Rules, RulesModuleAPI, DiscountResult } from './types';
4
+ import { Discount } from '../Discount/types';
5
5
  export declare class RulesModule extends BaseModule implements Module, RulesModuleAPI {
6
6
  protected defaultName: string;
7
7
  protected defaultVersion: string;
@@ -1,4 +1,4 @@
1
- import { Discount } from "../Discount/types";
1
+ import { Discount } from '../Discount/types';
2
2
  export declare enum RulesHooks {
3
3
  OnRulesListChange = "rules:onRulesListChange",
4
4
  OnDestroy = "rules:onDestroy"