@pisell/pisellos 0.0.214 → 0.0.216

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 (82) hide show
  1. package/dist/core/index.js +2 -1
  2. package/dist/effects/index.d.ts +4 -3
  3. package/dist/effects/index.js +15 -6
  4. package/dist/modules/AccountList/index.d.ts +7 -1
  5. package/dist/modules/AccountList/index.js +81 -14
  6. package/dist/modules/AccountList/types.d.ts +28 -0
  7. package/dist/modules/AccountList/types.js +8 -0
  8. package/dist/modules/Customer/constants.d.ts +7 -0
  9. package/dist/modules/Customer/constants.js +12 -0
  10. package/dist/modules/Customer/index.d.ts +89 -0
  11. package/dist/modules/Customer/index.js +440 -0
  12. package/dist/modules/Customer/types.d.ts +130 -0
  13. package/dist/modules/Customer/types.js +39 -0
  14. package/dist/modules/ProductList/index.d.ts +12 -1
  15. package/dist/modules/ProductList/index.js +28 -4
  16. package/dist/modules/Rules/index.js +7 -5
  17. package/dist/modules/Rules/types.d.ts +1 -0
  18. package/dist/modules/index.d.ts +1 -0
  19. package/dist/modules/index.js +1 -0
  20. package/dist/plugins/window.d.ts +1 -0
  21. package/dist/solution/BookingByStep/index.js +8 -15
  22. package/dist/solution/BookingTicket/index.d.ts +134 -0
  23. package/dist/solution/BookingTicket/index.js +534 -0
  24. package/dist/solution/BookingTicket/types.d.ts +66 -0
  25. package/dist/solution/BookingTicket/types.js +41 -0
  26. package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +22 -0
  27. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +159 -0
  28. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +19 -0
  29. package/dist/solution/BookingTicket/utils/scan/handleScan.js +182 -0
  30. package/dist/solution/BookingTicket/utils/scan/index.d.ts +59 -0
  31. package/dist/solution/BookingTicket/utils/scan/index.js +201 -0
  32. package/dist/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
  33. package/dist/solution/BookingTicket/utils/scan/scanCache.js +305 -0
  34. package/dist/solution/ShopDiscount/index.js +4 -2
  35. package/dist/solution/index.d.ts +1 -0
  36. package/dist/solution/index.js +1 -0
  37. package/dist/types/index.d.ts +3 -1
  38. package/dist/utils/task.d.ts +31 -0
  39. package/dist/utils/task.js +150 -0
  40. package/dist/utils/watch.d.ts +102 -0
  41. package/dist/utils/watch.js +294 -0
  42. package/lib/core/index.js +1 -1
  43. package/lib/effects/index.d.ts +4 -3
  44. package/lib/effects/index.js +4 -1
  45. package/lib/modules/AccountList/index.d.ts +7 -1
  46. package/lib/modules/AccountList/index.js +27 -0
  47. package/lib/modules/AccountList/types.d.ts +28 -0
  48. package/lib/modules/Customer/constants.d.ts +7 -0
  49. package/lib/modules/Customer/constants.js +39 -0
  50. package/lib/modules/Customer/index.d.ts +89 -0
  51. package/lib/modules/Customer/index.js +305 -0
  52. package/lib/modules/Customer/types.d.ts +130 -0
  53. package/lib/modules/Customer/types.js +35 -0
  54. package/lib/modules/ProductList/index.d.ts +12 -1
  55. package/lib/modules/ProductList/index.js +30 -3
  56. package/lib/modules/Rules/index.js +4 -3
  57. package/lib/modules/Rules/types.d.ts +1 -0
  58. package/lib/modules/index.d.ts +1 -0
  59. package/lib/modules/index.js +2 -0
  60. package/lib/plugins/window.d.ts +1 -0
  61. package/lib/solution/BookingByStep/index.js +0 -7
  62. package/lib/solution/BookingTicket/index.d.ts +134 -0
  63. package/lib/solution/BookingTicket/index.js +331 -0
  64. package/lib/solution/BookingTicket/types.d.ts +66 -0
  65. package/lib/solution/BookingTicket/types.js +70 -0
  66. package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +22 -0
  67. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +117 -0
  68. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +19 -0
  69. package/lib/solution/BookingTicket/utils/scan/handleScan.js +137 -0
  70. package/lib/solution/BookingTicket/utils/scan/index.d.ts +59 -0
  71. package/lib/solution/BookingTicket/utils/scan/index.js +149 -0
  72. package/lib/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
  73. package/lib/solution/BookingTicket/utils/scan/scanCache.js +231 -0
  74. package/lib/solution/ShopDiscount/index.js +2 -1
  75. package/lib/solution/index.d.ts +1 -0
  76. package/lib/solution/index.js +2 -0
  77. package/lib/types/index.d.ts +3 -1
  78. package/lib/utils/task.d.ts +31 -0
  79. package/lib/utils/task.js +84 -0
  80. package/lib/utils/watch.d.ts +102 -0
  81. package/lib/utils/watch.js +217 -0
  82. 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
  );
@@ -161,6 +170,24 @@ var ProductList = class extends import_BaseModule.BaseModule {
161
170
  async selectProducts(products) {
162
171
  this.store.selectProducts = products;
163
172
  }
173
+ /**
174
+ * 根据商品编码或条码搜索商品
175
+ * @param code 商品编码或条码
176
+ * @returns 匹配的商品列表,如果没有匹配则返回空数组
177
+ */
178
+ findProductsByCodeOrBarcode(code) {
179
+ if (!code || typeof code !== "string") {
180
+ return [];
181
+ }
182
+ const trimmedCode = code.trim();
183
+ if (!trimmedCode) {
184
+ return [];
185
+ }
186
+ const matchingProducts = this.store.list.filter((product) => {
187
+ return product.code && product.code.trim() === trimmedCode || product.barcode && product.barcode.trim() === trimmedCode;
188
+ });
189
+ return (0, import_lodash_es.cloneDeep)(matchingProducts);
190
+ }
164
191
  };
165
192
  // Annotate the CommonJS export names for ESM import in node:
166
193
  0 && (module.exports = {
@@ -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) === 0 || !product.price) && (discount.tag || discount.type) === "good_pass")
219
+ if ((Number(product.price) <= 0 || !product.price) && (discount.tag || discount.type) === "good_pass")
219
220
  return false;
220
- if ((Number(product.total) === 0 || !product.total) && !((_a2 = product.discount_list) == null ? void 0 : _a2.find((n) => {
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,
@@ -39,6 +39,7 @@ type ProductDetail = {
39
39
  original_price?: number | string;
40
40
  num?: number;
41
41
  quantity: number;
42
+ vouchersApplicable?: boolean;
42
43
  };
43
44
  export interface RulesParamsHooks {
44
45
  getProduct: (product: Record<string, any>) => ProductDetail;
@@ -3,6 +3,7 @@ export * from './ProductList';
3
3
  export * from './Cart';
4
4
  export * from './Account';
5
5
  export * from './AccountList';
6
+ export * from './Customer';
6
7
  export * from './Date';
7
8
  export * from './Guests';
8
9
  export * from './Order';
@@ -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"),
@@ -13,6 +13,7 @@ export interface WindowPlugin extends Plugin {
13
13
  navigator: Partial<Navigator>;
14
14
  document: Partial<Document>;
15
15
  history: History;
16
+ interaction?: any;
16
17
  }
17
18
  /**
18
19
  * 简单的 Storage 接口实现
@@ -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,134 @@
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 data 用户自定义数据
111
+ */
112
+ activateCamera(data?: {
113
+ [key: string]: any;
114
+ }): void;
115
+ /**
116
+ * 设置其他参数
117
+ * @param params 参数
118
+ * @param options 选项
119
+ */
120
+ setOtherParams(params: Record<string, any>, { cover }?: {
121
+ cover?: boolean;
122
+ }): Promise<void>;
123
+ /**
124
+ * 获取其他参数
125
+ * @returns 其他参数
126
+ */
127
+ getOtherParams(): Promise<Record<string, any>>;
128
+ /**
129
+ * 销毁模块
130
+ */
131
+ destroy(): void;
132
+ }
133
+ export * from './types';
134
+ export { BookingTicketImpl as BookingTicket };
@@ -0,0 +1,331 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/solution/BookingTicket/index.ts
31
+ var BookingTicket_exports = {};
32
+ __export(BookingTicket_exports, {
33
+ BookingTicket: () => BookingTicketImpl,
34
+ BookingTicketImpl: () => BookingTicketImpl
35
+ });
36
+ module.exports = __toCommonJS(BookingTicket_exports);
37
+ var import_BaseModule = require("../../modules/BaseModule");
38
+ var import_types = require("./types");
39
+ var import_scan = __toESM(require("./utils/scan"));
40
+ var import_handleScan = require("./utils/scan/handleScan");
41
+ var import_scanCache = __toESM(require("./utils/scan/scanCache"));
42
+ __reExport(BookingTicket_exports, require("./types"), module.exports);
43
+ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
44
+ constructor() {
45
+ super(...arguments);
46
+ this.defaultName = "bookingTicket";
47
+ this.defaultVersion = "1.0.0";
48
+ this.isSolution = true;
49
+ this.otherParams = {};
50
+ }
51
+ async initialize(core, options) {
52
+ var _a, _b, _c;
53
+ this.core = core;
54
+ this.store = options.store || {};
55
+ this.otherParams = options.otherParams || {};
56
+ console.log("[BookingTicket] 初始化完成");
57
+ this.request = core.getPlugin("request");
58
+ this.window = core.getPlugin("window");
59
+ this.shopStore = core.getPlugin("shopStore");
60
+ if (!this.request) {
61
+ throw new Error("bookingTicket解决方案需要 request 插件支持");
62
+ }
63
+ if (!this.shopStore) {
64
+ throw new Error("bookingTicket解决方案需要 shopStore 插件支持");
65
+ }
66
+ let targetCacheData = {};
67
+ this.cacheId = (_a = this.otherParams) == null ? void 0 : _a.cacheId;
68
+ this.platform = (_b = this.otherParams) == null ? void 0 : _b.platform;
69
+ this.scan = new import_scan.default(this, "BOOKING_TICKET_SCAN");
70
+ if ((_c = this.otherParams) == null ? void 0 : _c.cacheId) {
71
+ const sessionData = this.window.sessionStorage.getItem(this.name);
72
+ if (sessionData) {
73
+ const data = JSON.parse(sessionData);
74
+ targetCacheData = data[this.otherParams.cacheId];
75
+ }
76
+ }
77
+ const moduleArr = [
78
+ "cart",
79
+ "products",
80
+ "accountList",
81
+ "customer",
82
+ "order"
83
+ ];
84
+ moduleArr.forEach((step) => {
85
+ var _a2, _b2;
86
+ const targetModule = (0, import_types.createModule)(step, this.name);
87
+ if (targetModule) {
88
+ this.store[step] = targetModule;
89
+ this.core.registerModule(targetModule, {
90
+ initialState: targetCacheData == null ? void 0 : targetCacheData[targetModule.name],
91
+ otherParams: {
92
+ ...this.otherParams,
93
+ fatherModule: this.name,
94
+ openCache: ((_a2 = this.otherParams) == null ? void 0 : _a2.cacheId) ? true : false,
95
+ cacheId: (_b2 = this.otherParams) == null ? void 0 : _b2.cacheId
96
+ }
97
+ });
98
+ } else {
99
+ throw new Error(`模块 ${step} 不存在`);
100
+ }
101
+ });
102
+ this.core.effects.emit(import_types.BookingTicketHooks.onInited, {});
103
+ }
104
+ /**
105
+ * 获取商品列表
106
+ * @param params 包含 schedule_date 的参数
107
+ * @returns 商品列表
108
+ */
109
+ async loadProducts(params = {}) {
110
+ const { schedule_date, customer_id, menu_list_ids, schedule_datetime } = params;
111
+ try {
112
+ const result = await this.store.products.loadProducts({
113
+ with_count: ["bundleGroup", "optionGroup"],
114
+ with_schedule: 1,
115
+ ...params,
116
+ cacheId: this.cacheId
117
+ });
118
+ this.core.effects.emit(import_types.BookingTicketHooks.onProductsLoaded, result);
119
+ return result;
120
+ } catch (error) {
121
+ console.error("Failed to load products:", error);
122
+ throw error;
123
+ }
124
+ }
125
+ /**
126
+ * 获取商品列表(不加载到模块中)
127
+ * @returns 商品列表
128
+ */
129
+ async getProducts() {
130
+ return this.store.products.getProducts();
131
+ }
132
+ /**
133
+ * 获取客户列表
134
+ * @param params 查询参数
135
+ * @returns 客户列表响应
136
+ */
137
+ async getCustomerList(params = {}) {
138
+ try {
139
+ const result = await this.store.customer.getCustomerList(params);
140
+ return result;
141
+ } catch (error) {
142
+ console.error("Failed to get customer list:", error);
143
+ throw error;
144
+ }
145
+ }
146
+ /**
147
+ * 设置活跃客户
148
+ * @param customer 客户信息
149
+ */
150
+ setActiveCustomer(customer) {
151
+ this.store.customer.setSelectedCustomer(customer);
152
+ this.core.effects.emit(import_types.BookingTicketHooks.onCustomerSelected, {
153
+ customer
154
+ });
155
+ }
156
+ /**
157
+ * 获取当前活跃客户
158
+ * @returns 当前活跃客户
159
+ */
160
+ getActiveCustomer() {
161
+ return this.store.customer.getSelectedCustomer();
162
+ }
163
+ /**
164
+ * 根据ID设置选中的客户
165
+ * @param customerId 客户ID
166
+ */
167
+ setSelectedCustomerById(customerId) {
168
+ const customer = this.store.customer.getCustomerById(customerId);
169
+ if (customer) {
170
+ this.store.customer.setSelectedCustomer(customer);
171
+ this.core.effects.emit(import_types.BookingTicketHooks.onCustomerSelected, {
172
+ customer
173
+ });
174
+ }
175
+ }
176
+ /**
177
+ * 获取所有客户
178
+ * @returns 客户列表
179
+ */
180
+ getCustomers() {
181
+ return this.store.customer.getCustomers();
182
+ }
183
+ /**
184
+ * 根据ID获取客户
185
+ * @param customerId 客户ID
186
+ * @returns 客户信息
187
+ */
188
+ getCustomerById(customerId) {
189
+ return this.store.customer.getCustomerById(customerId);
190
+ }
191
+ /**
192
+ * 清空客户列表
193
+ */
194
+ clearCustomers() {
195
+ this.store.customer.clearCustomers();
196
+ }
197
+ /**
198
+ * 添加客户到列表第一位
199
+ * @param customer 要添加的客户信息
200
+ */
201
+ addCustomerToFirst(customer) {
202
+ this.store.customer.addCustomerToFirst(customer);
203
+ }
204
+ /**
205
+ * 获取客户分页信息
206
+ * @returns 分页信息
207
+ */
208
+ getCustomerPaginationInfo() {
209
+ return this.store.customer.getPaginationInfo();
210
+ }
211
+ /**
212
+ * 获取客户列表总数
213
+ * @returns 总数
214
+ */
215
+ getCustomerTotal() {
216
+ return this.store.customer.getState().total;
217
+ }
218
+ /**
219
+ * 设置客户分页信息
220
+ * @param page 页码
221
+ * @param pageSize 每页数量
222
+ */
223
+ setCustomerPaginationInfo(page, pageSize) {
224
+ this.store.customer.setPaginationInfo(page, pageSize);
225
+ }
226
+ /**
227
+ * 便捷方法:切换客户分页并自动获取数据
228
+ * @param page 页码
229
+ * @param pageSize 每页数量(可选)
230
+ * @returns 客户列表响应
231
+ */
232
+ async changeCustomerPage(page, pageSize) {
233
+ try {
234
+ const result = await this.store.customer.changeCustomerPage(
235
+ page,
236
+ pageSize
237
+ );
238
+ return result;
239
+ } catch (error) {
240
+ console.error("Failed to change customer page:", error);
241
+ throw error;
242
+ }
243
+ }
244
+ /**
245
+ * 全局扫描监听
246
+ * @param callback 回调
247
+ */
248
+ scanGlobalListener(callback) {
249
+ const localSearch = (v) => this.store.products.findProductsByCodeOrBarcode(v);
250
+ const scanCallback = (0, import_handleScan.handleGlobalScan)(this.request, localSearch);
251
+ const safeCallback = (d) => {
252
+ try {
253
+ callback(d);
254
+ } catch (error) {
255
+ console.error("scanGlobalListener回掉函数异常", error);
256
+ }
257
+ };
258
+ const listener = { key: "global", callback: safeCallback };
259
+ const removeListener = this.scan.addListener(listener, scanCallback);
260
+ return removeListener;
261
+ }
262
+ /**
263
+ * 客户扫描监听
264
+ * @param callback 回调
265
+ */
266
+ scanCustomerListener(callback) {
267
+ const localSearch = (v) => this.store.products.findProductsByCodeOrBarcode(v);
268
+ const scanCallback = (0, import_handleScan.handleCustomerScan)(this.request, localSearch);
269
+ const safeCallback = (d) => {
270
+ try {
271
+ callback(d);
272
+ } catch (error) {
273
+ console.error("scanCustomerListener回掉函数异常", error);
274
+ }
275
+ };
276
+ const listener = { key: "customer", callback: safeCallback };
277
+ const removeListener = this.scan.addListener(listener, scanCallback);
278
+ return removeListener;
279
+ }
280
+ /**
281
+ * 调用摄像头
282
+ * @param data 用户自定义数据
283
+ */
284
+ activateCamera(data) {
285
+ var _a, _b, _c, _d;
286
+ (_d = (_c = (_b = (_a = this.window) == null ? void 0 : _a.interaction) == null ? void 0 : _b.utils) == null ? void 0 : _c.postMessageToApp) == null ? void 0 : _d.call(_c, {
287
+ module: "global",
288
+ key: "active_native_scanner",
289
+ data
290
+ });
291
+ }
292
+ /**
293
+ * 设置其他参数
294
+ * @param params 参数
295
+ * @param options 选项
296
+ */
297
+ async setOtherParams(params, { cover = false } = {}) {
298
+ if (cover) {
299
+ this.otherParams = params;
300
+ } else {
301
+ this.otherParams = { ...this.otherParams, ...params };
302
+ }
303
+ }
304
+ /**
305
+ * 获取其他参数
306
+ * @returns 其他参数
307
+ */
308
+ async getOtherParams() {
309
+ return this.otherParams;
310
+ }
311
+ /**
312
+ * 销毁模块
313
+ */
314
+ destroy() {
315
+ var _a, _b, _c, _d, _e;
316
+ (_a = this.store.cart) == null ? void 0 : _a.destroy();
317
+ (_b = this.store.products) == null ? void 0 : _b.destroy();
318
+ (_c = this.store.accountList) == null ? void 0 : _c.destroy();
319
+ (_d = this.store.customer) == null ? void 0 : _d.destroy();
320
+ (_e = this.store.order) == null ? void 0 : _e.destroy();
321
+ this.core.effects.offByModuleDestroy(this.name);
322
+ this.core.unregisterModule(this);
323
+ import_scanCache.default.clear();
324
+ }
325
+ };
326
+ // Annotate the CommonJS export names for ESM import in node:
327
+ 0 && (module.exports = {
328
+ BookingTicket,
329
+ BookingTicketImpl,
330
+ ...require("./types")
331
+ });
@@ -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
+ }