@pisell/pisellos 0.0.324 → 0.0.326
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.
- package/dist/effects/index.d.ts +2 -2
- package/dist/modules/Account/index.js +2 -3
- package/dist/modules/BaseModule.d.ts +3 -0
- package/dist/modules/BaseModule.js +15 -0
- package/dist/modules/Customer/index.js +9 -10
- package/dist/modules/Customer/types.d.ts +1 -1
- package/dist/modules/Discount/index.js +1 -1
- package/dist/modules/Guests/index.js +9 -9
- package/dist/modules/Payment/index.js +18 -18
- package/dist/modules/Payment/types.d.ts +7 -7
- package/dist/modules/Payment/walletpass.js +4 -1
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/ProductList/index.js +2 -3
- package/dist/modules/Resource/index.js +1 -1
- package/dist/modules/Rules/index.js +2 -3
- package/dist/modules/Rules/types.d.ts +1 -1
- package/dist/modules/Schedule/type.d.ts +7 -7
- package/dist/modules/Schedule/types.d.ts +9 -9
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/index.js +2 -2
- package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +7 -7
- package/dist/solution/BuyTickets/index.js +7 -8
- package/dist/solution/Checkout/index.js +29 -29
- package/dist/solution/ShopDiscount/index.js +1 -1
- package/dist/solution/ShopDiscount/types.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/task.d.ts +2 -2
- package/dist/utils/watch.d.ts +2 -2
- package/lib/core/index.js +28 -27
- package/lib/effects/index.d.ts +2 -2
- package/lib/effects/index.js +7 -3
- package/lib/modules/Account/index.js +12 -12
- package/lib/modules/AccountList/index.js +11 -14
- package/lib/modules/BaseModule.d.ts +3 -0
- package/lib/modules/BaseModule.js +12 -6
- package/lib/modules/Cart/index.js +9 -14
- package/lib/modules/Cart/utils/cartProduct.js +6 -3
- package/lib/modules/Customer/constants.js +1 -1
- package/lib/modules/Customer/index.js +24 -28
- package/lib/modules/Customer/types.d.ts +1 -1
- package/lib/modules/Date/index.js +6 -10
- package/lib/modules/Date/types.js +0 -1
- package/lib/modules/Discount/index.js +7 -12
- package/lib/modules/Guests/index.js +24 -19
- package/lib/modules/Order/index.js +9 -11
- package/lib/modules/Payment/cash.js +1 -1
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +1 -1
- package/lib/modules/Payment/eftpos.js +1 -1
- package/lib/modules/Payment/index.js +86 -97
- package/lib/modules/Payment/types.d.ts +7 -7
- package/lib/modules/Payment/utils.js +6 -3
- package/lib/modules/Payment/walletpass.js +34 -32
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Product/index.js +5 -6
- package/lib/modules/ProductList/index.js +5 -8
- package/lib/modules/Resource/index.js +13 -9
- package/lib/modules/Rules/index.js +19 -15
- package/lib/modules/Rules/types.d.ts +1 -1
- package/lib/modules/Schedule/index.js +5 -8
- package/lib/modules/Schedule/type.d.ts +7 -7
- package/lib/modules/Schedule/types.d.ts +9 -9
- package/lib/modules/Schedule/utils.js +4 -2
- package/lib/modules/Step/index.js +4 -7
- package/lib/modules/Summary/index.js +4 -9
- package/lib/plugins/request.js +33 -34
- package/lib/plugins/window.js +113 -101
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +105 -71
- package/lib/solution/BookingByStep/utils/capacity.js +15 -10
- package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
- package/lib/solution/BookingByStep/utils/resources.js +8 -4
- package/lib/solution/BookingByStep/utils/stock.js +6 -3
- package/lib/solution/BookingByStep/utils/timeslots.js +27 -24
- package/lib/solution/BookingTicket/index.js +20 -25
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +3 -3
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +6 -6
- package/lib/solution/BookingTicket/utils/scan/index.js +1 -3
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +9 -10
- package/lib/solution/BuyTickets/index.js +22 -23
- package/lib/solution/Checkout/index.js +227 -234
- package/lib/solution/Checkout/utils/index.js +22 -18
- package/lib/solution/ShopDiscount/index.js +12 -16
- package/lib/solution/ShopDiscount/types.d.ts +1 -1
- package/lib/types/index.d.ts +1 -1
- package/lib/utils/task.d.ts +2 -2
- package/lib/utils/task.js +3 -3
- package/lib/utils/watch.d.ts +2 -2
- package/lib/utils/watch.js +7 -5
- 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("购物车不能为空");
|
|
52
52
|
}
|
|
53
53
|
if (params.cartItems) {
|
|
54
54
|
params.cartItems.forEach((item, index) => {
|
|
55
55
|
if (!item.id) {
|
|
56
|
-
errors.push(
|
|
56
|
+
errors.push(`购物车商品 ${index + 1} 缺少商品ID`);
|
|
57
57
|
}
|
|
58
58
|
if (!item.price || parseFloat(String(item.price)) < 0) {
|
|
59
|
-
errors.push(
|
|
59
|
+
errors.push(`购物车商品 ${index + 1} 价格无效`);
|
|
60
60
|
}
|
|
61
61
|
if (!item.num || item.num <= 0) {
|
|
62
|
-
errors.push(
|
|
62
|
+
errors.push(`购物车商品 ${index + 1} 数量无效`);
|
|
63
63
|
}
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
if (params.orderType && !["virtual", "appointment_booking"].includes(params.orderType)) {
|
|
67
|
-
errors.push("
|
|
67
|
+
errors.push("订单类型无效,必须是 virtual 或 appointment_booking");
|
|
68
68
|
}
|
|
69
69
|
if (params.platform && !["pc", "h5"].includes(params.platform)) {
|
|
70
|
-
errors.push("
|
|
70
|
+
errors.push("平台类型无效,必须是 pc 或 h5");
|
|
71
71
|
}
|
|
72
72
|
return {
|
|
73
73
|
valid: errors.length === 0,
|
|
@@ -84,7 +84,8 @@ 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))
|
|
87
|
+
if (isNaN(numAmount))
|
|
88
|
+
return "0.00";
|
|
88
89
|
return numAmount.toFixed(2);
|
|
89
90
|
}
|
|
90
91
|
function validateAmount(amount) {
|
|
@@ -164,9 +165,12 @@ async function retry(fn, maxAttempts = 3, delay = 1e3) {
|
|
|
164
165
|
throw lastError;
|
|
165
166
|
}
|
|
166
167
|
function isEmpty(obj) {
|
|
167
|
-
if (obj == null)
|
|
168
|
-
|
|
169
|
-
if (typeof 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;
|
|
170
174
|
return false;
|
|
171
175
|
}
|
|
172
176
|
function getErrorMessage(error) {
|
|
@@ -179,7 +183,7 @@ function getErrorMessage(error) {
|
|
|
179
183
|
if (error && typeof error === "object" && "message" in error) {
|
|
180
184
|
return String(error.message);
|
|
181
185
|
}
|
|
182
|
-
return "
|
|
186
|
+
return "未知错误";
|
|
183
187
|
}
|
|
184
188
|
function isProduction() {
|
|
185
189
|
return process.env.NODE_ENV === "production";
|
|
@@ -204,24 +208,24 @@ function validateLocalOrderData(orderData) {
|
|
|
204
208
|
var _a;
|
|
205
209
|
const errors = [];
|
|
206
210
|
if (!orderData.type) {
|
|
207
|
-
errors.push("
|
|
211
|
+
errors.push("订单类型不能为空");
|
|
208
212
|
}
|
|
209
213
|
if (!orderData.platform) {
|
|
210
|
-
errors.push("
|
|
214
|
+
errors.push("平台信息不能为空");
|
|
211
215
|
}
|
|
212
216
|
if ((!orderData.bookings || orderData.bookings.length === 0) && !((_a = orderData == null ? void 0 : orderData.relation_products) == null ? void 0 : _a.length)) {
|
|
213
|
-
errors.push("
|
|
217
|
+
errors.push("预订信息不能为空");
|
|
214
218
|
}
|
|
215
219
|
if (orderData.bookings) {
|
|
216
220
|
orderData.bookings.forEach((booking, index) => {
|
|
217
221
|
if (!booking.product || !booking.product.product_id) {
|
|
218
|
-
errors.push(
|
|
222
|
+
errors.push(`预订项 ${index + 1} 缺少商品信息`);
|
|
219
223
|
}
|
|
220
224
|
if (!booking.start_date) {
|
|
221
|
-
errors.push(
|
|
225
|
+
errors.push(`预订项 ${index + 1} 缺少开始日期`);
|
|
222
226
|
}
|
|
223
227
|
if (!booking.start_time) {
|
|
224
|
-
errors.push(
|
|
228
|
+
errors.push(`预订项 ${index + 1} 缺少开始时间`);
|
|
225
229
|
}
|
|
226
230
|
});
|
|
227
231
|
}
|
|
@@ -284,7 +288,7 @@ function extractAmountFromCartSummary(cartSummary) {
|
|
|
284
288
|
break;
|
|
285
289
|
}
|
|
286
290
|
});
|
|
287
|
-
console.log("[Checkout]
|
|
291
|
+
console.log("[Checkout] 从购物车小计提取金额信息:", {
|
|
288
292
|
totalAmount: result.totalAmount,
|
|
289
293
|
subTotal: result.subTotal,
|
|
290
294
|
taxAmount: result.taxAmount,
|
|
@@ -41,16 +41,12 @@ 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;
|
|
52
44
|
constructor(name, version) {
|
|
53
45
|
super(name, version);
|
|
46
|
+
this.defaultName = "shopDiscount";
|
|
47
|
+
this.defaultVersion = "1.0.0";
|
|
48
|
+
this.isSolution = true;
|
|
49
|
+
this.options = {};
|
|
54
50
|
this.store = {
|
|
55
51
|
customer: null,
|
|
56
52
|
productList: [],
|
|
@@ -68,7 +64,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
68
64
|
this.options = options;
|
|
69
65
|
this.store = { ...this.store, ...options.store || {} };
|
|
70
66
|
this.hooks = (_b = (_a = options.otherParams) == null ? void 0 : _a.rules) == null ? void 0 : _b.hooks;
|
|
71
|
-
console.log("[ShopDiscount]
|
|
67
|
+
console.log("[ShopDiscount] 初始化完成");
|
|
72
68
|
this.initializePlugins();
|
|
73
69
|
this.registerDependentModules();
|
|
74
70
|
this.registerEventListeners();
|
|
@@ -80,8 +76,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
80
76
|
(_a = this.store.discount) == null ? void 0 : _a.destroy();
|
|
81
77
|
(_b = this.store.rules) == null ? void 0 : _b.destroy();
|
|
82
78
|
this.core.effects.offByModuleDestroy(this.name);
|
|
83
|
-
await this.core.effects.emit(
|
|
84
|
-
console.log("[ShopDiscount]
|
|
79
|
+
await this.core.effects.emit(`${this.name}:onDestroy`, {});
|
|
80
|
+
console.log("[ShopDiscount] 已销毁");
|
|
85
81
|
}
|
|
86
82
|
async clear() {
|
|
87
83
|
var _a, _b;
|
|
@@ -96,10 +92,10 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
96
92
|
this.request = this.core.getPlugin("request");
|
|
97
93
|
this.window = this.core.getPlugin("window");
|
|
98
94
|
if (!this.request) {
|
|
99
|
-
throw new Error("ShopDiscount
|
|
95
|
+
throw new Error("ShopDiscount需要 request 插件支持");
|
|
100
96
|
}
|
|
101
97
|
if (!this.window) {
|
|
102
|
-
throw new Error("ShopDiscount
|
|
98
|
+
throw new Error("ShopDiscount需要 window 插件支持");
|
|
103
99
|
}
|
|
104
100
|
}
|
|
105
101
|
registerDependentModules() {
|
|
@@ -304,7 +300,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
304
300
|
discountList: newDiscountList || this.getDiscountList()
|
|
305
301
|
};
|
|
306
302
|
} catch (error) {
|
|
307
|
-
console.error("[ShopDiscount]
|
|
303
|
+
console.error("[ShopDiscount] 扫码出错:", error);
|
|
308
304
|
return {
|
|
309
305
|
type: "clientCalc",
|
|
310
306
|
isAvailable: false,
|
|
@@ -435,7 +431,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
435
431
|
);
|
|
436
432
|
}
|
|
437
433
|
} catch (error) {
|
|
438
|
-
console.error("[ShopDiscount]
|
|
434
|
+
console.error("[ShopDiscount] 获取客户钱包信息出错:", error);
|
|
439
435
|
}
|
|
440
436
|
}
|
|
441
437
|
async bestDiscount(cb) {
|
|
@@ -489,7 +485,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
489
485
|
filteredDiscountList
|
|
490
486
|
);
|
|
491
487
|
} catch (error) {
|
|
492
|
-
console.error("[ShopDiscount]
|
|
488
|
+
console.error("[ShopDiscount] 加载准备配置出错:", error);
|
|
493
489
|
}
|
|
494
490
|
}
|
|
495
491
|
};
|
|
@@ -11,7 +11,7 @@ export declare enum ShopDiscountHooks {
|
|
|
11
11
|
onRulesListChange = "shopDiscount:onRulesListChange",
|
|
12
12
|
onLoadPrepareCalcResult = "shopDiscount:onLoadPrepareCalcResult"
|
|
13
13
|
}
|
|
14
|
-
export
|
|
14
|
+
export type Customer = {
|
|
15
15
|
id: string | number;
|
|
16
16
|
name: string;
|
|
17
17
|
email: string;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export interface ModuleOptions {
|
|
|
27
27
|
initialState?: Record<string, any>;
|
|
28
28
|
otherParams?: Record<string, any>;
|
|
29
29
|
}
|
|
30
|
-
export
|
|
30
|
+
export 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;
|
package/lib/utils/task.d.ts
CHANGED
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;
|
|
29
26
|
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
|
}
|
package/lib/utils/watch.d.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* 监听模块
|
|
3
3
|
*
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
6
|
-
export
|
|
5
|
+
export type WatchEventCallback = (...args: any[]) => void;
|
|
6
|
+
export type WatchEventItem = {
|
|
7
7
|
key: string;
|
|
8
8
|
callback: WatchEventCallback;
|
|
9
9
|
};
|
package/lib/utils/watch.js
CHANGED
|
@@ -23,10 +23,12 @@ __export(watch_exports, {
|
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(watch_exports);
|
|
25
25
|
var Watch = class {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
constructor() {
|
|
27
|
+
// 监听列表
|
|
28
|
+
this.events = /* @__PURE__ */ new Map();
|
|
29
|
+
// 启用列表 - 使用数组保持顺序
|
|
30
|
+
this.enableListMap = /* @__PURE__ */ new Map();
|
|
31
|
+
}
|
|
30
32
|
/**
|
|
31
33
|
* 订阅事件
|
|
32
34
|
* @param event 事件名称
|
|
@@ -130,7 +132,7 @@ var Watch = class {
|
|
|
130
132
|
try {
|
|
131
133
|
(_a = callbacks.get(lastCallbackKey)) == null ? void 0 : _a(...args);
|
|
132
134
|
} catch (error) {
|
|
133
|
-
console.error(
|
|
135
|
+
console.error(`执行事件"${watchKey}"的回调时出错:`, error);
|
|
134
136
|
}
|
|
135
137
|
}
|
|
136
138
|
}
|