@pisell/pisellos 0.0.321 → 0.0.324

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 (74) hide show
  1. package/dist/effects/index.d.ts +2 -2
  2. package/dist/modules/Customer/types.d.ts +1 -1
  3. package/dist/modules/Payment/types.d.ts +7 -7
  4. package/dist/modules/Product/index.d.ts +1 -1
  5. package/dist/modules/ProductList/index.js +2 -1
  6. package/dist/modules/Rules/types.d.ts +1 -1
  7. package/dist/modules/Schedule/type.d.ts +7 -7
  8. package/dist/modules/Schedule/types.d.ts +9 -9
  9. package/dist/solution/BookingByStep/index.d.ts +1 -1
  10. package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
  11. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  12. package/dist/types/index.d.ts +1 -1
  13. package/dist/utils/task.d.ts +2 -2
  14. package/dist/utils/watch.d.ts +2 -2
  15. package/lib/core/index.js +27 -28
  16. package/lib/effects/index.d.ts +2 -2
  17. package/lib/effects/index.js +3 -7
  18. package/lib/modules/Account/index.js +9 -10
  19. package/lib/modules/AccountList/index.js +14 -11
  20. package/lib/modules/BaseModule.js +6 -3
  21. package/lib/modules/Cart/index.js +14 -9
  22. package/lib/modules/Cart/utils/cartProduct.js +3 -6
  23. package/lib/modules/Customer/constants.js +1 -1
  24. package/lib/modules/Customer/index.js +18 -15
  25. package/lib/modules/Customer/types.d.ts +1 -1
  26. package/lib/modules/Date/index.js +10 -6
  27. package/lib/modules/Date/types.js +1 -0
  28. package/lib/modules/Discount/index.js +11 -6
  29. package/lib/modules/Guests/index.js +10 -15
  30. package/lib/modules/Order/index.js +11 -9
  31. package/lib/modules/Payment/cash.js +1 -1
  32. package/lib/modules/Payment/cashRecommendationAlgorithm.js +1 -1
  33. package/lib/modules/Payment/eftpos.js +1 -1
  34. package/lib/modules/Payment/index.js +80 -69
  35. package/lib/modules/Payment/types.d.ts +7 -7
  36. package/lib/modules/Payment/utils.js +3 -6
  37. package/lib/modules/Payment/walletpass.js +31 -31
  38. package/lib/modules/Product/index.d.ts +1 -1
  39. package/lib/modules/Product/index.js +6 -5
  40. package/lib/modules/ProductList/index.js +7 -4
  41. package/lib/modules/Resource/index.js +8 -12
  42. package/lib/modules/Rules/index.js +12 -17
  43. package/lib/modules/Rules/types.d.ts +1 -1
  44. package/lib/modules/Schedule/index.js +8 -5
  45. package/lib/modules/Schedule/type.d.ts +7 -7
  46. package/lib/modules/Schedule/types.d.ts +9 -9
  47. package/lib/modules/Schedule/utils.js +2 -4
  48. package/lib/modules/Step/index.js +7 -4
  49. package/lib/modules/Summary/index.js +9 -4
  50. package/lib/plugins/request.js +34 -33
  51. package/lib/plugins/window.js +101 -113
  52. package/lib/solution/BookingByStep/index.d.ts +1 -1
  53. package/lib/solution/BookingByStep/index.js +70 -104
  54. package/lib/solution/BookingByStep/utils/capacity.js +10 -15
  55. package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
  56. package/lib/solution/BookingByStep/utils/resources.js +4 -8
  57. package/lib/solution/BookingByStep/utils/stock.js +3 -6
  58. package/lib/solution/BookingByStep/utils/timeslots.js +24 -27
  59. package/lib/solution/BookingTicket/index.js +19 -14
  60. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +3 -3
  61. package/lib/solution/BookingTicket/utils/scan/handleScan.js +6 -6
  62. package/lib/solution/BookingTicket/utils/scan/index.js +3 -1
  63. package/lib/solution/BookingTicket/utils/scan/scanCache.js +10 -9
  64. package/lib/solution/BuyTickets/index.js +15 -15
  65. package/lib/solution/Checkout/index.js +206 -199
  66. package/lib/solution/Checkout/utils/index.js +18 -22
  67. package/lib/solution/ShopDiscount/index.js +15 -11
  68. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  69. package/lib/types/index.d.ts +1 -1
  70. package/lib/utils/task.d.ts +2 -2
  71. package/lib/utils/task.js +3 -3
  72. package/lib/utils/watch.d.ts +2 -2
  73. package/lib/utils/watch.js +5 -7
  74. package/package.json +1 -1
@@ -48,26 +48,26 @@ var import_types = require("../../../modules/Payment/types");
48
48
  function validateCheckoutData(params) {
49
49
  const errors = [];
50
50
  if (!params.cartItems || params.cartItems.length === 0) {
51
- errors.push("购物车不能为空");
51
+ errors.push("\u8D2D\u7269\u8F66\u4E0D\u80FD\u4E3A\u7A7A");
52
52
  }
53
53
  if (params.cartItems) {
54
54
  params.cartItems.forEach((item, index) => {
55
55
  if (!item.id) {
56
- errors.push(`购物车商品 ${index + 1} 缺少商品ID`);
56
+ errors.push(`\u8D2D\u7269\u8F66\u5546\u54C1 ${index + 1} \u7F3A\u5C11\u5546\u54C1ID`);
57
57
  }
58
58
  if (!item.price || parseFloat(String(item.price)) < 0) {
59
- errors.push(`购物车商品 ${index + 1} 价格无效`);
59
+ errors.push(`\u8D2D\u7269\u8F66\u5546\u54C1 ${index + 1} \u4EF7\u683C\u65E0\u6548`);
60
60
  }
61
61
  if (!item.num || item.num <= 0) {
62
- errors.push(`购物车商品 ${index + 1} 数量无效`);
62
+ errors.push(`\u8D2D\u7269\u8F66\u5546\u54C1 ${index + 1} \u6570\u91CF\u65E0\u6548`);
63
63
  }
64
64
  });
65
65
  }
66
66
  if (params.orderType && !["virtual", "appointment_booking"].includes(params.orderType)) {
67
- errors.push("订单类型无效,必须是 virtual appointment_booking");
67
+ errors.push("\u8BA2\u5355\u7C7B\u578B\u65E0\u6548\uFF0C\u5FC5\u987B\u662F virtual \u6216 appointment_booking");
68
68
  }
69
69
  if (params.platform && !["pc", "h5"].includes(params.platform)) {
70
- errors.push("平台类型无效,必须是 pc h5");
70
+ errors.push("\u5E73\u53F0\u7C7B\u578B\u65E0\u6548\uFF0C\u5FC5\u987B\u662F pc \u6216 h5");
71
71
  }
72
72
  return {
73
73
  valid: errors.length === 0,
@@ -84,8 +84,7 @@ function createCheckoutError(type, message, details) {
84
84
  }
85
85
  function formatAmount(amount) {
86
86
  const numAmount = typeof amount === "string" ? parseFloat(amount) : amount;
87
- if (isNaN(numAmount))
88
- return "0.00";
87
+ if (isNaN(numAmount)) return "0.00";
89
88
  return numAmount.toFixed(2);
90
89
  }
91
90
  function validateAmount(amount) {
@@ -165,12 +164,9 @@ async function retry(fn, maxAttempts = 3, delay = 1e3) {
165
164
  throw lastError;
166
165
  }
167
166
  function isEmpty(obj) {
168
- if (obj == null)
169
- return true;
170
- if (Array.isArray(obj) || typeof obj === "string")
171
- return obj.length === 0;
172
- if (typeof obj === "object")
173
- return Object.keys(obj).length === 0;
167
+ if (obj == null) return true;
168
+ if (Array.isArray(obj) || typeof obj === "string") return obj.length === 0;
169
+ if (typeof obj === "object") return Object.keys(obj).length === 0;
174
170
  return false;
175
171
  }
176
172
  function getErrorMessage(error) {
@@ -183,7 +179,7 @@ function getErrorMessage(error) {
183
179
  if (error && typeof error === "object" && "message" in error) {
184
180
  return String(error.message);
185
181
  }
186
- return "未知错误";
182
+ return "\u672A\u77E5\u9519\u8BEF";
187
183
  }
188
184
  function isProduction() {
189
185
  return process.env.NODE_ENV === "production";
@@ -208,24 +204,24 @@ function validateLocalOrderData(orderData) {
208
204
  var _a;
209
205
  const errors = [];
210
206
  if (!orderData.type) {
211
- errors.push("订单类型不能为空");
207
+ errors.push("\u8BA2\u5355\u7C7B\u578B\u4E0D\u80FD\u4E3A\u7A7A");
212
208
  }
213
209
  if (!orderData.platform) {
214
- errors.push("平台信息不能为空");
210
+ errors.push("\u5E73\u53F0\u4FE1\u606F\u4E0D\u80FD\u4E3A\u7A7A");
215
211
  }
216
212
  if ((!orderData.bookings || orderData.bookings.length === 0) && !((_a = orderData == null ? void 0 : orderData.relation_products) == null ? void 0 : _a.length)) {
217
- errors.push("预订信息不能为空");
213
+ errors.push("\u9884\u8BA2\u4FE1\u606F\u4E0D\u80FD\u4E3A\u7A7A");
218
214
  }
219
215
  if (orderData.bookings) {
220
216
  orderData.bookings.forEach((booking, index) => {
221
217
  if (!booking.product || !booking.product.product_id) {
222
- errors.push(`预订项 ${index + 1} 缺少商品信息`);
218
+ errors.push(`\u9884\u8BA2\u9879 ${index + 1} \u7F3A\u5C11\u5546\u54C1\u4FE1\u606F`);
223
219
  }
224
220
  if (!booking.start_date) {
225
- errors.push(`预订项 ${index + 1} 缺少开始日期`);
221
+ errors.push(`\u9884\u8BA2\u9879 ${index + 1} \u7F3A\u5C11\u5F00\u59CB\u65E5\u671F`);
226
222
  }
227
223
  if (!booking.start_time) {
228
- errors.push(`预订项 ${index + 1} 缺少开始时间`);
224
+ errors.push(`\u9884\u8BA2\u9879 ${index + 1} \u7F3A\u5C11\u5F00\u59CB\u65F6\u95F4`);
229
225
  }
230
226
  });
231
227
  }
@@ -288,7 +284,7 @@ function extractAmountFromCartSummary(cartSummary) {
288
284
  break;
289
285
  }
290
286
  });
291
- console.log("[Checkout] 从购物车小计提取金额信息:", {
287
+ console.log("[Checkout] \u4ECE\u8D2D\u7269\u8F66\u5C0F\u8BA1\u63D0\u53D6\u91D1\u989D\u4FE1\u606F:", {
292
288
  totalAmount: result.totalAmount,
293
289
  subTotal: result.subTotal,
294
290
  taxAmount: result.taxAmount,
@@ -41,12 +41,16 @@ var import_utils = require("./utils");
41
41
  var import_decimal = __toESM(require("decimal.js"));
42
42
  var import_lodash_es = require("lodash-es");
43
43
  var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
44
+ defaultName = "shopDiscount";
45
+ defaultVersion = "1.0.0";
46
+ isSolution = true;
47
+ request;
48
+ window;
49
+ store;
50
+ options = {};
51
+ hooks;
44
52
  constructor(name, version) {
45
53
  super(name, version);
46
- this.defaultName = "shopDiscount";
47
- this.defaultVersion = "1.0.0";
48
- this.isSolution = true;
49
- this.options = {};
50
54
  this.store = {
51
55
  customer: null,
52
56
  productList: [],
@@ -64,7 +68,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
64
68
  this.options = options;
65
69
  this.store = { ...this.store, ...options.store || {} };
66
70
  this.hooks = (_b = (_a = options.otherParams) == null ? void 0 : _a.rules) == null ? void 0 : _b.hooks;
67
- console.log("[ShopDiscount] 初始化完成");
71
+ console.log("[ShopDiscount] \u521D\u59CB\u5316\u5B8C\u6210");
68
72
  this.initializePlugins();
69
73
  this.registerDependentModules();
70
74
  this.registerEventListeners();
@@ -77,7 +81,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
77
81
  (_b = this.store.rules) == null ? void 0 : _b.destroy();
78
82
  this.core.effects.offByModuleDestroy(this.name);
79
83
  await this.core.effects.emit(import_types.ShopDiscountHooks.onDestroy, {});
80
- console.log("[ShopDiscount] 已销毁");
84
+ console.log("[ShopDiscount] \u5DF2\u9500\u6BC1");
81
85
  }
82
86
  async clear() {
83
87
  var _a, _b;
@@ -92,10 +96,10 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
92
96
  this.request = this.core.getPlugin("request");
93
97
  this.window = this.core.getPlugin("window");
94
98
  if (!this.request) {
95
- throw new Error("ShopDiscount需要 request 插件支持");
99
+ throw new Error("ShopDiscount\u9700\u8981 request \u63D2\u4EF6\u652F\u6301");
96
100
  }
97
101
  if (!this.window) {
98
- throw new Error("ShopDiscount需要 window 插件支持");
102
+ throw new Error("ShopDiscount\u9700\u8981 window \u63D2\u4EF6\u652F\u6301");
99
103
  }
100
104
  }
101
105
  registerDependentModules() {
@@ -300,7 +304,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
300
304
  discountList: newDiscountList || this.getDiscountList()
301
305
  };
302
306
  } catch (error) {
303
- console.error("[ShopDiscount] 扫码出错:", error);
307
+ console.error("[ShopDiscount] \u626B\u7801\u51FA\u9519:", error);
304
308
  return {
305
309
  type: "clientCalc",
306
310
  isAvailable: false,
@@ -431,7 +435,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
431
435
  );
432
436
  }
433
437
  } catch (error) {
434
- console.error("[ShopDiscount] 获取客户钱包信息出错:", error);
438
+ console.error("[ShopDiscount] \u83B7\u53D6\u5BA2\u6237\u94B1\u5305\u4FE1\u606F\u51FA\u9519:", error);
435
439
  }
436
440
  }
437
441
  async bestDiscount(cb) {
@@ -485,7 +489,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
485
489
  filteredDiscountList
486
490
  );
487
491
  } catch (error) {
488
- console.error("[ShopDiscount] 加载准备配置出错:", error);
492
+ console.error("[ShopDiscount] \u52A0\u8F7D\u51C6\u5907\u914D\u7F6E\u51FA\u9519:", error);
489
493
  }
490
494
  }
491
495
  };
@@ -11,7 +11,7 @@ export declare enum ShopDiscountHooks {
11
11
  onRulesListChange = "shopDiscount:onRulesListChange",
12
12
  onLoadPrepareCalcResult = "shopDiscount:onLoadPrepareCalcResult"
13
13
  }
14
- export type Customer = {
14
+ export declare type Customer = {
15
15
  id: string | number;
16
16
  name: string;
17
17
  email: string;
@@ -27,7 +27,7 @@ export interface ModuleOptions {
27
27
  initialState?: Record<string, any>;
28
28
  otherParams?: Record<string, any>;
29
29
  }
30
- export type EventHandler = (data?: any) => void;
30
+ export declare type EventHandler = (data?: any) => void;
31
31
  export interface PisellCore {
32
32
  registerPlugin: (plugin: Plugin, options?: PluginOptions) => void;
33
33
  getPlugin: <T extends Plugin>(name: string) => T | null;
@@ -1,5 +1,5 @@
1
- type Action = (...args: any[]) => Promise<any>;
2
- type Task = {
1
+ declare type Action = (...args: any[]) => Promise<any>;
2
+ declare type Task = {
3
3
  uuid: string;
4
4
  type: string;
5
5
  actionParams?: Record<string, any>;
package/lib/utils/task.js CHANGED
@@ -23,10 +23,10 @@ __export(task_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(task_exports);
25
25
  var Tasks = class {
26
+ actions = /* @__PURE__ */ new Map();
27
+ taskQueue = [];
28
+ isRunning = false;
26
29
  constructor(actions) {
27
- this.actions = /* @__PURE__ */ new Map();
28
- this.taskQueue = [];
29
- this.isRunning = false;
30
30
  if (actions) {
31
31
  this.actions = actions;
32
32
  }
@@ -2,8 +2,8 @@
2
2
  * 监听模块
3
3
  *
4
4
  */
5
- export type WatchEventCallback = (...args: any[]) => void;
6
- export type WatchEventItem = {
5
+ export declare type WatchEventCallback = (...args: any[]) => void;
6
+ export declare type WatchEventItem = {
7
7
  key: string;
8
8
  callback: WatchEventCallback;
9
9
  };
@@ -23,12 +23,10 @@ __export(watch_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(watch_exports);
25
25
  var Watch = class {
26
- constructor() {
27
- // 监听列表
28
- this.events = /* @__PURE__ */ new Map();
29
- // 启用列表 - 使用数组保持顺序
30
- this.enableListMap = /* @__PURE__ */ new Map();
31
- }
26
+ // 监听列表
27
+ events = /* @__PURE__ */ new Map();
28
+ // 启用列表 - 使用数组保持顺序
29
+ enableListMap = /* @__PURE__ */ new Map();
32
30
  /**
33
31
  * 订阅事件
34
32
  * @param event 事件名称
@@ -132,7 +130,7 @@ var Watch = class {
132
130
  try {
133
131
  (_a = callbacks.get(lastCallbackKey)) == null ? void 0 : _a(...args);
134
132
  } catch (error) {
135
- console.error(`执行事件"${watchKey}"的回调时出错:`, error);
133
+ console.error(`\u6267\u884C\u4E8B\u4EF6"${watchKey}"\u7684\u56DE\u8C03\u65F6\u51FA\u9519:`, error);
136
134
  }
137
135
  }
138
136
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.321",
4
+ "version": "0.0.324",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",