@pisell/pisellos 3.0.75 → 3.0.76

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 (319) hide show
  1. package/dist/core/index.js +2 -1
  2. package/dist/effects/index.d.ts +5 -3
  3. package/dist/effects/index.js +40 -8
  4. package/dist/modules/Account/index.js +2 -3
  5. package/dist/modules/AccountList/index.d.ts +7 -1
  6. package/dist/modules/AccountList/index.js +81 -14
  7. package/dist/modules/AccountList/types.d.ts +28 -0
  8. package/dist/modules/AccountList/types.js +8 -0
  9. package/dist/modules/BaseModule.d.ts +3 -0
  10. package/dist/modules/BaseModule.js +15 -0
  11. package/dist/modules/Cart/index.d.ts +1 -0
  12. package/dist/modules/Cart/index.js +2 -1
  13. package/dist/modules/Cart/utils/cartProduct.js +21 -4
  14. package/dist/modules/Customer/constants.d.ts +7 -0
  15. package/dist/modules/Customer/constants.js +12 -0
  16. package/dist/modules/Customer/index.d.ts +122 -0
  17. package/dist/modules/Customer/index.js +696 -0
  18. package/dist/modules/Customer/types.d.ts +146 -0
  19. package/dist/modules/Customer/types.js +41 -0
  20. package/dist/modules/Discount/index.d.ts +1 -0
  21. package/dist/modules/Discount/index.js +3 -3
  22. package/dist/modules/Discount/types.d.ts +9 -0
  23. package/dist/modules/Guests/index.js +9 -9
  24. package/dist/modules/Order/index.d.ts +25 -1
  25. package/dist/modules/Order/index.js +224 -3
  26. package/dist/modules/Order/types.d.ts +45 -0
  27. package/dist/modules/Order/types.js +8 -0
  28. package/dist/modules/Order/utils.js +1 -1
  29. package/dist/modules/Payment/cash.d.ts +19 -0
  30. package/dist/modules/Payment/cash.js +97 -0
  31. package/dist/modules/Payment/cashRecommendationAlgorithm.d.ts +22 -0
  32. package/dist/modules/Payment/cashRecommendationAlgorithm.js +423 -0
  33. package/dist/modules/Payment/eftpos.d.ts +11 -0
  34. package/dist/modules/Payment/eftpos.js +80 -0
  35. package/dist/modules/Payment/index.d.ts +184 -9
  36. package/dist/modules/Payment/index.js +2084 -109
  37. package/dist/modules/Payment/mx51.d.ts +0 -0
  38. package/dist/modules/Payment/mx51.js +0 -0
  39. package/dist/modules/Payment/types.d.ts +772 -30
  40. package/dist/modules/Payment/types.js +236 -12
  41. package/dist/modules/Payment/utils.d.ts +17 -0
  42. package/dist/modules/Payment/utils.js +62 -0
  43. package/dist/modules/Payment/walletpass.d.ts +99 -0
  44. package/dist/modules/Payment/walletpass.js +711 -0
  45. package/dist/modules/ProductList/index.d.ts +12 -1
  46. package/dist/modules/ProductList/index.js +37 -15
  47. package/dist/modules/Resource/index.js +1 -1
  48. package/dist/modules/Rules/index.d.ts +2 -1
  49. package/dist/modules/Rules/index.js +470 -127
  50. package/dist/modules/Rules/types.d.ts +1 -0
  51. package/dist/modules/Schedule/index.d.ts +9 -0
  52. package/dist/modules/Schedule/index.js +77 -0
  53. package/dist/modules/Summary/utils.d.ts +5 -0
  54. package/dist/modules/Summary/utils.js +36 -1
  55. package/dist/modules/index.d.ts +1 -0
  56. package/dist/modules/index.js +1 -0
  57. package/dist/plugins/app-types/app/app.d.ts +83 -0
  58. package/dist/plugins/app-types/app/const.d.ts +4 -0
  59. package/dist/plugins/app-types/app/index.d.ts +14 -0
  60. package/dist/plugins/app-types/applicationManager/application.d.ts +50 -0
  61. package/dist/plugins/app-types/applicationManager/index.d.ts +13 -0
  62. package/dist/plugins/app-types/config.d.ts +3 -0
  63. package/dist/plugins/app-types/cookie/index.d.ts +13 -0
  64. package/dist/plugins/app-types/data/index.d.ts +8 -0
  65. package/dist/plugins/app-types/history/config.d.ts +24 -0
  66. package/dist/plugins/app-types/history/index.d.ts +20 -0
  67. package/dist/plugins/app-types/history/type.d.ts +2 -0
  68. package/dist/plugins/app-types/hooks/index.d.ts +12 -0
  69. package/dist/plugins/app-types/hooks/useDelayedValue/index.d.ts +2 -0
  70. package/dist/plugins/app-types/hooks/useDispatch/index.d.ts +2 -0
  71. package/dist/plugins/app-types/hooks/useLowCode/index.d.ts +13 -0
  72. package/dist/plugins/app-types/hooks/useStore/index.d.ts +6 -0
  73. package/dist/plugins/app-types/index.d.ts +6 -0
  74. package/dist/plugins/app-types/indexDB/index.d.ts +178 -0
  75. package/dist/plugins/app-types/locales/en.d.ts +3 -0
  76. package/dist/plugins/app-types/locales/index.d.ts +37 -0
  77. package/dist/plugins/app-types/locales/original.d.ts +3 -0
  78. package/dist/plugins/app-types/locales/type.d.ts +19 -0
  79. package/dist/plugins/app-types/locales/zh-CN.d.ts +3 -0
  80. package/dist/plugins/app-types/locales/zh-HK.d.ts +3 -0
  81. package/dist/plugins/app-types/logger/feishu.d.ts +11 -0
  82. package/dist/plugins/app-types/logger/index.d.ts +122 -0
  83. package/dist/plugins/app-types/menuManager/hooks.d.ts +17 -0
  84. package/dist/plugins/app-types/menuManager/index.d.ts +28 -0
  85. package/dist/plugins/app-types/models/global.d.ts +32 -0
  86. package/dist/plugins/app-types/models/index.d.ts +45 -0
  87. package/dist/plugins/app-types/models/type.d.ts +2 -0
  88. package/dist/plugins/app-types/package.json +15 -0
  89. package/dist/plugins/app-types/plugin/index.d.ts +0 -0
  90. package/dist/plugins/app-types/pubsub/example.d.ts +5 -0
  91. package/dist/plugins/app-types/pubsub/index.d.ts +63 -0
  92. package/dist/plugins/app-types/request/cache.d.ts +46 -0
  93. package/dist/plugins/app-types/request/cancelToken.d.ts +38 -0
  94. package/dist/plugins/app-types/request/config.d.ts +3 -0
  95. package/dist/plugins/app-types/request/constants.d.ts +2 -0
  96. package/dist/plugins/app-types/request/index.d.ts +24 -0
  97. package/dist/plugins/app-types/request/pisell2Request.d.ts +6 -0
  98. package/dist/plugins/app-types/request/type.d.ts +41 -0
  99. package/dist/plugins/app-types/request/utils.d.ts +46 -0
  100. package/dist/plugins/app-types/routes/config.d.ts +7 -0
  101. package/dist/plugins/app-types/routes/index.d.ts +28 -0
  102. package/dist/plugins/app-types/socket/components/SocketMonitorPage.d.ts +6 -0
  103. package/dist/plugins/app-types/socket/components/index.d.ts +2 -0
  104. package/dist/plugins/app-types/socket/constants.d.ts +33 -0
  105. package/dist/plugins/app-types/socket/events.d.ts +31 -0
  106. package/dist/plugins/app-types/socket/heartbeat.d.ts +66 -0
  107. package/dist/plugins/app-types/socket/index.d.ts +61 -0
  108. package/dist/plugins/app-types/socket/monitor.d.ts +169 -0
  109. package/dist/plugins/app-types/socket/reconnect.d.ts +61 -0
  110. package/dist/plugins/app-types/socket/socket.d.ts +129 -0
  111. package/dist/plugins/app-types/socket/types.d.ts +85 -0
  112. package/dist/plugins/app-types/storage/index.d.ts +17 -0
  113. package/dist/plugins/app-types/tasks/index.d.ts +77 -0
  114. package/dist/plugins/app-types/tasks/type.d.ts +62 -0
  115. package/dist/plugins/app-types/tasks/useTasks.d.ts +5 -0
  116. package/dist/plugins/app-types/type.d.ts +2 -0
  117. package/dist/plugins/app-types/variables/VariablesProvider.d.ts +7 -0
  118. package/dist/plugins/app-types/variables/config.d.ts +3 -0
  119. package/dist/plugins/app-types/variables/index.d.ts +6 -0
  120. package/dist/plugins/app-types/variables/type.d.ts +2 -0
  121. package/dist/plugins/app-types/website/index.d.ts +6 -0
  122. package/dist/plugins/app.d.ts +8 -0
  123. package/dist/plugins/app.js +1 -0
  124. package/dist/plugins/window.d.ts +1 -0
  125. package/dist/solution/BookingByStep/index.js +43 -13
  126. package/dist/solution/BookingByStep/utils/capacity.js +1 -1
  127. package/dist/solution/BookingByStep/utils/products.d.ts +6 -0
  128. package/dist/solution/BookingByStep/utils/products.js +10 -0
  129. package/dist/solution/BookingTicket/index.d.ts +184 -0
  130. package/dist/solution/BookingTicket/index.js +698 -0
  131. package/dist/solution/BookingTicket/types.d.ts +68 -0
  132. package/dist/solution/BookingTicket/types.js +43 -0
  133. package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +22 -0
  134. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +159 -0
  135. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +22 -0
  136. package/dist/solution/BookingTicket/utils/scan/handleScan.js +189 -0
  137. package/dist/solution/BookingTicket/utils/scan/index.d.ts +85 -0
  138. package/dist/solution/BookingTicket/utils/scan/index.js +294 -0
  139. package/dist/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
  140. package/dist/solution/BookingTicket/utils/scan/scanCache.js +305 -0
  141. package/dist/solution/BuyTickets/index.js +7 -8
  142. package/dist/solution/Checkout/appointmentDemo.json +1 -0
  143. package/dist/solution/Checkout/index.d.ts +432 -0
  144. package/dist/solution/Checkout/index.js +4452 -0
  145. package/dist/solution/Checkout/types.d.ts +727 -0
  146. package/dist/solution/Checkout/types.js +104 -0
  147. package/dist/solution/Checkout/utils/index.d.ts +121 -0
  148. package/dist/solution/Checkout/utils/index.js +511 -0
  149. package/dist/solution/ShopDiscount/index.d.ts +10 -10
  150. package/dist/solution/ShopDiscount/index.js +111 -60
  151. package/dist/solution/ShopDiscount/types.d.ts +8 -0
  152. package/dist/solution/ShopDiscount/utils.d.ts +24 -0
  153. package/dist/solution/ShopDiscount/utils.js +135 -1
  154. package/dist/solution/index.d.ts +2 -0
  155. package/dist/solution/index.js +3 -1
  156. package/dist/types/index.d.ts +4 -1
  157. package/dist/utils/task.d.ts +40 -0
  158. package/dist/utils/task.js +171 -0
  159. package/dist/utils/watch.d.ts +102 -0
  160. package/dist/utils/watch.js +294 -0
  161. package/lib/core/index.js +1 -1
  162. package/lib/effects/index.d.ts +5 -3
  163. package/lib/effects/index.js +17 -1
  164. package/lib/modules/Account/index.js +2 -3
  165. package/lib/modules/AccountList/index.d.ts +7 -1
  166. package/lib/modules/AccountList/index.js +27 -0
  167. package/lib/modules/AccountList/types.d.ts +28 -0
  168. package/lib/modules/BaseModule.d.ts +3 -0
  169. package/lib/modules/BaseModule.js +9 -0
  170. package/lib/modules/Cart/index.d.ts +1 -0
  171. package/lib/modules/Cart/index.js +5 -2
  172. package/lib/modules/Cart/utils/cartProduct.js +22 -6
  173. package/lib/modules/Customer/constants.d.ts +7 -0
  174. package/lib/modules/Customer/constants.js +39 -0
  175. package/lib/modules/Customer/index.d.ts +122 -0
  176. package/lib/modules/Customer/index.js +439 -0
  177. package/lib/modules/Customer/types.d.ts +146 -0
  178. package/lib/modules/Customer/types.js +37 -0
  179. package/lib/modules/Discount/index.d.ts +1 -0
  180. package/lib/modules/Discount/index.js +3 -3
  181. package/lib/modules/Discount/types.d.ts +9 -0
  182. package/lib/modules/Guests/index.js +9 -9
  183. package/lib/modules/Order/index.d.ts +25 -1
  184. package/lib/modules/Order/index.js +186 -1
  185. package/lib/modules/Order/types.d.ts +45 -0
  186. package/lib/modules/Order/utils.js +1 -1
  187. package/lib/modules/Payment/cash.d.ts +19 -0
  188. package/lib/modules/Payment/cash.js +64 -0
  189. package/lib/modules/Payment/cashRecommendationAlgorithm.d.ts +22 -0
  190. package/lib/modules/Payment/cashRecommendationAlgorithm.js +342 -0
  191. package/lib/modules/Payment/eftpos.d.ts +11 -0
  192. package/lib/modules/Payment/eftpos.js +51 -0
  193. package/lib/modules/Payment/index.d.ts +184 -9
  194. package/lib/modules/Payment/index.js +1084 -51
  195. package/lib/modules/Payment/mx51.d.ts +0 -0
  196. package/lib/modules/Payment/mx51.js +0 -0
  197. package/lib/modules/Payment/types.d.ts +772 -30
  198. package/lib/modules/Payment/types.js +79 -6
  199. package/lib/modules/Payment/utils.d.ts +17 -0
  200. package/lib/modules/Payment/utils.js +67 -0
  201. package/lib/modules/Payment/walletpass.d.ts +99 -0
  202. package/lib/modules/Payment/walletpass.js +484 -0
  203. package/lib/modules/ProductList/index.d.ts +12 -1
  204. package/lib/modules/ProductList/index.js +31 -12
  205. package/lib/modules/Resource/index.js +1 -1
  206. package/lib/modules/Rules/index.d.ts +2 -1
  207. package/lib/modules/Rules/index.js +318 -72
  208. package/lib/modules/Rules/types.d.ts +1 -0
  209. package/lib/modules/Schedule/index.d.ts +9 -0
  210. package/lib/modules/Schedule/index.js +60 -0
  211. package/lib/modules/Summary/utils.d.ts +5 -0
  212. package/lib/modules/Summary/utils.js +27 -3
  213. package/lib/modules/index.d.ts +1 -0
  214. package/lib/modules/index.js +2 -0
  215. package/lib/plugins/app-types/app/app.d.ts +83 -0
  216. package/lib/plugins/app-types/app/const.d.ts +4 -0
  217. package/lib/plugins/app-types/app/index.d.ts +14 -0
  218. package/lib/plugins/app-types/applicationManager/application.d.ts +50 -0
  219. package/lib/plugins/app-types/applicationManager/index.d.ts +13 -0
  220. package/lib/plugins/app-types/config.d.ts +3 -0
  221. package/lib/plugins/app-types/cookie/index.d.ts +13 -0
  222. package/lib/plugins/app-types/data/index.d.ts +8 -0
  223. package/lib/plugins/app-types/history/config.d.ts +24 -0
  224. package/lib/plugins/app-types/history/index.d.ts +20 -0
  225. package/lib/plugins/app-types/history/type.d.ts +2 -0
  226. package/lib/plugins/app-types/hooks/index.d.ts +12 -0
  227. package/lib/plugins/app-types/hooks/useDelayedValue/index.d.ts +2 -0
  228. package/lib/plugins/app-types/hooks/useDispatch/index.d.ts +2 -0
  229. package/lib/plugins/app-types/hooks/useLowCode/index.d.ts +13 -0
  230. package/lib/plugins/app-types/hooks/useStore/index.d.ts +6 -0
  231. package/lib/plugins/app-types/index.d.ts +6 -0
  232. package/lib/plugins/app-types/indexDB/index.d.ts +178 -0
  233. package/lib/plugins/app-types/locales/en.d.ts +3 -0
  234. package/lib/plugins/app-types/locales/index.d.ts +37 -0
  235. package/lib/plugins/app-types/locales/original.d.ts +3 -0
  236. package/lib/plugins/app-types/locales/type.d.ts +19 -0
  237. package/lib/plugins/app-types/locales/zh-CN.d.ts +3 -0
  238. package/lib/plugins/app-types/locales/zh-HK.d.ts +3 -0
  239. package/lib/plugins/app-types/logger/feishu.d.ts +11 -0
  240. package/lib/plugins/app-types/logger/index.d.ts +122 -0
  241. package/lib/plugins/app-types/menuManager/hooks.d.ts +17 -0
  242. package/lib/plugins/app-types/menuManager/index.d.ts +28 -0
  243. package/lib/plugins/app-types/models/global.d.ts +32 -0
  244. package/lib/plugins/app-types/models/index.d.ts +45 -0
  245. package/lib/plugins/app-types/models/type.d.ts +2 -0
  246. package/lib/plugins/app-types/package.json +15 -0
  247. package/lib/plugins/app-types/plugin/index.d.ts +0 -0
  248. package/lib/plugins/app-types/pubsub/example.d.ts +5 -0
  249. package/lib/plugins/app-types/pubsub/index.d.ts +63 -0
  250. package/lib/plugins/app-types/request/cache.d.ts +46 -0
  251. package/lib/plugins/app-types/request/cancelToken.d.ts +38 -0
  252. package/lib/plugins/app-types/request/config.d.ts +3 -0
  253. package/lib/plugins/app-types/request/constants.d.ts +2 -0
  254. package/lib/plugins/app-types/request/index.d.ts +24 -0
  255. package/lib/plugins/app-types/request/pisell2Request.d.ts +6 -0
  256. package/lib/plugins/app-types/request/type.d.ts +41 -0
  257. package/lib/plugins/app-types/request/utils.d.ts +46 -0
  258. package/lib/plugins/app-types/routes/config.d.ts +7 -0
  259. package/lib/plugins/app-types/routes/index.d.ts +28 -0
  260. package/lib/plugins/app-types/socket/components/SocketMonitorPage.d.ts +6 -0
  261. package/lib/plugins/app-types/socket/components/index.d.ts +2 -0
  262. package/lib/plugins/app-types/socket/constants.d.ts +33 -0
  263. package/lib/plugins/app-types/socket/events.d.ts +31 -0
  264. package/lib/plugins/app-types/socket/heartbeat.d.ts +66 -0
  265. package/lib/plugins/app-types/socket/index.d.ts +61 -0
  266. package/lib/plugins/app-types/socket/monitor.d.ts +169 -0
  267. package/lib/plugins/app-types/socket/reconnect.d.ts +61 -0
  268. package/lib/plugins/app-types/socket/socket.d.ts +129 -0
  269. package/lib/plugins/app-types/socket/types.d.ts +85 -0
  270. package/lib/plugins/app-types/storage/index.d.ts +17 -0
  271. package/lib/plugins/app-types/tasks/index.d.ts +77 -0
  272. package/lib/plugins/app-types/tasks/type.d.ts +62 -0
  273. package/lib/plugins/app-types/tasks/useTasks.d.ts +5 -0
  274. package/lib/plugins/app-types/type.d.ts +2 -0
  275. package/lib/plugins/app-types/variables/VariablesProvider.d.ts +7 -0
  276. package/lib/plugins/app-types/variables/config.d.ts +3 -0
  277. package/lib/plugins/app-types/variables/index.d.ts +6 -0
  278. package/lib/plugins/app-types/variables/type.d.ts +2 -0
  279. package/lib/plugins/app-types/website/index.d.ts +6 -0
  280. package/lib/plugins/app.d.ts +8 -0
  281. package/lib/plugins/app.js +17 -0
  282. package/lib/plugins/window.d.ts +1 -0
  283. package/lib/solution/BookingByStep/index.js +18 -6
  284. package/lib/solution/BookingByStep/utils/capacity.js +1 -1
  285. package/lib/solution/BookingByStep/utils/products.d.ts +6 -0
  286. package/lib/solution/BookingByStep/utils/products.js +8 -2
  287. package/lib/solution/BookingTicket/index.d.ts +184 -0
  288. package/lib/solution/BookingTicket/index.js +426 -0
  289. package/lib/solution/BookingTicket/types.d.ts +68 -0
  290. package/lib/solution/BookingTicket/types.js +72 -0
  291. package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +22 -0
  292. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +117 -0
  293. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +22 -0
  294. package/lib/solution/BookingTicket/utils/scan/handleScan.js +132 -0
  295. package/lib/solution/BookingTicket/utils/scan/index.d.ts +85 -0
  296. package/lib/solution/BookingTicket/utils/scan/index.js +216 -0
  297. package/lib/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
  298. package/lib/solution/BookingTicket/utils/scan/scanCache.js +231 -0
  299. package/lib/solution/BuyTickets/index.js +7 -8
  300. package/lib/solution/Checkout/appointmentDemo.json +1 -0
  301. package/lib/solution/Checkout/index.d.ts +432 -0
  302. package/lib/solution/Checkout/index.js +2776 -0
  303. package/lib/solution/Checkout/types.d.ts +727 -0
  304. package/lib/solution/Checkout/types.js +63 -0
  305. package/lib/solution/Checkout/utils/index.d.ts +121 -0
  306. package/lib/solution/Checkout/utils/index.js +362 -0
  307. package/lib/solution/ShopDiscount/index.d.ts +10 -10
  308. package/lib/solution/ShopDiscount/index.js +53 -27
  309. package/lib/solution/ShopDiscount/types.d.ts +8 -0
  310. package/lib/solution/ShopDiscount/utils.d.ts +24 -0
  311. package/lib/solution/ShopDiscount/utils.js +88 -1
  312. package/lib/solution/index.d.ts +2 -0
  313. package/lib/solution/index.js +5 -1
  314. package/lib/types/index.d.ts +4 -1
  315. package/lib/utils/task.d.ts +40 -0
  316. package/lib/utils/task.js +109 -0
  317. package/lib/utils/watch.d.ts +102 -0
  318. package/lib/utils/watch.js +217 -0
  319. package/package.json +3 -1
@@ -25,11 +25,11 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
25
25
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
26
26
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
27
27
  import { BaseModule } from "../../modules/BaseModule";
28
- import { ShopDiscountHooks } from "./types";
29
28
  import { DiscountModule } from "../../modules/Discount";
30
29
  import { RulesModule } from "../../modules/Rules";
31
30
  import { filterDiscountListByBookingTime as _filterDiscountListByBookingTime, isAllNormalProduct } from "./utils";
32
31
  import Decimal from 'decimal.js';
32
+ import { isBoolean } from 'lodash-es';
33
33
  export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
34
34
  _inherits(ShopDiscountImpl, _BaseModule);
35
35
  var _super = _createSuper(ShopDiscountImpl);
@@ -108,7 +108,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
108
108
  (_this$store$rules = this.store.rules) === null || _this$store$rules === void 0 || _this$store$rules.destroy();
109
109
  this.core.effects.offByModuleDestroy(this.name);
110
110
  _context2.next = 7;
111
- return this.core.effects.emit(ShopDiscountHooks.onDestroy, {});
111
+ return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
112
112
  case 7:
113
113
  console.log('[ShopDiscount] 已销毁');
114
114
  case 8:
@@ -196,7 +196,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
196
196
  key: "registerEventListeners",
197
197
  value: function registerEventListeners() {
198
198
  var _this2 = this;
199
- this.core.effects.on(ShopDiscountHooks.onCustomerChange, function (customer) {
199
+ this.core.effects.only("".concat(this.name, ":onCustomerChange"), function (customer) {
200
200
  var _this2$options$otherP;
201
201
  if ((_this2$options$otherP = _this2.options.otherParams) !== null && _this2$options$otherP !== void 0 && _this2$options$otherP.cacheId && _this2.getDiscountList().length) {
202
202
  return;
@@ -276,7 +276,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
276
276
  }
277
277
  this.store.customer = customer;
278
278
  _context4.next = 4;
279
- return this.core.effects.emit(ShopDiscountHooks.onCustomerChange, customer);
279
+ return this.core.effects.emit("".concat(this.name, ":onCustomerChange"), customer);
280
280
  case 4:
281
281
  case "end":
282
282
  return _context4.stop();
@@ -335,19 +335,38 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
335
335
  // 设置优惠券使用状态
336
336
  }, {
337
337
  key: "setDiscountSelected",
338
- value: function setDiscountSelected(_ref2) {
339
- var discountId = _ref2.discountId,
340
- isSelected = _ref2.isSelected;
338
+ value: function setDiscountSelected(params) {
341
339
  // 获取当前优惠券列表
342
340
  var discountList = this.getDiscountList();
343
341
 
342
+ // 构建选择操作列表
343
+ var selectionOperations = [];
344
+
345
+ // 主要操作
346
+ selectionOperations.push({
347
+ discountId: params.discountId,
348
+ isSelected: params.isSelected
349
+ });
350
+
351
+ // 如果有批量操作列表,添加到操作列表中
352
+ if (params.selectedList && params.selectedList.length > 0) {
353
+ selectionOperations.push.apply(selectionOperations, _toConsumableArray(params.selectedList));
354
+ }
355
+
356
+ // 创建选择状态映射(去重处理,后面的操作会覆盖前面的)
357
+ var selectionMap = new Map();
358
+ selectionOperations.forEach(function (operation) {
359
+ selectionMap.set(operation.discountId, operation.isSelected);
360
+ });
361
+
344
362
  // 找到需要修改状态的优惠券
345
363
  var newDiscountList = discountList.map(function (discount) {
346
- if (discount.id === discountId) {
364
+ if (selectionMap.has(discount.id)) {
365
+ var targetIsSelected = selectionMap.get(discount.id);
347
366
  return _objectSpread(_objectSpread({}, discount), {}, {
348
- isSelected: isSelected,
367
+ isSelected: targetIsSelected,
349
368
  // 手动设置不使用
350
- isManualSelect: !isSelected
369
+ isManualSelect: !targetIsSelected
351
370
  });
352
371
  }
353
372
  return _objectSpread(_objectSpread({}, discount), {}, {
@@ -357,12 +376,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
357
376
 
358
377
  // 更新优惠券列表
359
378
  this.setDiscountList(newDiscountList);
360
-
361
- // 如果取消选择优惠券,需要重新计算其他可用优惠券
362
- return this.calcDiscount(this.store.productList || [], {
363
- discountId: discountId,
364
- isSelected: isSelected
365
- });
379
+ return this.calcDiscount(this.store.productList || [], params);
366
380
  }
367
381
  }, {
368
382
  key: "setProductList",
@@ -375,7 +389,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
375
389
  key: "scanCode",
376
390
  value: function () {
377
391
  var _scanCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(code, customerId) {
378
- var _this$store$discount3, _this$store$bookingSu2, resultDiscountList, rulesModule, withScanList, currentSelectedDiscountList, _ref3, newProductList, newDiscountList, isAvailable, _this$options$otherPa6;
392
+ var _this$store$discount3, _this$store$bookingSu2, resultDiscountList, rulesModule, withScanList, currentSelectedDiscountList, _ref2, newProductList, newDiscountList, isAvailable, _this$options$otherPa6;
379
393
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
380
394
  while (1) switch (_context5.prev = _context5.next) {
381
395
  case 0:
@@ -437,7 +451,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
437
451
  discountList: this.getDiscountList()
438
452
  });
439
453
  case 16:
440
- _ref3 = rulesModule.isDiscountListAvailable({
454
+ _ref2 = rulesModule.isDiscountListAvailable({
441
455
  productList: this.store.productList || [],
442
456
  oldDiscountList: this.getDiscountList(),
443
457
  newDiscountList: withScanList,
@@ -447,28 +461,29 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
447
461
  isAvailable: false,
448
462
  productList: this.store.productList || [],
449
463
  discountList: this.getDiscountList()
450
- }, newProductList = _ref3.productList, newDiscountList = _ref3.discountList, isAvailable = _ref3.isAvailable;
464
+ }, newProductList = _ref2.productList, newDiscountList = _ref2.discountList, isAvailable = _ref2.isAvailable;
451
465
  if (!isAvailable) {
452
- _context5.next = 23;
466
+ _context5.next = 24;
453
467
  break;
454
468
  }
455
469
  this.setDiscountList(newDiscountList || []);
470
+ this.store.originalDiscountList = newDiscountList || [];
456
471
  this.setProductList(newProductList || []);
457
472
  if (!(this.isWalkIn() && resultDiscountList.length && ((_this$options$otherPa6 = this.options.otherParams) === null || _this$options$otherPa6 === void 0 ? void 0 : _this$options$otherPa6.platform) === 'shop')) {
458
- _context5.next = 23;
473
+ _context5.next = 24;
459
474
  break;
460
475
  }
461
- _context5.next = 23;
476
+ _context5.next = 24;
462
477
  return this.getCustomerWallet(resultDiscountList[0].customer_id);
463
- case 23:
478
+ case 24:
464
479
  return _context5.abrupt("return", {
465
480
  type: "clientCalc",
466
481
  isAvailable: isAvailable || false,
467
482
  productList: newProductList || this.store.productList || [],
468
483
  discountList: newDiscountList || this.getDiscountList()
469
484
  });
470
- case 26:
471
- _context5.prev = 26;
485
+ case 27:
486
+ _context5.prev = 27;
472
487
  _context5.t1 = _context5["catch"](0);
473
488
  console.error('[ShopDiscount] 扫码出错:', _context5.t1);
474
489
  return _context5.abrupt("return", {
@@ -477,11 +492,11 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
477
492
  productList: this.store.productList || [],
478
493
  discountList: this.getDiscountList()
479
494
  });
480
- case 30:
495
+ case 31:
481
496
  case "end":
482
497
  return _context5.stop();
483
498
  }
484
- }, _callee5, this, [[0, 26]]);
499
+ }, _callee5, this, [[0, 27]]);
485
500
  }));
486
501
  function scanCode(_x4, _x5) {
487
502
  return _scanCode.apply(this, arguments);
@@ -521,7 +536,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
521
536
  while (1) switch (_context6.prev = _context6.next) {
522
537
  case 0:
523
538
  _context6.next = 2;
524
- return this.core.effects.emit(ShopDiscountHooks.onDiscountListChange, discountList);
539
+ return this.core.effects.emit("".concat(this.name, ":onDiscountListChange"), discountList);
525
540
  case 2:
526
541
  case "end":
527
542
  return _context6.stop();
@@ -551,19 +566,21 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
551
566
  return n.id === (((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id);
552
567
  });
553
568
  if (index !== -1) {
569
+ var _discount$metadata;
554
570
  editModeDiscountList[index] = _objectSpread(_objectSpread({}, editModeDiscountList[index]), {}, {
555
571
  amount: new Decimal(discount.amount || 0).plus(new Decimal(editModeDiscountList[index].amount || 0)).toNumber(),
556
- savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus(new Decimal(editModeDiscountList[index].savedAmount || 0)).toNumber()
572
+ savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus((discount === null || discount === void 0 || (_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.product_discount_difference) || 0).plus(new Decimal(editModeDiscountList[index].savedAmount || 0)).toNumber()
557
573
  });
558
574
  } else {
559
- var _discount$discount2, _discount$discount3, _discount$discount4;
575
+ var _discount$metadata2, _discount$discount2, _discount$discount3, _discount$discount4;
560
576
  if (discount.type && !discount.tag) {
561
577
  discount.tag = discount.type;
562
578
  }
563
579
  editModeDiscountList.push(_objectSpread(_objectSpread({}, discount), {}, {
580
+ name: discount.name || discount.discount.title.auto,
564
581
  isEditMode: true,
565
582
  limited_relation_product_data: {},
566
- savedAmount: discount.amount * ((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1),
583
+ savedAmount: new Decimal(discount.amount || 0).times((product === null || product === void 0 ? void 0 : product.quantity) || (product === null || product === void 0 ? void 0 : product.num) || 1).plus((discount === null || discount === void 0 || (_discount$metadata2 = discount.metadata) === null || _discount$metadata2 === void 0 ? void 0 : _discount$metadata2.product_discount_difference) || 0).toNumber(),
567
584
  isAvailable: true,
568
585
  id: ((_discount$discount2 = discount.discount) === null || _discount$discount2 === void 0 ? void 0 : _discount$discount2.resource_id) || discount.id,
569
586
  format_title: ((_discount$discount3 = discount.discount) === null || _discount$discount3 === void 0 ? void 0 : _discount$discount3.title) || discount.format_title,
@@ -586,8 +603,9 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
586
603
  });
587
604
  if (!targetProduct) return false;
588
605
  var product = (_this3$hooks2 = _this3.hooks) === null || _this3$hooks2 === void 0 ? void 0 : _this3$hooks2.getProduct(targetProduct);
589
- // 如果 product.total 0有可能是她已经用过商品券或者折扣卡导致的 0,所以此时还需要判断 origin_total 是否为 0
590
- return Number(product === null || product === void 0 ? void 0 : product.total) === 0 && (Number(product === null || product === void 0 ? void 0 : product.origin_total) === 0 || !(product !== null && product !== void 0 && product.origin_total));
606
+ // 如果 product.total 是小于等于0有可能是她已经用过商品券或者折扣卡导致的,或者本身就是负数价格,所以此时还需要判断 origin_total 是否小于等于0
607
+ // 如果 product.vouchersApplicable是布尔值,并且是 false,也当做免费商品处理,此商品不可用优惠券或折扣卡
608
+ return Number(product === null || product === void 0 ? void 0 : product.total) <= 0 && (Number(product === null || product === void 0 ? void 0 : product.origin_total) <= 0 || !(product !== null && product !== void 0 && product.origin_total)) || isBoolean(product === null || product === void 0 ? void 0 : product.vouchersApplicable) && !(product !== null && product !== void 0 && product.vouchersApplicable);
591
609
  };
592
610
  var allUsedProductIds = newDiscountList.filter(function (item) {
593
611
  return !(item !== null && item !== void 0 && item.isEditMode);
@@ -635,7 +653,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
635
653
  key: "getCustomerWallet",
636
654
  value: function () {
637
655
  var _getCustomerWallet = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(id) {
638
- var result, customer;
656
+ var _result, customer;
639
657
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
640
658
  while (1) switch (_context7.prev = _context7.next) {
641
659
  case 0:
@@ -645,15 +663,15 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
645
663
  with_trashed: 1
646
664
  });
647
665
  case 3:
648
- result = _context7.sent;
649
- if (!(result !== null && result !== void 0 && result.data)) {
666
+ _result = _context7.sent;
667
+ if (!(_result !== null && _result !== void 0 && _result.data)) {
650
668
  _context7.next = 9;
651
669
  break;
652
670
  }
653
- customer = Object.assign({}, (_objectDestructuringEmpty(result.data), result.data));
671
+ customer = Object.assign({}, (_objectDestructuringEmpty(_result.data), _result.data));
654
672
  this.setCustomer(customer);
655
673
  _context7.next = 9;
656
- return this.core.effects.emit(ShopDiscountHooks.onScanCustomerChange, customer);
674
+ return this.core.effects.emit("".concat(this.name, ":onScanCustomerChange"), customer);
657
675
  case 9:
658
676
  _context7.next = 14;
659
677
  break;
@@ -671,20 +689,53 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
671
689
  return _getCustomerWallet.apply(this, arguments);
672
690
  }
673
691
  return getCustomerWallet;
674
- }() // 加载准备配置
692
+ }()
675
693
  }, {
676
- key: "loadPrepareConfig",
694
+ key: "bestDiscount",
677
695
  value: function () {
678
- var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
679
- var _this$getCustomer2, _this$store$discount7, _this$getDiscountList, _this$store$discount8, _this$store$productLi, customerId, goodPassList, scanDiscount, scanDiscountIds, newGoodPassList, newDiscountList, filteredDiscountList, result;
696
+ var _bestDiscount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(cb) {
697
+ var _this$store$productLi;
698
+ var newDiscountList, _result2;
680
699
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
681
700
  while (1) switch (_context8.prev = _context8.next) {
682
701
  case 0:
683
- _context8.prev = 0;
702
+ newDiscountList = this.store.originalDiscountList;
703
+ this.setDiscountList(newDiscountList);
704
+ if (!((_this$store$productLi = this.store.productList) !== null && _this$store$productLi !== void 0 && _this$store$productLi.length)) {
705
+ _context8.next = 7;
706
+ break;
707
+ }
708
+ _result2 = this.calcDiscount(this.store.productList);
709
+ cb === null || cb === void 0 || cb(_result2);
710
+ _context8.next = 7;
711
+ return this.core.effects.emit("".concat(this.name, ":onLoadPrepareCalcResult"), _result2);
712
+ case 7:
713
+ _context8.next = 9;
714
+ return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), newDiscountList);
715
+ case 9:
716
+ case "end":
717
+ return _context8.stop();
718
+ }
719
+ }, _callee8, this);
720
+ }));
721
+ function bestDiscount(_x8) {
722
+ return _bestDiscount.apply(this, arguments);
723
+ }
724
+ return bestDiscount;
725
+ }() // 加载准备配置
726
+ }, {
727
+ key: "loadPrepareConfig",
728
+ value: function () {
729
+ var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
730
+ var _this$getCustomer2, _this$store$discount7, _this$getDiscountList, _this$store$discount8, _this$store$productLi2, customerId, goodPassList, scanDiscount, scanDiscountIds, newGoodPassList, newDiscountList, filteredDiscountList, _result3;
731
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
732
+ while (1) switch (_context9.prev = _context9.next) {
733
+ case 0:
734
+ _context9.prev = 0;
684
735
  customerId = params.customerId || ((_this$getCustomer2 = this.getCustomer()) === null || _this$getCustomer2 === void 0 ? void 0 : _this$getCustomer2.id); // if (customerId === 1 || !customerId) {
685
736
  // return
686
737
  // }
687
- _context8.next = 4;
738
+ _context9.next = 4;
688
739
  return (_this$store$discount7 = this.store.discount) === null || _this$store$discount7 === void 0 ? void 0 : _this$store$discount7.loadPrepareConfig({
689
740
  customer_id: customerId,
690
741
  action: 'create',
@@ -693,7 +744,7 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
693
744
  with_wallet_pass_holder: 1
694
745
  });
695
746
  case 4:
696
- goodPassList = _context8.sent;
747
+ goodPassList = _context9.sent;
697
748
  scanDiscount = (_this$getDiscountList = this.getDiscountList()) === null || _this$getDiscountList === void 0 ? void 0 : _this$getDiscountList.filter(function (item) {
698
749
  return item.isScan;
699
750
  }); // goodPassList 里可能有 scanDiscount 重合的部分,goodPassList 需要剔除
@@ -705,37 +756,37 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
705
756
  });
706
757
  newDiscountList = [].concat(_toConsumableArray(scanDiscount), _toConsumableArray(newGoodPassList || [])); // 存储原始优惠券列表
707
758
  this.store.originalDiscountList = newDiscountList;
708
- _context8.next = 12;
759
+ _context9.next = 12;
709
760
  return (_this$store$discount8 = this.store.discount) === null || _this$store$discount8 === void 0 ? void 0 : _this$store$discount8.setOriginalDiscountList(newDiscountList);
710
761
  case 12:
711
762
  // 根据当前预约时间过滤优惠券列表
712
763
  filteredDiscountList = this.filterDiscountListByBookingTime(newDiscountList, this.store.currentBookingTime);
713
764
  this.store.filteredDiscountList = filteredDiscountList;
714
765
  this.setDiscountList(filteredDiscountList || []);
715
- if (!((_this$store$productLi = this.store.productList) !== null && _this$store$productLi !== void 0 && _this$store$productLi.length)) {
716
- _context8.next = 19;
766
+ if (!((_this$store$productLi2 = this.store.productList) !== null && _this$store$productLi2 !== void 0 && _this$store$productLi2.length)) {
767
+ _context9.next = 19;
717
768
  break;
718
769
  }
719
- result = this.calcDiscount(this.store.productList);
720
- _context8.next = 19;
721
- return this.core.effects.emit(ShopDiscountHooks.onLoadPrepareCalcResult, result);
770
+ _result3 = this.calcDiscount(this.store.productList);
771
+ _context9.next = 19;
772
+ return this.core.effects.emit("".concat(this.name, ":onLoadPrepareCalcResult"), _result3);
722
773
  case 19:
723
- _context8.next = 21;
724
- return this.core.effects.emit(ShopDiscountHooks.onLoadDiscountList, filteredDiscountList);
774
+ _context9.next = 21;
775
+ return this.core.effects.emit("".concat(this.name, ":onLoadDiscountList"), filteredDiscountList);
725
776
  case 21:
726
- _context8.next = 26;
777
+ _context9.next = 26;
727
778
  break;
728
779
  case 23:
729
- _context8.prev = 23;
730
- _context8.t0 = _context8["catch"](0);
731
- console.error('[ShopDiscount] 加载准备配置出错:', _context8.t0);
780
+ _context9.prev = 23;
781
+ _context9.t0 = _context9["catch"](0);
782
+ console.error('[ShopDiscount] 加载准备配置出错:', _context9.t0);
732
783
  case 26:
733
784
  case "end":
734
- return _context8.stop();
785
+ return _context9.stop();
735
786
  }
736
- }, _callee8, this, [[0, 23]]);
787
+ }, _callee9, this, [[0, 23]]);
737
788
  }));
738
- function loadPrepareConfig(_x8) {
789
+ function loadPrepareConfig(_x9) {
739
790
  return _loadPrepareConfig.apply(this, arguments);
740
791
  }
741
792
  return loadPrepareConfig;
@@ -36,3 +36,11 @@ export interface ShopDiscountState {
36
36
  [key: string]: any;
37
37
  };
38
38
  }
39
+ export interface SetDiscountSelectedParams {
40
+ discountId: number;
41
+ isSelected: boolean;
42
+ selectedList?: {
43
+ discountId: number;
44
+ isSelected: boolean;
45
+ }[];
46
+ }
@@ -65,3 +65,27 @@ export declare const getDateIsInSchedule: (dateTime: string, scheduleList: Sched
65
65
  * @returns 过滤后的优惠券列表
66
66
  */
67
67
  export declare const filterDiscountListByBookingTime: (discountList: Discount[], bookingTime: string | null) => Discount[];
68
+ /**
69
+ * 判断是否是订单级别的固定金额折扣卡
70
+ * @param discount 折扣
71
+ * @returns 是否是订单级别的固定金额折扣卡
72
+ */
73
+ export declare const isOrderLevelFixedAmountDiscount: (discount: Discount) => boolean;
74
+ /**
75
+ * 计算订单级别固定金额折扣卡的分摊结果
76
+ * @param discount 折扣卡
77
+ * @param applicableProducts 适用商品列表 { productId, amount, quantity, parentQuantity }
78
+ * @returns 分摊结果 Map<productId, { discountAmount, difference }>
79
+ * 注意:
80
+ * - discountAmount 是单价折扣金额(不是总折扣金额)
81
+ * - difference(总差值)优先直接加到数量为1的单商品折扣上,如果没有则存储在metadata中
82
+ */
83
+ export declare const calculateOrderLevelDiscountAllocation: (discount: Discount, applicableProducts: Array<{
84
+ productId: string | number;
85
+ amount: number;
86
+ quantity: number;
87
+ parentQuantity?: number;
88
+ }>) => Map<string | number, {
89
+ discountAmount: number;
90
+ difference: number;
91
+ }>;
@@ -1,3 +1,9 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
1
7
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
8
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3
9
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
@@ -45,7 +51,8 @@ export var getDiscountAmount = function getDiscountAmount(discount, total, price
45
51
 
46
52
  // 固定金额 小于0时返回0
47
53
  if (isFixedAmount) {
48
- return Math.max(new Decimal(price).minus(new Decimal(discount.par_value || 0)).toNumber(), 0);
54
+ var _discount$amount;
55
+ return Math.max(new Decimal(price).minus(new Decimal(((_discount$amount = discount.amount) !== null && _discount$amount !== void 0 ? _discount$amount : discount.par_value) || 0)).toNumber(), 0);
49
56
  }
50
57
 
51
58
  // 百分比:根据折扣卡金额计算
@@ -462,4 +469,131 @@ export var filterDiscountListByBookingTime = function filterDiscountListByBookin
462
469
  return true;
463
470
  }
464
471
  });
472
+ };
473
+ /**
474
+ * 判断是否是订单级别的固定金额折扣卡
475
+ * @param discount 折扣
476
+ * @returns 是否是订单级别的固定金额折扣卡
477
+ */
478
+ export var isOrderLevelFixedAmountDiscount = function isOrderLevelFixedAmountDiscount(discount) {
479
+ var _discount$metadata3, _discount$metadata4;
480
+ return discount.tag === 'product_discount_card' && (discount === null || discount === void 0 || (_discount$metadata3 = discount.metadata) === null || _discount$metadata3 === void 0 ? void 0 : _discount$metadata3.discount_card_type) === 'fixed_amount' && (discount === null || discount === void 0 || (_discount$metadata4 = discount.metadata) === null || _discount$metadata4 === void 0 ? void 0 : _discount$metadata4.discount_calculation_mode) === 'order_level';
481
+ };
482
+
483
+ /**
484
+ * 计算订单级别固定金额折扣卡的分摊结果
485
+ * @param discount 折扣卡
486
+ * @param applicableProducts 适用商品列表 { productId, amount, quantity, parentQuantity }
487
+ * @returns 分摊结果 Map<productId, { discountAmount, difference }>
488
+ * 注意:
489
+ * - discountAmount 是单价折扣金额(不是总折扣金额)
490
+ * - difference(总差值)优先直接加到数量为1的单商品折扣上,如果没有则存储在metadata中
491
+ */
492
+ export var calculateOrderLevelDiscountAllocation = function calculateOrderLevelDiscountAllocation(discount, applicableProducts) {
493
+ var result = new Map();
494
+ if (applicableProducts.length === 0) {
495
+ return result;
496
+ }
497
+
498
+ // 计算适用商品的总金额(数量 × 单价)
499
+ var totalAmount = applicableProducts.reduce(function (acc, product) {
500
+ return new Decimal(acc).plus(new Decimal(product.amount).mul(product.quantity)).toNumber();
501
+ }, 0);
502
+ if (totalAmount <= 0) {
503
+ return result;
504
+ }
505
+
506
+ // 固定减免金额
507
+ var fixedAmount = new Decimal(discount.par_value || 0).toNumber();
508
+
509
+ // 如果固定金额 >= 商品总金额,折扣最高为商品金额(免费)
510
+ var actualDiscountTotal = Math.min(fixedAmount, totalAmount);
511
+
512
+ // 计算每个商品的单价折扣金额
513
+ var allocatedTotal = new Decimal(0);
514
+ applicableProducts.forEach(function (product) {
515
+ // 🔥 分摊公式改为:(单价 / 适用商品总金额) × 固定金额
516
+ // 这样只有一次取整,避免精度损失
517
+ var rawDiscountPerItem = new Decimal(product.amount).div(totalAmount).mul(actualDiscountTotal);
518
+
519
+ // 保留两位小数,向下取整(单价折扣)
520
+ var discountAmountPerItem = rawDiscountPerItem.toDecimalPlaces(2, Decimal.ROUND_DOWN).toNumber();
521
+ result.set(product.productId, {
522
+ discountAmount: discountAmountPerItem,
523
+ // 单价折扣金额
524
+ difference: 0 // 默认差值为0
525
+ });
526
+
527
+ // 累加实际分配的总折扣金额(单价折扣 × 数量)
528
+ allocatedTotal = allocatedTotal.plus(new Decimal(discountAmountPerItem).mul(product.quantity));
529
+ });
530
+
531
+ // 🔥 计算总差值
532
+ // 总差值 = 固定金额 - 所有商品的 (单价折扣 × 数量) 之和
533
+ var totalDifference = new Decimal(actualDiscountTotal).minus(allocatedTotal).toDecimalPlaces(2, Decimal.ROUND_HALF_UP).toNumber();
534
+ if (totalDifference > 0) {
535
+ // 🔥 判断商品是否是真正的"数量为1"
536
+ // 主商品:quantity === 1
537
+ // 子商品:quantity === 1 且 parentQuantity === 1
538
+ var isSingleQuantity = function isSingleQuantity(product) {
539
+ if (product.parentQuantity !== undefined) {
540
+ // 子商品:需要同时满足自身数量为1且主商品数量为1
541
+ return product.quantity === 1 && product.parentQuantity === 1;
542
+ }
543
+ // 主商品:只需要自身数量为1
544
+ return product.quantity === 1;
545
+ };
546
+
547
+ // 🔥 筛选出数量为1的商品
548
+ var singleQuantityProducts = applicableProducts.filter(isSingleQuantity);
549
+ if (singleQuantityProducts.length > 0) {
550
+ // 🔥 优先级1:找到有足够剩余空间且金额最大的商品
551
+ // 剩余空间 = 商品价格 - 当前折扣金额 >= 差值
552
+ var productsWithEnoughSpace = singleQuantityProducts.filter(function (product) {
553
+ var allocation = result.get(product.productId);
554
+ if (!allocation) return false;
555
+ var remainingSpace = new Decimal(product.amount).minus(allocation.discountAmount).toNumber();
556
+ return remainingSpace >= totalDifference;
557
+ });
558
+ if (productsWithEnoughSpace.length > 0) {
559
+ // 按金额降序排序,选择金额最大的
560
+ productsWithEnoughSpace.sort(function (a, b) {
561
+ return b.amount - a.amount;
562
+ });
563
+ var targetProduct = productsWithEnoughSpace[0];
564
+ var targetAllocation = result.get(targetProduct.productId);
565
+ if (targetAllocation) {
566
+ // 差值直接加到折扣金额上
567
+ result.set(targetProduct.productId, {
568
+ discountAmount: new Decimal(targetAllocation.discountAmount).plus(totalDifference).toNumber(),
569
+ difference: 0 // 不需要存储差值
570
+ });
571
+ }
572
+ } else {
573
+ // 🔥 优先级2:所有数量为1的商品都没有足够剩余空间
574
+ // 选择金额最大的商品,差值存储在metadata中
575
+ singleQuantityProducts.sort(function (a, b) {
576
+ return b.amount - a.amount;
577
+ });
578
+ var _targetProduct = singleQuantityProducts[0];
579
+ var _targetAllocation = result.get(_targetProduct.productId);
580
+ if (_targetAllocation) {
581
+ result.set(_targetProduct.productId, _objectSpread(_objectSpread({}, _targetAllocation), {}, {
582
+ difference: totalDifference
583
+ }));
584
+ }
585
+ }
586
+ } else {
587
+ // 🔥 优先级3:没有数量为1的商品,走原有逻辑
588
+ // 差值存储在最后一个商品的metadata中
589
+ var lastProduct = applicableProducts[applicableProducts.length - 1];
590
+ var lastProductAllocation = result.get(lastProduct.productId);
591
+ if (lastProductAllocation) {
592
+ result.set(lastProduct.productId, _objectSpread(_objectSpread({}, lastProductAllocation), {}, {
593
+ difference: totalDifference
594
+ }));
595
+ }
596
+ }
597
+ }
598
+ return result;
465
599
  };
@@ -1,4 +1,6 @@
1
1
  export * from './BuyTickets';
2
2
  export * from './BookingByStep';
3
+ export * from './BookingTicket';
3
4
  export * from './ShopDiscount';
4
5
  export * from './RegisterAndLogin';
6
+ export * from './Checkout';
@@ -1,4 +1,6 @@
1
1
  export * from "./BuyTickets";
2
2
  export * from "./BookingByStep";
3
+ export * from "./BookingTicket";
3
4
  export * from "./ShopDiscount";
4
- export * from "./RegisterAndLogin";
5
+ export * from "./RegisterAndLogin";
6
+ export * from "./Checkout";
@@ -38,7 +38,10 @@ 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
+ only: (event: string, callback: (payload: any) => void) => () => void;
44
+ off: (event: string, callback: (payload: any) => void) => void;
42
45
  emit: (event: string, payload: any, value?: any) => Promise<{
43
46
  status: boolean;
44
47
  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;