@pisell/pisellos 0.0.569 → 0.10.2

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 (328) hide show
  1. package/dist/core/index.js +10 -6
  2. package/dist/index.d.ts +0 -1
  3. package/dist/index.js +0 -3
  4. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  5. package/dist/model/strategy/adapter/walletPass/evaluator.js +7 -5
  6. package/dist/model/strategy/adapter/walletPass/example.js +26 -3
  7. package/dist/model/strategy/adapter/walletPass/index.js +5 -5
  8. package/dist/model/strategy/adapter/walletPass/type.d.ts +0 -3
  9. package/dist/model/strategy/adapter/walletPass/utils.d.ts +0 -26
  10. package/dist/model/strategy/adapter/walletPass/utils.js +17 -92
  11. package/dist/model/strategy/strategy-example.js +19 -5
  12. package/dist/modules/BaseModule.d.ts +1 -1
  13. package/dist/modules/BaseModule.js +8 -10
  14. package/dist/modules/Cart/index.js +3 -0
  15. package/dist/modules/Cart/utils/cartProduct.js +1 -0
  16. package/dist/modules/Cart/utils/cartResource.js +0 -2
  17. package/dist/modules/Cart/utils/changePrice.js +9 -16
  18. package/dist/modules/Date/index.js +5 -1
  19. package/dist/modules/Discount/index.d.ts +0 -1
  20. package/dist/modules/Discount/index.js +7 -22
  21. package/dist/modules/Discount/types.d.ts +0 -1
  22. package/dist/modules/OpenData/index.js +2 -0
  23. package/dist/modules/Order/index.js +70 -40
  24. package/dist/modules/Payment/index.js +162 -97
  25. package/dist/modules/Payment/types.d.ts +4 -8
  26. package/dist/modules/Payment/walletpass.d.ts +0 -2
  27. package/dist/modules/Payment/walletpass.js +5 -4
  28. package/dist/modules/ProductList/index.d.ts +1 -1
  29. package/dist/modules/ProductList/index.js +3 -12
  30. package/dist/modules/ProductList/types.d.ts +0 -1
  31. package/dist/modules/Rules/index.js +126 -427
  32. package/dist/modules/SalesSummary/utils.js +1 -2
  33. package/dist/modules/Schedule/getDateIsInSchedule.js +0 -5
  34. package/dist/modules/Schedule/index.js +1 -0
  35. package/dist/modules/Schedule/utils.js +1 -0
  36. package/dist/modules/Step/index.js +1 -0
  37. package/dist/modules/Summary/utils.js +22 -43
  38. package/dist/plugins/request.js +4 -1
  39. package/dist/plugins/window.js +6 -2
  40. package/dist/server/index.js +129 -97
  41. package/dist/server/modules/menu/index.js +41 -32
  42. package/dist/server/modules/order/index.js +4 -2
  43. package/dist/server/modules/products/index.js +42 -24
  44. package/dist/server/modules/quotation/index.js +38 -29
  45. package/dist/server/modules/resource/index.js +4 -3
  46. package/dist/server/modules/schedule/index.js +35 -27
  47. package/dist/server/utils/product.js +1 -0
  48. package/dist/solution/BaseSales/index.js +41 -38
  49. package/dist/solution/BookingByStep/index.d.ts +1 -1
  50. package/dist/solution/BookingByStep/index.js +60 -11
  51. package/dist/solution/BookingByStep/utils/capacity.js +11 -1
  52. package/dist/solution/BookingByStep/utils/resources.js +3 -1
  53. package/dist/solution/BookingByStep/utils/timeslots.js +43 -2
  54. package/dist/solution/BookingTicket/index.d.ts +1 -1
  55. package/dist/solution/BookingTicket/index.js +2 -0
  56. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +7 -6
  57. package/dist/solution/BookingTicket/utils/scan/handleScan.js +31 -25
  58. package/dist/solution/BookingTicket/utils/scan/index.js +10 -6
  59. package/dist/solution/BuyTickets/index.js +12 -9
  60. package/dist/solution/Checkout/index.js +252 -177
  61. package/dist/solution/Checkout/utils/index.js +16 -4
  62. package/dist/solution/RegisterAndLogin/index.js +76 -30
  63. package/dist/solution/ScanOrder/index.js +60 -50
  64. package/dist/solution/ShopDiscount/index.js +14 -15
  65. package/dist/solution/ShopDiscount/types.d.ts +4 -5
  66. package/dist/solution/ShopDiscount/utils.d.ts +0 -9
  67. package/dist/solution/ShopDiscount/utils.js +0 -9
  68. package/dist/solution/VenueBooking/index.d.ts +3 -31
  69. package/dist/solution/VenueBooking/index.js +496 -651
  70. package/dist/solution/VenueBooking/types.d.ts +1 -3
  71. package/dist/solution/VenueBooking/types.js +0 -1
  72. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
  73. package/dist/solution/VenueBooking/utils/dateSummary.js +25 -12
  74. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
  75. package/dist/solution/VenueBooking/utils/timeSlot.js +4 -9
  76. package/dist/types/index.d.ts +1 -1
  77. package/dist/utils/task.js +18 -15
  78. package/dist/utils/watch.js +1 -0
  79. package/lib/apis/picoding.js +0 -2
  80. package/lib/core/index.js +132 -130
  81. package/lib/effects/index.js +57 -46
  82. package/lib/index.d.ts +0 -1
  83. package/lib/index.js +50 -92
  84. package/lib/model/index.js +21 -14
  85. package/lib/model/strategy/adapter/dataVariant/adapter.js +50 -38
  86. package/lib/model/strategy/adapter/dataVariant/evaluator.js +236 -162
  87. package/lib/model/strategy/adapter/dataVariant/examples.js +237 -229
  88. package/lib/model/strategy/adapter/dataVariant/index.js +34 -39
  89. package/lib/model/strategy/adapter/dataVariant/type.js +28 -57
  90. package/lib/model/strategy/adapter/index.js +64 -100
  91. package/lib/model/strategy/adapter/itemRule/adapter.js +144 -156
  92. package/lib/model/strategy/adapter/itemRule/evaluator.js +48 -36
  93. package/lib/model/strategy/adapter/itemRule/examples.js +225 -295
  94. package/lib/model/strategy/adapter/itemRule/index.js +57 -83
  95. package/lib/model/strategy/adapter/itemRule/type.js +36 -97
  96. package/lib/model/strategy/adapter/promotion/adapter.js +63 -84
  97. package/lib/model/strategy/adapter/promotion/evaluator.js +231 -381
  98. package/lib/model/strategy/adapter/promotion/examples.js +159 -139
  99. package/lib/model/strategy/adapter/promotion/index.js +49 -1
  100. package/lib/model/strategy/adapter/promotion/type.js +35 -199
  101. package/lib/model/strategy/adapter/type.js +16 -4
  102. package/lib/model/strategy/adapter/walletPass/evaluator.js +152 -180
  103. package/lib/model/strategy/adapter/walletPass/example.js +190 -217
  104. package/lib/model/strategy/adapter/walletPass/index.js +51 -75
  105. package/lib/model/strategy/adapter/walletPass/locales.js +58 -36
  106. package/lib/model/strategy/adapter/walletPass/type.d.ts +0 -3
  107. package/lib/model/strategy/adapter/walletPass/type.js +16 -4
  108. package/lib/model/strategy/adapter/walletPass/utils.d.ts +0 -26
  109. package/lib/model/strategy/adapter/walletPass/utils.js +383 -678
  110. package/lib/model/strategy/engine.js +168 -270
  111. package/lib/model/strategy/index.js +34 -49
  112. package/lib/model/strategy/strategy-example.js +239 -243
  113. package/lib/model/strategy/type.js +40 -100
  114. package/lib/modules/Account/index.js +53 -39
  115. package/lib/modules/Account/types.js +33 -20
  116. package/lib/modules/AccountList/index.js +154 -116
  117. package/lib/modules/AccountList/types.js +31 -30
  118. package/lib/modules/AccountList/utils.js +30 -18
  119. package/lib/modules/BaseModule.d.ts +1 -1
  120. package/lib/modules/BaseModule.js +46 -25
  121. package/lib/modules/BookingContext/index.js +136 -158
  122. package/lib/modules/BookingContext/types.js +32 -46
  123. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +143 -131
  124. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +82 -75
  125. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +150 -170
  126. package/lib/modules/BookingContext/utils/flexible.js +55 -38
  127. package/lib/modules/BookingContext/utils/formatResourceList.js +34 -19
  128. package/lib/modules/BookingContext/utils/index.js +41 -124
  129. package/lib/modules/BookingContext/utils/noResource.js +70 -58
  130. package/lib/modules/BookingContext/utils/orderLineDisplay.js +41 -14
  131. package/lib/modules/BookingContext/utils/productExtend.js +155 -202
  132. package/lib/modules/BookingContext/utils/resourceErrors.js +53 -53
  133. package/lib/modules/BookingContext/utils/resourceSelection.js +41 -19
  134. package/lib/modules/BookingContext/utils/resources.js +167 -209
  135. package/lib/modules/BookingContext/utils/serviceTimes.js +116 -115
  136. package/lib/modules/BookingContext/utils/timeSlices.js +80 -70
  137. package/lib/modules/Cart/index.js +124 -170
  138. package/lib/modules/Cart/types.js +51 -46
  139. package/lib/modules/Cart/utils/cartAccount.js +39 -40
  140. package/lib/modules/Cart/utils/cartDate.js +61 -56
  141. package/lib/modules/Cart/utils/cartDiscount.js +33 -28
  142. package/lib/modules/Cart/utils/cartNote.js +32 -27
  143. package/lib/modules/Cart/utils/cartProduct.js +251 -321
  144. package/lib/modules/Cart/utils/cartRelationForms.js +35 -29
  145. package/lib/modules/Cart/utils/cartResource.js +78 -72
  146. package/lib/modules/Cart/utils/changePrice.js +50 -28
  147. package/lib/modules/Cart/utils/index.js +48 -106
  148. package/lib/modules/Customer/constants.js +34 -13
  149. package/lib/modules/Customer/index.js +169 -232
  150. package/lib/modules/Customer/types.js +35 -38
  151. package/lib/modules/Date/index.js +115 -116
  152. package/lib/modules/Date/types.js +28 -16
  153. package/lib/modules/Date/utils.js +123 -174
  154. package/lib/modules/Discount/index.d.ts +0 -1
  155. package/lib/modules/Discount/index.js +128 -130
  156. package/lib/modules/Discount/types.d.ts +0 -1
  157. package/lib/modules/Discount/types.js +31 -9
  158. package/lib/modules/Guests/index.js +56 -30
  159. package/lib/modules/Guests/types.js +33 -23
  160. package/lib/modules/Holder/index.js +189 -209
  161. package/lib/modules/Holder/types.js +16 -4
  162. package/lib/modules/Holder/utils.js +49 -20
  163. package/lib/modules/OpenData/index.js +76 -69
  164. package/lib/modules/OpenData/types.js +16 -4
  165. package/lib/modules/OpenData/utils.js +78 -44
  166. package/lib/modules/Order/index.js +1909 -1572
  167. package/lib/modules/Order/types.js +35 -78
  168. package/lib/modules/Order/utils/bundleDiscountHydration.js +74 -41
  169. package/lib/modules/Order/utils/manualProductDiscount.js +123 -124
  170. package/lib/modules/Order/utils/orderCollectionIdentity.js +210 -148
  171. package/lib/modules/Order/utils.js +634 -799
  172. package/lib/modules/Payment/cash.js +33 -20
  173. package/lib/modules/Payment/cashRecommendationAlgorithm.js +76 -145
  174. package/lib/modules/Payment/eftpos.js +30 -16
  175. package/lib/modules/Payment/index.js +378 -518
  176. package/lib/modules/Payment/mx51.js +0 -1
  177. package/lib/modules/Payment/types.d.ts +4 -8
  178. package/lib/modules/Payment/types.js +107 -216
  179. package/lib/modules/Payment/utils.js +48 -51
  180. package/lib/modules/Payment/walletpass.d.ts +0 -2
  181. package/lib/modules/Payment/walletpass.js +211 -226
  182. package/lib/modules/Product/index.js +46 -51
  183. package/lib/modules/Product/types.js +16 -4
  184. package/lib/modules/Product/utils.js +33 -32
  185. package/lib/modules/ProductList/index.d.ts +1 -1
  186. package/lib/modules/ProductList/index.js +117 -117
  187. package/lib/modules/ProductList/types.d.ts +0 -1
  188. package/lib/modules/ProductList/types.js +31 -9
  189. package/lib/modules/Quotation/index.js +100 -66
  190. package/lib/modules/Quotation/types.js +16 -4
  191. package/lib/modules/Resource/index.js +59 -27
  192. package/lib/modules/Resource/types.js +32 -22
  193. package/lib/modules/Resource/utils.js +38 -30
  194. package/lib/modules/ResourcePlanner/index.js +61 -60
  195. package/lib/modules/ResourcePlanner/planner.js +384 -346
  196. package/lib/modules/ResourcePlanner/types.js +16 -4
  197. package/lib/modules/Rules/index.js +903 -1475
  198. package/lib/modules/Rules/types.js +40 -17
  199. package/lib/modules/SalesSummary/index.js +90 -85
  200. package/lib/modules/SalesSummary/types.js +16 -4
  201. package/lib/modules/SalesSummary/utils.js +427 -351
  202. package/lib/modules/ScanOrderLogger/index.js +79 -59
  203. package/lib/modules/ScanOrderLogger/providers/feishu.js +78 -54
  204. package/lib/modules/ScanOrderLogger/providers/grafana.js +36 -13
  205. package/lib/modules/ScanOrderLogger/types.js +16 -4
  206. package/lib/modules/Schedule/getDateIsInSchedule.js +163 -339
  207. package/lib/modules/Schedule/index.js +114 -100
  208. package/lib/modules/Schedule/type.js +16 -4
  209. package/lib/modules/Schedule/types.js +16 -4
  210. package/lib/modules/Schedule/utils.js +291 -433
  211. package/lib/modules/Step/index.js +52 -40
  212. package/lib/modules/Step/tyeps.js +16 -4
  213. package/lib/modules/Summary/index.js +71 -66
  214. package/lib/modules/Summary/types.js +16 -4
  215. package/lib/modules/Summary/utils.js +418 -791
  216. package/lib/modules/SurchargeList/index.js +60 -46
  217. package/lib/modules/SurchargeList/types.js +16 -4
  218. package/lib/modules/index.js +63 -245
  219. package/lib/plugins/app.js +16 -4
  220. package/lib/plugins/index.js +25 -36
  221. package/lib/plugins/request.js +126 -137
  222. package/lib/plugins/shopStore.js +16 -4
  223. package/lib/plugins/user.js +16 -4
  224. package/lib/plugins/window.js +179 -171
  225. package/lib/server/index.js +2337 -2675
  226. package/lib/server/modules/floor-plan/index.js +123 -102
  227. package/lib/server/modules/floor-plan/types.js +30 -15
  228. package/lib/server/modules/index.js +68 -106
  229. package/lib/server/modules/menu/index.js +122 -146
  230. package/lib/server/modules/menu/types.js +31 -18
  231. package/lib/server/modules/order/index.js +642 -567
  232. package/lib/server/modules/order/types.js +32 -117
  233. package/lib/server/modules/order/utils/filterBookings.js +194 -219
  234. package/lib/server/modules/order/utils/filterOrders.js +92 -118
  235. package/lib/server/modules/payment/index.js +83 -59
  236. package/lib/server/modules/payment/types.js +16 -4
  237. package/lib/server/modules/products/index.js +459 -575
  238. package/lib/server/modules/products/types.js +34 -44
  239. package/lib/server/modules/quotation/index.js +172 -137
  240. package/lib/server/modules/quotation/types.js +31 -21
  241. package/lib/server/modules/resource/index.js +184 -213
  242. package/lib/server/modules/resource/types.js +33 -42
  243. package/lib/server/modules/schedule/index.js +123 -135
  244. package/lib/server/modules/schedule/types.js +21 -14
  245. package/lib/server/modules/schedule/utils.js +163 -334
  246. package/lib/server/types.js +16 -4
  247. package/lib/server/utils/index.js +23 -25
  248. package/lib/server/utils/product.js +139 -196
  249. package/lib/server/utils/schedule.js +41 -34
  250. package/lib/server/utils/small-ticket.js +456 -478
  251. package/lib/server/utils/time.js +49 -40
  252. package/lib/solution/BaseSales/index.js +1016 -850
  253. package/lib/solution/BaseSales/types.js +37 -41
  254. package/lib/solution/BaseSales/utils/cartPromotion.js +460 -611
  255. package/lib/solution/BaseSales/utils/parseSalesResponse.js +105 -85
  256. package/lib/solution/BaseSales/utils/quotationPrice.js +114 -56
  257. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +143 -102
  258. package/lib/solution/BaseSales/utils.js +140 -155
  259. package/lib/solution/BookingByStep/index.d.ts +1 -1
  260. package/lib/solution/BookingByStep/index.js +1340 -1530
  261. package/lib/solution/BookingByStep/types.js +99 -40
  262. package/lib/solution/BookingByStep/utils/capacity.js +160 -192
  263. package/lib/solution/BookingByStep/utils/products.js +52 -42
  264. package/lib/solution/BookingByStep/utils/resources.js +330 -527
  265. package/lib/solution/BookingByStep/utils/stock.js +44 -65
  266. package/lib/solution/BookingByStep/utils/timeslots.js +131 -129
  267. package/lib/solution/BookingTicket/index.d.ts +1 -1
  268. package/lib/solution/BookingTicket/index.js +459 -543
  269. package/lib/solution/BookingTicket/types.js +77 -99
  270. package/lib/solution/BookingTicket/utils/addProductDecision.js +184 -219
  271. package/lib/solution/BookingTicket/utils/addTimeAvailability.js +89 -58
  272. package/lib/solution/BookingTicket/utils/bookingStatus.js +78 -107
  273. package/lib/solution/BookingTicket/utils/cartView.js +94 -110
  274. package/lib/solution/BookingTicket/utils/exampleData.js +0 -185
  275. package/lib/solution/BookingTicket/utils/orderCustomer.js +41 -18
  276. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +86 -219
  277. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +93 -144
  278. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +91 -79
  279. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +41 -54
  280. package/lib/solution/BookingTicket/utils/scan/handleScan.js +81 -84
  281. package/lib/solution/BookingTicket/utils/scan/index.js +104 -98
  282. package/lib/solution/BookingTicket/utils/scan/scanCache.js +43 -90
  283. package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +64 -52
  284. package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +58 -56
  285. package/lib/solution/BuyTickets/index.js +70 -67
  286. package/lib/solution/BuyTickets/types.js +38 -22
  287. package/lib/solution/Checkout/index.js +1158 -1451
  288. package/lib/solution/Checkout/types.js +61 -91
  289. package/lib/solution/Checkout/utils/index.js +156 -228
  290. package/lib/solution/PlaceOrder/index.js +0 -55
  291. package/lib/solution/RegisterAndLogin/config.js +460 -493
  292. package/lib/solution/RegisterAndLogin/index.js +630 -633
  293. package/lib/solution/RegisterAndLogin/types.js +76 -189
  294. package/lib/solution/RegisterAndLogin/utils.js +125 -183
  295. package/lib/solution/Sales/index.js +320 -317
  296. package/lib/solution/Sales/types.js +33 -27
  297. package/lib/solution/ScanOrder/index.js +862 -831
  298. package/lib/solution/ScanOrder/types.js +34 -33
  299. package/lib/solution/ScanOrder/utils.js +371 -406
  300. package/lib/solution/ShopDiscount/index.js +233 -235
  301. package/lib/solution/ShopDiscount/types.d.ts +4 -5
  302. package/lib/solution/ShopDiscount/types.js +37 -15
  303. package/lib/solution/ShopDiscount/utils.d.ts +0 -9
  304. package/lib/solution/ShopDiscount/utils.js +172 -309
  305. package/lib/solution/UnifiedBookingSales/index.js +405 -379
  306. package/lib/solution/UnifiedBookingSales/types.js +31 -12
  307. package/lib/solution/VenueBooking/index.d.ts +3 -31
  308. package/lib/solution/VenueBooking/index.js +916 -967
  309. package/lib/solution/VenueBooking/types.d.ts +1 -3
  310. package/lib/solution/VenueBooking/types.js +39 -20
  311. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +2 -2
  312. package/lib/solution/VenueBooking/utils/dateSummary.js +62 -25
  313. package/lib/solution/VenueBooking/utils/resource.js +54 -31
  314. package/lib/solution/VenueBooking/utils/slotMerge.js +107 -94
  315. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +0 -2
  316. package/lib/solution/VenueBooking/utils/timeSlot.js +133 -138
  317. package/lib/solution/VenueBooking/utils.js +67 -130
  318. package/lib/solution/index.js +41 -124
  319. package/lib/store/createStore.js +29 -32
  320. package/lib/types/index.d.ts +1 -1
  321. package/lib/types/index.js +16 -4
  322. package/lib/utils/task.js +36 -36
  323. package/lib/utils/watch.js +47 -81
  324. package/package.json +2 -4
  325. package/dist/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
  326. package/dist/solution/VenueBooking/utils/smartPricing.js +0 -233
  327. package/lib/solution/VenueBooking/utils/smartPricing.d.ts +0 -70
  328. package/lib/solution/VenueBooking/utils/smartPricing.js +0 -192
@@ -117,13 +117,20 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
117
117
  _context.next = 15;
118
118
  return this.initializeSubModules(core, options);
119
119
  case 15:
120
- _context.next = 17;
120
+ // 预加载支付方式(利用缓存机制)
121
+ // await this.preloadPaymentMethods();
122
+
123
+ // 清理过期的已同步订单数据
124
+ // await this.cleanupExpiredOrdersAsync();
125
+
126
+ console.log('[Checkout] 初始化完成');
127
+ _context.next = 18;
121
128
  return this.core.effects.emit("".concat(this.name, ":onCheckoutInitialized"), {
122
129
  timestamp: Date.now()
123
130
  });
124
- case 17:
125
- this.logInfo('CheckoutModule initialized successfully');
126
131
  case 18:
132
+ this.logInfo('CheckoutModule initialized successfully');
133
+ case 19:
127
134
  case "end":
128
135
  return _context.stop();
129
136
  }
@@ -281,8 +288,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
281
288
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
282
289
  while (1) switch (_context5.prev = _context5.next) {
283
290
  case 0:
291
+ console.log('[Checkout] 收到支付方式加载完成事件:', methods.length);
284
292
  _this2.store.paymentMethods = methods;
285
- case 1:
293
+ case 2:
286
294
  case "end":
287
295
  return _context5.stop();
288
296
  }
@@ -299,8 +307,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
299
307
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
300
308
  while (1) switch (_context6.prev = _context6.next) {
301
309
  case 0:
310
+ console.log('[Checkout] 收到支付方式变更事件:', {
311
+ oldCount: data.oldMethods.length,
312
+ newCount: data.newMethods.length
313
+ });
302
314
  _this2.store.paymentMethods = data.newMethods;
303
- case 1:
315
+ case 2:
304
316
  case "end":
305
317
  return _context6.stop();
306
318
  }
@@ -340,20 +352,21 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
340
352
  case 5:
341
353
  // 保存购物车数据
342
354
  this.store.cartItems = params.cartItems;
343
- _context7.next = 13;
355
+ console.log('[Checkout] 结账流程初始化完成');
356
+ _context7.next = 14;
344
357
  break;
345
- case 8:
346
- _context7.prev = 8;
358
+ case 9:
359
+ _context7.prev = 9;
347
360
  _context7.t0 = _context7["catch"](1);
348
- _context7.next = 12;
361
+ _context7.next = 13;
349
362
  return this.handleError(_context7.t0, CheckoutErrorType.UnknownError);
350
- case 12:
351
- throw _context7.t0;
352
363
  case 13:
364
+ throw _context7.t0;
365
+ case 14:
353
366
  case "end":
354
367
  return _context7.stop();
355
368
  }
356
- }, _callee7, this, [[1, 8]]);
369
+ }, _callee7, this, [[1, 9]]);
357
370
  }));
358
371
  function initializeCheckoutAsync(_x9) {
359
372
  return _initializeCheckoutAsync.apply(this, arguments);
@@ -655,8 +668,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
655
668
  }; // 只有在有客户信息时才存储
656
669
  if (customerInfo.customer_id || customerInfo.customer_name) {
657
670
  this.store.currentCustomer = customerInfo;
671
+ console.log('[Checkout] 保存客户信息:', customerInfo);
658
672
  } else {
659
673
  this.store.currentCustomer = undefined;
674
+ console.log('[Checkout] 未提供客户信息');
660
675
  }
661
676
 
662
677
  // 计算是否需要支付定金,如果需要默认切换到定金模式,以及记录定金总金额,并把当前默认待付金额调整为定金总金额
@@ -1082,26 +1097,28 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1082
1097
  timestamp: Date.now()
1083
1098
  });
1084
1099
  case 11:
1100
+ console.log('[Checkout] 结账流程完成:', order.id);
1101
+
1085
1102
  // 🔧 新增:自动重置 store 状态(同步执行)
1086
1103
  this.resetStoreState();
1087
1104
  return _context11.abrupt("return", {
1088
1105
  success: true,
1089
1106
  orderId: String(order.id)
1090
1107
  });
1091
- case 15:
1092
- _context11.prev = 15;
1108
+ case 16:
1109
+ _context11.prev = 16;
1093
1110
  _context11.t0 = _context11["catch"](0);
1094
- _context11.next = 19;
1111
+ _context11.next = 20;
1095
1112
  return this.handleError(_context11.t0, CheckoutErrorType.UnknownError);
1096
- case 19:
1113
+ case 20:
1097
1114
  return _context11.abrupt("return", {
1098
1115
  success: false
1099
1116
  });
1100
- case 20:
1117
+ case 21:
1101
1118
  case "end":
1102
1119
  return _context11.stop();
1103
1120
  }
1104
- }, _callee11, this, [[0, 15]]);
1121
+ }, _callee11, this, [[0, 16]]);
1105
1122
  }));
1106
1123
  function completeCheckoutAsync() {
1107
1124
  return _completeCheckoutAsync.apply(this, arguments);
@@ -1133,6 +1150,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1133
1150
  cartItems = _this$store.cartItems,
1134
1151
  localOrderData = _this$store.localOrderData;
1135
1152
  if (!_currentOrder) {
1153
+ console.log('[Checkout] 当前没有活跃订单');
1136
1154
  return null;
1137
1155
  }
1138
1156
 
@@ -1178,26 +1196,27 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1178
1196
  _context12.prev = 0;
1179
1197
  _currentOrder2 = this.store.currentOrder;
1180
1198
  if (_currentOrder2) {
1181
- _context12.next = 4;
1199
+ _context12.next = 5;
1182
1200
  break;
1183
1201
  }
1202
+ console.log('[Checkout] 当前没有活跃订单,无法获取支付项');
1184
1203
  return _context12.abrupt("return", []);
1185
- case 4:
1186
- _context12.next = 6;
1204
+ case 5:
1205
+ _context12.next = 7;
1187
1206
  return this.payment.getPaymentItemsAsync(_currentOrder2.uuid);
1188
- case 6:
1207
+ case 7:
1189
1208
  paymentItems = _context12.sent;
1190
1209
  return _context12.abrupt("return", paymentItems);
1191
- case 10:
1192
- _context12.prev = 10;
1210
+ case 11:
1211
+ _context12.prev = 11;
1193
1212
  _context12.t0 = _context12["catch"](0);
1194
1213
  console.error('[Checkout] 获取当前订单支付项失败:', _context12.t0);
1195
1214
  return _context12.abrupt("return", []);
1196
- case 14:
1215
+ case 15:
1197
1216
  case "end":
1198
1217
  return _context12.stop();
1199
1218
  }
1200
- }, _callee12, this, [[0, 10]]);
1219
+ }, _callee12, this, [[0, 11]]);
1201
1220
  }));
1202
1221
  function getCurrentOrderPaymentItemsAsync() {
1203
1222
  return _getCurrentOrderPaymentItemsAsync.apply(this, arguments);
@@ -1254,7 +1273,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1254
1273
  case 8:
1255
1274
  updatedOrder = _context13.sent;
1256
1275
  if (!updatedOrder) {
1257
- _context13.next = 19;
1276
+ _context13.next = 20;
1258
1277
  break;
1259
1278
  }
1260
1279
  // 🔧 重要:Payment.replaceOrderIdByUuidAsync 返回的是 DB 快照(只保证 order_id 变化)
@@ -1279,27 +1298,32 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1279
1298
  timestamp: Date.now()
1280
1299
  });
1281
1300
  case 16:
1301
+ console.log('[Checkout] 本地订单ID替换成功:', {
1302
+ uuid: updatedOrder.uuid,
1303
+ newOrderId: updatedOrder.id
1304
+ });
1305
+
1282
1306
  // 标记订单已同步(替换ID意味着订单已在后端创建)
1283
1307
  this.store.isOrderSynced = true;
1284
1308
 
1285
1309
  // 订单ID替换后更新 stateAmount
1286
- _context13.next = 19;
1310
+ _context13.next = 20;
1287
1311
  return this.updateStateAmountToRemaining(false);
1288
- case 19:
1312
+ case 20:
1289
1313
  return _context13.abrupt("return", updatedOrder);
1290
- case 22:
1291
- _context13.prev = 22;
1314
+ case 23:
1315
+ _context13.prev = 23;
1292
1316
  _context13.t0 = _context13["catch"](0);
1293
1317
  console.error('[Checkout] 替换订单ID失败:', _context13.t0);
1294
- _context13.next = 27;
1318
+ _context13.next = 28;
1295
1319
  return this.handleError(_context13.t0, CheckoutErrorType.UnknownError);
1296
- case 27:
1297
- return _context13.abrupt("return", null);
1298
1320
  case 28:
1321
+ return _context13.abrupt("return", null);
1322
+ case 29:
1299
1323
  case "end":
1300
1324
  return _context13.stop();
1301
1325
  }
1302
- }, _callee13, this, [[0, 22]]);
1326
+ }, _callee13, this, [[0, 23]]);
1303
1327
  }));
1304
1328
  function replaceLocalOrderIdAsync(_x13) {
1305
1329
  return _replaceLocalOrderIdAsync.apply(this, arguments);
@@ -1946,11 +1970,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1946
1970
  newDepositValue = isDeposit;
1947
1971
  oldDepositValue = this.store.currentOrder.is_deposit; // 如果状态没有变化,直接返回
1948
1972
  if (!(oldDepositValue === newDepositValue)) {
1949
- _context19.next = 9;
1973
+ _context19.next = 10;
1950
1974
  break;
1951
1975
  }
1976
+ console.log('[Checkout] 定金状态无变化,跳过更新');
1952
1977
  return _context19.abrupt("return");
1953
- case 9:
1978
+ case 10:
1954
1979
  deposit_amount = this.store.currentOrder.deposit_amount || '0.00'; // 如果原来没有 deposit_amount,则默认把待付金额置为 deposit_amount
1955
1980
  if (!deposit_amount || Number(deposit_amount) === 0) {
1956
1981
  deposit_amount = this.store.currentOrder.expect_amount;
@@ -1969,9 +1994,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1969
1994
  // this.logInfo('订单从定金改为全款,清空定金金额');
1970
1995
  // }
1971
1996
  // 调用 Payment 模块更新订单
1972
- _context19.next = 14;
1997
+ _context19.next = 15;
1973
1998
  return this.payment.updateOrderAsync(this.store.currentOrder.uuid, updateParams);
1974
- case 14:
1999
+ case 15:
1975
2000
  // 更新本地缓存的订单对象
1976
2001
  this.store.currentOrder = _objectSpread(_objectSpread({}, this.store.currentOrder), updateParams);
1977
2002
 
@@ -1985,31 +2010,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1985
2010
  this.updateStateAmountToRemaining(false);
1986
2011
 
1987
2012
  // 触发订单更新事件
1988
- _context19.next = 20;
2013
+ _context19.next = 21;
1989
2014
  return this.core.effects.emit("".concat(this.name, ":onOrderCreated"), {
1990
2015
  order: this.store.currentOrder,
1991
2016
  timestamp: Date.now()
1992
2017
  });
1993
- case 20:
2018
+ case 21:
1994
2019
  this.logInfo('订单定金状态更新成功:', {
1995
2020
  isDeposit: newDepositValue,
1996
2021
  depositAmount: this.store.currentOrder.deposit_amount
1997
2022
  });
1998
- _context19.next = 29;
2023
+ _context19.next = 30;
1999
2024
  break;
2000
- case 23:
2001
- _context19.prev = 23;
2025
+ case 24:
2026
+ _context19.prev = 24;
2002
2027
  _context19.t0 = _context19["catch"](0);
2003
2028
  this.logError('更新订单定金状态失败:', _context19.t0);
2004
- _context19.next = 28;
2029
+ _context19.next = 29;
2005
2030
  return this.handleError(_context19.t0, CheckoutErrorType.ValidationFailed);
2006
- case 28:
2007
- throw _context19.t0;
2008
2031
  case 29:
2032
+ throw _context19.t0;
2033
+ case 30:
2009
2034
  case "end":
2010
2035
  return _context19.stop();
2011
2036
  }
2012
- }, _callee19, this, [[0, 23]]);
2037
+ }, _callee19, this, [[0, 24]]);
2013
2038
  }));
2014
2039
  function updateOrderDepositStatusAsync(_x19) {
2015
2040
  return _updateOrderDepositStatusAsync.apply(this, arguments);
@@ -2164,6 +2189,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2164
2189
  return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2165
2190
  while (1) switch (_context21.prev = _context21.next) {
2166
2191
  case 0:
2192
+ console.log('manualSyncOrderAsync called');
2167
2193
  this.logInfo('manualSyncOrderAsync called', {
2168
2194
  hasCurrentOrder: !!this.store.currentOrder,
2169
2195
  currentOrderId: (_this$store$currentOr15 = this.store.currentOrder) === null || _this$store$currentOr15 === void 0 ? void 0 : _this$store$currentOr15.order_id,
@@ -2172,16 +2198,16 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2172
2198
  isOrderSynced: this.store.isOrderSynced,
2173
2199
  isVirtualOrderId: this.store.currentOrder ? isVirtualOrderId(this.store.currentOrder.order_id) : false
2174
2200
  });
2175
- _context21.prev = 1;
2201
+ _context21.prev = 2;
2176
2202
  if (this.store.currentOrder) {
2177
- _context21.next = 4;
2203
+ _context21.next = 5;
2178
2204
  break;
2179
2205
  }
2180
2206
  return _context21.abrupt("return", {
2181
2207
  success: false,
2182
2208
  message: '当前没有活跃订单,无法同步'
2183
2209
  });
2184
- case 4:
2210
+ case 5:
2185
2211
  orderUuid = this.store.currentOrder.uuid;
2186
2212
  oldOrderId = this.store.currentOrder.order_id; // 检查订单是否已经同步
2187
2213
  if (this.store.isOrderSynced) {
@@ -2191,9 +2217,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2191
2217
  _context21.t1 = orderUuid;
2192
2218
  _context21.t2 = oldOrderId;
2193
2219
  _context21.t3 = this.store.currentOrder.total_amount;
2194
- _context21.next = 13;
2220
+ _context21.next = 14;
2195
2221
  return this.calculateRemainingAmountAsync();
2196
- case 13:
2222
+ case 14:
2197
2223
  _context21.t4 = _context21.sent;
2198
2224
  _context21.t5 = {
2199
2225
  orderUuid: _context21.t1,
@@ -2202,10 +2228,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2202
2228
  remainingAmount: _context21.t4
2203
2229
  };
2204
2230
  _context21.t0.logInfo.call(_context21.t0, '开始手动同步订单到后端:', _context21.t5);
2205
- _context21.next = 18;
2231
+ console.time('manualSyncOrderAsync');
2232
+
2233
+ // 强制同步订单到后端,并获取完整响应数据
2234
+ _context21.next = 20;
2206
2235
  return this.syncOrderToBackendWithReturn(true);
2207
- case 18:
2236
+ case 20:
2208
2237
  syncResult = _context21.sent;
2238
+ console.timeEnd('manualSyncOrderAsync');
2209
2239
  this.logInfo('手动同步订单完成:', {
2210
2240
  orderUuid: orderUuid,
2211
2241
  syncResult: syncResult,
@@ -2226,13 +2256,13 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2226
2256
  newRes = _objectSpread(_objectSpread({}, syncResult), {}, {
2227
2257
  is_deposit: ((_this$store$currentOr18 = this.store.currentOrder) === null || _this$store$currentOr18 === void 0 ? void 0 : _this$store$currentOr18.is_deposit) || 0
2228
2258
  });
2229
- _context21.next = 27;
2259
+ _context21.next = 30;
2230
2260
  return this.updateStateAmountToRemaining(false);
2231
- case 27:
2232
- return _context21.abrupt("return", newRes);
2233
2261
  case 30:
2234
- _context21.prev = 30;
2235
- _context21.t6 = _context21["catch"](1);
2262
+ return _context21.abrupt("return", newRes);
2263
+ case 33:
2264
+ _context21.prev = 33;
2265
+ _context21.t6 = _context21["catch"](2);
2236
2266
  this.logError('手动同步订单失败:', _context21.t6);
2237
2267
  errorMessage = _context21.t6 instanceof Error ? _context21.t6.message : '同步失败';
2238
2268
  return _context21.abrupt("return", {
@@ -2240,11 +2270,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2240
2270
  message: "\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(errorMessage),
2241
2271
  orderUuid: (_this$store$currentOr19 = this.store.currentOrder) === null || _this$store$currentOr19 === void 0 ? void 0 : _this$store$currentOr19.uuid
2242
2272
  });
2243
- case 35:
2273
+ case 38:
2244
2274
  case "end":
2245
2275
  return _context21.stop();
2246
2276
  }
2247
- }, _callee21, this, [[1, 30]]);
2277
+ }, _callee21, this, [[2, 33]]);
2248
2278
  }));
2249
2279
  function manualSyncOrderAsync() {
2250
2280
  return _manualSyncOrderAsync.apply(this, arguments);
@@ -2261,6 +2291,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2261
2291
  key: "getOrderNote",
2262
2292
  value: function getOrderNote() {
2263
2293
  if (!this.store.localOrderData) {
2294
+ console.log('[Checkout] 没有本地订单数据,无法获取备注');
2264
2295
  return '';
2265
2296
  }
2266
2297
  return this.store.localOrderData.shop_note || '';
@@ -2290,9 +2321,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2290
2321
  value: function isCurrentOrderSynced() {
2291
2322
  // 如果没有当前订单,返回false
2292
2323
  if (!this.store.currentOrder) {
2324
+ console.log('[Checkout] 没有当前订单,同步状态为false');
2293
2325
  return false;
2294
2326
  }
2295
2327
  var syncStatus = this.store.isOrderSynced;
2328
+ console.log('[Checkout] 当前订单同步状态:', {
2329
+ orderUuid: this.store.currentOrder.uuid,
2330
+ orderId: this.store.currentOrder.order_id,
2331
+ isOrderSynced: syncStatus
2332
+ });
2296
2333
  return syncStatus;
2297
2334
  }
2298
2335
 
@@ -2511,7 +2548,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2511
2548
  key: "updateOrderNoteAsync",
2512
2549
  value: (function () {
2513
2550
  var _updateOrderNoteAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(note) {
2514
- var _this$store$currentOr23, oldNote, orderInPayment;
2551
+ var _this$store$currentOr23, _this$store$currentOr24, oldNote, orderInPayment;
2515
2552
  return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2516
2553
  while (1) switch (_context24.prev = _context24.next) {
2517
2554
  case 0:
@@ -2522,51 +2559,65 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2522
2559
  }
2523
2560
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, '没有本地订单数据,无法更新备注');
2524
2561
  case 3:
2562
+ console.log('[Checkout] 更新订单备注:', {
2563
+ orderUuid: (_this$store$currentOr23 = this.store.currentOrder) === null || _this$store$currentOr23 === void 0 ? void 0 : _this$store$currentOr23.uuid,
2564
+ oldNote: this.store.localOrderData.shop_note,
2565
+ newNote: note
2566
+ });
2567
+
2525
2568
  // 更新备注
2526
2569
  oldNote = this.store.localOrderData.shop_note;
2527
2570
  this.store.localOrderData.shop_note = note;
2528
2571
 
2529
2572
  // 如果有当前订单,也同步到Payment模块中的订单数据
2530
2573
  if (!this.store.currentOrder) {
2531
- _context24.next = 16;
2574
+ _context24.next = 17;
2532
2575
  break;
2533
2576
  }
2534
- _context24.prev = 6;
2535
- _context24.next = 9;
2577
+ _context24.prev = 7;
2578
+ _context24.next = 10;
2536
2579
  return this.payment.getPaymentOrderByUuidAsync(this.store.currentOrder.uuid);
2537
- case 9:
2580
+ case 10:
2538
2581
  orderInPayment = _context24.sent;
2539
- if (orderInPayment && orderInPayment.note !== undefined) {}
2540
- _context24.next = 16;
2582
+ if (orderInPayment && orderInPayment.note !== undefined) {
2583
+ // 使用Payment模块的更新方法(如果有的话)
2584
+ // 这里可能需要根据Payment模块的实际API来调整
2585
+ console.log('[Checkout] 同步备注到Payment模块的订单数据中');
2586
+ }
2587
+ _context24.next = 17;
2541
2588
  break;
2542
- case 13:
2543
- _context24.prev = 13;
2544
- _context24.t0 = _context24["catch"](6);
2589
+ case 14:
2590
+ _context24.prev = 14;
2591
+ _context24.t0 = _context24["catch"](7);
2545
2592
  console.warn('[Checkout] 同步备注到Payment模块失败,但本地更新成功:', _context24.t0);
2546
- case 16:
2547
- _context24.next = 18;
2593
+ case 17:
2594
+ _context24.next = 19;
2548
2595
  return this.core.effects.emit("".concat(this.name, ":onOrderNoteChanged"), {
2549
- orderUuid: (_this$store$currentOr23 = this.store.currentOrder) === null || _this$store$currentOr23 === void 0 ? void 0 : _this$store$currentOr23.uuid,
2596
+ orderUuid: (_this$store$currentOr24 = this.store.currentOrder) === null || _this$store$currentOr24 === void 0 ? void 0 : _this$store$currentOr24.uuid,
2550
2597
  oldNote: oldNote,
2551
2598
  newNote: note,
2552
2599
  timestamp: Date.now()
2553
2600
  });
2554
- case 18:
2555
- _context24.next = 26;
2601
+ case 19:
2602
+ console.log('[Checkout] 订单备注更新成功:', {
2603
+ oldNote: oldNote,
2604
+ newNote: note
2605
+ });
2606
+ _context24.next = 28;
2556
2607
  break;
2557
- case 20:
2558
- _context24.prev = 20;
2608
+ case 22:
2609
+ _context24.prev = 22;
2559
2610
  _context24.t1 = _context24["catch"](0);
2560
2611
  console.error('[Checkout] 更新订单备注失败:', _context24.t1);
2561
- _context24.next = 25;
2612
+ _context24.next = 27;
2562
2613
  return this.handleError(_context24.t1, CheckoutErrorType.ValidationFailed);
2563
- case 25:
2614
+ case 27:
2564
2615
  throw _context24.t1;
2565
- case 26:
2616
+ case 28:
2566
2617
  case "end":
2567
2618
  return _context24.stop();
2568
2619
  }
2569
- }, _callee24, this, [[0, 20], [6, 13]]);
2620
+ }, _callee24, this, [[0, 22], [7, 14]]);
2570
2621
  }));
2571
2622
  function updateOrderNoteAsync(_x22) {
2572
2623
  return _updateOrderNoteAsync.apply(this, arguments);
@@ -2614,7 +2665,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2614
2665
  key: "handlePaymentSuccess",
2615
2666
  value: (function () {
2616
2667
  var _handlePaymentSuccess = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(data) {
2617
- var _this$store$currentOr24;
2668
+ var _this$store$currentOr25;
2618
2669
  return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2619
2670
  while (1) switch (_context26.prev = _context26.next) {
2620
2671
  case 0:
@@ -2625,7 +2676,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2625
2676
  return this.core.effects.emit("".concat(this.name, ":onPaymentSuccess"), {
2626
2677
  orderUuid: data.orderUuid,
2627
2678
  paymentMethodCode: '',
2628
- amount: ((_this$store$currentOr24 = this.store.currentOrder) === null || _this$store$currentOr24 === void 0 ? void 0 : _this$store$currentOr24.total_amount) || '0',
2679
+ amount: ((_this$store$currentOr25 = this.store.currentOrder) === null || _this$store$currentOr25 === void 0 ? void 0 : _this$store$currentOr25.total_amount) || '0',
2629
2680
  timestamp: data.timestamp
2630
2681
  });
2631
2682
  case 4:
@@ -2650,7 +2701,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2650
2701
  key: "handlePaymentError",
2651
2702
  value: (function () {
2652
2703
  var _handlePaymentError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(data) {
2653
- var _this$store$currentOr25;
2704
+ var _this$store$currentOr26;
2654
2705
  var error;
2655
2706
  return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2656
2707
  while (1) switch (_context27.prev = _context27.next) {
@@ -2663,7 +2714,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2663
2714
  return this.core.effects.emit("".concat(this.name, ":onPaymentFailed"), {
2664
2715
  orderUuid: data.orderUuid,
2665
2716
  paymentMethodCode: '',
2666
- amount: ((_this$store$currentOr25 = this.store.currentOrder) === null || _this$store$currentOr25 === void 0 ? void 0 : _this$store$currentOr25.total_amount) || '0',
2717
+ amount: ((_this$store$currentOr26 = this.store.currentOrder) === null || _this$store$currentOr26 === void 0 ? void 0 : _this$store$currentOr26.total_amount) || '0',
2667
2718
  timestamp: data.timestamp
2668
2719
  });
2669
2720
  case 5:
@@ -2787,23 +2838,25 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2787
2838
  while (1) switch (_context29.prev = _context29.next) {
2788
2839
  case 0:
2789
2840
  _context29.prev = 0;
2790
- _context29.next = 3;
2841
+ console.log('[Checkout] 预加载支付方式...');
2842
+ _context29.next = 4;
2791
2843
  return this.payment.getPayMethodListAsync();
2792
- case 3:
2844
+ case 4:
2793
2845
  methods = _context29.sent;
2794
2846
  this.store.paymentMethods = methods;
2795
- _context29.next = 11;
2847
+ console.log("[Checkout] \u9884\u52A0\u8F7D\u5B8C\u6210\uFF0C\u5171 ".concat(methods.length, " \u79CD\u652F\u4ED8\u65B9\u5F0F"));
2848
+ _context29.next = 13;
2796
2849
  break;
2797
- case 7:
2798
- _context29.prev = 7;
2850
+ case 9:
2851
+ _context29.prev = 9;
2799
2852
  _context29.t0 = _context29["catch"](0);
2800
2853
  console.error('[Checkout] 预加载支付方式失败:', _context29.t0);
2801
2854
  this.store.paymentMethods = [];
2802
- case 11:
2855
+ case 13:
2803
2856
  case "end":
2804
2857
  return _context29.stop();
2805
2858
  }
2806
- }, _callee29, this, [[0, 7]]);
2859
+ }, _callee29, this, [[0, 9]]);
2807
2860
  }));
2808
2861
  function preloadPaymentMethods() {
2809
2862
  return _preloadPaymentMethods.apply(this, arguments);
@@ -2832,43 +2885,48 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2832
2885
  retentionDays = cleanupConfig.retentionDays || 7; // 默认保留7天
2833
2886
  maxOrdersToDelete = cleanupConfig.maxOrdersToDelete || 100; // 默认最多删除100个订单
2834
2887
  if (isCleanupEnabled) {
2835
- _context30.next = 7;
2888
+ _context30.next = 8;
2836
2889
  break;
2837
2890
  }
2891
+ console.log('[Checkout] 订单数据清理功能已禁用');
2838
2892
  return _context30.abrupt("return");
2839
- case 7:
2840
- _context30.next = 9;
2893
+ case 8:
2894
+ console.log("[Checkout] \u5F00\u59CB\u6E05\u7406\u8FC7\u671F\u8BA2\u5355\u6570\u636E\uFF08\u4FDD\u7559 ".concat(retentionDays, " \u5929\u5185\u7684\u6570\u636E\uFF09..."));
2895
+
2896
+ // 获取所有订单
2897
+ _context30.next = 11;
2841
2898
  return this.payment.getOrderListAsync();
2842
- case 9:
2899
+ case 11:
2843
2900
  allOrders = _context30.sent;
2844
2901
  if (!(!allOrders || allOrders.length === 0)) {
2845
- _context30.next = 12;
2902
+ _context30.next = 15;
2846
2903
  break;
2847
2904
  }
2905
+ console.log('[Checkout] 没有找到需要清理的订单数据');
2848
2906
  return _context30.abrupt("return");
2849
- case 12:
2907
+ case 15:
2850
2908
  thresholdDate = new Date();
2851
2909
  thresholdDate.setDate(thresholdDate.getDate() - retentionDays);
2852
2910
  deletedCount = 0;
2853
2911
  ordersToDelete = [];
2854
2912
  _iterator = _createForOfIteratorHelper(allOrders);
2855
- _context30.prev = 17;
2913
+ _context30.prev = 20;
2856
2914
  _iterator.s();
2857
- case 19:
2915
+ case 22:
2858
2916
  if ((_step = _iterator.n()).done) {
2859
- _context30.next = 38;
2917
+ _context30.next = 41;
2860
2918
  break;
2861
2919
  }
2862
2920
  order = _step.value;
2863
- _context30.prev = 21;
2921
+ _context30.prev = 24;
2864
2922
  // 检查订单是否已同步(订单ID不是虚拟ID)
2865
2923
  isSynced = order.order_id && !isVirtualOrderId(order.order_id);
2866
2924
  if (isSynced) {
2867
- _context30.next = 25;
2925
+ _context30.next = 28;
2868
2926
  break;
2869
2927
  }
2870
- return _context30.abrupt("continue", 36);
2871
- case 25:
2928
+ return _context30.abrupt("continue", 39);
2929
+ case 28:
2872
2930
  // 检查创建时间
2873
2931
  orderCreatedAt = null; // 尝试从 order_info.created_at 获取创建时间
2874
2932
  if ((_order$order_info = order.order_info) !== null && _order$order_info !== void 0 && _order$order_info.created_at) {
@@ -2881,11 +2939,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2881
2939
 
2882
2940
  // 如果无法获取创建时间,跳过此订单
2883
2941
  if (!(!orderCreatedAt || isNaN(orderCreatedAt.getTime()))) {
2884
- _context30.next = 29;
2942
+ _context30.next = 32;
2885
2943
  break;
2886
2944
  }
2887
- return _context30.abrupt("continue", 36);
2888
- case 29:
2945
+ return _context30.abrupt("continue", 39);
2946
+ case 32:
2889
2947
  // 检查是否超过指定天数
2890
2948
  if (orderCreatedAt < thresholdDate) {
2891
2949
  ordersToDelete.push({
@@ -2895,68 +2953,69 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2895
2953
  daysSinceCreated: Math.floor((Date.now() - orderCreatedAt.getTime()) / (1000 * 60 * 60 * 24))
2896
2954
  });
2897
2955
  }
2898
- _context30.next = 36;
2956
+ _context30.next = 39;
2899
2957
  break;
2900
- case 32:
2901
- _context30.prev = 32;
2902
- _context30.t0 = _context30["catch"](21);
2958
+ case 35:
2959
+ _context30.prev = 35;
2960
+ _context30.t0 = _context30["catch"](24);
2903
2961
  console.warn("[Checkout] \u5904\u7406\u8BA2\u5355 ".concat(order.uuid, " \u65F6\u51FA\u9519:"), _context30.t0);
2904
- return _context30.abrupt("continue", 36);
2905
- case 36:
2906
- _context30.next = 19;
2962
+ return _context30.abrupt("continue", 39);
2963
+ case 39:
2964
+ _context30.next = 22;
2907
2965
  break;
2908
- case 38:
2909
- _context30.next = 43;
2966
+ case 41:
2967
+ _context30.next = 46;
2910
2968
  break;
2911
- case 40:
2912
- _context30.prev = 40;
2913
- _context30.t1 = _context30["catch"](17);
2914
- _iterator.e(_context30.t1);
2915
2969
  case 43:
2916
2970
  _context30.prev = 43;
2917
- _iterator.f();
2918
- return _context30.finish(43);
2971
+ _context30.t1 = _context30["catch"](20);
2972
+ _iterator.e(_context30.t1);
2919
2973
  case 46:
2974
+ _context30.prev = 46;
2975
+ _iterator.f();
2976
+ return _context30.finish(46);
2977
+ case 49:
2920
2978
  // 按创建时间排序(最老的先删除)并限制删除数量
2921
2979
  ordersToDelete.sort(function (a, b) {
2922
2980
  return new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime();
2923
2981
  });
2924
2982
  actualOrdersToDelete = ordersToDelete.slice(0, maxOrdersToDelete); // 删除符合条件的订单
2925
2983
  _iterator2 = _createForOfIteratorHelper(actualOrdersToDelete);
2926
- _context30.prev = 49;
2984
+ _context30.prev = 52;
2927
2985
  _iterator2.s();
2928
- case 51:
2986
+ case 54:
2929
2987
  if ((_step2 = _iterator2.n()).done) {
2930
- _context30.next = 64;
2988
+ _context30.next = 68;
2931
2989
  break;
2932
2990
  }
2933
2991
  orderInfo = _step2.value;
2934
- _context30.prev = 53;
2935
- _context30.next = 56;
2992
+ _context30.prev = 56;
2993
+ _context30.next = 59;
2936
2994
  return this.payment.deletePaymentOrderAsync(orderInfo.uuid);
2937
- case 56:
2995
+ case 59:
2938
2996
  deletedCount++;
2939
- _context30.next = 62;
2997
+ console.log("[Checkout] \u5DF2\u5220\u9664\u8FC7\u671F\u8BA2\u5355: ".concat(orderInfo.orderId, " (").concat(orderInfo.daysSinceCreated, " \u5929\u524D\u521B\u5EFA)"));
2998
+ _context30.next = 66;
2940
2999
  break;
2941
- case 59:
2942
- _context30.prev = 59;
2943
- _context30.t2 = _context30["catch"](53);
3000
+ case 63:
3001
+ _context30.prev = 63;
3002
+ _context30.t2 = _context30["catch"](56);
2944
3003
  console.error("[Checkout] \u5220\u9664\u8BA2\u5355 ".concat(orderInfo.uuid, " \u5931\u8D25:"), _context30.t2);
2945
- case 62:
2946
- _context30.next = 51;
3004
+ case 66:
3005
+ _context30.next = 54;
2947
3006
  break;
2948
- case 64:
2949
- _context30.next = 69;
3007
+ case 68:
3008
+ _context30.next = 73;
2950
3009
  break;
2951
- case 66:
2952
- _context30.prev = 66;
2953
- _context30.t3 = _context30["catch"](49);
3010
+ case 70:
3011
+ _context30.prev = 70;
3012
+ _context30.t3 = _context30["catch"](52);
2954
3013
  _iterator2.e(_context30.t3);
2955
- case 69:
2956
- _context30.prev = 69;
3014
+ case 73:
3015
+ _context30.prev = 73;
2957
3016
  _iterator2.f();
2958
- return _context30.finish(69);
2959
- case 72:
3017
+ return _context30.finish(73);
3018
+ case 76:
2960
3019
  summary = {
2961
3020
  totalOrders: allOrders.length,
2962
3021
  expiredSyncedOrders: ordersToDelete.length,
@@ -2968,22 +3027,26 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2968
3027
  skippedOrders: Math.max(0, ordersToDelete.length - maxOrdersToDelete)
2969
3028
  }; // 记录清理结果
2970
3029
  this.logInfo('Expired orders cleanup completed', summary);
2971
- if (ordersToDelete.length > maxOrdersToDelete) {} else {}
2972
- _context30.next = 82;
3030
+ if (ordersToDelete.length > maxOrdersToDelete) {
3031
+ console.log("[Checkout] \u8FC7\u671F\u8BA2\u5355\u6E05\u7406\u5B8C\u6210: \u603B\u8BA1 ".concat(allOrders.length, " \u4E2A\u8BA2\u5355\uFF0C\u53D1\u73B0 ").concat(ordersToDelete.length, " \u4E2A\u8FC7\u671F\u5DF2\u540C\u6B65\u8BA2\u5355\uFF0C\u5220\u9664\u4E86 ").concat(deletedCount, " \u4E2A\uFF08\u9650\u5236\u4E3A ").concat(maxOrdersToDelete, " \u4E2A\uFF09"));
3032
+ } else {
3033
+ console.log("[Checkout] \u8FC7\u671F\u8BA2\u5355\u6E05\u7406\u5B8C\u6210: \u603B\u8BA1 ".concat(allOrders.length, " \u4E2A\u8BA2\u5355\uFF0C\u5220\u9664\u4E86 ").concat(deletedCount, " \u4E2A\u8FC7\u671F\u5DF2\u540C\u6B65\u8BA2\u5355"));
3034
+ }
3035
+ _context30.next = 86;
2973
3036
  break;
2974
- case 77:
2975
- _context30.prev = 77;
3037
+ case 81:
3038
+ _context30.prev = 81;
2976
3039
  _context30.t4 = _context30["catch"](0);
2977
3040
  errorMessage = _context30.t4 instanceof Error ? _context30.t4.message : String(_context30.t4);
2978
3041
  console.error('[Checkout] 清理过期订单数据失败:', _context30.t4);
2979
3042
  this.logError('Expired orders cleanup failed', {
2980
3043
  error: errorMessage
2981
3044
  });
2982
- case 82:
3045
+ case 86:
2983
3046
  case "end":
2984
3047
  return _context30.stop();
2985
3048
  }
2986
- }, _callee30, this, [[0, 77], [17, 40, 43, 46], [21, 32], [49, 66, 69, 72], [53, 59]]);
3049
+ }, _callee30, this, [[0, 81], [20, 43, 46, 49], [24, 35], [52, 70, 73, 76], [56, 63]]);
2987
3050
  }));
2988
3051
  function cleanupExpiredOrdersAsync() {
2989
3052
  return _cleanupExpiredOrdersAsync.apply(this, arguments);
@@ -3381,19 +3444,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3381
3444
  }
3382
3445
  return _context36.abrupt("return");
3383
3446
  case 4:
3384
- _context36.next = 6;
3447
+ console.time('updateStateAmountToRemaining');
3448
+ // 🚀 性能优化:一次性批量获取所有需要的数据
3449
+ _context36.next = 7;
3385
3450
  return this.fetchOrderDataBatch();
3386
- case 6:
3451
+ case 7:
3387
3452
  _yield$this$fetchOrde3 = _context36.sent;
3388
3453
  paymentItems = _yield$this$fetchOrde3.paymentItems;
3389
3454
  _currentOrder3 = _yield$this$fetchOrde3.currentOrder;
3455
+ console.timeEnd('updateStateAmountToRemaining');
3390
3456
  if (_currentOrder3) {
3391
- _context36.next = 12;
3457
+ _context36.next = 14;
3392
3458
  break;
3393
3459
  }
3394
3460
  this.logWarning('updateStateAmountToRemaining: 未找到当前订单');
3395
3461
  return _context36.abrupt("return");
3396
- case 12:
3462
+ case 14:
3397
3463
  // 🚀 性能优化:一次性计算所有金额(纯计算,不查询数据库)
3398
3464
  paidAmount = this.calculatePaidAmountFromItems(paymentItems); // 缓存已支付金额,供其他方法使用
3399
3465
  this.calculationCache.paidAmount = paidAmount;
@@ -3429,19 +3495,20 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3429
3495
  currentBalanceDueAmount = this.store.balanceDueAmount; // 批量更新状态,减少操作次数
3430
3496
  hasStateChanged = false; // 如果需要更新定金状态
3431
3497
  if (!needUpdateDepositStatus) {
3432
- _context36.next = 26;
3498
+ _context36.next = 28;
3433
3499
  break;
3434
3500
  }
3435
3501
  this.store.currentOrder = _objectSpread(_objectSpread({}, this.store.currentOrder), {}, {
3436
3502
  is_deposit: 0
3437
3503
  });
3438
- _context36.next = 25;
3504
+ _context36.next = 27;
3439
3505
  return this.payment.updateOrderAsync(this.store.currentOrder.uuid, {
3440
3506
  is_deposit: 0
3441
3507
  });
3442
- case 25:
3508
+ case 27:
3443
3509
  hasStateChanged = true;
3444
- case 26:
3510
+ case 28:
3511
+ console.time('updateStateAmountToRemaining: remainingAmount');
3445
3512
  // 更新 stateAmount
3446
3513
  if (remainingAmount !== currentStateAmount) {
3447
3514
  this.store.stateAmount = remainingAmount;
@@ -3460,6 +3527,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3460
3527
  newAmount: remainingAmount
3461
3528
  });
3462
3529
  }
3530
+ console.timeEnd('updateStateAmountToRemaining: remainingAmount');
3531
+ console.time('updateStateAmountToRemaining: updateStateAmountToRemaining');
3463
3532
  // 更新 balanceDueAmount
3464
3533
  if (remainingAmount !== currentBalanceDueAmount) {
3465
3534
  this.store.balanceDueAmount = remainingAmount;
@@ -3479,6 +3548,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3479
3548
  newAmount: remainingAmount
3480
3549
  });
3481
3550
  }
3551
+ console.timeEnd('updateStateAmountToRemaining: updateStateAmountToRemaining');
3482
3552
  if (!hasStateChanged) {
3483
3553
  this.logInfo('状态无需更新,当前值已是最新:', {
3484
3554
  stateAmount: currentStateAmount,
@@ -3488,28 +3558,28 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3488
3558
 
3489
3559
  // 检查订单支付完成(复用已获取的数据)
3490
3560
  if (!checkOrder) {
3491
- _context36.next = 34;
3561
+ _context36.next = 40;
3492
3562
  break;
3493
3563
  }
3494
- _context36.next = 32;
3564
+ _context36.next = 38;
3495
3565
  return this.checkOrderPaymentCompletionOptimized(paymentItems, remainingAmount);
3496
- case 32:
3497
- _context36.next = 35;
3566
+ case 38:
3567
+ _context36.next = 41;
3498
3568
  break;
3499
- case 34:
3569
+ case 40:
3500
3570
  this.logInfo('外部传入无需 checkOrder,不执行订单支付完成检测和同步');
3501
- case 35:
3502
- _context36.next = 40;
3571
+ case 41:
3572
+ _context36.next = 46;
3503
3573
  break;
3504
- case 37:
3505
- _context36.prev = 37;
3574
+ case 43:
3575
+ _context36.prev = 43;
3506
3576
  _context36.t0 = _context36["catch"](1);
3507
3577
  this.logError('更新 stateAmount 为剩余金额失败:', _context36.t0);
3508
- case 40:
3578
+ case 46:
3509
3579
  case "end":
3510
3580
  return _context36.stop();
3511
3581
  }
3512
- }, _callee36, this, [[1, 37]]);
3582
+ }, _callee36, this, [[1, 43]]);
3513
3583
  }));
3514
3584
  function updateStateAmountToRemaining() {
3515
3585
  return _updateStateAmountToRemaining.apply(this, arguments);
@@ -4140,11 +4210,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4140
4210
  resolveInFlight,
4141
4211
  rejectInFlight,
4142
4212
  inFlightPromise,
4143
- _this$store$currentOr26,
4144
4213
  _this$store$currentOr27,
4214
+ _this$store$currentOr28,
4145
4215
  _this$store$currentCu2,
4146
4216
  _this$otherParams2,
4147
- _this$store$currentOr28,
4217
+ _this$store$currentOr29,
4148
4218
  _this$store$localOrde,
4149
4219
  _this$store$localOrde2,
4150
4220
  _checkoutResponse12,
@@ -4261,7 +4331,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4261
4331
  })
4262
4332
  });
4263
4333
  }); // 确定最终的定金金额:优先使用手动设置的值,否则从支付项中计算
4264
- manualDepositAmount = ((_this$store$currentOr26 = this.store.currentOrder) === null || _this$store$currentOr26 === void 0 ? void 0 : _this$store$currentOr26.deposit_amount) || '0.00'; // 优先级逻辑:手动设置的定金金额 > 从支付项计算的金额
4334
+ manualDepositAmount = ((_this$store$currentOr27 = this.store.currentOrder) === null || _this$store$currentOr27 === void 0 ? void 0 : _this$store$currentOr27.deposit_amount) || '0.00'; // 优先级逻辑:手动设置的定金金额 > 从支付项计算的金额
4265
4335
  manualDepositValue = new Decimal(manualDepositAmount);
4266
4336
  if (manualDepositValue.gt(0)) {
4267
4337
  // 如果手动设置了定金金额且大于0,使用手动设置的值
@@ -4321,7 +4391,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4321
4391
  }),
4322
4392
  manualDepositAmount: manualDepositAmount,
4323
4393
  finalDepositAmount: finalDepositAmount,
4324
- isDeposit: ((_this$store$currentOr27 = this.store.currentOrder) === null || _this$store$currentOr27 === void 0 ? void 0 : _this$store$currentOr27.is_deposit) || 0
4394
+ isDeposit: ((_this$store$currentOr28 = this.store.currentOrder) === null || _this$store$currentOr28 === void 0 ? void 0 : _this$store$currentOr28.is_deposit) || 0
4325
4395
  });
4326
4396
 
4327
4397
  // 计算订单状态,优先读取外面传递的,如果没有则根据订单支付数据来
@@ -4369,7 +4439,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4369
4439
  currency_symbol: this.otherParams.currency_symbol,
4370
4440
  currency_format: this.otherParams.currency_format,
4371
4441
  business_code: ((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.business_code) || undefined,
4372
- is_deposit: ((_this$store$currentOr28 = this.store.currentOrder) !== null && _this$store$currentOr28 !== void 0 && _this$store$currentOr28.is_deposit || Number(finalDepositAmount) > 0 ? 1 : 0) || 0,
4442
+ is_deposit: ((_this$store$currentOr29 = this.store.currentOrder) !== null && _this$store$currentOr29 !== void 0 && _this$store$currentOr29.is_deposit || Number(finalDepositAmount) > 0 ? 1 : 0) || 0,
4373
4443
  deposit_amount: finalDepositAmount,
4374
4444
  // 使用最终确定的定金金额(手动设置优先)
4375
4445
  product_tax_fee: this.store.localOrderData.tax_fee,
@@ -5012,7 +5082,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
5012
5082
  case 6:
5013
5083
  // 取消注册模块
5014
5084
  this.core.unregisterModule(this);
5015
- case 7:
5085
+ console.log('[Checkout] 已销毁');
5086
+ case 8:
5016
5087
  case "end":
5017
5088
  return _context46.stop();
5018
5089
  }
@@ -5039,6 +5110,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
5039
5110
  uuid: this.store.currentOrder.uuid,
5040
5111
  orderId: this.store.currentOrder.order_id
5041
5112
  } : null;
5113
+ console.log('[Checkout] 重置 store 状态,准备创建新订单', prevOrderInfo);
5114
+
5042
5115
  // 重置订单相关的 store 状态(保留 paymentMethods,因为支付方式数据变更不频繁)
5043
5116
  this.store.currentOrder = undefined;
5044
5117
  this.store.localOrderData = undefined;
@@ -5060,6 +5133,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
5060
5133
 
5061
5134
  // 注意:故意保留 this.store.paymentMethods,因为支付方式数据不易变更,保留在内存中提高性能
5062
5135
 
5136
+ console.log('[Checkout] Store 状态重置完成');
5137
+
5063
5138
  // 🚀 性能优化:异步触发订单清理事件(不阻塞主流程)
5064
5139
  // 使用 setTimeout 确保事件处理不会阻塞状态重置
5065
5140
  if (prevOrderInfo) {