@pisell/pisellos 0.0.567 → 0.0.568

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 (228) hide show
  1. package/dist/core/index.js +6 -9
  2. package/dist/model/strategy/adapter/walletPass/evaluator.js +0 -2
  3. package/dist/model/strategy/adapter/walletPass/example.js +3 -26
  4. package/dist/model/strategy/adapter/walletPass/utils.js +0 -3
  5. package/dist/model/strategy/strategy-example.js +5 -19
  6. package/dist/modules/Cart/index.js +0 -3
  7. package/dist/modules/Cart/utils/cartProduct.js +0 -1
  8. package/dist/modules/Date/index.js +1 -5
  9. package/dist/modules/Discount/index.js +1 -4
  10. package/dist/modules/OpenData/index.js +0 -2
  11. package/dist/modules/Order/index.d.ts +1 -1
  12. package/dist/modules/Order/index.js +14 -41
  13. package/dist/modules/Payment/index.js +142 -270
  14. package/dist/modules/Payment/walletpass.js +4 -5
  15. package/dist/modules/Rules/index.js +0 -7
  16. package/dist/modules/Schedule/utils.js +0 -1
  17. package/dist/modules/Step/index.js +0 -1
  18. package/dist/plugins/request.js +1 -4
  19. package/dist/plugins/window.js +2 -6
  20. package/dist/server/index.js +88 -121
  21. package/dist/server/modules/menu/index.js +32 -41
  22. package/dist/server/modules/products/index.js +29 -49
  23. package/dist/server/modules/quotation/index.js +29 -38
  24. package/dist/server/modules/resource/index.js +3 -4
  25. package/dist/server/modules/schedule/index.js +32 -40
  26. package/dist/server/utils/product.js +0 -1
  27. package/dist/solution/BookingByStep/index.d.ts +1 -1
  28. package/dist/solution/BookingByStep/index.js +7 -59
  29. package/dist/solution/BookingByStep/utils/capacity.js +1 -11
  30. package/dist/solution/BookingByStep/utils/resources.js +1 -3
  31. package/dist/solution/BookingByStep/utils/timeslots.js +2 -43
  32. package/dist/solution/BookingTicket/index.d.ts +1 -1
  33. package/dist/solution/BookingTicket/index.js +5 -7
  34. package/dist/solution/BookingTicket/utils/scan/handleScan.js +25 -31
  35. package/dist/solution/BookingTicket/utils/scan/index.js +6 -10
  36. package/dist/solution/BuyTickets/index.js +9 -12
  37. package/dist/solution/Checkout/index.js +177 -246
  38. package/dist/solution/Checkout/utils/index.js +4 -16
  39. package/dist/solution/RegisterAndLogin/index.js +30 -76
  40. package/dist/solution/ScanOrder/index.js +50 -60
  41. package/dist/solution/ShopDiscount/index.js +2 -7
  42. package/dist/solution/VenueBooking/index.d.ts +5 -0
  43. package/dist/solution/VenueBooking/index.js +364 -327
  44. package/dist/utils/task.js +15 -18
  45. package/dist/utils/watch.js +0 -1
  46. package/lib/apis/picoding.js +2 -0
  47. package/lib/core/index.js +130 -131
  48. package/lib/effects/index.js +46 -57
  49. package/lib/index.js +92 -53
  50. package/lib/model/index.js +14 -21
  51. package/lib/model/strategy/adapter/dataVariant/adapter.js +38 -50
  52. package/lib/model/strategy/adapter/dataVariant/evaluator.js +162 -236
  53. package/lib/model/strategy/adapter/dataVariant/examples.js +229 -237
  54. package/lib/model/strategy/adapter/dataVariant/index.js +39 -34
  55. package/lib/model/strategy/adapter/dataVariant/type.js +57 -28
  56. package/lib/model/strategy/adapter/index.js +100 -64
  57. package/lib/model/strategy/adapter/itemRule/adapter.js +156 -144
  58. package/lib/model/strategy/adapter/itemRule/evaluator.js +36 -48
  59. package/lib/model/strategy/adapter/itemRule/examples.js +295 -225
  60. package/lib/model/strategy/adapter/itemRule/index.js +83 -57
  61. package/lib/model/strategy/adapter/itemRule/type.js +97 -36
  62. package/lib/model/strategy/adapter/promotion/adapter.js +84 -63
  63. package/lib/model/strategy/adapter/promotion/evaluator.js +381 -231
  64. package/lib/model/strategy/adapter/promotion/examples.js +139 -159
  65. package/lib/model/strategy/adapter/promotion/index.js +1 -49
  66. package/lib/model/strategy/adapter/promotion/type.js +199 -35
  67. package/lib/model/strategy/adapter/type.js +4 -16
  68. package/lib/model/strategy/adapter/walletPass/evaluator.js +180 -152
  69. package/lib/model/strategy/adapter/walletPass/example.js +217 -190
  70. package/lib/model/strategy/adapter/walletPass/index.js +75 -51
  71. package/lib/model/strategy/adapter/walletPass/locales.js +36 -58
  72. package/lib/model/strategy/adapter/walletPass/type.js +4 -16
  73. package/lib/model/strategy/adapter/walletPass/utils.js +652 -402
  74. package/lib/model/strategy/engine.js +270 -168
  75. package/lib/model/strategy/index.js +49 -34
  76. package/lib/model/strategy/strategy-example.js +243 -239
  77. package/lib/model/strategy/type.js +100 -40
  78. package/lib/modules/Account/index.js +39 -53
  79. package/lib/modules/Account/types.js +20 -33
  80. package/lib/modules/AccountList/index.js +116 -154
  81. package/lib/modules/AccountList/types.js +30 -31
  82. package/lib/modules/AccountList/utils.js +18 -30
  83. package/lib/modules/BaseModule.js +22 -45
  84. package/lib/modules/Cart/index.js +170 -124
  85. package/lib/modules/Cart/types.js +46 -51
  86. package/lib/modules/Cart/utils/cartAccount.js +40 -39
  87. package/lib/modules/Cart/utils/cartDate.js +56 -61
  88. package/lib/modules/Cart/utils/cartDiscount.js +28 -33
  89. package/lib/modules/Cart/utils/cartNote.js +27 -32
  90. package/lib/modules/Cart/utils/cartProduct.js +306 -241
  91. package/lib/modules/Cart/utils/cartRelationForms.js +29 -35
  92. package/lib/modules/Cart/utils/cartResource.js +72 -78
  93. package/lib/modules/Cart/utils/changePrice.js +26 -62
  94. package/lib/modules/Cart/utils/index.js +106 -48
  95. package/lib/modules/Customer/constants.js +13 -34
  96. package/lib/modules/Customer/index.js +216 -153
  97. package/lib/modules/Customer/types.js +38 -35
  98. package/lib/modules/Date/index.js +116 -115
  99. package/lib/modules/Date/types.js +16 -28
  100. package/lib/modules/Date/utils.js +174 -123
  101. package/lib/modules/Discount/index.js +117 -113
  102. package/lib/modules/Discount/types.js +9 -31
  103. package/lib/modules/Guests/index.js +30 -56
  104. package/lib/modules/Guests/types.js +23 -33
  105. package/lib/modules/Holder/index.js +209 -189
  106. package/lib/modules/Holder/types.js +4 -16
  107. package/lib/modules/Holder/utils.js +20 -49
  108. package/lib/modules/OpenData/index.js +63 -74
  109. package/lib/modules/OpenData/types.js +4 -16
  110. package/lib/modules/OpenData/utils.js +44 -78
  111. package/lib/modules/Order/index.d.ts +1 -1
  112. package/lib/modules/Order/index.js +332 -320
  113. package/lib/modules/Order/types.js +24 -33
  114. package/lib/modules/Order/utils.js +350 -284
  115. package/lib/modules/Payment/cash.js +20 -33
  116. package/lib/modules/Payment/cashRecommendationAlgorithm.js +145 -76
  117. package/lib/modules/Payment/eftpos.js +16 -30
  118. package/lib/modules/Payment/index.js +566 -432
  119. package/lib/modules/Payment/mx51.js +1 -0
  120. package/lib/modules/Payment/types.js +216 -107
  121. package/lib/modules/Payment/utils.js +50 -47
  122. package/lib/modules/Payment/walletpass.js +221 -203
  123. package/lib/modules/Product/index.js +51 -46
  124. package/lib/modules/Product/types.js +4 -16
  125. package/lib/modules/Product/utils.js +32 -33
  126. package/lib/modules/ProductList/index.js +111 -110
  127. package/lib/modules/ProductList/types.js +9 -31
  128. package/lib/modules/Quotation/index.js +60 -82
  129. package/lib/modules/Quotation/types.js +4 -16
  130. package/lib/modules/Resource/index.js +27 -59
  131. package/lib/modules/Resource/types.js +22 -32
  132. package/lib/modules/Resource/utils.js +30 -38
  133. package/lib/modules/Rules/index.js +1172 -872
  134. package/lib/modules/Rules/types.js +17 -40
  135. package/lib/modules/SalesSummary/index.js +59 -68
  136. package/lib/modules/SalesSummary/types.js +4 -16
  137. package/lib/modules/SalesSummary/utils.js +176 -193
  138. package/lib/modules/ScanOrderLogger/index.js +59 -79
  139. package/lib/modules/ScanOrderLogger/providers/feishu.js +54 -78
  140. package/lib/modules/ScanOrderLogger/providers/grafana.js +13 -36
  141. package/lib/modules/ScanOrderLogger/types.js +4 -16
  142. package/lib/modules/Schedule/getDateIsInSchedule.js +334 -167
  143. package/lib/modules/Schedule/index.js +97 -107
  144. package/lib/modules/Schedule/type.js +4 -16
  145. package/lib/modules/Schedule/types.js +4 -16
  146. package/lib/modules/Schedule/utils.js +433 -291
  147. package/lib/modules/Step/index.js +40 -52
  148. package/lib/modules/Step/tyeps.js +4 -16
  149. package/lib/modules/Summary/index.js +66 -70
  150. package/lib/modules/Summary/types.js +4 -16
  151. package/lib/modules/Summary/utils.js +782 -429
  152. package/lib/modules/index.js +212 -57
  153. package/lib/plugins/app.js +4 -16
  154. package/lib/plugins/index.js +36 -25
  155. package/lib/plugins/request.js +137 -126
  156. package/lib/plugins/shopStore.js +4 -16
  157. package/lib/plugins/user.js +4 -16
  158. package/lib/plugins/window.js +171 -179
  159. package/lib/server/index.js +882 -623
  160. package/lib/server/modules/index.js +85 -59
  161. package/lib/server/modules/menu/index.js +146 -122
  162. package/lib/server/modules/menu/types.js +18 -31
  163. package/lib/server/modules/order/index.js +195 -231
  164. package/lib/server/modules/order/types.js +107 -32
  165. package/lib/server/modules/order/utils/filterBookings.js +174 -140
  166. package/lib/server/modules/order/utils/filterOrders.js +89 -60
  167. package/lib/server/modules/products/index.js +430 -335
  168. package/lib/server/modules/products/types.js +41 -34
  169. package/lib/server/modules/quotation/index.js +76 -77
  170. package/lib/server/modules/quotation/types.js +21 -31
  171. package/lib/server/modules/resource/index.js +216 -187
  172. package/lib/server/modules/resource/types.js +42 -33
  173. package/lib/server/modules/schedule/index.js +134 -119
  174. package/lib/server/modules/schedule/types.js +14 -21
  175. package/lib/server/modules/schedule/utils.js +334 -163
  176. package/lib/server/types.js +4 -16
  177. package/lib/server/utils/index.js +25 -23
  178. package/lib/server/utils/product.js +196 -139
  179. package/lib/server/utils/schedule.js +34 -41
  180. package/lib/server/utils/time.js +40 -49
  181. package/lib/solution/BookingByStep/index.d.ts +1 -1
  182. package/lib/solution/BookingByStep/index.js +1530 -1343
  183. package/lib/solution/BookingByStep/types.js +40 -99
  184. package/lib/solution/BookingByStep/utils/capacity.js +192 -160
  185. package/lib/solution/BookingByStep/utils/products.js +42 -52
  186. package/lib/solution/BookingByStep/utils/resources.js +527 -330
  187. package/lib/solution/BookingByStep/utils/stock.js +65 -44
  188. package/lib/solution/BookingByStep/utils/timeslots.js +129 -131
  189. package/lib/solution/BookingTicket/index.d.ts +1 -1
  190. package/lib/solution/BookingTicket/index.js +147 -122
  191. package/lib/solution/BookingTicket/types.js +38 -64
  192. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +64 -80
  193. package/lib/solution/BookingTicket/utils/scan/handleScan.js +82 -80
  194. package/lib/solution/BookingTicket/utils/scan/index.js +90 -94
  195. package/lib/solution/BookingTicket/utils/scan/scanCache.js +90 -43
  196. package/lib/solution/BuyTickets/index.js +67 -70
  197. package/lib/solution/BuyTickets/types.js +22 -38
  198. package/lib/solution/Checkout/index.js +1451 -1158
  199. package/lib/solution/Checkout/types.js +91 -61
  200. package/lib/solution/Checkout/utils/index.js +227 -158
  201. package/lib/solution/PlaceOrder/index.js +55 -0
  202. package/lib/solution/RegisterAndLogin/config.js +493 -460
  203. package/lib/solution/RegisterAndLogin/index.js +633 -630
  204. package/lib/solution/RegisterAndLogin/types.js +189 -76
  205. package/lib/solution/RegisterAndLogin/utils.js +183 -125
  206. package/lib/solution/Sales/index.js +218 -200
  207. package/lib/solution/Sales/types.js +27 -33
  208. package/lib/solution/ScanOrder/index.js +803 -840
  209. package/lib/solution/ScanOrder/types.js +34 -34
  210. package/lib/solution/ScanOrder/utils.js +372 -331
  211. package/lib/solution/ShopDiscount/index.js +230 -236
  212. package/lib/solution/ShopDiscount/types.js +15 -37
  213. package/lib/solution/ShopDiscount/utils.js +309 -172
  214. package/lib/solution/VenueBooking/index.d.ts +5 -0
  215. package/lib/solution/VenueBooking/index.js +886 -929
  216. package/lib/solution/VenueBooking/types.js +20 -40
  217. package/lib/solution/VenueBooking/utils/dateSummary.js +22 -54
  218. package/lib/solution/VenueBooking/utils/resource.js +31 -54
  219. package/lib/solution/VenueBooking/utils/slotMerge.js +88 -106
  220. package/lib/solution/VenueBooking/utils/smartPricing.js +112 -100
  221. package/lib/solution/VenueBooking/utils/timeSlot.js +133 -132
  222. package/lib/solution/VenueBooking/utils.js +130 -67
  223. package/lib/solution/index.js +102 -37
  224. package/lib/store/createStore.js +32 -29
  225. package/lib/types/index.js +4 -16
  226. package/lib/utils/task.js +36 -36
  227. package/lib/utils/watch.js +81 -47
  228. package/package.json +2 -1
@@ -1,98 +1,82 @@
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;
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {
7
+ BookingTicketImpl: true,
8
+ BookingTicket: true
18
9
  };
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
10
+ exports.BookingTicketImpl = exports.BookingTicket = void 0;
11
+ var _BaseModule = require("../../modules/BaseModule");
12
+ var _types = require("./types");
13
+ Object.keys(_types).forEach(function (key) {
14
+ if (key === "default" || key === "__esModule") return;
15
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
16
+ if (key in exports && exports[key] === _types[key]) return;
17
+ Object.defineProperty(exports, key, {
18
+ enumerable: true,
19
+ get: function () {
20
+ return _types[key];
21
+ }
22
+ });
35
23
  });
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
- }
24
+ var _scan = _interopRequireDefault(require("./utils/scan"));
25
+ var _handleScan = require("./utils/scan/handleScan");
26
+ var _scanCache = _interopRequireDefault(require("./utils/scan/scanCache"));
27
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
+ class BookingTicketImpl extends _BaseModule.BaseModule {
29
+ defaultName = 'bookingTicket';
30
+ defaultVersion = '1.0.0';
31
+ isSolution = true;
32
+ request;
33
+ window;
34
+ shopStore;
35
+ store;
36
+ otherParams = {};
37
+ cacheId;
38
+ platform; // 平台类型,用于判断是 PC / H5
39
+
40
+ scan;
51
41
  async initialize(core, options) {
52
- var _a, _b, _c;
53
42
  this.core = core;
54
43
  this.store = options.store || {};
55
44
  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");
45
+ // 获取依赖的插件
46
+ this.request = core.getPlugin('request');
47
+ this.window = core.getPlugin('window');
48
+ this.shopStore = core.getPlugin('shopStore');
60
49
  if (!this.request) {
61
- throw new Error("bookingTicket解决方案需要 request 插件支持");
50
+ throw new Error('bookingTicket解决方案需要 request 插件支持');
62
51
  }
63
52
  if (!this.shopStore) {
64
- throw new Error("bookingTicket解决方案需要 shopStore 插件支持");
53
+ throw new Error('bookingTicket解决方案需要 shopStore 插件支持');
65
54
  }
55
+
56
+ // 如果有传 cacheid,默认需要收集上面这些模块里用户操作选中的数据
66
57
  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) {
58
+ this.cacheId = this.otherParams?.cacheId;
59
+ this.platform = this.otherParams?.platform;
60
+ this.scan = new _scan.default(this, 'BOOKING_TICKET_SCAN');
61
+ if (this.otherParams?.cacheId) {
71
62
  const sessionData = this.window.sessionStorage.getItem(this.name);
72
63
  if (sessionData) {
73
64
  const data = JSON.parse(sessionData);
74
65
  targetCacheData = data[this.otherParams.cacheId];
75
66
  }
76
67
  }
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);
68
+ const moduleArr = ['cart', 'products', 'accountList', 'customer', 'order'];
69
+ moduleArr.forEach(step => {
70
+ const targetModule = (0, _types.createModule)(step, this.name);
87
71
  if (targetModule) {
88
72
  this.store[step] = targetModule;
89
73
  this.core.registerModule(targetModule, {
90
- initialState: targetCacheData == null ? void 0 : targetCacheData[targetModule.name],
74
+ initialState: targetCacheData?.[targetModule.name],
91
75
  otherParams: {
92
76
  ...this.otherParams,
93
77
  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
78
+ openCache: this.otherParams?.cacheId ? true : false,
79
+ cacheId: this.otherParams?.cacheId
96
80
  }
97
81
  });
98
82
  } else {
@@ -101,16 +85,22 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
101
85
  });
102
86
  this.core.effects.emit(`${this.name}:onInited`, {});
103
87
  }
88
+
104
89
  /**
105
90
  * 获取商品列表
106
91
  * @param params 包含 schedule_date 的参数
107
92
  * @returns 商品列表
108
93
  */
109
94
  async loadProducts(params = {}, options) {
110
- const { schedule_date, customer_id, menu_list_ids, schedule_datetime } = params;
95
+ const {
96
+ schedule_date,
97
+ customer_id,
98
+ menu_list_ids,
99
+ schedule_datetime
100
+ } = params;
111
101
  try {
112
102
  const result = await this.store.products.loadProducts({
113
- with_count: ["bundleGroup", "optionGroup"],
103
+ with_count: ['bundleGroup', 'optionGroup'],
114
104
  with_schedule: 1,
115
105
  ...params,
116
106
  cacheId: this.cacheId
@@ -118,24 +108,26 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
118
108
  this.core.effects.emit(`${this.name}:onProductsLoaded`, result);
119
109
  return result;
120
110
  } catch (error) {
121
- console.error("Failed to load products:", error);
111
+ console.error('Failed to load products:', error);
122
112
  throw error;
123
113
  }
124
114
  }
115
+
125
116
  /**
126
117
  * 取消商品查询订阅
127
118
  * @param subscriberId 订阅时传入的 subscriberId
128
119
  */
129
120
  unsubscribeProductQuery(subscriberId) {
130
- var _a;
131
- (_a = this.core.server) == null ? void 0 : _a.removeProductQuerySubscriber(subscriberId);
121
+ this.core.server?.removeProductQuerySubscriber(subscriberId);
132
122
  }
123
+
133
124
  /**
134
125
  * 初始化外设扫码结果监听
135
126
  */
136
127
  initPeripheralsListener() {
137
128
  this.scan.initPeripheralsListener();
138
129
  }
130
+
139
131
  /**
140
132
  * 获取商品列表(不加载到模块中)
141
133
  * @returns 商品列表
@@ -143,19 +135,21 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
143
135
  async getProducts() {
144
136
  return this.store.products.getProducts();
145
137
  }
138
+
146
139
  /**
147
140
  * 获取日程时间段点
148
141
  * @param params 参数
149
142
  * @returns 日程时间段点
150
143
  */
151
144
  async getScheduleTimePoints(params) {
152
- const result = await this.request.post("/menu/schedule-time-points", {
145
+ const result = await this.request.post('/menu/schedule-time-points', {
153
146
  menu_list_ids: params.menu_list_ids
154
147
  }, {
155
148
  osServer: true
156
149
  });
157
150
  return result.data || [];
158
151
  }
152
+
159
153
  /**
160
154
  * 获取客户列表
161
155
  * @param params 查询参数
@@ -166,10 +160,11 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
166
160
  const result = await this.store.customer.getCustomerList(params);
167
161
  return result;
168
162
  } catch (error) {
169
- console.error("Failed to get customer list:", error);
163
+ console.error('Failed to get customer list:', error);
170
164
  throw error;
171
165
  }
172
166
  }
167
+
173
168
  /**
174
169
  * 设置活跃客户
175
170
  * @param customer 客户信息
@@ -180,6 +175,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
180
175
  customer
181
176
  });
182
177
  }
178
+
183
179
  /**
184
180
  * 获取当前活跃客户
185
181
  * @returns 当前活跃客户
@@ -187,6 +183,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
187
183
  getActiveCustomer() {
188
184
  return this.store.customer.getSelectedCustomer();
189
185
  }
186
+
190
187
  /**
191
188
  * 根据ID设置选中的客户
192
189
  * @param customerId 客户ID
@@ -200,6 +197,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
200
197
  });
201
198
  }
202
199
  }
200
+
203
201
  /**
204
202
  * 获取所有客户
205
203
  * @returns 客户列表
@@ -207,6 +205,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
207
205
  getCustomers() {
208
206
  return this.store.customer.getCustomers();
209
207
  }
208
+
210
209
  /**
211
210
  * 根据ID获取客户
212
211
  * @param customerId 客户ID
@@ -215,12 +214,14 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
215
214
  getCustomerById(customerId) {
216
215
  return this.store.customer.getCustomerById(customerId);
217
216
  }
217
+
218
218
  /**
219
219
  * 清空客户列表
220
220
  */
221
221
  clearCustomers() {
222
222
  this.store.customer.clearCustomers();
223
223
  }
224
+
224
225
  /**
225
226
  * 添加客户到列表第一位
226
227
  * @param customer 要添加的客户信息
@@ -228,6 +229,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
228
229
  addCustomerToFirst(customer) {
229
230
  this.store.customer.addCustomerToFirst(customer);
230
231
  }
232
+
231
233
  /**
232
234
  * 获取客户分页信息
233
235
  * @returns 分页信息
@@ -235,6 +237,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
235
237
  getCustomerPaginationInfo() {
236
238
  return this.store.customer.getPaginationInfo();
237
239
  }
240
+
238
241
  /**
239
242
  * 获取客户列表总数
240
243
  * @returns 总数
@@ -242,6 +245,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
242
245
  getCustomerTotal() {
243
246
  return this.store.customer.getState().total;
244
247
  }
248
+
245
249
  /**
246
250
  * 设置客户分页信息
247
251
  * @param page 页码
@@ -250,6 +254,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
250
254
  setCustomerPaginationInfo(page, pageSize) {
251
255
  this.store.customer.setPaginationInfo(page, pageSize);
252
256
  }
257
+
253
258
  /**
254
259
  * 便捷方法:切换客户分页并自动获取数据
255
260
  * @param page 页码
@@ -258,16 +263,14 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
258
263
  */
259
264
  async changeCustomerPage(page, pageSize) {
260
265
  try {
261
- const result = await this.store.customer.changeCustomerPage(
262
- page,
263
- pageSize
264
- );
266
+ const result = await this.store.customer.changeCustomerPage(page, pageSize);
265
267
  return result;
266
268
  } catch (error) {
267
- console.error("Failed to change customer page:", error);
269
+ console.error('Failed to change customer page:', error);
268
270
  throw error;
269
271
  }
270
272
  }
273
+
271
274
  /**
272
275
  * 滚动加载更多客户数据 - 数据会追加到现有列表中
273
276
  * @returns 客户列表响应
@@ -278,10 +281,11 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
278
281
  this.core.effects.emit(`${this.name}:onCustomerListUpdate`, result);
279
282
  return result;
280
283
  } catch (error) {
281
- console.error("Failed to load more customers:", error);
284
+ console.error('Failed to load more customers:', error);
282
285
  throw error;
283
286
  }
284
287
  }
288
+
285
289
  /**
286
290
  * 重置并重新开始滚动加载客户数据
287
291
  * @param params 查询参数
@@ -293,10 +297,11 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
293
297
  this.core.effects.emit(`${this.name}:onCustomerListReset`, result);
294
298
  return result;
295
299
  } catch (error) {
296
- console.error("Failed to reset and load customers:", error);
300
+ console.error('Failed to reset and load customers:', error);
297
301
  throw error;
298
302
  }
299
303
  }
304
+
300
305
  /**
301
306
  * 检查是否还有更多客户数据可以加载
302
307
  * @returns 是否还有更多数据
@@ -304,6 +309,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
304
309
  hasMoreCustomers() {
305
310
  return this.store.customer.hasMoreCustomers();
306
311
  }
312
+
307
313
  /**
308
314
  * 获取当前的客户搜索条件
309
315
  * @returns 当前搜索条件
@@ -311,6 +317,7 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
311
317
  getCurrentCustomerSearchParams() {
312
318
  return this.store.customer.getCurrentSearchParams();
313
319
  }
320
+
314
321
  /**
315
322
  * 获取客户列表状态(包含滚动加载相关状态)
316
323
  * @returns 客户状态
@@ -318,104 +325,123 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
318
325
  getCustomerState() {
319
326
  return this.store.customer.getState();
320
327
  }
328
+
321
329
  /**
322
330
  * 全局扫描监听
323
331
  * @param callback 回调
324
332
  */
325
333
  scanGlobalListener(callback) {
326
- const localSearch = (v) => this.store.products.findProductsByCodeOrBarcode(v);
327
- const scanCallback = (0, import_handleScan.handleGlobalScan)(this.request, localSearch);
328
- const safeCallback = (d) => {
334
+ const localSearch = v => this.store.products.findProductsByCodeOrBarcode(v);
335
+ const scanCallback = (0, _handleScan.handleGlobalScan)(this.request, localSearch);
336
+ const safeCallback = d => {
329
337
  try {
330
338
  callback(d);
331
339
  } catch (error) {
332
- console.error("scanGlobalListener传入的回调函数异常", error);
340
+ console.error('scanGlobalListener传入的回调函数异常', error);
333
341
  }
334
342
  };
335
- const listener = { key: "global", callback: safeCallback };
343
+ const listener = {
344
+ key: 'global',
345
+ callback: safeCallback
346
+ };
336
347
  const removeListener = this.scan.addListener(listener, scanCallback);
337
348
  return removeListener;
338
349
  }
350
+
339
351
  /**
340
352
  * 客户扫描监听
341
353
  * @param callback 回调
342
354
  */
343
355
  scanCustomerListener(callback) {
344
- const scanCallback = (0, import_handleScan.handleCustomerScan)();
345
- const safeCallback = (d) => {
356
+ const scanCallback = (0, _handleScan.handleCustomerScan)();
357
+ const safeCallback = d => {
346
358
  try {
347
359
  callback(d);
348
360
  } catch (error) {
349
- console.error("scanCustomerListener传入的回调函数异常", error);
361
+ console.error('scanCustomerListener传入的回调函数异常', error);
350
362
  }
351
363
  };
352
- const listener = { key: "customer", callback: safeCallback };
364
+ const listener = {
365
+ key: 'customer',
366
+ callback: safeCallback
367
+ };
353
368
  const removeListener = this.scan.addListener(listener, scanCallback);
354
369
  return removeListener;
355
370
  }
371
+
356
372
  /**
357
373
  * @title 通用扫描监听
358
374
  * @description 直接将扫描结果返回给调用方
359
375
  * @param callback 回调
360
376
  */
361
377
  scanUniversalListener(callback, key) {
362
- const scanCallback = (0, import_handleScan.handleUniversalScan)();
363
- const safeCallback = (d) => {
378
+ const scanCallback = (0, _handleScan.handleUniversalScan)();
379
+ const safeCallback = d => {
364
380
  try {
365
381
  callback(d);
366
382
  } catch (error) {
367
- console.error(
368
- `scanUniversalListener传入的回调函数异常, key: ${key}`,
369
- error
370
- );
383
+ console.error(`scanUniversalListener传入的回调函数异常, key: ${key}`, error);
371
384
  }
372
385
  };
373
- const listener = { key, callback: safeCallback };
386
+ const listener = {
387
+ key,
388
+ callback: safeCallback
389
+ };
374
390
  const removeListener = this.scan.addListener(listener, scanCallback);
375
391
  return removeListener;
376
392
  }
393
+
377
394
  /**
378
395
  * 调用摄像头
379
396
  * @param data 用户自定义数据
380
397
  */
381
398
  activateCamera(data) {
382
- var _a, _b, _c, _d;
383
- (_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, {
384
- module: "global",
385
- key: "active_native_scanner",
399
+ this.window?.interaction?.utils?.postMessageToApp?.({
400
+ module: 'global',
401
+ key: 'active_native_scanner',
386
402
  data
387
403
  });
388
404
  }
405
+
389
406
  /**
390
407
  * 禁用所有扫描监听
391
408
  */
392
409
  disableAllScanListeners() {
393
410
  this.scan.disableAllListeners();
394
411
  }
412
+
395
413
  /**
396
414
  * 启用所有扫描监听
397
415
  */
398
416
  enableAllScanListeners() {
399
417
  this.scan.enableAllListeners();
400
418
  }
419
+
401
420
  /**
402
421
  * 清空所有扫描监听对应的任务执行队列
403
422
  */
404
423
  clearAllScanListenersTaskQueue() {
405
424
  this.scan.clearTaskQueue();
406
425
  }
426
+
407
427
  /**
408
428
  * 设置其他参数
409
429
  * @param params 参数
410
430
  * @param options 选项
411
431
  */
412
- async setOtherParams(params, { cover = false } = {}) {
432
+ async setOtherParams(params, {
433
+ cover = false
434
+ } = {}) {
413
435
  if (cover) {
414
436
  this.otherParams = params;
415
437
  } else {
416
- this.otherParams = { ...this.otherParams, ...params };
438
+ this.otherParams = {
439
+ ...this.otherParams,
440
+ ...params
441
+ };
417
442
  }
418
443
  }
444
+
419
445
  /**
420
446
  * 获取其他参数
421
447
  * @returns 其他参数
@@ -423,25 +449,24 @@ var BookingTicketImpl = class extends import_BaseModule.BaseModule {
423
449
  async getOtherParams() {
424
450
  return this.otherParams;
425
451
  }
452
+
426
453
  /**
427
454
  * 销毁模块
428
455
  */
429
456
  destroy() {
430
- var _a, _b, _c, _d, _e;
431
- (_a = this.store.cart) == null ? void 0 : _a.destroy();
432
- (_b = this.store.products) == null ? void 0 : _b.destroy();
433
- (_c = this.store.accountList) == null ? void 0 : _c.destroy();
434
- (_d = this.store.customer) == null ? void 0 : _d.destroy();
435
- (_e = this.store.order) == null ? void 0 : _e.destroy();
457
+ this.store.cart?.destroy();
458
+ this.store.products?.destroy();
459
+ this.store.accountList?.destroy();
460
+ this.store.customer?.destroy();
461
+ this.store.order?.destroy();
436
462
  this.core.effects.offByModuleDestroy(this.name);
437
463
  this.core.unregisterModule(this);
464
+ // 清除所有的监听
438
465
  this.scan.removeAllListeners();
439
- import_scanCache.default.clear();
466
+ // 清除scan数据内存缓存
467
+ _scanCache.default.clear();
440
468
  }
441
- };
442
- // Annotate the CommonJS export names for ESM import in node:
443
- 0 && (module.exports = {
444
- BookingTicket,
445
- BookingTicketImpl,
446
- ...require("./types")
447
- });
469
+ }
470
+
471
+ // 导出相关类型和实现
472
+ exports.BookingTicket = exports.BookingTicketImpl = BookingTicketImpl;
@@ -1,72 +1,46 @@
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ "use strict";
18
2
 
19
- // src/solution/BookingTicket/types.ts
20
- var types_exports = {};
21
- __export(types_exports, {
22
- BookingTicketHooks: () => BookingTicketHooks,
23
- createModule: () => createModule
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
24
5
  });
25
- module.exports = __toCommonJS(types_exports);
26
- var import_modules = require("../../modules");
27
- var import_Customer = require("../../modules/Customer");
6
+ exports.BookingTicketHooks = void 0;
7
+ exports.createModule = createModule;
8
+ var _modules = require("../../modules");
9
+ var _Customer = require("../../modules/Customer");
28
10
  function createModule(moduleName, solutionName, name, version) {
29
11
  switch (moduleName) {
30
- case "cart":
31
- return new import_modules.CartModule(
32
- `${solutionName}_${name || moduleName}`,
33
- version
34
- );
35
- case "products":
36
- return new import_modules.ProductList(
37
- `${solutionName}_${name || moduleName}`,
38
- version
39
- );
40
- case "accountList":
41
- return new import_modules.AccountListModule(
42
- `${solutionName}_${name || moduleName}`,
43
- version
44
- );
45
- case "customer":
46
- return new import_Customer.CustomerModule(
47
- `${solutionName}_${name || moduleName}`,
48
- version
49
- );
50
- case "order":
51
- return new import_modules.OrderModule(
52
- `${solutionName}_${name || moduleName}`,
53
- version
54
- );
12
+ case 'cart':
13
+ return new _modules.CartModule(`${solutionName}_${name || moduleName}`, version);
14
+ case 'products':
15
+ return new _modules.ProductList(`${solutionName}_${name || moduleName}`, version);
16
+ case 'accountList':
17
+ return new _modules.AccountListModule(`${solutionName}_${name || moduleName}`, version);
18
+ case 'customer':
19
+ return new _Customer.CustomerModule(`${solutionName}_${name || moduleName}`, version);
20
+ case 'order':
21
+ return new _modules.OrderModule(`${solutionName}_${name || moduleName}`, version);
55
22
  default:
56
23
  throw new Error(`Unknown module type: ${moduleName}`);
57
24
  }
58
25
  }
59
- var BookingTicketHooks = /* @__PURE__ */ ((BookingTicketHooks2) => {
60
- BookingTicketHooks2["onInited"] = "bookingTicket:onInited";
61
- BookingTicketHooks2["onDestroy"] = "bookingTicket:onDestroy";
62
- BookingTicketHooks2["onProductsLoaded"] = "bookingTicket:onProductsLoaded";
63
- BookingTicketHooks2["onCustomerSelected"] = "bookingTicket:onCustomerSelected";
64
- BookingTicketHooks2["onCustomerListUpdate"] = "bookingTicket:onCustomerListUpdate";
65
- BookingTicketHooks2["onCustomerListReset"] = "bookingTicket:onCustomerListReset";
66
- return BookingTicketHooks2;
67
- })(BookingTicketHooks || {});
68
- // Annotate the CommonJS export names for ESM import in node:
69
- 0 && (module.exports = {
70
- BookingTicketHooks,
71
- createModule
72
- });
26
+ let BookingTicketHooks = exports.BookingTicketHooks = /*#__PURE__*/function (BookingTicketHooks) {
27
+ BookingTicketHooks["onInited"] = "bookingTicket:onInited";
28
+ BookingTicketHooks["onDestroy"] = "bookingTicket:onDestroy";
29
+ BookingTicketHooks["onProductsLoaded"] = "bookingTicket:onProductsLoaded";
30
+ BookingTicketHooks["onCustomerSelected"] = "bookingTicket:onCustomerSelected";
31
+ BookingTicketHooks["onCustomerListUpdate"] = "bookingTicket:onCustomerListUpdate";
32
+ BookingTicketHooks["onCustomerListReset"] = "bookingTicket:onCustomerListReset";
33
+ return BookingTicketHooks;
34
+ }({});
35
+ /**
36
+ * 获取客户列表的参数
37
+ */
38
+ /**
39
+ * 客户信息
40
+ */
41
+ /**
42
+ * 加载商品列表的参数
43
+ */
44
+ /**
45
+ * 扫描结果
46
+ */