@pisell/pisellos 2.1.41 → 2.2.2
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/core/index.d.ts +8 -1
- package/dist/core/index.js +116 -42
- package/dist/modules/Customer/index.js +1 -1
- package/dist/modules/Order/index.js +4 -4
- package/dist/modules/Order/types.d.ts +0 -1
- package/dist/modules/Product/types.d.ts +19 -0
- package/dist/modules/ProductList/index.js +3 -11
- package/dist/modules/Schedule/types.d.ts +2 -0
- package/dist/plugins/request.d.ts +19 -1
- package/dist/plugins/request.js +11 -0
- package/dist/server/index.d.ts +152 -0
- package/dist/server/index.js +946 -0
- package/dist/server/modules/index.d.ts +16 -0
- package/dist/server/modules/index.js +21 -0
- package/dist/server/modules/menu/index.d.ts +63 -0
- package/dist/server/modules/menu/index.js +476 -0
- package/dist/server/modules/menu/types.d.ts +68 -0
- package/dist/server/modules/menu/types.js +16 -0
- package/dist/server/modules/products/index.d.ts +141 -0
- package/dist/server/modules/products/index.js +774 -0
- package/dist/server/modules/products/types.d.ts +94 -0
- package/dist/server/modules/products/types.js +43 -0
- package/dist/server/modules/quotation/index.d.ts +47 -0
- package/dist/server/modules/quotation/index.js +367 -0
- package/dist/server/modules/quotation/types.d.ts +50 -0
- package/dist/server/modules/quotation/types.js +20 -0
- package/dist/server/modules/schedule/index.d.ts +62 -0
- package/dist/server/modules/schedule/index.js +431 -0
- package/dist/server/modules/schedule/types.d.ts +1 -0
- package/dist/server/modules/schedule/types.js +2 -0
- package/dist/server/modules/schedule/utils.d.ts +32 -0
- package/dist/server/modules/schedule/utils.js +747 -0
- package/dist/server/types.d.ts +64 -0
- package/dist/server/types.js +1 -0
- package/dist/server/utils/index.d.ts +5 -0
- package/dist/server/utils/index.js +6 -0
- package/dist/server/utils/product.d.ts +18 -0
- package/dist/server/utils/product.js +339 -0
- package/dist/server/utils/schedule.d.ts +14 -0
- package/dist/server/utils/schedule.js +108 -0
- package/dist/server/utils/time.d.ts +18 -0
- package/dist/server/utils/time.js +53 -0
- package/dist/solution/BookingByStep/index.d.ts +2 -22
- package/dist/solution/BookingByStep/index.js +29 -502
- package/dist/solution/BookingByStep/utils/capacity.d.ts +2 -7
- package/dist/solution/BookingByStep/utils/capacity.js +8 -24
- package/dist/solution/BookingTicket/index.d.ts +8 -0
- package/dist/solution/BookingTicket/index.js +105 -71
- package/dist/solution/ShopDiscount/index.js +9 -27
- package/dist/solution/index.d.ts +0 -1
- package/dist/solution/index.js +0 -1
- package/dist/types/index.d.ts +26 -0
- package/lib/core/index.d.ts +8 -1
- package/lib/core/index.js +48 -1
- package/lib/modules/Customer/index.js +1 -1
- package/lib/modules/Order/index.js +2 -5
- package/lib/modules/Order/types.d.ts +0 -1
- package/lib/modules/Product/types.d.ts +19 -0
- package/lib/modules/ProductList/index.js +2 -10
- package/lib/modules/Schedule/types.d.ts +2 -0
- package/lib/plugins/request.d.ts +19 -1
- package/lib/plugins/request.js +11 -1
- package/lib/server/index.d.ts +152 -0
- package/lib/server/index.js +555 -0
- package/lib/server/modules/index.d.ts +16 -0
- package/lib/server/modules/index.js +47 -0
- package/lib/server/modules/menu/index.d.ts +63 -0
- package/lib/server/modules/menu/index.js +234 -0
- package/lib/server/modules/menu/types.d.ts +68 -0
- package/lib/server/modules/menu/types.js +33 -0
- package/lib/server/modules/products/index.d.ts +141 -0
- package/lib/server/modules/products/index.js +442 -0
- package/lib/server/modules/products/types.d.ts +94 -0
- package/lib/server/modules/products/types.js +35 -0
- package/lib/server/modules/quotation/index.d.ts +47 -0
- package/lib/server/modules/quotation/index.js +177 -0
- package/lib/server/modules/quotation/types.d.ts +50 -0
- package/lib/server/modules/quotation/types.js +33 -0
- package/lib/server/modules/schedule/index.d.ts +62 -0
- package/lib/server/modules/schedule/index.js +231 -0
- package/lib/server/modules/schedule/types.d.ts +1 -0
- package/lib/server/modules/schedule/types.js +23 -0
- package/lib/server/modules/schedule/utils.d.ts +32 -0
- package/lib/server/modules/schedule/utils.js +451 -0
- package/lib/server/types.d.ts +64 -0
- package/lib/server/types.js +17 -0
- package/lib/server/utils/index.d.ts +5 -0
- package/lib/server/utils/index.js +25 -0
- package/lib/server/utils/product.d.ts +18 -0
- package/lib/server/utils/product.js +262 -0
- package/lib/server/utils/schedule.d.ts +14 -0
- package/lib/server/utils/schedule.js +88 -0
- package/lib/server/utils/time.d.ts +18 -0
- package/lib/server/utils/time.js +70 -0
- package/lib/solution/BookingByStep/index.d.ts +2 -22
- package/lib/solution/BookingByStep/index.js +42 -321
- package/lib/solution/BookingByStep/utils/capacity.d.ts +2 -7
- package/lib/solution/BookingByStep/utils/capacity.js +8 -21
- package/lib/solution/BookingTicket/index.d.ts +8 -0
- package/lib/solution/BookingTicket/index.js +13 -0
- package/lib/solution/ShopDiscount/index.js +0 -9
- package/lib/solution/index.d.ts +0 -1
- package/lib/solution/index.js +0 -2
- package/lib/types/index.d.ts +26 -0
- package/package.json +2 -2
- package/dist/solution/RegisterAndLogin/config.d.ts +0 -87
- package/dist/solution/RegisterAndLogin/config.js +0 -792
- package/dist/solution/RegisterAndLogin/index.d.ts +0 -189
- package/dist/solution/RegisterAndLogin/index.js +0 -2667
- package/dist/solution/RegisterAndLogin/types.d.ts +0 -444
- package/dist/solution/RegisterAndLogin/types.js +0 -231
- package/dist/solution/RegisterAndLogin/utils.d.ts +0 -95
- package/dist/solution/RegisterAndLogin/utils.js +0 -322
- package/lib/solution/RegisterAndLogin/config.d.ts +0 -87
- package/lib/solution/RegisterAndLogin/config.js +0 -594
- package/lib/solution/RegisterAndLogin/index.d.ts +0 -189
- package/lib/solution/RegisterAndLogin/index.js +0 -1593
- package/lib/solution/RegisterAndLogin/types.d.ts +0 -444
- package/lib/solution/RegisterAndLogin/types.js +0 -78
- package/lib/solution/RegisterAndLogin/utils.d.ts +0 -95
- package/lib/solution/RegisterAndLogin/utils.js +0 -279
|
@@ -68,12 +68,12 @@ var formatDefaultCapacitys = ({
|
|
|
68
68
|
}
|
|
69
69
|
return [{ id: 0, value: 1, name: "" }];
|
|
70
70
|
};
|
|
71
|
-
var getSumCapacity = ({ capacity
|
|
71
|
+
var getSumCapacity = ({ capacity }) => {
|
|
72
72
|
let sum = 0;
|
|
73
73
|
for (let item of capacity || []) {
|
|
74
74
|
sum += item.value;
|
|
75
75
|
}
|
|
76
|
-
return sum
|
|
76
|
+
return sum;
|
|
77
77
|
};
|
|
78
78
|
function getCapacityInfoByCartItem(targetCartItem) {
|
|
79
79
|
var _a;
|
|
@@ -81,7 +81,7 @@ function getCapacityInfoByCartItem(targetCartItem) {
|
|
|
81
81
|
capacity: (_a = targetCartItem._productOrigin) == null ? void 0 : _a.capacity,
|
|
82
82
|
product_bundle: targetCartItem._origin.product.product_bundle
|
|
83
83
|
});
|
|
84
|
-
const currentCapacity = getSumCapacity({ capacity: formatCapacity
|
|
84
|
+
const currentCapacity = getSumCapacity({ capacity: formatCapacity });
|
|
85
85
|
return {
|
|
86
86
|
formatCapacity,
|
|
87
87
|
currentCapacity
|
|
@@ -194,7 +194,7 @@ function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, allResourc
|
|
|
194
194
|
);
|
|
195
195
|
if (needsThisResourceType) {
|
|
196
196
|
if (selectType === "single") {
|
|
197
|
-
requiredCapacityByType[formId] = (requiredCapacityByType[formId] || 0) +
|
|
197
|
+
requiredCapacityByType[formId] = (requiredCapacityByType[formId] || 0) + 1;
|
|
198
198
|
} else {
|
|
199
199
|
requiredCapacityByType[formId] = (requiredCapacityByType[formId] || 0) + currentCapacity;
|
|
200
200
|
}
|
|
@@ -238,18 +238,13 @@ function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, allResourc
|
|
|
238
238
|
console.log(`capacity.ts - 资源类型 ${formId} 多个预约检查: 总容量 ${totalAvailableCapacity}, 需求 ${requiredCapacity}`);
|
|
239
239
|
if (totalAvailableCapacity < requiredCapacity) {
|
|
240
240
|
console.log(`资源类型 ${formId} 容量不足: 需要 ${requiredCapacity}, 可用 ${totalAvailableCapacity}`);
|
|
241
|
-
return
|
|
242
|
-
success: false,
|
|
243
|
-
required: requiredCapacity,
|
|
244
|
-
available: totalAvailableCapacity
|
|
245
|
-
};
|
|
241
|
+
return false;
|
|
246
242
|
}
|
|
247
243
|
} else {
|
|
248
244
|
let availableResourceCount = 0;
|
|
249
245
|
resourcesInType.forEach((resource) => {
|
|
250
246
|
const availableTimes = resource.times.filter((time) => {
|
|
251
|
-
|
|
252
|
-
return !(0, import_dayjs.default)(time.start_at).isAfter((0, import_dayjs.default)(timeSlotStart), "minute") && !(0, import_dayjs.default)(time.end_at).isBefore((0, import_dayjs.default)(timeSlotEnd), "minute") || (0, import_dayjs.default)(time.start_at).isBefore((0, import_dayjs.default)(timeSlotEnd), "minute") && (0, import_dayjs.default)(time.end_at).isAfter((0, import_dayjs.default)(timeSlotStart), "minute") && ((_a2 = time.event_list) == null ? void 0 : _a2.length) === 0;
|
|
247
|
+
return !(0, import_dayjs.default)(time.start_at).isAfter((0, import_dayjs.default)(timeSlotStart), "minute") && !(0, import_dayjs.default)(time.end_at).isBefore((0, import_dayjs.default)(timeSlotEnd), "minute") || (0, import_dayjs.default)(time.start_at).isBefore((0, import_dayjs.default)(timeSlotEnd), "minute") && (0, import_dayjs.default)(time.end_at).isAfter((0, import_dayjs.default)(timeSlotStart), "minute");
|
|
253
248
|
});
|
|
254
249
|
if (availableTimes.length > 0) {
|
|
255
250
|
availableResourceCount++;
|
|
@@ -258,19 +253,11 @@ function checkTimeSlotCapacity(timeSlotStart, timeSlotEnd, cartItems, allResourc
|
|
|
258
253
|
console.log(`capacity.ts - 资源类型 ${formId} 单个预约检查: 可用资源数 ${availableResourceCount}, 需求 ${requiredCapacity}`);
|
|
259
254
|
if (availableResourceCount < requiredCapacity) {
|
|
260
255
|
console.log(`资源类型 ${formId} 数量不足: 需要 ${requiredCapacity}, 可用 ${availableResourceCount}`);
|
|
261
|
-
return
|
|
262
|
-
success: false,
|
|
263
|
-
required: requiredCapacity,
|
|
264
|
-
available: availableResourceCount
|
|
265
|
-
};
|
|
256
|
+
return false;
|
|
266
257
|
}
|
|
267
258
|
}
|
|
268
259
|
}
|
|
269
|
-
return
|
|
270
|
-
success: true,
|
|
271
|
-
required: 0,
|
|
272
|
-
available: 0
|
|
273
|
-
};
|
|
260
|
+
return true;
|
|
274
261
|
}
|
|
275
262
|
// Annotate the CommonJS export names for ESM import in node:
|
|
276
263
|
0 && (module.exports = {
|
|
@@ -31,6 +31,14 @@ export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
|
31
31
|
* @returns 商品列表
|
|
32
32
|
*/
|
|
33
33
|
getProducts(): Promise<ProductData[]>;
|
|
34
|
+
/**
|
|
35
|
+
* 获取日程时间段点
|
|
36
|
+
* @param params 参数
|
|
37
|
+
* @returns 日程时间段点
|
|
38
|
+
*/
|
|
39
|
+
getScheduleTimePoints(params: {
|
|
40
|
+
menu_list_ids: number[];
|
|
41
|
+
}): Promise<any>;
|
|
34
42
|
/**
|
|
35
43
|
* 获取客户列表
|
|
36
44
|
* @param params 查询参数
|
|
@@ -135,6 +135,19 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
|
135
135
|
async getProducts() {
|
|
136
136
|
return this.store.products.getProducts();
|
|
137
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* 获取日程时间段点
|
|
140
|
+
* @param params 参数
|
|
141
|
+
* @returns 日程时间段点
|
|
142
|
+
*/
|
|
143
|
+
async getScheduleTimePoints(params) {
|
|
144
|
+
const result = await this.request.post("/menu/schedule-time-points", {
|
|
145
|
+
menu_list_ids: params.menu_list_ids
|
|
146
|
+
}, {
|
|
147
|
+
osServer: true
|
|
148
|
+
});
|
|
149
|
+
return result.data || [];
|
|
150
|
+
}
|
|
138
151
|
/**
|
|
139
152
|
* 获取客户列表
|
|
140
153
|
* @param params 查询参数
|
|
@@ -233,15 +233,6 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
233
233
|
isScan: true
|
|
234
234
|
};
|
|
235
235
|
});
|
|
236
|
-
const currentSelectedDiscountList = this.getDiscountList().filter((n) => n.isSelected);
|
|
237
|
-
if (currentSelectedDiscountList.length && currentSelectedDiscountList.some((n) => withScanList.some((m) => m.id === n.id))) {
|
|
238
|
-
return {
|
|
239
|
-
type: "clientCalc",
|
|
240
|
-
isAvailable: true,
|
|
241
|
-
productList: this.store.productList || [],
|
|
242
|
-
discountList: this.getDiscountList()
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
236
|
const {
|
|
246
237
|
productList: newProductList,
|
|
247
238
|
discountList: newDiscountList,
|
package/lib/solution/index.d.ts
CHANGED
package/lib/solution/index.js
CHANGED
|
@@ -20,7 +20,6 @@ __reExport(solution_exports, require("./BuyTickets"), module.exports);
|
|
|
20
20
|
__reExport(solution_exports, require("./BookingByStep"), module.exports);
|
|
21
21
|
__reExport(solution_exports, require("./BookingTicket"), module.exports);
|
|
22
22
|
__reExport(solution_exports, require("./ShopDiscount"), module.exports);
|
|
23
|
-
__reExport(solution_exports, require("./RegisterAndLogin"), module.exports);
|
|
24
23
|
__reExport(solution_exports, require("./Checkout"), module.exports);
|
|
25
24
|
// Annotate the CommonJS export names for ESM import in node:
|
|
26
25
|
0 && (module.exports = {
|
|
@@ -28,6 +27,5 @@ __reExport(solution_exports, require("./Checkout"), module.exports);
|
|
|
28
27
|
...require("./BookingByStep"),
|
|
29
28
|
...require("./BookingTicket"),
|
|
30
29
|
...require("./ShopDiscount"),
|
|
31
|
-
...require("./RegisterAndLogin"),
|
|
32
30
|
...require("./Checkout")
|
|
33
31
|
});
|
package/lib/types/index.d.ts
CHANGED
|
@@ -75,6 +75,26 @@ export interface ModuleContextConfig {
|
|
|
75
75
|
name: string;
|
|
76
76
|
validations: ContextValidationRule[];
|
|
77
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Server 模块配置
|
|
80
|
+
*/
|
|
81
|
+
export interface ServerModuleConfig {
|
|
82
|
+
/** 模块名称 */
|
|
83
|
+
name: string;
|
|
84
|
+
/** 是否自动预加载数据 */
|
|
85
|
+
preload?: boolean;
|
|
86
|
+
/** 模块配置参数 */
|
|
87
|
+
config?: Record<string, any>;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Server 配置选项
|
|
91
|
+
*/
|
|
92
|
+
export interface ServerOptions {
|
|
93
|
+
/** 要启用的模块列表 */
|
|
94
|
+
modules?: string[] | ServerModuleConfig[];
|
|
95
|
+
/** 是否自动初始化数据 */
|
|
96
|
+
autoInitData?: boolean;
|
|
97
|
+
}
|
|
78
98
|
export interface PisellOSOptions {
|
|
79
99
|
debug?: boolean;
|
|
80
100
|
plugins?: Array<{
|
|
@@ -86,4 +106,10 @@ export interface PisellOSOptions {
|
|
|
86
106
|
options?: ModuleOptions;
|
|
87
107
|
}>;
|
|
88
108
|
context?: BusinessContext;
|
|
109
|
+
/** Server 配置 */
|
|
110
|
+
server?: ServerOptions;
|
|
111
|
+
}
|
|
112
|
+
export interface InitializeServerOptions {
|
|
113
|
+
onModuleLoad?: (module: string) => void;
|
|
114
|
+
onModuleLoadComplete?: (module: string) => void;
|
|
89
115
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": false,
|
|
3
3
|
"name": "@pisell/pisellos",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.2.2",
|
|
5
5
|
"description": "一个可扩展的前端模块化SDK框架,支持插件系统",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -69,4 +69,4 @@
|
|
|
69
69
|
"publishConfig": {
|
|
70
70
|
"access": "public"
|
|
71
71
|
}
|
|
72
|
-
}
|
|
72
|
+
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 注册登录解决方案配置
|
|
3
|
-
* 根据不同渠道配置不同的接口地址和参数
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* API 配置接口
|
|
7
|
-
*/
|
|
8
|
-
export interface ApiConfig {
|
|
9
|
-
url: string;
|
|
10
|
-
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
11
|
-
transformParams?: (params: any) => any;
|
|
12
|
-
transformResponse?: (response: any) => any;
|
|
13
|
-
options?: Record<string, any>;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* 渠道配置接口
|
|
17
|
-
*/
|
|
18
|
-
export interface ChannelConfig {
|
|
19
|
-
sendEmailVerificationCode: ApiConfig;
|
|
20
|
-
sendEmailLoginCode: ApiConfig;
|
|
21
|
-
sendSmsRegisterCode: ApiConfig;
|
|
22
|
-
sendEmailRegisterLink: ApiConfig;
|
|
23
|
-
verifyEmailRegistrationLink: ApiConfig;
|
|
24
|
-
emailPasswordLogin: ApiConfig;
|
|
25
|
-
emailCodeRegister: ApiConfig;
|
|
26
|
-
phoneCodeRegister: ApiConfig;
|
|
27
|
-
resendEmailRegisterLink: ApiConfig;
|
|
28
|
-
checkEmailLinkCode: ApiConfig;
|
|
29
|
-
sendSmsLoginCode: ApiConfig;
|
|
30
|
-
phoneCodeLogin: ApiConfig;
|
|
31
|
-
guestLogin: ApiConfig;
|
|
32
|
-
checkEmailExists: ApiConfig;
|
|
33
|
-
checkEmailCode: ApiConfig;
|
|
34
|
-
checkMobileCode: ApiConfig;
|
|
35
|
-
phonePasswordLogin: ApiConfig;
|
|
36
|
-
sendPasswordResetEmail: ApiConfig;
|
|
37
|
-
sendPasswordResetSms: ApiConfig;
|
|
38
|
-
sendResetPasswordLink: ApiConfig;
|
|
39
|
-
checkResetPasswordCode: ApiConfig;
|
|
40
|
-
resetPasswordByCode: ApiConfig;
|
|
41
|
-
resetPasswordByEmail: ApiConfig;
|
|
42
|
-
resetPasswordByPhone: ApiConfig;
|
|
43
|
-
verifyCode: ApiConfig;
|
|
44
|
-
register: ApiConfig;
|
|
45
|
-
login: ApiConfig;
|
|
46
|
-
oauthLogin: ApiConfig;
|
|
47
|
-
validateToken: ApiConfig;
|
|
48
|
-
logout: ApiConfig;
|
|
49
|
-
getCountries: ApiConfig;
|
|
50
|
-
facebookLogin: ApiConfig;
|
|
51
|
-
appleLogin: ApiConfig;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* 渠道配置映射
|
|
55
|
-
*/
|
|
56
|
-
export declare const channelConfigMap: Record<string, ChannelConfig>;
|
|
57
|
-
/**
|
|
58
|
-
* 获取渠道配置
|
|
59
|
-
*/
|
|
60
|
-
export declare function getChannelConfig(channel: string): ChannelConfig;
|
|
61
|
-
/**
|
|
62
|
-
* API 调用器类
|
|
63
|
-
* 负责根据配置执行 API 调用
|
|
64
|
-
*/
|
|
65
|
-
export declare class ApiCaller {
|
|
66
|
-
private request;
|
|
67
|
-
private config;
|
|
68
|
-
constructor(request: {
|
|
69
|
-
get: <T = any>(url: string, data?: any, options?: any) => Promise<T>;
|
|
70
|
-
post: <T = any>(url: string, data?: any, options?: any) => Promise<T>;
|
|
71
|
-
put: <T = any>(url: string, data?: any, options?: any) => Promise<T>;
|
|
72
|
-
delete: <T = any>(url: string, options?: any) => Promise<T>;
|
|
73
|
-
}, config: ChannelConfig);
|
|
74
|
-
/**
|
|
75
|
-
* 执行 API 调用
|
|
76
|
-
*/
|
|
77
|
-
call<T = any>(apiName: keyof ChannelConfig, params?: any, additionalOptions?: any): Promise<T>;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* 创建 API 调用器
|
|
81
|
-
*/
|
|
82
|
-
export declare function createApiCaller(request: {
|
|
83
|
-
get: <T = any>(url: string, data?: any, options?: any) => Promise<T>;
|
|
84
|
-
post: <T = any>(url: string, data?: any, options?: any) => Promise<T>;
|
|
85
|
-
put: <T = any>(url: string, data?: any, options?: any) => Promise<T>;
|
|
86
|
-
delete: <T = any>(url: string, options?: any) => Promise<T>;
|
|
87
|
-
}, channel: string): ApiCaller;
|