@pisell/pisellos 2.2.152 → 2.2.154

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/dist/core/index.js +1 -0
  2. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  3. package/dist/modules/Cart/utils/cartProduct.js +1 -1
  4. package/dist/modules/Discount/index.d.ts +6 -2
  5. package/dist/modules/Discount/index.js +14 -8
  6. package/dist/modules/Order/index.d.ts +2 -0
  7. package/dist/modules/Order/index.js +234 -161
  8. package/dist/modules/Order/types.d.ts +19 -0
  9. package/dist/modules/Order/utils.js +7 -6
  10. package/dist/modules/Payment/index.d.ts +4 -0
  11. package/dist/modules/Payment/index.js +567 -505
  12. package/dist/modules/Payment/types.d.ts +29 -9
  13. package/dist/modules/SalesSummary/index.d.ts +7 -5
  14. package/dist/modules/SalesSummary/index.js +35 -11
  15. package/dist/plugins/app.d.ts +2 -0
  16. package/dist/server/index.d.ts +2 -5
  17. package/dist/server/index.js +58 -66
  18. package/dist/server/modules/index.d.ts +1 -1
  19. package/dist/server/modules/products/index.d.ts +12 -1
  20. package/dist/server/modules/products/index.js +169 -78
  21. package/dist/server/modules/products/types.d.ts +11 -0
  22. package/dist/server/modules/products/types.js +4 -0
  23. package/dist/server/utils/product.js +2 -2
  24. package/dist/solution/BaseSales/index.d.ts +26 -2
  25. package/dist/solution/BaseSales/index.js +342 -112
  26. package/dist/solution/BaseSales/types.d.ts +4 -4
  27. package/dist/solution/BaseSales/types.js +4 -4
  28. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +62 -0
  29. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +116 -0
  30. package/dist/solution/BaseSales/utils.js +3 -3
  31. package/dist/solution/BookingByStep/index.d.ts +1 -1
  32. package/dist/solution/BookingTicket/index.d.ts +11 -13
  33. package/dist/solution/BookingTicket/index.js +23 -37
  34. package/dist/solution/BookingTicket/types.d.ts +9 -6
  35. package/dist/solution/BookingTicket/types.js +6 -3
  36. package/dist/solution/BookingTicket/utils/cartView.d.ts +7 -12
  37. package/dist/solution/BookingTicket/utils/cartView.js +52 -14
  38. package/dist/solution/BookingTicket/utils/orderCustomer.d.ts +4 -0
  39. package/dist/solution/BookingTicket/utils/orderCustomer.js +31 -0
  40. package/dist/solution/Sales/index.d.ts +3 -0
  41. package/dist/solution/Sales/index.js +85 -43
  42. package/dist/solution/Sales/types.d.ts +3 -0
  43. package/dist/solution/ScanOrder/types.d.ts +4 -4
  44. package/dist/solution/ScanOrder/types.js +4 -4
  45. package/dist/solution/ScanOrder/utils.js +3 -3
  46. package/dist/solution/ShopDiscount/index.d.ts +2 -1
  47. package/dist/solution/ShopDiscount/index.js +32 -20
  48. package/dist/solution/ShopDiscount/types.d.ts +1 -0
  49. package/lib/core/index.js +1 -0
  50. package/lib/modules/Cart/utils/cartProduct.js +1 -1
  51. package/lib/modules/Discount/index.d.ts +6 -2
  52. package/lib/modules/Discount/index.js +3 -1
  53. package/lib/modules/Order/index.d.ts +2 -0
  54. package/lib/modules/Order/index.js +40 -8
  55. package/lib/modules/Order/types.d.ts +19 -0
  56. package/lib/modules/Order/utils.js +4 -2
  57. package/lib/modules/Payment/index.d.ts +4 -0
  58. package/lib/modules/Payment/index.js +26 -2
  59. package/lib/modules/Payment/types.d.ts +29 -9
  60. package/lib/modules/SalesSummary/index.d.ts +7 -5
  61. package/lib/modules/SalesSummary/index.js +29 -9
  62. package/lib/plugins/app.d.ts +2 -0
  63. package/lib/server/index.d.ts +2 -5
  64. package/lib/server/index.js +38 -58
  65. package/lib/server/modules/index.d.ts +1 -1
  66. package/lib/server/modules/products/index.d.ts +12 -1
  67. package/lib/server/modules/products/index.js +69 -9
  68. package/lib/server/modules/products/types.d.ts +11 -0
  69. package/lib/server/utils/product.js +2 -2
  70. package/lib/solution/BaseSales/index.d.ts +26 -2
  71. package/lib/solution/BaseSales/index.js +169 -3
  72. package/lib/solution/BaseSales/types.d.ts +4 -4
  73. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +62 -0
  74. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +155 -0
  75. package/lib/solution/BaseSales/utils.js +3 -3
  76. package/lib/solution/BookingByStep/index.d.ts +1 -1
  77. package/lib/solution/BookingTicket/index.d.ts +11 -13
  78. package/lib/solution/BookingTicket/index.js +17 -27
  79. package/lib/solution/BookingTicket/types.d.ts +9 -6
  80. package/lib/solution/BookingTicket/utils/cartView.d.ts +7 -12
  81. package/lib/solution/BookingTicket/utils/cartView.js +44 -18
  82. package/lib/solution/BookingTicket/utils/orderCustomer.d.ts +4 -0
  83. package/lib/solution/BookingTicket/utils/orderCustomer.js +58 -0
  84. package/lib/solution/Sales/index.d.ts +3 -0
  85. package/lib/solution/Sales/index.js +50 -15
  86. package/lib/solution/Sales/types.d.ts +3 -0
  87. package/lib/solution/ScanOrder/types.d.ts +4 -4
  88. package/lib/solution/ScanOrder/utils.js +3 -3
  89. package/lib/solution/ShopDiscount/index.d.ts +2 -1
  90. package/lib/solution/ShopDiscount/index.js +10 -4
  91. package/lib/solution/ShopDiscount/types.d.ts +1 -0
  92. package/package.json +1 -1
@@ -110,6 +110,9 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
110
110
  _defineProperty(_assertThisInitialized(_this), "logger", void 0);
111
111
  // LoggerManager 实例
112
112
  _defineProperty(_assertThisInitialized(_this), "voucherUpdateLockByOrderUuid", new Map());
113
+ _defineProperty(_assertThisInitialized(_this), "payMethodMemoryCache", null);
114
+ _defineProperty(_assertThisInitialized(_this), "payMethodListInFlight", null);
115
+ _defineProperty(_assertThisInitialized(_this), "isRefreshingPaymentMethods", false);
113
116
  _defineProperty(_assertThisInitialized(_this), "otherParams", {});
114
117
  // 支付方式实例
115
118
  _defineProperty(_assertThisInitialized(_this), "cash", void 0);
@@ -375,129 +378,184 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
375
378
  key: "getPayMethodListAsync",
376
379
  value: (function () {
377
380
  var _getPayMethodListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
378
- var cachedMethods, hasCache, response, payMethods, _iterator2, _step2, method;
381
+ var _this$payMethodMemory,
382
+ _this4 = this;
379
383
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
380
384
  while (1) switch (_context4.prev = _context4.next) {
381
385
  case 0:
382
386
  this.logInfo('Starting getPayMethodListAsync');
383
- _context4.prev = 1;
387
+ if (!((_this$payMethodMemory = this.payMethodMemoryCache) !== null && _this$payMethodMemory !== void 0 && _this$payMethodMemory.length)) {
388
+ _context4.next = 3;
389
+ break;
390
+ }
391
+ return _context4.abrupt("return", this.payMethodMemoryCache);
392
+ case 3:
393
+ if (!this.payMethodListInFlight) {
394
+ _context4.next = 5;
395
+ break;
396
+ }
397
+ return _context4.abrupt("return", this.payMethodListInFlight);
398
+ case 5:
399
+ this.payMethodListInFlight = this.loadPayMethodListAsync().finally(function () {
400
+ _this4.payMethodListInFlight = null;
401
+ });
402
+ return _context4.abrupt("return", this.payMethodListInFlight);
403
+ case 7:
404
+ case "end":
405
+ return _context4.stop();
406
+ }
407
+ }, _callee4, this);
408
+ }));
409
+ function getPayMethodListAsync() {
410
+ return _getPayMethodListAsync.apply(this, arguments);
411
+ }
412
+ return getPayMethodListAsync;
413
+ }())
414
+ }, {
415
+ key: "loadPayMethodListAsync",
416
+ value: function () {
417
+ var _loadPayMethodListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
418
+ var cachedMethods, hasCache, response, payMethods, _iterator2, _step2, method;
419
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
420
+ while (1) switch (_context5.prev = _context5.next) {
421
+ case 0:
422
+ _context5.prev = 0;
384
423
  // 先尝试从 IndexDB 获取缓存
385
424
  cachedMethods = [];
386
- _context4.prev = 3;
387
- _context4.next = 6;
425
+ _context5.prev = 2;
426
+ _context5.next = 5;
388
427
  return this.dbManager.getAll('pay_method');
389
- case 6:
390
- cachedMethods = _context4.sent;
391
- _context4.next = 12;
428
+ case 5:
429
+ cachedMethods = _context5.sent;
430
+ _context5.next = 11;
392
431
  break;
393
- case 9:
394
- _context4.prev = 9;
395
- _context4.t0 = _context4["catch"](3);
432
+ case 8:
433
+ _context5.prev = 8;
434
+ _context5.t0 = _context5["catch"](2);
396
435
  console.warn('[PaymentModule] pay_method 表不存在,将从服务器获取数据');
397
- case 12:
436
+ case 11:
398
437
  // 如果有缓存,先返回缓存数据
399
438
  hasCache = cachedMethods.length > 0;
400
439
  if (!hasCache) {
401
- _context4.next = 16;
440
+ _context5.next = 16;
402
441
  break;
403
442
  }
443
+ this.payMethodMemoryCache = cachedMethods;
404
444
  // 后台异步获取最新数据
405
445
  this.refreshPaymentMethodsInBackground(cachedMethods);
406
- return _context4.abrupt("return", cachedMethods);
446
+ return _context5.abrupt("return", cachedMethods);
407
447
  case 16:
408
- _context4.next = 18;
448
+ _context5.next = 18;
409
449
  return this.request.get('/pay/custom-payment/all');
410
450
  case 18:
411
- response = _context4.sent;
412
- response.data = this.filterPayMethods(response.data);
413
- payMethods = response.data || []; // 尝试缓存到 IndexDB
414
- _context4.prev = 21;
451
+ response = _context5.sent;
452
+ _context5.next = 21;
453
+ return this.filterPayMethods(response.data);
454
+ case 21:
455
+ response.data = _context5.sent;
456
+ payMethods = response.data || [];
457
+ this.payMethodMemoryCache = payMethods;
458
+
459
+ // 尝试缓存到 IndexDB
460
+ _context5.prev = 24;
415
461
  _iterator2 = _createForOfIteratorHelper(payMethods);
416
- _context4.prev = 23;
462
+ _context5.prev = 26;
417
463
  _iterator2.s();
418
- case 25:
464
+ case 28:
419
465
  if ((_step2 = _iterator2.n()).done) {
420
- _context4.next = 31;
466
+ _context5.next = 34;
421
467
  break;
422
468
  }
423
469
  method = _step2.value;
424
- _context4.next = 29;
470
+ _context5.next = 32;
425
471
  return this.dbManager.update('pay_method', method);
426
- case 29:
427
- _context4.next = 25;
472
+ case 32:
473
+ _context5.next = 28;
428
474
  break;
429
- case 31:
430
- _context4.next = 36;
475
+ case 34:
476
+ _context5.next = 39;
431
477
  break;
432
- case 33:
433
- _context4.prev = 33;
434
- _context4.t1 = _context4["catch"](23);
435
- _iterator2.e(_context4.t1);
436
478
  case 36:
437
- _context4.prev = 36;
438
- _iterator2.f();
439
- return _context4.finish(36);
479
+ _context5.prev = 36;
480
+ _context5.t1 = _context5["catch"](26);
481
+ _iterator2.e(_context5.t1);
440
482
  case 39:
441
- _context4.next = 44;
483
+ _context5.prev = 39;
484
+ _iterator2.f();
485
+ return _context5.finish(39);
486
+ case 42:
487
+ _context5.next = 47;
442
488
  break;
443
- case 41:
444
- _context4.prev = 41;
445
- _context4.t2 = _context4["catch"](21);
446
- console.warn('[PaymentModule] 无法缓存支付方式,pay_method 表不存在');
447
489
  case 44:
448
- _context4.next = 46;
490
+ _context5.prev = 44;
491
+ _context5.t2 = _context5["catch"](24);
492
+ console.warn('[PaymentModule] 无法缓存支付方式,pay_method 表不存在');
493
+ case 47:
494
+ _context5.next = 49;
449
495
  return this.core.effects.emit("".concat(this.name, ":onPaymentMethodsLoaded"), payMethods);
450
- case 46:
496
+ case 49:
451
497
  this.logInfo('getPayMethodListAsync completed successfully', {
452
498
  payMethods: payMethods
453
499
  });
454
- return _context4.abrupt("return", payMethods);
455
- case 50:
456
- _context4.prev = 50;
457
- _context4.t3 = _context4["catch"](1);
458
- console.error('[PaymentModule] 获取支付方式列表失败', _context4.t3);
459
- this.logError('getPayMethodListAsync failed', _context4.t3);
500
+ return _context5.abrupt("return", payMethods);
501
+ case 53:
502
+ _context5.prev = 53;
503
+ _context5.t3 = _context5["catch"](0);
504
+ console.error('[PaymentModule] 获取支付方式列表失败', _context5.t3);
505
+ this.logError('getPayMethodListAsync failed', _context5.t3);
460
506
  // 如果所有操作都失败,返回空数组
461
- return _context4.abrupt("return", []);
462
- case 55:
507
+ return _context5.abrupt("return", []);
508
+ case 58:
463
509
  case "end":
464
- return _context4.stop();
510
+ return _context5.stop();
465
511
  }
466
- }, _callee4, this, [[1, 50], [3, 9], [21, 41], [23, 33, 36, 39]]);
512
+ }, _callee5, this, [[0, 53], [2, 8], [24, 44], [26, 36, 39, 42]]);
467
513
  }));
468
- function getPayMethodListAsync() {
469
- return _getPayMethodListAsync.apply(this, arguments);
514
+ function loadPayMethodListAsync() {
515
+ return _loadPayMethodListAsync.apply(this, arguments);
470
516
  }
471
- return getPayMethodListAsync;
517
+ return loadPayMethodListAsync;
472
518
  }()
473
519
  /**
474
520
  * 后台刷新支付方式列表
475
521
  */
476
- )
477
522
  }, {
478
523
  key: "refreshPaymentMethodsInBackground",
479
524
  value: (function () {
480
- var _refreshPaymentMethodsInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(cachedMethods) {
525
+ var _refreshPaymentMethodsInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(cachedMethods) {
481
526
  var response, newPayMethods, hasChanges, _iterator3, _step3, method, _iterator4, _step4, _method, eventData;
482
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
483
- while (1) switch (_context5.prev = _context5.next) {
527
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
528
+ while (1) switch (_context6.prev = _context6.next) {
484
529
  case 0:
530
+ if (!this.isRefreshingPaymentMethods) {
531
+ _context6.next = 2;
532
+ break;
533
+ }
534
+ return _context6.abrupt("return");
535
+ case 2:
536
+ this.isRefreshingPaymentMethods = true;
485
537
  this.logInfo('Starting refreshPaymentMethodsInBackground', {
486
538
  cachedMethodsCount: cachedMethods.length
487
539
  });
488
- _context5.prev = 1;
540
+ _context6.prev = 4;
489
541
  console.log('[PaymentModule] 后台刷新支付方式列表...');
490
542
 
491
543
  // 从服务器获取最新数据
492
- _context5.next = 5;
544
+ _context6.next = 8;
493
545
  return this.request.get('/pay/custom-payment/all');
494
- case 5:
495
- response = _context5.sent;
496
- response.data = this.filterPayMethods(response.data);
497
- newPayMethods = response.data || []; // 检查是否有变化
546
+ case 8:
547
+ response = _context6.sent;
548
+ _context6.next = 11;
549
+ return this.filterPayMethods(response.data);
550
+ case 11:
551
+ response.data = _context6.sent;
552
+ newPayMethods = response.data || [];
553
+ this.payMethodMemoryCache = newPayMethods;
554
+
555
+ // 检查是否有变化
498
556
  hasChanges = this.hasPaymentMethodsChanged(cachedMethods, newPayMethods);
499
557
  if (!hasChanges) {
500
- _context5.next = 57;
558
+ _context6.next = 63;
501
559
  break;
502
560
  }
503
561
  console.log('[PaymentModule] 支付方式列表已更新');
@@ -507,92 +565,96 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
507
565
  });
508
566
 
509
567
  // 更新缓存
510
- _context5.prev = 12;
568
+ _context6.prev = 18;
511
569
  // 先清除旧数据
512
570
  _iterator3 = _createForOfIteratorHelper(cachedMethods);
513
- _context5.prev = 14;
571
+ _context6.prev = 20;
514
572
  _iterator3.s();
515
- case 16:
573
+ case 22:
516
574
  if ((_step3 = _iterator3.n()).done) {
517
- _context5.next = 22;
575
+ _context6.next = 28;
518
576
  break;
519
577
  }
520
578
  method = _step3.value;
521
- _context5.next = 20;
579
+ _context6.next = 26;
522
580
  return this.dbManager.delete('pay_method', method.id);
523
- case 20:
524
- _context5.next = 16;
581
+ case 26:
582
+ _context6.next = 22;
525
583
  break;
526
- case 22:
527
- _context5.next = 27;
584
+ case 28:
585
+ _context6.next = 33;
528
586
  break;
529
- case 24:
530
- _context5.prev = 24;
531
- _context5.t0 = _context5["catch"](14);
532
- _iterator3.e(_context5.t0);
533
- case 27:
534
- _context5.prev = 27;
535
- _iterator3.f();
536
- return _context5.finish(27);
537
587
  case 30:
588
+ _context6.prev = 30;
589
+ _context6.t0 = _context6["catch"](20);
590
+ _iterator3.e(_context6.t0);
591
+ case 33:
592
+ _context6.prev = 33;
593
+ _iterator3.f();
594
+ return _context6.finish(33);
595
+ case 36:
538
596
  // 添加新数据
539
597
  _iterator4 = _createForOfIteratorHelper(newPayMethods);
540
- _context5.prev = 31;
598
+ _context6.prev = 37;
541
599
  _iterator4.s();
542
- case 33:
600
+ case 39:
543
601
  if ((_step4 = _iterator4.n()).done) {
544
- _context5.next = 39;
602
+ _context6.next = 45;
545
603
  break;
546
604
  }
547
605
  _method = _step4.value;
548
- _context5.next = 37;
606
+ _context6.next = 43;
549
607
  return this.dbManager.update('pay_method', _method);
550
- case 37:
551
- _context5.next = 33;
608
+ case 43:
609
+ _context6.next = 39;
552
610
  break;
553
- case 39:
554
- _context5.next = 44;
611
+ case 45:
612
+ _context6.next = 50;
555
613
  break;
556
- case 41:
557
- _context5.prev = 41;
558
- _context5.t1 = _context5["catch"](31);
559
- _iterator4.e(_context5.t1);
560
- case 44:
561
- _context5.prev = 44;
562
- _iterator4.f();
563
- return _context5.finish(44);
564
614
  case 47:
565
- _context5.next = 52;
615
+ _context6.prev = 47;
616
+ _context6.t1 = _context6["catch"](37);
617
+ _iterator4.e(_context6.t1);
618
+ case 50:
619
+ _context6.prev = 50;
620
+ _iterator4.f();
621
+ return _context6.finish(50);
622
+ case 53:
623
+ _context6.next = 58;
566
624
  break;
567
- case 49:
568
- _context5.prev = 49;
569
- _context5.t2 = _context5["catch"](12);
570
- console.warn('[PaymentModule] 无法更新支付方式缓存', _context5.t2);
571
- case 52:
625
+ case 55:
626
+ _context6.prev = 55;
627
+ _context6.t2 = _context6["catch"](18);
628
+ console.warn('[PaymentModule] 无法更新支付方式缓存', _context6.t2);
629
+ case 58:
572
630
  // 通知外部支付方式已变化
573
631
  eventData = {
574
632
  oldMethods: cachedMethods,
575
633
  newMethods: newPayMethods
576
634
  };
577
- _context5.next = 55;
635
+ _context6.next = 61;
578
636
  return this.core.effects.emit("".concat(this.name, ":onPaymentMethodsChanged"), eventData);
579
- case 55:
580
- _context5.next = 58;
637
+ case 61:
638
+ _context6.next = 64;
581
639
  break;
582
- case 57:
640
+ case 63:
583
641
  console.log('[PaymentModule] 支付方式列表无变化');
584
- case 58:
585
- _context5.next = 63;
642
+ case 64:
643
+ _context6.next = 69;
586
644
  break;
587
- case 60:
588
- _context5.prev = 60;
589
- _context5.t3 = _context5["catch"](1);
590
- console.error('[PaymentModule] 后台刷新支付方式失败', _context5.t3);
591
- case 63:
645
+ case 66:
646
+ _context6.prev = 66;
647
+ _context6.t3 = _context6["catch"](4);
648
+ console.error('[PaymentModule] 后台刷新支付方式失败', _context6.t3);
649
+ case 69:
650
+ _context6.prev = 69;
651
+ this.isRefreshingPaymentMethods = false;
652
+ return _context6.finish(69);
653
+ case 72:
592
654
  case "end":
593
- return _context5.stop();
655
+ return _context6.stop();
594
656
  }
595
- }, _callee5, this, [[1, 60], [12, 49], [14, 24, 27, 30], [31, 41, 44, 47]]);
657
+ }, _callee6, this, [[4, 66, 69, 72], [18, 55], [20, 30, 33, 36], [37, 47, 50, 53]]);
596
658
  }));
597
659
  function refreshPaymentMethodsInBackground(_x5) {
598
660
  return _refreshPaymentMethodsInBackground.apply(this, arguments);
@@ -702,25 +764,25 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
702
764
  }, {
703
765
  key: "getOrderListAsync",
704
766
  value: (function () {
705
- var _getOrderListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
706
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
707
- while (1) switch (_context6.prev = _context6.next) {
767
+ var _getOrderListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
768
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
769
+ while (1) switch (_context7.prev = _context7.next) {
708
770
  case 0:
709
- _context6.prev = 0;
710
- _context6.next = 3;
771
+ _context7.prev = 0;
772
+ _context7.next = 3;
711
773
  return this.dbManager.getAll('order');
712
774
  case 3:
713
- return _context6.abrupt("return", _context6.sent);
775
+ return _context7.abrupt("return", _context7.sent);
714
776
  case 6:
715
- _context6.prev = 6;
716
- _context6.t0 = _context6["catch"](0);
717
- console.error('[PaymentModule] 获取订单列表失败', _context6.t0);
718
- return _context6.abrupt("return", []);
777
+ _context7.prev = 6;
778
+ _context7.t0 = _context7["catch"](0);
779
+ console.error('[PaymentModule] 获取订单列表失败', _context7.t0);
780
+ return _context7.abrupt("return", []);
719
781
  case 10:
720
782
  case "end":
721
- return _context6.stop();
783
+ return _context7.stop();
722
784
  }
723
- }, _callee6, this, [[0, 6]]);
785
+ }, _callee7, this, [[0, 6]]);
724
786
  }));
725
787
  function getOrderListAsync() {
726
788
  return _getOrderListAsync.apply(this, arguments);
@@ -734,25 +796,25 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
734
796
  }, {
735
797
  key: "getPaymentOrderByUuidAsync",
736
798
  value: (function () {
737
- var _getPaymentOrderByUuidAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(orderUuid) {
738
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
739
- while (1) switch (_context7.prev = _context7.next) {
799
+ var _getPaymentOrderByUuidAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(orderUuid) {
800
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
801
+ while (1) switch (_context8.prev = _context8.next) {
740
802
  case 0:
741
- _context7.prev = 0;
742
- _context7.next = 3;
803
+ _context8.prev = 0;
804
+ _context8.next = 3;
743
805
  return this.dbManager.get('order', orderUuid, true);
744
806
  case 3:
745
- return _context7.abrupt("return", _context7.sent);
807
+ return _context8.abrupt("return", _context8.sent);
746
808
  case 6:
747
- _context7.prev = 6;
748
- _context7.t0 = _context7["catch"](0);
749
- console.error('[PaymentModule] 获取支付订单失败', _context7.t0);
750
- return _context7.abrupt("return", null);
809
+ _context8.prev = 6;
810
+ _context8.t0 = _context8["catch"](0);
811
+ console.error('[PaymentModule] 获取支付订单失败', _context8.t0);
812
+ return _context8.abrupt("return", null);
751
813
  case 10:
752
814
  case "end":
753
- return _context7.stop();
815
+ return _context8.stop();
754
816
  }
755
- }, _callee7, this, [[0, 6]]);
817
+ }, _callee8, this, [[0, 6]]);
756
818
  }));
757
819
  function getPaymentOrderByUuidAsync(_x6) {
758
820
  return _getPaymentOrderByUuidAsync.apply(this, arguments);
@@ -766,17 +828,17 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
766
828
  }, {
767
829
  key: "createPaymentOrderAsync",
768
830
  value: (function () {
769
- var _createPaymentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
770
- var _this4 = this;
831
+ var _createPaymentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
832
+ var _this5 = this;
771
833
  var newOrder, currentTime, dbAddStartTime, dbAddDuration;
772
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
773
- while (1) switch (_context8.prev = _context8.next) {
834
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
835
+ while (1) switch (_context9.prev = _context9.next) {
774
836
  case 0:
775
837
  this.logInfo('Starting createPaymentOrderAsync', {
776
838
  orderId: params.order_id,
777
839
  totalAmount: params.total_amount
778
840
  });
779
- _context8.prev = 1;
841
+ _context9.prev = 1;
780
842
  // 检测是否有重复的 order_id
781
843
  // console.time('createLocalOrderAsync: getExistingOrder')
782
844
  // const existingOrder = await this.dbManager.get('order', params.order_id);
@@ -862,7 +924,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
862
924
 
863
925
  // 🚀 性能监控:记录数据库添加操作耗时
864
926
  dbAddStartTime = Date.now();
865
- _context8.next = 7;
927
+ _context9.next = 7;
866
928
  return this.dbManager.add('order', newOrder, true);
867
929
  case 7:
868
930
  dbAddDuration = Date.now() - dbAddStartTime;
@@ -875,22 +937,22 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
875
937
  performance: dbAddDuration > 100 ? 'slow' : dbAddDuration > 50 ? 'medium' : 'fast'
876
938
  });
877
939
  setTimeout(function () {
878
- _this4.core.effects.emit("".concat(_this4.name, ":onOrderAdded"), newOrder);
940
+ _this5.core.effects.emit("".concat(_this5.name, ":onOrderAdded"), newOrder);
879
941
  }, 0);
880
- return _context8.abrupt("return", newOrder);
942
+ return _context9.abrupt("return", newOrder);
881
943
  case 13:
882
- _context8.prev = 13;
883
- _context8.t0 = _context8["catch"](1);
884
- console.error('[PaymentModule] 创建支付订单失败', _context8.t0);
885
- this.logError('createPaymentOrderAsync failed', _context8.t0, {
944
+ _context9.prev = 13;
945
+ _context9.t0 = _context9["catch"](1);
946
+ console.error('[PaymentModule] 创建支付订单失败', _context9.t0);
947
+ this.logError('createPaymentOrderAsync failed', _context9.t0, {
886
948
  orderId: params.order_id
887
949
  });
888
- throw _context8.t0;
950
+ throw _context9.t0;
889
951
  case 18:
890
952
  case "end":
891
- return _context8.stop();
953
+ return _context9.stop();
892
954
  }
893
- }, _callee8, this, [[1, 13]]);
955
+ }, _callee9, this, [[1, 13]]);
894
956
  }));
895
957
  function createPaymentOrderAsync(_x7) {
896
958
  return _createPaymentOrderAsync.apply(this, arguments);
@@ -904,40 +966,40 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
904
966
  }, {
905
967
  key: "deletePaymentOrderAsync",
906
968
  value: (function () {
907
- var _deletePaymentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(orderUuid) {
969
+ var _deletePaymentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(orderUuid) {
908
970
  var order;
909
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
910
- while (1) switch (_context9.prev = _context9.next) {
971
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
972
+ while (1) switch (_context10.prev = _context10.next) {
911
973
  case 0:
912
- _context9.prev = 0;
913
- _context9.next = 3;
974
+ _context10.prev = 0;
975
+ _context10.next = 3;
914
976
  return this.dbManager.get('order', orderUuid);
915
977
  case 3:
916
- order = _context9.sent;
978
+ order = _context10.sent;
917
979
  if (!order) {
918
- _context9.next = 10;
980
+ _context10.next = 10;
919
981
  break;
920
982
  }
921
- _context9.next = 7;
983
+ _context10.next = 7;
922
984
  return this.dbManager.delete('order', orderUuid);
923
985
  case 7:
924
- _context9.next = 9;
986
+ _context10.next = 9;
925
987
  return this.core.effects.emit("".concat(this.name, ":onOrderDeleted"), order);
926
988
  case 9:
927
989
  console.log('[PaymentModule] 支付订单删除成功:', orderUuid);
928
990
  case 10:
929
- _context9.next = 16;
991
+ _context10.next = 16;
930
992
  break;
931
993
  case 12:
932
- _context9.prev = 12;
933
- _context9.t0 = _context9["catch"](0);
934
- console.error('[PaymentModule] 删除支付订单失败', _context9.t0);
935
- throw _context9.t0;
994
+ _context10.prev = 12;
995
+ _context10.t0 = _context10["catch"](0);
996
+ console.error('[PaymentModule] 删除支付订单失败', _context10.t0);
997
+ throw _context10.t0;
936
998
  case 16:
937
999
  case "end":
938
- return _context9.stop();
1000
+ return _context10.stop();
939
1001
  }
940
- }, _callee9, this, [[0, 12]]);
1002
+ }, _callee10, this, [[0, 12]]);
941
1003
  }));
942
1004
  function deletePaymentOrderAsync(_x8) {
943
1005
  return _deletePaymentOrderAsync.apply(this, arguments);
@@ -951,47 +1013,47 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
951
1013
  }, {
952
1014
  key: "updateOrderAsync",
953
1015
  value: (function () {
954
- var _updateOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(orderUuid, params) {
1016
+ var _updateOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(orderUuid, params) {
955
1017
  var order, updatedOrder;
956
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
957
- while (1) switch (_context10.prev = _context10.next) {
1018
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1019
+ while (1) switch (_context11.prev = _context11.next) {
958
1020
  case 0:
959
- _context10.prev = 0;
960
- _context10.next = 3;
1021
+ _context11.prev = 0;
1022
+ _context11.next = 3;
961
1023
  return this.dbManager.get('order', orderUuid);
962
1024
  case 3:
963
- order = _context10.sent;
1025
+ order = _context11.sent;
964
1026
  if (!order) {
965
- _context10.next = 13;
1027
+ _context11.next = 13;
966
1028
  break;
967
1029
  }
968
1030
  updatedOrder = _objectSpread(_objectSpread({}, order), params);
969
1031
  this.recalculateOrderAmount(updatedOrder);
970
- _context10.next = 9;
1032
+ _context11.next = 9;
971
1033
  return this.dbManager.update('order', updatedOrder);
972
1034
  case 9:
973
- _context10.next = 11;
1035
+ _context11.next = 11;
974
1036
  return this.core.effects.emit("".concat(this.name, ":onOrderUpdated"), updatedOrder);
975
1037
  case 11:
976
- _context10.next = 13;
1038
+ _context11.next = 13;
977
1039
  return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
978
1040
  action: 'update',
979
1041
  order: updatedOrder,
980
1042
  originalOrder: order
981
1043
  });
982
1044
  case 13:
983
- _context10.next = 19;
1045
+ _context11.next = 19;
984
1046
  break;
985
1047
  case 15:
986
- _context10.prev = 15;
987
- _context10.t0 = _context10["catch"](0);
988
- console.error('[PaymentModule] 更新订单失败', _context10.t0);
989
- throw _context10.t0;
1048
+ _context11.prev = 15;
1049
+ _context11.t0 = _context11["catch"](0);
1050
+ console.error('[PaymentModule] 更新订单失败', _context11.t0);
1051
+ throw _context11.t0;
990
1052
  case 19:
991
1053
  case "end":
992
- return _context10.stop();
1054
+ return _context11.stop();
993
1055
  }
994
- }, _callee10, this, [[0, 15]]);
1056
+ }, _callee11, this, [[0, 15]]);
995
1057
  }));
996
1058
  function updateOrderAsync(_x9, _x10) {
997
1059
  return _updateOrderAsync.apply(this, arguments);
@@ -1012,38 +1074,38 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1012
1074
  }, {
1013
1075
  key: "replaceOrderIdByUuidAsync",
1014
1076
  value: (function () {
1015
- var _replaceOrderIdByUuidAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(orderUuid, newOrderId) {
1077
+ var _replaceOrderIdByUuidAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(orderUuid, newOrderId) {
1016
1078
  var existingOrder, allOrders, duplicateOrder, originalOrderId, updatedOrder;
1017
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1018
- while (1) switch (_context11.prev = _context11.next) {
1079
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1080
+ while (1) switch (_context12.prev = _context12.next) {
1019
1081
  case 0:
1020
1082
  this.logInfo('Starting replaceOrderIdByUuidAsync', {
1021
1083
  orderUuid: orderUuid,
1022
1084
  newOrderId: newOrderId
1023
1085
  });
1024
- _context11.prev = 1;
1025
- _context11.next = 4;
1086
+ _context12.prev = 1;
1087
+ _context12.next = 4;
1026
1088
  return this.dbManager.get('order', orderUuid);
1027
1089
  case 4:
1028
- existingOrder = _context11.sent;
1090
+ existingOrder = _context12.sent;
1029
1091
  if (existingOrder) {
1030
- _context11.next = 8;
1092
+ _context12.next = 8;
1031
1093
  break;
1032
1094
  }
1033
1095
  this.logWarning('Order not found for UUID replacement', {
1034
1096
  orderUuid: orderUuid
1035
1097
  });
1036
- return _context11.abrupt("return", null);
1098
+ return _context12.abrupt("return", null);
1037
1099
  case 8:
1038
- _context11.next = 10;
1100
+ _context12.next = 10;
1039
1101
  return this.dbManager.getAll('order');
1040
1102
  case 10:
1041
- allOrders = _context11.sent;
1103
+ allOrders = _context12.sent;
1042
1104
  duplicateOrder = allOrders.find(function (order) {
1043
1105
  return String(order.order_id) === String(newOrderId) && order.uuid !== orderUuid;
1044
1106
  });
1045
1107
  if (!duplicateOrder) {
1046
- _context11.next = 15;
1108
+ _context12.next = 15;
1047
1109
  break;
1048
1110
  }
1049
1111
  this.logWarning('New order ID already exists', {
@@ -1065,13 +1127,13 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1065
1127
  updated_at: new Date().toISOString()
1066
1128
  })
1067
1129
  }); // 更新到数据库
1068
- _context11.next = 19;
1130
+ _context12.next = 19;
1069
1131
  return this.dbManager.update('order', updatedOrder);
1070
1132
  case 19:
1071
- _context11.next = 21;
1133
+ _context12.next = 21;
1072
1134
  return this.core.effects.emit("".concat(this.name, ":onOrderUpdated"), updatedOrder);
1073
1135
  case 21:
1074
- _context11.next = 23;
1136
+ _context12.next = 23;
1075
1137
  return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
1076
1138
  action: 'order_id_replaced',
1077
1139
  order: updatedOrder,
@@ -1088,21 +1150,21 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1088
1150
  newOrderId: newOrderId
1089
1151
  });
1090
1152
  console.log("[PaymentModule] \u8BA2\u5355ID\u66FF\u6362\u6210\u529F: ".concat(originalOrderId, " \u2192 ").concat(newOrderId));
1091
- return _context11.abrupt("return", updatedOrder);
1153
+ return _context12.abrupt("return", updatedOrder);
1092
1154
  case 28:
1093
- _context11.prev = 28;
1094
- _context11.t0 = _context11["catch"](1);
1095
- console.error('[PaymentModule] 替换订单ID失败', _context11.t0);
1096
- this.logError('replaceOrderIdByUuidAsync failed', _context11.t0, {
1155
+ _context12.prev = 28;
1156
+ _context12.t0 = _context12["catch"](1);
1157
+ console.error('[PaymentModule] 替换订单ID失败', _context12.t0);
1158
+ this.logError('replaceOrderIdByUuidAsync failed', _context12.t0, {
1097
1159
  orderUuid: orderUuid,
1098
1160
  newOrderId: newOrderId
1099
1161
  });
1100
- throw _context11.t0;
1162
+ throw _context12.t0;
1101
1163
  case 33:
1102
1164
  case "end":
1103
- return _context11.stop();
1165
+ return _context12.stop();
1104
1166
  }
1105
- }, _callee11, this, [[1, 28]]);
1167
+ }, _callee12, this, [[1, 28]]);
1106
1168
  }));
1107
1169
  function replaceOrderIdByUuidAsync(_x11, _x12) {
1108
1170
  return _replaceOrderIdByUuidAsync.apply(this, arguments);
@@ -1120,40 +1182,40 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1120
1182
  }, {
1121
1183
  key: "getPaymentItemsAsync",
1122
1184
  value: (function () {
1123
- var _getPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(orderUuid) {
1185
+ var _getPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderUuid) {
1124
1186
  var includeVoided,
1125
1187
  order,
1126
1188
  allPayments,
1127
- _args12 = arguments;
1128
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1129
- while (1) switch (_context12.prev = _context12.next) {
1189
+ _args13 = arguments;
1190
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1191
+ while (1) switch (_context13.prev = _context13.next) {
1130
1192
  case 0:
1131
- includeVoided = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : false;
1193
+ includeVoided = _args13.length > 1 && _args13[1] !== undefined ? _args13[1] : false;
1132
1194
  if (orderUuid) {
1133
- _context12.next = 3;
1195
+ _context13.next = 3;
1134
1196
  break;
1135
1197
  }
1136
1198
  throw new Error('orderUuid is required');
1137
1199
  case 3:
1138
- _context12.next = 5;
1200
+ _context13.next = 5;
1139
1201
  return this.getPaymentOrderByUuidAsync(orderUuid);
1140
1202
  case 5:
1141
- order = _context12.sent;
1203
+ order = _context13.sent;
1142
1204
  allPayments = (order === null || order === void 0 ? void 0 : order.payment) || [];
1143
1205
  if (!includeVoided) {
1144
- _context12.next = 9;
1206
+ _context13.next = 9;
1145
1207
  break;
1146
1208
  }
1147
- return _context12.abrupt("return", allPayments);
1209
+ return _context13.abrupt("return", allPayments);
1148
1210
  case 9:
1149
- return _context12.abrupt("return", allPayments.filter(function (payment) {
1211
+ return _context13.abrupt("return", allPayments.filter(function (payment) {
1150
1212
  return payment.status !== 'voided';
1151
1213
  }));
1152
1214
  case 10:
1153
1215
  case "end":
1154
- return _context12.stop();
1216
+ return _context13.stop();
1155
1217
  }
1156
- }, _callee12, this);
1218
+ }, _callee13, this);
1157
1219
  }));
1158
1220
  function getPaymentItemsAsync(_x13) {
1159
1221
  return _getPaymentItemsAsync.apply(this, arguments);
@@ -1170,16 +1232,16 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1170
1232
  }, {
1171
1233
  key: "getAllPaymentItemsAsync",
1172
1234
  value: (function () {
1173
- var _getAllPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderUuid) {
1174
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1175
- while (1) switch (_context13.prev = _context13.next) {
1235
+ var _getAllPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(orderUuid) {
1236
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1237
+ while (1) switch (_context14.prev = _context14.next) {
1176
1238
  case 0:
1177
- return _context13.abrupt("return", this.getPaymentItemsAsync(orderUuid, true));
1239
+ return _context14.abrupt("return", this.getPaymentItemsAsync(orderUuid, true));
1178
1240
  case 1:
1179
1241
  case "end":
1180
- return _context13.stop();
1242
+ return _context14.stop();
1181
1243
  }
1182
- }, _callee13, this);
1244
+ }, _callee14, this);
1183
1245
  }));
1184
1246
  function getAllPaymentItemsAsync(_x14) {
1185
1247
  return _getAllPaymentItemsAsync.apply(this, arguments);
@@ -1193,10 +1255,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1193
1255
  }, {
1194
1256
  key: "addPaymentItemAsync",
1195
1257
  value: (function () {
1196
- var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(orderUuid, paymentItem) {
1258
+ var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(orderUuid, paymentItem) {
1197
1259
  var _paymentItem$metadata, _newPaymentItem$metad, _newPaymentItem$metad2, _newPaymentItem$metad3, order, expectAmount, paidDepositAmount, expectedDepositAmount, warningMessage, paymentUuid, currentTime, newPaymentItem;
1198
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1199
- while (1) switch (_context14.prev = _context14.next) {
1260
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1261
+ while (1) switch (_context15.prev = _context15.next) {
1200
1262
  case 0:
1201
1263
  this.logInfo('Starting addPaymentItemAsync', {
1202
1264
  orderUuid: orderUuid,
@@ -1204,20 +1266,20 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1204
1266
  paymentCode: paymentItem.code,
1205
1267
  orderPaymentType: paymentItem.order_payment_type
1206
1268
  });
1207
- _context14.prev = 1;
1269
+ _context15.prev = 1;
1208
1270
  this.logInfo('准备获取订单', {
1209
1271
  orderUuid: orderUuid
1210
1272
  });
1211
- _context14.next = 5;
1273
+ _context15.next = 5;
1212
1274
  return this.getPaymentOrderByUuidAsync(orderUuid);
1213
1275
  case 5:
1214
- order = _context14.sent;
1276
+ order = _context15.sent;
1215
1277
  this.logInfo('获取订单信息成功', {
1216
1278
  orderUuid: orderUuid,
1217
1279
  order: order
1218
1280
  });
1219
1281
  if (order) {
1220
- _context14.next = 9;
1282
+ _context15.next = 9;
1221
1283
  break;
1222
1284
  }
1223
1285
  throw new Error("Order not found: ".concat(orderUuid));
@@ -1232,7 +1294,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1232
1294
  }, new Decimal(0));
1233
1295
  expectedDepositAmount = new Decimal(order.deposit_amount || '0').sub(paidDepositAmount); // 有一种特殊情况,订单金额为 0,但是定金金额>0,且此时是定金状态的,允许添加支付项
1234
1296
  if (!(expectAmount.lte(0) && expectedDepositAmount.eq(0))) {
1235
- _context14.next = 17;
1297
+ _context15.next = 17;
1236
1298
  break;
1237
1299
  }
1238
1300
  warningMessage = "\u8BA2\u5355 ".concat(orderUuid, " \u5F85\u4ED8\u91D1\u989D\u5DF2\u4E3A0\uFF0C\u4E0D\u5141\u8BB8\u6DFB\u52A0\u65B0\u7684\u652F\u4ED8\u9879");
@@ -1287,7 +1349,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1287
1349
  orderUuid: orderUuid,
1288
1350
  order: order
1289
1351
  });
1290
- _context14.next = 25;
1352
+ _context15.next = 25;
1291
1353
  return this.dbManager.update('order', order, true);
1292
1354
  case 25:
1293
1355
  this.logInfo('更新订单支付项完成', {
@@ -1310,22 +1372,22 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1310
1372
  actualPaidAmount: (_newPaymentItem$metad2 = newPaymentItem.metadata) === null || _newPaymentItem$metad2 === void 0 ? void 0 : _newPaymentItem$metad2.actual_paid_amount,
1311
1373
  changeGivenAmount: (_newPaymentItem$metad3 = newPaymentItem.metadata) === null || _newPaymentItem$metad3 === void 0 ? void 0 : _newPaymentItem$metad3.change_given_amount
1312
1374
  });
1313
- _context14.next = 35;
1375
+ _context15.next = 35;
1314
1376
  break;
1315
1377
  case 30:
1316
- _context14.prev = 30;
1317
- _context14.t0 = _context14["catch"](1);
1318
- console.error('[PaymentModule] 添加支付项失败', _context14.t0);
1319
- this.logError('addPaymentItemAsync failed', _context14.t0, {
1378
+ _context15.prev = 30;
1379
+ _context15.t0 = _context15["catch"](1);
1380
+ console.error('[PaymentModule] 添加支付项失败', _context15.t0);
1381
+ this.logError('addPaymentItemAsync failed', _context15.t0, {
1320
1382
  orderUuid: orderUuid,
1321
1383
  paymentItem: paymentItem
1322
1384
  });
1323
- throw _context14.t0;
1385
+ throw _context15.t0;
1324
1386
  case 35:
1325
1387
  case "end":
1326
- return _context14.stop();
1388
+ return _context15.stop();
1327
1389
  }
1328
- }, _callee14, this, [[1, 30]]);
1390
+ }, _callee15, this, [[1, 30]]);
1329
1391
  }));
1330
1392
  function addPaymentItemAsync(_x15, _x16) {
1331
1393
  return _addPaymentItemAsync.apply(this, arguments);
@@ -1339,22 +1401,22 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1339
1401
  }, {
1340
1402
  key: "deletePaymentAsync",
1341
1403
  value: (function () {
1342
- var _deletePaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(orderUuid, paymentUuid) {
1404
+ var _deletePaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(orderUuid, paymentUuid) {
1343
1405
  var order, paymentItem;
1344
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1345
- while (1) switch (_context15.prev = _context15.next) {
1406
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1407
+ while (1) switch (_context16.prev = _context16.next) {
1346
1408
  case 0:
1347
1409
  this.logInfo('Starting deletePaymentAsync (mark as voided)', {
1348
1410
  orderUuid: orderUuid,
1349
1411
  paymentUuid: paymentUuid
1350
1412
  });
1351
- _context15.prev = 1;
1352
- _context15.next = 4;
1413
+ _context16.prev = 1;
1414
+ _context16.next = 4;
1353
1415
  return this.dbManager.get('order', orderUuid);
1354
1416
  case 4:
1355
- order = _context15.sent;
1417
+ order = _context16.sent;
1356
1418
  if (order) {
1357
- _context15.next = 7;
1419
+ _context16.next = 7;
1358
1420
  break;
1359
1421
  }
1360
1422
  throw new Error('订单不存在');
@@ -1363,17 +1425,17 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1363
1425
  return payment.uuid === paymentUuid;
1364
1426
  });
1365
1427
  if (paymentItem) {
1366
- _context15.next = 10;
1428
+ _context16.next = 10;
1367
1429
  break;
1368
1430
  }
1369
1431
  throw new Error("\u652F\u4ED8\u9879\u4E0D\u5B58\u5728: ".concat(paymentUuid));
1370
1432
  case 10:
1371
1433
  if (!(paymentItem.status === 'voided')) {
1372
- _context15.next = 13;
1434
+ _context16.next = 13;
1373
1435
  break;
1374
1436
  }
1375
1437
  console.warn("[PaymentModule] \u652F\u4ED8\u9879 ".concat(paymentUuid, " \u5DF2\u7ECF\u88AB\u5220\u9664\uFF0C\u8DF3\u8FC7\u64CD\u4F5C"));
1376
- return _context15.abrupt("return");
1438
+ return _context16.abrupt("return");
1377
1439
  case 13:
1378
1440
  // 标记删除而不是物理删除
1379
1441
  paymentItem.status = 'voided';
@@ -1390,16 +1452,16 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1390
1452
  this.recalculateOrderAmount(order);
1391
1453
 
1392
1454
  // 更新到 IndexDB
1393
- _context15.next = 20;
1455
+ _context16.next = 20;
1394
1456
  return this.dbManager.update('order', order);
1395
1457
  case 20:
1396
- _context15.next = 22;
1458
+ _context16.next = 22;
1397
1459
  return this.core.effects.emit("".concat(this.name, ":onPaymentDeleted"), {
1398
1460
  order: order,
1399
1461
  paymentItem: paymentItem
1400
1462
  });
1401
1463
  case 22:
1402
- _context15.next = 24;
1464
+ _context16.next = 24;
1403
1465
  return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
1404
1466
  action: 'payment_delete',
1405
1467
  order: order,
@@ -1412,22 +1474,22 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1412
1474
  originalAmount: paymentItem.origin_amount,
1413
1475
  newExpectAmount: order.expect_amount
1414
1476
  });
1415
- _context15.next = 32;
1477
+ _context16.next = 32;
1416
1478
  break;
1417
1479
  case 27:
1418
- _context15.prev = 27;
1419
- _context15.t0 = _context15["catch"](1);
1420
- console.error('[PaymentModule] 删除支付项失败', _context15.t0);
1421
- this.logError('deletePaymentAsync failed', _context15.t0, {
1480
+ _context16.prev = 27;
1481
+ _context16.t0 = _context16["catch"](1);
1482
+ console.error('[PaymentModule] 删除支付项失败', _context16.t0);
1483
+ this.logError('deletePaymentAsync failed', _context16.t0, {
1422
1484
  orderUuid: orderUuid,
1423
1485
  paymentUuid: paymentUuid
1424
1486
  });
1425
- throw _context15.t0;
1487
+ throw _context16.t0;
1426
1488
  case 32:
1427
1489
  case "end":
1428
- return _context15.stop();
1490
+ return _context16.stop();
1429
1491
  }
1430
- }, _callee15, this, [[1, 27]]);
1492
+ }, _callee16, this, [[1, 27]]);
1431
1493
  }));
1432
1494
  function deletePaymentAsync(_x17, _x18) {
1433
1495
  return _deletePaymentAsync.apply(this, arguments);
@@ -1444,18 +1506,18 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1444
1506
  }, {
1445
1507
  key: "updateVoucherPaymentItemsAsync",
1446
1508
  value: (function () {
1447
- var _updateVoucherPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(orderUuid, voucherPaymentItems) {
1448
- var _this5 = this;
1449
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1450
- while (1) switch (_context17.prev = _context17.next) {
1509
+ var _updateVoucherPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(orderUuid, voucherPaymentItems) {
1510
+ var _this6 = this;
1511
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1512
+ while (1) switch (_context18.prev = _context18.next) {
1451
1513
  case 0:
1452
- return _context17.abrupt("return", this.runVoucherUpdateLocked(orderUuid, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
1453
- var _this5$normalizeVouch, normalizedVoucherItems, originalCount, normalizedCount, order, existingVoucherItems, _iterator6, _step6, voucherItem, orderAfterDelete, existingActiveVoucherKeys, _iterator7, _step7, _voucherItem, orderPaymentType, key, updatedOrder;
1454
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1455
- while (1) switch (_context16.prev = _context16.next) {
1514
+ return _context18.abrupt("return", this.runVoucherUpdateLocked(orderUuid, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
1515
+ var _this6$normalizeVouch, normalizedVoucherItems, originalCount, normalizedCount, order, existingVoucherItems, _iterator6, _step6, voucherItem, orderAfterDelete, existingActiveVoucherKeys, _iterator7, _step7, _voucherItem, orderPaymentType, key, updatedOrder;
1516
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1517
+ while (1) switch (_context17.prev = _context17.next) {
1456
1518
  case 0:
1457
- _this5$normalizeVouch = _this5.normalizeVoucherPaymentItems(voucherPaymentItems), normalizedVoucherItems = _this5$normalizeVouch.items, originalCount = _this5$normalizeVouch.originalCount, normalizedCount = _this5$normalizeVouch.normalizedCount;
1458
- _this5.logInfo('Starting updateVoucherPaymentItemsAsync', {
1519
+ _this6$normalizeVouch = _this6.normalizeVoucherPaymentItems(voucherPaymentItems), normalizedVoucherItems = _this6$normalizeVouch.items, originalCount = _this6$normalizeVouch.originalCount, normalizedCount = _this6$normalizeVouch.normalizedCount;
1520
+ _this6.logInfo('Starting updateVoucherPaymentItemsAsync', {
1459
1521
  orderUuid: orderUuid,
1460
1522
  originalVoucherCount: originalCount,
1461
1523
  normalizedVoucherCount: normalizedCount,
@@ -1475,13 +1537,13 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1475
1537
  normalizedCount: normalizedCount
1476
1538
  });
1477
1539
  }
1478
- _context16.prev = 3;
1479
- _context16.next = 6;
1480
- return _this5.getPaymentOrderByUuidAsync(orderUuid);
1540
+ _context17.prev = 3;
1541
+ _context17.next = 6;
1542
+ return _this6.getPaymentOrderByUuidAsync(orderUuid);
1481
1543
  case 6:
1482
- order = _context16.sent;
1544
+ order = _context17.sent;
1483
1545
  if (order) {
1484
- _context16.next = 9;
1546
+ _context17.next = 9;
1485
1547
  break;
1486
1548
  }
1487
1549
  throw new Error("\u8BA2\u5355\u4E0D\u5B58\u5728: ".concat(orderUuid));
@@ -1507,38 +1569,38 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1507
1569
 
1508
1570
  // 2. 删除所有现有的代金券支付项(仅删除未同步的)
1509
1571
  _iterator6 = _createForOfIteratorHelper(existingVoucherItems);
1510
- _context16.prev = 12;
1572
+ _context17.prev = 12;
1511
1573
  _iterator6.s();
1512
1574
  case 14:
1513
1575
  if ((_step6 = _iterator6.n()).done) {
1514
- _context16.next = 21;
1576
+ _context17.next = 21;
1515
1577
  break;
1516
1578
  }
1517
1579
  voucherItem = _step6.value;
1518
1580
  console.log("[PaymentModule] \u5220\u9664\u73B0\u6709\u4EE3\u91D1\u5238\u652F\u4ED8\u9879: ".concat(voucherItem.uuid));
1519
- _context16.next = 19;
1520
- return _this5.deletePaymentAsync(orderUuid, voucherItem.uuid);
1581
+ _context17.next = 19;
1582
+ return _this6.deletePaymentAsync(orderUuid, voucherItem.uuid);
1521
1583
  case 19:
1522
- _context16.next = 14;
1584
+ _context17.next = 14;
1523
1585
  break;
1524
1586
  case 21:
1525
- _context16.next = 26;
1587
+ _context17.next = 26;
1526
1588
  break;
1527
1589
  case 23:
1528
- _context16.prev = 23;
1529
- _context16.t0 = _context16["catch"](12);
1530
- _iterator6.e(_context16.t0);
1590
+ _context17.prev = 23;
1591
+ _context17.t0 = _context17["catch"](12);
1592
+ _iterator6.e(_context17.t0);
1531
1593
  case 26:
1532
- _context16.prev = 26;
1594
+ _context17.prev = 26;
1533
1595
  _iterator6.f();
1534
- return _context16.finish(26);
1596
+ return _context17.finish(26);
1535
1597
  case 29:
1536
- _context16.next = 31;
1537
- return _this5.getPaymentOrderByUuidAsync(orderUuid);
1598
+ _context17.next = 31;
1599
+ return _this6.getPaymentOrderByUuidAsync(orderUuid);
1538
1600
  case 31:
1539
- orderAfterDelete = _context16.sent;
1601
+ orderAfterDelete = _context17.sent;
1540
1602
  if (orderAfterDelete) {
1541
- _context16.next = 34;
1603
+ _context17.next = 34;
1542
1604
  break;
1543
1605
  }
1544
1606
  throw new Error("\u8BA2\u5355\u4E0D\u5B58\u5728: ".concat(orderUuid));
@@ -1553,18 +1615,18 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1553
1615
  newItemCount: normalizedVoucherItems.length
1554
1616
  });
1555
1617
  _iterator7 = _createForOfIteratorHelper(normalizedVoucherItems);
1556
- _context16.prev = 37;
1618
+ _context17.prev = 37;
1557
1619
  _iterator7.s();
1558
1620
  case 39:
1559
1621
  if ((_step7 = _iterator7.n()).done) {
1560
- _context16.next = 52;
1622
+ _context17.next = 52;
1561
1623
  break;
1562
1624
  }
1563
1625
  _voucherItem = _step7.value;
1564
1626
  orderPaymentType = _voucherItem.order_payment_type || 'normal';
1565
1627
  key = "".concat(_voucherItem.voucher_id, "|").concat(orderPaymentType);
1566
1628
  if (!existingActiveVoucherKeys.has(key)) {
1567
- _context16.next = 46;
1629
+ _context17.next = 46;
1568
1630
  break;
1569
1631
  }
1570
1632
  console.warn('[PaymentModule] Skip adding voucher payment item because it already exists (active)', {
@@ -1572,7 +1634,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1572
1634
  voucher_id: _voucherItem.voucher_id,
1573
1635
  order_payment_type: orderPaymentType
1574
1636
  });
1575
- return _context16.abrupt("continue", 50);
1637
+ return _context17.abrupt("continue", 50);
1576
1638
  case 46:
1577
1639
  console.log("[PaymentModule] \u6DFB\u52A0\u4EE3\u91D1\u5238\u652F\u4ED8\u9879:", _objectSpread(_objectSpread({}, _voucherItem), {}, {
1578
1640
  code: _voucherItem.code,
@@ -1580,64 +1642,64 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1580
1642
  voucher_id: _voucherItem.voucher_id,
1581
1643
  order_payment_type: orderPaymentType
1582
1644
  }));
1583
- _context16.next = 49;
1584
- return _this5.addPaymentItemAsync(orderUuid, _voucherItem);
1645
+ _context17.next = 49;
1646
+ return _this6.addPaymentItemAsync(orderUuid, _voucherItem);
1585
1647
  case 49:
1586
1648
  existingActiveVoucherKeys.add(key);
1587
1649
  case 50:
1588
- _context16.next = 39;
1650
+ _context17.next = 39;
1589
1651
  break;
1590
1652
  case 52:
1591
- _context16.next = 57;
1653
+ _context17.next = 57;
1592
1654
  break;
1593
1655
  case 54:
1594
- _context16.prev = 54;
1595
- _context16.t1 = _context16["catch"](37);
1596
- _iterator7.e(_context16.t1);
1656
+ _context17.prev = 54;
1657
+ _context17.t1 = _context17["catch"](37);
1658
+ _iterator7.e(_context17.t1);
1597
1659
  case 57:
1598
- _context16.prev = 57;
1660
+ _context17.prev = 57;
1599
1661
  _iterator7.f();
1600
- return _context16.finish(57);
1662
+ return _context17.finish(57);
1601
1663
  case 60:
1602
- _context16.next = 62;
1603
- return _this5.getPaymentOrderByUuidAsync(orderUuid);
1664
+ _context17.next = 62;
1665
+ return _this6.getPaymentOrderByUuidAsync(orderUuid);
1604
1666
  case 62:
1605
- updatedOrder = _context16.sent;
1606
- _context16.next = 65;
1607
- return _this5.core.effects.emit("".concat(_this5.name, ":onPaymentAdded"), {
1667
+ updatedOrder = _context17.sent;
1668
+ _context17.next = 65;
1669
+ return _this6.core.effects.emit("".concat(_this6.name, ":onPaymentAdded"), {
1608
1670
  orderUuid: orderUuid,
1609
1671
  order: updatedOrder,
1610
1672
  payment: null // 批量操作不提供单个支付项
1611
1673
  });
1612
1674
  case 65:
1613
- _this5.logInfo('updateVoucherPaymentItemsAsync completed successfully', {
1675
+ _this6.logInfo('updateVoucherPaymentItemsAsync completed successfully', {
1614
1676
  orderUuid: orderUuid,
1615
1677
  removedVoucherCount: existingVoucherItems.length,
1616
1678
  addedVoucherCount: normalizedVoucherItems.length,
1617
1679
  finalExpectAmount: updatedOrder === null || updatedOrder === void 0 ? void 0 : updatedOrder.expect_amount
1618
1680
  });
1619
- _context16.next = 73;
1681
+ _context17.next = 73;
1620
1682
  break;
1621
1683
  case 68:
1622
- _context16.prev = 68;
1623
- _context16.t2 = _context16["catch"](3);
1624
- console.error('[PaymentModule] 批量更新代金券支付项失败:', _context16.t2);
1625
- _this5.logError('updateVoucherPaymentItemsAsync failed', _context16.t2, {
1684
+ _context17.prev = 68;
1685
+ _context17.t2 = _context17["catch"](3);
1686
+ console.error('[PaymentModule] 批量更新代金券支付项失败:', _context17.t2);
1687
+ _this6.logError('updateVoucherPaymentItemsAsync failed', _context17.t2, {
1626
1688
  orderUuid: orderUuid,
1627
1689
  voucherPaymentItems: voucherPaymentItems
1628
1690
  });
1629
- throw _context16.t2;
1691
+ throw _context17.t2;
1630
1692
  case 73:
1631
1693
  case "end":
1632
- return _context16.stop();
1694
+ return _context17.stop();
1633
1695
  }
1634
- }, _callee16, null, [[3, 68], [12, 23, 26, 29], [37, 54, 57, 60]]);
1696
+ }, _callee17, null, [[3, 68], [12, 23, 26, 29], [37, 54, 57, 60]]);
1635
1697
  }))));
1636
1698
  case 1:
1637
1699
  case "end":
1638
- return _context17.stop();
1700
+ return _context18.stop();
1639
1701
  }
1640
- }, _callee17, this);
1702
+ }, _callee18, this);
1641
1703
  }));
1642
1704
  function updateVoucherPaymentItemsAsync(_x19, _x20) {
1643
1705
  return _updateVoucherPaymentItemsAsync.apply(this, arguments);
@@ -1651,18 +1713,18 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1651
1713
  }, {
1652
1714
  key: "updatePaymentAsync",
1653
1715
  value: (function () {
1654
- var _updatePaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(orderUuid, paymentUuid, params) {
1716
+ var _updatePaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(orderUuid, paymentUuid, params) {
1655
1717
  var order, paymentItem, formattedParams;
1656
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1657
- while (1) switch (_context18.prev = _context18.next) {
1718
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1719
+ while (1) switch (_context19.prev = _context19.next) {
1658
1720
  case 0:
1659
- _context18.prev = 0;
1660
- _context18.next = 3;
1721
+ _context19.prev = 0;
1722
+ _context19.next = 3;
1661
1723
  return this.dbManager.get('order', orderUuid);
1662
1724
  case 3:
1663
- order = _context18.sent;
1725
+ order = _context19.sent;
1664
1726
  if (order) {
1665
- _context18.next = 6;
1727
+ _context19.next = 6;
1666
1728
  break;
1667
1729
  }
1668
1730
  throw new Error('订单不存在');
@@ -1671,7 +1733,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1671
1733
  return payment.uuid === paymentUuid;
1672
1734
  });
1673
1735
  if (!paymentItem) {
1674
- _context18.next = 18;
1736
+ _context19.next = 18;
1675
1737
  break;
1676
1738
  }
1677
1739
  // 如果更新参数中包含 amount,先格式化
@@ -1685,34 +1747,34 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1685
1747
  this.recalculateOrderAmount(order);
1686
1748
 
1687
1749
  // 更新到 IndexDB
1688
- _context18.next = 14;
1750
+ _context19.next = 14;
1689
1751
  return this.dbManager.update('order', order);
1690
1752
  case 14:
1691
- _context18.next = 16;
1753
+ _context19.next = 16;
1692
1754
  return this.core.effects.emit("".concat(this.name, ":onPaymentUpdated"), {
1693
1755
  order: order,
1694
1756
  paymentItem: paymentItem
1695
1757
  });
1696
1758
  case 16:
1697
- _context18.next = 18;
1759
+ _context19.next = 18;
1698
1760
  return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
1699
1761
  action: 'payment_update',
1700
1762
  order: order,
1701
1763
  paymentItem: paymentItem
1702
1764
  });
1703
1765
  case 18:
1704
- _context18.next = 24;
1766
+ _context19.next = 24;
1705
1767
  break;
1706
1768
  case 20:
1707
- _context18.prev = 20;
1708
- _context18.t0 = _context18["catch"](0);
1709
- console.error('[PaymentModule] 更新支付项失败', _context18.t0);
1710
- throw _context18.t0;
1769
+ _context19.prev = 20;
1770
+ _context19.t0 = _context19["catch"](0);
1771
+ console.error('[PaymentModule] 更新支付项失败', _context19.t0);
1772
+ throw _context19.t0;
1711
1773
  case 24:
1712
1774
  case "end":
1713
- return _context18.stop();
1775
+ return _context19.stop();
1714
1776
  }
1715
- }, _callee18, this, [[0, 20]]);
1777
+ }, _callee19, this, [[0, 20]]);
1716
1778
  }));
1717
1779
  function updatePaymentAsync(_x21, _x22, _x23) {
1718
1780
  return _updatePaymentAsync.apply(this, arguments);
@@ -1726,61 +1788,61 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1726
1788
  }, {
1727
1789
  key: "submitPayAsync",
1728
1790
  value: (function () {
1729
- var _submitPayAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(orderUuid) {
1791
+ var _submitPayAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(orderUuid) {
1730
1792
  var orderToSubmit, order, allOrders, _iterator8, _step8, _order, result;
1731
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1732
- while (1) switch (_context19.prev = _context19.next) {
1793
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1794
+ while (1) switch (_context20.prev = _context20.next) {
1733
1795
  case 0:
1734
1796
  this.logInfo('Starting submitPayAsync', {
1735
1797
  orderUuid: orderUuid
1736
1798
  });
1737
- _context19.prev = 1;
1799
+ _context20.prev = 1;
1738
1800
  if (!orderUuid) {
1739
- _context19.next = 9;
1801
+ _context20.next = 9;
1740
1802
  break;
1741
1803
  }
1742
- _context19.next = 5;
1804
+ _context20.next = 5;
1743
1805
  return this.dbManager.get('order', orderUuid);
1744
1806
  case 5:
1745
- order = _context19.sent;
1807
+ order = _context20.sent;
1746
1808
  orderToSubmit = order ? [order] : [];
1747
- _context19.next = 13;
1809
+ _context20.next = 13;
1748
1810
  break;
1749
1811
  case 9:
1750
- _context19.next = 11;
1812
+ _context20.next = 11;
1751
1813
  return this.dbManager.getAll('order');
1752
1814
  case 11:
1753
- allOrders = _context19.sent;
1815
+ allOrders = _context20.sent;
1754
1816
  // 包括正在处理中的订单和部分支付的订单(可能添加了新的支付项)
1755
1817
  orderToSubmit = allOrders.filter(function (order) {
1756
1818
  return order.payment_status === PaymentStatus.Processing || order.payment_status === PaymentStatus.PartiallyPaid;
1757
1819
  });
1758
1820
  case 13:
1759
1821
  _iterator8 = _createForOfIteratorHelper(orderToSubmit);
1760
- _context19.prev = 14;
1822
+ _context20.prev = 14;
1761
1823
  _iterator8.s();
1762
1824
  case 16:
1763
1825
  if ((_step8 = _iterator8.n()).done) {
1764
- _context19.next = 22;
1826
+ _context20.next = 22;
1765
1827
  break;
1766
1828
  }
1767
1829
  _order = _step8.value;
1768
- _context19.next = 20;
1830
+ _context20.next = 20;
1769
1831
  return this.submitSingleOrderPayment(_order);
1770
1832
  case 20:
1771
- _context19.next = 16;
1833
+ _context20.next = 16;
1772
1834
  break;
1773
1835
  case 22:
1774
- _context19.next = 27;
1836
+ _context20.next = 27;
1775
1837
  break;
1776
1838
  case 24:
1777
- _context19.prev = 24;
1778
- _context19.t0 = _context19["catch"](14);
1779
- _iterator8.e(_context19.t0);
1839
+ _context20.prev = 24;
1840
+ _context20.t0 = _context20["catch"](14);
1841
+ _iterator8.e(_context20.t0);
1780
1842
  case 27:
1781
- _context19.prev = 27;
1843
+ _context20.prev = 27;
1782
1844
  _iterator8.f();
1783
- return _context19.finish(27);
1845
+ return _context20.finish(27);
1784
1846
  case 30:
1785
1847
  result = {
1786
1848
  status: 'success'
@@ -1789,22 +1851,22 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1789
1851
  result: result.status,
1790
1852
  processedOrdersCount: orderToSubmit.length
1791
1853
  });
1792
- return _context19.abrupt("return", result);
1854
+ return _context20.abrupt("return", result);
1793
1855
  case 35:
1794
- _context19.prev = 35;
1795
- _context19.t1 = _context19["catch"](1);
1796
- console.error('[PaymentModule] 提交支付失败', _context19.t1);
1797
- this.logError('submitPayAsync failed', _context19.t1, {
1856
+ _context20.prev = 35;
1857
+ _context20.t1 = _context20["catch"](1);
1858
+ console.error('[PaymentModule] 提交支付失败', _context20.t1);
1859
+ this.logError('submitPayAsync failed', _context20.t1, {
1798
1860
  orderUuid: orderUuid
1799
1861
  });
1800
- return _context19.abrupt("return", {
1862
+ return _context20.abrupt("return", {
1801
1863
  status: 'failed'
1802
1864
  });
1803
1865
  case 40:
1804
1866
  case "end":
1805
- return _context19.stop();
1867
+ return _context20.stop();
1806
1868
  }
1807
- }, _callee19, this, [[1, 35], [14, 24, 27, 30]]);
1869
+ }, _callee20, this, [[1, 35], [14, 24, 27, 30]]);
1808
1870
  }));
1809
1871
  function submitPayAsync(_x24) {
1810
1872
  return _submitPayAsync.apply(this, arguments);
@@ -1818,12 +1880,12 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1818
1880
  }, {
1819
1881
  key: "submitSingleOrderPayment",
1820
1882
  value: (function () {
1821
- var _submitSingleOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(order) {
1883
+ var _submitSingleOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(order) {
1822
1884
  var paymentData, totalPaidAmount, orderTotalAmount;
1823
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1824
- while (1) switch (_context20.prev = _context20.next) {
1885
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1886
+ while (1) switch (_context21.prev = _context21.next) {
1825
1887
  case 0:
1826
- _context20.prev = 0;
1888
+ _context21.prev = 0;
1827
1889
  paymentData = {
1828
1890
  payments: order.payment.map(function (payment) {
1829
1891
  return {
@@ -1859,11 +1921,11 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1859
1921
  paymentData.payment_status = order.payment_status === PaymentStatus.Finished ? 'paid' : 'partially_paid';
1860
1922
 
1861
1923
  // 更新订单状态到数据库
1862
- _context20.next = 8;
1924
+ _context21.next = 8;
1863
1925
  return this.dbManager.update('order', order);
1864
1926
  case 8:
1865
1927
  if (!(paymentData.payments.length === 0)) {
1866
- _context20.next = 12;
1928
+ _context21.next = 12;
1867
1929
  break;
1868
1930
  }
1869
1931
  console.log("[PaymentModule] \u8BA2\u5355 ".concat(order.uuid, " \u652F\u4ED8\u5217\u8868\u4E3A\u7A7A\uFF0C\u8DF3\u8FC7\u652F\u4ED8\u5904\u7406"));
@@ -1871,29 +1933,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1871
1933
  orderUuid: order.uuid,
1872
1934
  orderId: order.order_id
1873
1935
  });
1874
- return _context20.abrupt("return");
1936
+ return _context21.abrupt("return");
1875
1937
  case 12:
1876
- _context20.next = 14;
1938
+ _context21.next = 14;
1877
1939
  return this.core.effects.emit("".concat(this.name, ":onPaymentSubmitted"), order);
1878
1940
  case 14:
1879
- _context20.next = 16;
1941
+ _context21.next = 16;
1880
1942
  return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
1881
1943
  action: 'submit',
1882
1944
  order: order
1883
1945
  });
1884
1946
  case 16:
1885
- _context20.next = 22;
1947
+ _context21.next = 22;
1886
1948
  break;
1887
1949
  case 18:
1888
- _context20.prev = 18;
1889
- _context20.t0 = _context20["catch"](0);
1890
- console.error("[PaymentModule] \u8BA2\u5355 ".concat(order.uuid, " \u652F\u4ED8\u63D0\u4EA4\u5931\u8D25"), _context20.t0);
1891
- throw _context20.t0;
1950
+ _context21.prev = 18;
1951
+ _context21.t0 = _context21["catch"](0);
1952
+ console.error("[PaymentModule] \u8BA2\u5355 ".concat(order.uuid, " \u652F\u4ED8\u63D0\u4EA4\u5931\u8D25"), _context21.t0);
1953
+ throw _context21.t0;
1892
1954
  case 22:
1893
1955
  case "end":
1894
- return _context20.stop();
1956
+ return _context21.stop();
1895
1957
  }
1896
- }, _callee20, this, [[0, 18]]);
1958
+ }, _callee21, this, [[0, 18]]);
1897
1959
  }));
1898
1960
  function submitSingleOrderPayment(_x25) {
1899
1961
  return _submitSingleOrderPayment.apply(this, arguments);
@@ -1907,27 +1969,27 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1907
1969
  }, {
1908
1970
  key: "getRemainingOrderAmountAsync",
1909
1971
  value: (function () {
1910
- var _getRemainingOrderAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(orderUuid) {
1972
+ var _getRemainingOrderAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(orderUuid) {
1911
1973
  var order;
1912
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1913
- while (1) switch (_context21.prev = _context21.next) {
1974
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1975
+ while (1) switch (_context22.prev = _context22.next) {
1914
1976
  case 0:
1915
- _context21.next = 2;
1977
+ _context22.next = 2;
1916
1978
  return this.getPaymentOrderByUuidAsync(orderUuid);
1917
1979
  case 2:
1918
- order = _context21.sent;
1980
+ order = _context22.sent;
1919
1981
  if (order) {
1920
- _context21.next = 5;
1982
+ _context22.next = 5;
1921
1983
  break;
1922
1984
  }
1923
1985
  throw new Error('订单不存在');
1924
1986
  case 5:
1925
- return _context21.abrupt("return", new Decimal(order.expect_amount).toNumber());
1987
+ return _context22.abrupt("return", new Decimal(order.expect_amount).toNumber());
1926
1988
  case 6:
1927
1989
  case "end":
1928
- return _context21.stop();
1990
+ return _context22.stop();
1929
1991
  }
1930
- }, _callee21, this);
1992
+ }, _callee22, this);
1931
1993
  }));
1932
1994
  function getRemainingOrderAmountAsync(_x26) {
1933
1995
  return _getRemainingOrderAmountAsync.apply(this, arguments);
@@ -1941,63 +2003,63 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1941
2003
  }, {
1942
2004
  key: "getRemainingOrderAmountWithInputAsync",
1943
2005
  value: (function () {
1944
- var _getRemainingOrderAmountWithInputAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(inputAmount, orderUuid) {
2006
+ var _getRemainingOrderAmountWithInputAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(inputAmount, orderUuid) {
1945
2007
  var order, inputDecimal;
1946
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1947
- while (1) switch (_context22.prev = _context22.next) {
2008
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2009
+ while (1) switch (_context23.prev = _context23.next) {
1948
2010
  case 0:
1949
- _context22.next = 2;
2011
+ _context23.next = 2;
1950
2012
  return this.getPaymentOrderByUuidAsync(orderUuid);
1951
2013
  case 2:
1952
- order = _context22.sent;
2014
+ order = _context23.sent;
1953
2015
  if (order) {
1954
- _context22.next = 5;
2016
+ _context23.next = 5;
1955
2017
  break;
1956
2018
  }
1957
2019
  throw new Error('订单不存在');
1958
2020
  case 5:
1959
2021
  if (!(inputAmount === null || inputAmount === undefined)) {
1960
- _context22.next = 7;
2022
+ _context23.next = 7;
1961
2023
  break;
1962
2024
  }
1963
- return _context22.abrupt("return", new Decimal(order.expect_amount).toNumber());
2025
+ return _context23.abrupt("return", new Decimal(order.expect_amount).toNumber());
1964
2026
  case 7:
1965
2027
  if (!(typeof inputAmount === 'string')) {
1966
- _context22.next = 10;
2028
+ _context23.next = 10;
1967
2029
  break;
1968
2030
  }
1969
2031
  if (!(inputAmount.trim() === '')) {
1970
- _context22.next = 10;
2032
+ _context23.next = 10;
1971
2033
  break;
1972
2034
  }
1973
- return _context22.abrupt("return", new Decimal(order.expect_amount).toNumber());
2035
+ return _context23.abrupt("return", new Decimal(order.expect_amount).toNumber());
1974
2036
  case 10:
1975
2037
  if (!(typeof inputAmount === 'number')) {
1976
- _context22.next = 14;
2038
+ _context23.next = 14;
1977
2039
  break;
1978
2040
  }
1979
2041
  if (!(isNaN(inputAmount) || !isFinite(inputAmount))) {
1980
- _context22.next = 14;
2042
+ _context23.next = 14;
1981
2043
  break;
1982
2044
  }
1983
2045
  // 如果输入是 NaN 或无穷大,返回原始的待付金额
1984
2046
  console.warn("[PaymentModule] \u8F93\u5165\u91D1\u989D\u4E0D\u662F\u6709\u6548\u6570\u5B57: ".concat(inputAmount, "\uFF0C\u8FD4\u56DE\u539F\u59CB\u5F85\u4ED8\u91D1\u989D"));
1985
- return _context22.abrupt("return", new Decimal(order.expect_amount).toNumber());
2047
+ return _context23.abrupt("return", new Decimal(order.expect_amount).toNumber());
1986
2048
  case 14:
1987
- _context22.prev = 14;
2049
+ _context23.prev = 14;
1988
2050
  inputDecimal = new Decimal(inputAmount);
1989
- return _context22.abrupt("return", new Decimal(order.expect_amount).minus(inputDecimal).toNumber());
2051
+ return _context23.abrupt("return", new Decimal(order.expect_amount).minus(inputDecimal).toNumber());
1990
2052
  case 19:
1991
- _context22.prev = 19;
1992
- _context22.t0 = _context22["catch"](14);
2053
+ _context23.prev = 19;
2054
+ _context23.t0 = _context23["catch"](14);
1993
2055
  // 如果输入不是有效的数字,返回原始的待付金额
1994
2056
  console.warn("[PaymentModule] \u8F93\u5165\u91D1\u989D\u683C\u5F0F\u65E0\u6548: ".concat(inputAmount, "\uFF0C\u8FD4\u56DE\u539F\u59CB\u5F85\u4ED8\u91D1\u989D"));
1995
- return _context22.abrupt("return", new Decimal(order.expect_amount).toNumber());
2057
+ return _context23.abrupt("return", new Decimal(order.expect_amount).toNumber());
1996
2058
  case 23:
1997
2059
  case "end":
1998
- return _context22.stop();
2060
+ return _context23.stop();
1999
2061
  }
2000
- }, _callee22, this, [[14, 19]]);
2062
+ }, _callee23, this, [[14, 19]]);
2001
2063
  }));
2002
2064
  function getRemainingOrderAmountWithInputAsync(_x27, _x28) {
2003
2065
  return _getRemainingOrderAmountWithInputAsync.apply(this, arguments);
@@ -2066,29 +2128,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
2066
2128
  }, {
2067
2129
  key: "getCashPaymentMethod",
2068
2130
  value: (function () {
2069
- var _getCashPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
2131
+ var _getCashPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
2070
2132
  var payMethods;
2071
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2072
- while (1) switch (_context23.prev = _context23.next) {
2133
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2134
+ while (1) switch (_context24.prev = _context24.next) {
2073
2135
  case 0:
2074
- _context23.prev = 0;
2075
- _context23.next = 3;
2136
+ _context24.prev = 0;
2137
+ _context24.next = 3;
2076
2138
  return this.dbManager.getAll('pay_method');
2077
2139
  case 3:
2078
- payMethods = _context23.sent;
2079
- return _context23.abrupt("return", payMethods.find(function (method) {
2140
+ payMethods = _context24.sent;
2141
+ return _context24.abrupt("return", payMethods.find(function (method) {
2080
2142
  return method.code === PaymentMethodType.Cash;
2081
2143
  }) || null);
2082
2144
  case 7:
2083
- _context23.prev = 7;
2084
- _context23.t0 = _context23["catch"](0);
2085
- console.error('[PaymentModule] 获取现金支付方式失败', _context23.t0);
2086
- return _context23.abrupt("return", null);
2145
+ _context24.prev = 7;
2146
+ _context24.t0 = _context24["catch"](0);
2147
+ console.error('[PaymentModule] 获取现金支付方式失败', _context24.t0);
2148
+ return _context24.abrupt("return", null);
2087
2149
  case 11:
2088
2150
  case "end":
2089
- return _context23.stop();
2151
+ return _context24.stop();
2090
2152
  }
2091
- }, _callee23, this, [[0, 7]]);
2153
+ }, _callee24, this, [[0, 7]]);
2092
2154
  }));
2093
2155
  function getCashPaymentMethod() {
2094
2156
  return _getCashPaymentMethod.apply(this, arguments);
@@ -2102,29 +2164,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
2102
2164
  }, {
2103
2165
  key: "getEftposPaymentMethod",
2104
2166
  value: (function () {
2105
- var _getEftposPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
2167
+ var _getEftposPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
2106
2168
  var payMethods;
2107
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2108
- while (1) switch (_context24.prev = _context24.next) {
2169
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2170
+ while (1) switch (_context25.prev = _context25.next) {
2109
2171
  case 0:
2110
- _context24.prev = 0;
2111
- _context24.next = 3;
2172
+ _context25.prev = 0;
2173
+ _context25.next = 3;
2112
2174
  return this.dbManager.getAll('pay_method');
2113
2175
  case 3:
2114
- payMethods = _context24.sent;
2115
- return _context24.abrupt("return", payMethods.find(function (method) {
2176
+ payMethods = _context25.sent;
2177
+ return _context25.abrupt("return", payMethods.find(function (method) {
2116
2178
  return method.code === PaymentMethodType.Eftpos;
2117
2179
  }) || null);
2118
2180
  case 7:
2119
- _context24.prev = 7;
2120
- _context24.t0 = _context24["catch"](0);
2121
- console.error('[PaymentModule] 获取Eftpos支付方式失败', _context24.t0);
2122
- return _context24.abrupt("return", null);
2181
+ _context25.prev = 7;
2182
+ _context25.t0 = _context25["catch"](0);
2183
+ console.error('[PaymentModule] 获取Eftpos支付方式失败', _context25.t0);
2184
+ return _context25.abrupt("return", null);
2123
2185
  case 11:
2124
2186
  case "end":
2125
- return _context24.stop();
2187
+ return _context25.stop();
2126
2188
  }
2127
- }, _callee24, this, [[0, 7]]);
2189
+ }, _callee25, this, [[0, 7]]);
2128
2190
  }));
2129
2191
  function getEftposPaymentMethod() {
2130
2192
  return _getEftposPaymentMethod.apply(this, arguments);
@@ -2138,29 +2200,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
2138
2200
  }, {
2139
2201
  key: "getWalletPaymentMethod",
2140
2202
  value: (function () {
2141
- var _getWalletPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
2203
+ var _getWalletPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
2142
2204
  var payMethods;
2143
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2144
- while (1) switch (_context25.prev = _context25.next) {
2205
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2206
+ while (1) switch (_context26.prev = _context26.next) {
2145
2207
  case 0:
2146
- _context25.prev = 0;
2147
- _context25.next = 3;
2208
+ _context26.prev = 0;
2209
+ _context26.next = 3;
2148
2210
  return this.dbManager.getAll('pay_method');
2149
2211
  case 3:
2150
- payMethods = _context25.sent;
2151
- return _context25.abrupt("return", payMethods.find(function (method) {
2212
+ payMethods = _context26.sent;
2213
+ return _context26.abrupt("return", payMethods.find(function (method) {
2152
2214
  return method.code === PaymentMethodType.Wallet;
2153
2215
  }) || null);
2154
2216
  case 7:
2155
- _context25.prev = 7;
2156
- _context25.t0 = _context25["catch"](0);
2157
- console.error('[PaymentModule] 获取钱包支付方式失败', _context25.t0);
2158
- return _context25.abrupt("return", null);
2217
+ _context26.prev = 7;
2218
+ _context26.t0 = _context26["catch"](0);
2219
+ console.error('[PaymentModule] 获取钱包支付方式失败', _context26.t0);
2220
+ return _context26.abrupt("return", null);
2159
2221
  case 11:
2160
2222
  case "end":
2161
- return _context25.stop();
2223
+ return _context26.stop();
2162
2224
  }
2163
- }, _callee25, this, [[0, 7]]);
2225
+ }, _callee26, this, [[0, 7]]);
2164
2226
  }));
2165
2227
  function getWalletPaymentMethod() {
2166
2228
  return _getWalletPaymentMethod.apply(this, arguments);
@@ -2174,38 +2236,38 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
2174
2236
  }, {
2175
2237
  key: "ensurePaymentTables",
2176
2238
  value: (function () {
2177
- var _ensurePaymentTables = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
2178
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2179
- while (1) switch (_context26.prev = _context26.next) {
2239
+ var _ensurePaymentTables = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
2240
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2241
+ while (1) switch (_context27.prev = _context27.next) {
2180
2242
  case 0:
2181
- _context26.prev = 0;
2182
- _context26.next = 3;
2243
+ _context27.prev = 0;
2244
+ _context27.next = 3;
2183
2245
  return this.dbManager.getAll('pay_method');
2184
2246
  case 3:
2185
- _context26.next = 9;
2247
+ _context27.next = 9;
2186
2248
  break;
2187
2249
  case 5:
2188
- _context26.prev = 5;
2189
- _context26.t0 = _context26["catch"](0);
2250
+ _context27.prev = 5;
2251
+ _context27.t0 = _context27["catch"](0);
2190
2252
  console.warn('[PaymentModule] pay_method 表不存在,请在数据库配置中添加以下配置:');
2191
2253
  console.warn('{ name: "pay_method", keyPath: "id" }');
2192
2254
  case 9:
2193
- _context26.prev = 9;
2194
- _context26.next = 12;
2255
+ _context27.prev = 9;
2256
+ _context27.next = 12;
2195
2257
  return this.dbManager.getAll('order');
2196
2258
  case 12:
2197
- _context26.next = 18;
2259
+ _context27.next = 18;
2198
2260
  break;
2199
2261
  case 14:
2200
- _context26.prev = 14;
2201
- _context26.t1 = _context26["catch"](9);
2262
+ _context27.prev = 14;
2263
+ _context27.t1 = _context27["catch"](9);
2202
2264
  console.warn('[PaymentModule] order 表不存在,请在数据库配置中添加以下配置:');
2203
2265
  console.warn('{ name: "order", keyPath: "uuid" }');
2204
2266
  case 18:
2205
2267
  case "end":
2206
- return _context26.stop();
2268
+ return _context27.stop();
2207
2269
  }
2208
- }, _callee26, this, [[0, 5], [9, 14]]);
2270
+ }, _callee27, this, [[0, 5], [9, 14]]);
2209
2271
  }));
2210
2272
  function ensurePaymentTables() {
2211
2273
  return _ensurePaymentTables.apply(this, arguments);
@@ -2219,29 +2281,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
2219
2281
  }, {
2220
2282
  key: "getPartiallyPaidOrdersAsync",
2221
2283
  value: (function () {
2222
- var _getPartiallyPaidOrdersAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
2284
+ var _getPartiallyPaidOrdersAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
2223
2285
  var allOrders;
2224
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2225
- while (1) switch (_context27.prev = _context27.next) {
2286
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2287
+ while (1) switch (_context28.prev = _context28.next) {
2226
2288
  case 0:
2227
- _context27.prev = 0;
2228
- _context27.next = 3;
2289
+ _context28.prev = 0;
2290
+ _context28.next = 3;
2229
2291
  return this.dbManager.getAll('order');
2230
2292
  case 3:
2231
- allOrders = _context27.sent;
2232
- return _context27.abrupt("return", allOrders.filter(function (order) {
2293
+ allOrders = _context28.sent;
2294
+ return _context28.abrupt("return", allOrders.filter(function (order) {
2233
2295
  return order.payment_status === PaymentStatus.PartiallyPaid;
2234
2296
  }));
2235
2297
  case 7:
2236
- _context27.prev = 7;
2237
- _context27.t0 = _context27["catch"](0);
2238
- console.error('[PaymentModule] 获取部分支付订单失败', _context27.t0);
2239
- return _context27.abrupt("return", []);
2298
+ _context28.prev = 7;
2299
+ _context28.t0 = _context28["catch"](0);
2300
+ console.error('[PaymentModule] 获取部分支付订单失败', _context28.t0);
2301
+ return _context28.abrupt("return", []);
2240
2302
  case 11:
2241
2303
  case "end":
2242
- return _context27.stop();
2304
+ return _context28.stop();
2243
2305
  }
2244
- }, _callee27, this, [[0, 7]]);
2306
+ }, _callee28, this, [[0, 7]]);
2245
2307
  }));
2246
2308
  function getPartiallyPaidOrdersAsync() {
2247
2309
  return _getPartiallyPaidOrdersAsync.apply(this, arguments);
@@ -2262,17 +2324,17 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
2262
2324
  }, {
2263
2325
  key: "roundAmountAsync",
2264
2326
  value: function () {
2265
- var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(originalAmount, interval, rule) {
2327
+ var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(originalAmount, interval, rule) {
2266
2328
  var amount, roundingInterval, supportedIntervals, intervalValue, baseValue, roundedValue, finalAmount, originalAmountStr, roundedAmountStr, roundingDifference, roundingDifferenceStr;
2267
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
2268
- while (1) switch (_context28.prev = _context28.next) {
2329
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
2330
+ while (1) switch (_context29.prev = _context29.next) {
2269
2331
  case 0:
2270
- _context28.prev = 0;
2332
+ _context29.prev = 0;
2271
2333
  // 参数验证
2272
2334
  amount = new Decimal(originalAmount);
2273
2335
  roundingInterval = new Decimal(interval);
2274
2336
  if (!roundingInterval.lte(0)) {
2275
- _context28.next = 5;
2337
+ _context29.next = 5;
2276
2338
  break;
2277
2339
  }
2278
2340
  throw new Error('舍入间隔必须大于 0');
@@ -2287,25 +2349,25 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
2287
2349
  // 计算基础值:x / interval
2288
2350
  baseValue = amount.div(roundingInterval);
2289
2351
  console.log("[PaymentModule] \u820D\u5165\u8BA1\u7B97 - \u539F\u59CB\u91D1\u989D: ".concat(amount.toString(), ", \u95F4\u9694: ").concat(intervalValue, ", \u57FA\u7840\u503C: ").concat(baseValue.toString(), ", \u89C4\u5219: ").concat(rule));
2290
- _context28.t0 = rule;
2291
- _context28.next = _context28.t0 === RoundingRule.Standard ? 13 : _context28.t0 === 'standard' ? 13 : _context28.t0 === RoundingRule.StandardDown ? 15 : _context28.t0 === 'standard_down' ? 15 : _context28.t0 === RoundingRule.AlwaysUp ? 17 : _context28.t0 === 'always_up' ? 17 : _context28.t0 === RoundingRule.AlwaysDown ? 19 : _context28.t0 === 'always_down' ? 19 : 21;
2352
+ _context29.t0 = rule;
2353
+ _context29.next = _context29.t0 === RoundingRule.Standard ? 13 : _context29.t0 === 'standard' ? 13 : _context29.t0 === RoundingRule.StandardDown ? 15 : _context29.t0 === 'standard_down' ? 15 : _context29.t0 === RoundingRule.AlwaysUp ? 17 : _context29.t0 === 'always_up' ? 17 : _context29.t0 === RoundingRule.AlwaysDown ? 19 : _context29.t0 === 'always_down' ? 19 : 21;
2292
2354
  break;
2293
2355
  case 13:
2294
2356
  // 标准舍入(中点向上)
2295
2357
  roundedValue = this.standardRound(baseValue, true);
2296
- return _context28.abrupt("break", 22);
2358
+ return _context29.abrupt("break", 22);
2297
2359
  case 15:
2298
2360
  // 标准舍入(中点向下)
2299
2361
  roundedValue = this.standardRound(baseValue, false);
2300
- return _context28.abrupt("break", 22);
2362
+ return _context29.abrupt("break", 22);
2301
2363
  case 17:
2302
2364
  // 总是向上舍入
2303
2365
  roundedValue = baseValue.ceil();
2304
- return _context28.abrupt("break", 22);
2366
+ return _context29.abrupt("break", 22);
2305
2367
  case 19:
2306
2368
  // 总是向下舍入
2307
2369
  roundedValue = baseValue.floor();
2308
- return _context28.abrupt("break", 22);
2370
+ return _context29.abrupt("break", 22);
2309
2371
  case 21:
2310
2372
  throw new Error("\u4E0D\u652F\u6301\u7684\u820D\u5165\u89C4\u5219: ".concat(rule));
2311
2373
  case 22:
@@ -2313,11 +2375,11 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
2313
2375
  finalAmount = roundedValue.mul(roundingInterval);
2314
2376
  originalAmountStr = amount.toFixed(2); // 如果最终金额是 0 元,则不采用舍入金额,返回原始金额
2315
2377
  if (!finalAmount.eq(0)) {
2316
- _context28.next = 27;
2378
+ _context29.next = 27;
2317
2379
  break;
2318
2380
  }
2319
2381
  console.log("[PaymentModule] \u6700\u7EC8\u91D1\u989D\u4E3A0\uFF0C\u8FD4\u56DE\u539F\u59CB\u91D1\u989D: ".concat(originalAmountStr));
2320
- return _context28.abrupt("return", {
2382
+ return _context29.abrupt("return", {
2321
2383
  originalAmount: originalAmountStr,
2322
2384
  roundedAmount: originalAmountStr,
2323
2385
  roundingDifference: '0.00'
@@ -2327,21 +2389,21 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
2327
2389
  roundingDifference = finalAmount.sub(amount);
2328
2390
  roundingDifferenceStr = roundingDifference.toFixed(2);
2329
2391
  console.log("[PaymentModule] \u820D\u5165\u7ED3\u679C - \u539F\u59CB\u91D1\u989D: ".concat(originalAmountStr, ", \u820D\u5165\u540E\u91D1\u989D: ").concat(roundedAmountStr, ", \u820D\u5165\u5DEE\u989D: ").concat(roundingDifferenceStr));
2330
- return _context28.abrupt("return", {
2392
+ return _context29.abrupt("return", {
2331
2393
  originalAmount: originalAmountStr,
2332
2394
  roundedAmount: roundedAmountStr,
2333
2395
  roundingDifference: roundingDifferenceStr
2334
2396
  });
2335
2397
  case 34:
2336
- _context28.prev = 34;
2337
- _context28.t1 = _context28["catch"](0);
2338
- console.error('[PaymentModule] 金额舍入失败:', _context28.t1);
2339
- throw new Error("\u91D1\u989D\u820D\u5165\u5931\u8D25: ".concat(_context28.t1 instanceof Error ? _context28.t1.message : String(_context28.t1)));
2398
+ _context29.prev = 34;
2399
+ _context29.t1 = _context29["catch"](0);
2400
+ console.error('[PaymentModule] 金额舍入失败:', _context29.t1);
2401
+ throw new Error("\u91D1\u989D\u820D\u5165\u5931\u8D25: ".concat(_context29.t1 instanceof Error ? _context29.t1.message : String(_context29.t1)));
2340
2402
  case 38:
2341
2403
  case "end":
2342
- return _context28.stop();
2404
+ return _context29.stop();
2343
2405
  }
2344
- }, _callee28, this, [[0, 34]]);
2406
+ }, _callee29, this, [[0, 34]]);
2345
2407
  }));
2346
2408
  function roundAmountAsync(_x29, _x30, _x31) {
2347
2409
  return _roundAmountAsync.apply(this, arguments);