@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
@@ -0,0 +1,549 @@
1
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
2
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
3
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
4
+ 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); }
5
+ import { CheckoutStatus, CheckoutStep } from "../types";
6
+ import { PaymentMethodType } from "../../../modules/Payment/types";
7
+
8
+ /**
9
+ * 验证结账数据
10
+ */
11
+ export function validateCheckoutData(params) {
12
+ var errors = [];
13
+
14
+ // 验证购物车商品
15
+ if (!params.cartItems || params.cartItems.length === 0) {
16
+ errors.push('购物车不能为空');
17
+ }
18
+
19
+ // 验证购物车商品数据完整性
20
+ if (params.cartItems) {
21
+ params.cartItems.forEach(function (item, index) {
22
+ if (!item.id) {
23
+ errors.push("\u8D2D\u7269\u8F66\u5546\u54C1 ".concat(index + 1, " \u7F3A\u5C11\u5546\u54C1ID"));
24
+ }
25
+ if (!item.price || parseFloat(String(item.price)) < 0) {
26
+ errors.push("\u8D2D\u7269\u8F66\u5546\u54C1 ".concat(index + 1, " \u4EF7\u683C\u65E0\u6548"));
27
+ }
28
+ if (!item.num || item.num <= 0) {
29
+ errors.push("\u8D2D\u7269\u8F66\u5546\u54C1 ".concat(index + 1, " \u6570\u91CF\u65E0\u6548"));
30
+ }
31
+ });
32
+ }
33
+
34
+ // 验证订单类型
35
+ if (params.orderType && !['virtual', 'appointment_booking'].includes(params.orderType)) {
36
+ errors.push('订单类型无效,必须是 virtual 或 appointment_booking');
37
+ }
38
+
39
+ // 验证平台类型
40
+ if (params.platform && !['pc', 'h5'].includes(params.platform)) {
41
+ errors.push('平台类型无效,必须是 pc 或 h5');
42
+ }
43
+ return {
44
+ valid: errors.length === 0,
45
+ errors: errors
46
+ };
47
+ }
48
+
49
+ /**
50
+ * 创建结账错误对象
51
+ */
52
+ export function createCheckoutError(type, message, details) {
53
+ return {
54
+ type: type,
55
+ message: message,
56
+ details: details,
57
+ timestamp: Date.now()
58
+ };
59
+ }
60
+
61
+ /**
62
+ * 计算结账进度
63
+ */
64
+ export function calculateProgress(status, step) {
65
+ // 基于状态的基础进度
66
+ var baseProgress = 0;
67
+ switch (status) {
68
+ case CheckoutStatus.Initializing:
69
+ baseProgress = 5;
70
+ break;
71
+ case CheckoutStatus.Ready:
72
+ baseProgress = 10;
73
+ break;
74
+ case CheckoutStatus.CreatingOrder:
75
+ baseProgress = 25;
76
+ break;
77
+ case CheckoutStatus.OrderCreated:
78
+ baseProgress = 40;
79
+ break;
80
+ case CheckoutStatus.ProcessingPayment:
81
+ baseProgress = 65;
82
+ break;
83
+ case CheckoutStatus.PaymentCompleted:
84
+ baseProgress = 85;
85
+ break;
86
+ case CheckoutStatus.Completed:
87
+ baseProgress = 100;
88
+ break;
89
+ case CheckoutStatus.Cancelled:
90
+ case CheckoutStatus.Error:
91
+ baseProgress = 0;
92
+ break;
93
+ default:
94
+ baseProgress = 0;
95
+ }
96
+
97
+ // 基于步骤的额外进度
98
+ var stepProgress = 0;
99
+ switch (step) {
100
+ case CheckoutStep.OrderConfirmation:
101
+ stepProgress = 0;
102
+ break;
103
+ case CheckoutStep.PaymentMethod:
104
+ stepProgress = 10;
105
+ break;
106
+ case CheckoutStep.PaymentProcessing:
107
+ stepProgress = 15;
108
+ break;
109
+ case CheckoutStep.Complete:
110
+ stepProgress = 0; // 已经在状态中体现
111
+ break;
112
+ }
113
+ return Math.min(100, baseProgress + stepProgress);
114
+ }
115
+
116
+ /**
117
+ * 格式化金额
118
+ */
119
+ export function formatAmount(amount) {
120
+ var numAmount = typeof amount === 'string' ? parseFloat(amount) : amount;
121
+ if (isNaN(numAmount)) return '0.00';
122
+ return numAmount.toFixed(2);
123
+ }
124
+
125
+ /**
126
+ * 验证金额
127
+ */
128
+ export function validateAmount(amount) {
129
+ var numAmount = typeof amount === 'string' ? parseFloat(amount) : amount;
130
+ return !isNaN(numAmount) && numAmount >= 0;
131
+ }
132
+
133
+ /**
134
+ * 生成唯一订单ID
135
+ */
136
+ export function generateOrderId() {
137
+ var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'order';
138
+ var timestamp = Date.now();
139
+ var random = Math.floor(Math.random() * 10000).toString().padStart(4, '0');
140
+ return "".concat(prefix, "_").concat(timestamp, "_").concat(random);
141
+ }
142
+
143
+ /**
144
+ * 检查是否为有效的支付方式代码
145
+ */
146
+ export function isValidPaymentMethodCode(code) {
147
+ // 基本的支付方式代码验证
148
+ return typeof code === 'string' && code.length > 0 && /^[a-zA-Z0-9_-]+$/.test(code);
149
+ }
150
+
151
+ /**
152
+ * 安全地解析JSON
153
+ */
154
+ export function safeJsonParse(jsonString, defaultValue) {
155
+ try {
156
+ return JSON.parse(jsonString);
157
+ } catch (_unused) {
158
+ return defaultValue;
159
+ }
160
+ }
161
+
162
+ /**
163
+ * 深度克隆对象
164
+ */
165
+ export function deepClone(obj) {
166
+ if (obj === null || _typeof(obj) !== 'object') {
167
+ return obj;
168
+ }
169
+ if (obj instanceof Date) {
170
+ return new Date(obj.getTime());
171
+ }
172
+ if (obj instanceof Array) {
173
+ return obj.map(function (item) {
174
+ return deepClone(item);
175
+ });
176
+ }
177
+ if (_typeof(obj) === 'object') {
178
+ var clonedObj = {};
179
+ for (var key in obj) {
180
+ if (obj.hasOwnProperty(key)) {
181
+ clonedObj[key] = deepClone(obj[key]);
182
+ }
183
+ }
184
+ return clonedObj;
185
+ }
186
+ return obj;
187
+ }
188
+
189
+ /**
190
+ * 防抖函数
191
+ */
192
+ export function debounce(func, wait) {
193
+ var timeout = null;
194
+ return function () {
195
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
196
+ args[_key] = arguments[_key];
197
+ }
198
+ if (timeout) {
199
+ clearTimeout(timeout);
200
+ }
201
+ timeout = setTimeout(function () {
202
+ func.apply(null, args);
203
+ }, wait);
204
+ };
205
+ }
206
+
207
+ /**
208
+ * 节流函数
209
+ */
210
+ export function throttle(func, wait) {
211
+ var lastTime = 0;
212
+ return function () {
213
+ var now = Date.now();
214
+ if (now - lastTime >= wait) {
215
+ lastTime = now;
216
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
217
+ args[_key2] = arguments[_key2];
218
+ }
219
+ func.apply(null, args);
220
+ }
221
+ };
222
+ }
223
+
224
+ /**
225
+ * 重试函数
226
+ */
227
+ export function retry(_x) {
228
+ return _retry.apply(this, arguments);
229
+ }
230
+
231
+ /**
232
+ * 检查对象是否为空
233
+ */
234
+ function _retry() {
235
+ _retry = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(fn) {
236
+ var maxAttempts,
237
+ delay,
238
+ lastError,
239
+ _loop,
240
+ _ret,
241
+ attempt,
242
+ _args2 = arguments;
243
+ return _regeneratorRuntime().wrap(function _callee$(_context2) {
244
+ while (1) switch (_context2.prev = _context2.next) {
245
+ case 0:
246
+ maxAttempts = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : 3;
247
+ delay = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : 1000;
248
+ _loop = /*#__PURE__*/_regeneratorRuntime().mark(function _loop(attempt) {
249
+ return _regeneratorRuntime().wrap(function _loop$(_context) {
250
+ while (1) switch (_context.prev = _context.next) {
251
+ case 0:
252
+ _context.prev = 0;
253
+ _context.next = 3;
254
+ return fn();
255
+ case 3:
256
+ _context.t0 = _context.sent;
257
+ return _context.abrupt("return", {
258
+ v: _context.t0
259
+ });
260
+ case 7:
261
+ _context.prev = 7;
262
+ _context.t1 = _context["catch"](0);
263
+ lastError = _context.t1;
264
+ if (!(attempt === maxAttempts)) {
265
+ _context.next = 12;
266
+ break;
267
+ }
268
+ throw lastError;
269
+ case 12:
270
+ _context.next = 14;
271
+ return new Promise(function (resolve) {
272
+ return setTimeout(resolve, delay * attempt);
273
+ });
274
+ case 14:
275
+ case "end":
276
+ return _context.stop();
277
+ }
278
+ }, _loop, null, [[0, 7]]);
279
+ });
280
+ attempt = 1;
281
+ case 4:
282
+ if (!(attempt <= maxAttempts)) {
283
+ _context2.next = 12;
284
+ break;
285
+ }
286
+ return _context2.delegateYield(_loop(attempt), "t0", 6);
287
+ case 6:
288
+ _ret = _context2.t0;
289
+ if (!_ret) {
290
+ _context2.next = 9;
291
+ break;
292
+ }
293
+ return _context2.abrupt("return", _ret.v);
294
+ case 9:
295
+ attempt++;
296
+ _context2.next = 4;
297
+ break;
298
+ case 12:
299
+ throw lastError;
300
+ case 13:
301
+ case "end":
302
+ return _context2.stop();
303
+ }
304
+ }, _callee);
305
+ }));
306
+ return _retry.apply(this, arguments);
307
+ }
308
+ export function isEmpty(obj) {
309
+ if (obj == null) return true;
310
+ if (Array.isArray(obj) || typeof obj === 'string') return obj.length === 0;
311
+ if (_typeof(obj) === 'object') return Object.keys(obj).length === 0;
312
+ return false;
313
+ }
314
+
315
+ /**
316
+ * 获取错误消息
317
+ */
318
+ export function getErrorMessage(error) {
319
+ if (error instanceof Error) {
320
+ return error.message;
321
+ }
322
+ if (typeof error === 'string') {
323
+ return error;
324
+ }
325
+ if (error && _typeof(error) === 'object' && 'message' in error) {
326
+ return String(error.message);
327
+ }
328
+ return '未知错误';
329
+ }
330
+
331
+ /**
332
+ * 检查是否为生产环境
333
+ */
334
+ export function isProduction() {
335
+ return process.env.NODE_ENV === 'production';
336
+ }
337
+
338
+ /**
339
+ * 日志记录器
340
+ */
341
+ export var logger = {
342
+ info: function info(message) {
343
+ var _console;
344
+ for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
345
+ args[_key3 - 1] = arguments[_key3];
346
+ }
347
+ (_console = console).log.apply(_console, ["[Checkout] ".concat(message)].concat(args));
348
+ },
349
+ warn: function warn(message) {
350
+ var _console2;
351
+ for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
352
+ args[_key4 - 1] = arguments[_key4];
353
+ }
354
+ (_console2 = console).warn.apply(_console2, ["[Checkout] ".concat(message)].concat(args));
355
+ },
356
+ error: function error(message) {
357
+ var _console3;
358
+ for (var _len5 = arguments.length, args = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
359
+ args[_key5 - 1] = arguments[_key5];
360
+ }
361
+ (_console3 = console).error.apply(_console3, ["[Checkout] ".concat(message)].concat(args));
362
+ },
363
+ debug: function debug(message) {
364
+ if (!isProduction()) {
365
+ var _console4;
366
+ for (var _len6 = arguments.length, args = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) {
367
+ args[_key6 - 1] = arguments[_key6];
368
+ }
369
+ (_console4 = console).debug.apply(_console4, ["[Checkout] ".concat(message)].concat(args));
370
+ }
371
+ }
372
+ };
373
+
374
+ // ========== 从 CheckoutImpl 类中移出的纯静态方法 ==========
375
+
376
+ /**
377
+ * 验证本地订单数据
378
+ */
379
+ export function validateLocalOrderData(orderData) {
380
+ var _orderData$relation_p;
381
+ var errors = [];
382
+
383
+ // 验证基本字段
384
+ if (!orderData.type) {
385
+ errors.push('订单类型不能为空');
386
+ }
387
+ if (!orderData.platform) {
388
+ errors.push('平台信息不能为空');
389
+ }
390
+ if ((!orderData.bookings || orderData.bookings.length === 0) && !(orderData !== null && orderData !== void 0 && (_orderData$relation_p = orderData.relation_products) !== null && _orderData$relation_p !== void 0 && _orderData$relation_p.length)) {
391
+ errors.push('预订信息不能为空');
392
+ }
393
+
394
+ // 验证预订信息
395
+ if (orderData.bookings) {
396
+ orderData.bookings.forEach(function (booking, index) {
397
+ if (!booking.product || !booking.product.product_id) {
398
+ errors.push("\u9884\u8BA2\u9879 ".concat(index + 1, " \u7F3A\u5C11\u5546\u54C1\u4FE1\u606F"));
399
+ }
400
+ if (!booking.start_date) {
401
+ errors.push("\u9884\u8BA2\u9879 ".concat(index + 1, " \u7F3A\u5C11\u5F00\u59CB\u65E5\u671F"));
402
+ }
403
+ if (!booking.start_time) {
404
+ errors.push("\u9884\u8BA2\u9879 ".concat(index + 1, " \u7F3A\u5C11\u5F00\u59CB\u65F6\u95F4"));
405
+ }
406
+ });
407
+ }
408
+ return {
409
+ valid: errors.length === 0,
410
+ errors: errors
411
+ };
412
+ }
413
+
414
+ /**
415
+ * 生成本地订单ID
416
+ */
417
+ export function generateLocalOrderId() {
418
+ var timestamp = Date.now();
419
+ var random = Math.floor(Math.random() * 10000).toString().padStart(4, '0');
420
+ return "local_order_".concat(timestamp, "_").concat(random);
421
+ }
422
+
423
+ /**
424
+ * 格式化日期时间为 YYYY-MM-DD hh:mm:ss 格式
425
+ *
426
+ * @param date 要格式化的日期对象
427
+ * @returns 格式化后的日期时间字符串
428
+ */
429
+ export function formatDateTime(date) {
430
+ var year = date.getFullYear();
431
+ var month = String(date.getMonth() + 1).padStart(2, '0');
432
+ var day = String(date.getDate()).padStart(2, '0');
433
+ var hours = String(date.getHours()).padStart(2, '0');
434
+ var minutes = String(date.getMinutes()).padStart(2, '0');
435
+ var seconds = String(date.getSeconds()).padStart(2, '0');
436
+ return "".concat(year, "-").concat(month, "-").concat(day, " ").concat(hours, ":").concat(minutes, ":").concat(seconds);
437
+ }
438
+
439
+ /**
440
+ * 从购物车小计数据中提取金额信息
441
+ */
442
+ export function extractAmountFromCartSummary(cartSummary) {
443
+ var result = {
444
+ totalAmount: '0.00',
445
+ subTotal: '0.00',
446
+ taxAmount: '0.00',
447
+ discountAmount: '0.00',
448
+ shopDiscountAmount: '0.00',
449
+ roundingAmount: '0.00'
450
+ };
451
+ cartSummary.forEach(function (item) {
452
+ var value = Number(item.value).toFixed(2);
453
+ switch (item.key) {
454
+ case 'expect_amount':
455
+ result.totalAmount = value;
456
+ break;
457
+ case 'sub_total':
458
+ result.subTotal = value;
459
+ break;
460
+ case 'tax':
461
+ result.taxAmount = value;
462
+ if (item.tax) {
463
+ result.taxDetails = item.tax;
464
+ }
465
+ break;
466
+ case 'discount':
467
+ result.discountAmount = value;
468
+ break;
469
+ case 'shop_discount':
470
+ result.shopDiscountAmount = value;
471
+ break;
472
+ case 'custom_roundingAmount':
473
+ result.roundingAmount = value;
474
+ break;
475
+ default:
476
+ // 处理其他可能的键,如定金等
477
+ if (item.key.includes('deposit')) {
478
+ result.depositAmount = value;
479
+ }
480
+ break;
481
+ }
482
+ });
483
+ console.log('[Checkout] 从购物车小计提取金额信息:', {
484
+ totalAmount: result.totalAmount,
485
+ subTotal: result.subTotal,
486
+ taxAmount: result.taxAmount,
487
+ discountAmount: result.discountAmount,
488
+ shopDiscountAmount: result.shopDiscountAmount,
489
+ roundingAmount: result.roundingAmount
490
+ });
491
+ return result;
492
+ }
493
+
494
+ /**
495
+ * 计算购物车总金额
496
+ */
497
+ export function calculateTotalAmount(cartItems) {
498
+ var total = cartItems.reduce(function (sum, item) {
499
+ var price = parseFloat(String(item.price) || '0');
500
+ var quantity = item.quantity || 1;
501
+ return sum + price * quantity;
502
+ }, 0);
503
+ return total.toFixed(2);
504
+ }
505
+
506
+ /**
507
+ * 判断订单ID是否为本地生成的虚拟ID
508
+ *
509
+ * @param orderId 订单ID
510
+ * @returns true 表示是虚拟ID,false 表示是真实的后端ID
511
+ */
512
+ export function isVirtualOrderId(orderId) {
513
+ return orderId.startsWith('local_order_');
514
+ }
515
+
516
+ /**
517
+ * 判断支付方式是否需要同步订单到后端
518
+ *
519
+ * 现金支付(CASHMANUAL)和自定义支付不需要同步,其他支付方式需要同步
520
+ *
521
+ * @param paymentCode 支付方式代码
522
+ * @param paymentType 支付方式类型
523
+ * @returns 是否需要同步订单
524
+ */
525
+ export function shouldSyncOrderForPayment(paymentCode, paymentType) {
526
+ var codeUpper = (paymentCode === null || paymentCode === void 0 ? void 0 : paymentCode.toUpperCase()) || '';
527
+ var typeUpper = (paymentType === null || paymentType === void 0 ? void 0 : paymentType.toUpperCase()) || '';
528
+
529
+ // 现金支付不需要同步 - 支持多种现金支付识别方式
530
+ var cashIdentifiers = ['CASHMANUAL', 'CASH', 'MANUAL'];
531
+ if (cashIdentifiers.some(function (id) {
532
+ return codeUpper.includes(id) || typeUpper.includes(id);
533
+ })) {
534
+ return false;
535
+ }
536
+
537
+ // 标准现金支付代码检查
538
+ if (paymentCode === PaymentMethodType.Cash || paymentType === PaymentMethodType.Cash) {
539
+ return false;
540
+ }
541
+
542
+ // 自定义支付不需要同步
543
+ if (codeUpper.includes('CUSTOM') || typeUpper.includes('CUSTOM')) {
544
+ return false;
545
+ }
546
+
547
+ // 其他支付方式都需要同步
548
+ return true;
549
+ }
@@ -1,6 +1,6 @@
1
1
  import { Module, PisellCore } from '../../types';
2
2
  import { BaseModule } from '../../modules/BaseModule';
3
- import { Customer } from './types';
3
+ import { Customer, SetDiscountSelectedParams } from './types';
4
4
  import { Discount } from '../../modules/Discount/types';
5
5
  export declare class ShopDiscountImpl extends BaseModule implements Module {
6
6
  protected defaultName: string;
@@ -19,17 +19,11 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
19
19
  private registerDependentModules;
20
20
  private registerEventListeners;
21
21
  setCustomer(customer: Customer): Promise<void>;
22
- calcDiscount(productList: Record<string, any>[], options?: {
23
- discountId: number;
24
- isSelected: boolean;
25
- }): {
22
+ calcDiscount(productList: Record<string, any>[], options?: SetDiscountSelectedParams): {
26
23
  productList: Record<string, any>[];
27
24
  discountList: Discount[];
28
25
  };
29
- setDiscountSelected({ discountId, isSelected, }: {
30
- discountId: number;
31
- isSelected: boolean;
32
- }): {
26
+ setDiscountSelected(params: SetDiscountSelectedParams): {
33
27
  productList: Record<string, any>[];
34
28
  discountList: Discount[];
35
29
  };
@@ -47,6 +41,7 @@ export declare class ShopDiscountImpl extends BaseModule implements Module {
47
41
  private setDiscountList;
48
42
  private getDiscountList;
49
43
  private getCustomerWallet;
44
+ private bestDiscount;
50
45
  private loadPrepareConfig;
51
46
  }
52
47
  export default ShopDiscountImpl;