@pisell/pisellos 0.0.568 → 0.0.570

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 (455) hide show
  1. package/dist/effects/index.d.ts +2 -2
  2. package/dist/model/strategy/adapter/dataVariant/type.d.ts +3 -3
  3. package/dist/model/strategy/adapter/itemRule/type.d.ts +6 -6
  4. package/dist/model/strategy/adapter/promotion/evaluator.js +3 -2
  5. package/dist/model/strategy/adapter/promotion/type.d.ts +5 -5
  6. package/dist/model/strategy/adapter/walletPass/utils.js +7 -4
  7. package/dist/model/strategy/type.d.ts +1 -1
  8. package/dist/modules/BaseModule.d.ts +2 -2
  9. package/dist/modules/BaseModule.js +4 -4
  10. package/dist/modules/BookingContext/index.d.ts +48 -0
  11. package/dist/modules/BookingContext/index.js +566 -0
  12. package/dist/modules/BookingContext/types.d.ts +102 -0
  13. package/dist/modules/BookingContext/types.js +51 -0
  14. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  15. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +302 -0
  16. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  17. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +149 -0
  18. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
  19. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +249 -0
  20. package/dist/modules/BookingContext/utils/flexible.d.ts +28 -0
  21. package/dist/modules/BookingContext/utils/flexible.js +56 -0
  22. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  23. package/dist/modules/BookingContext/utils/formatResourceList.js +38 -0
  24. package/dist/modules/BookingContext/utils/index.d.ts +11 -0
  25. package/dist/modules/BookingContext/utils/index.js +11 -0
  26. package/dist/modules/BookingContext/utils/noResource.d.ts +13 -0
  27. package/dist/modules/BookingContext/utils/noResource.js +77 -0
  28. package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
  29. package/dist/modules/BookingContext/utils/orderLineDisplay.js +36 -0
  30. package/dist/modules/BookingContext/utils/productExtend.d.ts +72 -0
  31. package/dist/modules/BookingContext/utils/productExtend.js +339 -0
  32. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  33. package/dist/modules/BookingContext/utils/resourceErrors.js +74 -0
  34. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  35. package/dist/modules/BookingContext/utils/resourceSelection.js +24 -0
  36. package/dist/modules/BookingContext/utils/resources.d.ts +80 -0
  37. package/dist/modules/BookingContext/utils/resources.js +486 -0
  38. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  39. package/dist/modules/BookingContext/utils/serviceTimes.js +151 -0
  40. package/dist/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  41. package/dist/modules/BookingContext/utils/timeSlices.js +100 -0
  42. package/dist/modules/Cart/utils/cartProduct.js +26 -5
  43. package/dist/modules/Cart/utils/changePrice.js +27 -20
  44. package/dist/modules/Customer/index.d.ts +20 -0
  45. package/dist/modules/Customer/index.js +172 -83
  46. package/dist/modules/Customer/types.d.ts +3 -1
  47. package/dist/modules/Discount/index.d.ts +2 -1
  48. package/dist/modules/Discount/index.js +37 -9
  49. package/dist/modules/Discount/types.d.ts +2 -1
  50. package/dist/modules/Holder/types.d.ts +1 -1
  51. package/dist/modules/OpenData/index.d.ts +8 -0
  52. package/dist/modules/OpenData/index.js +36 -16
  53. package/dist/modules/OpenData/types.d.ts +1 -1
  54. package/dist/modules/Order/index.d.ts +448 -23
  55. package/dist/modules/Order/index.js +5417 -561
  56. package/dist/modules/Order/types.d.ts +693 -88
  57. package/dist/modules/Order/types.js +68 -1
  58. package/dist/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
  59. package/dist/modules/Order/utils/bundleDiscountHydration.js +144 -0
  60. package/dist/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  61. package/dist/modules/Order/utils/manualProductDiscount.js +210 -0
  62. package/dist/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
  63. package/dist/modules/Order/utils/orderCollectionIdentity.js +405 -0
  64. package/dist/modules/Order/utils.d.ts +167 -18
  65. package/dist/modules/Order/utils.js +960 -165
  66. package/dist/modules/Payment/index.d.ts +10 -9
  67. package/dist/modules/Payment/index.js +465 -703
  68. package/dist/modules/Payment/types.d.ts +47 -23
  69. package/dist/modules/Payment/utils.d.ts +1 -1
  70. package/dist/modules/Payment/utils.js +4 -3
  71. package/dist/modules/Payment/walletpass.js +44 -29
  72. package/dist/modules/Product/index.d.ts +1 -1
  73. package/dist/modules/Product/types.d.ts +29 -7
  74. package/dist/modules/ProductList/index.d.ts +17 -13
  75. package/dist/modules/ProductList/index.js +184 -74
  76. package/dist/modules/ProductList/types.d.ts +17 -0
  77. package/dist/modules/Quotation/index.d.ts +22 -2
  78. package/dist/modules/Quotation/index.js +108 -42
  79. package/dist/modules/Quotation/types.d.ts +19 -0
  80. package/dist/modules/ResourcePlanner/index.d.ts +24 -0
  81. package/dist/modules/ResourcePlanner/index.js +181 -0
  82. package/dist/modules/ResourcePlanner/planner.d.ts +14 -0
  83. package/dist/modules/ResourcePlanner/planner.js +1069 -0
  84. package/dist/modules/ResourcePlanner/types.d.ts +227 -0
  85. package/dist/modules/ResourcePlanner/types.js +1 -0
  86. package/dist/modules/Rules/index.d.ts +8 -10
  87. package/dist/modules/Rules/index.js +222 -109
  88. package/dist/modules/Rules/types.d.ts +15 -4
  89. package/dist/modules/SalesSummary/index.d.ts +23 -26
  90. package/dist/modules/SalesSummary/index.js +152 -46
  91. package/dist/modules/SalesSummary/types.d.ts +9 -1
  92. package/dist/modules/SalesSummary/utils.d.ts +3 -22
  93. package/dist/modules/SalesSummary/utils.js +803 -163
  94. package/dist/modules/ScanOrderLogger/types.d.ts +2 -2
  95. package/dist/modules/Schedule/getDateIsInSchedule.d.ts +1 -1
  96. package/dist/modules/Schedule/getDateIsInSchedule.js +14 -7
  97. package/dist/modules/Schedule/index.d.ts +18 -5
  98. package/dist/modules/Schedule/index.js +78 -24
  99. package/dist/modules/Schedule/type.d.ts +7 -7
  100. package/dist/modules/Schedule/types.d.ts +11 -9
  101. package/dist/modules/Summary/index.js +4 -3
  102. package/dist/modules/SurchargeList/index.d.ts +18 -0
  103. package/dist/modules/SurchargeList/index.js +185 -0
  104. package/dist/modules/SurchargeList/types.d.ts +15 -0
  105. package/dist/modules/SurchargeList/types.js +1 -0
  106. package/dist/modules/index.d.ts +3 -0
  107. package/dist/modules/index.js +4 -1
  108. package/dist/plugins/app.d.ts +2 -0
  109. package/dist/plugins/request.d.ts +3 -2
  110. package/dist/server/index.d.ts +462 -8
  111. package/dist/server/index.js +6112 -656
  112. package/dist/server/modules/floor-plan/index.d.ts +39 -0
  113. package/dist/server/modules/floor-plan/index.js +595 -0
  114. package/dist/server/modules/floor-plan/types.d.ts +43 -0
  115. package/dist/server/modules/floor-plan/types.js +13 -0
  116. package/dist/server/modules/index.d.ts +7 -2
  117. package/dist/server/modules/index.js +6 -0
  118. package/dist/server/modules/menu/types.d.ts +1 -1
  119. package/dist/server/modules/order/index.d.ts +207 -14
  120. package/dist/server/modules/order/index.js +2326 -379
  121. package/dist/server/modules/order/types.d.ts +91 -20
  122. package/dist/server/modules/order/types.js +14 -1
  123. package/dist/server/modules/order/utils/filterBookings.d.ts +7 -1
  124. package/dist/server/modules/order/utils/filterBookings.js +118 -11
  125. package/dist/server/modules/order/utils/filterOrders.js +242 -14
  126. package/dist/server/modules/payment/index.d.ts +28 -0
  127. package/dist/server/modules/payment/index.js +305 -0
  128. package/dist/server/modules/payment/types.d.ts +9 -0
  129. package/dist/server/modules/payment/types.js +1 -0
  130. package/dist/server/modules/products/index.d.ts +105 -14
  131. package/dist/server/modules/products/index.js +1393 -516
  132. package/dist/server/modules/products/types.d.ts +35 -2
  133. package/dist/server/modules/products/types.js +4 -0
  134. package/dist/server/modules/quotation/index.d.ts +39 -0
  135. package/dist/server/modules/quotation/index.js +278 -66
  136. package/dist/server/modules/resource/index.d.ts +2 -3
  137. package/dist/server/modules/resource/index.js +108 -86
  138. package/dist/server/modules/resource/types.d.ts +1 -1
  139. package/dist/server/modules/schedule/index.d.ts +6 -4
  140. package/dist/server/modules/schedule/index.js +116 -85
  141. package/dist/server/modules/schedule/utils.d.ts +1 -1
  142. package/dist/server/test.json +713 -0
  143. package/dist/server/types.d.ts +6 -4
  144. package/dist/server/utils/product.js +2 -2
  145. package/dist/server/utils/small-ticket.d.ts +71 -0
  146. package/dist/server/utils/small-ticket.js +963 -0
  147. package/dist/solution/BaseSales/index.d.ts +378 -0
  148. package/dist/solution/BaseSales/index.js +4006 -0
  149. package/dist/solution/BaseSales/types.d.ts +394 -0
  150. package/dist/solution/BaseSales/types.js +40 -0
  151. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +287 -0
  152. package/dist/solution/BaseSales/utils/cartPromotion.js +1450 -0
  153. package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +144 -0
  154. package/dist/solution/BaseSales/utils/parseSalesResponse.js +157 -0
  155. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +18 -0
  156. package/dist/solution/BaseSales/utils/quotationPrice.js +250 -0
  157. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +63 -0
  158. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +218 -0
  159. package/dist/solution/BaseSales/utils.d.ts +40 -0
  160. package/dist/solution/BaseSales/utils.js +263 -0
  161. package/dist/solution/BookingByStep/index.d.ts +2 -2
  162. package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
  163. package/dist/solution/BookingTicket/index.d.ts +382 -25
  164. package/dist/solution/BookingTicket/index.js +2506 -443
  165. package/dist/solution/BookingTicket/types.d.ts +191 -6
  166. package/dist/solution/BookingTicket/types.js +83 -10
  167. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +117 -0
  168. package/dist/solution/BookingTicket/utils/addProductDecision.js +346 -0
  169. package/dist/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
  170. package/dist/solution/BookingTicket/utils/addTimeAvailability.js +95 -0
  171. package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +77 -0
  172. package/dist/solution/BookingTicket/utils/bookingStatus.js +136 -0
  173. package/dist/solution/BookingTicket/utils/cartView.d.ts +29 -0
  174. package/dist/solution/BookingTicket/utils/cartView.js +209 -0
  175. package/dist/solution/BookingTicket/utils/exampleData.d.ts +123 -0
  176. package/dist/solution/BookingTicket/utils/exampleData.js +183 -0
  177. package/dist/solution/BookingTicket/utils/orderCustomer.d.ts +4 -0
  178. package/dist/solution/BookingTicket/utils/orderCustomer.js +31 -0
  179. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
  180. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.js +438 -0
  181. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
  182. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +400 -0
  183. package/dist/solution/BookingTicket/utils/scan/cloudSearch.d.ts +4 -0
  184. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +41 -1
  185. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
  186. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +56 -0
  187. package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  188. package/dist/solution/BookingTicket/utils/scan/handleScan.js +11 -3
  189. package/dist/solution/BookingTicket/utils/scan/index.d.ts +5 -0
  190. package/dist/solution/BookingTicket/utils/scan/index.js +20 -8
  191. package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
  192. package/dist/solution/BookingTicket/utils/scan/scanProductValues.js +150 -0
  193. package/dist/solution/BookingTicket/utils/sessionCatalogStale.d.ts +23 -0
  194. package/dist/solution/BookingTicket/utils/sessionCatalogStale.js +78 -0
  195. package/dist/solution/Checkout/index.d.ts +1 -0
  196. package/dist/solution/Checkout/index.js +25 -34
  197. package/dist/solution/Checkout/utils/index.js +4 -4
  198. package/dist/solution/RegisterAndLogin/config.js +2 -10
  199. package/dist/solution/Sales/index.d.ts +50 -5
  200. package/dist/solution/Sales/index.js +484 -92
  201. package/dist/solution/Sales/types.d.ts +29 -5
  202. package/dist/solution/ScanOrder/index.d.ts +27 -21
  203. package/dist/solution/ScanOrder/index.js +499 -434
  204. package/dist/solution/ScanOrder/types.d.ts +38 -16
  205. package/dist/solution/ScanOrder/types.js +4 -5
  206. package/dist/solution/ScanOrder/utils.d.ts +4 -1
  207. package/dist/solution/ScanOrder/utils.js +109 -34
  208. package/dist/solution/ShopDiscount/index.js +4 -4
  209. package/dist/solution/ShopDiscount/types.d.ts +1 -1
  210. package/dist/solution/ShopDiscount/utils.d.ts +2 -2
  211. package/dist/solution/UnifiedBookingSales/index.d.ts +183 -0
  212. package/dist/solution/UnifiedBookingSales/index.js +1871 -0
  213. package/dist/solution/UnifiedBookingSales/types.d.ts +143 -0
  214. package/dist/solution/UnifiedBookingSales/types.js +11 -0
  215. package/dist/solution/VenueBooking/index.d.ts +29 -20
  216. package/dist/solution/VenueBooking/index.js +301 -213
  217. package/dist/solution/VenueBooking/sales-section-4-annotated.json +0 -2
  218. package/dist/solution/VenueBooking/types.d.ts +1 -1
  219. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +6 -0
  220. package/dist/solution/VenueBooking/utils/slotMerge.js +9 -3
  221. package/dist/solution/index.d.ts +2 -0
  222. package/dist/solution/index.js +3 -1
  223. package/dist/types/index.d.ts +12 -2
  224. package/dist/utils/task.d.ts +2 -2
  225. package/dist/utils/watch.d.ts +2 -2
  226. package/lib/effects/index.d.ts +2 -2
  227. package/lib/model/strategy/adapter/dataVariant/type.d.ts +3 -3
  228. package/lib/model/strategy/adapter/itemRule/type.d.ts +6 -6
  229. package/lib/model/strategy/adapter/promotion/evaluator.js +3 -2
  230. package/lib/model/strategy/adapter/promotion/type.d.ts +5 -5
  231. package/lib/model/strategy/adapter/walletPass/utils.js +6 -4
  232. package/lib/model/strategy/type.d.ts +1 -1
  233. package/lib/modules/BaseModule.d.ts +2 -2
  234. package/lib/modules/BaseModule.js +4 -4
  235. package/lib/modules/BookingContext/index.d.ts +48 -0
  236. package/lib/modules/BookingContext/index.js +390 -0
  237. package/lib/modules/BookingContext/types.d.ts +102 -0
  238. package/lib/modules/BookingContext/types.js +48 -0
  239. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +16 -0
  240. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +286 -0
  241. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +8 -0
  242. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +148 -0
  243. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +76 -0
  244. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +242 -0
  245. package/lib/modules/BookingContext/utils/flexible.d.ts +28 -0
  246. package/lib/modules/BookingContext/utils/flexible.js +63 -0
  247. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +8 -0
  248. package/lib/modules/BookingContext/utils/formatResourceList.js +35 -0
  249. package/lib/modules/BookingContext/utils/index.d.ts +11 -0
  250. package/lib/modules/BookingContext/utils/index.js +126 -0
  251. package/lib/modules/BookingContext/utils/noResource.d.ts +13 -0
  252. package/lib/modules/BookingContext/utils/noResource.js +78 -0
  253. package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +1 -0
  254. package/lib/modules/BookingContext/utils/orderLineDisplay.js +29 -0
  255. package/lib/modules/BookingContext/utils/productExtend.d.ts +72 -0
  256. package/lib/modules/BookingContext/utils/productExtend.js +330 -0
  257. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +41 -0
  258. package/lib/modules/BookingContext/utils/resourceErrors.js +80 -0
  259. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +7 -0
  260. package/lib/modules/BookingContext/utils/resourceSelection.js +24 -0
  261. package/lib/modules/BookingContext/utils/resources.d.ts +80 -0
  262. package/lib/modules/BookingContext/utils/resources.js +419 -0
  263. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +55 -0
  264. package/lib/modules/BookingContext/utils/serviceTimes.js +161 -0
  265. package/lib/modules/BookingContext/utils/timeSlices.d.ts +42 -0
  266. package/lib/modules/BookingContext/utils/timeSlices.js +114 -0
  267. package/lib/modules/Cart/utils/cartProduct.js +27 -5
  268. package/lib/modules/Cart/utils/changePrice.js +20 -14
  269. package/lib/modules/Customer/index.d.ts +20 -0
  270. package/lib/modules/Customer/index.js +63 -10
  271. package/lib/modules/Customer/types.d.ts +3 -1
  272. package/lib/modules/Discount/index.d.ts +2 -1
  273. package/lib/modules/Discount/index.js +18 -2
  274. package/lib/modules/Discount/types.d.ts +2 -1
  275. package/lib/modules/Holder/types.d.ts +1 -1
  276. package/lib/modules/OpenData/index.d.ts +8 -0
  277. package/lib/modules/OpenData/index.js +21 -3
  278. package/lib/modules/OpenData/types.d.ts +1 -1
  279. package/lib/modules/Order/index.d.ts +448 -23
  280. package/lib/modules/Order/index.js +3641 -308
  281. package/lib/modules/Order/types.d.ts +693 -88
  282. package/lib/modules/Order/types.js +55 -1
  283. package/lib/modules/Order/utils/bundleDiscountHydration.d.ts +5 -0
  284. package/lib/modules/Order/utils/bundleDiscountHydration.js +106 -0
  285. package/lib/modules/Order/utils/manualProductDiscount.d.ts +106 -0
  286. package/lib/modules/Order/utils/manualProductDiscount.js +207 -0
  287. package/lib/modules/Order/utils/orderCollectionIdentity.d.ts +53 -0
  288. package/lib/modules/Order/utils/orderCollectionIdentity.js +353 -0
  289. package/lib/modules/Order/utils.d.ts +167 -18
  290. package/lib/modules/Order/utils.js +974 -138
  291. package/lib/modules/Payment/index.d.ts +10 -9
  292. package/lib/modules/Payment/index.js +30 -124
  293. package/lib/modules/Payment/types.d.ts +47 -23
  294. package/lib/modules/Payment/utils.d.ts +1 -1
  295. package/lib/modules/Payment/utils.js +4 -3
  296. package/lib/modules/Payment/walletpass.js +16 -6
  297. package/lib/modules/Product/index.d.ts +1 -1
  298. package/lib/modules/Product/types.d.ts +29 -7
  299. package/lib/modules/ProductList/index.d.ts +17 -13
  300. package/lib/modules/ProductList/index.js +92 -51
  301. package/lib/modules/ProductList/types.d.ts +17 -0
  302. package/lib/modules/Quotation/index.d.ts +22 -2
  303. package/lib/modules/Quotation/index.js +76 -20
  304. package/lib/modules/Quotation/types.d.ts +19 -0
  305. package/lib/modules/ResourcePlanner/index.d.ts +24 -0
  306. package/lib/modules/ResourcePlanner/index.js +147 -0
  307. package/lib/modules/ResourcePlanner/planner.d.ts +14 -0
  308. package/lib/modules/ResourcePlanner/planner.js +895 -0
  309. package/lib/modules/ResourcePlanner/types.d.ts +227 -0
  310. package/lib/modules/ResourcePlanner/types.js +5 -0
  311. package/lib/modules/Rules/index.d.ts +8 -10
  312. package/lib/modules/Rules/index.js +153 -61
  313. package/lib/modules/Rules/types.d.ts +15 -4
  314. package/lib/modules/SalesSummary/index.d.ts +23 -26
  315. package/lib/modules/SalesSummary/index.js +84 -16
  316. package/lib/modules/SalesSummary/types.d.ts +9 -1
  317. package/lib/modules/SalesSummary/utils.d.ts +3 -22
  318. package/lib/modules/SalesSummary/utils.js +616 -111
  319. package/lib/modules/ScanOrderLogger/types.d.ts +2 -2
  320. package/lib/modules/Schedule/getDateIsInSchedule.d.ts +1 -1
  321. package/lib/modules/Schedule/getDateIsInSchedule.js +14 -7
  322. package/lib/modules/Schedule/index.d.ts +18 -5
  323. package/lib/modules/Schedule/index.js +49 -14
  324. package/lib/modules/Schedule/type.d.ts +7 -7
  325. package/lib/modules/Schedule/types.d.ts +11 -9
  326. package/lib/modules/Summary/index.js +2 -2
  327. package/lib/modules/SurchargeList/index.d.ts +18 -0
  328. package/lib/modules/SurchargeList/index.js +95 -0
  329. package/lib/modules/SurchargeList/types.d.ts +15 -0
  330. package/lib/modules/SurchargeList/types.js +5 -0
  331. package/lib/modules/index.d.ts +3 -0
  332. package/lib/modules/index.js +33 -0
  333. package/lib/plugins/app.d.ts +2 -0
  334. package/lib/plugins/request.d.ts +3 -2
  335. package/lib/server/index.d.ts +462 -8
  336. package/lib/server/index.js +3901 -205
  337. package/lib/server/modules/floor-plan/index.d.ts +39 -0
  338. package/lib/server/modules/floor-plan/index.js +306 -0
  339. package/lib/server/modules/floor-plan/types.d.ts +43 -0
  340. package/lib/server/modules/floor-plan/types.js +19 -0
  341. package/lib/server/modules/index.d.ts +7 -2
  342. package/lib/server/modules/index.js +21 -0
  343. package/lib/server/modules/menu/types.d.ts +1 -1
  344. package/lib/server/modules/order/index.d.ts +207 -14
  345. package/lib/server/modules/order/index.js +1324 -141
  346. package/lib/server/modules/order/types.d.ts +91 -20
  347. package/lib/server/modules/order/types.js +11 -1
  348. package/lib/server/modules/order/utils/filterBookings.d.ts +7 -1
  349. package/lib/server/modules/order/utils/filterBookings.js +119 -11
  350. package/lib/server/modules/order/utils/filterOrders.js +238 -13
  351. package/lib/server/modules/payment/index.d.ts +28 -0
  352. package/lib/server/modules/payment/index.js +168 -0
  353. package/lib/server/modules/payment/types.d.ts +9 -0
  354. package/lib/server/modules/payment/types.js +5 -0
  355. package/lib/server/modules/products/index.d.ts +105 -14
  356. package/lib/server/modules/products/index.js +588 -97
  357. package/lib/server/modules/products/types.d.ts +35 -2
  358. package/lib/server/modules/products/types.js +3 -0
  359. package/lib/server/modules/quotation/index.d.ts +39 -0
  360. package/lib/server/modules/quotation/index.js +145 -1
  361. package/lib/server/modules/resource/index.d.ts +2 -3
  362. package/lib/server/modules/resource/index.js +71 -45
  363. package/lib/server/modules/resource/types.d.ts +1 -1
  364. package/lib/server/modules/schedule/index.d.ts +6 -4
  365. package/lib/server/modules/schedule/index.js +55 -44
  366. package/lib/server/modules/schedule/utils.d.ts +1 -1
  367. package/lib/server/test.json +713 -0
  368. package/lib/server/types.d.ts +6 -4
  369. package/lib/server/utils/product.js +2 -2
  370. package/lib/server/utils/small-ticket.d.ts +71 -0
  371. package/lib/server/utils/small-ticket.js +926 -0
  372. package/lib/solution/BaseSales/index.d.ts +378 -0
  373. package/lib/solution/BaseSales/index.js +2367 -0
  374. package/lib/solution/BaseSales/types.d.ts +394 -0
  375. package/lib/solution/BaseSales/types.js +47 -0
  376. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +287 -0
  377. package/lib/solution/BaseSales/utils/cartPromotion.js +1155 -0
  378. package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +144 -0
  379. package/lib/solution/BaseSales/utils/parseSalesResponse.js +140 -0
  380. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +18 -0
  381. package/lib/solution/BaseSales/utils/quotationPrice.js +231 -0
  382. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +63 -0
  383. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +215 -0
  384. package/lib/solution/BaseSales/utils.d.ts +40 -0
  385. package/lib/solution/BaseSales/utils.js +259 -0
  386. package/lib/solution/BookingByStep/index.d.ts +2 -2
  387. package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
  388. package/lib/solution/BookingTicket/index.d.ts +382 -25
  389. package/lib/solution/BookingTicket/index.js +1350 -76
  390. package/lib/solution/BookingTicket/types.d.ts +191 -6
  391. package/lib/solution/BookingTicket/types.js +71 -10
  392. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +117 -0
  393. package/lib/solution/BookingTicket/utils/addProductDecision.js +353 -0
  394. package/lib/solution/BookingTicket/utils/addTimeAvailability.d.ts +35 -0
  395. package/lib/solution/BookingTicket/utils/addTimeAvailability.js +94 -0
  396. package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +77 -0
  397. package/lib/solution/BookingTicket/utils/bookingStatus.js +136 -0
  398. package/lib/solution/BookingTicket/utils/cartView.d.ts +29 -0
  399. package/lib/solution/BookingTicket/utils/cartView.js +200 -0
  400. package/lib/solution/BookingTicket/utils/exampleData.d.ts +123 -0
  401. package/lib/solution/BookingTicket/utils/exampleData.js +185 -0
  402. package/lib/solution/BookingTicket/utils/orderCustomer.d.ts +4 -0
  403. package/lib/solution/BookingTicket/utils/orderCustomer.js +35 -0
  404. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +185 -0
  405. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +387 -0
  406. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +36 -0
  407. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +220 -0
  408. package/lib/solution/BookingTicket/utils/scan/cloudSearch.d.ts +4 -0
  409. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +24 -3
  410. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +32 -0
  411. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +64 -0
  412. package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +3 -1
  413. package/lib/solution/BookingTicket/utils/scan/handleScan.js +4 -2
  414. package/lib/solution/BookingTicket/utils/scan/index.d.ts +5 -0
  415. package/lib/solution/BookingTicket/utils/scan/index.js +14 -2
  416. package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +21 -0
  417. package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +115 -0
  418. package/lib/solution/BookingTicket/utils/sessionCatalogStale.d.ts +23 -0
  419. package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +83 -0
  420. package/lib/solution/Checkout/index.d.ts +1 -0
  421. package/lib/solution/Checkout/index.js +18 -19
  422. package/lib/solution/Checkout/utils/index.js +4 -4
  423. package/lib/solution/RegisterAndLogin/config.js +2 -10
  424. package/lib/solution/Sales/index.d.ts +50 -5
  425. package/lib/solution/Sales/index.js +296 -39
  426. package/lib/solution/Sales/types.d.ts +29 -5
  427. package/lib/solution/ScanOrder/index.d.ts +27 -21
  428. package/lib/solution/ScanOrder/index.js +144 -103
  429. package/lib/solution/ScanOrder/types.d.ts +38 -16
  430. package/lib/solution/ScanOrder/types.js +4 -5
  431. package/lib/solution/ScanOrder/utils.d.ts +4 -1
  432. package/lib/solution/ScanOrder/utils.js +98 -26
  433. package/lib/solution/ShopDiscount/index.js +3 -3
  434. package/lib/solution/ShopDiscount/types.d.ts +1 -1
  435. package/lib/solution/ShopDiscount/utils.d.ts +2 -2
  436. package/lib/solution/UnifiedBookingSales/index.d.ts +183 -0
  437. package/lib/solution/UnifiedBookingSales/index.js +1050 -0
  438. package/lib/solution/UnifiedBookingSales/types.d.ts +143 -0
  439. package/lib/solution/UnifiedBookingSales/types.js +14 -0
  440. package/lib/solution/VenueBooking/index.d.ts +29 -20
  441. package/lib/solution/VenueBooking/index.js +169 -94
  442. package/lib/solution/VenueBooking/sales-section-4-annotated.json +0 -2
  443. package/lib/solution/VenueBooking/types.d.ts +1 -1
  444. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +6 -0
  445. package/lib/solution/VenueBooking/utils/slotMerge.js +9 -3
  446. package/lib/solution/index.d.ts +2 -0
  447. package/lib/solution/index.js +22 -0
  448. package/lib/types/index.d.ts +12 -2
  449. package/lib/utils/task.d.ts +2 -2
  450. package/lib/utils/watch.d.ts +2 -2
  451. package/package.json +18 -19
  452. package/dist/model/strategy/adapter/promotion/index.d.ts +0 -4
  453. package/dist/solution/Checkout/appointmentDemo.json +0 -1
  454. package/lib/model/strategy/adapter/promotion/index.d.ts +0 -4
  455. package/lib/solution/Checkout/appointmentDemo.json +0 -1
@@ -76,6 +76,13 @@ function generateRequestUniqueId() {
76
76
 
77
77
  return "".concat(year).concat(month).concat(day).concat(hour).concat(minute).concat(second).concat(millisecond).concat(randomDigits);
78
78
  }
79
+ function normalizeCustomPaymentId(paymentItem) {
80
+ var _ref, _paymentItem$custom_p;
81
+ var rawId = (_ref = (_paymentItem$custom_p = paymentItem.custom_payment_id) !== null && _paymentItem$custom_p !== void 0 ? _paymentItem$custom_p : paymentItem.id) !== null && _ref !== void 0 ? _ref : 0;
82
+ var parsedId = Number(rawId);
83
+ if (!Number.isFinite(parsedId)) return 0;
84
+ return parsedId;
85
+ }
79
86
 
80
87
  /**
81
88
  * 支付模块实现
@@ -190,16 +197,15 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
190
197
  this.logger = this.app.logger;
191
198
 
192
199
  // 确保支付模块所需的对象存储已创建
193
- _context.next = 15;
194
- return this.ensurePaymentTables();
195
- case 15:
200
+ // await this.ensurePaymentTables();
201
+
196
202
  this.registerNetworkHandlers();
197
203
 
198
204
  // // 预连接数据库
199
205
  // this.dbManager.connect()
200
206
 
201
207
  this.logInfo('PaymentModule initialized successfully');
202
- case 17:
208
+ case 15:
203
209
  case "end":
204
210
  return _context.stop();
205
211
  }
@@ -210,6 +216,18 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
210
216
  }
211
217
  return initialize;
212
218
  }()
219
+ /**
220
+ * 更新父级解决方案透传的运行态参数,主要用于日志父模块等上下文。
221
+ *
222
+ * @example
223
+ * paymentModule.updateOtherParams({ fatherModule: 'bookingTicket' });
224
+ */
225
+ }, {
226
+ key: "updateOtherParams",
227
+ value: function updateOtherParams(params) {
228
+ this.otherParams = params || {};
229
+ }
230
+
213
231
  /**
214
232
  * 记录信息日志
215
233
  */
@@ -296,7 +314,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
296
314
  var network = this.app.plugins.get('network');
297
315
  this.logInfo('Registering network status listener');
298
316
  network === null || network === void 0 || network.addListener('networkStatusChange', /*#__PURE__*/function () {
299
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(status) {
317
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(status) {
300
318
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
301
319
  while (1) switch (_context2.prev = _context2.next) {
302
320
  case 0:
@@ -315,340 +333,82 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
315
333
  }, _callee2);
316
334
  }));
317
335
  return function (_x3) {
318
- return _ref.apply(this, arguments);
336
+ return _ref2.apply(this, arguments);
319
337
  };
320
338
  }());
321
339
  }
322
- }, {
323
- key: "filterPayMethods",
324
- value: function () {
325
- var _filterPayMethods = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(payMethods) {
326
- var walletPassMethod;
327
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
328
- while (1) switch (_context3.prev = _context3.next) {
329
- case 0:
330
- // 1. 筛选 status === 1 && disable === 0的数据
331
- // 2. 检查列表里是否有 code=WALLET_PASS的数据,如果没有,则列表里如果有 PRODUCTVOUCHER 、 GIFTCARD 、 POINTCARD 则删除他们
332
- // 如果有 code = WALLET_PASS的数据,则列表里PRODUCTVOUCHER 、 GIFTCARD 、 POINTCARD 的channel_application 指向 WALLET_PASS 的 channel_application
333
- payMethods = payMethods.filter(function (method) {
334
- return method.status === 1 && method.disable === 0;
335
- });
336
- walletPassMethod = payMethods.find(function (method) {
337
- return method.code === 'WALLET_PASS';
338
- });
339
- if (walletPassMethod) {
340
- payMethods.forEach(function (method) {
341
- if (method.code === 'PRODUCTVOUCHER' || method.code === 'GIFTCARD' || method.code === 'POINTCARD') {
342
- method.channel_application = walletPassMethod.channel_application;
343
- }
344
- });
345
- } else {
346
- payMethods = payMethods.filter(function (method) {
347
- return method.code !== 'PRODUCTVOUCHER' && method.code !== 'GIFTCARD' && method.code !== 'POINTCARD';
348
- });
349
- }
350
- return _context3.abrupt("return", payMethods);
351
- case 4:
352
- case "end":
353
- return _context3.stop();
354
- }
355
- }, _callee3);
356
- }));
357
- function filterPayMethods(_x4) {
358
- return _filterPayMethods.apply(this, arguments);
359
- }
360
- return filterPayMethods;
361
- }()
340
+
362
341
  /**
363
342
  * 获取支付方式列表
364
343
  */
365
344
  }, {
366
345
  key: "getPayMethodListAsync",
367
346
  value: (function () {
368
- var _getPayMethodListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
369
- var cachedMethods, hasCache, response, payMethods, _iterator2, _step2, method;
370
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
371
- while (1) switch (_context4.prev = _context4.next) {
347
+ var _getPayMethodListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
348
+ var response, payMethods;
349
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
350
+ while (1) switch (_context3.prev = _context3.next) {
372
351
  case 0:
373
352
  this.logInfo('Starting getPayMethodListAsync');
374
- _context4.prev = 1;
375
- // 先尝试从 IndexDB 获取缓存
376
- cachedMethods = [];
377
- _context4.prev = 3;
378
- _context4.next = 6;
379
- return this.dbManager.getAll('pay_method');
380
- case 6:
381
- cachedMethods = _context4.sent;
382
- _context4.next = 12;
383
- break;
384
- case 9:
385
- _context4.prev = 9;
386
- _context4.t0 = _context4["catch"](3);
387
- console.warn('[PaymentModule] pay_method 表不存在,将从服务器获取数据');
388
- case 12:
389
- // 如果有缓存,先返回缓存数据
390
- hasCache = cachedMethods.length > 0;
391
- if (!hasCache) {
392
- _context4.next = 16;
393
- break;
394
- }
395
- // 后台异步获取最新数据
396
- this.refreshPaymentMethodsInBackground(cachedMethods);
397
- return _context4.abrupt("return", cachedMethods);
398
- case 16:
399
- _context4.next = 18;
400
- return this.request.get('/pay/custom-payment/all');
401
- case 18:
402
- response = _context4.sent;
403
- response.data = this.filterPayMethods(response.data);
404
- payMethods = response.data || []; // 尝试缓存到 IndexDB
405
- _context4.prev = 21;
406
- _iterator2 = _createForOfIteratorHelper(payMethods);
407
- _context4.prev = 23;
408
- _iterator2.s();
409
- case 25:
410
- if ((_step2 = _iterator2.n()).done) {
411
- _context4.next = 31;
412
- break;
413
- }
414
- method = _step2.value;
415
- _context4.next = 29;
416
- return this.dbManager.update('pay_method', method);
417
- case 29:
418
- _context4.next = 25;
419
- break;
420
- case 31:
421
- _context4.next = 36;
422
- break;
423
- case 33:
424
- _context4.prev = 33;
425
- _context4.t1 = _context4["catch"](23);
426
- _iterator2.e(_context4.t1);
427
- case 36:
428
- _context4.prev = 36;
429
- _iterator2.f();
430
- return _context4.finish(36);
431
- case 39:
432
- _context4.next = 44;
433
- break;
434
- case 41:
435
- _context4.prev = 41;
436
- _context4.t2 = _context4["catch"](21);
437
- console.warn('[PaymentModule] 无法缓存支付方式,pay_method 表不存在');
438
- case 44:
439
- _context4.next = 46;
440
- return this.core.effects.emit("".concat(this.name, ":onPaymentMethodsLoaded"), payMethods);
441
- case 46:
353
+ _context3.prev = 1;
354
+ _context3.next = 4;
355
+ return this.request.get('/pay/custom-payment/all', {
356
+ filterPaymentMethods: true
357
+ }, {
358
+ osServer: true
359
+ });
360
+ case 4:
361
+ response = _context3.sent;
362
+ payMethods = (response === null || response === void 0 ? void 0 : response.data) || response || [];
442
363
  this.logInfo('getPayMethodListAsync completed successfully', {
443
364
  payMethods: payMethods
444
365
  });
445
- return _context4.abrupt("return", payMethods);
446
- case 50:
447
- _context4.prev = 50;
448
- _context4.t3 = _context4["catch"](1);
449
- console.error('[PaymentModule] 获取支付方式列表失败', _context4.t3);
450
- this.logError('getPayMethodListAsync failed', _context4.t3);
366
+ return _context3.abrupt("return", payMethods);
367
+ case 10:
368
+ _context3.prev = 10;
369
+ _context3.t0 = _context3["catch"](1);
370
+ console.error('[PaymentModule] 获取支付方式列表失败', _context3.t0);
371
+ this.logError('getPayMethodListAsync failed', _context3.t0);
451
372
  // 如果所有操作都失败,返回空数组
452
- return _context4.abrupt("return", []);
453
- case 55:
373
+ return _context3.abrupt("return", []);
374
+ case 15:
454
375
  case "end":
455
- return _context4.stop();
376
+ return _context3.stop();
456
377
  }
457
- }, _callee4, this, [[1, 50], [3, 9], [21, 41], [23, 33, 36, 39]]);
378
+ }, _callee3, this, [[1, 10]]);
458
379
  }));
459
380
  function getPayMethodListAsync() {
460
381
  return _getPayMethodListAsync.apply(this, arguments);
461
382
  }
462
383
  return getPayMethodListAsync;
463
384
  }()
464
- /**
465
- * 后台刷新支付方式列表
466
- */
467
- )
468
- }, {
469
- key: "refreshPaymentMethodsInBackground",
470
- value: (function () {
471
- var _refreshPaymentMethodsInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(cachedMethods) {
472
- var response, newPayMethods, hasChanges, _iterator3, _step3, method, _iterator4, _step4, _method, eventData;
473
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
474
- while (1) switch (_context5.prev = _context5.next) {
475
- case 0:
476
- this.logInfo('Starting refreshPaymentMethodsInBackground', {
477
- cachedMethodsCount: cachedMethods.length
478
- });
479
- _context5.prev = 1;
480
- _context5.next = 4;
481
- return this.request.get('/pay/custom-payment/all');
482
- case 4:
483
- response = _context5.sent;
484
- response.data = this.filterPayMethods(response.data);
485
- newPayMethods = response.data || []; // 检查是否有变化
486
- hasChanges = this.hasPaymentMethodsChanged(cachedMethods, newPayMethods);
487
- if (!hasChanges) {
488
- _context5.next = 55;
489
- break;
490
- }
491
- this.logInfo('Payment methods updated in background', {
492
- oldCount: cachedMethods.length,
493
- newCount: newPayMethods.length
494
- });
495
-
496
- // 更新缓存
497
- _context5.prev = 10;
498
- // 先清除旧数据
499
- _iterator3 = _createForOfIteratorHelper(cachedMethods);
500
- _context5.prev = 12;
501
- _iterator3.s();
502
- case 14:
503
- if ((_step3 = _iterator3.n()).done) {
504
- _context5.next = 20;
505
- break;
506
- }
507
- method = _step3.value;
508
- _context5.next = 18;
509
- return this.dbManager.delete('pay_method', method.id);
510
- case 18:
511
- _context5.next = 14;
512
- break;
513
- case 20:
514
- _context5.next = 25;
515
- break;
516
- case 22:
517
- _context5.prev = 22;
518
- _context5.t0 = _context5["catch"](12);
519
- _iterator3.e(_context5.t0);
520
- case 25:
521
- _context5.prev = 25;
522
- _iterator3.f();
523
- return _context5.finish(25);
524
- case 28:
525
- // 添加新数据
526
- _iterator4 = _createForOfIteratorHelper(newPayMethods);
527
- _context5.prev = 29;
528
- _iterator4.s();
529
- case 31:
530
- if ((_step4 = _iterator4.n()).done) {
531
- _context5.next = 37;
532
- break;
533
- }
534
- _method = _step4.value;
535
- _context5.next = 35;
536
- return this.dbManager.update('pay_method', _method);
537
- case 35:
538
- _context5.next = 31;
539
- break;
540
- case 37:
541
- _context5.next = 42;
542
- break;
543
- case 39:
544
- _context5.prev = 39;
545
- _context5.t1 = _context5["catch"](29);
546
- _iterator4.e(_context5.t1);
547
- case 42:
548
- _context5.prev = 42;
549
- _iterator4.f();
550
- return _context5.finish(42);
551
- case 45:
552
- _context5.next = 50;
553
- break;
554
- case 47:
555
- _context5.prev = 47;
556
- _context5.t2 = _context5["catch"](10);
557
- console.warn('[PaymentModule] 无法更新支付方式缓存', _context5.t2);
558
- case 50:
559
- // 通知外部支付方式已变化
560
- eventData = {
561
- oldMethods: cachedMethods,
562
- newMethods: newPayMethods
563
- };
564
- _context5.next = 53;
565
- return this.core.effects.emit("".concat(this.name, ":onPaymentMethodsChanged"), eventData);
566
- case 53:
567
- _context5.next = 55;
568
- break;
569
- case 55:
570
- _context5.next = 60;
571
- break;
572
- case 57:
573
- _context5.prev = 57;
574
- _context5.t3 = _context5["catch"](1);
575
- console.error('[PaymentModule] 后台刷新支付方式失败', _context5.t3);
576
- case 60:
577
- case "end":
578
- return _context5.stop();
579
- }
580
- }, _callee5, this, [[1, 57], [10, 47], [12, 22, 25, 28], [29, 39, 42, 45]]);
581
- }));
582
- function refreshPaymentMethodsInBackground(_x5) {
583
- return _refreshPaymentMethodsInBackground.apply(this, arguments);
584
- }
585
- return refreshPaymentMethodsInBackground;
586
- }()
587
- /**
588
- * 检查支付方式列表是否有变化
589
- */
590
- )
591
- }, {
592
- key: "hasPaymentMethodsChanged",
593
- value: function hasPaymentMethodsChanged(oldMethods, newMethods) {
594
- if (oldMethods.length !== newMethods.length) {
595
- return true;
596
- }
597
-
598
- // 创建旧数据的 Map 便于查找
599
- var oldMethodsMap = new Map(oldMethods.map(function (method) {
600
- return [method.id, method];
601
- }));
602
-
603
- // 检查每个新方法是否与旧方法相同
604
- var _iterator5 = _createForOfIteratorHelper(newMethods),
605
- _step5;
606
- try {
607
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
608
- var newMethod = _step5.value;
609
- var oldMethod = oldMethodsMap.get(newMethod.id);
610
- if (!oldMethod) {
611
- return true; // 新增方法
612
- }
613
-
614
- // 检查关键字段是否有变化
615
- if (oldMethod.code !== newMethod.code || oldMethod.name !== newMethod.name || oldMethod.type !== newMethod.type || oldMethod.description !== newMethod.description || oldMethod.status !== newMethod.status || oldMethod.disable !== newMethod.disable || oldMethod.is_surcharge !== newMethod.is_surcharge || oldMethod.fixed !== newMethod.fixed || oldMethod.percentage !== newMethod.percentage || oldMethod.enabled !== newMethod.enabled || JSON.stringify(oldMethod.channel_application || []) !== JSON.stringify(newMethod.channel_application || []) || JSON.stringify(oldMethod.companies || []) !== JSON.stringify(newMethod.companies || []) || JSON.stringify(oldMethod.metadata || {}) !== JSON.stringify(newMethod.metadata || {})) {
616
- return true; // 方法属性有变化
617
- }
618
- }
619
- } catch (err) {
620
- _iterator5.e(err);
621
- } finally {
622
- _iterator5.f();
623
- }
624
- return false;
625
- }
626
-
627
385
  /**
628
386
  * 获取订单列表
629
387
  */
388
+ /** @deprecated */
389
+ )
630
390
  }, {
631
391
  key: "getOrderListAsync",
632
392
  value: (function () {
633
- var _getOrderListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
634
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
635
- while (1) switch (_context6.prev = _context6.next) {
393
+ var _getOrderListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
394
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
395
+ while (1) switch (_context4.prev = _context4.next) {
636
396
  case 0:
637
- _context6.prev = 0;
638
- _context6.next = 3;
397
+ _context4.prev = 0;
398
+ _context4.next = 3;
639
399
  return this.dbManager.getAll('order');
640
400
  case 3:
641
- return _context6.abrupt("return", _context6.sent);
401
+ return _context4.abrupt("return", _context4.sent);
642
402
  case 6:
643
- _context6.prev = 6;
644
- _context6.t0 = _context6["catch"](0);
645
- console.error('[PaymentModule] 获取订单列表失败', _context6.t0);
646
- return _context6.abrupt("return", []);
403
+ _context4.prev = 6;
404
+ _context4.t0 = _context4["catch"](0);
405
+ console.error('[PaymentModule] 获取订单列表失败', _context4.t0);
406
+ return _context4.abrupt("return", []);
647
407
  case 10:
648
408
  case "end":
649
- return _context6.stop();
409
+ return _context4.stop();
650
410
  }
651
- }, _callee6, this, [[0, 6]]);
411
+ }, _callee4, this, [[0, 6]]);
652
412
  }));
653
413
  function getOrderListAsync() {
654
414
  return _getOrderListAsync.apply(this, arguments);
@@ -662,27 +422,27 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
662
422
  }, {
663
423
  key: "getPaymentOrderByUuidAsync",
664
424
  value: (function () {
665
- var _getPaymentOrderByUuidAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(orderUuid) {
666
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
667
- while (1) switch (_context7.prev = _context7.next) {
425
+ var _getPaymentOrderByUuidAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(orderUuid) {
426
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
427
+ while (1) switch (_context5.prev = _context5.next) {
668
428
  case 0:
669
- _context7.prev = 0;
670
- _context7.next = 3;
429
+ _context5.prev = 0;
430
+ _context5.next = 3;
671
431
  return this.dbManager.get('order', orderUuid, true);
672
432
  case 3:
673
- return _context7.abrupt("return", _context7.sent);
433
+ return _context5.abrupt("return", _context5.sent);
674
434
  case 6:
675
- _context7.prev = 6;
676
- _context7.t0 = _context7["catch"](0);
677
- console.error('[PaymentModule] 获取支付订单失败', _context7.t0);
678
- return _context7.abrupt("return", null);
435
+ _context5.prev = 6;
436
+ _context5.t0 = _context5["catch"](0);
437
+ console.error('[PaymentModule] 获取支付订单失败', _context5.t0);
438
+ return _context5.abrupt("return", null);
679
439
  case 10:
680
440
  case "end":
681
- return _context7.stop();
441
+ return _context5.stop();
682
442
  }
683
- }, _callee7, this, [[0, 6]]);
443
+ }, _callee5, this, [[0, 6]]);
684
444
  }));
685
- function getPaymentOrderByUuidAsync(_x6) {
445
+ function getPaymentOrderByUuidAsync(_x4) {
686
446
  return _getPaymentOrderByUuidAsync.apply(this, arguments);
687
447
  }
688
448
  return getPaymentOrderByUuidAsync;
@@ -694,17 +454,17 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
694
454
  }, {
695
455
  key: "createPaymentOrderAsync",
696
456
  value: (function () {
697
- var _createPaymentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
457
+ var _createPaymentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
698
458
  var _this4 = this;
699
459
  var newOrder, currentTime, dbAddStartTime, dbAddDuration;
700
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
701
- while (1) switch (_context8.prev = _context8.next) {
460
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
461
+ while (1) switch (_context6.prev = _context6.next) {
702
462
  case 0:
703
463
  this.logInfo('Starting createPaymentOrderAsync', {
704
464
  orderId: params.order_id,
705
465
  totalAmount: params.total_amount
706
466
  });
707
- _context8.prev = 1;
467
+ _context6.prev = 1;
708
468
  // 检测是否有重复的 order_id
709
469
  // console.time('createLocalOrderAsync: getExistingOrder')
710
470
  // const existingOrder = await this.dbManager.get('order', params.order_id);
@@ -790,7 +550,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
790
550
 
791
551
  // 🚀 性能监控:记录数据库添加操作耗时
792
552
  dbAddStartTime = Date.now();
793
- _context8.next = 7;
553
+ _context6.next = 7;
794
554
  return this.dbManager.add('order', newOrder, true);
795
555
  case 7:
796
556
  dbAddDuration = Date.now() - dbAddStartTime;
@@ -805,22 +565,22 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
805
565
  setTimeout(function () {
806
566
  _this4.core.effects.emit("".concat(_this4.name, ":onOrderAdded"), newOrder);
807
567
  }, 0);
808
- return _context8.abrupt("return", newOrder);
568
+ return _context6.abrupt("return", newOrder);
809
569
  case 13:
810
- _context8.prev = 13;
811
- _context8.t0 = _context8["catch"](1);
812
- console.error('[PaymentModule] 创建支付订单失败', _context8.t0);
813
- this.logError('createPaymentOrderAsync failed', _context8.t0, {
570
+ _context6.prev = 13;
571
+ _context6.t0 = _context6["catch"](1);
572
+ console.error('[PaymentModule] 创建支付订单失败', _context6.t0);
573
+ this.logError('createPaymentOrderAsync failed', _context6.t0, {
814
574
  orderId: params.order_id
815
575
  });
816
- throw _context8.t0;
576
+ throw _context6.t0;
817
577
  case 18:
818
578
  case "end":
819
- return _context8.stop();
579
+ return _context6.stop();
820
580
  }
821
- }, _callee8, this, [[1, 13]]);
581
+ }, _callee6, this, [[1, 13]]);
822
582
  }));
823
- function createPaymentOrderAsync(_x7) {
583
+ function createPaymentOrderAsync(_x5) {
824
584
  return _createPaymentOrderAsync.apply(this, arguments);
825
585
  }
826
586
  return createPaymentOrderAsync;
@@ -832,40 +592,40 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
832
592
  }, {
833
593
  key: "deletePaymentOrderAsync",
834
594
  value: (function () {
835
- var _deletePaymentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(orderUuid) {
595
+ var _deletePaymentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(orderUuid) {
836
596
  var order;
837
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
838
- while (1) switch (_context9.prev = _context9.next) {
597
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
598
+ while (1) switch (_context7.prev = _context7.next) {
839
599
  case 0:
840
- _context9.prev = 0;
841
- _context9.next = 3;
600
+ _context7.prev = 0;
601
+ _context7.next = 3;
842
602
  return this.dbManager.get('order', orderUuid);
843
603
  case 3:
844
- order = _context9.sent;
604
+ order = _context7.sent;
845
605
  if (!order) {
846
- _context9.next = 9;
606
+ _context7.next = 9;
847
607
  break;
848
608
  }
849
- _context9.next = 7;
609
+ _context7.next = 7;
850
610
  return this.dbManager.delete('order', orderUuid);
851
611
  case 7:
852
- _context9.next = 9;
612
+ _context7.next = 9;
853
613
  return this.core.effects.emit("".concat(this.name, ":onOrderDeleted"), order);
854
614
  case 9:
855
- _context9.next = 15;
615
+ _context7.next = 15;
856
616
  break;
857
617
  case 11:
858
- _context9.prev = 11;
859
- _context9.t0 = _context9["catch"](0);
860
- console.error('[PaymentModule] 删除支付订单失败', _context9.t0);
861
- throw _context9.t0;
618
+ _context7.prev = 11;
619
+ _context7.t0 = _context7["catch"](0);
620
+ console.error('[PaymentModule] 删除支付订单失败', _context7.t0);
621
+ throw _context7.t0;
862
622
  case 15:
863
623
  case "end":
864
- return _context9.stop();
624
+ return _context7.stop();
865
625
  }
866
- }, _callee9, this, [[0, 11]]);
626
+ }, _callee7, this, [[0, 11]]);
867
627
  }));
868
- function deletePaymentOrderAsync(_x8) {
628
+ function deletePaymentOrderAsync(_x6) {
869
629
  return _deletePaymentOrderAsync.apply(this, arguments);
870
630
  }
871
631
  return deletePaymentOrderAsync;
@@ -877,49 +637,49 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
877
637
  }, {
878
638
  key: "updateOrderAsync",
879
639
  value: (function () {
880
- var _updateOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(orderUuid, params) {
640
+ var _updateOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(orderUuid, params) {
881
641
  var order, updatedOrder;
882
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
883
- while (1) switch (_context10.prev = _context10.next) {
642
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
643
+ while (1) switch (_context8.prev = _context8.next) {
884
644
  case 0:
885
- _context10.prev = 0;
886
- _context10.next = 3;
645
+ _context8.prev = 0;
646
+ _context8.next = 3;
887
647
  return this.dbManager.get('order', orderUuid);
888
648
  case 3:
889
- order = _context10.sent;
649
+ order = _context8.sent;
890
650
  if (!order) {
891
- _context10.next = 13;
651
+ _context8.next = 13;
892
652
  break;
893
653
  }
894
654
  updatedOrder = _objectSpread(_objectSpread({}, order), params);
895
655
  this.recalculateOrderAmount(updatedOrder);
896
- _context10.next = 9;
656
+ _context8.next = 9;
897
657
  return this.dbManager.update('order', updatedOrder);
898
658
  case 9:
899
- _context10.next = 11;
659
+ _context8.next = 11;
900
660
  return this.core.effects.emit("".concat(this.name, ":onOrderUpdated"), updatedOrder);
901
661
  case 11:
902
- _context10.next = 13;
662
+ _context8.next = 13;
903
663
  return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
904
664
  action: 'update',
905
665
  order: updatedOrder,
906
666
  originalOrder: order
907
667
  });
908
668
  case 13:
909
- _context10.next = 19;
669
+ _context8.next = 19;
910
670
  break;
911
671
  case 15:
912
- _context10.prev = 15;
913
- _context10.t0 = _context10["catch"](0);
914
- console.error('[PaymentModule] 更新订单失败', _context10.t0);
915
- throw _context10.t0;
672
+ _context8.prev = 15;
673
+ _context8.t0 = _context8["catch"](0);
674
+ console.error('[PaymentModule] 更新订单失败', _context8.t0);
675
+ throw _context8.t0;
916
676
  case 19:
917
677
  case "end":
918
- return _context10.stop();
678
+ return _context8.stop();
919
679
  }
920
- }, _callee10, this, [[0, 15]]);
680
+ }, _callee8, this, [[0, 15]]);
921
681
  }));
922
- function updateOrderAsync(_x9, _x10) {
682
+ function updateOrderAsync(_x7, _x8) {
923
683
  return _updateOrderAsync.apply(this, arguments);
924
684
  }
925
685
  return updateOrderAsync;
@@ -938,38 +698,38 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
938
698
  }, {
939
699
  key: "replaceOrderIdByUuidAsync",
940
700
  value: (function () {
941
- var _replaceOrderIdByUuidAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(orderUuid, newOrderId) {
701
+ var _replaceOrderIdByUuidAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(orderUuid, newOrderId) {
942
702
  var existingOrder, allOrders, duplicateOrder, originalOrderId, updatedOrder;
943
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
944
- while (1) switch (_context11.prev = _context11.next) {
703
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
704
+ while (1) switch (_context9.prev = _context9.next) {
945
705
  case 0:
946
706
  this.logInfo('Starting replaceOrderIdByUuidAsync', {
947
707
  orderUuid: orderUuid,
948
708
  newOrderId: newOrderId
949
709
  });
950
- _context11.prev = 1;
951
- _context11.next = 4;
710
+ _context9.prev = 1;
711
+ _context9.next = 4;
952
712
  return this.dbManager.get('order', orderUuid);
953
713
  case 4:
954
- existingOrder = _context11.sent;
714
+ existingOrder = _context9.sent;
955
715
  if (existingOrder) {
956
- _context11.next = 8;
716
+ _context9.next = 8;
957
717
  break;
958
718
  }
959
719
  this.logWarning('Order not found for UUID replacement', {
960
720
  orderUuid: orderUuid
961
721
  });
962
- return _context11.abrupt("return", null);
722
+ return _context9.abrupt("return", null);
963
723
  case 8:
964
- _context11.next = 10;
724
+ _context9.next = 10;
965
725
  return this.dbManager.getAll('order');
966
726
  case 10:
967
- allOrders = _context11.sent;
727
+ allOrders = _context9.sent;
968
728
  duplicateOrder = allOrders.find(function (order) {
969
729
  return String(order.order_id) === String(newOrderId) && order.uuid !== orderUuid;
970
730
  });
971
731
  if (!duplicateOrder) {
972
- _context11.next = 15;
732
+ _context9.next = 15;
973
733
  break;
974
734
  }
975
735
  this.logWarning('New order ID already exists', {
@@ -991,13 +751,13 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
991
751
  updated_at: new Date().toISOString()
992
752
  })
993
753
  }); // 更新到数据库
994
- _context11.next = 19;
754
+ _context9.next = 19;
995
755
  return this.dbManager.update('order', updatedOrder);
996
756
  case 19:
997
- _context11.next = 21;
757
+ _context9.next = 21;
998
758
  return this.core.effects.emit("".concat(this.name, ":onOrderUpdated"), updatedOrder);
999
759
  case 21:
1000
- _context11.next = 23;
760
+ _context9.next = 23;
1001
761
  return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
1002
762
  action: 'order_id_replaced',
1003
763
  order: updatedOrder,
@@ -1013,23 +773,23 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1013
773
  originalOrderId: originalOrderId,
1014
774
  newOrderId: newOrderId
1015
775
  });
1016
- return _context11.abrupt("return", updatedOrder);
776
+ return _context9.abrupt("return", updatedOrder);
1017
777
  case 27:
1018
- _context11.prev = 27;
1019
- _context11.t0 = _context11["catch"](1);
1020
- console.error('[PaymentModule] 替换订单ID失败', _context11.t0);
1021
- this.logError('replaceOrderIdByUuidAsync failed', _context11.t0, {
778
+ _context9.prev = 27;
779
+ _context9.t0 = _context9["catch"](1);
780
+ console.error('[PaymentModule] 替换订单ID失败', _context9.t0);
781
+ this.logError('replaceOrderIdByUuidAsync failed', _context9.t0, {
1022
782
  orderUuid: orderUuid,
1023
783
  newOrderId: newOrderId
1024
784
  });
1025
- throw _context11.t0;
785
+ throw _context9.t0;
1026
786
  case 32:
1027
787
  case "end":
1028
- return _context11.stop();
788
+ return _context9.stop();
1029
789
  }
1030
- }, _callee11, this, [[1, 27]]);
790
+ }, _callee9, this, [[1, 27]]);
1031
791
  }));
1032
- function replaceOrderIdByUuidAsync(_x11, _x12) {
792
+ function replaceOrderIdByUuidAsync(_x9, _x10) {
1033
793
  return _replaceOrderIdByUuidAsync.apply(this, arguments);
1034
794
  }
1035
795
  return replaceOrderIdByUuidAsync;
@@ -1045,42 +805,42 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1045
805
  }, {
1046
806
  key: "getPaymentItemsAsync",
1047
807
  value: (function () {
1048
- var _getPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(orderUuid) {
808
+ var _getPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(orderUuid) {
1049
809
  var includeVoided,
1050
810
  order,
1051
811
  allPayments,
1052
- _args12 = arguments;
1053
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1054
- while (1) switch (_context12.prev = _context12.next) {
812
+ _args10 = arguments;
813
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
814
+ while (1) switch (_context10.prev = _context10.next) {
1055
815
  case 0:
1056
- includeVoided = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : false;
816
+ includeVoided = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : false;
1057
817
  if (orderUuid) {
1058
- _context12.next = 3;
818
+ _context10.next = 3;
1059
819
  break;
1060
820
  }
1061
821
  throw new Error('orderUuid is required');
1062
822
  case 3:
1063
- _context12.next = 5;
823
+ _context10.next = 5;
1064
824
  return this.getPaymentOrderByUuidAsync(orderUuid);
1065
825
  case 5:
1066
- order = _context12.sent;
826
+ order = _context10.sent;
1067
827
  allPayments = (order === null || order === void 0 ? void 0 : order.payment) || [];
1068
828
  if (!includeVoided) {
1069
- _context12.next = 9;
829
+ _context10.next = 9;
1070
830
  break;
1071
831
  }
1072
- return _context12.abrupt("return", allPayments);
832
+ return _context10.abrupt("return", allPayments);
1073
833
  case 9:
1074
- return _context12.abrupt("return", allPayments.filter(function (payment) {
834
+ return _context10.abrupt("return", allPayments.filter(function (payment) {
1075
835
  return payment.status !== 'voided';
1076
836
  }));
1077
837
  case 10:
1078
838
  case "end":
1079
- return _context12.stop();
839
+ return _context10.stop();
1080
840
  }
1081
- }, _callee12, this);
841
+ }, _callee10, this);
1082
842
  }));
1083
- function getPaymentItemsAsync(_x13) {
843
+ function getPaymentItemsAsync(_x11) {
1084
844
  return _getPaymentItemsAsync.apply(this, arguments);
1085
845
  }
1086
846
  return getPaymentItemsAsync;
@@ -1095,18 +855,18 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1095
855
  }, {
1096
856
  key: "getAllPaymentItemsAsync",
1097
857
  value: (function () {
1098
- var _getAllPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderUuid) {
1099
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1100
- while (1) switch (_context13.prev = _context13.next) {
858
+ var _getAllPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(orderUuid) {
859
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
860
+ while (1) switch (_context11.prev = _context11.next) {
1101
861
  case 0:
1102
- return _context13.abrupt("return", this.getPaymentItemsAsync(orderUuid, true));
862
+ return _context11.abrupt("return", this.getPaymentItemsAsync(orderUuid, true));
1103
863
  case 1:
1104
864
  case "end":
1105
- return _context13.stop();
865
+ return _context11.stop();
1106
866
  }
1107
- }, _callee13, this);
867
+ }, _callee11, this);
1108
868
  }));
1109
- function getAllPaymentItemsAsync(_x14) {
869
+ function getAllPaymentItemsAsync(_x12) {
1110
870
  return _getAllPaymentItemsAsync.apply(this, arguments);
1111
871
  }
1112
872
  return getAllPaymentItemsAsync;
@@ -1118,10 +878,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1118
878
  }, {
1119
879
  key: "addPaymentItemAsync",
1120
880
  value: (function () {
1121
- var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(orderUuid, paymentItem) {
881
+ var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(orderUuid, paymentItem) {
1122
882
  var _paymentItem$metadata, _newPaymentItem$metad, _newPaymentItem$metad2, _newPaymentItem$metad3, order, expectAmount, paidDepositAmount, expectedDepositAmount, warningMessage, paymentUuid, currentTime, newPaymentItem;
1123
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1124
- while (1) switch (_context14.prev = _context14.next) {
883
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
884
+ while (1) switch (_context12.prev = _context12.next) {
1125
885
  case 0:
1126
886
  this.logInfo('Starting addPaymentItemAsync', {
1127
887
  orderUuid: orderUuid,
@@ -1129,20 +889,20 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1129
889
  paymentCode: paymentItem.code,
1130
890
  orderPaymentType: paymentItem.order_payment_type
1131
891
  });
1132
- _context14.prev = 1;
892
+ _context12.prev = 1;
1133
893
  this.logInfo('准备获取订单', {
1134
894
  orderUuid: orderUuid
1135
895
  });
1136
- _context14.next = 5;
896
+ _context12.next = 5;
1137
897
  return this.getPaymentOrderByUuidAsync(orderUuid);
1138
898
  case 5:
1139
- order = _context14.sent;
899
+ order = _context12.sent;
1140
900
  this.logInfo('获取订单信息成功', {
1141
901
  orderUuid: orderUuid,
1142
902
  order: order
1143
903
  });
1144
904
  if (order) {
1145
- _context14.next = 9;
905
+ _context12.next = 9;
1146
906
  break;
1147
907
  }
1148
908
  throw new Error("Order not found: ".concat(orderUuid));
@@ -1157,7 +917,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1157
917
  }, new Decimal(0));
1158
918
  expectedDepositAmount = new Decimal(order.deposit_amount || '0').sub(paidDepositAmount); // 有一种特殊情况,订单金额为 0,但是定金金额>0,且此时是定金状态的,允许添加支付项
1159
919
  if (!(expectAmount.lte(0) && expectedDepositAmount.eq(0))) {
1160
- _context14.next = 17;
920
+ _context12.next = 17;
1161
921
  break;
1162
922
  }
1163
923
  warningMessage = "\u8BA2\u5355 ".concat(orderUuid, " \u5F85\u4ED8\u91D1\u989D\u5DF2\u4E3A0\uFF0C\u4E0D\u5141\u8BB8\u6DFB\u52A0\u65B0\u7684\u652F\u4ED8\u9879");
@@ -1183,12 +943,14 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1183
943
  currentTime = formatDateTime(new Date());
1184
944
  newPaymentItem = {
1185
945
  uuid: paymentUuid,
1186
- custom_payment_id: paymentItem.custom_payment_id || 0,
946
+ custom_payment_id: normalizeCustomPaymentId(paymentItem),
1187
947
  name: paymentItem.name,
1188
948
  code: paymentItem.code,
1189
949
  type: paymentItem.type,
1190
950
  amount: formatAmount(paymentItem.amount),
1191
951
  voucher_id: paymentItem.voucher_id || '',
952
+ wallet_pass_usage_unit: paymentItem.wallet_pass_usage_unit,
953
+ wallet_pass_use_value: paymentItem.wallet_pass_use_value,
1192
954
  rounding_amount: paymentItem.rounding_amount || '0.00',
1193
955
  service_charge: paymentItem.service_charge,
1194
956
  status: 'active',
@@ -1199,8 +961,6 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1199
961
  // 创建时间
1200
962
  updated_at: currentTime,
1201
963
  // 更新时间
1202
- wallet_pass_usage_unit: paymentItem === null || paymentItem === void 0 ? void 0 : paymentItem.wallet_pass_usage_unit,
1203
- wallet_pass_use_value: paymentItem === null || paymentItem === void 0 ? void 0 : paymentItem.wallet_pass_use_value,
1204
964
  metadata: _objectSpread(_objectSpread({}, paymentItem.metadata), {}, {
1205
965
  // 保留传入的所有 metadata 字段
1206
966
  unique_payment_number: paymentUuid // 设置唯一支付号为支付项的 uuid
@@ -1212,7 +972,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1212
972
  orderUuid: orderUuid,
1213
973
  order: order
1214
974
  });
1215
- _context14.next = 25;
975
+ _context12.next = 25;
1216
976
  return this.dbManager.update('order', order, true);
1217
977
  case 25:
1218
978
  this.logInfo('更新订单支付项完成', {
@@ -1235,24 +995,24 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1235
995
  actualPaidAmount: (_newPaymentItem$metad2 = newPaymentItem.metadata) === null || _newPaymentItem$metad2 === void 0 ? void 0 : _newPaymentItem$metad2.actual_paid_amount,
1236
996
  changeGivenAmount: (_newPaymentItem$metad3 = newPaymentItem.metadata) === null || _newPaymentItem$metad3 === void 0 ? void 0 : _newPaymentItem$metad3.change_given_amount
1237
997
  });
1238
- _context14.next = 35;
998
+ _context12.next = 35;
1239
999
  break;
1240
1000
  case 30:
1241
- _context14.prev = 30;
1242
- _context14.t0 = _context14["catch"](1);
1243
- console.error('[PaymentModule] 添加支付项失败', _context14.t0);
1244
- this.logError('addPaymentItemAsync failed', _context14.t0, {
1001
+ _context12.prev = 30;
1002
+ _context12.t0 = _context12["catch"](1);
1003
+ console.error('[PaymentModule] 添加支付项失败', _context12.t0);
1004
+ this.logError('addPaymentItemAsync failed', _context12.t0, {
1245
1005
  orderUuid: orderUuid,
1246
1006
  paymentItem: paymentItem
1247
1007
  });
1248
- throw _context14.t0;
1008
+ throw _context12.t0;
1249
1009
  case 35:
1250
1010
  case "end":
1251
- return _context14.stop();
1011
+ return _context12.stop();
1252
1012
  }
1253
- }, _callee14, this, [[1, 30]]);
1013
+ }, _callee12, this, [[1, 30]]);
1254
1014
  }));
1255
- function addPaymentItemAsync(_x15, _x16) {
1015
+ function addPaymentItemAsync(_x13, _x14) {
1256
1016
  return _addPaymentItemAsync.apply(this, arguments);
1257
1017
  }
1258
1018
  return addPaymentItemAsync;
@@ -1264,22 +1024,22 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1264
1024
  }, {
1265
1025
  key: "deletePaymentAsync",
1266
1026
  value: (function () {
1267
- var _deletePaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(orderUuid, paymentUuid) {
1027
+ var _deletePaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderUuid, paymentUuid) {
1268
1028
  var order, paymentItem;
1269
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1270
- while (1) switch (_context15.prev = _context15.next) {
1029
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1030
+ while (1) switch (_context13.prev = _context13.next) {
1271
1031
  case 0:
1272
1032
  this.logInfo('Starting deletePaymentAsync (mark as voided)', {
1273
1033
  orderUuid: orderUuid,
1274
1034
  paymentUuid: paymentUuid
1275
1035
  });
1276
- _context15.prev = 1;
1277
- _context15.next = 4;
1036
+ _context13.prev = 1;
1037
+ _context13.next = 4;
1278
1038
  return this.dbManager.get('order', orderUuid);
1279
1039
  case 4:
1280
- order = _context15.sent;
1040
+ order = _context13.sent;
1281
1041
  if (order) {
1282
- _context15.next = 7;
1042
+ _context13.next = 7;
1283
1043
  break;
1284
1044
  }
1285
1045
  throw new Error('订单不存在');
@@ -1288,17 +1048,17 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1288
1048
  return payment.uuid === paymentUuid;
1289
1049
  });
1290
1050
  if (paymentItem) {
1291
- _context15.next = 10;
1051
+ _context13.next = 10;
1292
1052
  break;
1293
1053
  }
1294
1054
  throw new Error("\u652F\u4ED8\u9879\u4E0D\u5B58\u5728: ".concat(paymentUuid));
1295
1055
  case 10:
1296
1056
  if (!(paymentItem.status === 'voided')) {
1297
- _context15.next = 13;
1057
+ _context13.next = 13;
1298
1058
  break;
1299
1059
  }
1300
1060
  console.warn("[PaymentModule] \u652F\u4ED8\u9879 ".concat(paymentUuid, " \u5DF2\u7ECF\u88AB\u5220\u9664\uFF0C\u8DF3\u8FC7\u64CD\u4F5C"));
1301
- return _context15.abrupt("return");
1061
+ return _context13.abrupt("return");
1302
1062
  case 13:
1303
1063
  // 标记删除而不是物理删除
1304
1064
  paymentItem.status = 'voided';
@@ -1309,16 +1069,16 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1309
1069
  this.recalculateOrderAmount(order);
1310
1070
 
1311
1071
  // 更新到 IndexDB
1312
- _context15.next = 19;
1072
+ _context13.next = 19;
1313
1073
  return this.dbManager.update('order', order);
1314
1074
  case 19:
1315
- _context15.next = 21;
1075
+ _context13.next = 21;
1316
1076
  return this.core.effects.emit("".concat(this.name, ":onPaymentDeleted"), {
1317
1077
  order: order,
1318
1078
  paymentItem: paymentItem
1319
1079
  });
1320
1080
  case 21:
1321
- _context15.next = 23;
1081
+ _context13.next = 23;
1322
1082
  return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
1323
1083
  action: 'payment_delete',
1324
1084
  order: order,
@@ -1331,24 +1091,24 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1331
1091
  originalAmount: paymentItem.origin_amount,
1332
1092
  newExpectAmount: order.expect_amount
1333
1093
  });
1334
- _context15.next = 31;
1094
+ _context13.next = 31;
1335
1095
  break;
1336
1096
  case 26:
1337
- _context15.prev = 26;
1338
- _context15.t0 = _context15["catch"](1);
1339
- console.error('[PaymentModule] 删除支付项失败', _context15.t0);
1340
- this.logError('deletePaymentAsync failed', _context15.t0, {
1097
+ _context13.prev = 26;
1098
+ _context13.t0 = _context13["catch"](1);
1099
+ console.error('[PaymentModule] 删除支付项失败', _context13.t0);
1100
+ this.logError('deletePaymentAsync failed', _context13.t0, {
1341
1101
  orderUuid: orderUuid,
1342
1102
  paymentUuid: paymentUuid
1343
1103
  });
1344
- throw _context15.t0;
1104
+ throw _context13.t0;
1345
1105
  case 31:
1346
1106
  case "end":
1347
- return _context15.stop();
1107
+ return _context13.stop();
1348
1108
  }
1349
- }, _callee15, this, [[1, 26]]);
1109
+ }, _callee13, this, [[1, 26]]);
1350
1110
  }));
1351
- function deletePaymentAsync(_x17, _x18) {
1111
+ function deletePaymentAsync(_x15, _x16) {
1352
1112
  return _deletePaymentAsync.apply(this, arguments);
1353
1113
  }
1354
1114
  return deletePaymentAsync;
@@ -1363,15 +1123,15 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1363
1123
  }, {
1364
1124
  key: "updateVoucherPaymentItemsAsync",
1365
1125
  value: (function () {
1366
- var _updateVoucherPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(orderUuid, voucherPaymentItems) {
1126
+ var _updateVoucherPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(orderUuid, voucherPaymentItems) {
1367
1127
  var _this5 = this;
1368
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1369
- while (1) switch (_context17.prev = _context17.next) {
1128
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1129
+ while (1) switch (_context15.prev = _context15.next) {
1370
1130
  case 0:
1371
- return _context17.abrupt("return", this.runVoucherUpdateLocked(orderUuid, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1372
- var _this5$normalizeVouch, normalizedVoucherItems, originalCount, normalizedCount, order, existingVoucherItems, _iterator6, _step6, voucherItem, orderAfterDelete, existingActiveVoucherKeys, _iterator7, _step7, _voucherItem, orderPaymentType, key, updatedOrder;
1373
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1374
- while (1) switch (_context16.prev = _context16.next) {
1131
+ return _context15.abrupt("return", this.runVoucherUpdateLocked(orderUuid, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
1132
+ var _this5$normalizeVouch, normalizedVoucherItems, originalCount, normalizedCount, order, existingVoucherItems, _iterator2, _step2, voucherItem, orderAfterDelete, existingActiveVoucherKeys, _iterator3, _step3, _voucherItem, orderPaymentType, key, updatedOrder;
1133
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1134
+ while (1) switch (_context14.prev = _context14.next) {
1375
1135
  case 0:
1376
1136
  _this5$normalizeVouch = _this5.normalizeVoucherPaymentItems(voucherPaymentItems), normalizedVoucherItems = _this5$normalizeVouch.items, originalCount = _this5$normalizeVouch.originalCount, normalizedCount = _this5$normalizeVouch.normalizedCount;
1377
1137
  _this5.logInfo('Starting updateVoucherPaymentItemsAsync', {
@@ -1394,13 +1154,13 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1394
1154
  normalizedCount: normalizedCount
1395
1155
  });
1396
1156
  }
1397
- _context16.prev = 3;
1398
- _context16.next = 6;
1157
+ _context14.prev = 3;
1158
+ _context14.next = 6;
1399
1159
  return _this5.getPaymentOrderByUuidAsync(orderUuid);
1400
1160
  case 6:
1401
- order = _context16.sent;
1161
+ order = _context14.sent;
1402
1162
  if (order) {
1403
- _context16.next = 9;
1163
+ _context14.next = 9;
1404
1164
  break;
1405
1165
  }
1406
1166
  throw new Error("\u8BA2\u5355\u4E0D\u5B58\u5728: ".concat(orderUuid));
@@ -1411,38 +1171,38 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1411
1171
  return payment.voucher_id && payment.status !== 'voided' && !payment.isSynced;
1412
1172
  });
1413
1173
  // 2. 删除所有现有的代金券支付项(仅删除未同步的)
1414
- _iterator6 = _createForOfIteratorHelper(existingVoucherItems);
1415
- _context16.prev = 11;
1416
- _iterator6.s();
1174
+ _iterator2 = _createForOfIteratorHelper(existingVoucherItems);
1175
+ _context14.prev = 11;
1176
+ _iterator2.s();
1417
1177
  case 13:
1418
- if ((_step6 = _iterator6.n()).done) {
1419
- _context16.next = 19;
1178
+ if ((_step2 = _iterator2.n()).done) {
1179
+ _context14.next = 19;
1420
1180
  break;
1421
1181
  }
1422
- voucherItem = _step6.value;
1423
- _context16.next = 17;
1182
+ voucherItem = _step2.value;
1183
+ _context14.next = 17;
1424
1184
  return _this5.deletePaymentAsync(orderUuid, voucherItem.uuid);
1425
1185
  case 17:
1426
- _context16.next = 13;
1186
+ _context14.next = 13;
1427
1187
  break;
1428
1188
  case 19:
1429
- _context16.next = 24;
1189
+ _context14.next = 24;
1430
1190
  break;
1431
1191
  case 21:
1432
- _context16.prev = 21;
1433
- _context16.t0 = _context16["catch"](11);
1434
- _iterator6.e(_context16.t0);
1192
+ _context14.prev = 21;
1193
+ _context14.t0 = _context14["catch"](11);
1194
+ _iterator2.e(_context14.t0);
1435
1195
  case 24:
1436
- _context16.prev = 24;
1437
- _iterator6.f();
1438
- return _context16.finish(24);
1196
+ _context14.prev = 24;
1197
+ _iterator2.f();
1198
+ return _context14.finish(24);
1439
1199
  case 27:
1440
- _context16.next = 29;
1200
+ _context14.next = 29;
1441
1201
  return _this5.getPaymentOrderByUuidAsync(orderUuid);
1442
1202
  case 29:
1443
- orderAfterDelete = _context16.sent;
1203
+ orderAfterDelete = _context14.sent;
1444
1204
  if (orderAfterDelete) {
1445
- _context16.next = 32;
1205
+ _context14.next = 32;
1446
1206
  break;
1447
1207
  }
1448
1208
  throw new Error("\u8BA2\u5355\u4E0D\u5B58\u5728: ".concat(orderUuid));
@@ -1452,19 +1212,19 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1452
1212
  }).map(function (p) {
1453
1213
  return "".concat(p.voucher_id, "|").concat(p.order_payment_type || 'normal');
1454
1214
  }));
1455
- _iterator7 = _createForOfIteratorHelper(normalizedVoucherItems);
1456
- _context16.prev = 34;
1457
- _iterator7.s();
1215
+ _iterator3 = _createForOfIteratorHelper(normalizedVoucherItems);
1216
+ _context14.prev = 34;
1217
+ _iterator3.s();
1458
1218
  case 36:
1459
- if ((_step7 = _iterator7.n()).done) {
1460
- _context16.next = 48;
1219
+ if ((_step3 = _iterator3.n()).done) {
1220
+ _context14.next = 48;
1461
1221
  break;
1462
1222
  }
1463
- _voucherItem = _step7.value;
1223
+ _voucherItem = _step3.value;
1464
1224
  orderPaymentType = _voucherItem.order_payment_type || 'normal';
1465
1225
  key = "".concat(_voucherItem.voucher_id, "|").concat(orderPaymentType);
1466
1226
  if (!existingActiveVoucherKeys.has(key)) {
1467
- _context16.next = 43;
1227
+ _context14.next = 43;
1468
1228
  break;
1469
1229
  }
1470
1230
  console.warn('[PaymentModule] Skip adding voucher payment item because it already exists (active)', {
@@ -1472,32 +1232,32 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1472
1232
  voucher_id: _voucherItem.voucher_id,
1473
1233
  order_payment_type: orderPaymentType
1474
1234
  });
1475
- return _context16.abrupt("continue", 46);
1235
+ return _context14.abrupt("continue", 46);
1476
1236
  case 43:
1477
- _context16.next = 45;
1237
+ _context14.next = 45;
1478
1238
  return _this5.addPaymentItemAsync(orderUuid, _voucherItem);
1479
1239
  case 45:
1480
1240
  existingActiveVoucherKeys.add(key);
1481
1241
  case 46:
1482
- _context16.next = 36;
1242
+ _context14.next = 36;
1483
1243
  break;
1484
1244
  case 48:
1485
- _context16.next = 53;
1245
+ _context14.next = 53;
1486
1246
  break;
1487
1247
  case 50:
1488
- _context16.prev = 50;
1489
- _context16.t1 = _context16["catch"](34);
1490
- _iterator7.e(_context16.t1);
1248
+ _context14.prev = 50;
1249
+ _context14.t1 = _context14["catch"](34);
1250
+ _iterator3.e(_context14.t1);
1491
1251
  case 53:
1492
- _context16.prev = 53;
1493
- _iterator7.f();
1494
- return _context16.finish(53);
1252
+ _context14.prev = 53;
1253
+ _iterator3.f();
1254
+ return _context14.finish(53);
1495
1255
  case 56:
1496
- _context16.next = 58;
1256
+ _context14.next = 58;
1497
1257
  return _this5.getPaymentOrderByUuidAsync(orderUuid);
1498
1258
  case 58:
1499
- updatedOrder = _context16.sent;
1500
- _context16.next = 61;
1259
+ updatedOrder = _context14.sent;
1260
+ _context14.next = 61;
1501
1261
  return _this5.core.effects.emit("".concat(_this5.name, ":onPaymentAdded"), {
1502
1262
  orderUuid: orderUuid,
1503
1263
  order: updatedOrder,
@@ -1510,30 +1270,30 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1510
1270
  addedVoucherCount: normalizedVoucherItems.length,
1511
1271
  finalExpectAmount: updatedOrder === null || updatedOrder === void 0 ? void 0 : updatedOrder.expect_amount
1512
1272
  });
1513
- _context16.next = 69;
1273
+ _context14.next = 69;
1514
1274
  break;
1515
1275
  case 64:
1516
- _context16.prev = 64;
1517
- _context16.t2 = _context16["catch"](3);
1518
- console.error('[PaymentModule] 批量更新代金券支付项失败:', _context16.t2);
1519
- _this5.logError('updateVoucherPaymentItemsAsync failed', _context16.t2, {
1276
+ _context14.prev = 64;
1277
+ _context14.t2 = _context14["catch"](3);
1278
+ console.error('[PaymentModule] 批量更新代金券支付项失败:', _context14.t2);
1279
+ _this5.logError('updateVoucherPaymentItemsAsync failed', _context14.t2, {
1520
1280
  orderUuid: orderUuid,
1521
1281
  voucherPaymentItems: voucherPaymentItems
1522
1282
  });
1523
- throw _context16.t2;
1283
+ throw _context14.t2;
1524
1284
  case 69:
1525
1285
  case "end":
1526
- return _context16.stop();
1286
+ return _context14.stop();
1527
1287
  }
1528
- }, _callee16, null, [[3, 64], [11, 21, 24, 27], [34, 50, 53, 56]]);
1288
+ }, _callee14, null, [[3, 64], [11, 21, 24, 27], [34, 50, 53, 56]]);
1529
1289
  }))));
1530
1290
  case 1:
1531
1291
  case "end":
1532
- return _context17.stop();
1292
+ return _context15.stop();
1533
1293
  }
1534
- }, _callee17, this);
1294
+ }, _callee15, this);
1535
1295
  }));
1536
- function updateVoucherPaymentItemsAsync(_x19, _x20) {
1296
+ function updateVoucherPaymentItemsAsync(_x17, _x18) {
1537
1297
  return _updateVoucherPaymentItemsAsync.apply(this, arguments);
1538
1298
  }
1539
1299
  return updateVoucherPaymentItemsAsync;
@@ -1545,18 +1305,18 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1545
1305
  }, {
1546
1306
  key: "updatePaymentAsync",
1547
1307
  value: (function () {
1548
- var _updatePaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(orderUuid, paymentUuid, params) {
1308
+ var _updatePaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(orderUuid, paymentUuid, params) {
1549
1309
  var order, paymentItem, formattedParams;
1550
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1551
- while (1) switch (_context18.prev = _context18.next) {
1310
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1311
+ while (1) switch (_context16.prev = _context16.next) {
1552
1312
  case 0:
1553
- _context18.prev = 0;
1554
- _context18.next = 3;
1313
+ _context16.prev = 0;
1314
+ _context16.next = 3;
1555
1315
  return this.dbManager.get('order', orderUuid);
1556
1316
  case 3:
1557
- order = _context18.sent;
1317
+ order = _context16.sent;
1558
1318
  if (order) {
1559
- _context18.next = 6;
1319
+ _context16.next = 6;
1560
1320
  break;
1561
1321
  }
1562
1322
  throw new Error('订单不存在');
@@ -1565,7 +1325,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1565
1325
  return payment.uuid === paymentUuid;
1566
1326
  });
1567
1327
  if (!paymentItem) {
1568
- _context18.next = 18;
1328
+ _context16.next = 18;
1569
1329
  break;
1570
1330
  }
1571
1331
  // 如果更新参数中包含 amount,先格式化
@@ -1579,36 +1339,36 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1579
1339
  this.recalculateOrderAmount(order);
1580
1340
 
1581
1341
  // 更新到 IndexDB
1582
- _context18.next = 14;
1342
+ _context16.next = 14;
1583
1343
  return this.dbManager.update('order', order);
1584
1344
  case 14:
1585
- _context18.next = 16;
1345
+ _context16.next = 16;
1586
1346
  return this.core.effects.emit("".concat(this.name, ":onPaymentUpdated"), {
1587
1347
  order: order,
1588
1348
  paymentItem: paymentItem
1589
1349
  });
1590
1350
  case 16:
1591
- _context18.next = 18;
1351
+ _context16.next = 18;
1592
1352
  return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
1593
1353
  action: 'payment_update',
1594
1354
  order: order,
1595
1355
  paymentItem: paymentItem
1596
1356
  });
1597
1357
  case 18:
1598
- _context18.next = 24;
1358
+ _context16.next = 24;
1599
1359
  break;
1600
1360
  case 20:
1601
- _context18.prev = 20;
1602
- _context18.t0 = _context18["catch"](0);
1603
- console.error('[PaymentModule] 更新支付项失败', _context18.t0);
1604
- throw _context18.t0;
1361
+ _context16.prev = 20;
1362
+ _context16.t0 = _context16["catch"](0);
1363
+ console.error('[PaymentModule] 更新支付项失败', _context16.t0);
1364
+ throw _context16.t0;
1605
1365
  case 24:
1606
1366
  case "end":
1607
- return _context18.stop();
1367
+ return _context16.stop();
1608
1368
  }
1609
- }, _callee18, this, [[0, 20]]);
1369
+ }, _callee16, this, [[0, 20]]);
1610
1370
  }));
1611
- function updatePaymentAsync(_x21, _x22, _x23) {
1371
+ function updatePaymentAsync(_x19, _x20, _x21) {
1612
1372
  return _updatePaymentAsync.apply(this, arguments);
1613
1373
  }
1614
1374
  return updatePaymentAsync;
@@ -1620,61 +1380,61 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1620
1380
  }, {
1621
1381
  key: "submitPayAsync",
1622
1382
  value: (function () {
1623
- var _submitPayAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(orderUuid) {
1624
- var orderToSubmit, order, allOrders, _iterator8, _step8, _order, result;
1625
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1626
- while (1) switch (_context19.prev = _context19.next) {
1383
+ var _submitPayAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(orderUuid) {
1384
+ var orderToSubmit, order, allOrders, _iterator4, _step4, _order, result;
1385
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1386
+ while (1) switch (_context17.prev = _context17.next) {
1627
1387
  case 0:
1628
1388
  this.logInfo('Starting submitPayAsync', {
1629
1389
  orderUuid: orderUuid
1630
1390
  });
1631
- _context19.prev = 1;
1391
+ _context17.prev = 1;
1632
1392
  if (!orderUuid) {
1633
- _context19.next = 9;
1393
+ _context17.next = 9;
1634
1394
  break;
1635
1395
  }
1636
- _context19.next = 5;
1396
+ _context17.next = 5;
1637
1397
  return this.dbManager.get('order', orderUuid);
1638
1398
  case 5:
1639
- order = _context19.sent;
1399
+ order = _context17.sent;
1640
1400
  orderToSubmit = order ? [order] : [];
1641
- _context19.next = 13;
1401
+ _context17.next = 13;
1642
1402
  break;
1643
1403
  case 9:
1644
- _context19.next = 11;
1404
+ _context17.next = 11;
1645
1405
  return this.dbManager.getAll('order');
1646
1406
  case 11:
1647
- allOrders = _context19.sent;
1407
+ allOrders = _context17.sent;
1648
1408
  // 包括正在处理中的订单和部分支付的订单(可能添加了新的支付项)
1649
1409
  orderToSubmit = allOrders.filter(function (order) {
1650
1410
  return order.payment_status === PaymentStatus.Processing || order.payment_status === PaymentStatus.PartiallyPaid;
1651
1411
  });
1652
1412
  case 13:
1653
- _iterator8 = _createForOfIteratorHelper(orderToSubmit);
1654
- _context19.prev = 14;
1655
- _iterator8.s();
1413
+ _iterator4 = _createForOfIteratorHelper(orderToSubmit);
1414
+ _context17.prev = 14;
1415
+ _iterator4.s();
1656
1416
  case 16:
1657
- if ((_step8 = _iterator8.n()).done) {
1658
- _context19.next = 22;
1417
+ if ((_step4 = _iterator4.n()).done) {
1418
+ _context17.next = 22;
1659
1419
  break;
1660
1420
  }
1661
- _order = _step8.value;
1662
- _context19.next = 20;
1421
+ _order = _step4.value;
1422
+ _context17.next = 20;
1663
1423
  return this.submitSingleOrderPayment(_order);
1664
1424
  case 20:
1665
- _context19.next = 16;
1425
+ _context17.next = 16;
1666
1426
  break;
1667
1427
  case 22:
1668
- _context19.next = 27;
1428
+ _context17.next = 27;
1669
1429
  break;
1670
1430
  case 24:
1671
- _context19.prev = 24;
1672
- _context19.t0 = _context19["catch"](14);
1673
- _iterator8.e(_context19.t0);
1431
+ _context17.prev = 24;
1432
+ _context17.t0 = _context17["catch"](14);
1433
+ _iterator4.e(_context17.t0);
1674
1434
  case 27:
1675
- _context19.prev = 27;
1676
- _iterator8.f();
1677
- return _context19.finish(27);
1435
+ _context17.prev = 27;
1436
+ _iterator4.f();
1437
+ return _context17.finish(27);
1678
1438
  case 30:
1679
1439
  result = {
1680
1440
  status: 'success'
@@ -1683,24 +1443,24 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1683
1443
  result: result.status,
1684
1444
  processedOrdersCount: orderToSubmit.length
1685
1445
  });
1686
- return _context19.abrupt("return", result);
1446
+ return _context17.abrupt("return", result);
1687
1447
  case 35:
1688
- _context19.prev = 35;
1689
- _context19.t1 = _context19["catch"](1);
1690
- console.error('[PaymentModule] 提交支付失败', _context19.t1);
1691
- this.logError('submitPayAsync failed', _context19.t1, {
1448
+ _context17.prev = 35;
1449
+ _context17.t1 = _context17["catch"](1);
1450
+ console.error('[PaymentModule] 提交支付失败', _context17.t1);
1451
+ this.logError('submitPayAsync failed', _context17.t1, {
1692
1452
  orderUuid: orderUuid
1693
1453
  });
1694
- return _context19.abrupt("return", {
1454
+ return _context17.abrupt("return", {
1695
1455
  status: 'failed'
1696
1456
  });
1697
1457
  case 40:
1698
1458
  case "end":
1699
- return _context19.stop();
1459
+ return _context17.stop();
1700
1460
  }
1701
- }, _callee19, this, [[1, 35], [14, 24, 27, 30]]);
1461
+ }, _callee17, this, [[1, 35], [14, 24, 27, 30]]);
1702
1462
  }));
1703
- function submitPayAsync(_x24) {
1463
+ function submitPayAsync(_x22) {
1704
1464
  return _submitPayAsync.apply(this, arguments);
1705
1465
  }
1706
1466
  return submitPayAsync;
@@ -1712,12 +1472,12 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1712
1472
  }, {
1713
1473
  key: "submitSingleOrderPayment",
1714
1474
  value: (function () {
1715
- var _submitSingleOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(order) {
1475
+ var _submitSingleOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(order) {
1716
1476
  var paymentData, totalPaidAmount, orderTotalAmount;
1717
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1718
- while (1) switch (_context20.prev = _context20.next) {
1477
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1478
+ while (1) switch (_context18.prev = _context18.next) {
1719
1479
  case 0:
1720
- _context20.prev = 0;
1480
+ _context18.prev = 0;
1721
1481
  paymentData = {
1722
1482
  payments: order.payment.map(function (payment) {
1723
1483
  return {
@@ -1751,42 +1511,42 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1751
1511
  paymentData.payment_status = order.payment_status === PaymentStatus.Finished ? 'paid' : 'partially_paid';
1752
1512
 
1753
1513
  // 更新订单状态到数据库
1754
- _context20.next = 8;
1514
+ _context18.next = 8;
1755
1515
  return this.dbManager.update('order', order);
1756
1516
  case 8:
1757
1517
  if (!(paymentData.payments.length === 0)) {
1758
- _context20.next = 11;
1518
+ _context18.next = 11;
1759
1519
  break;
1760
1520
  }
1761
1521
  this.logWarning('Empty payment list', {
1762
1522
  orderUuid: order.uuid,
1763
1523
  orderId: order.order_id
1764
1524
  });
1765
- return _context20.abrupt("return");
1525
+ return _context18.abrupt("return");
1766
1526
  case 11:
1767
- _context20.next = 13;
1527
+ _context18.next = 13;
1768
1528
  return this.core.effects.emit("".concat(this.name, ":onPaymentSubmitted"), order);
1769
1529
  case 13:
1770
- _context20.next = 15;
1530
+ _context18.next = 15;
1771
1531
  return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
1772
1532
  action: 'submit',
1773
1533
  order: order
1774
1534
  });
1775
1535
  case 15:
1776
- _context20.next = 21;
1536
+ _context18.next = 21;
1777
1537
  break;
1778
1538
  case 17:
1779
- _context20.prev = 17;
1780
- _context20.t0 = _context20["catch"](0);
1781
- console.error("[PaymentModule] \u8BA2\u5355 ".concat(order.uuid, " \u652F\u4ED8\u63D0\u4EA4\u5931\u8D25"), _context20.t0);
1782
- throw _context20.t0;
1539
+ _context18.prev = 17;
1540
+ _context18.t0 = _context18["catch"](0);
1541
+ console.error("[PaymentModule] \u8BA2\u5355 ".concat(order.uuid, " \u652F\u4ED8\u63D0\u4EA4\u5931\u8D25"), _context18.t0);
1542
+ throw _context18.t0;
1783
1543
  case 21:
1784
1544
  case "end":
1785
- return _context20.stop();
1545
+ return _context18.stop();
1786
1546
  }
1787
- }, _callee20, this, [[0, 17]]);
1547
+ }, _callee18, this, [[0, 17]]);
1788
1548
  }));
1789
- function submitSingleOrderPayment(_x25) {
1549
+ function submitSingleOrderPayment(_x23) {
1790
1550
  return _submitSingleOrderPayment.apply(this, arguments);
1791
1551
  }
1792
1552
  return submitSingleOrderPayment;
@@ -1798,29 +1558,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1798
1558
  }, {
1799
1559
  key: "getRemainingOrderAmountAsync",
1800
1560
  value: (function () {
1801
- var _getRemainingOrderAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(orderUuid) {
1561
+ var _getRemainingOrderAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(orderUuid) {
1802
1562
  var order;
1803
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1804
- while (1) switch (_context21.prev = _context21.next) {
1563
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1564
+ while (1) switch (_context19.prev = _context19.next) {
1805
1565
  case 0:
1806
- _context21.next = 2;
1566
+ _context19.next = 2;
1807
1567
  return this.getPaymentOrderByUuidAsync(orderUuid);
1808
1568
  case 2:
1809
- order = _context21.sent;
1569
+ order = _context19.sent;
1810
1570
  if (order) {
1811
- _context21.next = 5;
1571
+ _context19.next = 5;
1812
1572
  break;
1813
1573
  }
1814
1574
  throw new Error('订单不存在');
1815
1575
  case 5:
1816
- return _context21.abrupt("return", new Decimal(order.expect_amount).toNumber());
1576
+ return _context19.abrupt("return", new Decimal(order.expect_amount).toNumber());
1817
1577
  case 6:
1818
1578
  case "end":
1819
- return _context21.stop();
1579
+ return _context19.stop();
1820
1580
  }
1821
- }, _callee21, this);
1581
+ }, _callee19, this);
1822
1582
  }));
1823
- function getRemainingOrderAmountAsync(_x26) {
1583
+ function getRemainingOrderAmountAsync(_x24) {
1824
1584
  return _getRemainingOrderAmountAsync.apply(this, arguments);
1825
1585
  }
1826
1586
  return getRemainingOrderAmountAsync;
@@ -1832,65 +1592,65 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1832
1592
  }, {
1833
1593
  key: "getRemainingOrderAmountWithInputAsync",
1834
1594
  value: (function () {
1835
- var _getRemainingOrderAmountWithInputAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(inputAmount, orderUuid) {
1595
+ var _getRemainingOrderAmountWithInputAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(inputAmount, orderUuid) {
1836
1596
  var order, inputDecimal;
1837
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1838
- while (1) switch (_context22.prev = _context22.next) {
1597
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1598
+ while (1) switch (_context20.prev = _context20.next) {
1839
1599
  case 0:
1840
- _context22.next = 2;
1600
+ _context20.next = 2;
1841
1601
  return this.getPaymentOrderByUuidAsync(orderUuid);
1842
1602
  case 2:
1843
- order = _context22.sent;
1603
+ order = _context20.sent;
1844
1604
  if (order) {
1845
- _context22.next = 5;
1605
+ _context20.next = 5;
1846
1606
  break;
1847
1607
  }
1848
1608
  throw new Error('订单不存在');
1849
1609
  case 5:
1850
1610
  if (!(inputAmount === null || inputAmount === undefined)) {
1851
- _context22.next = 7;
1611
+ _context20.next = 7;
1852
1612
  break;
1853
1613
  }
1854
- return _context22.abrupt("return", new Decimal(order.expect_amount).toNumber());
1614
+ return _context20.abrupt("return", new Decimal(order.expect_amount).toNumber());
1855
1615
  case 7:
1856
1616
  if (!(typeof inputAmount === 'string')) {
1857
- _context22.next = 10;
1617
+ _context20.next = 10;
1858
1618
  break;
1859
1619
  }
1860
1620
  if (!(inputAmount.trim() === '')) {
1861
- _context22.next = 10;
1621
+ _context20.next = 10;
1862
1622
  break;
1863
1623
  }
1864
- return _context22.abrupt("return", new Decimal(order.expect_amount).toNumber());
1624
+ return _context20.abrupt("return", new Decimal(order.expect_amount).toNumber());
1865
1625
  case 10:
1866
1626
  if (!(typeof inputAmount === 'number')) {
1867
- _context22.next = 14;
1627
+ _context20.next = 14;
1868
1628
  break;
1869
1629
  }
1870
1630
  if (!(isNaN(inputAmount) || !isFinite(inputAmount))) {
1871
- _context22.next = 14;
1631
+ _context20.next = 14;
1872
1632
  break;
1873
1633
  }
1874
1634
  // 如果输入是 NaN 或无穷大,返回原始的待付金额
1875
1635
  console.warn("[PaymentModule] \u8F93\u5165\u91D1\u989D\u4E0D\u662F\u6709\u6548\u6570\u5B57: ".concat(inputAmount, "\uFF0C\u8FD4\u56DE\u539F\u59CB\u5F85\u4ED8\u91D1\u989D"));
1876
- return _context22.abrupt("return", new Decimal(order.expect_amount).toNumber());
1636
+ return _context20.abrupt("return", new Decimal(order.expect_amount).toNumber());
1877
1637
  case 14:
1878
- _context22.prev = 14;
1638
+ _context20.prev = 14;
1879
1639
  inputDecimal = new Decimal(inputAmount);
1880
- return _context22.abrupt("return", new Decimal(order.expect_amount).minus(inputDecimal).toNumber());
1640
+ return _context20.abrupt("return", new Decimal(order.expect_amount).minus(inputDecimal).toNumber());
1881
1641
  case 19:
1882
- _context22.prev = 19;
1883
- _context22.t0 = _context22["catch"](14);
1642
+ _context20.prev = 19;
1643
+ _context20.t0 = _context20["catch"](14);
1884
1644
  // 如果输入不是有效的数字,返回原始的待付金额
1885
1645
  console.warn("[PaymentModule] \u8F93\u5165\u91D1\u989D\u683C\u5F0F\u65E0\u6548: ".concat(inputAmount, "\uFF0C\u8FD4\u56DE\u539F\u59CB\u5F85\u4ED8\u91D1\u989D"));
1886
- return _context22.abrupt("return", new Decimal(order.expect_amount).toNumber());
1646
+ return _context20.abrupt("return", new Decimal(order.expect_amount).toNumber());
1887
1647
  case 23:
1888
1648
  case "end":
1889
- return _context22.stop();
1649
+ return _context20.stop();
1890
1650
  }
1891
- }, _callee22, this, [[14, 19]]);
1651
+ }, _callee20, this, [[14, 19]]);
1892
1652
  }));
1893
- function getRemainingOrderAmountWithInputAsync(_x27, _x28) {
1653
+ function getRemainingOrderAmountWithInputAsync(_x25, _x26) {
1894
1654
  return _getRemainingOrderAmountWithInputAsync.apply(this, arguments);
1895
1655
  }
1896
1656
  return getRemainingOrderAmountWithInputAsync;
@@ -1934,29 +1694,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1934
1694
  }, {
1935
1695
  key: "getCashPaymentMethod",
1936
1696
  value: (function () {
1937
- var _getCashPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
1697
+ var _getCashPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
1938
1698
  var payMethods;
1939
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1940
- while (1) switch (_context23.prev = _context23.next) {
1699
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1700
+ while (1) switch (_context21.prev = _context21.next) {
1941
1701
  case 0:
1942
- _context23.prev = 0;
1943
- _context23.next = 3;
1702
+ _context21.prev = 0;
1703
+ _context21.next = 3;
1944
1704
  return this.dbManager.getAll('pay_method');
1945
1705
  case 3:
1946
- payMethods = _context23.sent;
1947
- return _context23.abrupt("return", payMethods.find(function (method) {
1706
+ payMethods = _context21.sent;
1707
+ return _context21.abrupt("return", payMethods.find(function (method) {
1948
1708
  return method.code === PaymentMethodType.Cash;
1949
1709
  }) || null);
1950
1710
  case 7:
1951
- _context23.prev = 7;
1952
- _context23.t0 = _context23["catch"](0);
1953
- console.error('[PaymentModule] 获取现金支付方式失败', _context23.t0);
1954
- return _context23.abrupt("return", null);
1711
+ _context21.prev = 7;
1712
+ _context21.t0 = _context21["catch"](0);
1713
+ console.error('[PaymentModule] 获取现金支付方式失败', _context21.t0);
1714
+ return _context21.abrupt("return", null);
1955
1715
  case 11:
1956
1716
  case "end":
1957
- return _context23.stop();
1717
+ return _context21.stop();
1958
1718
  }
1959
- }, _callee23, this, [[0, 7]]);
1719
+ }, _callee21, this, [[0, 7]]);
1960
1720
  }));
1961
1721
  function getCashPaymentMethod() {
1962
1722
  return _getCashPaymentMethod.apply(this, arguments);
@@ -1970,29 +1730,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1970
1730
  }, {
1971
1731
  key: "getEftposPaymentMethod",
1972
1732
  value: (function () {
1973
- var _getEftposPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
1733
+ var _getEftposPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
1974
1734
  var payMethods;
1975
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1976
- while (1) switch (_context24.prev = _context24.next) {
1735
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1736
+ while (1) switch (_context22.prev = _context22.next) {
1977
1737
  case 0:
1978
- _context24.prev = 0;
1979
- _context24.next = 3;
1738
+ _context22.prev = 0;
1739
+ _context22.next = 3;
1980
1740
  return this.dbManager.getAll('pay_method');
1981
1741
  case 3:
1982
- payMethods = _context24.sent;
1983
- return _context24.abrupt("return", payMethods.find(function (method) {
1742
+ payMethods = _context22.sent;
1743
+ return _context22.abrupt("return", payMethods.find(function (method) {
1984
1744
  return method.code === PaymentMethodType.Eftpos;
1985
1745
  }) || null);
1986
1746
  case 7:
1987
- _context24.prev = 7;
1988
- _context24.t0 = _context24["catch"](0);
1989
- console.error('[PaymentModule] 获取Eftpos支付方式失败', _context24.t0);
1990
- return _context24.abrupt("return", null);
1747
+ _context22.prev = 7;
1748
+ _context22.t0 = _context22["catch"](0);
1749
+ console.error('[PaymentModule] 获取Eftpos支付方式失败', _context22.t0);
1750
+ return _context22.abrupt("return", null);
1991
1751
  case 11:
1992
1752
  case "end":
1993
- return _context24.stop();
1753
+ return _context22.stop();
1994
1754
  }
1995
- }, _callee24, this, [[0, 7]]);
1755
+ }, _callee22, this, [[0, 7]]);
1996
1756
  }));
1997
1757
  function getEftposPaymentMethod() {
1998
1758
  return _getEftposPaymentMethod.apply(this, arguments);
@@ -2006,29 +1766,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
2006
1766
  }, {
2007
1767
  key: "getWalletPaymentMethod",
2008
1768
  value: (function () {
2009
- var _getWalletPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
1769
+ var _getWalletPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
2010
1770
  var payMethods;
2011
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2012
- while (1) switch (_context25.prev = _context25.next) {
1771
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1772
+ while (1) switch (_context23.prev = _context23.next) {
2013
1773
  case 0:
2014
- _context25.prev = 0;
2015
- _context25.next = 3;
1774
+ _context23.prev = 0;
1775
+ _context23.next = 3;
2016
1776
  return this.dbManager.getAll('pay_method');
2017
1777
  case 3:
2018
- payMethods = _context25.sent;
2019
- return _context25.abrupt("return", payMethods.find(function (method) {
1778
+ payMethods = _context23.sent;
1779
+ return _context23.abrupt("return", payMethods.find(function (method) {
2020
1780
  return method.code === PaymentMethodType.Wallet;
2021
1781
  }) || null);
2022
1782
  case 7:
2023
- _context25.prev = 7;
2024
- _context25.t0 = _context25["catch"](0);
2025
- console.error('[PaymentModule] 获取钱包支付方式失败', _context25.t0);
2026
- return _context25.abrupt("return", null);
1783
+ _context23.prev = 7;
1784
+ _context23.t0 = _context23["catch"](0);
1785
+ console.error('[PaymentModule] 获取钱包支付方式失败', _context23.t0);
1786
+ return _context23.abrupt("return", null);
2027
1787
  case 11:
2028
1788
  case "end":
2029
- return _context25.stop();
1789
+ return _context23.stop();
2030
1790
  }
2031
- }, _callee25, this, [[0, 7]]);
1791
+ }, _callee23, this, [[0, 7]]);
2032
1792
  }));
2033
1793
  function getWalletPaymentMethod() {
2034
1794
  return _getWalletPaymentMethod.apply(this, arguments);
@@ -2038,42 +1798,43 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
2038
1798
  /**
2039
1799
  * 确保支付模块所需的数据库表已创建
2040
1800
  */
1801
+ /** @deprecated */
2041
1802
  )
2042
1803
  }, {
2043
1804
  key: "ensurePaymentTables",
2044
1805
  value: (function () {
2045
- var _ensurePaymentTables = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
2046
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2047
- while (1) switch (_context26.prev = _context26.next) {
1806
+ var _ensurePaymentTables = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
1807
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1808
+ while (1) switch (_context24.prev = _context24.next) {
2048
1809
  case 0:
2049
- _context26.prev = 0;
2050
- _context26.next = 3;
1810
+ _context24.prev = 0;
1811
+ _context24.next = 3;
2051
1812
  return this.dbManager.getAll('pay_method');
2052
1813
  case 3:
2053
- _context26.next = 9;
1814
+ _context24.next = 9;
2054
1815
  break;
2055
1816
  case 5:
2056
- _context26.prev = 5;
2057
- _context26.t0 = _context26["catch"](0);
1817
+ _context24.prev = 5;
1818
+ _context24.t0 = _context24["catch"](0);
2058
1819
  console.warn('[PaymentModule] pay_method 表不存在,请在数据库配置中添加以下配置:');
2059
1820
  console.warn('{ name: "pay_method", keyPath: "id" }');
2060
1821
  case 9:
2061
- _context26.prev = 9;
2062
- _context26.next = 12;
1822
+ _context24.prev = 9;
1823
+ _context24.next = 12;
2063
1824
  return this.dbManager.getAll('order');
2064
1825
  case 12:
2065
- _context26.next = 18;
1826
+ _context24.next = 18;
2066
1827
  break;
2067
1828
  case 14:
2068
- _context26.prev = 14;
2069
- _context26.t1 = _context26["catch"](9);
1829
+ _context24.prev = 14;
1830
+ _context24.t1 = _context24["catch"](9);
2070
1831
  console.warn('[PaymentModule] order 表不存在,请在数据库配置中添加以下配置:');
2071
1832
  console.warn('{ name: "order", keyPath: "uuid" }');
2072
1833
  case 18:
2073
1834
  case "end":
2074
- return _context26.stop();
1835
+ return _context24.stop();
2075
1836
  }
2076
- }, _callee26, this, [[0, 5], [9, 14]]);
1837
+ }, _callee24, this, [[0, 5], [9, 14]]);
2077
1838
  }));
2078
1839
  function ensurePaymentTables() {
2079
1840
  return _ensurePaymentTables.apply(this, arguments);
@@ -2083,33 +1844,34 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
2083
1844
  /**
2084
1845
  * 获取部分支付的订单
2085
1846
  */
1847
+ /** @deprecated */
2086
1848
  )
2087
1849
  }, {
2088
1850
  key: "getPartiallyPaidOrdersAsync",
2089
1851
  value: (function () {
2090
- var _getPartiallyPaidOrdersAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
1852
+ var _getPartiallyPaidOrdersAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
2091
1853
  var allOrders;
2092
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2093
- while (1) switch (_context27.prev = _context27.next) {
1854
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1855
+ while (1) switch (_context25.prev = _context25.next) {
2094
1856
  case 0:
2095
- _context27.prev = 0;
2096
- _context27.next = 3;
1857
+ _context25.prev = 0;
1858
+ _context25.next = 3;
2097
1859
  return this.dbManager.getAll('order');
2098
1860
  case 3:
2099
- allOrders = _context27.sent;
2100
- return _context27.abrupt("return", allOrders.filter(function (order) {
1861
+ allOrders = _context25.sent;
1862
+ return _context25.abrupt("return", allOrders.filter(function (order) {
2101
1863
  return order.payment_status === PaymentStatus.PartiallyPaid;
2102
1864
  }));
2103
1865
  case 7:
2104
- _context27.prev = 7;
2105
- _context27.t0 = _context27["catch"](0);
2106
- console.error('[PaymentModule] 获取部分支付订单失败', _context27.t0);
2107
- return _context27.abrupt("return", []);
1866
+ _context25.prev = 7;
1867
+ _context25.t0 = _context25["catch"](0);
1868
+ console.error('[PaymentModule] 获取部分支付订单失败', _context25.t0);
1869
+ return _context25.abrupt("return", []);
2108
1870
  case 11:
2109
1871
  case "end":
2110
- return _context27.stop();
1872
+ return _context25.stop();
2111
1873
  }
2112
- }, _callee27, this, [[0, 7]]);
1874
+ }, _callee25, this, [[0, 7]]);
2113
1875
  }));
2114
1876
  function getPartiallyPaidOrdersAsync() {
2115
1877
  return _getPartiallyPaidOrdersAsync.apply(this, arguments);
@@ -2130,17 +1892,17 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
2130
1892
  }, {
2131
1893
  key: "roundAmountAsync",
2132
1894
  value: function () {
2133
- var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(originalAmount, interval, rule) {
1895
+ var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(originalAmount, interval, rule) {
2134
1896
  var amount, roundingInterval, supportedIntervals, intervalValue, baseValue, roundedValue, finalAmount, originalAmountStr, roundedAmountStr, roundingDifference, roundingDifferenceStr;
2135
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2136
- while (1) switch (_context28.prev = _context28.next) {
1897
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1898
+ while (1) switch (_context26.prev = _context26.next) {
2137
1899
  case 0:
2138
- _context28.prev = 0;
1900
+ _context26.prev = 0;
2139
1901
  // 参数验证
2140
1902
  amount = new Decimal(originalAmount);
2141
1903
  roundingInterval = new Decimal(interval);
2142
1904
  if (!roundingInterval.lte(0)) {
2143
- _context28.next = 5;
1905
+ _context26.next = 5;
2144
1906
  break;
2145
1907
  }
2146
1908
  throw new Error('舍入间隔必须大于 0');
@@ -2154,25 +1916,25 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
2154
1916
 
2155
1917
  // 计算基础值:x / interval
2156
1918
  baseValue = amount.div(roundingInterval);
2157
- _context28.t0 = rule;
2158
- _context28.next = _context28.t0 === RoundingRule.Standard ? 12 : _context28.t0 === 'standard' ? 12 : _context28.t0 === RoundingRule.StandardDown ? 14 : _context28.t0 === 'standard_down' ? 14 : _context28.t0 === RoundingRule.AlwaysUp ? 16 : _context28.t0 === 'always_up' ? 16 : _context28.t0 === RoundingRule.AlwaysDown ? 18 : _context28.t0 === 'always_down' ? 18 : 20;
1919
+ _context26.t0 = rule;
1920
+ _context26.next = _context26.t0 === RoundingRule.Standard ? 12 : _context26.t0 === 'standard' ? 12 : _context26.t0 === RoundingRule.StandardDown ? 14 : _context26.t0 === 'standard_down' ? 14 : _context26.t0 === RoundingRule.AlwaysUp ? 16 : _context26.t0 === 'always_up' ? 16 : _context26.t0 === RoundingRule.AlwaysDown ? 18 : _context26.t0 === 'always_down' ? 18 : 20;
2159
1921
  break;
2160
1922
  case 12:
2161
1923
  // 标准舍入(中点向上)
2162
1924
  roundedValue = this.standardRound(baseValue, true);
2163
- return _context28.abrupt("break", 21);
1925
+ return _context26.abrupt("break", 21);
2164
1926
  case 14:
2165
1927
  // 标准舍入(中点向下)
2166
1928
  roundedValue = this.standardRound(baseValue, false);
2167
- return _context28.abrupt("break", 21);
1929
+ return _context26.abrupt("break", 21);
2168
1930
  case 16:
2169
1931
  // 总是向上舍入
2170
1932
  roundedValue = baseValue.ceil();
2171
- return _context28.abrupt("break", 21);
1933
+ return _context26.abrupt("break", 21);
2172
1934
  case 18:
2173
1935
  // 总是向下舍入
2174
1936
  roundedValue = baseValue.floor();
2175
- return _context28.abrupt("break", 21);
1937
+ return _context26.abrupt("break", 21);
2176
1938
  case 20:
2177
1939
  throw new Error("\u4E0D\u652F\u6301\u7684\u820D\u5165\u89C4\u5219: ".concat(rule));
2178
1940
  case 21:
@@ -2180,10 +1942,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
2180
1942
  finalAmount = roundedValue.mul(roundingInterval);
2181
1943
  originalAmountStr = amount.toFixed(2); // 如果最终金额是 0 元,则不采用舍入金额,返回原始金额
2182
1944
  if (!finalAmount.eq(0)) {
2183
- _context28.next = 25;
1945
+ _context26.next = 25;
2184
1946
  break;
2185
1947
  }
2186
- return _context28.abrupt("return", {
1948
+ return _context26.abrupt("return", {
2187
1949
  originalAmount: originalAmountStr,
2188
1950
  roundedAmount: originalAmountStr,
2189
1951
  roundingDifference: '0.00'
@@ -2192,23 +1954,23 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
2192
1954
  roundedAmountStr = finalAmount.toFixed(2); // 计算舍入差额
2193
1955
  roundingDifference = finalAmount.sub(amount);
2194
1956
  roundingDifferenceStr = roundingDifference.toFixed(2);
2195
- return _context28.abrupt("return", {
1957
+ return _context26.abrupt("return", {
2196
1958
  originalAmount: originalAmountStr,
2197
1959
  roundedAmount: roundedAmountStr,
2198
1960
  roundingDifference: roundingDifferenceStr
2199
1961
  });
2200
1962
  case 31:
2201
- _context28.prev = 31;
2202
- _context28.t1 = _context28["catch"](0);
2203
- console.error('[PaymentModule] 金额舍入失败:', _context28.t1);
2204
- throw new Error("\u91D1\u989D\u820D\u5165\u5931\u8D25: ".concat(_context28.t1 instanceof Error ? _context28.t1.message : String(_context28.t1)));
1963
+ _context26.prev = 31;
1964
+ _context26.t1 = _context26["catch"](0);
1965
+ console.error('[PaymentModule] 金额舍入失败:', _context26.t1);
1966
+ throw new Error("\u91D1\u989D\u820D\u5165\u5931\u8D25: ".concat(_context26.t1 instanceof Error ? _context26.t1.message : String(_context26.t1)));
2205
1967
  case 35:
2206
1968
  case "end":
2207
- return _context28.stop();
1969
+ return _context26.stop();
2208
1970
  }
2209
- }, _callee28, this, [[0, 31]]);
1971
+ }, _callee26, this, [[0, 31]]);
2210
1972
  }));
2211
- function roundAmountAsync(_x29, _x30, _x31) {
1973
+ function roundAmountAsync(_x27, _x28, _x29) {
2212
1974
  return _roundAmountAsync.apply(this, arguments);
2213
1975
  }
2214
1976
  return roundAmountAsync;