@pisell/pisellos 2.1.3 → 2.1.5

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 (291) 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/Cart/index.js +1 -1
  9. package/dist/modules/Customer/constants.d.ts +7 -0
  10. package/dist/modules/Customer/constants.js +12 -0
  11. package/dist/modules/Customer/index.d.ts +122 -0
  12. package/dist/modules/Customer/index.js +697 -0
  13. package/dist/modules/Customer/types.d.ts +146 -0
  14. package/dist/modules/Customer/types.js +41 -0
  15. package/dist/modules/Date/index.d.ts +17 -0
  16. package/dist/modules/Date/index.js +92 -4
  17. package/dist/modules/Discount/index.d.ts +1 -0
  18. package/dist/modules/Order/index.d.ts +25 -1
  19. package/dist/modules/Order/index.js +224 -2
  20. package/dist/modules/Order/types.d.ts +45 -0
  21. package/dist/modules/Order/types.js +8 -0
  22. package/dist/modules/Payment/cash.d.ts +19 -0
  23. package/dist/modules/Payment/cash.js +97 -0
  24. package/dist/modules/Payment/cashRecommendationAlgorithm.d.ts +22 -0
  25. package/dist/modules/Payment/cashRecommendationAlgorithm.js +423 -0
  26. package/dist/modules/Payment/eftpos.d.ts +11 -0
  27. package/dist/modules/Payment/eftpos.js +80 -0
  28. package/dist/modules/Payment/index.d.ts +184 -9
  29. package/dist/modules/Payment/index.js +2012 -108
  30. package/dist/modules/Payment/mx51.d.ts +0 -0
  31. package/dist/modules/Payment/mx51.js +0 -0
  32. package/dist/modules/Payment/types.d.ts +750 -30
  33. package/dist/modules/Payment/types.js +236 -12
  34. package/dist/modules/Payment/utils.d.ts +17 -0
  35. package/dist/modules/Payment/utils.js +62 -0
  36. package/dist/modules/Payment/walletpass.d.ts +99 -0
  37. package/dist/modules/Payment/walletpass.js +701 -0
  38. package/dist/modules/Product/index.d.ts +1 -1
  39. package/dist/modules/ProductList/index.d.ts +12 -1
  40. package/dist/modules/ProductList/index.js +27 -3
  41. package/dist/modules/Rules/index.d.ts +2 -0
  42. package/dist/modules/Rules/index.js +39 -17
  43. package/dist/modules/Rules/types.d.ts +1 -0
  44. package/dist/modules/Schedule/index.d.ts +9 -0
  45. package/dist/modules/Schedule/index.js +68 -0
  46. package/dist/modules/index.d.ts +1 -0
  47. package/dist/modules/index.js +1 -0
  48. package/dist/plugins/app-types/app/app.d.ts +83 -0
  49. package/dist/plugins/app-types/app/const.d.ts +4 -0
  50. package/dist/plugins/app-types/app/index.d.ts +14 -0
  51. package/dist/plugins/app-types/applicationManager/application.d.ts +50 -0
  52. package/dist/plugins/app-types/applicationManager/index.d.ts +13 -0
  53. package/dist/plugins/app-types/config.d.ts +3 -0
  54. package/dist/plugins/app-types/cookie/index.d.ts +13 -0
  55. package/dist/plugins/app-types/data/index.d.ts +8 -0
  56. package/dist/plugins/app-types/history/config.d.ts +24 -0
  57. package/dist/plugins/app-types/history/index.d.ts +20 -0
  58. package/dist/plugins/app-types/history/type.d.ts +2 -0
  59. package/dist/plugins/app-types/hooks/index.d.ts +12 -0
  60. package/dist/plugins/app-types/hooks/useDelayedValue/index.d.ts +2 -0
  61. package/dist/plugins/app-types/hooks/useDispatch/index.d.ts +2 -0
  62. package/dist/plugins/app-types/hooks/useLowCode/index.d.ts +13 -0
  63. package/dist/plugins/app-types/hooks/useStore/index.d.ts +6 -0
  64. package/dist/plugins/app-types/index.d.ts +6 -0
  65. package/dist/plugins/app-types/indexDB/index.d.ts +178 -0
  66. package/dist/plugins/app-types/locales/en.d.ts +3 -0
  67. package/dist/plugins/app-types/locales/index.d.ts +37 -0
  68. package/dist/plugins/app-types/locales/original.d.ts +3 -0
  69. package/dist/plugins/app-types/locales/type.d.ts +19 -0
  70. package/dist/plugins/app-types/locales/zh-CN.d.ts +3 -0
  71. package/dist/plugins/app-types/locales/zh-HK.d.ts +3 -0
  72. package/dist/plugins/app-types/logger/feishu.d.ts +11 -0
  73. package/dist/plugins/app-types/logger/index.d.ts +122 -0
  74. package/dist/plugins/app-types/menuManager/hooks.d.ts +17 -0
  75. package/dist/plugins/app-types/menuManager/index.d.ts +28 -0
  76. package/dist/plugins/app-types/models/global.d.ts +32 -0
  77. package/dist/plugins/app-types/models/index.d.ts +45 -0
  78. package/dist/plugins/app-types/models/type.d.ts +2 -0
  79. package/dist/plugins/app-types/package.json +15 -0
  80. package/dist/plugins/app-types/plugin/index.d.ts +0 -0
  81. package/dist/plugins/app-types/pubsub/example.d.ts +5 -0
  82. package/dist/plugins/app-types/pubsub/index.d.ts +63 -0
  83. package/dist/plugins/app-types/request/cache.d.ts +46 -0
  84. package/dist/plugins/app-types/request/cancelToken.d.ts +38 -0
  85. package/dist/plugins/app-types/request/config.d.ts +3 -0
  86. package/dist/plugins/app-types/request/constants.d.ts +2 -0
  87. package/dist/plugins/app-types/request/index.d.ts +24 -0
  88. package/dist/plugins/app-types/request/pisell2Request.d.ts +6 -0
  89. package/dist/plugins/app-types/request/type.d.ts +41 -0
  90. package/dist/plugins/app-types/request/utils.d.ts +46 -0
  91. package/dist/plugins/app-types/routes/config.d.ts +7 -0
  92. package/dist/plugins/app-types/routes/index.d.ts +28 -0
  93. package/dist/plugins/app-types/socket/components/SocketMonitorPage.d.ts +6 -0
  94. package/dist/plugins/app-types/socket/components/index.d.ts +2 -0
  95. package/dist/plugins/app-types/socket/constants.d.ts +33 -0
  96. package/dist/plugins/app-types/socket/events.d.ts +31 -0
  97. package/dist/plugins/app-types/socket/heartbeat.d.ts +66 -0
  98. package/dist/plugins/app-types/socket/index.d.ts +61 -0
  99. package/dist/plugins/app-types/socket/monitor.d.ts +169 -0
  100. package/dist/plugins/app-types/socket/reconnect.d.ts +61 -0
  101. package/dist/plugins/app-types/socket/socket.d.ts +129 -0
  102. package/dist/plugins/app-types/socket/types.d.ts +85 -0
  103. package/dist/plugins/app-types/storage/index.d.ts +17 -0
  104. package/dist/plugins/app-types/tasks/index.d.ts +77 -0
  105. package/dist/plugins/app-types/tasks/type.d.ts +62 -0
  106. package/dist/plugins/app-types/tasks/useTasks.d.ts +5 -0
  107. package/dist/plugins/app-types/type.d.ts +2 -0
  108. package/dist/plugins/app-types/variables/VariablesProvider.d.ts +7 -0
  109. package/dist/plugins/app-types/variables/config.d.ts +3 -0
  110. package/dist/plugins/app-types/variables/index.d.ts +6 -0
  111. package/dist/plugins/app-types/variables/type.d.ts +2 -0
  112. package/dist/plugins/app-types/website/index.d.ts +6 -0
  113. package/dist/plugins/app.d.ts +8 -0
  114. package/dist/plugins/app.js +1 -0
  115. package/dist/plugins/window.d.ts +1 -0
  116. package/dist/solution/BookingByStep/index.d.ts +1 -1
  117. package/dist/solution/BookingByStep/index.js +1 -1
  118. package/dist/solution/BookingTicket/index.d.ts +180 -0
  119. package/dist/solution/BookingTicket/index.js +689 -0
  120. package/dist/solution/BookingTicket/types.d.ts +68 -0
  121. package/dist/solution/BookingTicket/types.js +43 -0
  122. package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +22 -0
  123. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +159 -0
  124. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +22 -0
  125. package/dist/solution/BookingTicket/utils/scan/handleScan.js +189 -0
  126. package/dist/solution/BookingTicket/utils/scan/index.d.ts +81 -0
  127. package/dist/solution/BookingTicket/utils/scan/index.js +285 -0
  128. package/dist/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
  129. package/dist/solution/BookingTicket/utils/scan/scanCache.js +305 -0
  130. package/dist/solution/Checkout/appointmentDemo.json +1 -0
  131. package/dist/solution/Checkout/index.d.ts +509 -0
  132. package/dist/solution/Checkout/index.js +4874 -0
  133. package/dist/solution/Checkout/types.d.ts +923 -0
  134. package/dist/solution/Checkout/types.js +148 -0
  135. package/dist/solution/Checkout/utils/index.d.ts +117 -0
  136. package/dist/solution/Checkout/utils/index.js +549 -0
  137. package/dist/solution/ShopDiscount/index.d.ts +4 -9
  138. package/dist/solution/ShopDiscount/index.js +106 -54
  139. package/dist/solution/ShopDiscount/types.d.ts +10 -1
  140. package/dist/solution/index.d.ts +2 -0
  141. package/dist/solution/index.js +3 -1
  142. package/dist/types/index.d.ts +3 -1
  143. package/dist/utils/task.d.ts +40 -0
  144. package/dist/utils/task.js +171 -0
  145. package/dist/utils/watch.d.ts +102 -0
  146. package/dist/utils/watch.js +294 -0
  147. package/lib/core/index.js +1 -1
  148. package/lib/effects/index.d.ts +4 -3
  149. package/lib/effects/index.js +4 -1
  150. package/lib/modules/AccountList/index.d.ts +7 -1
  151. package/lib/modules/AccountList/index.js +27 -0
  152. package/lib/modules/AccountList/types.d.ts +28 -0
  153. package/lib/modules/Cart/index.js +1 -1
  154. package/lib/modules/Customer/constants.d.ts +7 -0
  155. package/lib/modules/Customer/constants.js +39 -0
  156. package/lib/modules/Customer/index.d.ts +122 -0
  157. package/lib/modules/Customer/index.js +440 -0
  158. package/lib/modules/Customer/types.d.ts +146 -0
  159. package/lib/modules/Customer/types.js +37 -0
  160. package/lib/modules/Date/index.d.ts +17 -0
  161. package/lib/modules/Date/index.js +64 -0
  162. package/lib/modules/Discount/index.d.ts +1 -0
  163. package/lib/modules/Order/index.d.ts +25 -1
  164. package/lib/modules/Order/index.js +182 -0
  165. package/lib/modules/Order/types.d.ts +45 -0
  166. package/lib/modules/Payment/cash.d.ts +19 -0
  167. package/lib/modules/Payment/cash.js +64 -0
  168. package/lib/modules/Payment/cashRecommendationAlgorithm.d.ts +22 -0
  169. package/lib/modules/Payment/cashRecommendationAlgorithm.js +342 -0
  170. package/lib/modules/Payment/eftpos.d.ts +11 -0
  171. package/lib/modules/Payment/eftpos.js +51 -0
  172. package/lib/modules/Payment/index.d.ts +184 -9
  173. package/lib/modules/Payment/index.js +1044 -50
  174. package/lib/modules/Payment/mx51.d.ts +0 -0
  175. package/lib/modules/Payment/mx51.js +0 -0
  176. package/lib/modules/Payment/types.d.ts +750 -30
  177. package/lib/modules/Payment/types.js +79 -6
  178. package/lib/modules/Payment/utils.d.ts +17 -0
  179. package/lib/modules/Payment/utils.js +67 -0
  180. package/lib/modules/Payment/walletpass.d.ts +99 -0
  181. package/lib/modules/Payment/walletpass.js +468 -0
  182. package/lib/modules/Product/index.d.ts +1 -1
  183. package/lib/modules/ProductList/index.d.ts +12 -1
  184. package/lib/modules/ProductList/index.js +29 -2
  185. package/lib/modules/Rules/index.d.ts +2 -0
  186. package/lib/modules/Rules/index.js +32 -15
  187. package/lib/modules/Rules/types.d.ts +1 -0
  188. package/lib/modules/Schedule/index.d.ts +9 -0
  189. package/lib/modules/Schedule/index.js +51 -0
  190. package/lib/modules/index.d.ts +1 -0
  191. package/lib/modules/index.js +2 -0
  192. package/lib/plugins/app-types/app/app.d.ts +83 -0
  193. package/lib/plugins/app-types/app/const.d.ts +4 -0
  194. package/lib/plugins/app-types/app/index.d.ts +14 -0
  195. package/lib/plugins/app-types/applicationManager/application.d.ts +50 -0
  196. package/lib/plugins/app-types/applicationManager/index.d.ts +13 -0
  197. package/lib/plugins/app-types/config.d.ts +3 -0
  198. package/lib/plugins/app-types/cookie/index.d.ts +13 -0
  199. package/lib/plugins/app-types/data/index.d.ts +8 -0
  200. package/lib/plugins/app-types/history/config.d.ts +24 -0
  201. package/lib/plugins/app-types/history/index.d.ts +20 -0
  202. package/lib/plugins/app-types/history/type.d.ts +2 -0
  203. package/lib/plugins/app-types/hooks/index.d.ts +12 -0
  204. package/lib/plugins/app-types/hooks/useDelayedValue/index.d.ts +2 -0
  205. package/lib/plugins/app-types/hooks/useDispatch/index.d.ts +2 -0
  206. package/lib/plugins/app-types/hooks/useLowCode/index.d.ts +13 -0
  207. package/lib/plugins/app-types/hooks/useStore/index.d.ts +6 -0
  208. package/lib/plugins/app-types/index.d.ts +6 -0
  209. package/lib/plugins/app-types/indexDB/index.d.ts +178 -0
  210. package/lib/plugins/app-types/locales/en.d.ts +3 -0
  211. package/lib/plugins/app-types/locales/index.d.ts +37 -0
  212. package/lib/plugins/app-types/locales/original.d.ts +3 -0
  213. package/lib/plugins/app-types/locales/type.d.ts +19 -0
  214. package/lib/plugins/app-types/locales/zh-CN.d.ts +3 -0
  215. package/lib/plugins/app-types/locales/zh-HK.d.ts +3 -0
  216. package/lib/plugins/app-types/logger/feishu.d.ts +11 -0
  217. package/lib/plugins/app-types/logger/index.d.ts +122 -0
  218. package/lib/plugins/app-types/menuManager/hooks.d.ts +17 -0
  219. package/lib/plugins/app-types/menuManager/index.d.ts +28 -0
  220. package/lib/plugins/app-types/models/global.d.ts +32 -0
  221. package/lib/plugins/app-types/models/index.d.ts +45 -0
  222. package/lib/plugins/app-types/models/type.d.ts +2 -0
  223. package/lib/plugins/app-types/package.json +15 -0
  224. package/lib/plugins/app-types/plugin/index.d.ts +0 -0
  225. package/lib/plugins/app-types/pubsub/example.d.ts +5 -0
  226. package/lib/plugins/app-types/pubsub/index.d.ts +63 -0
  227. package/lib/plugins/app-types/request/cache.d.ts +46 -0
  228. package/lib/plugins/app-types/request/cancelToken.d.ts +38 -0
  229. package/lib/plugins/app-types/request/config.d.ts +3 -0
  230. package/lib/plugins/app-types/request/constants.d.ts +2 -0
  231. package/lib/plugins/app-types/request/index.d.ts +24 -0
  232. package/lib/plugins/app-types/request/pisell2Request.d.ts +6 -0
  233. package/lib/plugins/app-types/request/type.d.ts +41 -0
  234. package/lib/plugins/app-types/request/utils.d.ts +46 -0
  235. package/lib/plugins/app-types/routes/config.d.ts +7 -0
  236. package/lib/plugins/app-types/routes/index.d.ts +28 -0
  237. package/lib/plugins/app-types/socket/components/SocketMonitorPage.d.ts +6 -0
  238. package/lib/plugins/app-types/socket/components/index.d.ts +2 -0
  239. package/lib/plugins/app-types/socket/constants.d.ts +33 -0
  240. package/lib/plugins/app-types/socket/events.d.ts +31 -0
  241. package/lib/plugins/app-types/socket/heartbeat.d.ts +66 -0
  242. package/lib/plugins/app-types/socket/index.d.ts +61 -0
  243. package/lib/plugins/app-types/socket/monitor.d.ts +169 -0
  244. package/lib/plugins/app-types/socket/reconnect.d.ts +61 -0
  245. package/lib/plugins/app-types/socket/socket.d.ts +129 -0
  246. package/lib/plugins/app-types/socket/types.d.ts +85 -0
  247. package/lib/plugins/app-types/storage/index.d.ts +17 -0
  248. package/lib/plugins/app-types/tasks/index.d.ts +77 -0
  249. package/lib/plugins/app-types/tasks/type.d.ts +62 -0
  250. package/lib/plugins/app-types/tasks/useTasks.d.ts +5 -0
  251. package/lib/plugins/app-types/type.d.ts +2 -0
  252. package/lib/plugins/app-types/variables/VariablesProvider.d.ts +7 -0
  253. package/lib/plugins/app-types/variables/config.d.ts +3 -0
  254. package/lib/plugins/app-types/variables/index.d.ts +6 -0
  255. package/lib/plugins/app-types/variables/type.d.ts +2 -0
  256. package/lib/plugins/app-types/website/index.d.ts +6 -0
  257. package/lib/plugins/app.d.ts +8 -0
  258. package/lib/plugins/app.js +17 -0
  259. package/lib/plugins/window.d.ts +1 -0
  260. package/lib/solution/BookingByStep/index.d.ts +1 -1
  261. package/lib/solution/BookingByStep/index.js +1 -2
  262. package/lib/solution/BookingTicket/index.d.ts +180 -0
  263. package/lib/solution/BookingTicket/index.js +420 -0
  264. package/lib/solution/BookingTicket/types.d.ts +68 -0
  265. package/lib/solution/BookingTicket/types.js +72 -0
  266. package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +22 -0
  267. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +117 -0
  268. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +22 -0
  269. package/lib/solution/BookingTicket/utils/scan/handleScan.js +132 -0
  270. package/lib/solution/BookingTicket/utils/scan/index.d.ts +81 -0
  271. package/lib/solution/BookingTicket/utils/scan/index.js +210 -0
  272. package/lib/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
  273. package/lib/solution/BookingTicket/utils/scan/scanCache.js +231 -0
  274. package/lib/solution/Checkout/appointmentDemo.json +1 -0
  275. package/lib/solution/Checkout/index.d.ts +509 -0
  276. package/lib/solution/Checkout/index.js +3002 -0
  277. package/lib/solution/Checkout/types.d.ts +923 -0
  278. package/lib/solution/Checkout/types.js +87 -0
  279. package/lib/solution/Checkout/utils/index.d.ts +117 -0
  280. package/lib/solution/Checkout/utils/index.js +403 -0
  281. package/lib/solution/ShopDiscount/index.d.ts +4 -9
  282. package/lib/solution/ShopDiscount/index.js +41 -13
  283. package/lib/solution/ShopDiscount/types.d.ts +10 -1
  284. package/lib/solution/index.d.ts +2 -0
  285. package/lib/solution/index.js +5 -1
  286. package/lib/types/index.d.ts +3 -1
  287. package/lib/utils/task.d.ts +40 -0
  288. package/lib/utils/task.js +109 -0
  289. package/lib/utils/watch.d.ts +102 -0
  290. package/lib/utils/watch.js +217 -0
  291. package/package.json +4 -2
@@ -38,6 +38,7 @@ var import_types = require("./types");
38
38
  var import_Discount = require("../../modules/Discount");
39
39
  var import_Rules = require("../../modules/Rules");
40
40
  var import_decimal = __toESM(require("decimal.js"));
41
+ var import_lodash_es = require("lodash-es");
41
42
  var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
42
43
  constructor(name, version) {
43
44
  super(name, version);
@@ -49,7 +50,8 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
49
50
  customer: null,
50
51
  productList: [],
51
52
  discount: null,
52
- rules: null
53
+ rules: null,
54
+ originalDiscountList: []
53
55
  };
54
56
  }
55
57
  // =========== 生命周期方法 ===========
@@ -172,27 +174,34 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
172
174
  };
173
175
  }
174
176
  // 设置优惠券使用状态
175
- setDiscountSelected({
176
- discountId,
177
- isSelected
178
- }) {
177
+ setDiscountSelected(params) {
179
178
  const discountList = this.getDiscountList();
179
+ const selectionOperations = [];
180
+ selectionOperations.push({
181
+ discountId: params.discountId,
182
+ isSelected: params.isSelected
183
+ });
184
+ if (params.selectedList && params.selectedList.length > 0) {
185
+ selectionOperations.push(...params.selectedList);
186
+ }
187
+ const selectionMap = /* @__PURE__ */ new Map();
188
+ selectionOperations.forEach((operation) => {
189
+ selectionMap.set(operation.discountId, operation.isSelected);
190
+ });
180
191
  const newDiscountList = discountList.map((discount) => {
181
- if (discount.id === discountId) {
192
+ if (selectionMap.has(discount.id)) {
193
+ const targetIsSelected = selectionMap.get(discount.id);
182
194
  return {
183
195
  ...discount,
184
- isSelected,
196
+ isSelected: targetIsSelected,
185
197
  // 手动设置不使用
186
- isManualSelect: !isSelected
198
+ isManualSelect: !targetIsSelected
187
199
  };
188
200
  }
189
201
  return { ...discount, isManualSelect: !(discount == null ? void 0 : discount.isSelected) };
190
202
  });
191
203
  this.setDiscountList(newDiscountList);
192
- return this.calcDiscount(this.store.productList || [], {
193
- discountId,
194
- isSelected
195
- });
204
+ return this.calcDiscount(this.store.productList || [], params);
196
205
  }
197
206
  setProductList(productList) {
198
207
  this.store.productList = productList;
@@ -240,6 +249,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
240
249
  };
241
250
  if (isAvailable) {
242
251
  this.setDiscountList(newDiscountList || []);
252
+ this.store.originalDiscountList = newDiscountList || [];
243
253
  this.setProductList(newProductList || []);
244
254
  if (this.isWalkIn() && resultDiscountList.length && ((_b = this.options.otherParams) == null ? void 0 : _b.platform) === "shop") {
245
255
  await this.getCustomerWallet(
@@ -337,7 +347,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
337
347
  var _a2;
338
348
  const targetProduct = productList.find((n) => n.id === id);
339
349
  const product = (_a2 = this.hooks) == null ? void 0 : _a2.getProduct(targetProduct);
340
- return Number(product == null ? void 0 : product.total) === 0 && (Number(product == null ? void 0 : product.origin_total) === 0 || !(product == null ? void 0 : product.origin_total));
350
+ return Number(product == null ? void 0 : product.total) <= 0 && (Number(product == null ? void 0 : product.origin_total) <= 0 || !(product == null ? void 0 : product.origin_total)) || (0, import_lodash_es.isBoolean)(product == null ? void 0 : product.vouchersApplicable) && !(product == null ? void 0 : product.vouchersApplicable);
341
351
  };
342
352
  const allUsedProductIds = newDiscountList.map((n) => {
343
353
  var _a2;
@@ -387,6 +397,23 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
387
397
  console.error("[ShopDiscount] 获取客户钱包信息出错:", error);
388
398
  }
389
399
  }
400
+ async bestDiscount(cb) {
401
+ var _a;
402
+ const newDiscountList = this.store.originalDiscountList;
403
+ this.setDiscountList(newDiscountList);
404
+ if ((_a = this.store.productList) == null ? void 0 : _a.length) {
405
+ const result = this.calcDiscount(this.store.productList);
406
+ cb == null ? void 0 : cb(result);
407
+ await this.core.effects.emit(
408
+ import_types.ShopDiscountHooks.onLoadPrepareCalcResult,
409
+ result
410
+ );
411
+ }
412
+ await this.core.effects.emit(
413
+ import_types.ShopDiscountHooks.onLoadDiscountList,
414
+ newDiscountList
415
+ );
416
+ }
390
417
  // 加载准备配置
391
418
  async loadPrepareConfig(params) {
392
419
  var _a, _b, _c, _d;
@@ -404,6 +431,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
404
431
  const scanDiscountIds = scanDiscount.map((n) => n.id);
405
432
  const newGoodPassList = goodPassList == null ? void 0 : goodPassList.filter((n) => !scanDiscountIds.includes(n.id));
406
433
  const newDiscountList = [...scanDiscount, ...newGoodPassList || []];
434
+ this.store.originalDiscountList = newDiscountList;
407
435
  this.setDiscountList(newDiscountList || []);
408
436
  if ((_d = this.store.productList) == null ? void 0 : _d.length) {
409
437
  const result = this.calcDiscount(this.store.productList);
@@ -1,4 +1,4 @@
1
- import { DiscountModule } from '../../modules/Discount';
1
+ import { DiscountModule, Discount } from '../../modules/Discount';
2
2
  import { RulesModule } from '../../modules/Rules';
3
3
  export declare enum ShopDiscountHooks {
4
4
  onInited = "shopDiscount:onInited",
@@ -22,4 +22,13 @@ export interface ShopDiscountState {
22
22
  discount: DiscountModule | null;
23
23
  rules: RulesModule | null;
24
24
  productList: Record<string, any>[];
25
+ originalDiscountList: Discount[];
26
+ }
27
+ export interface SetDiscountSelectedParams {
28
+ discountId: number;
29
+ isSelected: boolean;
30
+ selectedList?: {
31
+ discountId: number;
32
+ isSelected: boolean;
33
+ }[];
25
34
  }
@@ -1,3 +1,5 @@
1
1
  export * from './BuyTickets';
2
2
  export * from './BookingByStep';
3
+ export * from './BookingTicket';
3
4
  export * from './ShopDiscount';
5
+ export * from './Checkout';
@@ -18,10 +18,14 @@ var solution_exports = {};
18
18
  module.exports = __toCommonJS(solution_exports);
19
19
  __reExport(solution_exports, require("./BuyTickets"), module.exports);
20
20
  __reExport(solution_exports, require("./BookingByStep"), module.exports);
21
+ __reExport(solution_exports, require("./BookingTicket"), module.exports);
21
22
  __reExport(solution_exports, require("./ShopDiscount"), module.exports);
23
+ __reExport(solution_exports, require("./Checkout"), module.exports);
22
24
  // Annotate the CommonJS export names for ESM import in node:
23
25
  0 && (module.exports = {
24
26
  ...require("./BuyTickets"),
25
27
  ...require("./BookingByStep"),
26
- ...require("./ShopDiscount")
28
+ ...require("./BookingTicket"),
29
+ ...require("./ShopDiscount"),
30
+ ...require("./Checkout")
27
31
  });
@@ -38,7 +38,9 @@ export interface PisellCore {
38
38
  getModuleExports: <T = any>(name: string) => T | null;
39
39
  hasModule: (name: string) => boolean;
40
40
  effects: {
41
- on: (event: string, callback: (payload: any) => void) => void;
41
+ on: (event: string, callback: (payload: any) => void) => () => void;
42
+ once: (event: string, callback: (payload: any) => void) => () => void;
43
+ off: (event: string, callback: (payload: any) => void) => void;
42
44
  emit: (event: string, payload: any, value?: any) => Promise<{
43
45
  status: boolean;
44
46
  data: any;
@@ -0,0 +1,40 @@
1
+ type Action = (...args: any[]) => Promise<any>;
2
+ type Task = {
3
+ uuid: string;
4
+ type: string;
5
+ actionParams?: Record<string, any>;
6
+ };
7
+ declare class Tasks {
8
+ private actions;
9
+ private taskQueue;
10
+ isRunning: boolean;
11
+ constructor(actions?: Map<string, Action>);
12
+ /**
13
+ * 清空所有任务
14
+ */
15
+ clear(): void;
16
+ /**
17
+ * 清空任务执行队列
18
+ */
19
+ clearTaskQueue(): void;
20
+ /**
21
+ * 添加action
22
+ * @param name action名称
23
+ * @param action action函数
24
+ */
25
+ addAction(name: string, action: Action): void;
26
+ /**
27
+ * 添加任务
28
+ * @param task 任务
29
+ */
30
+ addTask(task: Task): void;
31
+ /**
32
+ * 执行任务
33
+ */
34
+ run(): Promise<void>;
35
+ /**
36
+ * 判定当前的任务是否依然存在
37
+ */
38
+ isTaskExist(uuid: string): boolean;
39
+ }
40
+ export default Tasks;
@@ -0,0 +1,109 @@
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);
18
+
19
+ // src/utils/task.ts
20
+ var task_exports = {};
21
+ __export(task_exports, {
22
+ default: () => task_default
23
+ });
24
+ module.exports = __toCommonJS(task_exports);
25
+ var Tasks = class {
26
+ constructor(actions) {
27
+ this.actions = /* @__PURE__ */ new Map();
28
+ this.taskQueue = [];
29
+ this.isRunning = false;
30
+ if (actions) {
31
+ this.actions = actions;
32
+ }
33
+ }
34
+ /**
35
+ * 清空所有任务
36
+ */
37
+ clear() {
38
+ this.actions.clear();
39
+ this.taskQueue = [];
40
+ this.isRunning = false;
41
+ }
42
+ /**
43
+ * 清空任务执行队列
44
+ */
45
+ clearTaskQueue() {
46
+ this.taskQueue = [];
47
+ this.isRunning = false;
48
+ }
49
+ /**
50
+ * 添加action
51
+ * @param name action名称
52
+ * @param action action函数
53
+ */
54
+ addAction(name, action) {
55
+ this.actions.set(name, action);
56
+ }
57
+ /**
58
+ * 添加任务
59
+ * @param task 任务
60
+ */
61
+ addTask(task) {
62
+ this.taskQueue.push(task);
63
+ this.run();
64
+ }
65
+ /**
66
+ * 执行任务
67
+ */
68
+ async run() {
69
+ var _a;
70
+ if (this.isRunning) {
71
+ return;
72
+ }
73
+ if (this.taskQueue.length === 0) {
74
+ this.isRunning = false;
75
+ return;
76
+ }
77
+ this.isRunning = true;
78
+ while (this.taskQueue.length > 0) {
79
+ const task = (_a = this.taskQueue) == null ? void 0 : _a[0];
80
+ if (!task) {
81
+ this.isRunning = false;
82
+ return;
83
+ }
84
+ const action = this.actions.get(task.type);
85
+ if (action) {
86
+ try {
87
+ await action({ ...(task == null ? void 0 : task.actionParams) || {}, uuid: task == null ? void 0 : task.uuid });
88
+ console.log("task_success>>>>>>>", task);
89
+ } catch (error) {
90
+ console.error("task_error>>>>>>>", error);
91
+ } finally {
92
+ const _task = this.taskQueue.shift();
93
+ console.log("task_shift>>>>>>>", _task);
94
+ }
95
+ } else {
96
+ const _task = this.taskQueue.shift();
97
+ console.log("task_action_not_found>>>>>>>", _task);
98
+ }
99
+ }
100
+ this.isRunning = false;
101
+ }
102
+ /**
103
+ * 判定当前的任务是否依然存在
104
+ */
105
+ isTaskExist(uuid) {
106
+ return this.taskQueue.some((task) => (task == null ? void 0 : task.uuid) === uuid);
107
+ }
108
+ };
109
+ var task_default = Tasks;
@@ -0,0 +1,102 @@
1
+ /**
2
+ * 监听模块
3
+ *
4
+ */
5
+ export type WatchEventCallback = (...args: any[]) => void;
6
+ export type WatchEventItem = {
7
+ key: string;
8
+ callback: WatchEventCallback;
9
+ };
10
+ export interface WatchEventSubscription {
11
+ unsubscribe: () => void;
12
+ }
13
+ declare class Watch {
14
+ private events;
15
+ private enableListMap;
16
+ /**
17
+ * 订阅事件
18
+ * @param event 事件名称
19
+ * @param callback 回调函数
20
+ * @returns 订阅对象,可用于取消订阅
21
+ */
22
+ subscribe(watchKey: string, event: WatchEventItem): WatchEventSubscription;
23
+ /**
24
+ * 启用事件
25
+ * @param watchKey 监听的key
26
+ * @param event 事件名称
27
+ */
28
+ enableEvent(watchKey: string, eventKey: string): void;
29
+ /**
30
+ * 禁用某个事件
31
+ * @param watchKey 监听的key
32
+ * @param eventKey 事件名称
33
+ */
34
+ disableEvent(watchKey: string, eventKey: string): void;
35
+ /**
36
+ * 冻结某个监听下的所有事件
37
+ * @param watchKey 监听的key
38
+ */
39
+ disabledAllEventByWatchKey(watchKey: string): void;
40
+ /**
41
+ * 启用某个监听下的所有事件
42
+ * @param watchKey 监听的key
43
+ */
44
+ enableAllEventByWatchKey(watchKey: string): void;
45
+ /**
46
+ * 取消订阅事件
47
+ * @param event 事件名称
48
+ * @param callback 回调函数
49
+ * @returns 是否成功取消订阅
50
+ */
51
+ unsubscribe(watchKey: string, event: WatchEventItem): void;
52
+ /**
53
+ * 发布事件
54
+ * @param event 事件名称
55
+ * @param args 事件参数
56
+ */
57
+ publish(watchKey: string, ...args: any[]): void;
58
+ /**
59
+ * 根据事件名称发布事件
60
+ * @param watchKey 监听的key
61
+ * @param eventKey 事件名称
62
+ * @param args 事件参数
63
+ */
64
+ publishByEventKey(watchKey: string, eventKey: string, ...args: any[]): void;
65
+ /**
66
+ * 获取最后一个启用的事件
67
+ * @param watchKey 监听的key
68
+ * @returns 最后一个启用的事件
69
+ */
70
+ getLastEnableEventKey(watchKey: string): WatchEventItem['key'] | undefined;
71
+ /**
72
+ * 移除某个事件的所有订阅
73
+ * @param event 事件名称
74
+ * @returns 是否成功移除
75
+ */
76
+ clearEvent(watchKey: string): void;
77
+ /**
78
+ * 移除所有事件订阅
79
+ */
80
+ clearAllEvents(): void;
81
+ /**
82
+ * 获取事件的订阅数量
83
+ * @param event 事件名称
84
+ * @returns 订阅数量
85
+ */
86
+ getSubscriberCount(event: string): number;
87
+ /**
88
+ * 检查事件是否有订阅者
89
+ * @param event 事件名称
90
+ * @returns 是否有订阅者
91
+ */
92
+ hasSubscribers(event: string): boolean;
93
+ /**
94
+ * 一次性订阅事件,事件触发后自动取消订阅
95
+ * @param event 事件名称
96
+ * @param callback 回调函数
97
+ * @returns 订阅对象,可用于取消订阅
98
+ */
99
+ once(watchKey: string, event: WatchEventItem): WatchEventSubscription;
100
+ }
101
+ declare const watch: Watch;
102
+ export default watch;
@@ -0,0 +1,217 @@
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);
18
+
19
+ // src/utils/watch.ts
20
+ var watch_exports = {};
21
+ __export(watch_exports, {
22
+ default: () => watch_default
23
+ });
24
+ module.exports = __toCommonJS(watch_exports);
25
+ var Watch = class {
26
+ constructor() {
27
+ // 监听列表
28
+ this.events = /* @__PURE__ */ new Map();
29
+ // 启用列表 - 使用数组保持顺序
30
+ this.enableListMap = /* @__PURE__ */ new Map();
31
+ }
32
+ /**
33
+ * 订阅事件
34
+ * @param event 事件名称
35
+ * @param callback 回调函数
36
+ * @returns 订阅对象,可用于取消订阅
37
+ */
38
+ subscribe(watchKey, event) {
39
+ if (!this.events.has(watchKey)) {
40
+ this.events.set(watchKey, /* @__PURE__ */ new Map());
41
+ }
42
+ const callbacks = this.events.get(watchKey);
43
+ callbacks.set(event.key, event.callback);
44
+ this.enableEvent(watchKey, event.key);
45
+ return {
46
+ // 取消订阅
47
+ unsubscribe: () => {
48
+ this.unsubscribe(watchKey, event);
49
+ }
50
+ };
51
+ }
52
+ /**
53
+ * 启用事件
54
+ * @param watchKey 监听的key
55
+ * @param event 事件名称
56
+ */
57
+ enableEvent(watchKey, eventKey) {
58
+ const enableList = this.enableListMap.get(watchKey);
59
+ if (enableList) {
60
+ if (enableList.includes(eventKey)) {
61
+ return;
62
+ }
63
+ enableList.push(eventKey);
64
+ } else {
65
+ this.enableListMap.set(watchKey, [eventKey]);
66
+ }
67
+ }
68
+ /**
69
+ * 禁用某个事件
70
+ * @param watchKey 监听的key
71
+ * @param eventKey 事件名称
72
+ */
73
+ disableEvent(watchKey, eventKey) {
74
+ const enableList = this.enableListMap.get(watchKey);
75
+ if (enableList) {
76
+ const index = enableList.indexOf(eventKey);
77
+ if (index !== -1) {
78
+ enableList.splice(index);
79
+ }
80
+ }
81
+ }
82
+ /**
83
+ * 冻结某个监听下的所有事件
84
+ * @param watchKey 监听的key
85
+ */
86
+ disabledAllEventByWatchKey(watchKey) {
87
+ this.enableListMap.set(watchKey, []);
88
+ }
89
+ /**
90
+ * 启用某个监听下的所有事件
91
+ * @param watchKey 监听的key
92
+ */
93
+ enableAllEventByWatchKey(watchKey) {
94
+ var _a;
95
+ this.enableListMap.set(
96
+ watchKey,
97
+ Array.from(((_a = this.events.get(watchKey)) == null ? void 0 : _a.keys()) || [])
98
+ );
99
+ }
100
+ /**
101
+ * 取消订阅事件
102
+ * @param event 事件名称
103
+ * @param callback 回调函数
104
+ * @returns 是否成功取消订阅
105
+ */
106
+ unsubscribe(watchKey, event) {
107
+ const callbacks = this.events.get(watchKey);
108
+ if (!callbacks) {
109
+ return;
110
+ }
111
+ this.disableEvent(watchKey, event.key);
112
+ callbacks.delete(event.key);
113
+ return;
114
+ }
115
+ /**
116
+ * 发布事件
117
+ * @param event 事件名称
118
+ * @param args 事件参数
119
+ */
120
+ publish(watchKey, ...args) {
121
+ var _a;
122
+ const callbacks = this.events.get(watchKey);
123
+ if (!callbacks) {
124
+ return;
125
+ }
126
+ const enableList = this.enableListMap.get(watchKey);
127
+ if (!enableList || enableList.length === 0) {
128
+ return;
129
+ }
130
+ const lastCallbackKey = enableList.at(-1);
131
+ if (lastCallbackKey) {
132
+ try {
133
+ (_a = callbacks.get(lastCallbackKey)) == null ? void 0 : _a(...args);
134
+ } catch (error) {
135
+ console.error(`执行事件"${watchKey}"的回调时出错:`, error);
136
+ }
137
+ }
138
+ }
139
+ /**
140
+ * 根据事件名称发布事件
141
+ * @param watchKey 监听的key
142
+ * @param eventKey 事件名称
143
+ * @param args 事件参数
144
+ */
145
+ publishByEventKey(watchKey, eventKey, ...args) {
146
+ var _a;
147
+ const callbacks = this.events.get(watchKey);
148
+ if (!callbacks) {
149
+ return;
150
+ }
151
+ (_a = callbacks.get(eventKey)) == null ? void 0 : _a(...args);
152
+ }
153
+ /**
154
+ * 获取最后一个启用的事件
155
+ * @param watchKey 监听的key
156
+ * @returns 最后一个启用的事件
157
+ */
158
+ getLastEnableEventKey(watchKey) {
159
+ const enableList = this.enableListMap.get(watchKey);
160
+ console.log("enableList", enableList);
161
+ if (!enableList) {
162
+ return void 0;
163
+ }
164
+ return enableList.at(-1) || void 0;
165
+ }
166
+ /**
167
+ * 移除某个事件的所有订阅
168
+ * @param event 事件名称
169
+ * @returns 是否成功移除
170
+ */
171
+ clearEvent(watchKey) {
172
+ this.disabledAllEventByWatchKey(watchKey);
173
+ this.events.delete(watchKey);
174
+ }
175
+ /**
176
+ * 移除所有事件订阅
177
+ */
178
+ clearAllEvents() {
179
+ this.events.clear();
180
+ this.enableListMap.clear();
181
+ }
182
+ /**
183
+ * 获取事件的订阅数量
184
+ * @param event 事件名称
185
+ * @returns 订阅数量
186
+ */
187
+ getSubscriberCount(event) {
188
+ const callbacks = this.events.get(event);
189
+ return callbacks ? callbacks.size : 0;
190
+ }
191
+ /**
192
+ * 检查事件是否有订阅者
193
+ * @param event 事件名称
194
+ * @returns 是否有订阅者
195
+ */
196
+ hasSubscribers(event) {
197
+ return this.getSubscriberCount(event) > 0;
198
+ }
199
+ /**
200
+ * 一次性订阅事件,事件触发后自动取消订阅
201
+ * @param event 事件名称
202
+ * @param callback 回调函数
203
+ * @returns 订阅对象,可用于取消订阅
204
+ */
205
+ once(watchKey, event) {
206
+ const wrappedCallback = (...args) => {
207
+ this.unsubscribe(watchKey, { key: event.key, callback: wrappedCallback });
208
+ event.callback(...args);
209
+ };
210
+ return this.subscribe(watchKey, {
211
+ key: event.key,
212
+ callback: wrappedCallback
213
+ });
214
+ }
215
+ };
216
+ var watch = new Watch();
217
+ var watch_default = watch;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "2.1.3",
4
+ "version": "2.1.5",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -12,6 +12,7 @@
12
12
  "scripts": {
13
13
  "build": "father build",
14
14
  "dev": "father dev --watch",
15
+ "push": "yalc push --replace",
15
16
  "test": "vitest",
16
17
  "lint": "eslint src --ext .ts",
17
18
  "format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md}\"",
@@ -54,6 +55,7 @@
54
55
  "@typescript-eslint/parser": "^5.57.1",
55
56
  "axios": "1.7.2",
56
57
  "eslint": "^8.37.0",
58
+ "fake-indexeddb": "^6.0.1",
57
59
  "father": "^4.1.0",
58
60
  "prettier": "^3.5.3",
59
61
  "ts-node": "^10.9.1",
@@ -67,4 +69,4 @@
67
69
  "publishConfig": {
68
70
  "access": "public"
69
71
  }
70
- }
72
+ }