@pisell/pisellos 0.0.235 → 0.0.236

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.
@@ -28,13 +28,13 @@ import { BaseModule } from "../../modules/BaseModule";
28
28
  import { OrderModule } from "../../modules/Order";
29
29
  import { PaymentModule } from "../../modules/Payment";
30
30
  import { CheckoutStatus, CheckoutStep, CheckoutHooks, CheckoutErrorType } from "./types";
31
- import { PaymentStatus, PaymentMethodType } from "../../modules/Payment/types";
31
+ import { PaymentStatus, PaymentHooks, PaymentMethodType } from "../../modules/Payment/types";
32
32
  import { validateCheckoutData, createCheckoutError, calculateProgress } from "./utils";
33
33
  export * from "./types";
34
34
 
35
35
  /**
36
36
  * 结账解决方案实现
37
- *
37
+ *
38
38
  * 整合订单处理和支付功能,提供完整的结账流程管理。
39
39
  * 支持多种支付方式,提供实时状态跟踪和错误处理。
40
40
  */
@@ -211,6 +211,47 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
211
211
  return _ref2.apply(this, arguments);
212
212
  };
213
213
  }());
214
+
215
+ // 监听支付方式加载完成事件
216
+ this.core.effects.on(PaymentHooks.OnPaymentMethodsLoaded, /*#__PURE__*/function () {
217
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(methods) {
218
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
219
+ while (1) switch (_context5.prev = _context5.next) {
220
+ case 0:
221
+ console.log('[Checkout] 收到支付方式加载完成事件:', methods.length);
222
+ _this2.store.paymentMethods = methods;
223
+ case 2:
224
+ case "end":
225
+ return _context5.stop();
226
+ }
227
+ }, _callee5);
228
+ }));
229
+ return function (_x7) {
230
+ return _ref3.apply(this, arguments);
231
+ };
232
+ }());
233
+
234
+ // 监听支付方式变更事件
235
+ this.core.effects.on(PaymentHooks.OnPaymentMethodsChanged, /*#__PURE__*/function () {
236
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(data) {
237
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
238
+ while (1) switch (_context6.prev = _context6.next) {
239
+ case 0:
240
+ console.log('[Checkout] 收到支付方式变更事件:', {
241
+ oldCount: data.oldMethods.length,
242
+ newCount: data.newMethods.length
243
+ });
244
+ _this2.store.paymentMethods = data.newMethods;
245
+ case 2:
246
+ case "end":
247
+ return _context6.stop();
248
+ }
249
+ }, _callee6);
250
+ }));
251
+ return function (_x8) {
252
+ return _ref4.apply(this, arguments);
253
+ };
254
+ }());
214
255
  }
215
256
 
216
257
  /**
@@ -219,21 +260,21 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
219
260
  }, {
220
261
  key: "initializeCheckoutAsync",
221
262
  value: (function () {
222
- var _initializeCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(params) {
263
+ var _initializeCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(params) {
223
264
  var validation;
224
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
225
- while (1) switch (_context5.prev = _context5.next) {
265
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
266
+ while (1) switch (_context7.prev = _context7.next) {
226
267
  case 0:
227
- _context5.prev = 0;
228
- _context5.next = 3;
268
+ _context7.prev = 0;
269
+ _context7.next = 3;
229
270
  return this.setStatus(CheckoutStatus.Initializing);
230
271
  case 3:
231
- _context5.next = 5;
272
+ _context7.next = 5;
232
273
  return this.validateCheckoutParams(params);
233
274
  case 5:
234
- validation = _context5.sent;
275
+ validation = _context7.sent;
235
276
  if (validation.valid) {
236
- _context5.next = 8;
277
+ _context7.next = 8;
237
278
  break;
238
279
  }
239
280
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u53C2\u6570\u9A8C\u8BC1\u5931\u8D25: ".concat(validation.errors.join(', ')));
@@ -242,29 +283,29 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
242
283
  this.store.cartItems = params.cartItems;
243
284
 
244
285
  // 设置为就绪状态
245
- _context5.next = 11;
286
+ _context7.next = 11;
246
287
  return this.setStatus(CheckoutStatus.Ready);
247
288
  case 11:
248
- _context5.next = 13;
289
+ _context7.next = 13;
249
290
  return this.setStep(CheckoutStep.OrderConfirmation);
250
291
  case 13:
251
292
  console.log('[Checkout] 结账流程初始化完成');
252
- _context5.next = 21;
293
+ _context7.next = 21;
253
294
  break;
254
295
  case 16:
255
- _context5.prev = 16;
256
- _context5.t0 = _context5["catch"](0);
257
- _context5.next = 20;
258
- return this.handleError(_context5.t0, CheckoutErrorType.UnknownError);
296
+ _context7.prev = 16;
297
+ _context7.t0 = _context7["catch"](0);
298
+ _context7.next = 20;
299
+ return this.handleError(_context7.t0, CheckoutErrorType.UnknownError);
259
300
  case 20:
260
- throw _context5.t0;
301
+ throw _context7.t0;
261
302
  case 21:
262
303
  case "end":
263
- return _context5.stop();
304
+ return _context7.stop();
264
305
  }
265
- }, _callee5, this, [[0, 16]]);
306
+ }, _callee7, this, [[0, 16]]);
266
307
  }));
267
- function initializeCheckoutAsync(_x7) {
308
+ function initializeCheckoutAsync(_x9) {
268
309
  return _initializeCheckoutAsync.apply(this, arguments);
269
310
  }
270
311
  return initializeCheckoutAsync;
@@ -294,18 +335,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
294
335
  }, {
295
336
  key: "initWalletData",
296
337
  value: function () {
297
- var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(params) {
338
+ var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
298
339
  var _this$store$currentOr2, _this$store$currentCu;
299
340
  var amountInfo, walletBusinessData;
300
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
301
- while (1) switch (_context6.prev = _context6.next) {
341
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
342
+ while (1) switch (_context8.prev = _context8.next) {
302
343
  case 0:
303
344
  amountInfo = (_this$store$currentOr2 = this.store.currentOrder) === null || _this$store$currentOr2 === void 0 || (_this$store$currentOr2 = _this$store$currentOr2.order_info) === null || _this$store$currentOr2 === void 0 ? void 0 : _this$store$currentOr2.amount_breakdown;
304
345
  if (amountInfo) {
305
- _context6.next = 3;
346
+ _context8.next = 3;
306
347
  break;
307
348
  }
308
- return _context6.abrupt("return");
349
+ return _context8.abrupt("return");
309
350
  case 3:
310
351
  // 准备钱包初始化的业务数据
311
352
  walletBusinessData = _objectSpread({
@@ -316,22 +357,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
316
357
  },
317
358
  products: this.getProductListByOrder()
318
359
  }, params);
319
- _context6.next = 6;
360
+ _context8.next = 6;
320
361
  return this.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
321
362
  case 6:
322
363
  case "end":
323
- return _context6.stop();
364
+ return _context8.stop();
324
365
  }
325
- }, _callee6, this);
366
+ }, _callee8, this);
326
367
  }));
327
- function initWalletData(_x8) {
368
+ function initWalletData(_x10) {
328
369
  return _initWalletData.apply(this, arguments);
329
370
  }
330
371
  return initWalletData;
331
372
  }()
332
373
  /**
333
374
  * 创建本地订单 (前端模拟下单流程)
334
- *
375
+ *
335
376
  * 此方法用于在前端模拟整个下单流程,创建一个本地的虚拟订单。
336
377
  * 用户在购物车点击下单时,会把购物车参数传递给此方法,
337
378
  * 方法会记录参数并创建本地虚拟订单,然后用 Payment 模块管理支付流程。
@@ -339,28 +380,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
339
380
  }, {
340
381
  key: "createLocalOrderAsync",
341
382
  value: (function () {
342
- var _createLocalOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(params) {
383
+ var _createLocalOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
343
384
  var _params$totalInfo, _params$totalInfo2, validation, localOrderId, amountInfo, customerInfo, paymentOrder;
344
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
345
- while (1) switch (_context7.prev = _context7.next) {
385
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
386
+ while (1) switch (_context9.prev = _context9.next) {
346
387
  case 0:
347
- _context7.prev = 0;
348
- _context7.next = 3;
349
- return this.setStatus(CheckoutStatus.CreatingOrder);
388
+ _context9.prev = 0;
389
+ _context9.next = 3;
390
+ return this.resetStoreStateAsync();
350
391
  case 3:
351
- _context7.next = 5;
352
- return this.validateLocalOrderData(params.orderData);
392
+ _context9.next = 5;
393
+ return this.setStatus(CheckoutStatus.CreatingOrder);
353
394
  case 5:
354
- validation = _context7.sent;
395
+ _context9.next = 7;
396
+ return this.validateLocalOrderData(params.orderData);
397
+ case 7:
398
+ validation = _context9.sent;
355
399
  if (validation.valid) {
356
- _context7.next = 8;
400
+ _context9.next = 10;
357
401
  break;
358
402
  }
359
403
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u8BA2\u5355\u6570\u636E\u9A8C\u8BC1\u5931\u8D25: ".concat(validation.errors.join(', ')));
360
- case 8:
404
+ case 10:
361
405
  // 生成本地虚拟订单ID (后续可以被真实订单ID替换)
362
406
  localOrderId = this.generateLocalOrderId(); // 从购物车小计数据中提取金额信息
363
- amountInfo = this.extractAmountFromCartSummary(params.cartSummary); // TODO: 外面传的是 pos ,但是现在 后端只有 shop 和 kiosk
407
+ amountInfo = this.extractAmountFromCartSummary(params.cartSummary); // TODO: 外面传的是 pos ,但是现在 后端只有 shop 和 kiosk
364
408
  params.orderData.platform = 'pos';
365
409
  // 补充 created_at 时间 (YYYY-MM-DD hh:mm:ss 格式)
366
410
  params.orderData.created_at = this.formatDateTime(new Date());
@@ -387,7 +431,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
387
431
  }
388
432
 
389
433
  // 创建支付订单对象
390
- _context7.next = 20;
434
+ _context9.next = 22;
391
435
  return this.payment.createPaymentOrderAsync({
392
436
  order_id: localOrderId,
393
437
  total_amount: amountInfo.totalAmount,
@@ -404,34 +448,34 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
404
448
  amount_breakdown: amountInfo
405
449
  }
406
450
  });
407
- case 20:
408
- paymentOrder = _context7.sent;
451
+ case 22:
452
+ paymentOrder = _context9.sent;
409
453
  this.store.currentOrder = paymentOrder;
410
- _context7.next = 24;
454
+ _context9.next = 26;
411
455
  return this.initWalletData();
412
- case 24:
413
- _context7.next = 26;
414
- return this.setStatus(CheckoutStatus.OrderCreated);
415
456
  case 26:
416
- _context7.next = 28;
417
- return this.setStep(CheckoutStep.PaymentMethod);
457
+ _context9.next = 28;
458
+ return this.setStatus(CheckoutStatus.OrderCreated);
418
459
  case 28:
460
+ _context9.next = 30;
461
+ return this.setStep(CheckoutStep.PaymentMethod);
462
+ case 30:
419
463
  if (!params.autoPayment) {
420
- _context7.next = 31;
464
+ _context9.next = 33;
421
465
  break;
422
466
  }
423
- _context7.next = 31;
467
+ _context9.next = 33;
424
468
  return this.setStep(CheckoutStep.PaymentProcessing);
425
- case 31:
426
- _context7.next = 33;
469
+ case 33:
470
+ _context9.next = 35;
427
471
  return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
428
472
  order: paymentOrder,
429
473
  timestamp: Date.now()
430
474
  });
431
- case 33:
432
- _context7.next = 35;
433
- return this.updateStateAmountToRemaining();
434
475
  case 35:
476
+ _context9.next = 37;
477
+ return this.updateStateAmountToRemaining();
478
+ case 37:
435
479
  console.log('[Checkout] 本地订单创建成功:', {
436
480
  localOrderId: localOrderId,
437
481
  uuid: paymentOrder.uuid,
@@ -440,41 +484,41 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
440
484
  taxAmount: amountInfo.taxAmount,
441
485
  stateAmount: this.store.stateAmount
442
486
  });
443
- return _context7.abrupt("return", paymentOrder);
444
- case 39:
445
- _context7.prev = 39;
446
- _context7.t0 = _context7["catch"](0);
447
- _context7.next = 43;
448
- return this.handleError(_context7.t0, CheckoutErrorType.OrderCreationFailed);
449
- case 43:
450
- _context7.next = 45;
487
+ return _context9.abrupt("return", paymentOrder);
488
+ case 41:
489
+ _context9.prev = 41;
490
+ _context9.t0 = _context9["catch"](0);
491
+ _context9.next = 45;
492
+ return this.handleError(_context9.t0, CheckoutErrorType.OrderCreationFailed);
493
+ case 45:
494
+ _context9.next = 47;
451
495
  return this.core.effects.emit(CheckoutHooks.OnOrderCreationFailed, {
452
496
  error: this.store.lastError,
453
497
  timestamp: Date.now()
454
498
  });
455
- case 45:
456
- throw _context7.t0;
457
- case 46:
499
+ case 47:
500
+ throw _context9.t0;
501
+ case 48:
458
502
  case "end":
459
- return _context7.stop();
503
+ return _context9.stop();
460
504
  }
461
- }, _callee7, this, [[0, 39]]);
505
+ }, _callee9, this, [[0, 41]]);
462
506
  }));
463
- function createLocalOrderAsync(_x9) {
507
+ function createLocalOrderAsync(_x11) {
464
508
  return _createLocalOrderAsync.apply(this, arguments);
465
509
  }
466
510
  return createLocalOrderAsync;
467
511
  }()
468
512
  /**
469
513
  * 手动下单 (根据虚拟订单生成实际订单)
470
- *
514
+ *
471
515
  * 使用当前存储的本地订单数据调用 Order 模块创建真实订单
472
516
  */
473
517
  )
474
518
  }, {
475
519
  key: "placeOrderAsync",
476
520
  value: (function () {
477
- var _placeOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
521
+ var _placeOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
478
522
  var params,
479
523
  _data,
480
524
  orderData,
@@ -482,26 +526,26 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
482
526
  realOrderId,
483
527
  updatedOrder,
484
528
  errorMessage,
485
- _args8 = arguments;
486
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
487
- while (1) switch (_context8.prev = _context8.next) {
529
+ _args10 = arguments;
530
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
531
+ while (1) switch (_context10.prev = _context10.next) {
488
532
  case 0:
489
- params = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {};
490
- _context8.prev = 1;
533
+ params = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : {};
534
+ _context10.prev = 1;
491
535
  if (this.store.localOrderData) {
492
- _context8.next = 4;
536
+ _context10.next = 4;
493
537
  break;
494
538
  }
495
539
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, '没有找到本地订单数据,请先调用 createLocalOrderAsync 创建虚拟订单');
496
540
  case 4:
497
541
  if (this.store.currentOrder) {
498
- _context8.next = 6;
542
+ _context10.next = 6;
499
543
  break;
500
544
  }
501
545
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, '没有找到当前订单,请先创建虚拟订单');
502
546
  case 6:
503
547
  console.log('[Checkout] 开始手动下单流程...');
504
- _context8.next = 9;
548
+ _context10.next = 9;
505
549
  return this.setStatus(CheckoutStatus.CreatingOrder);
506
550
  case 9:
507
551
  // 准备订单数据,使用 Order 模块期望的格式
@@ -510,18 +554,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
510
554
  type: this.store.localOrderData.type,
511
555
  platform: this.store.localOrderData.platform
512
556
  }; // 调用 Order 模块提交订单
513
- _context8.next = 12;
557
+ _context10.next = 12;
514
558
  return this.order.submitOrder({
515
559
  url: params.url,
516
560
  // 可选的自定义 URL
517
561
  query: orderData
518
562
  });
519
563
  case 12:
520
- orderResponse = _context8.sent;
564
+ orderResponse = _context10.sent;
521
565
  // 提取真实订单ID(假设返回格式包含 order_id)
522
566
  realOrderId = (orderResponse === null || orderResponse === void 0 || (_data = orderResponse.data) === null || _data === void 0 ? void 0 : _data.order_id) || (orderResponse === null || orderResponse === void 0 ? void 0 : orderResponse.order_id);
523
567
  if (realOrderId) {
524
- _context8.next = 16;
568
+ _context10.next = 16;
525
569
  break;
526
570
  }
527
571
  throw createCheckoutError(CheckoutErrorType.OrderCreationFailed, '订单创建成功但未返回订单ID');
@@ -530,15 +574,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
530
574
 
531
575
  // 如果设置了自动替换订单ID,则替换虚拟订单ID
532
576
  if (!(params.autoReplaceOrderId !== false)) {
533
- _context8.next = 23;
577
+ _context10.next = 23;
534
578
  break;
535
579
  }
536
580
  // 默认为 true
537
581
  console.log('[Checkout] 自动替换虚拟订单ID为真实订单ID...');
538
- _context8.next = 21;
582
+ _context10.next = 21;
539
583
  return this.replaceLocalOrderIdAsync(realOrderId);
540
584
  case 21:
541
- updatedOrder = _context8.sent;
585
+ updatedOrder = _context10.sent;
542
586
  if (updatedOrder) {
543
587
  console.log('[Checkout] 订单ID替换成功:', {
544
588
  oldId: this.store.currentOrder.order_id,
@@ -546,10 +590,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
546
590
  });
547
591
  }
548
592
  case 23:
549
- _context8.next = 25;
593
+ _context10.next = 25;
550
594
  return this.setStatus(CheckoutStatus.OrderCreated);
551
595
  case 25:
552
- _context8.next = 27;
596
+ _context10.next = 27;
553
597
  return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
554
598
  order: this.store.currentOrder,
555
599
  timestamp: Date.now()
@@ -558,33 +602,33 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
558
602
  // 标记订单已同步
559
603
  this.store.isOrderSynced = true;
560
604
  console.log('[Checkout] 手动下单流程完成');
561
- return _context8.abrupt("return", {
605
+ return _context10.abrupt("return", {
562
606
  success: true,
563
607
  orderId: realOrderId
564
608
  });
565
609
  case 32:
566
- _context8.prev = 32;
567
- _context8.t0 = _context8["catch"](1);
610
+ _context10.prev = 32;
611
+ _context10.t0 = _context10["catch"](1);
568
612
  // 处理 CheckoutError 对象
569
613
  errorMessage = '下单失败';
570
- if (_context8.t0 && _typeof(_context8.t0) === 'object' && 'message' in _context8.t0) {
571
- errorMessage = _context8.t0.message;
572
- } else if (_context8.t0 instanceof Error) {
573
- errorMessage = _context8.t0.message;
614
+ if (_context10.t0 && _typeof(_context10.t0) === 'object' && 'message' in _context10.t0) {
615
+ errorMessage = _context10.t0.message;
616
+ } else if (_context10.t0 instanceof Error) {
617
+ errorMessage = _context10.t0.message;
574
618
  }
575
619
  console.error('[Checkout] 手动下单失败:', errorMessage);
576
- _context8.next = 39;
577
- return this.handleError(_context8.t0, CheckoutErrorType.OrderCreationFailed);
620
+ _context10.next = 39;
621
+ return this.handleError(_context10.t0, CheckoutErrorType.OrderCreationFailed);
578
622
  case 39:
579
- return _context8.abrupt("return", {
623
+ return _context10.abrupt("return", {
580
624
  success: false,
581
625
  error: errorMessage
582
626
  });
583
627
  case 40:
584
628
  case "end":
585
- return _context8.stop();
629
+ return _context10.stop();
586
630
  }
587
- }, _callee8, this, [[1, 32]]);
631
+ }, _callee10, this, [[1, 32]]);
588
632
  }));
589
633
  function placeOrderAsync() {
590
634
  return _placeOrderAsync.apply(this, arguments);
@@ -598,13 +642,13 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
598
642
  }, {
599
643
  key: "createOrderAsync",
600
644
  value: (function () {
601
- var _createOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
645
+ var _createOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(params) {
602
646
  var _data2, checkResult, orderResponse, paymentOrder;
603
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
604
- while (1) switch (_context9.prev = _context9.next) {
647
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
648
+ while (1) switch (_context11.prev = _context11.next) {
605
649
  case 0:
606
- _context9.prev = 0;
607
- _context9.next = 3;
650
+ _context11.prev = 0;
651
+ _context11.next = 3;
608
652
  return this.setStatus(CheckoutStatus.CreatingOrder);
609
653
  case 3:
610
654
  // 验证购物车数据
@@ -613,12 +657,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
613
657
  type: 'account' // 默认使用 account 类型
614
658
  });
615
659
  if (checkResult) {
616
- _context9.next = 6;
660
+ _context11.next = 6;
617
661
  break;
618
662
  }
619
663
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, '购物车数据验证失败,请检查商品信息');
620
664
  case 6:
621
- _context9.next = 8;
665
+ _context11.next = 8;
622
666
  return this.order.submitOrder({
623
667
  query: {
624
668
  cartItems: params.cartItems,
@@ -627,23 +671,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
627
671
  }
628
672
  });
629
673
  case 8:
630
- orderResponse = _context9.sent;
631
- _context9.next = 11;
674
+ orderResponse = _context11.sent;
675
+ _context11.next = 11;
632
676
  return this.payment.createPaymentOrderAsync({
633
677
  order_id: (orderResponse === null || orderResponse === void 0 || (_data2 = orderResponse.data) === null || _data2 === void 0 ? void 0 : _data2.order_id) || "order_".concat(Date.now()),
634
678
  total_amount: this.calculateTotalAmount(params.cartItems),
635
679
  order_info: orderResponse === null || orderResponse === void 0 ? void 0 : orderResponse.data
636
680
  });
637
681
  case 11:
638
- paymentOrder = _context9.sent;
682
+ paymentOrder = _context11.sent;
639
683
  this.store.currentOrder = paymentOrder;
640
- _context9.next = 15;
684
+ _context11.next = 15;
641
685
  return this.setStatus(CheckoutStatus.OrderCreated);
642
686
  case 15:
643
- _context9.next = 17;
687
+ _context11.next = 17;
644
688
  return this.setStep(CheckoutStep.PaymentMethod);
645
689
  case 17:
646
- _context9.next = 19;
690
+ _context11.next = 19;
647
691
  return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
648
692
  order: paymentOrder,
649
693
  timestamp: Date.now()
@@ -653,31 +697,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
653
697
  this.store.isOrderSynced = true;
654
698
 
655
699
  // 自动设置 stateAmount 为剩余未支付金额
656
- _context9.next = 22;
700
+ _context11.next = 22;
657
701
  return this.updateStateAmountToRemaining();
658
702
  case 22:
659
703
  console.log('[Checkout] 订单创建成功:', paymentOrder.id);
660
- return _context9.abrupt("return", paymentOrder);
704
+ return _context11.abrupt("return", paymentOrder);
661
705
  case 26:
662
- _context9.prev = 26;
663
- _context9.t0 = _context9["catch"](0);
664
- _context9.next = 30;
665
- return this.handleError(_context9.t0, CheckoutErrorType.OrderCreationFailed);
706
+ _context11.prev = 26;
707
+ _context11.t0 = _context11["catch"](0);
708
+ _context11.next = 30;
709
+ return this.handleError(_context11.t0, CheckoutErrorType.OrderCreationFailed);
666
710
  case 30:
667
- _context9.next = 32;
711
+ _context11.next = 32;
668
712
  return this.core.effects.emit(CheckoutHooks.OnOrderCreationFailed, {
669
713
  error: this.store.lastError,
670
714
  timestamp: Date.now()
671
715
  });
672
716
  case 32:
673
- throw _context9.t0;
717
+ throw _context11.t0;
674
718
  case 33:
675
719
  case "end":
676
- return _context9.stop();
720
+ return _context11.stop();
677
721
  }
678
- }, _callee9, this, [[0, 26]]);
722
+ }, _callee11, this, [[0, 26]]);
679
723
  }));
680
- function createOrderAsync(_x10) {
724
+ function createOrderAsync(_x12) {
681
725
  return _createOrderAsync.apply(this, arguments);
682
726
  }
683
727
  return createOrderAsync;
@@ -689,22 +733,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
689
733
  }, {
690
734
  key: "processPaymentAsync",
691
735
  value: (function () {
692
- var _processPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(params) {
736
+ var _processPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(params) {
693
737
  var paymentMethod, paymentItem, result;
694
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
695
- while (1) switch (_context10.prev = _context10.next) {
738
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
739
+ while (1) switch (_context12.prev = _context12.next) {
696
740
  case 0:
697
- _context10.prev = 0;
741
+ _context12.prev = 0;
698
742
  if (this.store.currentOrder) {
699
- _context10.next = 3;
743
+ _context12.next = 3;
700
744
  break;
701
745
  }
702
746
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, '未找到当前订单,请先创建订单');
703
747
  case 3:
704
- _context10.next = 5;
748
+ _context12.next = 5;
705
749
  return this.setStatus(CheckoutStatus.ProcessingPayment);
706
750
  case 5:
707
- _context10.next = 7;
751
+ _context12.next = 7;
708
752
  return this.setStep(CheckoutStep.PaymentProcessing);
709
753
  case 7:
710
754
  // 查找支付方式
@@ -712,7 +756,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
712
756
  return method.code === params.paymentMethodCode;
713
757
  });
714
758
  if (paymentMethod) {
715
- _context10.next = 10;
759
+ _context12.next = 10;
716
760
  break;
717
761
  }
718
762
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u672A\u627E\u5230\u652F\u4ED8\u65B9\u5F0F: ".concat(params.paymentMethodCode));
@@ -725,14 +769,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
725
769
  amount: String(params.amount),
726
770
  id: paymentMethod.id
727
771
  }; // 添加支付项到订单
728
- _context10.next = 13;
772
+ _context12.next = 13;
729
773
  return this.payment.addPaymentItemAsync(this.store.currentOrder.uuid, paymentItem);
730
774
  case 13:
731
- _context10.next = 15;
775
+ _context12.next = 15;
732
776
  return this.payment.submitPayAsync(this.store.currentOrder.uuid);
733
777
  case 15:
734
- result = _context10.sent;
735
- _context10.next = 18;
778
+ result = _context12.sent;
779
+ _context12.next = 18;
736
780
  return this.core.effects.emit(CheckoutHooks.OnPaymentStarted, {
737
781
  orderUuid: this.store.currentOrder.uuid,
738
782
  paymentMethodCode: params.paymentMethodCode,
@@ -741,42 +785,42 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
741
785
  });
742
786
  case 18:
743
787
  if (!(result.status === 'success')) {
744
- _context10.next = 27;
788
+ _context12.next = 27;
745
789
  break;
746
790
  }
747
- _context10.next = 21;
791
+ _context12.next = 21;
748
792
  return this.setStatus(CheckoutStatus.PaymentCompleted);
749
793
  case 21:
750
- _context10.next = 23;
794
+ _context12.next = 23;
751
795
  return this.updateStateAmountToRemaining();
752
796
  case 23:
753
- _context10.next = 25;
797
+ _context12.next = 25;
754
798
  return this.handlePaymentSuccess({
755
799
  orderUuid: this.store.currentOrder.uuid,
756
800
  timestamp: Date.now()
757
801
  });
758
802
  case 25:
759
- _context10.next = 28;
803
+ _context12.next = 28;
760
804
  break;
761
805
  case 27:
762
806
  throw createCheckoutError(CheckoutErrorType.PaymentFailed, '支付处理失败,请重试');
763
807
  case 28:
764
- _context10.next = 35;
808
+ _context12.next = 35;
765
809
  break;
766
810
  case 30:
767
- _context10.prev = 30;
768
- _context10.t0 = _context10["catch"](0);
769
- _context10.next = 34;
770
- return this.handleError(_context10.t0, CheckoutErrorType.PaymentFailed);
811
+ _context12.prev = 30;
812
+ _context12.t0 = _context12["catch"](0);
813
+ _context12.next = 34;
814
+ return this.handleError(_context12.t0, CheckoutErrorType.PaymentFailed);
771
815
  case 34:
772
- throw _context10.t0;
816
+ throw _context12.t0;
773
817
  case 35:
774
818
  case "end":
775
- return _context10.stop();
819
+ return _context12.stop();
776
820
  }
777
- }, _callee10, this, [[0, 30]]);
821
+ }, _callee12, this, [[0, 30]]);
778
822
  }));
779
- function processPaymentAsync(_x11) {
823
+ function processPaymentAsync(_x13) {
780
824
  return _processPaymentAsync.apply(this, arguments);
781
825
  }
782
826
  return processPaymentAsync;
@@ -788,61 +832,66 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
788
832
  }, {
789
833
  key: "completeCheckoutAsync",
790
834
  value: (function () {
791
- var _completeCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
835
+ var _completeCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
792
836
  var order;
793
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
794
- while (1) switch (_context11.prev = _context11.next) {
837
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
838
+ while (1) switch (_context13.prev = _context13.next) {
795
839
  case 0:
796
- _context11.prev = 0;
840
+ _context13.prev = 0;
797
841
  if (this.store.currentOrder) {
798
- _context11.next = 3;
842
+ _context13.next = 3;
799
843
  break;
800
844
  }
801
845
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, '未找到当前订单');
802
846
  case 3:
803
- _context11.next = 5;
847
+ _context13.next = 5;
804
848
  return this.payment.getPaymentOrderByUuidAsync(this.store.currentOrder.uuid);
805
849
  case 5:
806
- order = _context11.sent;
850
+ order = _context13.sent;
807
851
  if (!(!order || order.payment_status !== PaymentStatus.Finished)) {
808
- _context11.next = 8;
852
+ _context13.next = 8;
809
853
  break;
810
854
  }
811
855
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, '订单支付未完成,无法完成结账');
812
856
  case 8:
813
857
  // 清理钱包模块的所有缓存数据
814
858
  this.payment.wallet.clearAllCache();
815
- _context11.next = 11;
859
+ _context13.next = 11;
816
860
  return this.setStatus(CheckoutStatus.Completed);
817
861
  case 11:
818
- _context11.next = 13;
862
+ _context13.next = 13;
819
863
  return this.setStep(CheckoutStep.Complete);
820
864
  case 13:
821
- _context11.next = 15;
865
+ _context13.next = 15;
822
866
  return this.core.effects.emit(CheckoutHooks.OnCheckoutCompleted, {
823
867
  orderId: order.id,
824
868
  timestamp: Date.now()
825
869
  });
826
870
  case 15:
827
871
  console.log('[Checkout] 结账流程完成:', order.id);
828
- return _context11.abrupt("return", {
872
+
873
+ // 🔧 新增:自动重置 store 状态
874
+ _context13.next = 18;
875
+ return this.resetStoreStateAsync();
876
+ case 18:
877
+ return _context13.abrupt("return", {
829
878
  success: true,
830
879
  orderId: String(order.id)
831
880
  });
832
- case 19:
833
- _context11.prev = 19;
834
- _context11.t0 = _context11["catch"](0);
835
- _context11.next = 23;
836
- return this.handleError(_context11.t0, CheckoutErrorType.UnknownError);
837
- case 23:
838
- return _context11.abrupt("return", {
881
+ case 21:
882
+ _context13.prev = 21;
883
+ _context13.t0 = _context13["catch"](0);
884
+ _context13.next = 25;
885
+ return this.handleError(_context13.t0, CheckoutErrorType.UnknownError);
886
+ case 25:
887
+ return _context13.abrupt("return", {
839
888
  success: false
840
889
  });
841
- case 24:
890
+ case 26:
842
891
  case "end":
843
- return _context11.stop();
892
+ return _context13.stop();
844
893
  }
845
- }, _callee11, this, [[0, 19]]);
894
+ }, _callee13, this, [[0, 21]]);
846
895
  }));
847
896
  function completeCheckoutAsync() {
848
897
  return _completeCheckoutAsync.apply(this, arguments);
@@ -856,16 +905,16 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
856
905
  }, {
857
906
  key: "cancelCheckoutAsync",
858
907
  value: (function () {
859
- var _cancelCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
860
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
861
- while (1) switch (_context12.prev = _context12.next) {
908
+ var _cancelCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
909
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
910
+ while (1) switch (_context14.prev = _context14.next) {
862
911
  case 0:
863
- _context12.prev = 0;
912
+ _context14.prev = 0;
864
913
  if (!this.store.currentOrder) {
865
- _context12.next = 5;
914
+ _context14.next = 5;
866
915
  break;
867
916
  }
868
- _context12.next = 4;
917
+ _context14.next = 4;
869
918
  return this.payment.deletePaymentOrderAsync(this.store.currentOrder.uuid);
870
919
  case 4:
871
920
  this.store.currentOrder = undefined;
@@ -878,28 +927,28 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
878
927
  this.store.stateAmount = '0.00';
879
928
  this.store.isOrderSynced = false;
880
929
  this.store.currentCustomer = undefined;
881
- _context12.next = 14;
930
+ _context14.next = 14;
882
931
  return this.setStatus(CheckoutStatus.Cancelled);
883
932
  case 14:
884
- _context12.next = 16;
933
+ _context14.next = 16;
885
934
  return this.core.effects.emit(CheckoutHooks.OnCheckoutCancelled, {
886
935
  timestamp: Date.now()
887
936
  });
888
937
  case 16:
889
938
  console.log('[Checkout] 结账流程已取消');
890
- _context12.next = 24;
939
+ _context14.next = 24;
891
940
  break;
892
941
  case 19:
893
- _context12.prev = 19;
894
- _context12.t0 = _context12["catch"](0);
895
- console.error('[Checkout] 取消结账失败:', _context12.t0);
896
- _context12.next = 24;
897
- return this.handleError(_context12.t0, CheckoutErrorType.UnknownError);
942
+ _context14.prev = 19;
943
+ _context14.t0 = _context14["catch"](0);
944
+ console.error('[Checkout] 取消结账失败:', _context14.t0);
945
+ _context14.next = 24;
946
+ return this.handleError(_context14.t0, CheckoutErrorType.UnknownError);
898
947
  case 24:
899
948
  case "end":
900
- return _context12.stop();
949
+ return _context14.stop();
901
950
  }
902
- }, _callee12, this, [[0, 19]]);
951
+ }, _callee14, this, [[0, 19]]);
903
952
  }));
904
953
  function cancelCheckoutAsync() {
905
954
  return _cancelCheckoutAsync.apply(this, arguments);
@@ -928,22 +977,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
928
977
  }, {
929
978
  key: "getCheckoutSummaryAsync",
930
979
  value: (function () {
931
- var _getCheckoutSummaryAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
980
+ var _getCheckoutSummaryAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
932
981
  var _this$store$currentOr3, _this$store$currentOr4;
933
982
  var totalAmount, paidAmount, remainingAmount;
934
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
935
- while (1) switch (_context13.prev = _context13.next) {
983
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
984
+ while (1) switch (_context15.prev = _context15.next) {
936
985
  case 0:
937
986
  totalAmount = ((_this$store$currentOr3 = this.store.currentOrder) === null || _this$store$currentOr3 === void 0 ? void 0 : _this$store$currentOr3.total_amount) || '0.00';
938
- _context13.next = 3;
987
+ _context15.next = 3;
939
988
  return this.calculatePaidAmountAsync();
940
989
  case 3:
941
- paidAmount = _context13.sent;
942
- _context13.next = 6;
990
+ paidAmount = _context15.sent;
991
+ _context15.next = 6;
943
992
  return this.calculateRemainingAmountAsync();
944
993
  case 6:
945
- remainingAmount = _context13.sent;
946
- return _context13.abrupt("return", {
994
+ remainingAmount = _context15.sent;
995
+ return _context15.abrupt("return", {
947
996
  order: this.store.currentOrder,
948
997
  totalAmount: totalAmount,
949
998
  paidAmount: paidAmount,
@@ -953,9 +1002,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
953
1002
  });
954
1003
  case 8:
955
1004
  case "end":
956
- return _context13.stop();
1005
+ return _context15.stop();
957
1006
  }
958
- }, _callee13, this);
1007
+ }, _callee15, this);
959
1008
  }));
960
1009
  function getCheckoutSummaryAsync() {
961
1010
  return _getCheckoutSummaryAsync.apply(this, arguments);
@@ -969,24 +1018,19 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
969
1018
  }, {
970
1019
  key: "getAvailablePaymentMethodsAsync",
971
1020
  value: (function () {
972
- var _getAvailablePaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
973
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
974
- while (1) switch (_context14.prev = _context14.next) {
1021
+ var _getAvailablePaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1022
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1023
+ while (1) switch (_context16.prev = _context16.next) {
975
1024
  case 0:
976
- if (!(this.store.paymentMethods.length === 0)) {
977
- _context14.next = 4;
978
- break;
979
- }
980
- console.log('[Checkout] 支付方式缓存为空,重新加载...');
981
- _context14.next = 4;
982
- return this.preloadPaymentMethods();
983
- case 4:
984
- return _context14.abrupt("return", this.store.paymentMethods);
985
- case 5:
1025
+ _context16.next = 2;
1026
+ return this.getPaymentMethodsAsync();
1027
+ case 2:
1028
+ return _context16.abrupt("return", _context16.sent);
1029
+ case 3:
986
1030
  case "end":
987
- return _context14.stop();
1031
+ return _context16.stop();
988
1032
  }
989
- }, _callee14, this);
1033
+ }, _callee16, this);
990
1034
  }));
991
1035
  function getAvailablePaymentMethodsAsync() {
992
1036
  return _getAvailablePaymentMethodsAsync.apply(this, arguments);
@@ -995,27 +1039,38 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
995
1039
  }()
996
1040
  /**
997
1041
  * 刷新支付方式缓存
998
- *
1042
+ *
999
1043
  * 强制重新从服务器获取支付方式列表,更新本地缓存
1000
1044
  */
1001
1045
  )
1002
1046
  }, {
1003
1047
  key: "refreshPaymentMethodsAsync",
1004
1048
  value: (function () {
1005
- var _refreshPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
1006
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1007
- while (1) switch (_context15.prev = _context15.next) {
1049
+ var _refreshPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1050
+ var methods;
1051
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1052
+ while (1) switch (_context17.prev = _context17.next) {
1008
1053
  case 0:
1009
1054
  console.log('[Checkout] 强制刷新支付方式缓存...');
1010
- _context15.next = 3;
1011
- return this.preloadPaymentMethods();
1012
- case 3:
1013
- return _context15.abrupt("return", this.store.paymentMethods);
1055
+ _context17.prev = 1;
1056
+ _context17.next = 4;
1057
+ return this.payment.getPayMethodListAsync();
1014
1058
  case 4:
1059
+ methods = _context17.sent;
1060
+ // 更新本地缓存
1061
+ this.store.paymentMethods = methods;
1062
+ console.log("[Checkout] \u5F3A\u5236\u5237\u65B0\u5B8C\u6210\uFF0C\u83B7\u53D6\u5230 ".concat(methods.length, " \u79CD\u652F\u4ED8\u65B9\u5F0F"));
1063
+ return _context17.abrupt("return", methods);
1064
+ case 10:
1065
+ _context17.prev = 10;
1066
+ _context17.t0 = _context17["catch"](1);
1067
+ console.error('[Checkout] 强制刷新支付方式失败:', _context17.t0);
1068
+ return _context17.abrupt("return", this.store.paymentMethods);
1069
+ case 14:
1015
1070
  case "end":
1016
- return _context15.stop();
1071
+ return _context17.stop();
1017
1072
  }
1018
- }, _callee15, this);
1073
+ }, _callee17, this, [[1, 10]]);
1019
1074
  }));
1020
1075
  function refreshPaymentMethodsAsync() {
1021
1076
  return _refreshPaymentMethodsAsync.apply(this, arguments);
@@ -1035,7 +1090,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1035
1090
 
1036
1091
  /**
1037
1092
  * 获取当前订单基础信息
1038
- *
1093
+ *
1039
1094
  * 返回当前订单的基础信息,包括订单状态、金额、支付状态等
1040
1095
  */
1041
1096
  }, {
@@ -1090,25 +1145,25 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1090
1145
 
1091
1146
  /**
1092
1147
  * 获取当前订单的支付项
1093
- *
1148
+ *
1094
1149
  * 返回当前订单的所有支付项,包括活跃和已撤销的支付项
1095
1150
  */
1096
1151
  }, {
1097
1152
  key: "getCurrentOrderPaymentItemsAsync",
1098
1153
  value: (function () {
1099
- var _getCurrentOrderPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1154
+ var _getCurrentOrderPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1100
1155
  var _currentOrder2, paymentItems;
1101
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1102
- while (1) switch (_context16.prev = _context16.next) {
1156
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1157
+ while (1) switch (_context18.prev = _context18.next) {
1103
1158
  case 0:
1104
- _context16.prev = 0;
1159
+ _context18.prev = 0;
1105
1160
  _currentOrder2 = this.store.currentOrder;
1106
1161
  if (_currentOrder2) {
1107
- _context16.next = 5;
1162
+ _context18.next = 5;
1108
1163
  break;
1109
1164
  }
1110
1165
  console.log('[Checkout] 当前没有活跃订单,无法获取支付项');
1111
- return _context16.abrupt("return", []);
1166
+ return _context18.abrupt("return", []);
1112
1167
  case 5:
1113
1168
  console.log('[Checkout] 获取当前订单支付项:', {
1114
1169
  orderUuid: _currentOrder2.uuid,
@@ -1116,10 +1171,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1116
1171
  });
1117
1172
 
1118
1173
  // 调用Payment模块获取支付项
1119
- _context16.next = 8;
1174
+ _context18.next = 8;
1120
1175
  return this.payment.getPaymentItemsAsync(_currentOrder2.uuid);
1121
1176
  case 8:
1122
- paymentItems = _context16.sent;
1177
+ paymentItems = _context18.sent;
1123
1178
  console.log('[Checkout] 成功获取支付项:', {
1124
1179
  orderUuid: _currentOrder2.uuid,
1125
1180
  paymentItemCount: paymentItems.length,
@@ -1144,17 +1199,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1144
1199
  };
1145
1200
  })
1146
1201
  });
1147
- return _context16.abrupt("return", paymentItems);
1202
+ return _context18.abrupt("return", paymentItems);
1148
1203
  case 13:
1149
- _context16.prev = 13;
1150
- _context16.t0 = _context16["catch"](0);
1151
- console.error('[Checkout] 获取当前订单支付项失败:', _context16.t0);
1152
- return _context16.abrupt("return", []);
1204
+ _context18.prev = 13;
1205
+ _context18.t0 = _context18["catch"](0);
1206
+ console.error('[Checkout] 获取当前订单支付项失败:', _context18.t0);
1207
+ return _context18.abrupt("return", []);
1153
1208
  case 17:
1154
1209
  case "end":
1155
- return _context16.stop();
1210
+ return _context18.stop();
1156
1211
  }
1157
- }, _callee16, this, [[0, 13]]);
1212
+ }, _callee18, this, [[0, 13]]);
1158
1213
  }));
1159
1214
  function getCurrentOrderPaymentItemsAsync() {
1160
1215
  return _getCurrentOrderPaymentItemsAsync.apply(this, arguments);
@@ -1168,10 +1223,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1168
1223
  }, {
1169
1224
  key: "validateCheckoutAsync",
1170
1225
  value: (function () {
1171
- var _validateCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1226
+ var _validateCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
1172
1227
  var errors;
1173
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1174
- while (1) switch (_context17.prev = _context17.next) {
1228
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1229
+ while (1) switch (_context19.prev = _context19.next) {
1175
1230
  case 0:
1176
1231
  errors = []; // 验证购物车
1177
1232
  if (!this.store.cartItems || this.store.cartItems.length === 0) {
@@ -1187,15 +1242,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1187
1242
  if (this.store.status === CheckoutStatus.Error) {
1188
1243
  errors.push('结账流程存在错误');
1189
1244
  }
1190
- return _context17.abrupt("return", {
1245
+ return _context19.abrupt("return", {
1191
1246
  valid: errors.length === 0,
1192
1247
  errors: errors
1193
1248
  });
1194
1249
  case 5:
1195
1250
  case "end":
1196
- return _context17.stop();
1251
+ return _context19.stop();
1197
1252
  }
1198
- }, _callee17, this);
1253
+ }, _callee19, this);
1199
1254
  }));
1200
1255
  function validateCheckoutAsync() {
1201
1256
  return _validateCheckoutAsync.apply(this, arguments);
@@ -1209,44 +1264,44 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1209
1264
  }, {
1210
1265
  key: "retryFailedOperationAsync",
1211
1266
  value: (function () {
1212
- var _retryFailedOperationAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
1213
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1214
- while (1) switch (_context18.prev = _context18.next) {
1267
+ var _retryFailedOperationAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
1268
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1269
+ while (1) switch (_context20.prev = _context20.next) {
1215
1270
  case 0:
1216
- _context18.prev = 0;
1271
+ _context20.prev = 0;
1217
1272
  if (!(this.store.status === CheckoutStatus.Error && this.store.lastError)) {
1218
- _context18.next = 10;
1273
+ _context20.next = 10;
1219
1274
  break;
1220
1275
  }
1221
- _context18.t0 = this.store.lastError.type;
1222
- _context18.next = _context18.t0 === CheckoutErrorType.OrderCreationFailed ? 5 : 9;
1276
+ _context20.t0 = this.store.lastError.type;
1277
+ _context20.next = _context20.t0 === CheckoutErrorType.OrderCreationFailed ? 5 : 9;
1223
1278
  break;
1224
1279
  case 5:
1225
1280
  if (!(this.store.cartItems.length > 0)) {
1226
- _context18.next = 8;
1281
+ _context20.next = 8;
1227
1282
  break;
1228
1283
  }
1229
- _context18.next = 8;
1284
+ _context20.next = 8;
1230
1285
  return this.createOrderAsync({
1231
1286
  cartItems: this.store.cartItems
1232
1287
  });
1233
1288
  case 8:
1234
- return _context18.abrupt("break", 10);
1289
+ return _context20.abrupt("break", 10);
1235
1290
  case 9:
1236
1291
  console.warn('[Checkout] 无法重试此类型的错误:', this.store.lastError.type);
1237
1292
  case 10:
1238
- _context18.next = 16;
1293
+ _context20.next = 16;
1239
1294
  break;
1240
1295
  case 12:
1241
- _context18.prev = 12;
1242
- _context18.t1 = _context18["catch"](0);
1243
- _context18.next = 16;
1244
- return this.handleError(_context18.t1, CheckoutErrorType.UnknownError);
1296
+ _context20.prev = 12;
1297
+ _context20.t1 = _context20["catch"](0);
1298
+ _context20.next = 16;
1299
+ return this.handleError(_context20.t1, CheckoutErrorType.UnknownError);
1245
1300
  case 16:
1246
1301
  case "end":
1247
- return _context18.stop();
1302
+ return _context20.stop();
1248
1303
  }
1249
- }, _callee18, this, [[0, 12]]);
1304
+ }, _callee20, this, [[0, 12]]);
1250
1305
  }));
1251
1306
  function retryFailedOperationAsync() {
1252
1307
  return _retryFailedOperationAsync.apply(this, arguments);
@@ -1289,41 +1344,41 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1289
1344
 
1290
1345
  /**
1291
1346
  * 替换本地订单ID为真实订单ID
1292
- *
1347
+ *
1293
1348
  * 当后端订单创建完成后,调用此方法将本地虚拟订单ID替换为真实订单ID
1294
- *
1349
+ *
1295
1350
  * @param newOrderId 后端返回的真实订单ID
1296
1351
  * @returns 更新后的订单对象,如果当前没有订单则返回null
1297
1352
  */
1298
1353
  }, {
1299
1354
  key: "replaceLocalOrderIdAsync",
1300
1355
  value: (function () {
1301
- var _replaceLocalOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(newOrderId) {
1356
+ var _replaceLocalOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(newOrderId) {
1302
1357
  var updatedOrder;
1303
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1304
- while (1) switch (_context19.prev = _context19.next) {
1358
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1359
+ while (1) switch (_context21.prev = _context21.next) {
1305
1360
  case 0:
1306
- _context19.prev = 0;
1361
+ _context21.prev = 0;
1307
1362
  if (this.store.currentOrder) {
1308
- _context19.next = 4;
1363
+ _context21.next = 4;
1309
1364
  break;
1310
1365
  }
1311
1366
  console.warn('[Checkout] 没有当前订单,无法替换订单ID');
1312
- return _context19.abrupt("return", null);
1367
+ return _context21.abrupt("return", null);
1313
1368
  case 4:
1314
- _context19.next = 6;
1369
+ _context21.next = 6;
1315
1370
  return this.payment.replaceOrderIdByUuidAsync(this.store.currentOrder.uuid, newOrderId);
1316
1371
  case 6:
1317
- updatedOrder = _context19.sent;
1372
+ updatedOrder = _context21.sent;
1318
1373
  if (!updatedOrder) {
1319
- _context19.next = 15;
1374
+ _context21.next = 15;
1320
1375
  break;
1321
1376
  }
1322
1377
  // 更新当前订单引用
1323
1378
  this.store.currentOrder = updatedOrder;
1324
1379
 
1325
1380
  // 触发订单更新事件
1326
- _context19.next = 11;
1381
+ _context21.next = 11;
1327
1382
  return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
1328
1383
  order: updatedOrder,
1329
1384
  timestamp: Date.now()
@@ -1338,50 +1393,50 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1338
1393
  this.store.isOrderSynced = true;
1339
1394
 
1340
1395
  // 订单ID替换后更新 stateAmount
1341
- _context19.next = 15;
1396
+ _context21.next = 15;
1342
1397
  return this.updateStateAmountToRemaining();
1343
1398
  case 15:
1344
- return _context19.abrupt("return", updatedOrder);
1399
+ return _context21.abrupt("return", updatedOrder);
1345
1400
  case 18:
1346
- _context19.prev = 18;
1347
- _context19.t0 = _context19["catch"](0);
1348
- console.error('[Checkout] 替换订单ID失败:', _context19.t0);
1349
- _context19.next = 23;
1350
- return this.handleError(_context19.t0, CheckoutErrorType.UnknownError);
1401
+ _context21.prev = 18;
1402
+ _context21.t0 = _context21["catch"](0);
1403
+ console.error('[Checkout] 替换订单ID失败:', _context21.t0);
1404
+ _context21.next = 23;
1405
+ return this.handleError(_context21.t0, CheckoutErrorType.UnknownError);
1351
1406
  case 23:
1352
- return _context19.abrupt("return", null);
1407
+ return _context21.abrupt("return", null);
1353
1408
  case 24:
1354
1409
  case "end":
1355
- return _context19.stop();
1410
+ return _context21.stop();
1356
1411
  }
1357
- }, _callee19, this, [[0, 18]]);
1412
+ }, _callee21, this, [[0, 18]]);
1358
1413
  }));
1359
- function replaceLocalOrderIdAsync(_x12) {
1414
+ function replaceLocalOrderIdAsync(_x14) {
1360
1415
  return _replaceLocalOrderIdAsync.apply(this, arguments);
1361
1416
  }
1362
1417
  return replaceLocalOrderIdAsync;
1363
1418
  }()
1364
1419
  /**
1365
1420
  * 设置自定义支付金额
1366
- *
1421
+ *
1367
1422
  * 允许UI自定义本次支付的金额,通常用于部分支付或调整支付金额场景
1368
- *
1423
+ *
1369
1424
  * @param amount 自定义支付金额,必须是有效的数字字符串
1370
1425
  */
1371
1426
  )
1372
1427
  }, {
1373
1428
  key: "setStateAmountAsync",
1374
1429
  value: (function () {
1375
- var _setStateAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(amount) {
1430
+ var _setStateAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(amount) {
1376
1431
  var numAmount, oldAmount, formattedAmount, errorMessage;
1377
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1378
- while (1) switch (_context20.prev = _context20.next) {
1432
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1433
+ while (1) switch (_context22.prev = _context22.next) {
1379
1434
  case 0:
1380
- _context20.prev = 0;
1435
+ _context22.prev = 0;
1381
1436
  // 验证金额格式
1382
1437
  numAmount = parseFloat(amount);
1383
1438
  if (!(isNaN(numAmount) || numAmount < 0)) {
1384
- _context20.next = 4;
1439
+ _context22.next = 4;
1385
1440
  break;
1386
1441
  }
1387
1442
  throw new Error("\u65E0\u6548\u7684\u652F\u4ED8\u91D1\u989D: ".concat(amount));
@@ -1389,16 +1444,16 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1389
1444
  oldAmount = this.store.stateAmount;
1390
1445
  formattedAmount = numAmount.toFixed(2); // 如果金额没有变化,直接返回
1391
1446
  if (!(oldAmount === formattedAmount)) {
1392
- _context20.next = 8;
1447
+ _context22.next = 8;
1393
1448
  break;
1394
1449
  }
1395
- return _context20.abrupt("return");
1450
+ return _context22.abrupt("return");
1396
1451
  case 8:
1397
1452
  // 更新状态
1398
1453
  this.store.stateAmount = formattedAmount;
1399
1454
 
1400
1455
  // 触发金额变更事件
1401
- _context20.next = 11;
1456
+ _context22.next = 11;
1402
1457
  return this.core.effects.emit(CheckoutHooks.OnStateAmountChanged, {
1403
1458
  oldAmount: oldAmount,
1404
1459
  newAmount: formattedAmount,
@@ -1409,31 +1464,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1409
1464
  oldAmount: oldAmount,
1410
1465
  newAmount: formattedAmount
1411
1466
  });
1412
- _context20.next = 21;
1467
+ _context22.next = 21;
1413
1468
  break;
1414
1469
  case 14:
1415
- _context20.prev = 14;
1416
- _context20.t0 = _context20["catch"](0);
1417
- errorMessage = _context20.t0 instanceof Error ? _context20.t0.message : '设置支付金额失败';
1470
+ _context22.prev = 14;
1471
+ _context22.t0 = _context22["catch"](0);
1472
+ errorMessage = _context22.t0 instanceof Error ? _context22.t0.message : '设置支付金额失败';
1418
1473
  console.error('[Checkout] 设置自定义支付金额失败:', errorMessage);
1419
- _context20.next = 20;
1474
+ _context22.next = 20;
1420
1475
  return this.handleError(new Error(errorMessage), CheckoutErrorType.ValidationFailed);
1421
1476
  case 20:
1422
- throw _context20.t0;
1477
+ throw _context22.t0;
1423
1478
  case 21:
1424
1479
  case "end":
1425
- return _context20.stop();
1480
+ return _context22.stop();
1426
1481
  }
1427
- }, _callee20, this, [[0, 14]]);
1482
+ }, _callee22, this, [[0, 14]]);
1428
1483
  }));
1429
- function setStateAmountAsync(_x13) {
1484
+ function setStateAmountAsync(_x15) {
1430
1485
  return _setStateAmountAsync.apply(this, arguments);
1431
1486
  }
1432
1487
  return setStateAmountAsync;
1433
1488
  }()
1434
1489
  /**
1435
1490
  * 获取当前自定义支付金额
1436
- *
1491
+ *
1437
1492
  * @returns 当前设置的自定义支付金额
1438
1493
  */
1439
1494
  )
@@ -1445,23 +1500,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1445
1500
 
1446
1501
  /**
1447
1502
  * 刷新 stateAmount 为当前剩余未支付金额
1448
- *
1503
+ *
1449
1504
  * UI 可以调用此方法来主动刷新支付金额状态
1450
1505
  */
1451
1506
  }, {
1452
1507
  key: "refreshStateAmountAsync",
1453
1508
  value: (function () {
1454
- var _refreshStateAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
1455
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1456
- while (1) switch (_context21.prev = _context21.next) {
1509
+ var _refreshStateAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
1510
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1511
+ while (1) switch (_context23.prev = _context23.next) {
1457
1512
  case 0:
1458
- _context21.next = 2;
1513
+ _context23.next = 2;
1459
1514
  return this.updateStateAmountToRemaining();
1460
1515
  case 2:
1461
1516
  case "end":
1462
- return _context21.stop();
1517
+ return _context23.stop();
1463
1518
  }
1464
- }, _callee21, this);
1519
+ }, _callee23, this);
1465
1520
  }));
1466
1521
  function refreshStateAmountAsync() {
1467
1522
  return _refreshStateAmountAsync.apply(this, arguments);
@@ -1470,9 +1525,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1470
1525
  }()
1471
1526
  /**
1472
1527
  * 获取购物车小计数据
1473
- *
1528
+ *
1474
1529
  * 返回当前结账流程中的购物车小计项数据,包含各种费用明细
1475
- *
1530
+ *
1476
1531
  * @returns 购物车小计数据数组,如果没有则返回 null
1477
1532
  */
1478
1533
  )
@@ -1498,9 +1553,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1498
1553
 
1499
1554
  /**
1500
1555
  * 获取提取的金额详细信息
1501
- *
1556
+ *
1502
1557
  * 从当前的购物车小计数据中提取结构化的金额信息
1503
- *
1558
+ *
1504
1559
  * @returns 提取的金额信息对象,如果没有小计数据则返回 null
1505
1560
  */
1506
1561
  }, {
@@ -1517,27 +1572,48 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1517
1572
 
1518
1573
  /**
1519
1574
  * 获取支付方式列表
1520
- *
1521
- * 直接调用 Payment 模块的 getPayMethodListAsync 方法
1522
- *
1575
+ *
1576
+ * 优先使用 store 中的缓存数据,避免重复接口调用。
1577
+ * 如果 store 中没有数据,则调用 Payment 模块的方法获取。
1578
+ *
1523
1579
  * @returns 支付方式列表
1524
1580
  */
1525
1581
  }, {
1526
1582
  key: "getPaymentMethodsAsync",
1527
1583
  value: (function () {
1528
- var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
1529
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1530
- while (1) switch (_context22.prev = _context22.next) {
1584
+ var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
1585
+ var methods;
1586
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1587
+ while (1) switch (_context24.prev = _context24.next) {
1531
1588
  case 0:
1532
- _context22.next = 2;
1533
- return this.payment.getPayMethodListAsync();
1534
- case 2:
1535
- return _context22.abrupt("return", _context22.sent);
1589
+ if (!(this.store.paymentMethods && this.store.paymentMethods.length > 0)) {
1590
+ _context24.next = 3;
1591
+ break;
1592
+ }
1593
+ console.log("[Checkout] \u4F7F\u7528\u7F13\u5B58\u7684\u652F\u4ED8\u65B9\u5F0F\u6570\u636E\uFF0C\u5171 ".concat(this.store.paymentMethods.length, " \u79CD"));
1594
+ return _context24.abrupt("return", this.store.paymentMethods);
1536
1595
  case 3:
1596
+ // 如果缓存为空,调用 Payment 模块获取
1597
+ console.log('[Checkout] store 中无缓存,从 Payment 模块获取支付方式...');
1598
+ _context24.prev = 4;
1599
+ _context24.next = 7;
1600
+ return this.payment.getPayMethodListAsync();
1601
+ case 7:
1602
+ methods = _context24.sent;
1603
+ // 更新缓存
1604
+ this.store.paymentMethods = methods;
1605
+ console.log("[Checkout] \u4ECE Payment \u6A21\u5757\u83B7\u53D6\u5230 ".concat(methods.length, " \u79CD\u652F\u4ED8\u65B9\u5F0F\uFF0C\u5DF2\u66F4\u65B0\u7F13\u5B58"));
1606
+ return _context24.abrupt("return", methods);
1607
+ case 13:
1608
+ _context24.prev = 13;
1609
+ _context24.t0 = _context24["catch"](4);
1610
+ console.error('[Checkout] 获取支付方式失败:', _context24.t0);
1611
+ return _context24.abrupt("return", []);
1612
+ case 17:
1537
1613
  case "end":
1538
- return _context22.stop();
1614
+ return _context24.stop();
1539
1615
  }
1540
- }, _callee22, this);
1616
+ }, _callee24, this, [[4, 13]]);
1541
1617
  }));
1542
1618
  function getPaymentMethodsAsync() {
1543
1619
  return _getPaymentMethodsAsync.apply(this, arguments);
@@ -1546,9 +1622,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1546
1622
  }()
1547
1623
  /**
1548
1624
  * 为当前订单添加支付项
1549
- *
1625
+ *
1550
1626
  * 向当前活跃订单添加一个支付项,支付项包含支付方式信息和金额
1551
- *
1627
+ *
1552
1628
  * @param paymentItem 支付项数据
1553
1629
  * @throws 当前没有活跃订单时抛出错误
1554
1630
  */
@@ -1556,14 +1632,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1556
1632
  }, {
1557
1633
  key: "addPaymentItemAsync",
1558
1634
  value: (function () {
1559
- var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(paymentItem) {
1635
+ var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(paymentItem) {
1560
1636
  var currentOrderId, isCurrentOrderReal;
1561
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1562
- while (1) switch (_context23.prev = _context23.next) {
1637
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1638
+ while (1) switch (_context25.prev = _context25.next) {
1563
1639
  case 0:
1564
- _context23.prev = 0;
1640
+ _context25.prev = 0;
1565
1641
  if (this.store.currentOrder) {
1566
- _context23.next = 3;
1642
+ _context25.next = 3;
1567
1643
  break;
1568
1644
  }
1569
1645
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, '未找到当前订单,无法添加支付项');
@@ -1580,7 +1656,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1580
1656
  });
1581
1657
 
1582
1658
  // 添加支付项到订单
1583
- _context23.next = 6;
1659
+ _context25.next = 6;
1584
1660
  return this.payment.addPaymentItemAsync(this.store.currentOrder.uuid, paymentItem);
1585
1661
  case 6:
1586
1662
  console.log('[Checkout] 支付项添加成功');
@@ -1642,10 +1718,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1642
1718
  // }
1643
1719
 
1644
1720
  // 支付项添加后,更新 stateAmount 为剩余未支付金额
1645
- _context23.next = 12;
1721
+ _context25.next = 12;
1646
1722
  return this.updateStateAmountToRemaining();
1647
1723
  case 12:
1648
- _context23.next = 14;
1724
+ _context25.next = 14;
1649
1725
  return this.core.effects.emit(CheckoutHooks.OnPaymentStarted, {
1650
1726
  orderUuid: this.store.currentOrder.uuid,
1651
1727
  paymentMethodCode: paymentItem.code,
@@ -1653,32 +1729,32 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1653
1729
  timestamp: Date.now()
1654
1730
  });
1655
1731
  case 14:
1656
- _context23.next = 22;
1732
+ _context25.next = 22;
1657
1733
  break;
1658
1734
  case 16:
1659
- _context23.prev = 16;
1660
- _context23.t0 = _context23["catch"](0);
1661
- console.error('[Checkout] 添加支付项失败:', _context23.t0);
1662
- _context23.next = 21;
1663
- return this.handleError(_context23.t0, CheckoutErrorType.PaymentFailed);
1735
+ _context25.prev = 16;
1736
+ _context25.t0 = _context25["catch"](0);
1737
+ console.error('[Checkout] 添加支付项失败:', _context25.t0);
1738
+ _context25.next = 21;
1739
+ return this.handleError(_context25.t0, CheckoutErrorType.PaymentFailed);
1664
1740
  case 21:
1665
- throw _context23.t0;
1741
+ throw _context25.t0;
1666
1742
  case 22:
1667
1743
  case "end":
1668
- return _context23.stop();
1744
+ return _context25.stop();
1669
1745
  }
1670
- }, _callee23, this, [[0, 16]]);
1746
+ }, _callee25, this, [[0, 16]]);
1671
1747
  }));
1672
- function addPaymentItemAsync(_x14) {
1748
+ function addPaymentItemAsync(_x16) {
1673
1749
  return _addPaymentItemAsync.apply(this, arguments);
1674
1750
  }
1675
1751
  return addPaymentItemAsync;
1676
1752
  }()
1677
1753
  /**
1678
1754
  * 删除当前订单的支付项
1679
- *
1755
+ *
1680
1756
  * 从当前活跃订单中删除指定的支付项,支付项将被标记为已撤销状态
1681
- *
1757
+ *
1682
1758
  * @param paymentUuid 要删除的支付项UUID
1683
1759
  * @throws 当前没有活跃订单时抛出错误
1684
1760
  * @throws 支付项不存在时抛出错误
@@ -1687,14 +1763,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1687
1763
  }, {
1688
1764
  key: "deletePaymentItemAsync",
1689
1765
  value: (function () {
1690
- var _deletePaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(paymentUuid) {
1766
+ var _deletePaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(paymentUuid) {
1691
1767
  var currentPayments, paymentItem, currentOrderId, isCurrentOrderReal, updatedOrder;
1692
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1693
- while (1) switch (_context24.prev = _context24.next) {
1768
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1769
+ while (1) switch (_context26.prev = _context26.next) {
1694
1770
  case 0:
1695
- _context24.prev = 0;
1771
+ _context26.prev = 0;
1696
1772
  if (this.store.currentOrder) {
1697
- _context24.next = 3;
1773
+ _context26.next = 3;
1698
1774
  break;
1699
1775
  }
1700
1776
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, '当前没有活跃订单,无法删除支付项');
@@ -1705,16 +1781,16 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1705
1781
  });
1706
1782
 
1707
1783
  // 从 Payment 模块验证支付项是否存在
1708
- _context24.next = 6;
1784
+ _context26.next = 6;
1709
1785
  return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid, true // 包括已撤销的支付项,因为我们需要验证是否存在
1710
1786
  );
1711
1787
  case 6:
1712
- currentPayments = _context24.sent;
1788
+ currentPayments = _context26.sent;
1713
1789
  paymentItem = currentPayments.find(function (p) {
1714
1790
  return p.uuid === paymentUuid;
1715
1791
  });
1716
1792
  if (paymentItem) {
1717
- _context24.next = 10;
1793
+ _context26.next = 10;
1718
1794
  break;
1719
1795
  }
1720
1796
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u652F\u4ED8\u9879\u4E0D\u5B58\u5728: ".concat(paymentUuid));
@@ -1727,7 +1803,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1727
1803
  });
1728
1804
 
1729
1805
  // 调用 Payment 模块删除支付项
1730
- _context24.next = 13;
1806
+ _context26.next = 13;
1731
1807
  return this.payment.deletePaymentAsync(this.store.currentOrder.uuid, paymentUuid);
1732
1808
  case 13:
1733
1809
  console.log('[Checkout] Payment模块删除完成');
@@ -1735,10 +1811,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1735
1811
  // 重新从Payment模块获取最新的订单数据,确保支付项同步
1736
1812
  currentOrderId = this.store.currentOrder.order_id; // 保存当前的订单ID
1737
1813
  isCurrentOrderReal = currentOrderId && !this.isVirtualOrderId(currentOrderId);
1738
- _context24.next = 18;
1814
+ _context26.next = 18;
1739
1815
  return this.payment.getPaymentOrderByUuidAsync(this.store.currentOrder.uuid);
1740
1816
  case 18:
1741
- updatedOrder = _context24.sent;
1817
+ updatedOrder = _context26.sent;
1742
1818
  if (updatedOrder) {
1743
1819
  // 如果当前订单ID是真实ID,但获取到的订单ID是虚拟ID,需要保护真实ID
1744
1820
  if (isCurrentOrderReal && this.isVirtualOrderId(updatedOrder.order_id)) {
@@ -1753,10 +1829,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1753
1829
  }
1754
1830
 
1755
1831
  // 更新 stateAmount 为剩余未支付金额
1756
- _context24.next = 22;
1832
+ _context26.next = 22;
1757
1833
  return this.updateStateAmountToRemaining();
1758
1834
  case 22:
1759
- _context24.next = 24;
1835
+ _context26.next = 24;
1760
1836
  return this.core.effects.emit(CheckoutHooks.OnPaymentStarted, {
1761
1837
  orderUuid: this.store.currentOrder.uuid,
1762
1838
  paymentMethodCode: paymentItem.code,
@@ -1766,33 +1842,33 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1766
1842
  });
1767
1843
  case 24:
1768
1844
  console.log('[Checkout] 支付项删除成功');
1769
- _context24.next = 33;
1845
+ _context26.next = 33;
1770
1846
  break;
1771
1847
  case 27:
1772
- _context24.prev = 27;
1773
- _context24.t0 = _context24["catch"](0);
1774
- console.error('[Checkout] 删除支付项失败:', _context24.t0);
1775
- _context24.next = 32;
1776
- return this.handleError(_context24.t0, CheckoutErrorType.PaymentFailed);
1848
+ _context26.prev = 27;
1849
+ _context26.t0 = _context26["catch"](0);
1850
+ console.error('[Checkout] 删除支付项失败:', _context26.t0);
1851
+ _context26.next = 32;
1852
+ return this.handleError(_context26.t0, CheckoutErrorType.PaymentFailed);
1777
1853
  case 32:
1778
- throw _context24.t0;
1854
+ throw _context26.t0;
1779
1855
  case 33:
1780
1856
  case "end":
1781
- return _context24.stop();
1857
+ return _context26.stop();
1782
1858
  }
1783
- }, _callee24, this, [[0, 27]]);
1859
+ }, _callee26, this, [[0, 27]]);
1784
1860
  }));
1785
- function deletePaymentItemAsync(_x15) {
1861
+ function deletePaymentItemAsync(_x17) {
1786
1862
  return _deletePaymentItemAsync.apply(this, arguments);
1787
1863
  }
1788
1864
  return deletePaymentItemAsync;
1789
1865
  }()
1790
1866
  /**
1791
1867
  * 批量更新当前订单的代金券支付项(覆盖更新)
1792
- *
1868
+ *
1793
1869
  * 删除所有现有的代金券支付项,然后添加新的代金券支付项。
1794
1870
  * 这是一个覆盖式更新操作,确保代金券支付项的一致性。
1795
- *
1871
+ *
1796
1872
  * @param voucherPaymentItems 新的代金券支付项列表,每个都必须包含 voucher_id
1797
1873
  * @throws 当前没有活跃订单时抛出错误
1798
1874
  * @throws 支付项缺少 voucher_id 时抛出错误
@@ -1801,14 +1877,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1801
1877
  }, {
1802
1878
  key: "updateVoucherPaymentItemsAsync",
1803
1879
  value: (function () {
1804
- var _updateVoucherPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(voucherPaymentItems) {
1880
+ var _updateVoucherPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(voucherPaymentItems) {
1805
1881
  var _iterator, _step, item, currentOrderId, isCurrentOrderReal, updatedOrder, voucherItems;
1806
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1807
- while (1) switch (_context25.prev = _context25.next) {
1882
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
1883
+ while (1) switch (_context27.prev = _context27.next) {
1808
1884
  case 0:
1809
- _context25.prev = 0;
1885
+ _context27.prev = 0;
1810
1886
  if (this.store.currentOrder) {
1811
- _context25.next = 3;
1887
+ _context27.next = 3;
1812
1888
  break;
1813
1889
  }
1814
1890
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, '当前没有活跃订单,无法更新代金券支付项');
@@ -1821,35 +1897,35 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1821
1897
 
1822
1898
  // 验证所有支付项都包含 voucher_id
1823
1899
  _iterator = _createForOfIteratorHelper(voucherPaymentItems);
1824
- _context25.prev = 5;
1900
+ _context27.prev = 5;
1825
1901
  _iterator.s();
1826
1902
  case 7:
1827
1903
  if ((_step = _iterator.n()).done) {
1828
- _context25.next = 13;
1904
+ _context27.next = 13;
1829
1905
  break;
1830
1906
  }
1831
1907
  item = _step.value;
1832
1908
  if (item.voucher_id) {
1833
- _context25.next = 11;
1909
+ _context27.next = 11;
1834
1910
  break;
1835
1911
  }
1836
1912
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u4EE3\u91D1\u5238\u652F\u4ED8\u9879\u7F3A\u5C11 voucher_id: ".concat(JSON.stringify(item)));
1837
1913
  case 11:
1838
- _context25.next = 7;
1914
+ _context27.next = 7;
1839
1915
  break;
1840
1916
  case 13:
1841
- _context25.next = 18;
1917
+ _context27.next = 18;
1842
1918
  break;
1843
1919
  case 15:
1844
- _context25.prev = 15;
1845
- _context25.t0 = _context25["catch"](5);
1846
- _iterator.e(_context25.t0);
1920
+ _context27.prev = 15;
1921
+ _context27.t0 = _context27["catch"](5);
1922
+ _iterator.e(_context27.t0);
1847
1923
  case 18:
1848
- _context25.prev = 18;
1924
+ _context27.prev = 18;
1849
1925
  _iterator.f();
1850
- return _context25.finish(18);
1926
+ return _context27.finish(18);
1851
1927
  case 21:
1852
- _context25.next = 23;
1928
+ _context27.next = 23;
1853
1929
  return this.payment.updateVoucherPaymentItemsAsync(this.store.currentOrder.uuid, voucherPaymentItems);
1854
1930
  case 23:
1855
1931
  console.log('[Checkout] Payment模块批量更新完成');
@@ -1857,10 +1933,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1857
1933
  // 重新从Payment模块获取最新的订单数据,确保支付项同步
1858
1934
  currentOrderId = this.store.currentOrder.order_id; // 保存当前的订单ID
1859
1935
  isCurrentOrderReal = currentOrderId && !this.isVirtualOrderId(currentOrderId);
1860
- _context25.next = 28;
1936
+ _context27.next = 28;
1861
1937
  return this.payment.getPaymentOrderByUuidAsync(this.store.currentOrder.uuid);
1862
1938
  case 28:
1863
- updatedOrder = _context25.sent;
1939
+ updatedOrder = _context27.sent;
1864
1940
  if (updatedOrder) {
1865
1941
  // 如果当前订单ID是真实ID,但获取到的订单ID是虚拟ID,需要保护真实ID
1866
1942
  if (isCurrentOrderReal && this.isVirtualOrderId(updatedOrder.order_id)) {
@@ -1891,10 +1967,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1891
1967
  }
1892
1968
 
1893
1969
  // 更新 stateAmount 为剩余未支付金额
1894
- _context25.next = 32;
1970
+ _context27.next = 32;
1895
1971
  return this.updateStateAmountToRemaining();
1896
1972
  case 32:
1897
- _context25.next = 34;
1973
+ _context27.next = 34;
1898
1974
  return this.core.effects.emit(CheckoutHooks.OnPaymentStarted, {
1899
1975
  orderUuid: this.store.currentOrder.uuid,
1900
1976
  paymentMethodCode: 'VOUCHER_BATCH',
@@ -1905,32 +1981,32 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1905
1981
  });
1906
1982
  case 34:
1907
1983
  console.log('[Checkout] 代金券支付项批量更新成功');
1908
- _context25.next = 43;
1984
+ _context27.next = 43;
1909
1985
  break;
1910
1986
  case 37:
1911
- _context25.prev = 37;
1912
- _context25.t1 = _context25["catch"](0);
1913
- console.error('[Checkout] 批量更新代金券支付项失败:', _context25.t1);
1914
- _context25.next = 42;
1915
- return this.handleError(_context25.t1, CheckoutErrorType.PaymentFailed);
1987
+ _context27.prev = 37;
1988
+ _context27.t1 = _context27["catch"](0);
1989
+ console.error('[Checkout] 批量更新代金券支付项失败:', _context27.t1);
1990
+ _context27.next = 42;
1991
+ return this.handleError(_context27.t1, CheckoutErrorType.PaymentFailed);
1916
1992
  case 42:
1917
- throw _context25.t1;
1993
+ throw _context27.t1;
1918
1994
  case 43:
1919
1995
  case "end":
1920
- return _context25.stop();
1996
+ return _context27.stop();
1921
1997
  }
1922
- }, _callee25, this, [[0, 37], [5, 15, 18, 21]]);
1998
+ }, _callee27, this, [[0, 37], [5, 15, 18, 21]]);
1923
1999
  }));
1924
- function updateVoucherPaymentItemsAsync(_x16) {
2000
+ function updateVoucherPaymentItemsAsync(_x18) {
1925
2001
  return _updateVoucherPaymentItemsAsync.apply(this, arguments);
1926
2002
  }
1927
2003
  return updateVoucherPaymentItemsAsync;
1928
2004
  }()
1929
2005
  /**
1930
2006
  * 修改当前订单的定金状态
1931
- *
2007
+ *
1932
2008
  * 更新当前订单的 is_deposit 字段,用于标识订单是否为定金订单
1933
- *
2009
+ *
1934
2010
  * @param isDeposit 定金状态 (1: 定金订单, 0: 全款订单)
1935
2011
  * @throws 当前没有活跃订单时抛出错误
1936
2012
  */
@@ -1938,20 +2014,20 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1938
2014
  }, {
1939
2015
  key: "updateOrderDepositStatusAsync",
1940
2016
  value: (function () {
1941
- var _updateOrderDepositStatusAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(isDeposit) {
2017
+ var _updateOrderDepositStatusAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(isDeposit) {
1942
2018
  var newDepositValue, oldDepositValue, updateParams;
1943
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1944
- while (1) switch (_context26.prev = _context26.next) {
2019
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2020
+ while (1) switch (_context28.prev = _context28.next) {
1945
2021
  case 0:
1946
- _context26.prev = 0;
2022
+ _context28.prev = 0;
1947
2023
  if (!(isDeposit !== 0 && isDeposit !== 1)) {
1948
- _context26.next = 3;
2024
+ _context28.next = 3;
1949
2025
  break;
1950
2026
  }
1951
2027
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, 'isDeposit 参数只能是 0(全款订单)或 1(定金订单)');
1952
2028
  case 3:
1953
2029
  if (this.store.currentOrder) {
1954
- _context26.next = 5;
2030
+ _context28.next = 5;
1955
2031
  break;
1956
2032
  }
1957
2033
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, '未找到当前订单,无法修改定金状态');
@@ -1959,11 +2035,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1959
2035
  newDepositValue = isDeposit;
1960
2036
  oldDepositValue = this.store.currentOrder.is_deposit; // 如果状态没有变化,直接返回
1961
2037
  if (!(oldDepositValue === newDepositValue)) {
1962
- _context26.next = 10;
2038
+ _context28.next = 10;
1963
2039
  break;
1964
2040
  }
1965
2041
  console.log('[Checkout] 定金状态无变化,跳过更新');
1966
- return _context26.abrupt("return");
2042
+ return _context28.abrupt("return");
1967
2043
  case 10:
1968
2044
  console.log('[Checkout] 更新订单定金状态:', {
1969
2045
  orderUuid: this.store.currentOrder.uuid,
@@ -1982,7 +2058,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1982
2058
  }
1983
2059
 
1984
2060
  // 调用 Payment 模块更新订单
1985
- _context26.next = 15;
2061
+ _context28.next = 15;
1986
2062
  return this.payment.updateOrderAsync(this.store.currentOrder.uuid, updateParams);
1987
2063
  case 15:
1988
2064
  // 更新本地缓存的订单对象
@@ -1994,7 +2070,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
1994
2070
  }
1995
2071
 
1996
2072
  // 触发订单更新事件
1997
- _context26.next = 19;
2073
+ _context28.next = 19;
1998
2074
  return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
1999
2075
  order: this.store.currentOrder,
2000
2076
  timestamp: Date.now()
@@ -2004,32 +2080,32 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2004
2080
  isDeposit: newDepositValue,
2005
2081
  depositAmount: this.store.currentOrder.deposit_amount
2006
2082
  });
2007
- _context26.next = 28;
2083
+ _context28.next = 28;
2008
2084
  break;
2009
2085
  case 22:
2010
- _context26.prev = 22;
2011
- _context26.t0 = _context26["catch"](0);
2012
- console.error('[Checkout] 更新订单定金状态失败:', _context26.t0);
2013
- _context26.next = 27;
2014
- return this.handleError(_context26.t0, CheckoutErrorType.ValidationFailed);
2086
+ _context28.prev = 22;
2087
+ _context28.t0 = _context28["catch"](0);
2088
+ console.error('[Checkout] 更新订单定金状态失败:', _context28.t0);
2089
+ _context28.next = 27;
2090
+ return this.handleError(_context28.t0, CheckoutErrorType.ValidationFailed);
2015
2091
  case 27:
2016
- throw _context26.t0;
2092
+ throw _context28.t0;
2017
2093
  case 28:
2018
2094
  case "end":
2019
- return _context26.stop();
2095
+ return _context28.stop();
2020
2096
  }
2021
- }, _callee26, this, [[0, 22]]);
2097
+ }, _callee28, this, [[0, 22]]);
2022
2098
  }));
2023
- function updateOrderDepositStatusAsync(_x17) {
2099
+ function updateOrderDepositStatusAsync(_x19) {
2024
2100
  return _updateOrderDepositStatusAsync.apply(this, arguments);
2025
2101
  }
2026
2102
  return updateOrderDepositStatusAsync;
2027
2103
  }()
2028
2104
  /**
2029
2105
  * 更新当前订单的客户信息
2030
- *
2106
+ *
2031
2107
  * 更新当前订单关联的客户信息,用于标识订单的所属客户
2032
- *
2108
+ *
2033
2109
  * @param customer 客户信息 (customer_id 和/或 customer_name)
2034
2110
  * @throws 当前没有活跃订单时抛出错误
2035
2111
  */
@@ -2037,13 +2113,13 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2037
2113
  }, {
2038
2114
  key: "updateOrderCustomerAsync",
2039
2115
  value: (function () {
2040
- var _updateOrderCustomerAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(customer) {
2041
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2042
- while (1) switch (_context27.prev = _context27.next) {
2116
+ var _updateOrderCustomerAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(customer) {
2117
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2118
+ while (1) switch (_context29.prev = _context29.next) {
2043
2119
  case 0:
2044
- _context27.prev = 0;
2120
+ _context29.prev = 0;
2045
2121
  if (this.store.currentOrder) {
2046
- _context27.next = 3;
2122
+ _context29.next = 3;
2047
2123
  break;
2048
2124
  }
2049
2125
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, '未找到当前订单,无法更新客户信息');
@@ -2066,30 +2142,30 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2066
2142
  this.store.localOrderData.customer_name = customer.customer_name;
2067
2143
  }
2068
2144
  console.log('[Checkout] 订单客户信息更新成功:', this.store.currentCustomer);
2069
- _context27.next = 15;
2145
+ _context29.next = 15;
2070
2146
  break;
2071
2147
  case 9:
2072
- _context27.prev = 9;
2073
- _context27.t0 = _context27["catch"](0);
2074
- console.error('[Checkout] 更新订单客户信息失败:', _context27.t0);
2075
- _context27.next = 14;
2076
- return this.handleError(_context27.t0, CheckoutErrorType.ValidationFailed);
2148
+ _context29.prev = 9;
2149
+ _context29.t0 = _context29["catch"](0);
2150
+ console.error('[Checkout] 更新订单客户信息失败:', _context29.t0);
2151
+ _context29.next = 14;
2152
+ return this.handleError(_context29.t0, CheckoutErrorType.ValidationFailed);
2077
2153
  case 14:
2078
- throw _context27.t0;
2154
+ throw _context29.t0;
2079
2155
  case 15:
2080
2156
  case "end":
2081
- return _context27.stop();
2157
+ return _context29.stop();
2082
2158
  }
2083
- }, _callee27, this, [[0, 9]]);
2159
+ }, _callee29, this, [[0, 9]]);
2084
2160
  }));
2085
- function updateOrderCustomerAsync(_x18) {
2161
+ function updateOrderCustomerAsync(_x20) {
2086
2162
  return _updateOrderCustomerAsync.apply(this, arguments);
2087
2163
  }
2088
2164
  return updateOrderCustomerAsync;
2089
2165
  }()
2090
2166
  /**
2091
2167
  * 获取当前订单的客户信息
2092
- *
2168
+ *
2093
2169
  * @returns 当前客户信息,如果没有则返回 null
2094
2170
  */
2095
2171
  )
@@ -2101,41 +2177,41 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2101
2177
 
2102
2178
  /**
2103
2179
  * 检查订单是否需要手动同步(异步版本)
2104
- *
2180
+ *
2105
2181
  * 返回订单是否为纯代金券支付且待付金额<=0但未同步的状态
2106
2182
  * 从 Payment 模块获取最新的支付项数据
2107
2183
  */
2108
2184
  }, {
2109
2185
  key: "needsManualSyncAsync",
2110
2186
  value: (function () {
2111
- var _needsManualSyncAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
2187
+ var _needsManualSyncAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
2112
2188
  var remainingAmount, remainingValue, currentPayments, allPaymentsHaveVoucherId;
2113
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2114
- while (1) switch (_context28.prev = _context28.next) {
2189
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2190
+ while (1) switch (_context30.prev = _context30.next) {
2115
2191
  case 0:
2116
- _context28.prev = 0;
2192
+ _context30.prev = 0;
2117
2193
  if (!(!this.store.currentOrder || this.store.isOrderSynced)) {
2118
- _context28.next = 3;
2194
+ _context30.next = 3;
2119
2195
  break;
2120
2196
  }
2121
- return _context28.abrupt("return", false);
2197
+ return _context30.abrupt("return", false);
2122
2198
  case 3:
2123
- _context28.next = 5;
2199
+ _context30.next = 5;
2124
2200
  return this.calculateRemainingAmountAsync();
2125
2201
  case 5:
2126
- remainingAmount = _context28.sent;
2202
+ remainingAmount = _context30.sent;
2127
2203
  remainingValue = parseFloat(remainingAmount);
2128
2204
  if (!(remainingValue > 0)) {
2129
- _context28.next = 9;
2205
+ _context30.next = 9;
2130
2206
  break;
2131
2207
  }
2132
- return _context28.abrupt("return", false);
2208
+ return _context30.abrupt("return", false);
2133
2209
  case 9:
2134
- _context28.next = 11;
2210
+ _context30.next = 11;
2135
2211
  return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid, false // 不包括已撤销的支付项
2136
2212
  );
2137
2213
  case 11:
2138
- currentPayments = _context28.sent;
2214
+ currentPayments = _context30.sent;
2139
2215
  allPaymentsHaveVoucherId = currentPayments.length > 0 && currentPayments.every(function (item) {
2140
2216
  return item.status !== 'voided' && item.voucher_id;
2141
2217
  });
@@ -2155,17 +2231,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2155
2231
  };
2156
2232
  })
2157
2233
  });
2158
- return _context28.abrupt("return", allPaymentsHaveVoucherId);
2234
+ return _context30.abrupt("return", allPaymentsHaveVoucherId);
2159
2235
  case 17:
2160
- _context28.prev = 17;
2161
- _context28.t0 = _context28["catch"](0);
2162
- console.error('[Checkout] needsManualSyncAsync 检查失败:', _context28.t0);
2163
- return _context28.abrupt("return", false);
2236
+ _context30.prev = 17;
2237
+ _context30.t0 = _context30["catch"](0);
2238
+ console.error('[Checkout] needsManualSyncAsync 检查失败:', _context30.t0);
2239
+ return _context30.abrupt("return", false);
2164
2240
  case 21:
2165
2241
  case "end":
2166
- return _context28.stop();
2242
+ return _context30.stop();
2167
2243
  }
2168
- }, _callee28, this, [[0, 17]]);
2244
+ }, _callee30, this, [[0, 17]]);
2169
2245
  }));
2170
2246
  function needsManualSyncAsync() {
2171
2247
  return _needsManualSyncAsync.apply(this, arguments);
@@ -2174,24 +2250,24 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2174
2250
  }()
2175
2251
  /**
2176
2252
  * 手动同步订单到后端
2177
- *
2253
+ *
2178
2254
  * 用于强制同步订单到后端,特别适用于纯代金券支付完成的订单
2179
2255
  */
2180
2256
  )
2181
2257
  }, {
2182
2258
  key: "manualSyncOrderAsync",
2183
2259
  value: (function () {
2184
- var _manualSyncOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
2260
+ var _manualSyncOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
2185
2261
  var orderUuid, oldOrderId, realOrderId, finalOrderId, finalIsVirtual, _this$store$currentOr6, errorMessage;
2186
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2187
- while (1) switch (_context29.prev = _context29.next) {
2262
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2263
+ while (1) switch (_context31.prev = _context31.next) {
2188
2264
  case 0:
2189
- _context29.prev = 0;
2265
+ _context31.prev = 0;
2190
2266
  if (this.store.currentOrder) {
2191
- _context29.next = 3;
2267
+ _context31.next = 3;
2192
2268
  break;
2193
2269
  }
2194
- return _context29.abrupt("return", {
2270
+ return _context31.abrupt("return", {
2195
2271
  success: false,
2196
2272
  message: '当前没有活跃订单,无法同步'
2197
2273
  });
@@ -2201,25 +2277,25 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2201
2277
  if (this.store.isOrderSynced) {
2202
2278
  console.log('[Checkout] 订单已同步过,将执行更新操作');
2203
2279
  }
2204
- _context29.t0 = console;
2205
- _context29.t1 = orderUuid;
2206
- _context29.t2 = oldOrderId;
2207
- _context29.t3 = this.store.currentOrder.total_amount;
2208
- _context29.next = 12;
2280
+ _context31.t0 = console;
2281
+ _context31.t1 = orderUuid;
2282
+ _context31.t2 = oldOrderId;
2283
+ _context31.t3 = this.store.currentOrder.total_amount;
2284
+ _context31.next = 12;
2209
2285
  return this.calculateRemainingAmountAsync();
2210
2286
  case 12:
2211
- _context29.t4 = _context29.sent;
2212
- _context29.t5 = {
2213
- orderUuid: _context29.t1,
2214
- orderId: _context29.t2,
2215
- totalAmount: _context29.t3,
2216
- remainingAmount: _context29.t4
2287
+ _context31.t4 = _context31.sent;
2288
+ _context31.t5 = {
2289
+ orderUuid: _context31.t1,
2290
+ orderId: _context31.t2,
2291
+ totalAmount: _context31.t3,
2292
+ remainingAmount: _context31.t4
2217
2293
  };
2218
- _context29.t0.log.call(_context29.t0, '[Checkout] 开始手动同步订单到后端:', _context29.t5);
2219
- _context29.next = 17;
2294
+ _context31.t0.log.call(_context31.t0, '[Checkout] 开始手动同步订单到后端:', _context31.t5);
2295
+ _context31.next = 17;
2220
2296
  return this.syncOrderToBackendWithReturn(true);
2221
2297
  case 17:
2222
- realOrderId = _context29.sent;
2298
+ realOrderId = _context31.sent;
2223
2299
  console.log('[Checkout] 手动同步订单完成:', {
2224
2300
  orderUuid: orderUuid,
2225
2301
  oldOrderId: oldOrderId,
@@ -2243,7 +2319,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2243
2319
  if (realOrderId !== finalOrderId) {
2244
2320
  console.error('[Checkout] 严重警告:返回的订单ID与存储的订单ID不一致!');
2245
2321
  }
2246
- return _context29.abrupt("return", {
2322
+ return _context31.abrupt("return", {
2247
2323
  success: true,
2248
2324
  message: '订单同步成功',
2249
2325
  orderId: realOrderId,
@@ -2251,20 +2327,20 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2251
2327
  orderUuid: orderUuid
2252
2328
  });
2253
2329
  case 27:
2254
- _context29.prev = 27;
2255
- _context29.t6 = _context29["catch"](0);
2256
- console.error('[Checkout] 手动同步订单失败:', _context29.t6);
2257
- errorMessage = _context29.t6 instanceof Error ? _context29.t6.message : '同步失败';
2258
- return _context29.abrupt("return", {
2330
+ _context31.prev = 27;
2331
+ _context31.t6 = _context31["catch"](0);
2332
+ console.error('[Checkout] 手动同步订单失败:', _context31.t6);
2333
+ errorMessage = _context31.t6 instanceof Error ? _context31.t6.message : '同步失败';
2334
+ return _context31.abrupt("return", {
2259
2335
  success: false,
2260
2336
  message: "\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(errorMessage),
2261
2337
  orderUuid: (_this$store$currentOr6 = this.store.currentOrder) === null || _this$store$currentOr6 === void 0 ? void 0 : _this$store$currentOr6.uuid
2262
2338
  });
2263
2339
  case 32:
2264
2340
  case "end":
2265
- return _context29.stop();
2341
+ return _context31.stop();
2266
2342
  }
2267
- }, _callee29, this, [[0, 27]]);
2343
+ }, _callee31, this, [[0, 27]]);
2268
2344
  }));
2269
2345
  function manualSyncOrderAsync() {
2270
2346
  return _manualSyncOrderAsync.apply(this, arguments);
@@ -2273,7 +2349,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2273
2349
  }()
2274
2350
  /**
2275
2351
  * 获取当前订单备注
2276
- *
2352
+ *
2277
2353
  * @returns 当前订单的备注内容,如果没有则返回空字符串
2278
2354
  */
2279
2355
  )
@@ -2289,7 +2365,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2289
2365
 
2290
2366
  /**
2291
2367
  * 获取当前订单ID
2292
- *
2368
+ *
2293
2369
  * @returns 当前订单的ID,如果没有订单则返回null
2294
2370
  */
2295
2371
  }, {
@@ -2303,7 +2379,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2303
2379
 
2304
2380
  /**
2305
2381
  * 获取当前订单是否已同步到后端
2306
- *
2382
+ *
2307
2383
  * @returns 当前订单是否已同步状态,如果没有订单则返回false
2308
2384
  */
2309
2385
  }, {
@@ -2325,21 +2401,21 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2325
2401
 
2326
2402
  /**
2327
2403
  * 取消当前本地订单
2328
- *
2404
+ *
2329
2405
  * 只能取消未同步到后端的本地订单,如果订单已同步则不能取消
2330
- *
2406
+ *
2331
2407
  * @param cancelReason 取消原因(可选)
2332
2408
  * @returns 取消结果
2333
2409
  */
2334
2410
  }, {
2335
2411
  key: "cancelCurrentOrderAsync",
2336
2412
  value: (function () {
2337
- var _cancelCurrentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(cancelReason) {
2413
+ var _cancelCurrentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(cancelReason) {
2338
2414
  var _this$store$currentOr7, _this$store$currentOr8, currentOrderUuid, currentOrderId, isOrderSynced, errorMessage;
2339
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
2340
- while (1) switch (_context30.prev = _context30.next) {
2415
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2416
+ while (1) switch (_context32.prev = _context32.next) {
2341
2417
  case 0:
2342
- _context30.prev = 0;
2418
+ _context32.prev = 0;
2343
2419
  console.log('[Checkout] 开始取消当前本地订单:', {
2344
2420
  hasCurrentOrder: !!this.store.currentOrder,
2345
2421
  orderUuid: (_this$store$currentOr7 = this.store.currentOrder) === null || _this$store$currentOr7 === void 0 ? void 0 : _this$store$currentOr7.uuid,
@@ -2350,11 +2426,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2350
2426
 
2351
2427
  // 检查是否有当前订单
2352
2428
  if (this.store.currentOrder) {
2353
- _context30.next = 5;
2429
+ _context32.next = 5;
2354
2430
  break;
2355
2431
  }
2356
2432
  console.log('[Checkout] 没有当前订单,无需取消');
2357
- return _context30.abrupt("return", {
2433
+ return _context32.abrupt("return", {
2358
2434
  success: false,
2359
2435
  message: '没有当前订单可取消'
2360
2436
  });
@@ -2363,14 +2439,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2363
2439
  currentOrderId = this.store.currentOrder.order_id;
2364
2440
  isOrderSynced = this.store.isOrderSynced; // 检查订单是否已同步,已同步的订单不能取消
2365
2441
  if (!isOrderSynced) {
2366
- _context30.next = 11;
2442
+ _context32.next = 11;
2367
2443
  break;
2368
2444
  }
2369
2445
  console.log('[Checkout] 订单已同步到后端,不能取消:', {
2370
2446
  orderId: currentOrderId,
2371
2447
  orderUuid: currentOrderUuid
2372
2448
  });
2373
- return _context30.abrupt("return", {
2449
+ return _context32.abrupt("return", {
2374
2450
  success: false,
2375
2451
  message: '订单已同步到后端,无法取消',
2376
2452
  orderId: currentOrderId
@@ -2379,18 +2455,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2379
2455
  console.log('[Checkout] 订单尚未同步,可以取消');
2380
2456
 
2381
2457
  // 删除本地订单数据
2382
- _context30.prev = 12;
2458
+ _context32.prev = 12;
2383
2459
  console.log('[Checkout] 删除本地订单数据');
2384
- _context30.next = 16;
2460
+ _context32.next = 16;
2385
2461
  return this.payment.deletePaymentOrderAsync(currentOrderUuid);
2386
2462
  case 16:
2387
2463
  console.log('[Checkout] 本地订单数据删除成功');
2388
- _context30.next = 22;
2464
+ _context32.next = 22;
2389
2465
  break;
2390
2466
  case 19:
2391
- _context30.prev = 19;
2392
- _context30.t0 = _context30["catch"](12);
2393
- console.warn('[Checkout] 删除本地订单数据失败,但继续执行:', _context30.t0);
2467
+ _context32.prev = 19;
2468
+ _context32.t0 = _context32["catch"](12);
2469
+ console.warn('[Checkout] 删除本地订单数据失败,但继续执行:', _context32.t0);
2394
2470
  case 22:
2395
2471
  // 清理订单相关状态,确保正确释放 currentOrder
2396
2472
  console.log('[Checkout] 清理订单相关状态');
@@ -2405,7 +2481,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2405
2481
  console.log('[Checkout] 订单状态清理完成,currentOrder已释放');
2406
2482
 
2407
2483
  // 触发订单取消事件
2408
- _context30.next = 32;
2484
+ _context32.next = 32;
2409
2485
  return this.core.effects.emit(CheckoutHooks.OnOrderCancelled, {
2410
2486
  orderUuid: currentOrderUuid,
2411
2487
  orderId: currentOrderId,
@@ -2420,34 +2496,34 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2420
2496
  orderId: currentOrderId,
2421
2497
  cancelReason: cancelReason
2422
2498
  });
2423
- return _context30.abrupt("return", {
2499
+ return _context32.abrupt("return", {
2424
2500
  success: true,
2425
2501
  message: '本地订单已成功取消',
2426
2502
  orderId: currentOrderId
2427
2503
  });
2428
2504
  case 36:
2429
- _context30.prev = 36;
2430
- _context30.t1 = _context30["catch"](0);
2431
- console.error('[Checkout] 取消本地订单失败:', _context30.t1);
2432
- errorMessage = _context30.t1 instanceof Error ? _context30.t1.message : '未知错误';
2433
- return _context30.abrupt("return", {
2505
+ _context32.prev = 36;
2506
+ _context32.t1 = _context32["catch"](0);
2507
+ console.error('[Checkout] 取消本地订单失败:', _context32.t1);
2508
+ errorMessage = _context32.t1 instanceof Error ? _context32.t1.message : '未知错误';
2509
+ return _context32.abrupt("return", {
2434
2510
  success: false,
2435
2511
  message: "\u53D6\u6D88\u8BA2\u5355\u5931\u8D25: ".concat(errorMessage)
2436
2512
  });
2437
2513
  case 41:
2438
2514
  case "end":
2439
- return _context30.stop();
2515
+ return _context32.stop();
2440
2516
  }
2441
- }, _callee30, this, [[0, 36], [12, 19]]);
2517
+ }, _callee32, this, [[0, 36], [12, 19]]);
2442
2518
  }));
2443
- function cancelCurrentOrderAsync(_x19) {
2519
+ function cancelCurrentOrderAsync(_x21) {
2444
2520
  return _cancelCurrentOrderAsync.apply(this, arguments);
2445
2521
  }
2446
2522
  return cancelCurrentOrderAsync;
2447
2523
  }()
2448
2524
  /**
2449
2525
  * 保存订单并稍后支付
2450
- *
2526
+ *
2451
2527
  * 将当前订单保存到后端,但排除代金券类支付项(voucher_id),
2452
2528
  * 适用于用户想要保存订单但稍后完成支付的场景
2453
2529
  */
@@ -2455,17 +2531,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2455
2531
  }, {
2456
2532
  key: "saveForLaterPaymentAsync",
2457
2533
  value: (function () {
2458
- var _saveForLaterPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
2534
+ var _saveForLaterPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
2459
2535
  var orderUuid, currentOrderId, allPaymentItems, filteredPaymentItems, voucherItems, realOrderId, finalOrderId, _this$store$currentOr9, errorMessage;
2460
- return _regeneratorRuntime().wrap(function _callee31$(_context31) {
2461
- while (1) switch (_context31.prev = _context31.next) {
2536
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2537
+ while (1) switch (_context33.prev = _context33.next) {
2462
2538
  case 0:
2463
- _context31.prev = 0;
2539
+ _context33.prev = 0;
2464
2540
  if (this.store.currentOrder) {
2465
- _context31.next = 3;
2541
+ _context33.next = 3;
2466
2542
  break;
2467
2543
  }
2468
- return _context31.abrupt("return", {
2544
+ return _context33.abrupt("return", {
2469
2545
  success: false,
2470
2546
  message: '当前没有活跃订单,无法保存'
2471
2547
  });
@@ -2479,10 +2555,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2479
2555
  });
2480
2556
 
2481
2557
  // 获取当前订单的所有支付项
2482
- _context31.next = 8;
2558
+ _context33.next = 8;
2483
2559
  return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid);
2484
2560
  case 8:
2485
- allPaymentItems = _context31.sent;
2561
+ allPaymentItems = _context33.sent;
2486
2562
  // 过滤掉带有 voucher_id 的支付项(代金券类支付项)
2487
2563
  filteredPaymentItems = allPaymentItems.filter(function (payment) {
2488
2564
  return !payment.voucher_id || payment.voucher_id.trim() === '';
@@ -2512,10 +2588,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2512
2588
  });
2513
2589
 
2514
2590
  // 调用同步方法,传入过滤后的支付项
2515
- _context31.next = 14;
2591
+ _context33.next = 14;
2516
2592
  return this.syncOrderToBackendWithReturn(false, filteredPaymentItems);
2517
2593
  case 14:
2518
- realOrderId = _context31.sent;
2594
+ realOrderId = _context33.sent;
2519
2595
  console.log('[Checkout] 保存订单完成:', {
2520
2596
  orderUuid: orderUuid,
2521
2597
  oldOrderId: currentOrderId,
@@ -2532,27 +2608,27 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2532
2608
  是否一致: realOrderId === finalOrderId,
2533
2609
  同步状态: this.store.isOrderSynced
2534
2610
  });
2535
- return _context31.abrupt("return", {
2611
+ return _context33.abrupt("return", {
2536
2612
  success: true,
2537
2613
  message: '订单保存成功,可稍后继续支付',
2538
2614
  orderId: realOrderId,
2539
2615
  orderUuid: orderUuid
2540
2616
  });
2541
2617
  case 21:
2542
- _context31.prev = 21;
2543
- _context31.t0 = _context31["catch"](0);
2544
- console.error('[Checkout] 保存订单失败:', _context31.t0);
2545
- errorMessage = _context31.t0 instanceof Error ? _context31.t0.message : '保存失败';
2546
- return _context31.abrupt("return", {
2618
+ _context33.prev = 21;
2619
+ _context33.t0 = _context33["catch"](0);
2620
+ console.error('[Checkout] 保存订单失败:', _context33.t0);
2621
+ errorMessage = _context33.t0 instanceof Error ? _context33.t0.message : '保存失败';
2622
+ return _context33.abrupt("return", {
2547
2623
  success: false,
2548
2624
  message: "\u8BA2\u5355\u4FDD\u5B58\u5931\u8D25: ".concat(errorMessage),
2549
2625
  orderUuid: (_this$store$currentOr9 = this.store.currentOrder) === null || _this$store$currentOr9 === void 0 ? void 0 : _this$store$currentOr9.uuid
2550
2626
  });
2551
2627
  case 26:
2552
2628
  case "end":
2553
- return _context31.stop();
2629
+ return _context33.stop();
2554
2630
  }
2555
- }, _callee31, this, [[0, 21]]);
2631
+ }, _callee33, this, [[0, 21]]);
2556
2632
  }));
2557
2633
  function saveForLaterPaymentAsync() {
2558
2634
  return _saveForLaterPaymentAsync.apply(this, arguments);
@@ -2561,7 +2637,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2561
2637
  }()
2562
2638
  /**
2563
2639
  * 获取当前商店折扣金额
2564
- *
2640
+ *
2565
2641
  * @returns 当前的商店折扣金额,如果没有则返回0
2566
2642
  */
2567
2643
  )
@@ -2588,20 +2664,20 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2588
2664
 
2589
2665
  /**
2590
2666
  * 更新订单商店折扣
2591
- *
2667
+ *
2592
2668
  * 同时更新cartSummary和localOrderData中的shop_discount值
2593
- *
2669
+ *
2594
2670
  * @param discountAmount 商店折扣金额
2595
2671
  */
2596
2672
  }, {
2597
2673
  key: "updateShopDiscountAsync",
2598
2674
  value: (function () {
2599
- var _updateShopDiscountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(discountAmount) {
2675
+ var _updateShopDiscountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(discountAmount) {
2600
2676
  var _this$store$currentOr10, _this$store$currentOr11, oldDiscount, shopDiscountItem, updatedAmountInfo;
2601
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
2602
- while (1) switch (_context32.prev = _context32.next) {
2677
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2678
+ while (1) switch (_context34.prev = _context34.next) {
2603
2679
  case 0:
2604
- _context32.prev = 0;
2680
+ _context34.prev = 0;
2605
2681
  oldDiscount = this.getShopDiscount();
2606
2682
  console.log('[Checkout] 更新商店折扣:', {
2607
2683
  orderUuid: (_this$store$currentOr10 = this.store.currentOrder) === null || _this$store$currentOr10 === void 0 ? void 0 : _this$store$currentOr10.uuid,
@@ -2649,10 +2725,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2649
2725
  }
2650
2726
 
2651
2727
  // 4. 更新 stateAmount 为剩余未支付金额
2652
- _context32.next = 8;
2728
+ _context34.next = 8;
2653
2729
  return this.updateStateAmountToRemaining();
2654
2730
  case 8:
2655
- _context32.next = 10;
2731
+ _context34.next = 10;
2656
2732
  return this.core.effects.emit(CheckoutHooks.OnShopDiscountChanged, {
2657
2733
  orderUuid: (_this$store$currentOr11 = this.store.currentOrder) === null || _this$store$currentOr11 === void 0 ? void 0 : _this$store$currentOr11.uuid,
2658
2734
  oldDiscount: oldDiscount,
@@ -2664,44 +2740,44 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2664
2740
  oldDiscount: oldDiscount,
2665
2741
  newDiscount: discountAmount
2666
2742
  });
2667
- _context32.next = 19;
2743
+ _context34.next = 19;
2668
2744
  break;
2669
2745
  case 13:
2670
- _context32.prev = 13;
2671
- _context32.t0 = _context32["catch"](0);
2672
- console.error('[Checkout] 更新商店折扣失败:', _context32.t0);
2673
- _context32.next = 18;
2674
- return this.handleError(_context32.t0, CheckoutErrorType.ValidationFailed);
2746
+ _context34.prev = 13;
2747
+ _context34.t0 = _context34["catch"](0);
2748
+ console.error('[Checkout] 更新商店折扣失败:', _context34.t0);
2749
+ _context34.next = 18;
2750
+ return this.handleError(_context34.t0, CheckoutErrorType.ValidationFailed);
2675
2751
  case 18:
2676
- throw _context32.t0;
2752
+ throw _context34.t0;
2677
2753
  case 19:
2678
2754
  case "end":
2679
- return _context32.stop();
2755
+ return _context34.stop();
2680
2756
  }
2681
- }, _callee32, this, [[0, 13]]);
2757
+ }, _callee34, this, [[0, 13]]);
2682
2758
  }));
2683
- function updateShopDiscountAsync(_x20) {
2759
+ function updateShopDiscountAsync(_x22) {
2684
2760
  return _updateShopDiscountAsync.apply(this, arguments);
2685
2761
  }
2686
2762
  return updateShopDiscountAsync;
2687
2763
  }()
2688
2764
  /**
2689
2765
  * 更新订单备注
2690
- *
2766
+ *
2691
2767
  * @param note 订单备注内容
2692
2768
  */
2693
2769
  )
2694
2770
  }, {
2695
2771
  key: "updateOrderNoteAsync",
2696
2772
  value: (function () {
2697
- var _updateOrderNoteAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(note) {
2773
+ var _updateOrderNoteAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(note) {
2698
2774
  var _this$store$currentOr12, _this$store$currentOr13, oldNote, orderInPayment;
2699
- return _regeneratorRuntime().wrap(function _callee33$(_context33) {
2700
- while (1) switch (_context33.prev = _context33.next) {
2775
+ return _regeneratorRuntime().wrap(function _callee35$(_context35) {
2776
+ while (1) switch (_context35.prev = _context35.next) {
2701
2777
  case 0:
2702
- _context33.prev = 0;
2778
+ _context35.prev = 0;
2703
2779
  if (this.store.localOrderData) {
2704
- _context33.next = 3;
2780
+ _context35.next = 3;
2705
2781
  break;
2706
2782
  }
2707
2783
  throw createCheckoutError(CheckoutErrorType.ValidationFailed, '没有本地订单数据,无法更新备注');
@@ -2718,27 +2794,27 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2718
2794
 
2719
2795
  // 如果有当前订单,也同步到Payment模块中的订单数据
2720
2796
  if (!this.store.currentOrder) {
2721
- _context33.next = 17;
2797
+ _context35.next = 17;
2722
2798
  break;
2723
2799
  }
2724
- _context33.prev = 7;
2725
- _context33.next = 10;
2800
+ _context35.prev = 7;
2801
+ _context35.next = 10;
2726
2802
  return this.payment.getPaymentOrderByUuidAsync(this.store.currentOrder.uuid);
2727
2803
  case 10:
2728
- orderInPayment = _context33.sent;
2804
+ orderInPayment = _context35.sent;
2729
2805
  if (orderInPayment && orderInPayment.note !== undefined) {
2730
2806
  // 使用Payment模块的更新方法(如果有的话)
2731
2807
  // 这里可能需要根据Payment模块的实际API来调整
2732
2808
  console.log('[Checkout] 同步备注到Payment模块的订单数据中');
2733
2809
  }
2734
- _context33.next = 17;
2810
+ _context35.next = 17;
2735
2811
  break;
2736
2812
  case 14:
2737
- _context33.prev = 14;
2738
- _context33.t0 = _context33["catch"](7);
2739
- console.warn('[Checkout] 同步备注到Payment模块失败,但本地更新成功:', _context33.t0);
2813
+ _context35.prev = 14;
2814
+ _context35.t0 = _context35["catch"](7);
2815
+ console.warn('[Checkout] 同步备注到Payment模块失败,但本地更新成功:', _context35.t0);
2740
2816
  case 17:
2741
- _context33.next = 19;
2817
+ _context35.next = 19;
2742
2818
  return this.core.effects.emit(CheckoutHooks.OnOrderNoteChanged, {
2743
2819
  orderUuid: (_this$store$currentOr13 = this.store.currentOrder) === null || _this$store$currentOr13 === void 0 ? void 0 : _this$store$currentOr13.uuid,
2744
2820
  oldNote: oldNote,
@@ -2750,23 +2826,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2750
2826
  oldNote: oldNote,
2751
2827
  newNote: note
2752
2828
  });
2753
- _context33.next = 28;
2829
+ _context35.next = 28;
2754
2830
  break;
2755
2831
  case 22:
2756
- _context33.prev = 22;
2757
- _context33.t1 = _context33["catch"](0);
2758
- console.error('[Checkout] 更新订单备注失败:', _context33.t1);
2759
- _context33.next = 27;
2760
- return this.handleError(_context33.t1, CheckoutErrorType.ValidationFailed);
2832
+ _context35.prev = 22;
2833
+ _context35.t1 = _context35["catch"](0);
2834
+ console.error('[Checkout] 更新订单备注失败:', _context35.t1);
2835
+ _context35.next = 27;
2836
+ return this.handleError(_context35.t1, CheckoutErrorType.ValidationFailed);
2761
2837
  case 27:
2762
- throw _context33.t1;
2838
+ throw _context35.t1;
2763
2839
  case 28:
2764
2840
  case "end":
2765
- return _context33.stop();
2841
+ return _context35.stop();
2766
2842
  }
2767
- }, _callee33, this, [[0, 22], [7, 14]]);
2843
+ }, _callee35, this, [[0, 22], [7, 14]]);
2768
2844
  }));
2769
- function updateOrderNoteAsync(_x21) {
2845
+ function updateOrderNoteAsync(_x23) {
2770
2846
  return _updateOrderNoteAsync.apply(this, arguments);
2771
2847
  }
2772
2848
  return updateOrderNoteAsync;
@@ -2778,14 +2854,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2778
2854
  }, {
2779
2855
  key: "setStatus",
2780
2856
  value: (function () {
2781
- var _setStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(status) {
2857
+ var _setStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(status) {
2782
2858
  var oldStatus;
2783
- return _regeneratorRuntime().wrap(function _callee34$(_context34) {
2784
- while (1) switch (_context34.prev = _context34.next) {
2859
+ return _regeneratorRuntime().wrap(function _callee36$(_context36) {
2860
+ while (1) switch (_context36.prev = _context36.next) {
2785
2861
  case 0:
2786
2862
  oldStatus = this.store.status;
2787
2863
  this.store.status = status;
2788
- _context34.next = 4;
2864
+ _context36.next = 4;
2789
2865
  return this.core.effects.emit(CheckoutHooks.OnStatusChanged, {
2790
2866
  oldStatus: oldStatus,
2791
2867
  newStatus: status,
@@ -2793,11 +2869,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2793
2869
  });
2794
2870
  case 4:
2795
2871
  case "end":
2796
- return _context34.stop();
2872
+ return _context36.stop();
2797
2873
  }
2798
- }, _callee34, this);
2874
+ }, _callee36, this);
2799
2875
  }));
2800
- function setStatus(_x22) {
2876
+ function setStatus(_x24) {
2801
2877
  return _setStatus.apply(this, arguments);
2802
2878
  }
2803
2879
  return setStatus;
@@ -2809,14 +2885,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2809
2885
  }, {
2810
2886
  key: "setStep",
2811
2887
  value: (function () {
2812
- var _setStep = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(step) {
2888
+ var _setStep = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(step) {
2813
2889
  var oldStep;
2814
- return _regeneratorRuntime().wrap(function _callee35$(_context35) {
2815
- while (1) switch (_context35.prev = _context35.next) {
2890
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
2891
+ while (1) switch (_context37.prev = _context37.next) {
2816
2892
  case 0:
2817
2893
  oldStep = this.store.step;
2818
2894
  this.store.step = step;
2819
- _context35.next = 4;
2895
+ _context37.next = 4;
2820
2896
  return this.core.effects.emit(CheckoutHooks.OnStepChanged, {
2821
2897
  oldStep: oldStep,
2822
2898
  newStep: step,
@@ -2824,11 +2900,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2824
2900
  });
2825
2901
  case 4:
2826
2902
  case "end":
2827
- return _context35.stop();
2903
+ return _context37.stop();
2828
2904
  }
2829
- }, _callee35, this);
2905
+ }, _callee37, this);
2830
2906
  }));
2831
- function setStep(_x23) {
2907
+ function setStep(_x25) {
2832
2908
  return _setStep.apply(this, arguments);
2833
2909
  }
2834
2910
  return setStep;
@@ -2840,17 +2916,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2840
2916
  }, {
2841
2917
  key: "handleError",
2842
2918
  value: (function () {
2843
- var _handleError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(error, type) {
2919
+ var _handleError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(error, type) {
2844
2920
  var checkoutError;
2845
- return _regeneratorRuntime().wrap(function _callee36$(_context36) {
2846
- while (1) switch (_context36.prev = _context36.next) {
2921
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
2922
+ while (1) switch (_context38.prev = _context38.next) {
2847
2923
  case 0:
2848
2924
  checkoutError = error instanceof Error && 'type' in error ? error : createCheckoutError(type, error.message, error);
2849
2925
  this.store.lastError = checkoutError;
2850
- _context36.next = 4;
2926
+ _context38.next = 4;
2851
2927
  return this.setStatus(CheckoutStatus.Error);
2852
2928
  case 4:
2853
- _context36.next = 6;
2929
+ _context38.next = 6;
2854
2930
  return this.core.effects.emit(CheckoutHooks.OnError, {
2855
2931
  error: checkoutError,
2856
2932
  context: {
@@ -2863,11 +2939,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2863
2939
  console.error('[Checkout] 错误:', checkoutError);
2864
2940
  case 7:
2865
2941
  case "end":
2866
- return _context36.stop();
2942
+ return _context38.stop();
2867
2943
  }
2868
- }, _callee36, this);
2944
+ }, _callee38, this);
2869
2945
  }));
2870
- function handleError(_x24, _x25) {
2946
+ function handleError(_x26, _x27) {
2871
2947
  return _handleError.apply(this, arguments);
2872
2948
  }
2873
2949
  return handleError;
@@ -2879,18 +2955,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2879
2955
  }, {
2880
2956
  key: "handlePaymentSuccess",
2881
2957
  value: (function () {
2882
- var _handlePaymentSuccess = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(data) {
2958
+ var _handlePaymentSuccess = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(data) {
2883
2959
  var _this$store$currentOr14;
2884
- return _regeneratorRuntime().wrap(function _callee37$(_context37) {
2885
- while (1) switch (_context37.prev = _context37.next) {
2960
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
2961
+ while (1) switch (_context39.prev = _context39.next) {
2886
2962
  case 0:
2887
- _context37.next = 2;
2963
+ _context39.next = 2;
2888
2964
  return this.setStatus(CheckoutStatus.PaymentCompleted);
2889
2965
  case 2:
2890
- _context37.next = 4;
2966
+ _context39.next = 4;
2891
2967
  return this.updateStateAmountToRemaining();
2892
2968
  case 4:
2893
- _context37.next = 6;
2969
+ _context39.next = 6;
2894
2970
  return this.core.effects.emit(CheckoutHooks.OnPaymentSuccess, {
2895
2971
  orderUuid: data.orderUuid,
2896
2972
  paymentMethodCode: '',
@@ -2898,15 +2974,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2898
2974
  timestamp: data.timestamp
2899
2975
  });
2900
2976
  case 6:
2901
- _context37.next = 8;
2977
+ _context39.next = 8;
2902
2978
  return this.completeCheckoutAsync();
2903
2979
  case 8:
2904
2980
  case "end":
2905
- return _context37.stop();
2981
+ return _context39.stop();
2906
2982
  }
2907
- }, _callee37, this);
2983
+ }, _callee39, this);
2908
2984
  }));
2909
- function handlePaymentSuccess(_x26) {
2985
+ function handlePaymentSuccess(_x28) {
2910
2986
  return _handlePaymentSuccess.apply(this, arguments);
2911
2987
  }
2912
2988
  return handlePaymentSuccess;
@@ -2918,17 +2994,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2918
2994
  }, {
2919
2995
  key: "handlePaymentError",
2920
2996
  value: (function () {
2921
- var _handlePaymentError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(data) {
2997
+ var _handlePaymentError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(data) {
2922
2998
  var _this$store$currentOr15;
2923
2999
  var error;
2924
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
2925
- while (1) switch (_context38.prev = _context38.next) {
3000
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
3001
+ while (1) switch (_context40.prev = _context40.next) {
2926
3002
  case 0:
2927
3003
  error = createCheckoutError(CheckoutErrorType.PaymentFailed, data.error || '支付同步失败');
2928
- _context38.next = 3;
3004
+ _context40.next = 3;
2929
3005
  return this.handleError(error instanceof Error ? error : new Error(String(error)), CheckoutErrorType.PaymentFailed);
2930
3006
  case 3:
2931
- _context38.next = 5;
3007
+ _context40.next = 5;
2932
3008
  return this.core.effects.emit(CheckoutHooks.OnPaymentFailed, {
2933
3009
  orderUuid: data.orderUuid,
2934
3010
  paymentMethodCode: '',
@@ -2937,11 +3013,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2937
3013
  });
2938
3014
  case 5:
2939
3015
  case "end":
2940
- return _context38.stop();
3016
+ return _context40.stop();
2941
3017
  }
2942
- }, _callee38, this);
3018
+ }, _callee40, this);
2943
3019
  }));
2944
- function handlePaymentError(_x27) {
3020
+ function handlePaymentError(_x29) {
2945
3021
  return _handlePaymentError.apply(this, arguments);
2946
3022
  }
2947
3023
  return handlePaymentError;
@@ -2953,18 +3029,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2953
3029
  }, {
2954
3030
  key: "validateCheckoutParams",
2955
3031
  value: (function () {
2956
- var _validateCheckoutParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(params) {
2957
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
2958
- while (1) switch (_context39.prev = _context39.next) {
3032
+ var _validateCheckoutParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
3033
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3034
+ while (1) switch (_context41.prev = _context41.next) {
2959
3035
  case 0:
2960
- return _context39.abrupt("return", validateCheckoutData(params));
3036
+ return _context41.abrupt("return", validateCheckoutData(params));
2961
3037
  case 1:
2962
3038
  case "end":
2963
- return _context39.stop();
3039
+ return _context41.stop();
2964
3040
  }
2965
- }, _callee39);
3041
+ }, _callee41);
2966
3042
  }));
2967
- function validateCheckoutParams(_x28) {
3043
+ function validateCheckoutParams(_x30) {
2968
3044
  return _validateCheckoutParams.apply(this, arguments);
2969
3045
  }
2970
3046
  return validateCheckoutParams;
@@ -2976,10 +3052,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2976
3052
  }, {
2977
3053
  key: "validateLocalOrderData",
2978
3054
  value: (function () {
2979
- var _validateLocalOrderData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(orderData) {
3055
+ var _validateLocalOrderData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(orderData) {
3056
+ var _orderData$relation_p;
2980
3057
  var errors;
2981
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
2982
- while (1) switch (_context40.prev = _context40.next) {
3058
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3059
+ while (1) switch (_context42.prev = _context42.next) {
2983
3060
  case 0:
2984
3061
  errors = []; // 验证基本字段
2985
3062
  if (!orderData.type) {
@@ -2988,7 +3065,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
2988
3065
  if (!orderData.platform) {
2989
3066
  errors.push('平台信息不能为空');
2990
3067
  }
2991
- if (!orderData.bookings || orderData.bookings.length === 0) {
3068
+ if ((!orderData.bookings || orderData.bookings.length === 0) && !(orderData !== null && orderData !== void 0 && (_orderData$relation_p = orderData.relation_products) !== null && _orderData$relation_p !== void 0 && _orderData$relation_p.length)) {
2992
3069
  errors.push('预订信息不能为空');
2993
3070
  }
2994
3071
 
@@ -3006,17 +3083,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3006
3083
  }
3007
3084
  });
3008
3085
  }
3009
- return _context40.abrupt("return", {
3086
+ return _context42.abrupt("return", {
3010
3087
  valid: errors.length === 0,
3011
3088
  errors: errors
3012
3089
  });
3013
3090
  case 6:
3014
3091
  case "end":
3015
- return _context40.stop();
3092
+ return _context42.stop();
3016
3093
  }
3017
- }, _callee40);
3094
+ }, _callee42);
3018
3095
  }));
3019
- function validateLocalOrderData(_x29) {
3096
+ function validateLocalOrderData(_x31) {
3020
3097
  return _validateLocalOrderData.apply(this, arguments);
3021
3098
  }
3022
3099
  return validateLocalOrderData;
@@ -3035,7 +3112,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3035
3112
 
3036
3113
  /**
3037
3114
  * 格式化日期时间为 YYYY-MM-DD hh:mm:ss 格式
3038
- *
3115
+ *
3039
3116
  * @param date 要格式化的日期对象
3040
3117
  * @returns 格式化后的日期时间字符串
3041
3118
  */
@@ -3114,31 +3191,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3114
3191
  }, {
3115
3192
  key: "preloadPaymentMethods",
3116
3193
  value: (function () {
3117
- var _preloadPaymentMethods = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41() {
3194
+ var _preloadPaymentMethods = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43() {
3118
3195
  var methods;
3119
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
3120
- while (1) switch (_context41.prev = _context41.next) {
3196
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3197
+ while (1) switch (_context43.prev = _context43.next) {
3121
3198
  case 0:
3122
- _context41.prev = 0;
3199
+ _context43.prev = 0;
3123
3200
  console.log('[Checkout] 预加载支付方式...');
3124
- _context41.next = 4;
3201
+ _context43.next = 4;
3125
3202
  return this.payment.getPayMethodListAsync();
3126
3203
  case 4:
3127
- methods = _context41.sent;
3204
+ methods = _context43.sent;
3128
3205
  this.store.paymentMethods = methods;
3129
3206
  console.log("[Checkout] \u9884\u52A0\u8F7D\u5B8C\u6210\uFF0C\u5171 ".concat(methods.length, " \u79CD\u652F\u4ED8\u65B9\u5F0F"));
3130
- _context41.next = 13;
3207
+ _context43.next = 13;
3131
3208
  break;
3132
3209
  case 9:
3133
- _context41.prev = 9;
3134
- _context41.t0 = _context41["catch"](0);
3135
- console.error('[Checkout] 预加载支付方式失败:', _context41.t0);
3210
+ _context43.prev = 9;
3211
+ _context43.t0 = _context43["catch"](0);
3212
+ console.error('[Checkout] 预加载支付方式失败:', _context43.t0);
3136
3213
  this.store.paymentMethods = [];
3137
3214
  case 13:
3138
3215
  case "end":
3139
- return _context41.stop();
3216
+ return _context43.stop();
3140
3217
  }
3141
- }, _callee41, this, [[0, 9]]);
3218
+ }, _callee43, this, [[0, 9]]);
3142
3219
  }));
3143
3220
  function preloadPaymentMethods() {
3144
3221
  return _preloadPaymentMethods.apply(this, arguments);
@@ -3166,24 +3243,24 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3166
3243
  }, {
3167
3244
  key: "calculatePaidAmountAsync",
3168
3245
  value: (function () {
3169
- var _calculatePaidAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42() {
3246
+ var _calculatePaidAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
3170
3247
  var payments, paidAmount, result;
3171
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
3172
- while (1) switch (_context42.prev = _context42.next) {
3248
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3249
+ while (1) switch (_context44.prev = _context44.next) {
3173
3250
  case 0:
3174
3251
  if (this.store.currentOrder) {
3175
- _context42.next = 3;
3252
+ _context44.next = 3;
3176
3253
  break;
3177
3254
  }
3178
3255
  console.log('[Checkout] calculatePaidAmountAsync: 没有当前订单');
3179
- return _context42.abrupt("return", '0.00');
3256
+ return _context44.abrupt("return", '0.00');
3180
3257
  case 3:
3181
- _context42.prev = 3;
3182
- _context42.next = 6;
3258
+ _context44.prev = 3;
3259
+ _context44.next = 6;
3183
3260
  return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid, false // 不包括已撤销的支付项
3184
3261
  );
3185
3262
  case 6:
3186
- payments = _context42.sent;
3263
+ payments = _context44.sent;
3187
3264
  console.log('[Checkout] calculatePaidAmountAsync: 支付项详情:', {
3188
3265
  paymentCount: payments.length,
3189
3266
  payments: payments.map(function (p) {
@@ -3205,17 +3282,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3205
3282
  }, 0);
3206
3283
  result = paidAmount.toFixed(2);
3207
3284
  console.log('[Checkout] calculatePaidAmountAsync: 计算结果 =', result);
3208
- return _context42.abrupt("return", result);
3285
+ return _context44.abrupt("return", result);
3209
3286
  case 14:
3210
- _context42.prev = 14;
3211
- _context42.t0 = _context42["catch"](3);
3212
- console.error('[Checkout] calculatePaidAmountAsync 失败:', _context42.t0);
3213
- return _context42.abrupt("return", '0.00');
3287
+ _context44.prev = 14;
3288
+ _context44.t0 = _context44["catch"](3);
3289
+ console.error('[Checkout] calculatePaidAmountAsync 失败:', _context44.t0);
3290
+ return _context44.abrupt("return", '0.00');
3214
3291
  case 18:
3215
3292
  case "end":
3216
- return _context42.stop();
3293
+ return _context44.stop();
3217
3294
  }
3218
- }, _callee42, this, [[3, 14]]);
3295
+ }, _callee44, this, [[3, 14]]);
3219
3296
  }));
3220
3297
  function calculatePaidAmountAsync() {
3221
3298
  return _calculatePaidAmountAsync.apply(this, arguments);
@@ -3229,25 +3306,25 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3229
3306
  }, {
3230
3307
  key: "calculateRemainingAmountAsync",
3231
3308
  value: (function () {
3232
- var _calculateRemainingAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43() {
3309
+ var _calculateRemainingAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
3233
3310
  var totalAmount, paidAmount, remainingAmount, result;
3234
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
3235
- while (1) switch (_context43.prev = _context43.next) {
3311
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3312
+ while (1) switch (_context45.prev = _context45.next) {
3236
3313
  case 0:
3237
3314
  if (this.store.currentOrder) {
3238
- _context43.next = 3;
3315
+ _context45.next = 3;
3239
3316
  break;
3240
3317
  }
3241
3318
  console.log('[Checkout] calculateRemainingAmountAsync: 没有当前订单');
3242
- return _context43.abrupt("return", '0.00');
3319
+ return _context45.abrupt("return", '0.00');
3243
3320
  case 3:
3244
3321
  totalAmount = parseFloat(this.store.currentOrder.total_amount || '0');
3245
- _context43.t0 = parseFloat;
3246
- _context43.next = 7;
3322
+ _context45.t0 = parseFloat;
3323
+ _context45.next = 7;
3247
3324
  return this.calculatePaidAmountAsync();
3248
3325
  case 7:
3249
- _context43.t1 = _context43.sent;
3250
- paidAmount = (0, _context43.t0)(_context43.t1);
3326
+ _context45.t1 = _context45.sent;
3327
+ paidAmount = (0, _context45.t0)(_context45.t1);
3251
3328
  remainingAmount = totalAmount - paidAmount;
3252
3329
  result = Math.max(0, remainingAmount).toFixed(2);
3253
3330
  console.log('[Checkout] calculateRemainingAmountAsync: 计算详情:', {
@@ -3257,12 +3334,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3257
3334
  calculatedRemaining: remainingAmount.toFixed(2),
3258
3335
  finalResult: result
3259
3336
  });
3260
- return _context43.abrupt("return", result);
3337
+ return _context45.abrupt("return", result);
3261
3338
  case 13:
3262
3339
  case "end":
3263
- return _context43.stop();
3340
+ return _context45.stop();
3264
3341
  }
3265
- }, _callee43, this);
3342
+ }, _callee45, this);
3266
3343
  }));
3267
3344
  function calculateRemainingAmountAsync() {
3268
3345
  return _calculateRemainingAmountAsync.apply(this, arguments);
@@ -3276,16 +3353,16 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3276
3353
  }, {
3277
3354
  key: "updateStateAmountToRemaining",
3278
3355
  value: (function () {
3279
- var _updateStateAmountToRemaining = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
3356
+ var _updateStateAmountToRemaining = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
3280
3357
  var _this$store$currentOr16, remainingAmount, currentStateAmount;
3281
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
3282
- while (1) switch (_context44.prev = _context44.next) {
3358
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
3359
+ while (1) switch (_context46.prev = _context46.next) {
3283
3360
  case 0:
3284
- _context44.prev = 0;
3285
- _context44.next = 3;
3361
+ _context46.prev = 0;
3362
+ _context46.next = 3;
3286
3363
  return this.calculateRemainingAmountAsync();
3287
3364
  case 3:
3288
- remainingAmount = _context44.sent;
3365
+ remainingAmount = _context46.sent;
3289
3366
  currentStateAmount = this.store.stateAmount;
3290
3367
  console.log('[Checkout] updateStateAmountToRemaining: 状态检查:', {
3291
3368
  calculatedRemainingAmount: remainingAmount,
@@ -3296,13 +3373,13 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3296
3373
 
3297
3374
  // 只有当剩余金额与当前 stateAmount 不同时才更新
3298
3375
  if (!(remainingAmount !== currentStateAmount)) {
3299
- _context44.next = 13;
3376
+ _context46.next = 13;
3300
3377
  break;
3301
3378
  }
3302
3379
  this.store.stateAmount = remainingAmount;
3303
3380
 
3304
3381
  // 发出 stateAmount 变更事件
3305
- _context44.next = 10;
3382
+ _context46.next = 10;
3306
3383
  return this.core.effects.emit(CheckoutHooks.OnStateAmountChanged, {
3307
3384
  oldAmount: currentStateAmount,
3308
3385
  newAmount: remainingAmount,
@@ -3313,7 +3390,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3313
3390
  oldAmount: currentStateAmount,
3314
3391
  newAmount: remainingAmount
3315
3392
  });
3316
- _context44.next = 14;
3393
+ _context46.next = 14;
3317
3394
  break;
3318
3395
  case 13:
3319
3396
  console.log('[Checkout] stateAmount 无需更新,当前值已是最新:', {
@@ -3321,20 +3398,20 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3321
3398
  remainingAmount: remainingAmount
3322
3399
  });
3323
3400
  case 14:
3324
- _context44.next = 16;
3401
+ _context46.next = 16;
3325
3402
  return this.checkOrderPaymentCompletion();
3326
3403
  case 16:
3327
- _context44.next = 21;
3404
+ _context46.next = 21;
3328
3405
  break;
3329
3406
  case 18:
3330
- _context44.prev = 18;
3331
- _context44.t0 = _context44["catch"](0);
3332
- console.error('[Checkout] 更新 stateAmount 为剩余金额失败:', _context44.t0);
3407
+ _context46.prev = 18;
3408
+ _context46.t0 = _context46["catch"](0);
3409
+ console.error('[Checkout] 更新 stateAmount 为剩余金额失败:', _context46.t0);
3333
3410
  case 21:
3334
3411
  case "end":
3335
- return _context44.stop();
3412
+ return _context46.stop();
3336
3413
  }
3337
- }, _callee44, this, [[0, 18]]);
3414
+ }, _callee46, this, [[0, 18]]);
3338
3415
  }));
3339
3416
  function updateStateAmountToRemaining() {
3340
3417
  return _updateStateAmountToRemaining.apply(this, arguments);
@@ -3343,39 +3420,39 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3343
3420
  }()
3344
3421
  /**
3345
3422
  * 检查订单支付是否完成
3346
- *
3423
+ *
3347
3424
  * 当剩余待付款金额 <= 0 时,触发订单支付完成事件
3348
3425
  */
3349
3426
  )
3350
3427
  }, {
3351
3428
  key: "checkOrderPaymentCompletion",
3352
3429
  value: (function () {
3353
- var _checkOrderPaymentCompletion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
3430
+ var _checkOrderPaymentCompletion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
3354
3431
  var remainingAmount, remainingValue, totalAmount, paidAmount, currentPayments, allPaymentsHaveVoucherId;
3355
- return _regeneratorRuntime().wrap(function _callee45$(_context45) {
3356
- while (1) switch (_context45.prev = _context45.next) {
3432
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
3433
+ while (1) switch (_context47.prev = _context47.next) {
3357
3434
  case 0:
3358
- _context45.prev = 0;
3435
+ _context47.prev = 0;
3359
3436
  if (this.store.currentOrder) {
3360
- _context45.next = 3;
3437
+ _context47.next = 3;
3361
3438
  break;
3362
3439
  }
3363
- return _context45.abrupt("return");
3440
+ return _context47.abrupt("return");
3364
3441
  case 3:
3365
- _context45.next = 5;
3442
+ _context47.next = 5;
3366
3443
  return this.calculateRemainingAmountAsync();
3367
3444
  case 5:
3368
- remainingAmount = _context45.sent;
3445
+ remainingAmount = _context47.sent;
3369
3446
  remainingValue = parseFloat(remainingAmount); // 当剩余金额小于等于0时,认为订单已完成支付
3370
3447
  if (!(remainingValue <= 0)) {
3371
- _context45.next = 27;
3448
+ _context47.next = 27;
3372
3449
  break;
3373
3450
  }
3374
3451
  totalAmount = this.store.currentOrder.total_amount;
3375
- _context45.next = 11;
3452
+ _context47.next = 11;
3376
3453
  return this.calculatePaidAmountAsync();
3377
3454
  case 11:
3378
- paidAmount = _context45.sent;
3455
+ paidAmount = _context47.sent;
3379
3456
  console.log('[Checkout] 检测到订单支付完成:', {
3380
3457
  orderUuid: this.store.currentOrder.uuid,
3381
3458
  orderId: this.store.currentOrder.order_id,
@@ -3386,11 +3463,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3386
3463
  });
3387
3464
 
3388
3465
  // 从 Payment 模块获取最新支付项,检查是否所有支付项都带有 voucher_id
3389
- _context45.next = 15;
3466
+ _context47.next = 15;
3390
3467
  return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid, false // 不包括已撤销的支付项
3391
3468
  );
3392
3469
  case 15:
3393
- currentPayments = _context45.sent;
3470
+ currentPayments = _context47.sent;
3394
3471
  allPaymentsHaveVoucherId = currentPayments.length > 0 && currentPayments.every(function (item) {
3395
3472
  return item.status !== 'voided' && item.voucher_id;
3396
3473
  });
@@ -3418,18 +3495,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3418
3495
  // }
3419
3496
  // }
3420
3497
  if (!allPaymentsHaveVoucherId) {
3421
- _context45.next = 22;
3498
+ _context47.next = 22;
3422
3499
  break;
3423
3500
  }
3424
3501
  console.log('[Checkout] 所有支付项均为代金券类型,跳过订单同步');
3425
- _context45.next = 25;
3502
+ _context47.next = 25;
3426
3503
  break;
3427
3504
  case 22:
3428
3505
  console.log('[Checkout] 支付完成但订单未同步,开始同步订单到后端...');
3429
- _context45.next = 25;
3506
+ _context47.next = 25;
3430
3507
  return this.syncOrderToBackend();
3431
3508
  case 25:
3432
- _context45.next = 27;
3509
+ _context47.next = 27;
3433
3510
  return this.core.effects.emit(CheckoutHooks.OnOrderPaymentCompleted, {
3434
3511
  orderUuid: this.store.currentOrder.uuid,
3435
3512
  orderId: this.store.currentOrder.order_id,
@@ -3439,17 +3516,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3439
3516
  timestamp: Date.now()
3440
3517
  });
3441
3518
  case 27:
3442
- _context45.next = 32;
3519
+ _context47.next = 32;
3443
3520
  break;
3444
3521
  case 29:
3445
- _context45.prev = 29;
3446
- _context45.t0 = _context45["catch"](0);
3447
- console.error('[Checkout] 检查订单支付完成状态失败:', _context45.t0);
3522
+ _context47.prev = 29;
3523
+ _context47.t0 = _context47["catch"](0);
3524
+ console.error('[Checkout] 检查订单支付完成状态失败:', _context47.t0);
3448
3525
  case 32:
3449
3526
  case "end":
3450
- return _context45.stop();
3527
+ return _context47.stop();
3451
3528
  }
3452
- }, _callee45, this, [[0, 29]]);
3529
+ }, _callee47, this, [[0, 29]]);
3453
3530
  }));
3454
3531
  function checkOrderPaymentCompletion() {
3455
3532
  return _checkOrderPaymentCompletion.apply(this, arguments);
@@ -3458,11 +3535,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3458
3535
  }()
3459
3536
  /**
3460
3537
  * 判断支付方式是否需要同步订单到后端
3461
- *
3538
+ *
3462
3539
  * 现金支付(CASHMANUAL)和自定义支付不需要同步,其他支付方式需要同步
3463
- *
3540
+ *
3464
3541
  * @param paymentCode 支付方式代码
3465
- * @param paymentType 支付方式类型
3542
+ * @param paymentType 支付方式类型
3466
3543
  * @returns 是否需要同步订单
3467
3544
  */
3468
3545
  )
@@ -3496,12 +3573,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3496
3573
 
3497
3574
  /**
3498
3575
  * 同步订单到后端
3499
- *
3576
+ *
3500
3577
  * 调用后端 /order/checkout 接口创建真实订单
3501
3578
  */
3502
3579
  /**
3503
3580
  * 判断订单ID是否为本地生成的虚拟ID
3504
- *
3581
+ *
3505
3582
  * @param orderId 订单ID
3506
3583
  * @returns true 表示是虚拟ID,false 表示是真实的后端ID
3507
3584
  */
@@ -3513,7 +3590,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3513
3590
 
3514
3591
  /**
3515
3592
  * 同步订单到后端并返回真实订单ID
3516
- *
3593
+ *
3517
3594
  * @param isManual 是否为手动同步,默认为 false
3518
3595
  * @param customPaymentItems 自定义支付项列表,如果提供则使用此列表而不是从数据库获取
3519
3596
  * @returns 后端返回的真实订单ID
@@ -3521,7 +3598,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3521
3598
  }, {
3522
3599
  key: "syncOrderToBackendWithReturn",
3523
3600
  value: (function () {
3524
- var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
3601
+ var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48() {
3525
3602
  var _this$store$currentCu2, _this$store$currentOr17, _this$store$currentOr18;
3526
3603
  var isManual,
3527
3604
  customPaymentItems,
@@ -3541,14 +3618,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3541
3618
  beforeManualUpdate,
3542
3619
  finalOrderId,
3543
3620
  finalIsVirtual,
3544
- _args46 = arguments;
3545
- return _regeneratorRuntime().wrap(function _callee46$(_context46) {
3546
- while (1) switch (_context46.prev = _context46.next) {
3621
+ _args48 = arguments;
3622
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
3623
+ while (1) switch (_context48.prev = _context48.next) {
3547
3624
  case 0:
3548
- isManual = _args46.length > 0 && _args46[0] !== undefined ? _args46[0] : false;
3549
- customPaymentItems = _args46.length > 1 ? _args46[1] : undefined;
3625
+ isManual = _args48.length > 0 && _args48[0] !== undefined ? _args48[0] : false;
3626
+ customPaymentItems = _args48.length > 1 ? _args48[1] : undefined;
3550
3627
  if (!(!this.store.localOrderData || !this.store.currentOrder)) {
3551
- _context46.next = 4;
3628
+ _context48.next = 4;
3552
3629
  break;
3553
3630
  }
3554
3631
  throw new Error('缺少必要的订单数据,无法同步到后端');
@@ -3589,17 +3666,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3589
3666
  });
3590
3667
 
3591
3668
  // 获取当前订单的支付项
3592
- _context46.t0 = customPaymentItems;
3593
- if (_context46.t0) {
3594
- _context46.next = 18;
3669
+ _context48.t0 = customPaymentItems;
3670
+ if (_context48.t0) {
3671
+ _context48.next = 18;
3595
3672
  break;
3596
3673
  }
3597
- _context46.next = 17;
3674
+ _context48.next = 17;
3598
3675
  return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid);
3599
3676
  case 17:
3600
- _context46.t0 = _context46.sent;
3677
+ _context48.t0 = _context48.sent;
3601
3678
  case 18:
3602
- paymentItems = _context46.t0;
3679
+ paymentItems = _context48.t0;
3603
3680
  console.log('[Checkout] 获取到支付项:', {
3604
3681
  count: paymentItems.length,
3605
3682
  isCustomFiltered: !!customPaymentItems,
@@ -3645,7 +3722,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3645
3722
  // surcharge_fee: this.otherParams.surcharge_fee,
3646
3723
  // surcharges: ,
3647
3724
  note: this.store.localOrderData.shop_note
3648
- // deposit_amount:
3725
+ // deposit_amount:
3649
3726
  }); // 如果是更新操作,需要在参数中包含真实的订单ID
3650
3727
 
3651
3728
  if (isUpdateOperation) {
@@ -3671,10 +3748,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3671
3748
  }
3672
3749
 
3673
3750
  // 调用 Order 模块的专用 createOrderByCheckout 方法
3674
- _context46.next = 24;
3751
+ _context48.next = 24;
3675
3752
  return this.order.createOrderByCheckout(orderParams);
3676
3753
  case 24:
3677
- checkoutResponse = _context46.sent;
3754
+ checkoutResponse = _context48.sent;
3678
3755
  console.log('[Checkout] 后端返回的响应数据:', {
3679
3756
  status: checkoutResponse === null || checkoutResponse === void 0 ? void 0 : checkoutResponse.status,
3680
3757
  code: checkoutResponse === null || checkoutResponse === void 0 ? void 0 : checkoutResponse.code,
@@ -3682,13 +3759,13 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3682
3759
  data: checkoutResponse === null || checkoutResponse === void 0 ? void 0 : checkoutResponse.data
3683
3760
  });
3684
3761
  if (!isUpdateOperation) {
3685
- _context46.next = 31;
3762
+ _context48.next = 31;
3686
3763
  break;
3687
3764
  }
3688
3765
  // 更新操作:使用现有的订单ID
3689
3766
  realOrderId = currentOrderId;
3690
3767
  console.log("[Checkout] \u8BA2\u5355\u66F4\u65B0\u6210\u529F\uFF0C\u8BA2\u5355ID: ".concat(realOrderId));
3691
- _context46.next = 52;
3768
+ _context48.next = 52;
3692
3769
  break;
3693
3770
  case 31:
3694
3771
  // 创建操作:从响应中提取新的订单ID
@@ -3702,7 +3779,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3702
3779
  extractedOrderId = String(extractedOrderId);
3703
3780
  }
3704
3781
  if (extractedOrderId) {
3705
- _context46.next = 36;
3782
+ _context48.next = 36;
3706
3783
  break;
3707
3784
  }
3708
3785
  throw new Error('后端返回的订单信息中未包含订单ID');
@@ -3716,11 +3793,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3716
3793
  oldOrderId: this.store.currentOrder.order_id,
3717
3794
  newOrderId: realOrderId
3718
3795
  });
3719
- _context46.prev = 39;
3720
- _context46.next = 42;
3796
+ _context48.prev = 39;
3797
+ _context48.next = 42;
3721
3798
  return this.payment.replaceOrderIdByUuidAsync(this.store.currentOrder.uuid, realOrderId);
3722
3799
  case 42:
3723
- updatedOrder = _context46.sent;
3800
+ updatedOrder = _context48.sent;
3724
3801
  console.log('[Checkout] Payment模块替换订单ID结果:', {
3725
3802
  wasSuccessful: !!updatedOrder,
3726
3803
  returnedOrderId: updatedOrder === null || updatedOrder === void 0 ? void 0 : updatedOrder.order_id,
@@ -3746,12 +3823,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3746
3823
  目标ID: realOrderId
3747
3824
  });
3748
3825
  }
3749
- _context46.next = 52;
3826
+ _context48.next = 52;
3750
3827
  break;
3751
3828
  case 47:
3752
- _context46.prev = 47;
3753
- _context46.t1 = _context46["catch"](39);
3754
- console.error('[Checkout] 调用Payment模块替换订单ID时发生错误:', _context46.t1);
3829
+ _context48.prev = 47;
3830
+ _context48.t1 = _context48["catch"](39);
3831
+ console.error('[Checkout] 调用Payment模块替换订单ID时发生错误:', _context48.t1);
3755
3832
 
3756
3833
  // 发生错误时也进行手动替换
3757
3834
  this.store.currentOrder.order_id = realOrderId;
@@ -3761,7 +3838,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3761
3838
  this.store.isOrderSynced = true;
3762
3839
 
3763
3840
  // 触发订单同步完成事件
3764
- _context46.next = 55;
3841
+ _context48.next = 55;
3765
3842
  return this.core.effects.emit(CheckoutHooks.OnOrderSynced, {
3766
3843
  orderUuid: this.store.currentOrder.uuid,
3767
3844
  realOrderId: realOrderId,
@@ -3787,12 +3864,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3787
3864
  }
3788
3865
 
3789
3866
  // 返回真实订单ID
3790
- return _context46.abrupt("return", realOrderId);
3867
+ return _context48.abrupt("return", realOrderId);
3791
3868
  case 60:
3792
3869
  case "end":
3793
- return _context46.stop();
3870
+ return _context48.stop();
3794
3871
  }
3795
- }, _callee46, this, [[39, 47]]);
3872
+ }, _callee48, this, [[39, 47]]);
3796
3873
  }));
3797
3874
  function syncOrderToBackendWithReturn() {
3798
3875
  return _syncOrderToBackendWithReturn.apply(this, arguments);
@@ -3802,27 +3879,27 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3802
3879
  }, {
3803
3880
  key: "syncOrderToBackend",
3804
3881
  value: function () {
3805
- var _syncOrderToBackend = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
3806
- return _regeneratorRuntime().wrap(function _callee47$(_context47) {
3807
- while (1) switch (_context47.prev = _context47.next) {
3882
+ var _syncOrderToBackend = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49() {
3883
+ return _regeneratorRuntime().wrap(function _callee49$(_context49) {
3884
+ while (1) switch (_context49.prev = _context49.next) {
3808
3885
  case 0:
3809
- _context47.prev = 0;
3810
- _context47.next = 3;
3886
+ _context49.prev = 0;
3887
+ _context49.next = 3;
3811
3888
  return this.syncOrderToBackendWithReturn(false);
3812
3889
  case 3:
3813
- _context47.next = 10;
3890
+ _context49.next = 10;
3814
3891
  break;
3815
3892
  case 5:
3816
- _context47.prev = 5;
3817
- _context47.t0 = _context47["catch"](0);
3818
- console.error('[Checkout] 同步订单到后端失败:', _context47.t0);
3819
- _context47.next = 10;
3820
- return this.handleError(new Error("\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(_context47.t0 instanceof Error ? _context47.t0.message : String(_context47.t0))), CheckoutErrorType.OrderCreationFailed);
3893
+ _context49.prev = 5;
3894
+ _context49.t0 = _context49["catch"](0);
3895
+ console.error('[Checkout] 同步订单到后端失败:', _context49.t0);
3896
+ _context49.next = 10;
3897
+ return this.handleError(new Error("\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(_context49.t0 instanceof Error ? _context49.t0.message : String(_context49.t0))), CheckoutErrorType.OrderCreationFailed);
3821
3898
  case 10:
3822
3899
  case "end":
3823
- return _context47.stop();
3900
+ return _context49.stop();
3824
3901
  }
3825
- }, _callee47, this, [[0, 5]]);
3902
+ }, _callee49, this, [[0, 5]]);
3826
3903
  }));
3827
3904
  function syncOrderToBackend() {
3828
3905
  return _syncOrderToBackend.apply(this, arguments);
@@ -3862,15 +3939,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3862
3939
  }, {
3863
3940
  key: "setOtherParams",
3864
3941
  value: function () {
3865
- var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
3866
- var _ref3,
3867
- _ref3$cover,
3942
+ var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
3943
+ var _ref5,
3944
+ _ref5$cover,
3868
3945
  cover,
3869
- _args48 = arguments;
3870
- return _regeneratorRuntime().wrap(function _callee48$(_context48) {
3871
- while (1) switch (_context48.prev = _context48.next) {
3946
+ _args50 = arguments;
3947
+ return _regeneratorRuntime().wrap(function _callee50$(_context50) {
3948
+ while (1) switch (_context50.prev = _context50.next) {
3872
3949
  case 0:
3873
- _ref3 = _args48.length > 1 && _args48[1] !== undefined ? _args48[1] : {}, _ref3$cover = _ref3.cover, cover = _ref3$cover === void 0 ? false : _ref3$cover;
3950
+ _ref5 = _args50.length > 1 && _args50[1] !== undefined ? _args50[1] : {}, _ref5$cover = _ref5.cover, cover = _ref5$cover === void 0 ? false : _ref5$cover;
3874
3951
  if (cover) {
3875
3952
  this.otherParams = params;
3876
3953
  } else {
@@ -3878,20 +3955,20 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3878
3955
  }
3879
3956
  case 2:
3880
3957
  case "end":
3881
- return _context48.stop();
3958
+ return _context50.stop();
3882
3959
  }
3883
- }, _callee48, this);
3960
+ }, _callee50, this);
3884
3961
  }));
3885
- function setOtherParams(_x30) {
3962
+ function setOtherParams(_x32) {
3886
3963
  return _setOtherParams.apply(this, arguments);
3887
3964
  }
3888
3965
  return setOtherParams;
3889
3966
  }()
3890
3967
  /**
3891
3968
  * 通过订单ID编辑订单备注
3892
- *
3969
+ *
3893
3970
  * 用于修改已同步到后端的订单备注,通常在支付成功后的弹窗中使用
3894
- *
3971
+ *
3895
3972
  * @param orderId 后端订单ID
3896
3973
  * @param note 新的订单备注
3897
3974
  * @returns 修改结果
@@ -3899,12 +3976,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3899
3976
  }, {
3900
3977
  key: "editOrderNoteByOrderIdAsync",
3901
3978
  value: (function () {
3902
- var _editOrderNoteByOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(orderId, note) {
3979
+ var _editOrderNoteByOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(orderId, note) {
3903
3980
  var response, previousNote, errorMessage, _errorMessage;
3904
- return _regeneratorRuntime().wrap(function _callee49$(_context49) {
3905
- while (1) switch (_context49.prev = _context49.next) {
3981
+ return _regeneratorRuntime().wrap(function _callee51$(_context51) {
3982
+ while (1) switch (_context51.prev = _context51.next) {
3906
3983
  case 0:
3907
- _context49.prev = 0;
3984
+ _context51.prev = 0;
3908
3985
  console.log('[Checkout] 开始编辑订单备注:', {
3909
3986
  orderId: orderId,
3910
3987
  note: note,
@@ -3913,21 +3990,21 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3913
3990
 
3914
3991
  // 参数验证
3915
3992
  if (orderId) {
3916
- _context49.next = 4;
3993
+ _context51.next = 4;
3917
3994
  break;
3918
3995
  }
3919
- return _context49.abrupt("return", {
3996
+ return _context51.abrupt("return", {
3920
3997
  success: false,
3921
3998
  message: '订单ID不能为空',
3922
3999
  orderId: orderId
3923
4000
  });
3924
4001
  case 4:
3925
- _context49.next = 6;
4002
+ _context51.next = 6;
3926
4003
  return this.request.put("/shop/order/order/".concat(orderId, "/note"), {
3927
4004
  note: note
3928
4005
  });
3929
4006
  case 6:
3930
- response = _context49.sent;
4007
+ response = _context51.sent;
3931
4008
  console.log('[Checkout] 订单备注编辑响应:', {
3932
4009
  orderId: orderId,
3933
4010
  status: response.status,
@@ -3937,14 +4014,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3937
4014
 
3938
4015
  // 检查响应状态
3939
4016
  if (!(response.status === true || response.status === 200)) {
3940
- _context49.next = 19;
4017
+ _context51.next = 19;
3941
4018
  break;
3942
4019
  }
3943
4020
  console.log("[Checkout] \u8BA2\u5355 ".concat(orderId, " \u5907\u6CE8\u4FEE\u6539\u6210\u529F"));
3944
4021
 
3945
4022
  // 如果当前订单就是被修改的订单,同时更新本地状态
3946
4023
  if (!(this.store.currentOrder && (String(this.store.currentOrder.order_id) === String(orderId) || String(this.store.currentOrder.id) === String(orderId)))) {
3947
- _context49.next = 16;
4024
+ _context51.next = 16;
3948
4025
  break;
3949
4026
  }
3950
4027
  console.log('[Checkout] 更新本地订单备注状态');
@@ -3956,7 +4033,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3956
4033
  }
3957
4034
 
3958
4035
  // 触发订单备注变更事件
3959
- _context49.next = 16;
4036
+ _context51.next = 16;
3960
4037
  return this.core.effects.emit(CheckoutHooks.OnOrderNoteChanged, {
3961
4038
  orderUuid: this.store.currentOrder.uuid,
3962
4039
  oldNote: previousNote,
@@ -3964,7 +4041,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3964
4041
  timestamp: Date.now()
3965
4042
  });
3966
4043
  case 16:
3967
- return _context49.abrupt("return", {
4044
+ return _context51.abrupt("return", {
3968
4045
  success: true,
3969
4046
  message: response.message || '订单备注修改成功',
3970
4047
  orderId: orderId
@@ -3973,40 +4050,40 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
3973
4050
  // API返回失败状态
3974
4051
  errorMessage = response.message || '订单备注修改失败';
3975
4052
  console.error("[Checkout] \u8BA2\u5355 ".concat(orderId, " \u5907\u6CE8\u4FEE\u6539\u5931\u8D25:"), errorMessage);
3976
- return _context49.abrupt("return", {
4053
+ return _context51.abrupt("return", {
3977
4054
  success: false,
3978
4055
  message: errorMessage,
3979
4056
  orderId: orderId
3980
4057
  });
3981
4058
  case 22:
3982
- _context49.next = 29;
4059
+ _context51.next = 29;
3983
4060
  break;
3984
4061
  case 24:
3985
- _context49.prev = 24;
3986
- _context49.t0 = _context49["catch"](0);
3987
- console.error('[Checkout] 编辑订单备注失败:', _context49.t0);
3988
- _errorMessage = _context49.t0 instanceof Error ? _context49.t0.message : '网络错误或服务器异常';
3989
- return _context49.abrupt("return", {
4062
+ _context51.prev = 24;
4063
+ _context51.t0 = _context51["catch"](0);
4064
+ console.error('[Checkout] 编辑订单备注失败:', _context51.t0);
4065
+ _errorMessage = _context51.t0 instanceof Error ? _context51.t0.message : '网络错误或服务器异常';
4066
+ return _context51.abrupt("return", {
3990
4067
  success: false,
3991
4068
  message: "\u7F16\u8F91\u8BA2\u5355\u5907\u6CE8\u5931\u8D25: ".concat(_errorMessage),
3992
4069
  orderId: orderId
3993
4070
  });
3994
4071
  case 29:
3995
4072
  case "end":
3996
- return _context49.stop();
4073
+ return _context51.stop();
3997
4074
  }
3998
- }, _callee49, this, [[0, 24]]);
4075
+ }, _callee51, this, [[0, 24]]);
3999
4076
  }));
4000
- function editOrderNoteByOrderIdAsync(_x31, _x32) {
4077
+ function editOrderNoteByOrderIdAsync(_x33, _x34) {
4001
4078
  return _editOrderNoteByOrderIdAsync.apply(this, arguments);
4002
4079
  }
4003
4080
  return editOrderNoteByOrderIdAsync;
4004
4081
  }()
4005
4082
  /**
4006
4083
  * 发送客户支付链接邮件
4007
- *
4084
+ *
4008
4085
  * 向指定邮箱发送订单支付提醒邮件
4009
- *
4086
+ *
4010
4087
  * @param params 发送参数
4011
4088
  * @returns 发送结果
4012
4089
  */
@@ -4014,12 +4091,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4014
4091
  }, {
4015
4092
  key: "sendCustomerPayLinkAsync",
4016
4093
  value: (function () {
4017
- var _sendCustomerPayLinkAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
4094
+ var _sendCustomerPayLinkAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
4018
4095
  var emailRegex, invalidEmails, requestBody, response, errorMessage, _errorMessage2;
4019
- return _regeneratorRuntime().wrap(function _callee50$(_context50) {
4020
- while (1) switch (_context50.prev = _context50.next) {
4096
+ return _regeneratorRuntime().wrap(function _callee52$(_context52) {
4097
+ while (1) switch (_context52.prev = _context52.next) {
4021
4098
  case 0:
4022
- _context50.prev = 0;
4099
+ _context52.prev = 0;
4023
4100
  console.log('[Checkout] 开始发送客户支付链接邮件:', {
4024
4101
  orderIds: params.order_ids,
4025
4102
  emails: params.emails,
@@ -4028,19 +4105,19 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4028
4105
 
4029
4106
  // 参数验证
4030
4107
  if (!(!params.order_ids || params.order_ids.length === 0)) {
4031
- _context50.next = 4;
4108
+ _context52.next = 4;
4032
4109
  break;
4033
4110
  }
4034
- return _context50.abrupt("return", {
4111
+ return _context52.abrupt("return", {
4035
4112
  success: false,
4036
4113
  message: '订单ID列表不能为空'
4037
4114
  });
4038
4115
  case 4:
4039
4116
  if (!(!params.emails || params.emails.length === 0)) {
4040
- _context50.next = 6;
4117
+ _context52.next = 6;
4041
4118
  break;
4042
4119
  }
4043
- return _context50.abrupt("return", {
4120
+ return _context52.abrupt("return", {
4044
4121
  success: false,
4045
4122
  message: '邮箱地址列表不能为空'
4046
4123
  });
@@ -4051,10 +4128,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4051
4128
  return !emailRegex.test(email);
4052
4129
  });
4053
4130
  if (!(invalidEmails.length > 0)) {
4054
- _context50.next = 10;
4131
+ _context52.next = 10;
4055
4132
  break;
4056
4133
  }
4057
- return _context50.abrupt("return", {
4134
+ return _context52.abrupt("return", {
4058
4135
  success: false,
4059
4136
  message: "\u90AE\u7BB1\u683C\u5F0F\u65E0\u6548: ".concat(invalidEmails.join(', '))
4060
4137
  });
@@ -4068,10 +4145,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4068
4145
  console.log('[Checkout] 发送支付链接邮件请求参数:', requestBody);
4069
4146
 
4070
4147
  // 调用后端API发送邮件
4071
- _context50.next = 14;
4148
+ _context52.next = 14;
4072
4149
  return this.request.post('/order/batch-email', requestBody);
4073
4150
  case 14:
4074
- response = _context50.sent;
4151
+ response = _context52.sent;
4075
4152
  console.log('[Checkout] 支付链接邮件发送响应:', {
4076
4153
  status: response.status,
4077
4154
  message: response.message,
@@ -4081,11 +4158,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4081
4158
 
4082
4159
  // 检查响应状态
4083
4160
  if (!(response.status === true || response.status === 200)) {
4084
- _context50.next = 21;
4161
+ _context52.next = 21;
4085
4162
  break;
4086
4163
  }
4087
4164
  console.log('[Checkout] 支付链接邮件发送成功');
4088
- return _context50.abrupt("return", {
4165
+ return _context52.abrupt("return", {
4089
4166
  success: true,
4090
4167
  message: response.message || '支付链接邮件发送成功'
4091
4168
  });
@@ -4093,36 +4170,36 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4093
4170
  // API返回失败状态
4094
4171
  errorMessage = response.message || '支付链接邮件发送失败';
4095
4172
  console.error('[Checkout] 支付链接邮件发送失败:', errorMessage);
4096
- return _context50.abrupt("return", {
4173
+ return _context52.abrupt("return", {
4097
4174
  success: false,
4098
4175
  message: errorMessage
4099
4176
  });
4100
4177
  case 24:
4101
- _context50.next = 31;
4178
+ _context52.next = 31;
4102
4179
  break;
4103
4180
  case 26:
4104
- _context50.prev = 26;
4105
- _context50.t0 = _context50["catch"](0);
4106
- console.error('[Checkout] 发送客户支付链接邮件失败:', _context50.t0);
4107
- _errorMessage2 = _context50.t0 instanceof Error ? _context50.t0.message : '网络错误或服务器异常';
4108
- return _context50.abrupt("return", {
4181
+ _context52.prev = 26;
4182
+ _context52.t0 = _context52["catch"](0);
4183
+ console.error('[Checkout] 发送客户支付链接邮件失败:', _context52.t0);
4184
+ _errorMessage2 = _context52.t0 instanceof Error ? _context52.t0.message : '网络错误或服务器异常';
4185
+ return _context52.abrupt("return", {
4109
4186
  success: false,
4110
4187
  message: "\u53D1\u9001\u652F\u4ED8\u94FE\u63A5\u90AE\u4EF6\u5931\u8D25: ".concat(_errorMessage2)
4111
4188
  });
4112
4189
  case 31:
4113
4190
  case "end":
4114
- return _context50.stop();
4191
+ return _context52.stop();
4115
4192
  }
4116
- }, _callee50, this, [[0, 26]]);
4193
+ }, _callee52, this, [[0, 26]]);
4117
4194
  }));
4118
- function sendCustomerPayLinkAsync(_x33) {
4195
+ function sendCustomerPayLinkAsync(_x35) {
4119
4196
  return _sendCustomerPayLinkAsync.apply(this, arguments);
4120
4197
  }
4121
4198
  return sendCustomerPayLinkAsync;
4122
4199
  }()
4123
4200
  /**
4124
4201
  * 金额舍入
4125
- *
4202
+ *
4126
4203
  * @param amount 原始金额
4127
4204
  * @returns 舍入结果详情,包含原始金额、舍入后金额和舍入差额
4128
4205
  */
@@ -4130,25 +4207,25 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4130
4207
  }, {
4131
4208
  key: "roundAmountAsync",
4132
4209
  value: (function () {
4133
- var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(amount) {
4210
+ var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(amount) {
4134
4211
  var _this$otherParams$ord, _this$otherParams$ord2;
4135
4212
  var result;
4136
- return _regeneratorRuntime().wrap(function _callee51$(_context51) {
4137
- while (1) switch (_context51.prev = _context51.next) {
4213
+ return _regeneratorRuntime().wrap(function _callee53$(_context53) {
4214
+ while (1) switch (_context53.prev = _context53.next) {
4138
4215
  case 0:
4139
- _context51.next = 2;
4216
+ _context53.next = 2;
4140
4217
  return this.payment.roundAmountAsync(amount, (_this$otherParams$ord = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord === void 0 ? void 0 : _this$otherParams$ord.interval, (_this$otherParams$ord2 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord2 === void 0 ? void 0 : _this$otherParams$ord2.type);
4141
4218
  case 2:
4142
- result = _context51.sent;
4219
+ result = _context53.sent;
4143
4220
  console.log("[Checkout] \u91D1\u989D\u820D\u5165\u5B8C\u6210 - \u539F\u59CB: ".concat(result.originalAmount, ", \u820D\u5165\u540E: ").concat(result.roundedAmount, ", \u5DEE\u989D: ").concat(result.roundingDifference));
4144
- return _context51.abrupt("return", result);
4221
+ return _context53.abrupt("return", result);
4145
4222
  case 5:
4146
4223
  case "end":
4147
- return _context51.stop();
4224
+ return _context53.stop();
4148
4225
  }
4149
- }, _callee51, this);
4226
+ }, _callee53, this);
4150
4227
  }));
4151
- function roundAmountAsync(_x34) {
4228
+ function roundAmountAsync(_x36) {
4152
4229
  return _roundAmountAsync.apply(this, arguments);
4153
4230
  }
4154
4231
  return roundAmountAsync;
@@ -4156,10 +4233,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4156
4233
  }, {
4157
4234
  key: "destroy",
4158
4235
  value: function () {
4159
- var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52() {
4236
+ var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54() {
4160
4237
  var _this$order, _this$order$destroy, _this$payment, _this$payment$destroy;
4161
- return _regeneratorRuntime().wrap(function _callee52$(_context52) {
4162
- while (1) switch (_context52.prev = _context52.next) {
4238
+ return _regeneratorRuntime().wrap(function _callee54$(_context54) {
4239
+ while (1) switch (_context54.prev = _context54.next) {
4163
4240
  case 0:
4164
4241
  // 清理钱包模块的所有缓存数据
4165
4242
  this.payment.wallet.clearAllCache();
@@ -4168,10 +4245,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4168
4245
  this.core.effects.offByModuleDestroy(this.name);
4169
4246
 
4170
4247
  // 销毁子模块
4171
- _context52.next = 4;
4248
+ _context54.next = 4;
4172
4249
  return (_this$order = this.order) === null || _this$order === void 0 || (_this$order$destroy = _this$order.destroy) === null || _this$order$destroy === void 0 ? void 0 : _this$order$destroy.call(_this$order);
4173
4250
  case 4:
4174
- _context52.next = 6;
4251
+ _context54.next = 6;
4175
4252
  return (_this$payment = this.payment) === null || _this$payment === void 0 || (_this$payment$destroy = _this$payment.destroy) === null || _this$payment$destroy === void 0 ? void 0 : _this$payment$destroy.call(_this$payment);
4176
4253
  case 6:
4177
4254
  // 取消注册模块
@@ -4179,15 +4256,136 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
4179
4256
  console.log('[Checkout] 已销毁');
4180
4257
  case 8:
4181
4258
  case "end":
4182
- return _context52.stop();
4259
+ return _context54.stop();
4183
4260
  }
4184
- }, _callee52, this);
4261
+ }, _callee54, this);
4185
4262
  }));
4186
4263
  function destroy() {
4187
4264
  return _destroy.apply(this, arguments);
4188
4265
  }
4189
4266
  return destroy;
4190
4267
  }()
4268
+ /**
4269
+ * 重置 store 状态
4270
+ *
4271
+ * 在创建新订单前调用,确保状态完全干净
4272
+ */
4273
+ }, {
4274
+ key: "resetStoreStateAsync",
4275
+ value: (function () {
4276
+ var _resetStoreStateAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55() {
4277
+ var prevOrderInfo;
4278
+ return _regeneratorRuntime().wrap(function _callee55$(_context55) {
4279
+ while (1) switch (_context55.prev = _context55.next) {
4280
+ case 0:
4281
+ _context55.prev = 0;
4282
+ prevOrderInfo = this.store.currentOrder ? {
4283
+ uuid: this.store.currentOrder.uuid,
4284
+ orderId: this.store.currentOrder.order_id
4285
+ } : null;
4286
+ console.log('[Checkout] 重置 store 状态,准备创建新订单', prevOrderInfo);
4287
+
4288
+ // 重置订单相关的 store 状态(保留 paymentMethods,因为支付方式数据变更不频繁)
4289
+ this.store.currentOrder = undefined;
4290
+ this.store.localOrderData = undefined;
4291
+ this.store.cartSummary = undefined;
4292
+ this.store.stateAmount = '0.00';
4293
+ this.store.isOrderSynced = false;
4294
+ this.store.currentCustomer = undefined;
4295
+ this.store.lastError = undefined;
4296
+
4297
+ // 清空购物车项目
4298
+ this.store.cartItems = [];
4299
+
4300
+ // 注意:故意保留 this.store.paymentMethods,因为支付方式数据不易变更,保留在内存中提高性能
4301
+
4302
+ // 重置状态和步骤为初始状态
4303
+ _context55.next = 13;
4304
+ return this.setStatus(CheckoutStatus.Ready);
4305
+ case 13:
4306
+ _context55.next = 15;
4307
+ return this.setStep(CheckoutStep.OrderConfirmation);
4308
+ case 15:
4309
+ // 清理钱包缓存
4310
+ this.payment.wallet.clearAllCache();
4311
+ console.log('[Checkout] Store 状态重置完成');
4312
+
4313
+ // 触发订单清理事件(如果之前有订单)
4314
+ if (!prevOrderInfo) {
4315
+ _context55.next = 20;
4316
+ break;
4317
+ }
4318
+ _context55.next = 20;
4319
+ return this.core.effects.emit(CheckoutHooks.OnOrderCleared, {
4320
+ previousOrder: prevOrderInfo,
4321
+ timestamp: Date.now()
4322
+ });
4323
+ case 20:
4324
+ _context55.next = 25;
4325
+ break;
4326
+ case 22:
4327
+ _context55.prev = 22;
4328
+ _context55.t0 = _context55["catch"](0);
4329
+ console.error('[Checkout] 重置 store 状态失败:', _context55.t0);
4330
+ case 25:
4331
+ case "end":
4332
+ return _context55.stop();
4333
+ }
4334
+ }, _callee55, this, [[0, 22]]);
4335
+ }));
4336
+ function resetStoreStateAsync() {
4337
+ return _resetStoreStateAsync.apply(this, arguments);
4338
+ }
4339
+ return resetStoreStateAsync;
4340
+ }()
4341
+ /**
4342
+ * 手动清理已完成的订单状态(公开方法)
4343
+ *
4344
+ * 供UI层调用的公开方法,用于手动清理订单状态
4345
+ *
4346
+ * @returns 清理结果
4347
+ */
4348
+ )
4349
+ }, {
4350
+ key: "clearCompletedOrderAsync",
4351
+ value: (function () {
4352
+ var _clearCompletedOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56() {
4353
+ var prevOrderInfo;
4354
+ return _regeneratorRuntime().wrap(function _callee56$(_context56) {
4355
+ while (1) switch (_context56.prev = _context56.next) {
4356
+ case 0:
4357
+ _context56.prev = 0;
4358
+ prevOrderInfo = this.store.currentOrder ? {
4359
+ uuid: this.store.currentOrder.uuid,
4360
+ orderId: this.store.currentOrder.order_id
4361
+ } : null;
4362
+ _context56.next = 4;
4363
+ return this.resetStoreStateAsync();
4364
+ case 4:
4365
+ return _context56.abrupt("return", {
4366
+ success: true,
4367
+ message: prevOrderInfo ? '订单状态已成功清理' : '没有需要清理的订单状态',
4368
+ clearedOrder: prevOrderInfo
4369
+ });
4370
+ case 7:
4371
+ _context56.prev = 7;
4372
+ _context56.t0 = _context56["catch"](0);
4373
+ console.error('[Checkout] 手动清理订单状态失败:', _context56.t0);
4374
+ return _context56.abrupt("return", {
4375
+ success: false,
4376
+ message: _context56.t0 instanceof Error ? _context56.t0.message : '清理失败'
4377
+ });
4378
+ case 11:
4379
+ case "end":
4380
+ return _context56.stop();
4381
+ }
4382
+ }, _callee56, this, [[0, 7]]);
4383
+ }));
4384
+ function clearCompletedOrderAsync() {
4385
+ return _clearCompletedOrderAsync.apply(this, arguments);
4386
+ }
4387
+ return clearCompletedOrderAsync;
4388
+ }())
4191
4389
  }]);
4192
4390
  return CheckoutImpl;
4193
4391
  }(BaseModule);