@pisell/pisellos 0.0.213 → 0.0.215
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.js +2 -1
- package/dist/effects/index.d.ts +4 -3
- package/dist/effects/index.js +15 -6
- package/dist/modules/AccountList/index.d.ts +7 -1
- package/dist/modules/AccountList/index.js +81 -14
- package/dist/modules/AccountList/types.d.ts +28 -0
- package/dist/modules/AccountList/types.js +8 -0
- package/dist/modules/Customer/constants.d.ts +7 -0
- package/dist/modules/Customer/constants.js +12 -0
- package/dist/modules/Customer/index.d.ts +89 -0
- package/dist/modules/Customer/index.js +439 -0
- package/dist/modules/Customer/types.d.ts +130 -0
- package/dist/modules/Customer/types.js +39 -0
- package/dist/modules/ProductList/index.d.ts +6 -1
- package/dist/modules/ProductList/index.js +8 -4
- package/dist/modules/Rules/index.js +7 -5
- package/dist/modules/Rules/types.d.ts +1 -0
- package/dist/modules/Schedule/utils.js +7 -1
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +1 -0
- package/dist/plugins/window.d.ts +1 -0
- package/dist/solution/BookingByStep/index.js +8 -15
- package/dist/solution/BookingTicket/index.d.ts +127 -0
- package/dist/solution/BookingTicket/index.js +494 -0
- package/dist/solution/BookingTicket/types.d.ts +66 -0
- package/dist/solution/BookingTicket/types.js +41 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +22 -0
- package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +147 -0
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +19 -0
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +138 -0
- package/dist/solution/BookingTicket/utils/scan/index.d.ts +51 -0
- package/dist/solution/BookingTicket/utils/scan/index.js +189 -0
- package/dist/solution/ShopDiscount/index.js +4 -2
- package/dist/solution/index.d.ts +1 -0
- package/dist/solution/index.js +1 -0
- package/dist/types/index.d.ts +3 -1
- package/dist/utils/task.d.ts +31 -0
- package/dist/utils/task.js +150 -0
- package/dist/utils/watch.d.ts +102 -0
- package/dist/utils/watch.js +294 -0
- package/lib/core/index.js +1 -1
- package/lib/effects/index.d.ts +4 -3
- package/lib/effects/index.js +4 -1
- package/lib/modules/AccountList/index.d.ts +7 -1
- package/lib/modules/AccountList/index.js +27 -0
- package/lib/modules/AccountList/types.d.ts +28 -0
- package/lib/modules/Customer/constants.d.ts +7 -0
- package/lib/modules/Customer/constants.js +39 -0
- package/lib/modules/Customer/index.d.ts +89 -0
- package/lib/modules/Customer/index.js +304 -0
- package/lib/modules/Customer/types.d.ts +130 -0
- package/lib/modules/Customer/types.js +35 -0
- package/lib/modules/ProductList/index.d.ts +6 -1
- package/lib/modules/ProductList/index.js +12 -3
- package/lib/modules/Rules/index.js +4 -3
- package/lib/modules/Rules/types.d.ts +1 -0
- package/lib/modules/Schedule/utils.js +8 -3
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +2 -0
- package/lib/plugins/window.d.ts +1 -0
- package/lib/solution/BookingByStep/index.js +0 -7
- package/lib/solution/BookingTicket/index.d.ts +127 -0
- package/lib/solution/BookingTicket/index.js +291 -0
- package/lib/solution/BookingTicket/types.d.ts +66 -0
- package/lib/solution/BookingTicket/types.js +70 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +22 -0
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +97 -0
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +19 -0
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +95 -0
- package/lib/solution/BookingTicket/utils/scan/index.d.ts +51 -0
- package/lib/solution/BookingTicket/utils/scan/index.js +153 -0
- package/lib/solution/ShopDiscount/index.js +2 -1
- package/lib/solution/index.d.ts +1 -0
- package/lib/solution/index.js +2 -0
- package/lib/types/index.d.ts +3 -1
- package/lib/utils/task.d.ts +31 -0
- package/lib/utils/task.js +84 -0
- package/lib/utils/watch.d.ts +102 -0
- package/lib/utils/watch.js +217 -0
- package/package.json +1 -1
|
@@ -68,14 +68,19 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
68
68
|
category_ids = [],
|
|
69
69
|
product_ids = [],
|
|
70
70
|
collection = [],
|
|
71
|
+
menu_list_ids = [],
|
|
72
|
+
customer_id: paramsCustomerId,
|
|
73
|
+
with_count = [],
|
|
74
|
+
schedule_datetime,
|
|
71
75
|
schedule_date,
|
|
72
|
-
cacheId
|
|
76
|
+
cacheId,
|
|
77
|
+
with_schedule
|
|
73
78
|
}) {
|
|
74
79
|
var _a;
|
|
75
80
|
let userPlugin = this.core.getPlugin("user");
|
|
76
81
|
let customer_id = void 0;
|
|
77
82
|
try {
|
|
78
|
-
customer_id = (_a = userPlugin == null ? void 0 : userPlugin.get()) == null ? void 0 : _a.id;
|
|
83
|
+
customer_id = paramsCustomerId || ((_a = userPlugin == null ? void 0 : userPlugin.get()) == null ? void 0 : _a.id);
|
|
79
84
|
} catch (error) {
|
|
80
85
|
console.error(error);
|
|
81
86
|
}
|
|
@@ -101,8 +106,12 @@ var ProductList = class extends import_BaseModule.BaseModule {
|
|
|
101
106
|
ids: product_ids,
|
|
102
107
|
collection,
|
|
103
108
|
front_end_cache_id: cacheId,
|
|
109
|
+
menu_list_ids,
|
|
110
|
+
with_count,
|
|
104
111
|
// client_schedule_ids: schedule_ids,
|
|
105
|
-
schedule_date
|
|
112
|
+
schedule_date,
|
|
113
|
+
with_schedule,
|
|
114
|
+
schedule_datetime
|
|
106
115
|
},
|
|
107
116
|
{ useCache: true }
|
|
108
117
|
);
|
|
@@ -37,6 +37,7 @@ var import_types = require("./types");
|
|
|
37
37
|
var import_utils = require("../../solution/ShopDiscount/utils");
|
|
38
38
|
var import_utils2 = require("../Cart/utils");
|
|
39
39
|
var import_decimal = __toESM(require("decimal.js"));
|
|
40
|
+
var import_lodash_es = require("lodash-es");
|
|
40
41
|
var RulesModule = class extends import_BaseModule.BaseModule {
|
|
41
42
|
constructor(name, version) {
|
|
42
43
|
super(name, version);
|
|
@@ -215,9 +216,9 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
215
216
|
}
|
|
216
217
|
const applicableDiscounts = sortedDiscountList.filter((discount) => {
|
|
217
218
|
var _a2;
|
|
218
|
-
if ((Number(product.price)
|
|
219
|
+
if ((Number(product.price) <= 0 || !product.price) && (discount.tag || discount.type) === "good_pass")
|
|
219
220
|
return false;
|
|
220
|
-
if ((Number(product.total)
|
|
221
|
+
if ((Number(product.total) <= 0 || !product.total) && !((_a2 = product.discount_list) == null ? void 0 : _a2.find((n) => {
|
|
221
222
|
var _a3;
|
|
222
223
|
return ((_a3 = n.discount) == null ? void 0 : _a3.resource_id) === discount.id;
|
|
223
224
|
})) && (discount.tag || discount.type) !== "good_pass")
|
|
@@ -242,7 +243,7 @@ var RulesModule = class extends import_BaseModule.BaseModule {
|
|
|
242
243
|
}))) {
|
|
243
244
|
isManualDiscount = false;
|
|
244
245
|
}
|
|
245
|
-
if (applicableDiscounts.length === 0 || isManualDiscount) {
|
|
246
|
+
if (applicableDiscounts.length === 0 || isManualDiscount || (0, import_lodash_es.isBoolean)(product.vouchersApplicable) && !product.vouchersApplicable) {
|
|
246
247
|
if (product.isClient) {
|
|
247
248
|
processedProductsMap.set(
|
|
248
249
|
product._id,
|
|
@@ -139,7 +139,10 @@ var getDaysByRepeatWeek = (params, isGetRange) => {
|
|
|
139
139
|
while (startTmp.isBefore(deadline, "day") || startTmp.isSame(deadline, "day")) {
|
|
140
140
|
for (let i = 0; i < frequency_date.length; i++) {
|
|
141
141
|
const item = frequency_date[i];
|
|
142
|
-
|
|
142
|
+
let _start = startTmp.day(item);
|
|
143
|
+
if (_start.isBefore(startTmp, "day")) {
|
|
144
|
+
_start = _start.add(1, "week");
|
|
145
|
+
}
|
|
143
146
|
let _end = _start.add(scheduleDiff, "second");
|
|
144
147
|
if (_end.isAfter(deadline, "day")) {
|
|
145
148
|
_end = deadline;
|
|
@@ -160,7 +163,7 @@ var getDaysByRepeatWeek = (params, isGetRange) => {
|
|
|
160
163
|
daysArr.push(...getDaysByStartEnd(_start, _end));
|
|
161
164
|
}
|
|
162
165
|
}
|
|
163
|
-
startTmp = startTmp.
|
|
166
|
+
startTmp = startTmp.add(frequency, "week");
|
|
164
167
|
}
|
|
165
168
|
return Array.from(new Set(daysArr));
|
|
166
169
|
};
|
|
@@ -585,7 +588,9 @@ function getAllSortedDateRanges(schedules) {
|
|
|
585
588
|
return durationA - durationB;
|
|
586
589
|
});
|
|
587
590
|
const uniqueDateRanges = sortedDateRanges.filter(
|
|
588
|
-
(range, index, self) => index === self.findIndex(
|
|
591
|
+
(range, index, self) => index === self.findIndex(
|
|
592
|
+
(t) => (0, import_dayjs.default)(t.start).isSame((0, import_dayjs.default)(range.start)) && (0, import_dayjs.default)(t.end).isSame((0, import_dayjs.default)(range.end))
|
|
593
|
+
)
|
|
589
594
|
);
|
|
590
595
|
return uniqueDateRanges;
|
|
591
596
|
}
|
package/lib/modules/index.d.ts
CHANGED
package/lib/modules/index.js
CHANGED
|
@@ -21,6 +21,7 @@ __reExport(modules_exports, require("./ProductList"), module.exports);
|
|
|
21
21
|
__reExport(modules_exports, require("./Cart"), module.exports);
|
|
22
22
|
__reExport(modules_exports, require("./Account"), module.exports);
|
|
23
23
|
__reExport(modules_exports, require("./AccountList"), module.exports);
|
|
24
|
+
__reExport(modules_exports, require("./Customer"), module.exports);
|
|
24
25
|
__reExport(modules_exports, require("./Date"), module.exports);
|
|
25
26
|
__reExport(modules_exports, require("./Guests"), module.exports);
|
|
26
27
|
__reExport(modules_exports, require("./Order"), module.exports);
|
|
@@ -36,6 +37,7 @@ __reExport(modules_exports, require("./Schedule"), module.exports);
|
|
|
36
37
|
...require("./Cart"),
|
|
37
38
|
...require("./Account"),
|
|
38
39
|
...require("./AccountList"),
|
|
40
|
+
...require("./Customer"),
|
|
39
41
|
...require("./Date"),
|
|
40
42
|
...require("./Guests"),
|
|
41
43
|
...require("./Order"),
|
package/lib/plugins/window.d.ts
CHANGED
|
@@ -644,13 +644,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
644
644
|
this.store.cart.removeItem(n._id);
|
|
645
645
|
});
|
|
646
646
|
}
|
|
647
|
-
const dateRange = this.store.date.getDateRange();
|
|
648
|
-
if ((dateRange == null ? void 0 : dateRange[0]) && !(0, import_dayjs.default)(dateRange[0].date).isSame((0, import_dayjs.default)(date.startTime), "day")) {
|
|
649
|
-
this.setDateRange([
|
|
650
|
-
{ date: (0, import_dayjs.default)(date.startTime).format("YYYY-MM-DD"), status: "available", week: "", weekNum: 0 },
|
|
651
|
-
{ date: (0, import_dayjs.default)(date.endTime).format("YYYY-MM-DD"), status: "available", week: "", weekNum: 0 }
|
|
652
|
-
]);
|
|
653
|
-
}
|
|
654
647
|
}
|
|
655
648
|
}
|
|
656
649
|
beforeUpdateCart(params, targetCartItem) {
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { Module, PisellCore } from '../../types';
|
|
2
|
+
import { BaseModule } from '../../modules/BaseModule';
|
|
3
|
+
import { RequestPlugin, WindowPlugin } from '../../plugins';
|
|
4
|
+
import { IGetCustomerListParams, ICustomer, ILoadProductsParams, IScanResult } from './types';
|
|
5
|
+
import { ProductData } from '../../modules';
|
|
6
|
+
export declare class BookingTicketImpl extends BaseModule implements Module {
|
|
7
|
+
protected defaultName: string;
|
|
8
|
+
protected defaultVersion: string;
|
|
9
|
+
isSolution: boolean;
|
|
10
|
+
request: RequestPlugin;
|
|
11
|
+
window: WindowPlugin;
|
|
12
|
+
private shopStore;
|
|
13
|
+
private store;
|
|
14
|
+
private otherParams;
|
|
15
|
+
private cacheId;
|
|
16
|
+
private platform;
|
|
17
|
+
private scan;
|
|
18
|
+
initialize(core: PisellCore, options: any): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* 获取商品列表
|
|
21
|
+
* @param params 包含 schedule_date 的参数
|
|
22
|
+
* @returns 商品列表
|
|
23
|
+
*/
|
|
24
|
+
loadProducts(params?: ILoadProductsParams): Promise<any>;
|
|
25
|
+
/**
|
|
26
|
+
* 获取商品列表(不加载到模块中)
|
|
27
|
+
* @returns 商品列表
|
|
28
|
+
*/
|
|
29
|
+
getProducts(): Promise<ProductData[]>;
|
|
30
|
+
/**
|
|
31
|
+
* 获取客户列表
|
|
32
|
+
* @param params 查询参数
|
|
33
|
+
* @returns 客户列表响应
|
|
34
|
+
*/
|
|
35
|
+
getCustomerList(params?: IGetCustomerListParams): Promise<import("../../modules").ICustomerListResponse>;
|
|
36
|
+
/**
|
|
37
|
+
* 设置活跃客户
|
|
38
|
+
* @param customer 客户信息
|
|
39
|
+
*/
|
|
40
|
+
setActiveCustomer(customer: ICustomer): void;
|
|
41
|
+
/**
|
|
42
|
+
* 获取当前活跃客户
|
|
43
|
+
* @returns 当前活跃客户
|
|
44
|
+
*/
|
|
45
|
+
getActiveCustomer(): ICustomer | null;
|
|
46
|
+
/**
|
|
47
|
+
* 根据ID设置选中的客户
|
|
48
|
+
* @param customerId 客户ID
|
|
49
|
+
*/
|
|
50
|
+
setSelectedCustomerById(customerId: string | number): void;
|
|
51
|
+
/**
|
|
52
|
+
* 获取所有客户
|
|
53
|
+
* @returns 客户列表
|
|
54
|
+
*/
|
|
55
|
+
getCustomers(): ICustomer[];
|
|
56
|
+
/**
|
|
57
|
+
* 根据ID获取客户
|
|
58
|
+
* @param customerId 客户ID
|
|
59
|
+
* @returns 客户信息
|
|
60
|
+
*/
|
|
61
|
+
getCustomerById(customerId: string | number): ICustomer | null;
|
|
62
|
+
/**
|
|
63
|
+
* 清空客户列表
|
|
64
|
+
*/
|
|
65
|
+
clearCustomers(): void;
|
|
66
|
+
/**
|
|
67
|
+
* 添加客户到列表第一位
|
|
68
|
+
* @param customer 要添加的客户信息
|
|
69
|
+
*/
|
|
70
|
+
addCustomerToFirst(customer: ICustomer): void;
|
|
71
|
+
/**
|
|
72
|
+
* 获取客户分页信息
|
|
73
|
+
* @returns 分页信息
|
|
74
|
+
*/
|
|
75
|
+
getCustomerPaginationInfo(): import("../../modules").IPaginationInfo;
|
|
76
|
+
/**
|
|
77
|
+
* 获取客户列表总数
|
|
78
|
+
* @returns 总数
|
|
79
|
+
*/
|
|
80
|
+
getCustomerTotal(): number;
|
|
81
|
+
/**
|
|
82
|
+
* 设置客户分页信息
|
|
83
|
+
* @param page 页码
|
|
84
|
+
* @param pageSize 每页数量
|
|
85
|
+
*/
|
|
86
|
+
setCustomerPaginationInfo(page: number, pageSize: number): void;
|
|
87
|
+
/**
|
|
88
|
+
* 便捷方法:切换客户分页并自动获取数据
|
|
89
|
+
* @param page 页码
|
|
90
|
+
* @param pageSize 每页数量(可选)
|
|
91
|
+
* @returns 客户列表响应
|
|
92
|
+
*/
|
|
93
|
+
changeCustomerPage(page: number, pageSize?: number): Promise<import("../../modules").ICustomerListResponse>;
|
|
94
|
+
/**
|
|
95
|
+
* 全局扫描监听
|
|
96
|
+
* @param callback 回调
|
|
97
|
+
*/
|
|
98
|
+
scanGlobalListener(callback: (data: IScanResult) => void): {
|
|
99
|
+
remove: () => void;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* 客户扫描监听
|
|
103
|
+
* @param callback 回调
|
|
104
|
+
*/
|
|
105
|
+
scanCustomerListener(callback: (data: IScanResult) => void): {
|
|
106
|
+
remove: () => void;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* 设置其他参数
|
|
110
|
+
* @param params 参数
|
|
111
|
+
* @param options 选项
|
|
112
|
+
*/
|
|
113
|
+
setOtherParams(params: Record<string, any>, { cover }?: {
|
|
114
|
+
cover?: boolean;
|
|
115
|
+
}): Promise<void>;
|
|
116
|
+
/**
|
|
117
|
+
* 获取其他参数
|
|
118
|
+
* @returns 其他参数
|
|
119
|
+
*/
|
|
120
|
+
getOtherParams(): Promise<Record<string, any>>;
|
|
121
|
+
/**
|
|
122
|
+
* 销毁模块
|
|
123
|
+
*/
|
|
124
|
+
destroy(): void;
|
|
125
|
+
}
|
|
126
|
+
export * from './types';
|
|
127
|
+
export { BookingTicketImpl as BookingTicket };
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/solution/BookingTicket/index.ts
|
|
21
|
+
var BookingTicket_exports = {};
|
|
22
|
+
__export(BookingTicket_exports, {
|
|
23
|
+
BookingTicket: () => BookingTicketImpl,
|
|
24
|
+
BookingTicketImpl: () => BookingTicketImpl
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(BookingTicket_exports);
|
|
27
|
+
var import_BaseModule = require("../../modules/BaseModule");
|
|
28
|
+
var import_types = require("./types");
|
|
29
|
+
var import_scan = require("./utils/scan/index");
|
|
30
|
+
var import_handleScan = require("./utils/scan/handleScan");
|
|
31
|
+
__reExport(BookingTicket_exports, require("./types"), module.exports);
|
|
32
|
+
var BookingTicketImpl = class extends import_BaseModule.BaseModule {
|
|
33
|
+
constructor() {
|
|
34
|
+
super(...arguments);
|
|
35
|
+
this.defaultName = "bookingTicket";
|
|
36
|
+
this.defaultVersion = "1.0.0";
|
|
37
|
+
this.isSolution = true;
|
|
38
|
+
this.otherParams = {};
|
|
39
|
+
}
|
|
40
|
+
async initialize(core, options) {
|
|
41
|
+
var _a, _b, _c;
|
|
42
|
+
this.core = core;
|
|
43
|
+
this.store = options.store || {};
|
|
44
|
+
this.otherParams = options.otherParams || {};
|
|
45
|
+
console.log("[BookingTicket] 初始化完成");
|
|
46
|
+
this.request = core.getPlugin("request");
|
|
47
|
+
this.window = core.getPlugin("window");
|
|
48
|
+
this.shopStore = core.getPlugin("shopStore");
|
|
49
|
+
if (!this.request) {
|
|
50
|
+
throw new Error("bookingTicket解决方案需要 request 插件支持");
|
|
51
|
+
}
|
|
52
|
+
if (!this.shopStore) {
|
|
53
|
+
throw new Error("bookingTicket解决方案需要 shopStore 插件支持");
|
|
54
|
+
}
|
|
55
|
+
let targetCacheData = {};
|
|
56
|
+
this.cacheId = (_a = this.otherParams) == null ? void 0 : _a.cacheId;
|
|
57
|
+
this.platform = (_b = this.otherParams) == null ? void 0 : _b.platform;
|
|
58
|
+
this.scan = new import_scan.Scan(this, "BOOKING_TICKET_SCAN");
|
|
59
|
+
if ((_c = this.otherParams) == null ? void 0 : _c.cacheId) {
|
|
60
|
+
const sessionData = this.window.sessionStorage.getItem(this.name);
|
|
61
|
+
if (sessionData) {
|
|
62
|
+
const data = JSON.parse(sessionData);
|
|
63
|
+
targetCacheData = data[this.otherParams.cacheId];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const moduleArr = [
|
|
67
|
+
"cart",
|
|
68
|
+
"products",
|
|
69
|
+
"accountList",
|
|
70
|
+
"customer",
|
|
71
|
+
"order"
|
|
72
|
+
];
|
|
73
|
+
moduleArr.forEach((step) => {
|
|
74
|
+
var _a2, _b2;
|
|
75
|
+
const targetModule = (0, import_types.createModule)(step, this.name);
|
|
76
|
+
if (targetModule) {
|
|
77
|
+
this.store[step] = targetModule;
|
|
78
|
+
this.core.registerModule(targetModule, {
|
|
79
|
+
initialState: targetCacheData == null ? void 0 : targetCacheData[targetModule.name],
|
|
80
|
+
otherParams: {
|
|
81
|
+
...this.otherParams,
|
|
82
|
+
fatherModule: this.name,
|
|
83
|
+
openCache: ((_a2 = this.otherParams) == null ? void 0 : _a2.cacheId) ? true : false,
|
|
84
|
+
cacheId: (_b2 = this.otherParams) == null ? void 0 : _b2.cacheId
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
} else {
|
|
88
|
+
throw new Error(`模块 ${step} 不存在`);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
this.core.effects.emit(import_types.BookingTicketHooks.onInited, {});
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* 获取商品列表
|
|
95
|
+
* @param params 包含 schedule_date 的参数
|
|
96
|
+
* @returns 商品列表
|
|
97
|
+
*/
|
|
98
|
+
async loadProducts(params = {}) {
|
|
99
|
+
const { schedule_date, customer_id, menu_list_ids, schedule_datetime } = params;
|
|
100
|
+
try {
|
|
101
|
+
const result = await this.store.products.loadProducts({
|
|
102
|
+
with_count: ["bundleGroup", "optionGroup"],
|
|
103
|
+
with_schedule: 1,
|
|
104
|
+
...params,
|
|
105
|
+
cacheId: this.cacheId
|
|
106
|
+
});
|
|
107
|
+
this.core.effects.emit(import_types.BookingTicketHooks.onProductsLoaded, result);
|
|
108
|
+
return result;
|
|
109
|
+
} catch (error) {
|
|
110
|
+
console.error("Failed to load products:", error);
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* 获取商品列表(不加载到模块中)
|
|
116
|
+
* @returns 商品列表
|
|
117
|
+
*/
|
|
118
|
+
async getProducts() {
|
|
119
|
+
return this.store.products.getProducts();
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* 获取客户列表
|
|
123
|
+
* @param params 查询参数
|
|
124
|
+
* @returns 客户列表响应
|
|
125
|
+
*/
|
|
126
|
+
async getCustomerList(params = {}) {
|
|
127
|
+
try {
|
|
128
|
+
const result = await this.store.customer.getCustomerList(params);
|
|
129
|
+
return result;
|
|
130
|
+
} catch (error) {
|
|
131
|
+
console.error("Failed to get customer list:", error);
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* 设置活跃客户
|
|
137
|
+
* @param customer 客户信息
|
|
138
|
+
*/
|
|
139
|
+
setActiveCustomer(customer) {
|
|
140
|
+
this.store.customer.setSelectedCustomer(customer);
|
|
141
|
+
this.core.effects.emit(import_types.BookingTicketHooks.onCustomerSelected, {
|
|
142
|
+
customer
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* 获取当前活跃客户
|
|
147
|
+
* @returns 当前活跃客户
|
|
148
|
+
*/
|
|
149
|
+
getActiveCustomer() {
|
|
150
|
+
return this.store.customer.getSelectedCustomer();
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* 根据ID设置选中的客户
|
|
154
|
+
* @param customerId 客户ID
|
|
155
|
+
*/
|
|
156
|
+
setSelectedCustomerById(customerId) {
|
|
157
|
+
const customer = this.store.customer.getCustomerById(customerId);
|
|
158
|
+
if (customer) {
|
|
159
|
+
this.store.customer.setSelectedCustomer(customer);
|
|
160
|
+
this.core.effects.emit(import_types.BookingTicketHooks.onCustomerSelected, {
|
|
161
|
+
customer
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* 获取所有客户
|
|
167
|
+
* @returns 客户列表
|
|
168
|
+
*/
|
|
169
|
+
getCustomers() {
|
|
170
|
+
return this.store.customer.getCustomers();
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* 根据ID获取客户
|
|
174
|
+
* @param customerId 客户ID
|
|
175
|
+
* @returns 客户信息
|
|
176
|
+
*/
|
|
177
|
+
getCustomerById(customerId) {
|
|
178
|
+
return this.store.customer.getCustomerById(customerId);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* 清空客户列表
|
|
182
|
+
*/
|
|
183
|
+
clearCustomers() {
|
|
184
|
+
this.store.customer.clearCustomers();
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* 添加客户到列表第一位
|
|
188
|
+
* @param customer 要添加的客户信息
|
|
189
|
+
*/
|
|
190
|
+
addCustomerToFirst(customer) {
|
|
191
|
+
this.store.customer.addCustomerToFirst(customer);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* 获取客户分页信息
|
|
195
|
+
* @returns 分页信息
|
|
196
|
+
*/
|
|
197
|
+
getCustomerPaginationInfo() {
|
|
198
|
+
return this.store.customer.getPaginationInfo();
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* 获取客户列表总数
|
|
202
|
+
* @returns 总数
|
|
203
|
+
*/
|
|
204
|
+
getCustomerTotal() {
|
|
205
|
+
return this.store.customer.getState().total;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* 设置客户分页信息
|
|
209
|
+
* @param page 页码
|
|
210
|
+
* @param pageSize 每页数量
|
|
211
|
+
*/
|
|
212
|
+
setCustomerPaginationInfo(page, pageSize) {
|
|
213
|
+
this.store.customer.setPaginationInfo(page, pageSize);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* 便捷方法:切换客户分页并自动获取数据
|
|
217
|
+
* @param page 页码
|
|
218
|
+
* @param pageSize 每页数量(可选)
|
|
219
|
+
* @returns 客户列表响应
|
|
220
|
+
*/
|
|
221
|
+
async changeCustomerPage(page, pageSize) {
|
|
222
|
+
try {
|
|
223
|
+
const result = await this.store.customer.changeCustomerPage(
|
|
224
|
+
page,
|
|
225
|
+
pageSize
|
|
226
|
+
);
|
|
227
|
+
return result;
|
|
228
|
+
} catch (error) {
|
|
229
|
+
console.error("Failed to change customer page:", error);
|
|
230
|
+
throw error;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* 全局扫描监听
|
|
235
|
+
* @param callback 回调
|
|
236
|
+
*/
|
|
237
|
+
scanGlobalListener(callback) {
|
|
238
|
+
const listenerCallback = (0, import_handleScan.handleGlobalScan)(this.request);
|
|
239
|
+
const listener = { key: "global", callback };
|
|
240
|
+
const removeListener = this.scan.addListener(listener, listenerCallback);
|
|
241
|
+
return removeListener;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* 客户扫描监听
|
|
245
|
+
* @param callback 回调
|
|
246
|
+
*/
|
|
247
|
+
scanCustomerListener(callback) {
|
|
248
|
+
const listenerCallback = (0, import_handleScan.handleCustomerScan)(this.request);
|
|
249
|
+
const listener = { key: "customer", callback };
|
|
250
|
+
const removeListener = this.scan.addListener(listener, listenerCallback);
|
|
251
|
+
return removeListener;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* 设置其他参数
|
|
255
|
+
* @param params 参数
|
|
256
|
+
* @param options 选项
|
|
257
|
+
*/
|
|
258
|
+
async setOtherParams(params, { cover = false } = {}) {
|
|
259
|
+
if (cover) {
|
|
260
|
+
this.otherParams = params;
|
|
261
|
+
} else {
|
|
262
|
+
this.otherParams = { ...this.otherParams, ...params };
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* 获取其他参数
|
|
267
|
+
* @returns 其他参数
|
|
268
|
+
*/
|
|
269
|
+
async getOtherParams() {
|
|
270
|
+
return this.otherParams;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* 销毁模块
|
|
274
|
+
*/
|
|
275
|
+
destroy() {
|
|
276
|
+
var _a, _b, _c, _d, _e;
|
|
277
|
+
(_a = this.store.cart) == null ? void 0 : _a.destroy();
|
|
278
|
+
(_b = this.store.products) == null ? void 0 : _b.destroy();
|
|
279
|
+
(_c = this.store.accountList) == null ? void 0 : _c.destroy();
|
|
280
|
+
(_d = this.store.customer) == null ? void 0 : _d.destroy();
|
|
281
|
+
(_e = this.store.order) == null ? void 0 : _e.destroy();
|
|
282
|
+
this.core.effects.offByModuleDestroy(this.name);
|
|
283
|
+
this.core.unregisterModule(this);
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
287
|
+
0 && (module.exports = {
|
|
288
|
+
BookingTicket,
|
|
289
|
+
BookingTicketImpl,
|
|
290
|
+
...require("./types")
|
|
291
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ProductList, CartModule, AccountListModule, OrderModule } from '../../modules';
|
|
2
|
+
import { CustomerModule } from '../../modules/Customer';
|
|
3
|
+
export interface BookingTicketState {
|
|
4
|
+
cart: CartModule;
|
|
5
|
+
products: ProductList;
|
|
6
|
+
accountList: AccountListModule;
|
|
7
|
+
customer: CustomerModule;
|
|
8
|
+
order: OrderModule;
|
|
9
|
+
}
|
|
10
|
+
export declare function createModule<T extends keyof BookingTicketState>(moduleName: T, solutionName: string, name?: string, version?: string): BookingTicketState[T];
|
|
11
|
+
export declare enum BookingTicketHooks {
|
|
12
|
+
onInited = "bookingTicket:onInited",
|
|
13
|
+
onDestroy = "bookingTicket:onDestroy",
|
|
14
|
+
onProductsLoaded = "bookingTicket:onProductsLoaded",
|
|
15
|
+
onCustomerSelected = "bookingTicket:onCustomerSelected"
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 获取客户列表的参数
|
|
19
|
+
*/
|
|
20
|
+
export interface IGetCustomerListParams {
|
|
21
|
+
/** 页码 */
|
|
22
|
+
skip?: number;
|
|
23
|
+
/** 每页数量 */
|
|
24
|
+
num?: number;
|
|
25
|
+
/** 搜索关键词 */
|
|
26
|
+
search?: string;
|
|
27
|
+
/** 其他筛选参数 */
|
|
28
|
+
[key: string]: any;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 客户信息
|
|
32
|
+
*/
|
|
33
|
+
export interface ICustomer {
|
|
34
|
+
/** 客户ID */
|
|
35
|
+
id: string | number;
|
|
36
|
+
/** 客户姓名 */
|
|
37
|
+
name: string;
|
|
38
|
+
/** 客户电话 */
|
|
39
|
+
phone?: string;
|
|
40
|
+
/** 客户邮箱 */
|
|
41
|
+
email?: string;
|
|
42
|
+
/** 其他客户信息 */
|
|
43
|
+
[key: string]: any;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 加载商品列表的参数
|
|
47
|
+
*/
|
|
48
|
+
export interface ILoadProductsParams {
|
|
49
|
+
/** 日期 格式:YYYY-MM-DD */
|
|
50
|
+
schedule_date?: string;
|
|
51
|
+
/** 客户ID */
|
|
52
|
+
customer_id?: number;
|
|
53
|
+
/** 餐牌列表ID */
|
|
54
|
+
menu_list_ids?: number[];
|
|
55
|
+
/** 时间 格式:YYYY-MM-DD HH:mm:ss*/
|
|
56
|
+
schedule_datetime?: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* 扫描结果
|
|
60
|
+
*/
|
|
61
|
+
export interface IScanResult {
|
|
62
|
+
status: 'success' | 'fail';
|
|
63
|
+
scanType: string;
|
|
64
|
+
scanCode: string;
|
|
65
|
+
result: any;
|
|
66
|
+
}
|