@pisell/pisellos 3.0.5 → 3.0.6

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 (146) 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 +8 -5
  13. package/dist/modules/Cart/index.js +101 -25
  14. package/dist/modules/Cart/types.d.ts +82 -5
  15. package/dist/modules/Cart/types.js +22 -0
  16. package/dist/modules/Cart/utils.d.ts +106 -13
  17. package/dist/modules/Cart/utils.js +289 -76
  18. package/dist/modules/Date/index.d.ts +6 -6
  19. package/dist/modules/Date/index.js +41 -58
  20. package/dist/modules/Date/types.d.ts +22 -6
  21. package/dist/modules/Date/utils.d.ts +4 -3
  22. package/dist/modules/Date/utils.js +81 -30
  23. package/dist/modules/Discount/index.d.ts +4 -4
  24. package/dist/modules/Discount/index.js +11 -11
  25. package/dist/modules/Order/index.d.ts +11 -5
  26. package/dist/modules/Order/index.js +47 -18
  27. package/dist/modules/Order/types.d.ts +10 -3
  28. package/dist/modules/Order/utils.d.ts +10 -0
  29. package/dist/modules/Order/utils.js +15 -0
  30. package/dist/modules/Product/index.d.ts +14 -1
  31. package/dist/modules/Product/index.js +35 -0
  32. package/dist/modules/Product/types.d.ts +27 -3
  33. package/dist/modules/ProductList/index.js +11 -5
  34. package/dist/modules/Resource/types.d.ts +1 -0
  35. package/dist/modules/Resource/utils.js +1 -1
  36. package/dist/modules/Rules/index.d.ts +3 -3
  37. package/dist/modules/Rules/index.js +121 -53
  38. package/dist/modules/Rules/types.d.ts +5 -1
  39. package/dist/modules/Schedule/index.d.ts +18 -0
  40. package/dist/modules/Schedule/index.js +111 -0
  41. package/dist/modules/Schedule/type.d.ts +157 -0
  42. package/dist/modules/Schedule/type.js +1 -0
  43. package/dist/modules/Schedule/types.d.ts +182 -0
  44. package/dist/modules/Schedule/types.js +1 -0
  45. package/dist/modules/Schedule/utils.d.ts +67 -0
  46. package/dist/modules/Schedule/utils.js +729 -0
  47. package/dist/modules/Step/index.d.ts +14 -3
  48. package/dist/modules/Step/index.js +54 -2
  49. package/dist/modules/Summary/index.d.ts +12 -5
  50. package/dist/modules/Summary/index.js +33 -7
  51. package/dist/modules/Summary/types.d.ts +23 -2
  52. package/dist/modules/Summary/utils.d.ts +14 -4
  53. package/dist/modules/Summary/utils.js +46 -4
  54. package/dist/modules/index.d.ts +10 -0
  55. package/dist/modules/index.js +11 -1
  56. package/dist/plugins/index.d.ts +3 -3
  57. package/dist/plugins/request.d.ts +3 -3
  58. package/dist/plugins/request.js +30 -30
  59. package/dist/plugins/shopStore.d.ts +1 -1
  60. package/dist/solution/BookingByStep/index.d.ts +97 -24
  61. package/dist/solution/BookingByStep/index.js +1024 -322
  62. package/dist/solution/BookingByStep/types.d.ts +3 -10
  63. package/dist/solution/BookingByStep/types.js +11 -15
  64. package/dist/solution/BookingByStep/utils/products.d.ts +1 -1
  65. package/dist/solution/BookingByStep/utils/products.js +3 -0
  66. package/dist/solution/BookingByStep/utils/resources.d.ts +60 -6
  67. package/dist/solution/BookingByStep/utils/resources.js +293 -52
  68. package/dist/solution/ShopDiscount/index.d.ts +4 -4
  69. package/dist/solution/ShopDiscount/index.js +16 -16
  70. package/dist/solution/ShopDiscount/types.d.ts +2 -2
  71. package/dist/solution/ShopDiscount/utils.js +1 -1
  72. package/lib/core/index.js +7 -2
  73. package/lib/modules/Account/index.d.ts +2 -6
  74. package/lib/modules/Account/index.js +15 -30
  75. package/lib/modules/Account/types.d.ts +12 -1
  76. package/lib/modules/AccountList/index.d.ts +20 -1
  77. package/lib/modules/AccountList/index.js +122 -13
  78. package/lib/modules/AccountList/types.d.ts +33 -1
  79. package/lib/modules/AccountList/utils.d.ts +9 -0
  80. package/lib/modules/AccountList/utils.js +39 -0
  81. package/lib/modules/BaseModule.d.ts +2 -2
  82. package/lib/modules/BaseModule.js +14 -3
  83. package/lib/modules/Cart/index.d.ts +8 -5
  84. package/lib/modules/Cart/index.js +81 -8
  85. package/lib/modules/Cart/types.d.ts +82 -5
  86. package/lib/modules/Cart/types.js +20 -2
  87. package/lib/modules/Cart/utils.d.ts +106 -13
  88. package/lib/modules/Cart/utils.js +188 -45
  89. package/lib/modules/Date/index.d.ts +6 -6
  90. package/lib/modules/Date/index.js +13 -28
  91. package/lib/modules/Date/types.d.ts +22 -6
  92. package/lib/modules/Date/utils.d.ts +4 -3
  93. package/lib/modules/Date/utils.js +47 -13
  94. package/lib/modules/Discount/index.d.ts +4 -4
  95. package/lib/modules/Discount/index.js +9 -2
  96. package/lib/modules/Guests/index.js +4 -1
  97. package/lib/modules/Order/index.d.ts +11 -5
  98. package/lib/modules/Order/index.js +24 -3
  99. package/lib/modules/Order/types.d.ts +10 -3
  100. package/lib/modules/Order/utils.d.ts +10 -0
  101. package/lib/modules/Order/utils.js +45 -0
  102. package/lib/modules/Payment/index.js +1 -6
  103. package/lib/modules/Product/index.d.ts +14 -1
  104. package/lib/modules/Product/index.js +19 -0
  105. package/lib/modules/Product/types.d.ts +27 -3
  106. package/lib/modules/ProductList/index.js +21 -7
  107. package/lib/modules/Resource/index.js +4 -1
  108. package/lib/modules/Resource/types.d.ts +1 -0
  109. package/lib/modules/Resource/utils.js +7 -4
  110. package/lib/modules/Rules/index.d.ts +3 -3
  111. package/lib/modules/Rules/index.js +118 -43
  112. package/lib/modules/Rules/types.d.ts +5 -1
  113. package/lib/modules/Schedule/index.d.ts +18 -0
  114. package/lib/modules/Schedule/index.js +81 -0
  115. package/lib/modules/Schedule/type.d.ts +157 -0
  116. package/lib/modules/Schedule/type.js +17 -0
  117. package/lib/modules/Schedule/types.d.ts +182 -0
  118. package/lib/modules/Schedule/types.js +17 -0
  119. package/lib/modules/Schedule/utils.d.ts +67 -0
  120. package/lib/modules/Schedule/utils.js +600 -0
  121. package/lib/modules/Step/index.d.ts +14 -3
  122. package/lib/modules/Step/index.js +38 -1
  123. package/lib/modules/Summary/index.d.ts +12 -5
  124. package/lib/modules/Summary/index.js +15 -1
  125. package/lib/modules/Summary/types.d.ts +23 -2
  126. package/lib/modules/Summary/utils.d.ts +14 -4
  127. package/lib/modules/Summary/utils.js +30 -1
  128. package/lib/modules/index.d.ts +10 -0
  129. package/lib/modules/index.js +21 -1
  130. package/lib/plugins/index.d.ts +3 -3
  131. package/lib/plugins/request.d.ts +3 -3
  132. package/lib/plugins/request.js +48 -11
  133. package/lib/plugins/shopStore.d.ts +1 -1
  134. package/lib/solution/BookingByStep/index.d.ts +97 -24
  135. package/lib/solution/BookingByStep/index.js +693 -145
  136. package/lib/solution/BookingByStep/types.d.ts +3 -10
  137. package/lib/solution/BookingByStep/types.js +37 -14
  138. package/lib/solution/BookingByStep/utils/products.d.ts +1 -1
  139. package/lib/solution/BookingByStep/utils/products.js +3 -0
  140. package/lib/solution/BookingByStep/utils/resources.d.ts +60 -6
  141. package/lib/solution/BookingByStep/utils/resources.js +286 -54
  142. package/lib/solution/BuyTickets/index.js +34 -20
  143. package/lib/solution/ShopDiscount/index.d.ts +4 -4
  144. package/lib/solution/ShopDiscount/index.js +10 -2
  145. package/lib/solution/ShopDiscount/types.d.ts +2 -2
  146. package/package.json +4 -2
@@ -36,6 +36,7 @@ var SummaryModule = class extends import_BaseModule.BaseModule {
36
36
  this.core = core;
37
37
  this.store = options.store;
38
38
  this.shopStore = this.core.getPlugin("shopStore");
39
+ this.request = this.core.getPlugin("request");
39
40
  if (options.initialState) {
40
41
  this.store.summary = options.initialState.summary;
41
42
  }
@@ -57,9 +58,22 @@ var SummaryModule = class extends import_BaseModule.BaseModule {
57
58
  this.store.summary = summary;
58
59
  return this.store.summary;
59
60
  }
61
+ /**
62
+ * 获取协议
63
+ * @param protocolId 协议ID
64
+ * @returns 协议
65
+ */
66
+ async getProtocol(protocolId) {
67
+ return this.request.get(`/shop-policy/${protocolId}`);
68
+ }
60
69
  storeChange() {
61
70
  if (this.openCache) {
62
- this.checkSaveCache({ cacheId: this.cacheId, fatherModule: this.fatherModule, store: this.store, cacheKey: ["summary"] });
71
+ this.checkSaveCache({
72
+ cacheId: this.cacheId,
73
+ fatherModule: this.fatherModule,
74
+ store: this.store,
75
+ cacheKey: ["summary"]
76
+ });
63
77
  }
64
78
  }
65
79
  };
@@ -1,13 +1,34 @@
1
- import { CartItem } from "../Cart/types";
1
+ import { CartItem } from '../Cart/types';
2
2
  export interface ISummaryState {
3
3
  summary: {
4
+ /** 商品总价 */
4
5
  subtotal: string | number;
6
+ /** 最终总价 */
5
7
  total: string | number;
8
+ /** 税率标题 */
6
9
  taxTitle?: string;
10
+ /** 商品总费率 */
7
11
  totalTaxFee?: string | number;
12
+ /** 商品价格是否包含费率 */
8
13
  isPriceIncludeTax?: 0 | 1;
14
+ /** 定金 */
15
+ deposit?: {
16
+ /** 定金总价 */
17
+ total?: string | number;
18
+ /** */
19
+ policies?: IProtocol[];
20
+ };
9
21
  };
10
22
  }
23
+ /**
24
+ * 定金协议
25
+ */
26
+ export interface IProtocol {
27
+ /** 协议名称 */
28
+ title: string;
29
+ /** 协议id */
30
+ id: string;
31
+ }
11
32
  export interface ISummaryModuleAPI {
12
- getSummary(cartItems: CartItem[]): Promise<ISummaryState["summary"]>;
33
+ getSummary(cartItems: CartItem[]): Promise<ISummaryState['summary']>;
13
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 - 购物车商品数组
@@ -17,3 +17,13 @@ export declare const calculateSubtotal: (items: CartItem[]) => string;
17
17
  * @Author: xiangfeng.xue
18
18
  */
19
19
  export declare const calculateTaxFee: (shopInfo: any, items: CartItem[]) => Decimal | "0.00";
20
+ /**
21
+ * @title: 计算定金
22
+ * @param items - 购物车商品数组
23
+ * @returns 定金字符串,保留2位小数
24
+ */
25
+ export declare const calculateDeposit: (items: CartItem[]) => {
26
+ total: string;
27
+ protocols: any[];
28
+ hasDeposit: never;
29
+ } | undefined;
@@ -29,6 +29,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
29
  // src/modules/Summary/utils.ts
30
30
  var utils_exports = {};
31
31
  __export(utils_exports, {
32
+ calculateDeposit: () => calculateDeposit,
32
33
  calculatePriceDetails: () => calculatePriceDetails,
33
34
  calculateSubtotal: () => calculateSubtotal,
34
35
  calculateTaxFee: () => calculateTaxFee
@@ -39,12 +40,14 @@ var calculatePriceDetails = (shopInfo, items) => {
39
40
  const subtotal = new import_decimal.default(calculateSubtotal(items));
40
41
  const totalTaxFee = new import_decimal.default(calculateTaxFee(shopInfo, items));
41
42
  const total = (shopInfo == null ? void 0 : shopInfo.is_price_include_tax) ? subtotal : subtotal.plus(totalTaxFee);
43
+ const deposit = calculateDeposit(items);
42
44
  return {
43
45
  subtotal: subtotal.toFixed(2),
44
46
  total: total.toFixed(2),
45
47
  taxTitle: shopInfo == null ? void 0 : shopInfo.tax_title,
46
48
  totalTaxFee: totalTaxFee.toFixed(2),
47
- isPriceIncludeTax: shopInfo == null ? void 0 : shopInfo.is_price_include_tax
49
+ isPriceIncludeTax: shopInfo == null ? void 0 : shopInfo.is_price_include_tax,
50
+ deposit
48
51
  };
49
52
  };
50
53
  var calculateSubtotal = (items) => {
@@ -70,8 +73,34 @@ var calculateTaxFee = (shopInfo, items) => {
70
73
  }, new import_decimal.default(0));
71
74
  return totalTaxFee;
72
75
  };
76
+ var calculateDeposit = (items) => {
77
+ if (!(items == null ? void 0 : items.length)) {
78
+ return void 0;
79
+ }
80
+ const protocols = [];
81
+ let hasDeposit = false;
82
+ const total = items.reduce((sum, item) => {
83
+ var _a, _b, _c;
84
+ if (item == null ? void 0 : item.deposit) {
85
+ hasDeposit = true;
86
+ const cartItemTotalPrice = new import_decimal.default(((_a = item == null ? void 0 : item.deposit) == null ? void 0 : _a.total) || 0);
87
+ (_c = (_b = item == null ? void 0 : item.deposit) == null ? void 0 : _b.protocols) == null ? void 0 : _c.forEach((protocol) => {
88
+ if (protocols.findIndex((p) => p.id === protocol.id) === -1) {
89
+ protocols.push(protocol);
90
+ }
91
+ });
92
+ return sum.plus(cartItemTotalPrice);
93
+ }
94
+ return sum;
95
+ }, new import_decimal.default(0));
96
+ if (hasDeposit) {
97
+ return { total: total.toFixed(2), protocols, hasDeposit };
98
+ }
99
+ return void 0;
100
+ };
73
101
  // Annotate the CommonJS export names for ESM import in node:
74
102
  0 && (module.exports = {
103
+ calculateDeposit,
75
104
  calculatePriceDetails,
76
105
  calculateSubtotal,
77
106
  calculateTaxFee
@@ -1,3 +1,13 @@
1
1
  export * from './Product';
2
2
  export * from './ProductList';
3
3
  export * from './Cart';
4
+ export * from './Account';
5
+ export * from './AccountList';
6
+ export * from './Date';
7
+ export * from './Guests';
8
+ export * from './Order';
9
+ export * from './Payment';
10
+ export * from './Resource';
11
+ export * from './Step';
12
+ export * from './Summary';
13
+ export * from './Schedule';
@@ -19,9 +19,29 @@ module.exports = __toCommonJS(modules_exports);
19
19
  __reExport(modules_exports, require("./Product"), module.exports);
20
20
  __reExport(modules_exports, require("./ProductList"), module.exports);
21
21
  __reExport(modules_exports, require("./Cart"), module.exports);
22
+ __reExport(modules_exports, require("./Account"), module.exports);
23
+ __reExport(modules_exports, require("./AccountList"), module.exports);
24
+ __reExport(modules_exports, require("./Date"), module.exports);
25
+ __reExport(modules_exports, require("./Guests"), module.exports);
26
+ __reExport(modules_exports, require("./Order"), module.exports);
27
+ __reExport(modules_exports, require("./Payment"), module.exports);
28
+ __reExport(modules_exports, require("./Resource"), module.exports);
29
+ __reExport(modules_exports, require("./Step"), module.exports);
30
+ __reExport(modules_exports, require("./Summary"), module.exports);
31
+ __reExport(modules_exports, require("./Schedule"), module.exports);
22
32
  // Annotate the CommonJS export names for ESM import in node:
23
33
  0 && (module.exports = {
24
34
  ...require("./Product"),
25
35
  ...require("./ProductList"),
26
- ...require("./Cart")
36
+ ...require("./Cart"),
37
+ ...require("./Account"),
38
+ ...require("./AccountList"),
39
+ ...require("./Date"),
40
+ ...require("./Guests"),
41
+ ...require("./Order"),
42
+ ...require("./Payment"),
43
+ ...require("./Resource"),
44
+ ...require("./Step"),
45
+ ...require("./Summary"),
46
+ ...require("./Schedule")
27
47
  });
@@ -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, ProductResourceItem, ECartItemInfoType, ECartItemCheckType } 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,60 @@ 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, }: {
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[];
45
+ schedule_ids?: number[];
46
+ }): Promise<any>;
47
+ loadProductByScheduleDate({ date, product_ids, category_ids, }: {
48
+ date: string;
49
+ product_ids?: number[];
50
+ category_ids?: number[];
34
51
  }): Promise<any>;
52
+ loadAllSchedule(): Promise<void>;
53
+ loadScheduleAvailableDate({ startDate, endDate, custom_page_id, }: {
54
+ startDate: string;
55
+ endDate: string;
56
+ custom_page_id?: number;
57
+ }): Promise<ITime[]>;
35
58
  storeProduct(productData: ProductData): Promise<void>;
36
- addAccount(accounts: Account[]): Promise<void>;
59
+ addAccount(account: Account | IHolder, extra?: {
60
+ type: 'account' | 'holder';
61
+ customerId: number;
62
+ }): Promise<Account | null>;
63
+ addAccounts(accounts: Account[] | IHolder[], extra?: {
64
+ type: 'account' | 'holder';
65
+ customerId: number;
66
+ }): Promise<Account[] | undefined>;
37
67
  getAccounts(): Promise<(Account | null)[]>;
38
68
  checkHasLoginAccount(): boolean;
39
69
  setActiveAccount(id: string): void;
40
70
  getActiveAccount(): Account | null;
41
71
  removeAccount(id: string): void;
72
+ /**
73
+ * 获取holder类型账户列表
74
+ * @param params
75
+ */
76
+ fetchHolderAccountsAsync(params: IFetchHolderAccountsParams): Promise<void>;
42
77
  setDateRange(dateRange: ITime[]): Promise<void>;
43
78
  clearDateRange(): void;
44
79
  getDateRange(): Promise<ITime[]>;
45
80
  getCart(): CartItem[];
46
81
  getAvailableDate(params?: {
82
+ url?: string;
47
83
  products?: ProductData[];
48
84
  startDate?: string;
49
85
  endDate?: string;
86
+ type?: 'month' | 'day';
50
87
  }): Promise<ITime[]>;
51
88
  /**
52
89
  * 获取购物车汇总信息
@@ -57,11 +94,25 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
57
94
  taxTitle?: string | undefined;
58
95
  totalTaxFee?: string | number | undefined;
59
96
  isPriceIncludeTax?: 0 | 1 | undefined;
97
+ deposit?: {
98
+ total?: string | number | undefined;
99
+ policies?: import("../../modules/Summary/types").IProtocol[] | undefined;
100
+ } | undefined;
60
101
  }>;
102
+ /**
103
+ * 获取协议
104
+ */
105
+ getProtocol(protocolId: string): Promise<any>;
61
106
  getProducts(): Promise<ProductData[]>;
62
107
  setLoginAccount(accountId: string, accountInfo: Account): Promise<void>;
63
108
  generateCartData(): Promise<void>;
64
109
  getFreeProduct(id: string | number): Promise<Response<any>>;
110
+ /**
111
+ * 检查购物车提交订单前是否符合条件
112
+ * @param type 类型 "holder" | "account"
113
+ * @returns boolean
114
+ */
115
+ checkBeforeSubmitOrder(type: 'holder' | 'account'): boolean;
65
116
  submitOrder(): Promise<void>;
66
117
  pay(): Promise<void>;
67
118
  getPayInfo(): Promise<void>;
@@ -80,7 +131,14 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
80
131
  /**
81
132
  * 从购物车中按类别删除信息
82
133
  */
83
- deleteCartItemInfo(types: "resource" | "time"): void;
134
+ deleteCartItemInfo(type: ECartItemInfoType, _id?: string): void;
135
+ checkCartItemByType(cartItem: CartItem, type: ECartItemCheckType): boolean;
136
+ /**
137
+ * 检查购物车商品是否符合条件
138
+ * @param type 类型
139
+ * @returns 不符合条件的购物车商品ID列表
140
+ */
141
+ checkCartItems(type: ECartItemCheckType): string[];
84
142
  destroy(): void;
85
143
  getResourcesList(): any[];
86
144
  getResourcesListByCartItem(id: string | number): {
@@ -96,22 +154,12 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
96
154
  resources: any[];
97
155
  currentResourceId: number;
98
156
  }): TimeSliceItem[];
99
- autoSelectResource({ resourceProductData, resources, timeSlots, }: {
100
- resourceProductData: any;
101
- resources: any[];
102
- timeSlots?: TimeSliceItem;
103
- }): {
104
- selectedResource: any;
105
- timeSlots?: undefined;
106
- } | {
107
- timeSlots: any[];
108
- selectedResource: any;
109
- } | undefined;
110
- autoSelectAccountResources({ holder_id, resources_code, timeSlots, countMap, }: {
157
+ autoSelectAccountResources({ holder_id, resources_code, timeSlots, countMap, capacity, }: {
111
158
  holder_id: string;
112
159
  resources_code: string | number;
113
160
  timeSlots?: TimeSliceItem;
114
161
  countMap: Record<number, number>;
162
+ capacity?: number;
115
163
  }): {
116
164
  selectedResource: any;
117
165
  timeSlots?: undefined;
@@ -126,4 +174,29 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
126
174
  submitTimeSlot(timeSlots: TimeSliceItem): void;
127
175
  clearCache(): void;
128
176
  clearCacheByModule(module: string): void;
177
+ private getScheduleDataByIds;
178
+ openProductDetail(productId: number): Promise<void>;
179
+ closeProductDetail(): void;
180
+ getTimeslotBySchedule({ date, scheduleIds, resources, }: {
181
+ date: string;
182
+ scheduleIds?: number[];
183
+ resources?: ProductResourceItem[];
184
+ }): {
185
+ start_time: string;
186
+ end_time: string;
187
+ start_at: dayjs.Dayjs;
188
+ end_at: dayjs.Dayjs;
189
+ count: number;
190
+ }[];
191
+ addProductToCart({ product, date, account, }: {
192
+ product: ProductData;
193
+ date: {
194
+ startTime: string;
195
+ endTime: string;
196
+ };
197
+ account: Account;
198
+ }): void;
199
+ setOtherData(key: string, value: any): void;
200
+ getOtherData(key: string): any;
201
+ getProductTypeById(id: number): Promise<"duration" | "session" | "normal">;
129
202
  }