@pisell/pisellos 2.2.242 → 2.2.244

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