@pisell/pisellos 3.0.55 → 3.0.57

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 (268) 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/Cart/utils/changePrice.d.ts +2 -2
  10. package/dist/modules/Cart/utils/changePrice.js +1 -1
  11. package/dist/modules/Customer/constants.d.ts +7 -0
  12. package/dist/modules/Customer/constants.js +12 -0
  13. package/dist/modules/Customer/index.d.ts +122 -0
  14. package/dist/modules/Customer/index.js +697 -0
  15. package/dist/modules/Customer/types.d.ts +146 -0
  16. package/dist/modules/Customer/types.js +41 -0
  17. package/dist/modules/Payment/cash.d.ts +11 -0
  18. package/dist/modules/Payment/cash.js +78 -0
  19. package/dist/modules/Payment/eftpos.d.ts +11 -0
  20. package/dist/modules/Payment/eftpos.js +80 -0
  21. package/dist/modules/Payment/index.d.ts +273 -9
  22. package/dist/modules/Payment/index.js +2525 -109
  23. package/dist/modules/Payment/types.d.ts +382 -30
  24. package/dist/modules/Payment/types.js +116 -14
  25. package/dist/modules/Payment/wallet.d.ts +11 -0
  26. package/dist/modules/Payment/wallet.js +78 -0
  27. package/dist/modules/Payment/walletpass.d.ts +0 -0
  28. package/dist/modules/Payment/walletpass.js +0 -0
  29. package/dist/modules/ProductList/index.d.ts +14 -3
  30. package/dist/modules/ProductList/index.js +58 -44
  31. package/dist/modules/ProductList/types.d.ts +0 -1
  32. package/dist/modules/Rules/index.js +27 -14
  33. package/dist/modules/Rules/types.d.ts +1 -0
  34. package/dist/modules/index.d.ts +1 -0
  35. package/dist/modules/index.js +1 -0
  36. package/dist/plugins/app-types/app/app.d.ts +83 -0
  37. package/dist/plugins/app-types/app/const.d.ts +4 -0
  38. package/dist/plugins/app-types/app/index.d.ts +14 -0
  39. package/dist/plugins/app-types/applicationManager/application.d.ts +50 -0
  40. package/dist/plugins/app-types/applicationManager/index.d.ts +13 -0
  41. package/dist/plugins/app-types/config.d.ts +3 -0
  42. package/dist/plugins/app-types/cookie/index.d.ts +13 -0
  43. package/dist/plugins/app-types/data/index.d.ts +8 -0
  44. package/dist/plugins/app-types/history/config.d.ts +24 -0
  45. package/dist/plugins/app-types/history/index.d.ts +20 -0
  46. package/dist/plugins/app-types/history/type.d.ts +2 -0
  47. package/dist/plugins/app-types/hooks/index.d.ts +12 -0
  48. package/dist/plugins/app-types/hooks/useDelayedValue/index.d.ts +2 -0
  49. package/dist/plugins/app-types/hooks/useDispatch/index.d.ts +2 -0
  50. package/dist/plugins/app-types/hooks/useLowCode/index.d.ts +13 -0
  51. package/dist/plugins/app-types/hooks/useStore/index.d.ts +6 -0
  52. package/dist/plugins/app-types/index.d.ts +6 -0
  53. package/dist/plugins/app-types/indexDB/index.d.ts +178 -0
  54. package/dist/plugins/app-types/locales/en.d.ts +3 -0
  55. package/dist/plugins/app-types/locales/index.d.ts +37 -0
  56. package/dist/plugins/app-types/locales/original.d.ts +3 -0
  57. package/dist/plugins/app-types/locales/type.d.ts +19 -0
  58. package/dist/plugins/app-types/locales/zh-CN.d.ts +3 -0
  59. package/dist/plugins/app-types/locales/zh-HK.d.ts +3 -0
  60. package/dist/plugins/app-types/logger/feishu.d.ts +11 -0
  61. package/dist/plugins/app-types/logger/index.d.ts +122 -0
  62. package/dist/plugins/app-types/menuManager/hooks.d.ts +17 -0
  63. package/dist/plugins/app-types/menuManager/index.d.ts +28 -0
  64. package/dist/plugins/app-types/models/global.d.ts +32 -0
  65. package/dist/plugins/app-types/models/index.d.ts +45 -0
  66. package/dist/plugins/app-types/models/type.d.ts +2 -0
  67. package/dist/plugins/app-types/package.json +15 -0
  68. package/dist/plugins/app-types/plugin/index.d.ts +0 -0
  69. package/dist/plugins/app-types/pubsub/example.d.ts +5 -0
  70. package/dist/plugins/app-types/pubsub/index.d.ts +63 -0
  71. package/dist/plugins/app-types/request/cache.d.ts +46 -0
  72. package/dist/plugins/app-types/request/cancelToken.d.ts +38 -0
  73. package/dist/plugins/app-types/request/config.d.ts +3 -0
  74. package/dist/plugins/app-types/request/constants.d.ts +2 -0
  75. package/dist/plugins/app-types/request/index.d.ts +24 -0
  76. package/dist/plugins/app-types/request/pisell2Request.d.ts +6 -0
  77. package/dist/plugins/app-types/request/type.d.ts +41 -0
  78. package/dist/plugins/app-types/request/utils.d.ts +46 -0
  79. package/dist/plugins/app-types/routes/config.d.ts +7 -0
  80. package/dist/plugins/app-types/routes/index.d.ts +28 -0
  81. package/dist/plugins/app-types/socket/components/SocketMonitorPage.d.ts +6 -0
  82. package/dist/plugins/app-types/socket/components/index.d.ts +2 -0
  83. package/dist/plugins/app-types/socket/constants.d.ts +33 -0
  84. package/dist/plugins/app-types/socket/events.d.ts +31 -0
  85. package/dist/plugins/app-types/socket/heartbeat.d.ts +66 -0
  86. package/dist/plugins/app-types/socket/index.d.ts +61 -0
  87. package/dist/plugins/app-types/socket/monitor.d.ts +169 -0
  88. package/dist/plugins/app-types/socket/reconnect.d.ts +61 -0
  89. package/dist/plugins/app-types/socket/socket.d.ts +129 -0
  90. package/dist/plugins/app-types/socket/types.d.ts +85 -0
  91. package/dist/plugins/app-types/storage/index.d.ts +17 -0
  92. package/dist/plugins/app-types/tasks/index.d.ts +77 -0
  93. package/dist/plugins/app-types/tasks/type.d.ts +62 -0
  94. package/dist/plugins/app-types/tasks/useTasks.d.ts +5 -0
  95. package/dist/plugins/app-types/type.d.ts +2 -0
  96. package/dist/plugins/app-types/variables/VariablesProvider.d.ts +7 -0
  97. package/dist/plugins/app-types/variables/config.d.ts +3 -0
  98. package/dist/plugins/app-types/variables/index.d.ts +6 -0
  99. package/dist/plugins/app-types/variables/type.d.ts +2 -0
  100. package/dist/plugins/app-types/website/index.d.ts +6 -0
  101. package/dist/plugins/app.d.ts +8 -0
  102. package/dist/plugins/app.js +1 -0
  103. package/dist/plugins/window.d.ts +1 -0
  104. package/dist/solution/BookingByStep/index.js +59 -35
  105. package/dist/solution/BookingByStep/types.d.ts +3 -2
  106. package/dist/solution/BookingTicket/index.d.ts +172 -0
  107. package/dist/solution/BookingTicket/index.js +665 -0
  108. package/dist/solution/BookingTicket/types.d.ts +68 -0
  109. package/dist/solution/BookingTicket/types.js +43 -0
  110. package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +22 -0
  111. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +159 -0
  112. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +16 -0
  113. package/dist/solution/BookingTicket/utils/scan/handleScan.js +174 -0
  114. package/dist/solution/BookingTicket/utils/scan/index.d.ts +81 -0
  115. package/dist/solution/BookingTicket/utils/scan/index.js +285 -0
  116. package/dist/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
  117. package/dist/solution/BookingTicket/utils/scan/scanCache.js +305 -0
  118. package/dist/solution/BuyTickets/index.d.ts +2 -2
  119. package/dist/solution/BuyTickets/index.js +1 -1
  120. package/dist/solution/Checkout/appointmentDemo.json +1 -0
  121. package/dist/solution/Checkout/index.d.ts +181 -0
  122. package/dist/solution/Checkout/index.js +1596 -0
  123. package/dist/solution/Checkout/types.d.ts +550 -0
  124. package/dist/solution/Checkout/types.js +132 -0
  125. package/dist/solution/Checkout/utils/index.d.ts +73 -0
  126. package/dist/solution/Checkout/utils/index.js +371 -0
  127. package/dist/solution/ShopDiscount/index.js +4 -2
  128. package/dist/solution/index.d.ts +2 -0
  129. package/dist/solution/index.js +3 -1
  130. package/dist/types/index.d.ts +3 -1
  131. package/dist/utils/task.d.ts +40 -0
  132. package/dist/utils/task.js +171 -0
  133. package/dist/utils/watch.d.ts +102 -0
  134. package/dist/utils/watch.js +294 -0
  135. package/lib/core/index.js +1 -1
  136. package/lib/effects/index.d.ts +4 -3
  137. package/lib/effects/index.js +4 -1
  138. package/lib/modules/AccountList/index.d.ts +7 -1
  139. package/lib/modules/AccountList/index.js +27 -0
  140. package/lib/modules/AccountList/types.d.ts +28 -0
  141. package/lib/modules/Cart/index.js +1 -1
  142. package/lib/modules/Cart/utils/changePrice.d.ts +2 -2
  143. package/lib/modules/Cart/utils/changePrice.js +1 -1
  144. package/lib/modules/Customer/constants.d.ts +7 -0
  145. package/lib/modules/Customer/constants.js +39 -0
  146. package/lib/modules/Customer/index.d.ts +122 -0
  147. package/lib/modules/Customer/index.js +440 -0
  148. package/lib/modules/Customer/types.d.ts +146 -0
  149. package/lib/modules/Customer/types.js +37 -0
  150. package/lib/modules/Payment/cash.d.ts +11 -0
  151. package/lib/modules/Payment/cash.js +51 -0
  152. package/lib/modules/Payment/eftpos.d.ts +11 -0
  153. package/lib/modules/Payment/eftpos.js +51 -0
  154. package/lib/modules/Payment/index.d.ts +273 -9
  155. package/lib/modules/Payment/index.js +1285 -50
  156. package/lib/modules/Payment/types.d.ts +382 -30
  157. package/lib/modules/Payment/types.js +41 -6
  158. package/lib/modules/Payment/wallet.d.ts +11 -0
  159. package/lib/modules/Payment/wallet.js +51 -0
  160. package/lib/modules/Payment/walletpass.d.ts +0 -0
  161. package/lib/modules/Payment/walletpass.js +0 -0
  162. package/lib/modules/ProductList/index.d.ts +14 -3
  163. package/lib/modules/ProductList/index.js +42 -28
  164. package/lib/modules/ProductList/types.d.ts +0 -1
  165. package/lib/modules/Rules/index.js +20 -12
  166. package/lib/modules/Rules/types.d.ts +1 -0
  167. package/lib/modules/index.d.ts +1 -0
  168. package/lib/modules/index.js +2 -0
  169. package/lib/plugins/app-types/app/app.d.ts +83 -0
  170. package/lib/plugins/app-types/app/const.d.ts +4 -0
  171. package/lib/plugins/app-types/app/index.d.ts +14 -0
  172. package/lib/plugins/app-types/applicationManager/application.d.ts +50 -0
  173. package/lib/plugins/app-types/applicationManager/index.d.ts +13 -0
  174. package/lib/plugins/app-types/config.d.ts +3 -0
  175. package/lib/plugins/app-types/cookie/index.d.ts +13 -0
  176. package/lib/plugins/app-types/data/index.d.ts +8 -0
  177. package/lib/plugins/app-types/history/config.d.ts +24 -0
  178. package/lib/plugins/app-types/history/index.d.ts +20 -0
  179. package/lib/plugins/app-types/history/type.d.ts +2 -0
  180. package/lib/plugins/app-types/hooks/index.d.ts +12 -0
  181. package/lib/plugins/app-types/hooks/useDelayedValue/index.d.ts +2 -0
  182. package/lib/plugins/app-types/hooks/useDispatch/index.d.ts +2 -0
  183. package/lib/plugins/app-types/hooks/useLowCode/index.d.ts +13 -0
  184. package/lib/plugins/app-types/hooks/useStore/index.d.ts +6 -0
  185. package/lib/plugins/app-types/index.d.ts +6 -0
  186. package/lib/plugins/app-types/indexDB/index.d.ts +178 -0
  187. package/lib/plugins/app-types/locales/en.d.ts +3 -0
  188. package/lib/plugins/app-types/locales/index.d.ts +37 -0
  189. package/lib/plugins/app-types/locales/original.d.ts +3 -0
  190. package/lib/plugins/app-types/locales/type.d.ts +19 -0
  191. package/lib/plugins/app-types/locales/zh-CN.d.ts +3 -0
  192. package/lib/plugins/app-types/locales/zh-HK.d.ts +3 -0
  193. package/lib/plugins/app-types/logger/feishu.d.ts +11 -0
  194. package/lib/plugins/app-types/logger/index.d.ts +122 -0
  195. package/lib/plugins/app-types/menuManager/hooks.d.ts +17 -0
  196. package/lib/plugins/app-types/menuManager/index.d.ts +28 -0
  197. package/lib/plugins/app-types/models/global.d.ts +32 -0
  198. package/lib/plugins/app-types/models/index.d.ts +45 -0
  199. package/lib/plugins/app-types/models/type.d.ts +2 -0
  200. package/lib/plugins/app-types/package.json +15 -0
  201. package/lib/plugins/app-types/plugin/index.d.ts +0 -0
  202. package/lib/plugins/app-types/pubsub/example.d.ts +5 -0
  203. package/lib/plugins/app-types/pubsub/index.d.ts +63 -0
  204. package/lib/plugins/app-types/request/cache.d.ts +46 -0
  205. package/lib/plugins/app-types/request/cancelToken.d.ts +38 -0
  206. package/lib/plugins/app-types/request/config.d.ts +3 -0
  207. package/lib/plugins/app-types/request/constants.d.ts +2 -0
  208. package/lib/plugins/app-types/request/index.d.ts +24 -0
  209. package/lib/plugins/app-types/request/pisell2Request.d.ts +6 -0
  210. package/lib/plugins/app-types/request/type.d.ts +41 -0
  211. package/lib/plugins/app-types/request/utils.d.ts +46 -0
  212. package/lib/plugins/app-types/routes/config.d.ts +7 -0
  213. package/lib/plugins/app-types/routes/index.d.ts +28 -0
  214. package/lib/plugins/app-types/socket/components/SocketMonitorPage.d.ts +6 -0
  215. package/lib/plugins/app-types/socket/components/index.d.ts +2 -0
  216. package/lib/plugins/app-types/socket/constants.d.ts +33 -0
  217. package/lib/plugins/app-types/socket/events.d.ts +31 -0
  218. package/lib/plugins/app-types/socket/heartbeat.d.ts +66 -0
  219. package/lib/plugins/app-types/socket/index.d.ts +61 -0
  220. package/lib/plugins/app-types/socket/monitor.d.ts +169 -0
  221. package/lib/plugins/app-types/socket/reconnect.d.ts +61 -0
  222. package/lib/plugins/app-types/socket/socket.d.ts +129 -0
  223. package/lib/plugins/app-types/socket/types.d.ts +85 -0
  224. package/lib/plugins/app-types/storage/index.d.ts +17 -0
  225. package/lib/plugins/app-types/tasks/index.d.ts +77 -0
  226. package/lib/plugins/app-types/tasks/type.d.ts +62 -0
  227. package/lib/plugins/app-types/tasks/useTasks.d.ts +5 -0
  228. package/lib/plugins/app-types/type.d.ts +2 -0
  229. package/lib/plugins/app-types/variables/VariablesProvider.d.ts +7 -0
  230. package/lib/plugins/app-types/variables/config.d.ts +3 -0
  231. package/lib/plugins/app-types/variables/index.d.ts +6 -0
  232. package/lib/plugins/app-types/variables/type.d.ts +2 -0
  233. package/lib/plugins/app-types/website/index.d.ts +6 -0
  234. package/lib/plugins/app.d.ts +8 -0
  235. package/lib/plugins/app.js +17 -0
  236. package/lib/plugins/window.d.ts +1 -0
  237. package/lib/solution/BookingByStep/index.js +40 -29
  238. package/lib/solution/BookingByStep/types.d.ts +3 -2
  239. package/lib/solution/BookingTicket/index.d.ts +172 -0
  240. package/lib/solution/BookingTicket/index.js +399 -0
  241. package/lib/solution/BookingTicket/types.d.ts +68 -0
  242. package/lib/solution/BookingTicket/types.js +72 -0
  243. package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +22 -0
  244. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +117 -0
  245. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +16 -0
  246. package/lib/solution/BookingTicket/utils/scan/handleScan.js +125 -0
  247. package/lib/solution/BookingTicket/utils/scan/index.d.ts +81 -0
  248. package/lib/solution/BookingTicket/utils/scan/index.js +210 -0
  249. package/lib/solution/BookingTicket/utils/scan/scanCache.d.ts +78 -0
  250. package/lib/solution/BookingTicket/utils/scan/scanCache.js +231 -0
  251. package/lib/solution/BuyTickets/index.d.ts +2 -2
  252. package/lib/solution/BuyTickets/index.js +1 -1
  253. package/lib/solution/Checkout/appointmentDemo.json +1 -0
  254. package/lib/solution/Checkout/index.d.ts +181 -0
  255. package/lib/solution/Checkout/index.js +864 -0
  256. package/lib/solution/Checkout/types.d.ts +550 -0
  257. package/lib/solution/Checkout/types.js +75 -0
  258. package/lib/solution/Checkout/utils/index.d.ts +73 -0
  259. package/lib/solution/Checkout/utils/index.js +266 -0
  260. package/lib/solution/ShopDiscount/index.js +2 -1
  261. package/lib/solution/index.d.ts +2 -0
  262. package/lib/solution/index.js +5 -1
  263. package/lib/types/index.d.ts +3 -1
  264. package/lib/utils/task.d.ts +40 -0
  265. package/lib/utils/task.js +109 -0
  266. package/lib/utils/watch.d.ts +102 -0
  267. package/lib/utils/watch.js +217 -0
  268. package/package.json +4 -2
@@ -0,0 +1,266 @@
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/solution/Checkout/utils/index.ts
20
+ var utils_exports = {};
21
+ __export(utils_exports, {
22
+ calculateProgress: () => calculateProgress,
23
+ createCheckoutError: () => createCheckoutError,
24
+ debounce: () => debounce,
25
+ deepClone: () => deepClone,
26
+ formatAmount: () => formatAmount,
27
+ generateOrderId: () => generateOrderId,
28
+ getErrorMessage: () => getErrorMessage,
29
+ isEmpty: () => isEmpty,
30
+ isProduction: () => isProduction,
31
+ isValidPaymentMethodCode: () => isValidPaymentMethodCode,
32
+ logger: () => logger,
33
+ retry: () => retry,
34
+ safeJsonParse: () => safeJsonParse,
35
+ throttle: () => throttle,
36
+ validateAmount: () => validateAmount,
37
+ validateCheckoutData: () => validateCheckoutData
38
+ });
39
+ module.exports = __toCommonJS(utils_exports);
40
+ var import_types = require("../types");
41
+ function validateCheckoutData(params) {
42
+ const errors = [];
43
+ if (!params.cartItems || params.cartItems.length === 0) {
44
+ errors.push("购物车不能为空");
45
+ }
46
+ if (params.cartItems) {
47
+ params.cartItems.forEach((item, index) => {
48
+ if (!item.id) {
49
+ errors.push(`购物车商品 ${index + 1} 缺少商品ID`);
50
+ }
51
+ if (!item.price || parseFloat(String(item.price)) < 0) {
52
+ errors.push(`购物车商品 ${index + 1} 价格无效`);
53
+ }
54
+ if (!item.num || item.num <= 0) {
55
+ errors.push(`购物车商品 ${index + 1} 数量无效`);
56
+ }
57
+ });
58
+ }
59
+ if (params.orderType && !["virtual", "appointment_booking"].includes(params.orderType)) {
60
+ errors.push("订单类型无效,必须是 virtual 或 appointment_booking");
61
+ }
62
+ if (params.platform && !["pc", "h5"].includes(params.platform)) {
63
+ errors.push("平台类型无效,必须是 pc 或 h5");
64
+ }
65
+ return {
66
+ valid: errors.length === 0,
67
+ errors
68
+ };
69
+ }
70
+ function createCheckoutError(type, message, details) {
71
+ return {
72
+ type,
73
+ message,
74
+ details,
75
+ timestamp: Date.now()
76
+ };
77
+ }
78
+ function calculateProgress(status, step) {
79
+ let baseProgress = 0;
80
+ switch (status) {
81
+ case import_types.CheckoutStatus.Initializing:
82
+ baseProgress = 5;
83
+ break;
84
+ case import_types.CheckoutStatus.Ready:
85
+ baseProgress = 10;
86
+ break;
87
+ case import_types.CheckoutStatus.CreatingOrder:
88
+ baseProgress = 25;
89
+ break;
90
+ case import_types.CheckoutStatus.OrderCreated:
91
+ baseProgress = 40;
92
+ break;
93
+ case import_types.CheckoutStatus.ProcessingPayment:
94
+ baseProgress = 65;
95
+ break;
96
+ case import_types.CheckoutStatus.PaymentCompleted:
97
+ baseProgress = 85;
98
+ break;
99
+ case import_types.CheckoutStatus.Completed:
100
+ baseProgress = 100;
101
+ break;
102
+ case import_types.CheckoutStatus.Cancelled:
103
+ case import_types.CheckoutStatus.Error:
104
+ baseProgress = 0;
105
+ break;
106
+ default:
107
+ baseProgress = 0;
108
+ }
109
+ let stepProgress = 0;
110
+ switch (step) {
111
+ case import_types.CheckoutStep.OrderConfirmation:
112
+ stepProgress = 0;
113
+ break;
114
+ case import_types.CheckoutStep.PaymentMethod:
115
+ stepProgress = 10;
116
+ break;
117
+ case import_types.CheckoutStep.PaymentProcessing:
118
+ stepProgress = 15;
119
+ break;
120
+ case import_types.CheckoutStep.Complete:
121
+ stepProgress = 0;
122
+ break;
123
+ }
124
+ return Math.min(100, baseProgress + stepProgress);
125
+ }
126
+ function formatAmount(amount) {
127
+ const numAmount = typeof amount === "string" ? parseFloat(amount) : amount;
128
+ if (isNaN(numAmount))
129
+ return "0.00";
130
+ return numAmount.toFixed(2);
131
+ }
132
+ function validateAmount(amount) {
133
+ const numAmount = typeof amount === "string" ? parseFloat(amount) : amount;
134
+ return !isNaN(numAmount) && numAmount >= 0;
135
+ }
136
+ function generateOrderId(prefix = "order") {
137
+ const timestamp = Date.now();
138
+ const random = Math.floor(Math.random() * 1e4).toString().padStart(4, "0");
139
+ return `${prefix}_${timestamp}_${random}`;
140
+ }
141
+ function isValidPaymentMethodCode(code) {
142
+ return typeof code === "string" && code.length > 0 && /^[a-zA-Z0-9_-]+$/.test(code);
143
+ }
144
+ function safeJsonParse(jsonString, defaultValue) {
145
+ try {
146
+ return JSON.parse(jsonString);
147
+ } catch {
148
+ return defaultValue;
149
+ }
150
+ }
151
+ function deepClone(obj) {
152
+ if (obj === null || typeof obj !== "object") {
153
+ return obj;
154
+ }
155
+ if (obj instanceof Date) {
156
+ return new Date(obj.getTime());
157
+ }
158
+ if (obj instanceof Array) {
159
+ return obj.map((item) => deepClone(item));
160
+ }
161
+ if (typeof obj === "object") {
162
+ const clonedObj = {};
163
+ for (const key in obj) {
164
+ if (obj.hasOwnProperty(key)) {
165
+ clonedObj[key] = deepClone(obj[key]);
166
+ }
167
+ }
168
+ return clonedObj;
169
+ }
170
+ return obj;
171
+ }
172
+ function debounce(func, wait) {
173
+ let timeout = null;
174
+ return (...args) => {
175
+ if (timeout) {
176
+ clearTimeout(timeout);
177
+ }
178
+ timeout = setTimeout(() => {
179
+ func.apply(null, args);
180
+ }, wait);
181
+ };
182
+ }
183
+ function throttle(func, wait) {
184
+ let lastTime = 0;
185
+ return (...args) => {
186
+ const now = Date.now();
187
+ if (now - lastTime >= wait) {
188
+ lastTime = now;
189
+ func.apply(null, args);
190
+ }
191
+ };
192
+ }
193
+ async function retry(fn, maxAttempts = 3, delay = 1e3) {
194
+ let lastError;
195
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
196
+ try {
197
+ return await fn();
198
+ } catch (error) {
199
+ lastError = error;
200
+ if (attempt === maxAttempts) {
201
+ throw lastError;
202
+ }
203
+ await new Promise((resolve) => setTimeout(resolve, delay * attempt));
204
+ }
205
+ }
206
+ throw lastError;
207
+ }
208
+ function isEmpty(obj) {
209
+ if (obj == null)
210
+ return true;
211
+ if (Array.isArray(obj) || typeof obj === "string")
212
+ return obj.length === 0;
213
+ if (typeof obj === "object")
214
+ return Object.keys(obj).length === 0;
215
+ return false;
216
+ }
217
+ function getErrorMessage(error) {
218
+ if (error instanceof Error) {
219
+ return error.message;
220
+ }
221
+ if (typeof error === "string") {
222
+ return error;
223
+ }
224
+ if (error && typeof error === "object" && "message" in error) {
225
+ return String(error.message);
226
+ }
227
+ return "未知错误";
228
+ }
229
+ function isProduction() {
230
+ return process.env.NODE_ENV === "production";
231
+ }
232
+ var logger = {
233
+ info: (message, ...args) => {
234
+ console.log(`[Checkout] ${message}`, ...args);
235
+ },
236
+ warn: (message, ...args) => {
237
+ console.warn(`[Checkout] ${message}`, ...args);
238
+ },
239
+ error: (message, ...args) => {
240
+ console.error(`[Checkout] ${message}`, ...args);
241
+ },
242
+ debug: (message, ...args) => {
243
+ if (!isProduction()) {
244
+ console.debug(`[Checkout] ${message}`, ...args);
245
+ }
246
+ }
247
+ };
248
+ // Annotate the CommonJS export names for ESM import in node:
249
+ 0 && (module.exports = {
250
+ calculateProgress,
251
+ createCheckoutError,
252
+ debounce,
253
+ deepClone,
254
+ formatAmount,
255
+ generateOrderId,
256
+ getErrorMessage,
257
+ isEmpty,
258
+ isProduction,
259
+ isValidPaymentMethodCode,
260
+ logger,
261
+ retry,
262
+ safeJsonParse,
263
+ throttle,
264
+ validateAmount,
265
+ validateCheckoutData
266
+ });
@@ -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);
@@ -337,7 +338,7 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
337
338
  var _a2;
338
339
  const targetProduct = productList.find((n) => n.id === id);
339
340
  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));
341
+ 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
342
  };
342
343
  const allUsedProductIds = newDiscountList.map((n) => {
343
344
  var _a2;
@@ -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;