@pisell/pisellos 2.2.13 → 2.2.15

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 (31) hide show
  1. package/dist/modules/Customer/index.js +1 -1
  2. package/dist/modules/Order/index.js +18 -13
  3. package/dist/modules/Payment/index.d.ts +1 -0
  4. package/dist/modules/Payment/index.js +537 -500
  5. package/dist/modules/Payment/types.d.ts +0 -1
  6. package/dist/modules/Payment/walletpass.js +1 -3
  7. package/dist/modules/ProductList/index.js +9 -8
  8. package/dist/modules/Rules/index.js +34 -66
  9. package/dist/solution/BookingByStep/index.js +8 -29
  10. package/dist/solution/BookingByStep/utils/products.d.ts +0 -6
  11. package/dist/solution/BookingByStep/utils/products.js +0 -10
  12. package/dist/solution/BookingTicket/index.d.ts +1 -1
  13. package/dist/solution/Checkout/index.js +21 -65
  14. package/dist/solution/Checkout/utils/index.d.ts +2 -1
  15. package/dist/solution/Checkout/utils/index.js +6 -4
  16. package/lib/modules/Customer/index.js +1 -1
  17. package/lib/modules/Order/index.js +20 -18
  18. package/lib/modules/Payment/index.d.ts +1 -0
  19. package/lib/modules/Payment/index.js +19 -3
  20. package/lib/modules/Payment/types.d.ts +0 -1
  21. package/lib/modules/Payment/walletpass.js +1 -10
  22. package/lib/modules/ProductList/index.js +7 -0
  23. package/lib/modules/Rules/index.js +36 -46
  24. package/lib/solution/BookingByStep/index.js +2 -15
  25. package/lib/solution/BookingByStep/utils/products.d.ts +0 -6
  26. package/lib/solution/BookingByStep/utils/products.js +2 -8
  27. package/lib/solution/BookingTicket/index.d.ts +1 -1
  28. package/lib/solution/Checkout/index.js +20 -69
  29. package/lib/solution/Checkout/utils/index.d.ts +2 -1
  30. package/lib/solution/Checkout/utils/index.js +6 -4
  31. package/package.json +2 -2
@@ -21,7 +21,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
21
21
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
22
22
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
23
23
  import { BaseModule } from "../BaseModule";
24
- import { PaymentStatus, PaymentMethodType, RoundingRule } from "./types";
24
+ import { PaymentStatus, PaymentHooks, PaymentMethodType, RoundingRule } from "./types";
25
25
  import { getUniqueId } from "../Cart/utils";
26
26
  import { CashPaymentImpl } from "./cash";
27
27
  import { EftposPaymentImpl } from "./eftpos";
@@ -273,105 +273,143 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
273
273
  };
274
274
  }());
275
275
  }
276
-
276
+ }, {
277
+ key: "filterPayMethods",
278
+ value: function () {
279
+ var _filterPayMethods = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(payMethods) {
280
+ var walletPassMethod;
281
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
282
+ while (1) switch (_context3.prev = _context3.next) {
283
+ case 0:
284
+ // 1. 筛选 status === 1 && disable === 0的数据
285
+ // 2. 检查列表里是否有 code=WALLET_PASS的数据,如果没有,则列表里如果有 PRODUCTVOUCHER 、 GIFTCARD 、 POINTCARD 则删除他们
286
+ // 如果有 code = WALLET_PASS的数据,则列表里PRODUCTVOUCHER 、 GIFTCARD 、 POINTCARD 的channel_application 指向 WALLET_PASS 的 channel_application
287
+ payMethods.filter(function (method) {
288
+ return method.status === 1 && method.disable === 0;
289
+ });
290
+ walletPassMethod = payMethods.find(function (method) {
291
+ return method.code === 'WALLET_PASS';
292
+ });
293
+ if (walletPassMethod) {
294
+ payMethods.forEach(function (method) {
295
+ if (method.code === 'PRODUCTVOUCHER' || method.code === 'GIFTCARD' || method.code === 'POINTCARD') {
296
+ method.channel_application = walletPassMethod.channel_application;
297
+ }
298
+ });
299
+ } else {
300
+ payMethods = payMethods.filter(function (method) {
301
+ return method.code !== 'PRODUCTVOUCHER' && method.code !== 'GIFTCARD' && method.code !== 'POINTCARD';
302
+ });
303
+ }
304
+ return _context3.abrupt("return", payMethods);
305
+ case 4:
306
+ case "end":
307
+ return _context3.stop();
308
+ }
309
+ }, _callee3);
310
+ }));
311
+ function filterPayMethods(_x4) {
312
+ return _filterPayMethods.apply(this, arguments);
313
+ }
314
+ return filterPayMethods;
315
+ }()
277
316
  /**
278
317
  * 获取支付方式列表
279
318
  */
280
319
  }, {
281
320
  key: "getPayMethodListAsync",
282
321
  value: (function () {
283
- var _getPayMethodListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
322
+ var _getPayMethodListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
284
323
  var cachedMethods, hasCache, response, payMethods, _iterator, _step, method;
285
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
286
- while (1) switch (_context3.prev = _context3.next) {
324
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
325
+ while (1) switch (_context4.prev = _context4.next) {
287
326
  case 0:
288
327
  this.logInfo('Starting getPayMethodListAsync');
289
- _context3.prev = 1;
328
+ _context4.prev = 1;
290
329
  // 先尝试从 IndexDB 获取缓存
291
330
  cachedMethods = [];
292
- _context3.prev = 3;
293
- _context3.next = 6;
331
+ _context4.prev = 3;
332
+ _context4.next = 6;
294
333
  return this.dbManager.getAll('pay_method');
295
334
  case 6:
296
- cachedMethods = _context3.sent;
297
- _context3.next = 12;
335
+ cachedMethods = _context4.sent;
336
+ _context4.next = 12;
298
337
  break;
299
338
  case 9:
300
- _context3.prev = 9;
301
- _context3.t0 = _context3["catch"](3);
339
+ _context4.prev = 9;
340
+ _context4.t0 = _context4["catch"](3);
302
341
  console.warn('[PaymentModule] pay_method 表不存在,将从服务器获取数据');
303
342
  case 12:
304
343
  // 如果有缓存,先返回缓存数据
305
344
  hasCache = cachedMethods.length > 0;
306
345
  if (!hasCache) {
307
- _context3.next = 16;
346
+ _context4.next = 16;
308
347
  break;
309
348
  }
310
349
  // 后台异步获取最新数据
311
350
  this.refreshPaymentMethodsInBackground(cachedMethods);
312
- return _context3.abrupt("return", cachedMethods);
351
+ return _context4.abrupt("return", cachedMethods);
313
352
  case 16:
314
- _context3.next = 18;
315
- return this.request.get('/pay/custom-payment/available', {
316
- channel: 'pos'
317
- });
353
+ _context4.next = 18;
354
+ return this.request.get('/pay/custom-payment/all');
318
355
  case 18:
319
- response = _context3.sent;
356
+ response = _context4.sent;
357
+ response.data = this.filterPayMethods(response.data);
320
358
  payMethods = response.data || []; // 尝试缓存到 IndexDB
321
- _context3.prev = 20;
359
+ _context4.prev = 21;
322
360
  _iterator = _createForOfIteratorHelper(payMethods);
323
- _context3.prev = 22;
361
+ _context4.prev = 23;
324
362
  _iterator.s();
325
- case 24:
363
+ case 25:
326
364
  if ((_step = _iterator.n()).done) {
327
- _context3.next = 30;
365
+ _context4.next = 31;
328
366
  break;
329
367
  }
330
368
  method = _step.value;
331
- _context3.next = 28;
369
+ _context4.next = 29;
332
370
  return this.dbManager.update('pay_method', method);
333
- case 28:
334
- _context3.next = 24;
371
+ case 29:
372
+ _context4.next = 25;
335
373
  break;
336
- case 30:
337
- _context3.next = 35;
374
+ case 31:
375
+ _context4.next = 36;
338
376
  break;
339
- case 32:
340
- _context3.prev = 32;
341
- _context3.t1 = _context3["catch"](22);
342
- _iterator.e(_context3.t1);
343
- case 35:
344
- _context3.prev = 35;
377
+ case 33:
378
+ _context4.prev = 33;
379
+ _context4.t1 = _context4["catch"](23);
380
+ _iterator.e(_context4.t1);
381
+ case 36:
382
+ _context4.prev = 36;
345
383
  _iterator.f();
346
- return _context3.finish(35);
347
- case 38:
348
- _context3.next = 43;
384
+ return _context4.finish(36);
385
+ case 39:
386
+ _context4.next = 44;
349
387
  break;
350
- case 40:
351
- _context3.prev = 40;
352
- _context3.t2 = _context3["catch"](20);
388
+ case 41:
389
+ _context4.prev = 41;
390
+ _context4.t2 = _context4["catch"](21);
353
391
  console.warn('[PaymentModule] 无法缓存支付方式,pay_method 表不存在');
354
- case 43:
355
- _context3.next = 45;
392
+ case 44:
393
+ _context4.next = 46;
356
394
  return this.core.effects.emit("".concat(this.name, ":onPaymentMethodsLoaded"), payMethods);
357
- case 45:
395
+ case 46:
358
396
  this.logInfo('getPayMethodListAsync completed successfully', {
359
397
  methodCount: payMethods.length,
360
398
  hasCache: cachedMethods.length > 0
361
399
  });
362
- return _context3.abrupt("return", payMethods);
363
- case 49:
364
- _context3.prev = 49;
365
- _context3.t3 = _context3["catch"](1);
366
- console.error('[PaymentModule] 获取支付方式列表失败', _context3.t3);
367
- this.logError('getPayMethodListAsync failed', _context3.t3);
400
+ return _context4.abrupt("return", payMethods);
401
+ case 50:
402
+ _context4.prev = 50;
403
+ _context4.t3 = _context4["catch"](1);
404
+ console.error('[PaymentModule] 获取支付方式列表失败', _context4.t3);
405
+ this.logError('getPayMethodListAsync failed', _context4.t3);
368
406
  // 如果所有操作都失败,返回空数组
369
- return _context3.abrupt("return", []);
370
- case 54:
407
+ return _context4.abrupt("return", []);
408
+ case 55:
371
409
  case "end":
372
- return _context3.stop();
410
+ return _context4.stop();
373
411
  }
374
- }, _callee3, this, [[1, 49], [3, 9], [20, 40], [22, 32, 35, 38]]);
412
+ }, _callee4, this, [[1, 50], [3, 9], [21, 41], [23, 33, 36, 39]]);
375
413
  }));
376
414
  function getPayMethodListAsync() {
377
415
  return _getPayMethodListAsync.apply(this, arguments);
@@ -385,28 +423,27 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
385
423
  }, {
386
424
  key: "refreshPaymentMethodsInBackground",
387
425
  value: (function () {
388
- var _refreshPaymentMethodsInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(cachedMethods) {
426
+ var _refreshPaymentMethodsInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(cachedMethods) {
389
427
  var response, newPayMethods, hasChanges, _iterator2, _step2, method, _iterator3, _step3, _method, eventData;
390
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
391
- while (1) switch (_context4.prev = _context4.next) {
428
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
429
+ while (1) switch (_context5.prev = _context5.next) {
392
430
  case 0:
393
431
  this.logInfo('Starting refreshPaymentMethodsInBackground', {
394
432
  cachedMethodsCount: cachedMethods.length
395
433
  });
396
- _context4.prev = 1;
434
+ _context5.prev = 1;
397
435
  console.log('[PaymentModule] 后台刷新支付方式列表...');
398
436
 
399
437
  // 从服务器获取最新数据
400
- _context4.next = 5;
401
- return this.request.get('/pay/custom-payment/available', {
402
- channel: 'pos'
403
- });
438
+ _context5.next = 5;
439
+ return this.request.get('/pay/custom-payment/all');
404
440
  case 5:
405
- response = _context4.sent;
441
+ response = _context5.sent;
442
+ response.data = this.filterPayMethods(response.data);
406
443
  newPayMethods = response.data || []; // 检查是否有变化
407
444
  hasChanges = this.hasPaymentMethodsChanged(cachedMethods, newPayMethods);
408
445
  if (!hasChanges) {
409
- _context4.next = 56;
446
+ _context5.next = 57;
410
447
  break;
411
448
  }
412
449
  console.log('[PaymentModule] 支付方式列表已更新');
@@ -416,94 +453,94 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
416
453
  });
417
454
 
418
455
  // 更新缓存
419
- _context4.prev = 11;
456
+ _context5.prev = 12;
420
457
  // 先清除旧数据
421
458
  _iterator2 = _createForOfIteratorHelper(cachedMethods);
422
- _context4.prev = 13;
459
+ _context5.prev = 14;
423
460
  _iterator2.s();
424
- case 15:
461
+ case 16:
425
462
  if ((_step2 = _iterator2.n()).done) {
426
- _context4.next = 21;
463
+ _context5.next = 22;
427
464
  break;
428
465
  }
429
466
  method = _step2.value;
430
- _context4.next = 19;
467
+ _context5.next = 20;
431
468
  return this.dbManager.delete('pay_method', method.id);
432
- case 19:
433
- _context4.next = 15;
469
+ case 20:
470
+ _context5.next = 16;
434
471
  break;
435
- case 21:
436
- _context4.next = 26;
472
+ case 22:
473
+ _context5.next = 27;
437
474
  break;
438
- case 23:
439
- _context4.prev = 23;
440
- _context4.t0 = _context4["catch"](13);
441
- _iterator2.e(_context4.t0);
442
- case 26:
443
- _context4.prev = 26;
475
+ case 24:
476
+ _context5.prev = 24;
477
+ _context5.t0 = _context5["catch"](14);
478
+ _iterator2.e(_context5.t0);
479
+ case 27:
480
+ _context5.prev = 27;
444
481
  _iterator2.f();
445
- return _context4.finish(26);
446
- case 29:
482
+ return _context5.finish(27);
483
+ case 30:
447
484
  // 添加新数据
448
485
  _iterator3 = _createForOfIteratorHelper(newPayMethods);
449
- _context4.prev = 30;
486
+ _context5.prev = 31;
450
487
  _iterator3.s();
451
- case 32:
488
+ case 33:
452
489
  if ((_step3 = _iterator3.n()).done) {
453
- _context4.next = 38;
490
+ _context5.next = 39;
454
491
  break;
455
492
  }
456
493
  _method = _step3.value;
457
- _context4.next = 36;
494
+ _context5.next = 37;
458
495
  return this.dbManager.update('pay_method', _method);
459
- case 36:
460
- _context4.next = 32;
496
+ case 37:
497
+ _context5.next = 33;
461
498
  break;
462
- case 38:
463
- _context4.next = 43;
499
+ case 39:
500
+ _context5.next = 44;
464
501
  break;
465
- case 40:
466
- _context4.prev = 40;
467
- _context4.t1 = _context4["catch"](30);
468
- _iterator3.e(_context4.t1);
469
- case 43:
470
- _context4.prev = 43;
502
+ case 41:
503
+ _context5.prev = 41;
504
+ _context5.t1 = _context5["catch"](31);
505
+ _iterator3.e(_context5.t1);
506
+ case 44:
507
+ _context5.prev = 44;
471
508
  _iterator3.f();
472
- return _context4.finish(43);
473
- case 46:
474
- _context4.next = 51;
509
+ return _context5.finish(44);
510
+ case 47:
511
+ _context5.next = 52;
475
512
  break;
476
- case 48:
477
- _context4.prev = 48;
478
- _context4.t2 = _context4["catch"](11);
479
- console.warn('[PaymentModule] 无法更新支付方式缓存', _context4.t2);
480
- case 51:
513
+ case 49:
514
+ _context5.prev = 49;
515
+ _context5.t2 = _context5["catch"](12);
516
+ console.warn('[PaymentModule] 无法更新支付方式缓存', _context5.t2);
517
+ case 52:
481
518
  // 通知外部支付方式已变化
482
519
  eventData = {
483
520
  oldMethods: cachedMethods,
484
521
  newMethods: newPayMethods
485
522
  };
486
- _context4.next = 54;
523
+ _context5.next = 55;
487
524
  return this.core.effects.emit("".concat(this.name, ":onPaymentMethodsChanged"), eventData);
488
- case 54:
489
- _context4.next = 57;
525
+ case 55:
526
+ _context5.next = 58;
490
527
  break;
491
- case 56:
492
- console.log('[PaymentModule] 支付方式列表无变化');
493
528
  case 57:
494
- _context4.next = 62;
529
+ console.log('[PaymentModule] 支付方式列表无变化');
530
+ case 58:
531
+ _context5.next = 63;
495
532
  break;
496
- case 59:
497
- _context4.prev = 59;
498
- _context4.t3 = _context4["catch"](1);
499
- console.error('[PaymentModule] 后台刷新支付方式失败', _context4.t3);
500
- case 62:
533
+ case 60:
534
+ _context5.prev = 60;
535
+ _context5.t3 = _context5["catch"](1);
536
+ console.error('[PaymentModule] 后台刷新支付方式失败', _context5.t3);
537
+ case 63:
501
538
  case "end":
502
- return _context4.stop();
539
+ return _context5.stop();
503
540
  }
504
- }, _callee4, this, [[1, 59], [11, 48], [13, 23, 26, 29], [30, 40, 43, 46]]);
541
+ }, _callee5, this, [[1, 60], [12, 49], [14, 24, 27, 30], [31, 41, 44, 47]]);
505
542
  }));
506
- function refreshPaymentMethodsInBackground(_x4) {
543
+ function refreshPaymentMethodsInBackground(_x5) {
507
544
  return _refreshPaymentMethodsInBackground.apply(this, arguments);
508
545
  }
509
546
  return refreshPaymentMethodsInBackground;
@@ -611,25 +648,25 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
611
648
  }, {
612
649
  key: "getOrderListAsync",
613
650
  value: (function () {
614
- var _getOrderListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
615
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
616
- while (1) switch (_context5.prev = _context5.next) {
651
+ var _getOrderListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
652
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
653
+ while (1) switch (_context6.prev = _context6.next) {
617
654
  case 0:
618
- _context5.prev = 0;
619
- _context5.next = 3;
655
+ _context6.prev = 0;
656
+ _context6.next = 3;
620
657
  return this.dbManager.getAll('order');
621
658
  case 3:
622
- return _context5.abrupt("return", _context5.sent);
659
+ return _context6.abrupt("return", _context6.sent);
623
660
  case 6:
624
- _context5.prev = 6;
625
- _context5.t0 = _context5["catch"](0);
626
- console.error('[PaymentModule] 获取订单列表失败', _context5.t0);
627
- return _context5.abrupt("return", []);
661
+ _context6.prev = 6;
662
+ _context6.t0 = _context6["catch"](0);
663
+ console.error('[PaymentModule] 获取订单列表失败', _context6.t0);
664
+ return _context6.abrupt("return", []);
628
665
  case 10:
629
666
  case "end":
630
- return _context5.stop();
667
+ return _context6.stop();
631
668
  }
632
- }, _callee5, this, [[0, 6]]);
669
+ }, _callee6, this, [[0, 6]]);
633
670
  }));
634
671
  function getOrderListAsync() {
635
672
  return _getOrderListAsync.apply(this, arguments);
@@ -643,27 +680,27 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
643
680
  }, {
644
681
  key: "getPaymentOrderByUuidAsync",
645
682
  value: (function () {
646
- var _getPaymentOrderByUuidAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(orderUuid) {
647
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
648
- while (1) switch (_context6.prev = _context6.next) {
683
+ var _getPaymentOrderByUuidAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(orderUuid) {
684
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
685
+ while (1) switch (_context7.prev = _context7.next) {
649
686
  case 0:
650
- _context6.prev = 0;
651
- _context6.next = 3;
687
+ _context7.prev = 0;
688
+ _context7.next = 3;
652
689
  return this.dbManager.get('order', orderUuid, true);
653
690
  case 3:
654
- return _context6.abrupt("return", _context6.sent);
691
+ return _context7.abrupt("return", _context7.sent);
655
692
  case 6:
656
- _context6.prev = 6;
657
- _context6.t0 = _context6["catch"](0);
658
- console.error('[PaymentModule] 获取支付订单失败', _context6.t0);
659
- return _context6.abrupt("return", null);
693
+ _context7.prev = 6;
694
+ _context7.t0 = _context7["catch"](0);
695
+ console.error('[PaymentModule] 获取支付订单失败', _context7.t0);
696
+ return _context7.abrupt("return", null);
660
697
  case 10:
661
698
  case "end":
662
- return _context6.stop();
699
+ return _context7.stop();
663
700
  }
664
- }, _callee6, this, [[0, 6]]);
701
+ }, _callee7, this, [[0, 6]]);
665
702
  }));
666
- function getPaymentOrderByUuidAsync(_x5) {
703
+ function getPaymentOrderByUuidAsync(_x6) {
667
704
  return _getPaymentOrderByUuidAsync.apply(this, arguments);
668
705
  }
669
706
  return getPaymentOrderByUuidAsync;
@@ -675,17 +712,17 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
675
712
  }, {
676
713
  key: "createPaymentOrderAsync",
677
714
  value: (function () {
678
- var _createPaymentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(params) {
715
+ var _createPaymentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
679
716
  var _this3 = this;
680
717
  var newOrder, currentTime, dbAddStartTime, dbAddDuration;
681
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
682
- while (1) switch (_context7.prev = _context7.next) {
718
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
719
+ while (1) switch (_context8.prev = _context8.next) {
683
720
  case 0:
684
721
  this.logInfo('Starting createPaymentOrderAsync', {
685
722
  orderId: params.order_id,
686
723
  totalAmount: params.total_amount
687
724
  });
688
- _context7.prev = 1;
725
+ _context8.prev = 1;
689
726
  // 检测是否有重复的 order_id
690
727
  // console.time('createLocalOrderAsync: getExistingOrder')
691
728
  // const existingOrder = await this.dbManager.get('order', params.order_id);
@@ -771,7 +808,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
771
808
 
772
809
  // 🚀 性能监控:记录数据库添加操作耗时
773
810
  dbAddStartTime = Date.now();
774
- _context7.next = 7;
811
+ _context8.next = 7;
775
812
  return this.dbManager.add('order', newOrder, true);
776
813
  case 7:
777
814
  dbAddDuration = Date.now() - dbAddStartTime;
@@ -786,22 +823,22 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
786
823
  setTimeout(function () {
787
824
  _this3.core.effects.emit("".concat(_this3.name, ":onOrderAdded"), newOrder);
788
825
  }, 0);
789
- return _context7.abrupt("return", newOrder);
826
+ return _context8.abrupt("return", newOrder);
790
827
  case 13:
791
- _context7.prev = 13;
792
- _context7.t0 = _context7["catch"](1);
793
- console.error('[PaymentModule] 创建支付订单失败', _context7.t0);
794
- this.logError('createPaymentOrderAsync failed', _context7.t0, {
828
+ _context8.prev = 13;
829
+ _context8.t0 = _context8["catch"](1);
830
+ console.error('[PaymentModule] 创建支付订单失败', _context8.t0);
831
+ this.logError('createPaymentOrderAsync failed', _context8.t0, {
795
832
  orderId: params.order_id
796
833
  });
797
- throw _context7.t0;
834
+ throw _context8.t0;
798
835
  case 18:
799
836
  case "end":
800
- return _context7.stop();
837
+ return _context8.stop();
801
838
  }
802
- }, _callee7, this, [[1, 13]]);
839
+ }, _callee8, this, [[1, 13]]);
803
840
  }));
804
- function createPaymentOrderAsync(_x6) {
841
+ function createPaymentOrderAsync(_x7) {
805
842
  return _createPaymentOrderAsync.apply(this, arguments);
806
843
  }
807
844
  return createPaymentOrderAsync;
@@ -813,42 +850,42 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
813
850
  }, {
814
851
  key: "deletePaymentOrderAsync",
815
852
  value: (function () {
816
- var _deletePaymentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(orderUuid) {
853
+ var _deletePaymentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(orderUuid) {
817
854
  var order;
818
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
819
- while (1) switch (_context8.prev = _context8.next) {
855
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
856
+ while (1) switch (_context9.prev = _context9.next) {
820
857
  case 0:
821
- _context8.prev = 0;
822
- _context8.next = 3;
858
+ _context9.prev = 0;
859
+ _context9.next = 3;
823
860
  return this.dbManager.get('order', orderUuid);
824
861
  case 3:
825
- order = _context8.sent;
862
+ order = _context9.sent;
826
863
  if (!order) {
827
- _context8.next = 10;
864
+ _context9.next = 10;
828
865
  break;
829
866
  }
830
- _context8.next = 7;
867
+ _context9.next = 7;
831
868
  return this.dbManager.delete('order', orderUuid);
832
869
  case 7:
833
- _context8.next = 9;
870
+ _context9.next = 9;
834
871
  return this.core.effects.emit("".concat(this.name, ":onOrderDeleted"), order);
835
872
  case 9:
836
873
  console.log('[PaymentModule] 支付订单删除成功:', orderUuid);
837
874
  case 10:
838
- _context8.next = 16;
875
+ _context9.next = 16;
839
876
  break;
840
877
  case 12:
841
- _context8.prev = 12;
842
- _context8.t0 = _context8["catch"](0);
843
- console.error('[PaymentModule] 删除支付订单失败', _context8.t0);
844
- throw _context8.t0;
878
+ _context9.prev = 12;
879
+ _context9.t0 = _context9["catch"](0);
880
+ console.error('[PaymentModule] 删除支付订单失败', _context9.t0);
881
+ throw _context9.t0;
845
882
  case 16:
846
883
  case "end":
847
- return _context8.stop();
884
+ return _context9.stop();
848
885
  }
849
- }, _callee8, this, [[0, 12]]);
886
+ }, _callee9, this, [[0, 12]]);
850
887
  }));
851
- function deletePaymentOrderAsync(_x7) {
888
+ function deletePaymentOrderAsync(_x8) {
852
889
  return _deletePaymentOrderAsync.apply(this, arguments);
853
890
  }
854
891
  return deletePaymentOrderAsync;
@@ -860,49 +897,49 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
860
897
  }, {
861
898
  key: "updateOrderAsync",
862
899
  value: (function () {
863
- var _updateOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(orderUuid, params) {
900
+ var _updateOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(orderUuid, params) {
864
901
  var order, updatedOrder;
865
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
866
- while (1) switch (_context9.prev = _context9.next) {
902
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
903
+ while (1) switch (_context10.prev = _context10.next) {
867
904
  case 0:
868
- _context9.prev = 0;
869
- _context9.next = 3;
905
+ _context10.prev = 0;
906
+ _context10.next = 3;
870
907
  return this.dbManager.get('order', orderUuid);
871
908
  case 3:
872
- order = _context9.sent;
909
+ order = _context10.sent;
873
910
  if (!order) {
874
- _context9.next = 13;
911
+ _context10.next = 13;
875
912
  break;
876
913
  }
877
914
  updatedOrder = _objectSpread(_objectSpread({}, order), params);
878
915
  this.recalculateOrderAmount(updatedOrder);
879
- _context9.next = 9;
916
+ _context10.next = 9;
880
917
  return this.dbManager.update('order', updatedOrder);
881
918
  case 9:
882
- _context9.next = 11;
919
+ _context10.next = 11;
883
920
  return this.core.effects.emit("".concat(this.name, ":onOrderUpdated"), updatedOrder);
884
921
  case 11:
885
- _context9.next = 13;
922
+ _context10.next = 13;
886
923
  return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
887
924
  action: 'update',
888
925
  order: updatedOrder,
889
926
  originalOrder: order
890
927
  });
891
928
  case 13:
892
- _context9.next = 19;
929
+ _context10.next = 19;
893
930
  break;
894
931
  case 15:
895
- _context9.prev = 15;
896
- _context9.t0 = _context9["catch"](0);
897
- console.error('[PaymentModule] 更新订单失败', _context9.t0);
898
- throw _context9.t0;
932
+ _context10.prev = 15;
933
+ _context10.t0 = _context10["catch"](0);
934
+ console.error('[PaymentModule] 更新订单失败', _context10.t0);
935
+ throw _context10.t0;
899
936
  case 19:
900
937
  case "end":
901
- return _context9.stop();
938
+ return _context10.stop();
902
939
  }
903
- }, _callee9, this, [[0, 15]]);
940
+ }, _callee10, this, [[0, 15]]);
904
941
  }));
905
- function updateOrderAsync(_x8, _x9) {
942
+ function updateOrderAsync(_x9, _x10) {
906
943
  return _updateOrderAsync.apply(this, arguments);
907
944
  }
908
945
  return updateOrderAsync;
@@ -921,38 +958,38 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
921
958
  }, {
922
959
  key: "replaceOrderIdByUuidAsync",
923
960
  value: (function () {
924
- var _replaceOrderIdByUuidAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(orderUuid, newOrderId) {
961
+ var _replaceOrderIdByUuidAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(orderUuid, newOrderId) {
925
962
  var existingOrder, allOrders, duplicateOrder, originalOrderId, updatedOrder;
926
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
927
- while (1) switch (_context10.prev = _context10.next) {
963
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
964
+ while (1) switch (_context11.prev = _context11.next) {
928
965
  case 0:
929
966
  this.logInfo('Starting replaceOrderIdByUuidAsync', {
930
967
  orderUuid: orderUuid,
931
968
  newOrderId: newOrderId
932
969
  });
933
- _context10.prev = 1;
934
- _context10.next = 4;
970
+ _context11.prev = 1;
971
+ _context11.next = 4;
935
972
  return this.dbManager.get('order', orderUuid);
936
973
  case 4:
937
- existingOrder = _context10.sent;
974
+ existingOrder = _context11.sent;
938
975
  if (existingOrder) {
939
- _context10.next = 8;
976
+ _context11.next = 8;
940
977
  break;
941
978
  }
942
979
  this.logWarning('Order not found for UUID replacement', {
943
980
  orderUuid: orderUuid
944
981
  });
945
- return _context10.abrupt("return", null);
982
+ return _context11.abrupt("return", null);
946
983
  case 8:
947
- _context10.next = 10;
984
+ _context11.next = 10;
948
985
  return this.dbManager.getAll('order');
949
986
  case 10:
950
- allOrders = _context10.sent;
987
+ allOrders = _context11.sent;
951
988
  duplicateOrder = allOrders.find(function (order) {
952
989
  return String(order.order_id) === String(newOrderId) && order.uuid !== orderUuid;
953
990
  });
954
991
  if (!duplicateOrder) {
955
- _context10.next = 15;
992
+ _context11.next = 15;
956
993
  break;
957
994
  }
958
995
  this.logWarning('New order ID already exists', {
@@ -974,13 +1011,13 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
974
1011
  updated_at: new Date().toISOString()
975
1012
  })
976
1013
  }); // 更新到数据库
977
- _context10.next = 19;
1014
+ _context11.next = 19;
978
1015
  return this.dbManager.update('order', updatedOrder);
979
1016
  case 19:
980
- _context10.next = 21;
1017
+ _context11.next = 21;
981
1018
  return this.core.effects.emit("".concat(this.name, ":onOrderUpdated"), updatedOrder);
982
1019
  case 21:
983
- _context10.next = 23;
1020
+ _context11.next = 23;
984
1021
  return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
985
1022
  action: 'order_id_replaced',
986
1023
  order: updatedOrder,
@@ -997,23 +1034,23 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
997
1034
  newOrderId: newOrderId
998
1035
  });
999
1036
  console.log("[PaymentModule] \u8BA2\u5355ID\u66FF\u6362\u6210\u529F: ".concat(originalOrderId, " \u2192 ").concat(newOrderId));
1000
- return _context10.abrupt("return", updatedOrder);
1037
+ return _context11.abrupt("return", updatedOrder);
1001
1038
  case 28:
1002
- _context10.prev = 28;
1003
- _context10.t0 = _context10["catch"](1);
1004
- console.error('[PaymentModule] 替换订单ID失败', _context10.t0);
1005
- this.logError('replaceOrderIdByUuidAsync failed', _context10.t0, {
1039
+ _context11.prev = 28;
1040
+ _context11.t0 = _context11["catch"](1);
1041
+ console.error('[PaymentModule] 替换订单ID失败', _context11.t0);
1042
+ this.logError('replaceOrderIdByUuidAsync failed', _context11.t0, {
1006
1043
  orderUuid: orderUuid,
1007
1044
  newOrderId: newOrderId
1008
1045
  });
1009
- throw _context10.t0;
1046
+ throw _context11.t0;
1010
1047
  case 33:
1011
1048
  case "end":
1012
- return _context10.stop();
1049
+ return _context11.stop();
1013
1050
  }
1014
- }, _callee10, this, [[1, 28]]);
1051
+ }, _callee11, this, [[1, 28]]);
1015
1052
  }));
1016
- function replaceOrderIdByUuidAsync(_x10, _x11) {
1053
+ function replaceOrderIdByUuidAsync(_x11, _x12) {
1017
1054
  return _replaceOrderIdByUuidAsync.apply(this, arguments);
1018
1055
  }
1019
1056
  return replaceOrderIdByUuidAsync;
@@ -1029,42 +1066,42 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1029
1066
  }, {
1030
1067
  key: "getPaymentItemsAsync",
1031
1068
  value: (function () {
1032
- var _getPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(orderUuid) {
1069
+ var _getPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(orderUuid) {
1033
1070
  var includeVoided,
1034
1071
  order,
1035
1072
  allPayments,
1036
- _args11 = arguments;
1037
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1038
- while (1) switch (_context11.prev = _context11.next) {
1073
+ _args12 = arguments;
1074
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1075
+ while (1) switch (_context12.prev = _context12.next) {
1039
1076
  case 0:
1040
- includeVoided = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : false;
1077
+ includeVoided = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : false;
1041
1078
  if (orderUuid) {
1042
- _context11.next = 3;
1079
+ _context12.next = 3;
1043
1080
  break;
1044
1081
  }
1045
1082
  throw new Error('orderUuid is required');
1046
1083
  case 3:
1047
- _context11.next = 5;
1084
+ _context12.next = 5;
1048
1085
  return this.getPaymentOrderByUuidAsync(orderUuid);
1049
1086
  case 5:
1050
- order = _context11.sent;
1087
+ order = _context12.sent;
1051
1088
  allPayments = (order === null || order === void 0 ? void 0 : order.payment) || [];
1052
1089
  if (!includeVoided) {
1053
- _context11.next = 9;
1090
+ _context12.next = 9;
1054
1091
  break;
1055
1092
  }
1056
- return _context11.abrupt("return", allPayments);
1093
+ return _context12.abrupt("return", allPayments);
1057
1094
  case 9:
1058
- return _context11.abrupt("return", allPayments.filter(function (payment) {
1095
+ return _context12.abrupt("return", allPayments.filter(function (payment) {
1059
1096
  return payment.status !== 'voided';
1060
1097
  }));
1061
1098
  case 10:
1062
1099
  case "end":
1063
- return _context11.stop();
1100
+ return _context12.stop();
1064
1101
  }
1065
- }, _callee11, this);
1102
+ }, _callee12, this);
1066
1103
  }));
1067
- function getPaymentItemsAsync(_x12) {
1104
+ function getPaymentItemsAsync(_x13) {
1068
1105
  return _getPaymentItemsAsync.apply(this, arguments);
1069
1106
  }
1070
1107
  return getPaymentItemsAsync;
@@ -1079,18 +1116,18 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1079
1116
  }, {
1080
1117
  key: "getAllPaymentItemsAsync",
1081
1118
  value: (function () {
1082
- var _getAllPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(orderUuid) {
1083
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1084
- while (1) switch (_context12.prev = _context12.next) {
1119
+ var _getAllPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderUuid) {
1120
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1121
+ while (1) switch (_context13.prev = _context13.next) {
1085
1122
  case 0:
1086
- return _context12.abrupt("return", this.getPaymentItemsAsync(orderUuid, true));
1123
+ return _context13.abrupt("return", this.getPaymentItemsAsync(orderUuid, true));
1087
1124
  case 1:
1088
1125
  case "end":
1089
- return _context12.stop();
1126
+ return _context13.stop();
1090
1127
  }
1091
- }, _callee12, this);
1128
+ }, _callee13, this);
1092
1129
  }));
1093
- function getAllPaymentItemsAsync(_x13) {
1130
+ function getAllPaymentItemsAsync(_x14) {
1094
1131
  return _getAllPaymentItemsAsync.apply(this, arguments);
1095
1132
  }
1096
1133
  return getAllPaymentItemsAsync;
@@ -1102,10 +1139,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1102
1139
  }, {
1103
1140
  key: "addPaymentItemAsync",
1104
1141
  value: (function () {
1105
- var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderUuid, paymentItem) {
1142
+ var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(orderUuid, paymentItem) {
1106
1143
  var _paymentItem$metadata, _newPaymentItem$metad, _newPaymentItem$metad2, _newPaymentItem$metad3, order, expectAmount, paidDepositAmount, expectedDepositAmount, warningMessage, paymentUuid, currentTime, newPaymentItem;
1107
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1108
- while (1) switch (_context13.prev = _context13.next) {
1144
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1145
+ while (1) switch (_context14.prev = _context14.next) {
1109
1146
  case 0:
1110
1147
  this.logInfo('Starting addPaymentItemAsync', {
1111
1148
  orderUuid: orderUuid,
@@ -1113,20 +1150,20 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1113
1150
  paymentCode: paymentItem.code,
1114
1151
  orderPaymentType: paymentItem.order_payment_type
1115
1152
  });
1116
- _context13.prev = 1;
1153
+ _context14.prev = 1;
1117
1154
  this.logInfo('准备获取订单', {
1118
1155
  orderUuid: orderUuid
1119
1156
  });
1120
- _context13.next = 5;
1157
+ _context14.next = 5;
1121
1158
  return this.getPaymentOrderByUuidAsync(orderUuid);
1122
1159
  case 5:
1123
- order = _context13.sent;
1160
+ order = _context14.sent;
1124
1161
  this.logInfo('获取订单信息成功', {
1125
1162
  orderUuid: orderUuid,
1126
1163
  order: order
1127
1164
  });
1128
1165
  if (order) {
1129
- _context13.next = 9;
1166
+ _context14.next = 9;
1130
1167
  break;
1131
1168
  }
1132
1169
  throw new Error("Order not found: ".concat(orderUuid));
@@ -1141,7 +1178,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1141
1178
  }, new Decimal(0));
1142
1179
  expectedDepositAmount = new Decimal(order.deposit_amount || '0').sub(paidDepositAmount); // 有一种特殊情况,订单金额为 0,但是定金金额>0,且此时是定金状态的,允许添加支付项
1143
1180
  if (!(expectAmount.lte(0) && expectedDepositAmount.eq(0))) {
1144
- _context13.next = 17;
1181
+ _context14.next = 17;
1145
1182
  break;
1146
1183
  }
1147
1184
  warningMessage = "\u8BA2\u5355 ".concat(orderUuid, " \u5F85\u4ED8\u91D1\u989D\u5DF2\u4E3A0\uFF0C\u4E0D\u5141\u8BB8\u6DFB\u52A0\u65B0\u7684\u652F\u4ED8\u9879");
@@ -1194,13 +1231,13 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1194
1231
  orderUuid: orderUuid,
1195
1232
  order: order
1196
1233
  });
1197
- _context13.next = 25;
1234
+ _context14.next = 25;
1198
1235
  return this.dbManager.update('order', order, true);
1199
1236
  case 25:
1200
1237
  this.logInfo('更新订单支付项完成', {
1201
1238
  orderUuid: orderUuid
1202
1239
  });
1203
- this.core.effects.emit("".concat(this.name, ":onPaymentAdded"), {
1240
+ this.core.effects.emit(PaymentHooks.OnPaymentAdded, {
1204
1241
  orderUuid: orderUuid,
1205
1242
  payment: newPaymentItem
1206
1243
  });
@@ -1217,24 +1254,24 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1217
1254
  actualPaidAmount: (_newPaymentItem$metad2 = newPaymentItem.metadata) === null || _newPaymentItem$metad2 === void 0 ? void 0 : _newPaymentItem$metad2.actual_paid_amount,
1218
1255
  changeGivenAmount: (_newPaymentItem$metad3 = newPaymentItem.metadata) === null || _newPaymentItem$metad3 === void 0 ? void 0 : _newPaymentItem$metad3.change_given_amount
1219
1256
  });
1220
- _context13.next = 35;
1257
+ _context14.next = 35;
1221
1258
  break;
1222
1259
  case 30:
1223
- _context13.prev = 30;
1224
- _context13.t0 = _context13["catch"](1);
1225
- console.error('[PaymentModule] 添加支付项失败', _context13.t0);
1226
- this.logError('addPaymentItemAsync failed', _context13.t0, {
1260
+ _context14.prev = 30;
1261
+ _context14.t0 = _context14["catch"](1);
1262
+ console.error('[PaymentModule] 添加支付项失败', _context14.t0);
1263
+ this.logError('addPaymentItemAsync failed', _context14.t0, {
1227
1264
  orderUuid: orderUuid,
1228
1265
  paymentItem: paymentItem
1229
1266
  });
1230
- throw _context13.t0;
1267
+ throw _context14.t0;
1231
1268
  case 35:
1232
1269
  case "end":
1233
- return _context13.stop();
1270
+ return _context14.stop();
1234
1271
  }
1235
- }, _callee13, this, [[1, 30]]);
1272
+ }, _callee14, this, [[1, 30]]);
1236
1273
  }));
1237
- function addPaymentItemAsync(_x14, _x15) {
1274
+ function addPaymentItemAsync(_x15, _x16) {
1238
1275
  return _addPaymentItemAsync.apply(this, arguments);
1239
1276
  }
1240
1277
  return addPaymentItemAsync;
@@ -1246,22 +1283,22 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1246
1283
  }, {
1247
1284
  key: "deletePaymentAsync",
1248
1285
  value: (function () {
1249
- var _deletePaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(orderUuid, paymentUuid) {
1286
+ var _deletePaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(orderUuid, paymentUuid) {
1250
1287
  var order, paymentItem;
1251
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1252
- while (1) switch (_context14.prev = _context14.next) {
1288
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1289
+ while (1) switch (_context15.prev = _context15.next) {
1253
1290
  case 0:
1254
1291
  this.logInfo('Starting deletePaymentAsync (mark as voided)', {
1255
1292
  orderUuid: orderUuid,
1256
1293
  paymentUuid: paymentUuid
1257
1294
  });
1258
- _context14.prev = 1;
1259
- _context14.next = 4;
1295
+ _context15.prev = 1;
1296
+ _context15.next = 4;
1260
1297
  return this.dbManager.get('order', orderUuid);
1261
1298
  case 4:
1262
- order = _context14.sent;
1299
+ order = _context15.sent;
1263
1300
  if (order) {
1264
- _context14.next = 7;
1301
+ _context15.next = 7;
1265
1302
  break;
1266
1303
  }
1267
1304
  throw new Error('订单不存在');
@@ -1270,17 +1307,17 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1270
1307
  return payment.uuid === paymentUuid;
1271
1308
  });
1272
1309
  if (paymentItem) {
1273
- _context14.next = 10;
1310
+ _context15.next = 10;
1274
1311
  break;
1275
1312
  }
1276
1313
  throw new Error("\u652F\u4ED8\u9879\u4E0D\u5B58\u5728: ".concat(paymentUuid));
1277
1314
  case 10:
1278
1315
  if (!(paymentItem.status === 'voided')) {
1279
- _context14.next = 13;
1316
+ _context15.next = 13;
1280
1317
  break;
1281
1318
  }
1282
1319
  console.warn("[PaymentModule] \u652F\u4ED8\u9879 ".concat(paymentUuid, " \u5DF2\u7ECF\u88AB\u5220\u9664\uFF0C\u8DF3\u8FC7\u64CD\u4F5C"));
1283
- return _context14.abrupt("return");
1320
+ return _context15.abrupt("return");
1284
1321
  case 13:
1285
1322
  // 标记删除而不是物理删除
1286
1323
  paymentItem.status = 'voided';
@@ -1297,16 +1334,16 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1297
1334
  this.recalculateOrderAmount(order);
1298
1335
 
1299
1336
  // 更新到 IndexDB
1300
- _context14.next = 20;
1337
+ _context15.next = 20;
1301
1338
  return this.dbManager.update('order', order);
1302
1339
  case 20:
1303
- _context14.next = 22;
1340
+ _context15.next = 22;
1304
1341
  return this.core.effects.emit("".concat(this.name, ":onPaymentDeleted"), {
1305
1342
  order: order,
1306
1343
  paymentItem: paymentItem
1307
1344
  });
1308
1345
  case 22:
1309
- _context14.next = 24;
1346
+ _context15.next = 24;
1310
1347
  return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
1311
1348
  action: 'payment_delete',
1312
1349
  order: order,
@@ -1319,24 +1356,24 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1319
1356
  originalAmount: paymentItem.origin_amount,
1320
1357
  newExpectAmount: order.expect_amount
1321
1358
  });
1322
- _context14.next = 32;
1359
+ _context15.next = 32;
1323
1360
  break;
1324
1361
  case 27:
1325
- _context14.prev = 27;
1326
- _context14.t0 = _context14["catch"](1);
1327
- console.error('[PaymentModule] 删除支付项失败', _context14.t0);
1328
- this.logError('deletePaymentAsync failed', _context14.t0, {
1362
+ _context15.prev = 27;
1363
+ _context15.t0 = _context15["catch"](1);
1364
+ console.error('[PaymentModule] 删除支付项失败', _context15.t0);
1365
+ this.logError('deletePaymentAsync failed', _context15.t0, {
1329
1366
  orderUuid: orderUuid,
1330
1367
  paymentUuid: paymentUuid
1331
1368
  });
1332
- throw _context14.t0;
1369
+ throw _context15.t0;
1333
1370
  case 32:
1334
1371
  case "end":
1335
- return _context14.stop();
1372
+ return _context15.stop();
1336
1373
  }
1337
- }, _callee14, this, [[1, 27]]);
1374
+ }, _callee15, this, [[1, 27]]);
1338
1375
  }));
1339
- function deletePaymentAsync(_x16, _x17) {
1376
+ function deletePaymentAsync(_x17, _x18) {
1340
1377
  return _deletePaymentAsync.apply(this, arguments);
1341
1378
  }
1342
1379
  return deletePaymentAsync;
@@ -1351,10 +1388,10 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1351
1388
  }, {
1352
1389
  key: "updateVoucherPaymentItemsAsync",
1353
1390
  value: (function () {
1354
- var _updateVoucherPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(orderUuid, voucherPaymentItems) {
1391
+ var _updateVoucherPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(orderUuid, voucherPaymentItems) {
1355
1392
  var order, existingVoucherItems, _iterator5, _step5, voucherItem, _iterator6, _step6, _voucherItem, updatedOrder;
1356
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
1357
- while (1) switch (_context15.prev = _context15.next) {
1393
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1394
+ while (1) switch (_context16.prev = _context16.next) {
1358
1395
  case 0:
1359
1396
  this.logInfo('Starting updateVoucherPaymentItemsAsync', {
1360
1397
  orderUuid: orderUuid,
@@ -1368,13 +1405,13 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1368
1405
  };
1369
1406
  })
1370
1407
  });
1371
- _context15.prev = 1;
1372
- _context15.next = 4;
1408
+ _context16.prev = 1;
1409
+ _context16.next = 4;
1373
1410
  return this.getPaymentOrderByUuidAsync(orderUuid);
1374
1411
  case 4:
1375
- order = _context15.sent;
1412
+ order = _context16.sent;
1376
1413
  if (order) {
1377
- _context15.next = 7;
1414
+ _context16.next = 7;
1378
1415
  break;
1379
1416
  }
1380
1417
  throw new Error("\u8BA2\u5355\u4E0D\u5B58\u5728: ".concat(orderUuid));
@@ -1400,31 +1437,31 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1400
1437
 
1401
1438
  // 2. 删除所有现有的代金券支付项
1402
1439
  _iterator5 = _createForOfIteratorHelper(existingVoucherItems);
1403
- _context15.prev = 10;
1440
+ _context16.prev = 10;
1404
1441
  _iterator5.s();
1405
1442
  case 12:
1406
1443
  if ((_step5 = _iterator5.n()).done) {
1407
- _context15.next = 19;
1444
+ _context16.next = 19;
1408
1445
  break;
1409
1446
  }
1410
1447
  voucherItem = _step5.value;
1411
1448
  console.log("[PaymentModule] \u5220\u9664\u73B0\u6709\u4EE3\u91D1\u5238\u652F\u4ED8\u9879: ".concat(voucherItem.uuid));
1412
- _context15.next = 17;
1449
+ _context16.next = 17;
1413
1450
  return this.deletePaymentAsync(orderUuid, voucherItem.uuid);
1414
1451
  case 17:
1415
- _context15.next = 12;
1452
+ _context16.next = 12;
1416
1453
  break;
1417
1454
  case 19:
1418
- _context15.next = 24;
1455
+ _context16.next = 24;
1419
1456
  break;
1420
1457
  case 21:
1421
- _context15.prev = 21;
1422
- _context15.t0 = _context15["catch"](10);
1423
- _iterator5.e(_context15.t0);
1458
+ _context16.prev = 21;
1459
+ _context16.t0 = _context16["catch"](10);
1460
+ _iterator5.e(_context16.t0);
1424
1461
  case 24:
1425
- _context15.prev = 24;
1462
+ _context16.prev = 24;
1426
1463
  _iterator5.f();
1427
- return _context15.finish(24);
1464
+ return _context16.finish(24);
1428
1465
  case 27:
1429
1466
  // 3. 添加新的代金券支付项
1430
1467
  console.log('[PaymentModule] 添加新的代金券支付项:', {
@@ -1432,16 +1469,16 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1432
1469
  newItemCount: voucherPaymentItems.length
1433
1470
  });
1434
1471
  _iterator6 = _createForOfIteratorHelper(voucherPaymentItems);
1435
- _context15.prev = 29;
1472
+ _context16.prev = 29;
1436
1473
  _iterator6.s();
1437
1474
  case 31:
1438
1475
  if ((_step6 = _iterator6.n()).done) {
1439
- _context15.next = 40;
1476
+ _context16.next = 40;
1440
1477
  break;
1441
1478
  }
1442
1479
  _voucherItem = _step6.value;
1443
1480
  if (_voucherItem.voucher_id) {
1444
- _context15.next = 35;
1481
+ _context16.next = 35;
1445
1482
  break;
1446
1483
  }
1447
1484
  throw new Error("\u4EE3\u91D1\u5238\u652F\u4ED8\u9879\u7F3A\u5C11 voucher_id: ".concat(JSON.stringify(_voucherItem)));
@@ -1452,28 +1489,28 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1452
1489
  voucher_id: _voucherItem.voucher_id,
1453
1490
  order_payment_type: _voucherItem.order_payment_type
1454
1491
  });
1455
- _context15.next = 38;
1492
+ _context16.next = 38;
1456
1493
  return this.addPaymentItemAsync(orderUuid, _voucherItem);
1457
1494
  case 38:
1458
- _context15.next = 31;
1495
+ _context16.next = 31;
1459
1496
  break;
1460
1497
  case 40:
1461
- _context15.next = 45;
1498
+ _context16.next = 45;
1462
1499
  break;
1463
1500
  case 42:
1464
- _context15.prev = 42;
1465
- _context15.t1 = _context15["catch"](29);
1466
- _iterator6.e(_context15.t1);
1501
+ _context16.prev = 42;
1502
+ _context16.t1 = _context16["catch"](29);
1503
+ _iterator6.e(_context16.t1);
1467
1504
  case 45:
1468
- _context15.prev = 45;
1505
+ _context16.prev = 45;
1469
1506
  _iterator6.f();
1470
- return _context15.finish(45);
1507
+ return _context16.finish(45);
1471
1508
  case 48:
1472
- _context15.next = 50;
1509
+ _context16.next = 50;
1473
1510
  return this.getPaymentOrderByUuidAsync(orderUuid);
1474
1511
  case 50:
1475
- updatedOrder = _context15.sent;
1476
- _context15.next = 53;
1512
+ updatedOrder = _context16.sent;
1513
+ _context16.next = 53;
1477
1514
  return this.core.effects.emit("".concat(this.name, ":onPaymentAdded"), {
1478
1515
  orderUuid: orderUuid,
1479
1516
  order: updatedOrder,
@@ -1486,24 +1523,24 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1486
1523
  addedVoucherCount: voucherPaymentItems.length,
1487
1524
  finalExpectAmount: updatedOrder === null || updatedOrder === void 0 ? void 0 : updatedOrder.expect_amount
1488
1525
  });
1489
- _context15.next = 61;
1526
+ _context16.next = 61;
1490
1527
  break;
1491
1528
  case 56:
1492
- _context15.prev = 56;
1493
- _context15.t2 = _context15["catch"](1);
1494
- console.error('[PaymentModule] 批量更新代金券支付项失败:', _context15.t2);
1495
- this.logError('updateVoucherPaymentItemsAsync failed', _context15.t2, {
1529
+ _context16.prev = 56;
1530
+ _context16.t2 = _context16["catch"](1);
1531
+ console.error('[PaymentModule] 批量更新代金券支付项失败:', _context16.t2);
1532
+ this.logError('updateVoucherPaymentItemsAsync failed', _context16.t2, {
1496
1533
  orderUuid: orderUuid,
1497
1534
  voucherPaymentItems: voucherPaymentItems
1498
1535
  });
1499
- throw _context15.t2;
1536
+ throw _context16.t2;
1500
1537
  case 61:
1501
1538
  case "end":
1502
- return _context15.stop();
1539
+ return _context16.stop();
1503
1540
  }
1504
- }, _callee15, this, [[1, 56], [10, 21, 24, 27], [29, 42, 45, 48]]);
1541
+ }, _callee16, this, [[1, 56], [10, 21, 24, 27], [29, 42, 45, 48]]);
1505
1542
  }));
1506
- function updateVoucherPaymentItemsAsync(_x18, _x19) {
1543
+ function updateVoucherPaymentItemsAsync(_x19, _x20) {
1507
1544
  return _updateVoucherPaymentItemsAsync.apply(this, arguments);
1508
1545
  }
1509
1546
  return updateVoucherPaymentItemsAsync;
@@ -1515,18 +1552,18 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1515
1552
  }, {
1516
1553
  key: "updatePaymentAsync",
1517
1554
  value: (function () {
1518
- var _updatePaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(orderUuid, paymentUuid, params) {
1555
+ var _updatePaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(orderUuid, paymentUuid, params) {
1519
1556
  var order, paymentItem, formattedParams;
1520
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
1521
- while (1) switch (_context16.prev = _context16.next) {
1557
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1558
+ while (1) switch (_context17.prev = _context17.next) {
1522
1559
  case 0:
1523
- _context16.prev = 0;
1524
- _context16.next = 3;
1560
+ _context17.prev = 0;
1561
+ _context17.next = 3;
1525
1562
  return this.dbManager.get('order', orderUuid);
1526
1563
  case 3:
1527
- order = _context16.sent;
1564
+ order = _context17.sent;
1528
1565
  if (order) {
1529
- _context16.next = 6;
1566
+ _context17.next = 6;
1530
1567
  break;
1531
1568
  }
1532
1569
  throw new Error('订单不存在');
@@ -1535,7 +1572,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1535
1572
  return payment.uuid === paymentUuid;
1536
1573
  });
1537
1574
  if (!paymentItem) {
1538
- _context16.next = 18;
1575
+ _context17.next = 18;
1539
1576
  break;
1540
1577
  }
1541
1578
  // 如果更新参数中包含 amount,先格式化
@@ -1549,36 +1586,36 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1549
1586
  this.recalculateOrderAmount(order);
1550
1587
 
1551
1588
  // 更新到 IndexDB
1552
- _context16.next = 14;
1589
+ _context17.next = 14;
1553
1590
  return this.dbManager.update('order', order);
1554
1591
  case 14:
1555
- _context16.next = 16;
1592
+ _context17.next = 16;
1556
1593
  return this.core.effects.emit("".concat(this.name, ":onPaymentUpdated"), {
1557
1594
  order: order,
1558
1595
  paymentItem: paymentItem
1559
1596
  });
1560
1597
  case 16:
1561
- _context16.next = 18;
1598
+ _context17.next = 18;
1562
1599
  return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
1563
1600
  action: 'payment_update',
1564
1601
  order: order,
1565
1602
  paymentItem: paymentItem
1566
1603
  });
1567
1604
  case 18:
1568
- _context16.next = 24;
1605
+ _context17.next = 24;
1569
1606
  break;
1570
1607
  case 20:
1571
- _context16.prev = 20;
1572
- _context16.t0 = _context16["catch"](0);
1573
- console.error('[PaymentModule] 更新支付项失败', _context16.t0);
1574
- throw _context16.t0;
1608
+ _context17.prev = 20;
1609
+ _context17.t0 = _context17["catch"](0);
1610
+ console.error('[PaymentModule] 更新支付项失败', _context17.t0);
1611
+ throw _context17.t0;
1575
1612
  case 24:
1576
1613
  case "end":
1577
- return _context16.stop();
1614
+ return _context17.stop();
1578
1615
  }
1579
- }, _callee16, this, [[0, 20]]);
1616
+ }, _callee17, this, [[0, 20]]);
1580
1617
  }));
1581
- function updatePaymentAsync(_x20, _x21, _x22) {
1618
+ function updatePaymentAsync(_x21, _x22, _x23) {
1582
1619
  return _updatePaymentAsync.apply(this, arguments);
1583
1620
  }
1584
1621
  return updatePaymentAsync;
@@ -1590,61 +1627,61 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1590
1627
  }, {
1591
1628
  key: "submitPayAsync",
1592
1629
  value: (function () {
1593
- var _submitPayAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(orderUuid) {
1630
+ var _submitPayAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(orderUuid) {
1594
1631
  var orderToSubmit, order, allOrders, _iterator7, _step7, _order, result;
1595
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
1596
- while (1) switch (_context17.prev = _context17.next) {
1632
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1633
+ while (1) switch (_context18.prev = _context18.next) {
1597
1634
  case 0:
1598
1635
  this.logInfo('Starting submitPayAsync', {
1599
1636
  orderUuid: orderUuid
1600
1637
  });
1601
- _context17.prev = 1;
1638
+ _context18.prev = 1;
1602
1639
  if (!orderUuid) {
1603
- _context17.next = 9;
1640
+ _context18.next = 9;
1604
1641
  break;
1605
1642
  }
1606
- _context17.next = 5;
1643
+ _context18.next = 5;
1607
1644
  return this.dbManager.get('order', orderUuid);
1608
1645
  case 5:
1609
- order = _context17.sent;
1646
+ order = _context18.sent;
1610
1647
  orderToSubmit = order ? [order] : [];
1611
- _context17.next = 13;
1648
+ _context18.next = 13;
1612
1649
  break;
1613
1650
  case 9:
1614
- _context17.next = 11;
1651
+ _context18.next = 11;
1615
1652
  return this.dbManager.getAll('order');
1616
1653
  case 11:
1617
- allOrders = _context17.sent;
1654
+ allOrders = _context18.sent;
1618
1655
  // 包括正在处理中的订单和部分支付的订单(可能添加了新的支付项)
1619
1656
  orderToSubmit = allOrders.filter(function (order) {
1620
1657
  return order.payment_status === PaymentStatus.Processing || order.payment_status === PaymentStatus.PartiallyPaid;
1621
1658
  });
1622
1659
  case 13:
1623
1660
  _iterator7 = _createForOfIteratorHelper(orderToSubmit);
1624
- _context17.prev = 14;
1661
+ _context18.prev = 14;
1625
1662
  _iterator7.s();
1626
1663
  case 16:
1627
1664
  if ((_step7 = _iterator7.n()).done) {
1628
- _context17.next = 22;
1665
+ _context18.next = 22;
1629
1666
  break;
1630
1667
  }
1631
1668
  _order = _step7.value;
1632
- _context17.next = 20;
1669
+ _context18.next = 20;
1633
1670
  return this.submitSingleOrderPayment(_order);
1634
1671
  case 20:
1635
- _context17.next = 16;
1672
+ _context18.next = 16;
1636
1673
  break;
1637
1674
  case 22:
1638
- _context17.next = 27;
1675
+ _context18.next = 27;
1639
1676
  break;
1640
1677
  case 24:
1641
- _context17.prev = 24;
1642
- _context17.t0 = _context17["catch"](14);
1643
- _iterator7.e(_context17.t0);
1678
+ _context18.prev = 24;
1679
+ _context18.t0 = _context18["catch"](14);
1680
+ _iterator7.e(_context18.t0);
1644
1681
  case 27:
1645
- _context17.prev = 27;
1682
+ _context18.prev = 27;
1646
1683
  _iterator7.f();
1647
- return _context17.finish(27);
1684
+ return _context18.finish(27);
1648
1685
  case 30:
1649
1686
  result = {
1650
1687
  status: 'success'
@@ -1653,24 +1690,24 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1653
1690
  result: result.status,
1654
1691
  processedOrdersCount: orderToSubmit.length
1655
1692
  });
1656
- return _context17.abrupt("return", result);
1693
+ return _context18.abrupt("return", result);
1657
1694
  case 35:
1658
- _context17.prev = 35;
1659
- _context17.t1 = _context17["catch"](1);
1660
- console.error('[PaymentModule] 提交支付失败', _context17.t1);
1661
- this.logError('submitPayAsync failed', _context17.t1, {
1695
+ _context18.prev = 35;
1696
+ _context18.t1 = _context18["catch"](1);
1697
+ console.error('[PaymentModule] 提交支付失败', _context18.t1);
1698
+ this.logError('submitPayAsync failed', _context18.t1, {
1662
1699
  orderUuid: orderUuid
1663
1700
  });
1664
- return _context17.abrupt("return", {
1701
+ return _context18.abrupt("return", {
1665
1702
  status: 'failed'
1666
1703
  });
1667
1704
  case 40:
1668
1705
  case "end":
1669
- return _context17.stop();
1706
+ return _context18.stop();
1670
1707
  }
1671
- }, _callee17, this, [[1, 35], [14, 24, 27, 30]]);
1708
+ }, _callee18, this, [[1, 35], [14, 24, 27, 30]]);
1672
1709
  }));
1673
- function submitPayAsync(_x23) {
1710
+ function submitPayAsync(_x24) {
1674
1711
  return _submitPayAsync.apply(this, arguments);
1675
1712
  }
1676
1713
  return submitPayAsync;
@@ -1682,12 +1719,12 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1682
1719
  }, {
1683
1720
  key: "submitSingleOrderPayment",
1684
1721
  value: (function () {
1685
- var _submitSingleOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(order) {
1722
+ var _submitSingleOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(order) {
1686
1723
  var paymentData, totalPaidAmount, orderTotalAmount;
1687
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
1688
- while (1) switch (_context18.prev = _context18.next) {
1724
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1725
+ while (1) switch (_context19.prev = _context19.next) {
1689
1726
  case 0:
1690
- _context18.prev = 0;
1727
+ _context19.prev = 0;
1691
1728
  paymentData = {
1692
1729
  payments: order.payment.map(function (payment) {
1693
1730
  return {
@@ -1723,11 +1760,11 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1723
1760
  paymentData.payment_status = order.payment_status === PaymentStatus.Finished ? 'paid' : 'partially_paid';
1724
1761
 
1725
1762
  // 更新订单状态到数据库
1726
- _context18.next = 8;
1763
+ _context19.next = 8;
1727
1764
  return this.dbManager.update('order', order);
1728
1765
  case 8:
1729
1766
  if (!(paymentData.payments.length === 0)) {
1730
- _context18.next = 12;
1767
+ _context19.next = 12;
1731
1768
  break;
1732
1769
  }
1733
1770
  console.log("[PaymentModule] \u8BA2\u5355 ".concat(order.uuid, " \u652F\u4ED8\u5217\u8868\u4E3A\u7A7A\uFF0C\u8DF3\u8FC7\u652F\u4ED8\u5904\u7406"));
@@ -1735,31 +1772,31 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1735
1772
  orderUuid: order.uuid,
1736
1773
  orderId: order.order_id
1737
1774
  });
1738
- return _context18.abrupt("return");
1775
+ return _context19.abrupt("return");
1739
1776
  case 12:
1740
- _context18.next = 14;
1777
+ _context19.next = 14;
1741
1778
  return this.core.effects.emit("".concat(this.name, ":onPaymentSubmitted"), order);
1742
1779
  case 14:
1743
- _context18.next = 16;
1780
+ _context19.next = 16;
1744
1781
  return this.core.effects.emit("".concat(this.name, ":onOrderChanged"), {
1745
1782
  action: 'submit',
1746
1783
  order: order
1747
1784
  });
1748
1785
  case 16:
1749
- _context18.next = 22;
1786
+ _context19.next = 22;
1750
1787
  break;
1751
1788
  case 18:
1752
- _context18.prev = 18;
1753
- _context18.t0 = _context18["catch"](0);
1754
- console.error("[PaymentModule] \u8BA2\u5355 ".concat(order.uuid, " \u652F\u4ED8\u63D0\u4EA4\u5931\u8D25"), _context18.t0);
1755
- throw _context18.t0;
1789
+ _context19.prev = 18;
1790
+ _context19.t0 = _context19["catch"](0);
1791
+ console.error("[PaymentModule] \u8BA2\u5355 ".concat(order.uuid, " \u652F\u4ED8\u63D0\u4EA4\u5931\u8D25"), _context19.t0);
1792
+ throw _context19.t0;
1756
1793
  case 22:
1757
1794
  case "end":
1758
- return _context18.stop();
1795
+ return _context19.stop();
1759
1796
  }
1760
- }, _callee18, this, [[0, 18]]);
1797
+ }, _callee19, this, [[0, 18]]);
1761
1798
  }));
1762
- function submitSingleOrderPayment(_x24) {
1799
+ function submitSingleOrderPayment(_x25) {
1763
1800
  return _submitSingleOrderPayment.apply(this, arguments);
1764
1801
  }
1765
1802
  return submitSingleOrderPayment;
@@ -1771,29 +1808,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1771
1808
  }, {
1772
1809
  key: "getRemainingOrderAmountAsync",
1773
1810
  value: (function () {
1774
- var _getRemainingOrderAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(orderUuid) {
1811
+ var _getRemainingOrderAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(orderUuid) {
1775
1812
  var order;
1776
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1777
- while (1) switch (_context19.prev = _context19.next) {
1813
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1814
+ while (1) switch (_context20.prev = _context20.next) {
1778
1815
  case 0:
1779
- _context19.next = 2;
1816
+ _context20.next = 2;
1780
1817
  return this.getPaymentOrderByUuidAsync(orderUuid);
1781
1818
  case 2:
1782
- order = _context19.sent;
1819
+ order = _context20.sent;
1783
1820
  if (order) {
1784
- _context19.next = 5;
1821
+ _context20.next = 5;
1785
1822
  break;
1786
1823
  }
1787
1824
  throw new Error('订单不存在');
1788
1825
  case 5:
1789
- return _context19.abrupt("return", new Decimal(order.expect_amount).toNumber());
1826
+ return _context20.abrupt("return", new Decimal(order.expect_amount).toNumber());
1790
1827
  case 6:
1791
1828
  case "end":
1792
- return _context19.stop();
1829
+ return _context20.stop();
1793
1830
  }
1794
- }, _callee19, this);
1831
+ }, _callee20, this);
1795
1832
  }));
1796
- function getRemainingOrderAmountAsync(_x25) {
1833
+ function getRemainingOrderAmountAsync(_x26) {
1797
1834
  return _getRemainingOrderAmountAsync.apply(this, arguments);
1798
1835
  }
1799
1836
  return getRemainingOrderAmountAsync;
@@ -1805,65 +1842,65 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1805
1842
  }, {
1806
1843
  key: "getRemainingOrderAmountWithInputAsync",
1807
1844
  value: (function () {
1808
- var _getRemainingOrderAmountWithInputAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(inputAmount, orderUuid) {
1845
+ var _getRemainingOrderAmountWithInputAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(inputAmount, orderUuid) {
1809
1846
  var order, inputDecimal;
1810
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1811
- while (1) switch (_context20.prev = _context20.next) {
1847
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1848
+ while (1) switch (_context21.prev = _context21.next) {
1812
1849
  case 0:
1813
- _context20.next = 2;
1850
+ _context21.next = 2;
1814
1851
  return this.getPaymentOrderByUuidAsync(orderUuid);
1815
1852
  case 2:
1816
- order = _context20.sent;
1853
+ order = _context21.sent;
1817
1854
  if (order) {
1818
- _context20.next = 5;
1855
+ _context21.next = 5;
1819
1856
  break;
1820
1857
  }
1821
1858
  throw new Error('订单不存在');
1822
1859
  case 5:
1823
1860
  if (!(inputAmount === null || inputAmount === undefined)) {
1824
- _context20.next = 7;
1861
+ _context21.next = 7;
1825
1862
  break;
1826
1863
  }
1827
- return _context20.abrupt("return", new Decimal(order.expect_amount).toNumber());
1864
+ return _context21.abrupt("return", new Decimal(order.expect_amount).toNumber());
1828
1865
  case 7:
1829
1866
  if (!(typeof inputAmount === 'string')) {
1830
- _context20.next = 10;
1867
+ _context21.next = 10;
1831
1868
  break;
1832
1869
  }
1833
1870
  if (!(inputAmount.trim() === '')) {
1834
- _context20.next = 10;
1871
+ _context21.next = 10;
1835
1872
  break;
1836
1873
  }
1837
- return _context20.abrupt("return", new Decimal(order.expect_amount).toNumber());
1874
+ return _context21.abrupt("return", new Decimal(order.expect_amount).toNumber());
1838
1875
  case 10:
1839
1876
  if (!(typeof inputAmount === 'number')) {
1840
- _context20.next = 14;
1877
+ _context21.next = 14;
1841
1878
  break;
1842
1879
  }
1843
1880
  if (!(isNaN(inputAmount) || !isFinite(inputAmount))) {
1844
- _context20.next = 14;
1881
+ _context21.next = 14;
1845
1882
  break;
1846
1883
  }
1847
1884
  // 如果输入是 NaN 或无穷大,返回原始的待付金额
1848
1885
  console.warn("[PaymentModule] \u8F93\u5165\u91D1\u989D\u4E0D\u662F\u6709\u6548\u6570\u5B57: ".concat(inputAmount, "\uFF0C\u8FD4\u56DE\u539F\u59CB\u5F85\u4ED8\u91D1\u989D"));
1849
- return _context20.abrupt("return", new Decimal(order.expect_amount).toNumber());
1886
+ return _context21.abrupt("return", new Decimal(order.expect_amount).toNumber());
1850
1887
  case 14:
1851
- _context20.prev = 14;
1888
+ _context21.prev = 14;
1852
1889
  inputDecimal = new Decimal(inputAmount);
1853
- return _context20.abrupt("return", new Decimal(order.expect_amount).minus(inputDecimal).toNumber());
1890
+ return _context21.abrupt("return", new Decimal(order.expect_amount).minus(inputDecimal).toNumber());
1854
1891
  case 19:
1855
- _context20.prev = 19;
1856
- _context20.t0 = _context20["catch"](14);
1892
+ _context21.prev = 19;
1893
+ _context21.t0 = _context21["catch"](14);
1857
1894
  // 如果输入不是有效的数字,返回原始的待付金额
1858
1895
  console.warn("[PaymentModule] \u8F93\u5165\u91D1\u989D\u683C\u5F0F\u65E0\u6548: ".concat(inputAmount, "\uFF0C\u8FD4\u56DE\u539F\u59CB\u5F85\u4ED8\u91D1\u989D"));
1859
- return _context20.abrupt("return", new Decimal(order.expect_amount).toNumber());
1896
+ return _context21.abrupt("return", new Decimal(order.expect_amount).toNumber());
1860
1897
  case 23:
1861
1898
  case "end":
1862
- return _context20.stop();
1899
+ return _context21.stop();
1863
1900
  }
1864
- }, _callee20, this, [[14, 19]]);
1901
+ }, _callee21, this, [[14, 19]]);
1865
1902
  }));
1866
- function getRemainingOrderAmountWithInputAsync(_x26, _x27) {
1903
+ function getRemainingOrderAmountWithInputAsync(_x27, _x28) {
1867
1904
  return _getRemainingOrderAmountWithInputAsync.apply(this, arguments);
1868
1905
  }
1869
1906
  return getRemainingOrderAmountWithInputAsync;
@@ -1929,29 +1966,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1929
1966
  }, {
1930
1967
  key: "getCashPaymentMethod",
1931
1968
  value: (function () {
1932
- var _getCashPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
1969
+ var _getCashPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
1933
1970
  var payMethods;
1934
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1935
- while (1) switch (_context21.prev = _context21.next) {
1971
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1972
+ while (1) switch (_context22.prev = _context22.next) {
1936
1973
  case 0:
1937
- _context21.prev = 0;
1938
- _context21.next = 3;
1974
+ _context22.prev = 0;
1975
+ _context22.next = 3;
1939
1976
  return this.dbManager.getAll('pay_method');
1940
1977
  case 3:
1941
- payMethods = _context21.sent;
1942
- return _context21.abrupt("return", payMethods.find(function (method) {
1978
+ payMethods = _context22.sent;
1979
+ return _context22.abrupt("return", payMethods.find(function (method) {
1943
1980
  return method.code === PaymentMethodType.Cash;
1944
1981
  }) || null);
1945
1982
  case 7:
1946
- _context21.prev = 7;
1947
- _context21.t0 = _context21["catch"](0);
1948
- console.error('[PaymentModule] 获取现金支付方式失败', _context21.t0);
1949
- return _context21.abrupt("return", null);
1983
+ _context22.prev = 7;
1984
+ _context22.t0 = _context22["catch"](0);
1985
+ console.error('[PaymentModule] 获取现金支付方式失败', _context22.t0);
1986
+ return _context22.abrupt("return", null);
1950
1987
  case 11:
1951
1988
  case "end":
1952
- return _context21.stop();
1989
+ return _context22.stop();
1953
1990
  }
1954
- }, _callee21, this, [[0, 7]]);
1991
+ }, _callee22, this, [[0, 7]]);
1955
1992
  }));
1956
1993
  function getCashPaymentMethod() {
1957
1994
  return _getCashPaymentMethod.apply(this, arguments);
@@ -1965,29 +2002,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
1965
2002
  }, {
1966
2003
  key: "getEftposPaymentMethod",
1967
2004
  value: (function () {
1968
- var _getEftposPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
2005
+ var _getEftposPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
1969
2006
  var payMethods;
1970
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1971
- while (1) switch (_context22.prev = _context22.next) {
2007
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2008
+ while (1) switch (_context23.prev = _context23.next) {
1972
2009
  case 0:
1973
- _context22.prev = 0;
1974
- _context22.next = 3;
2010
+ _context23.prev = 0;
2011
+ _context23.next = 3;
1975
2012
  return this.dbManager.getAll('pay_method');
1976
2013
  case 3:
1977
- payMethods = _context22.sent;
1978
- return _context22.abrupt("return", payMethods.find(function (method) {
2014
+ payMethods = _context23.sent;
2015
+ return _context23.abrupt("return", payMethods.find(function (method) {
1979
2016
  return method.code === PaymentMethodType.Eftpos;
1980
2017
  }) || null);
1981
2018
  case 7:
1982
- _context22.prev = 7;
1983
- _context22.t0 = _context22["catch"](0);
1984
- console.error('[PaymentModule] 获取Eftpos支付方式失败', _context22.t0);
1985
- return _context22.abrupt("return", null);
2019
+ _context23.prev = 7;
2020
+ _context23.t0 = _context23["catch"](0);
2021
+ console.error('[PaymentModule] 获取Eftpos支付方式失败', _context23.t0);
2022
+ return _context23.abrupt("return", null);
1986
2023
  case 11:
1987
2024
  case "end":
1988
- return _context22.stop();
2025
+ return _context23.stop();
1989
2026
  }
1990
- }, _callee22, this, [[0, 7]]);
2027
+ }, _callee23, this, [[0, 7]]);
1991
2028
  }));
1992
2029
  function getEftposPaymentMethod() {
1993
2030
  return _getEftposPaymentMethod.apply(this, arguments);
@@ -2001,29 +2038,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
2001
2038
  }, {
2002
2039
  key: "getWalletPaymentMethod",
2003
2040
  value: (function () {
2004
- var _getWalletPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
2041
+ var _getWalletPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
2005
2042
  var payMethods;
2006
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
2007
- while (1) switch (_context23.prev = _context23.next) {
2043
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2044
+ while (1) switch (_context24.prev = _context24.next) {
2008
2045
  case 0:
2009
- _context23.prev = 0;
2010
- _context23.next = 3;
2046
+ _context24.prev = 0;
2047
+ _context24.next = 3;
2011
2048
  return this.dbManager.getAll('pay_method');
2012
2049
  case 3:
2013
- payMethods = _context23.sent;
2014
- return _context23.abrupt("return", payMethods.find(function (method) {
2050
+ payMethods = _context24.sent;
2051
+ return _context24.abrupt("return", payMethods.find(function (method) {
2015
2052
  return method.code === PaymentMethodType.Wallet;
2016
2053
  }) || null);
2017
2054
  case 7:
2018
- _context23.prev = 7;
2019
- _context23.t0 = _context23["catch"](0);
2020
- console.error('[PaymentModule] 获取钱包支付方式失败', _context23.t0);
2021
- return _context23.abrupt("return", null);
2055
+ _context24.prev = 7;
2056
+ _context24.t0 = _context24["catch"](0);
2057
+ console.error('[PaymentModule] 获取钱包支付方式失败', _context24.t0);
2058
+ return _context24.abrupt("return", null);
2022
2059
  case 11:
2023
2060
  case "end":
2024
- return _context23.stop();
2061
+ return _context24.stop();
2025
2062
  }
2026
- }, _callee23, this, [[0, 7]]);
2063
+ }, _callee24, this, [[0, 7]]);
2027
2064
  }));
2028
2065
  function getWalletPaymentMethod() {
2029
2066
  return _getWalletPaymentMethod.apply(this, arguments);
@@ -2037,38 +2074,38 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
2037
2074
  }, {
2038
2075
  key: "ensurePaymentTables",
2039
2076
  value: (function () {
2040
- var _ensurePaymentTables = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
2041
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
2042
- while (1) switch (_context24.prev = _context24.next) {
2077
+ var _ensurePaymentTables = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
2078
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2079
+ while (1) switch (_context25.prev = _context25.next) {
2043
2080
  case 0:
2044
- _context24.prev = 0;
2045
- _context24.next = 3;
2081
+ _context25.prev = 0;
2082
+ _context25.next = 3;
2046
2083
  return this.dbManager.getAll('pay_method');
2047
2084
  case 3:
2048
- _context24.next = 9;
2085
+ _context25.next = 9;
2049
2086
  break;
2050
2087
  case 5:
2051
- _context24.prev = 5;
2052
- _context24.t0 = _context24["catch"](0);
2088
+ _context25.prev = 5;
2089
+ _context25.t0 = _context25["catch"](0);
2053
2090
  console.warn('[PaymentModule] pay_method 表不存在,请在数据库配置中添加以下配置:');
2054
2091
  console.warn('{ name: "pay_method", keyPath: "id" }');
2055
2092
  case 9:
2056
- _context24.prev = 9;
2057
- _context24.next = 12;
2093
+ _context25.prev = 9;
2094
+ _context25.next = 12;
2058
2095
  return this.dbManager.getAll('order');
2059
2096
  case 12:
2060
- _context24.next = 18;
2097
+ _context25.next = 18;
2061
2098
  break;
2062
2099
  case 14:
2063
- _context24.prev = 14;
2064
- _context24.t1 = _context24["catch"](9);
2100
+ _context25.prev = 14;
2101
+ _context25.t1 = _context25["catch"](9);
2065
2102
  console.warn('[PaymentModule] order 表不存在,请在数据库配置中添加以下配置:');
2066
2103
  console.warn('{ name: "order", keyPath: "uuid" }');
2067
2104
  case 18:
2068
2105
  case "end":
2069
- return _context24.stop();
2106
+ return _context25.stop();
2070
2107
  }
2071
- }, _callee24, this, [[0, 5], [9, 14]]);
2108
+ }, _callee25, this, [[0, 5], [9, 14]]);
2072
2109
  }));
2073
2110
  function ensurePaymentTables() {
2074
2111
  return _ensurePaymentTables.apply(this, arguments);
@@ -2082,29 +2119,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
2082
2119
  }, {
2083
2120
  key: "getPartiallyPaidOrdersAsync",
2084
2121
  value: (function () {
2085
- var _getPartiallyPaidOrdersAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
2122
+ var _getPartiallyPaidOrdersAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
2086
2123
  var allOrders;
2087
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
2088
- while (1) switch (_context25.prev = _context25.next) {
2124
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2125
+ while (1) switch (_context26.prev = _context26.next) {
2089
2126
  case 0:
2090
- _context25.prev = 0;
2091
- _context25.next = 3;
2127
+ _context26.prev = 0;
2128
+ _context26.next = 3;
2092
2129
  return this.dbManager.getAll('order');
2093
2130
  case 3:
2094
- allOrders = _context25.sent;
2095
- return _context25.abrupt("return", allOrders.filter(function (order) {
2131
+ allOrders = _context26.sent;
2132
+ return _context26.abrupt("return", allOrders.filter(function (order) {
2096
2133
  return order.payment_status === PaymentStatus.PartiallyPaid;
2097
2134
  }));
2098
2135
  case 7:
2099
- _context25.prev = 7;
2100
- _context25.t0 = _context25["catch"](0);
2101
- console.error('[PaymentModule] 获取部分支付订单失败', _context25.t0);
2102
- return _context25.abrupt("return", []);
2136
+ _context26.prev = 7;
2137
+ _context26.t0 = _context26["catch"](0);
2138
+ console.error('[PaymentModule] 获取部分支付订单失败', _context26.t0);
2139
+ return _context26.abrupt("return", []);
2103
2140
  case 11:
2104
2141
  case "end":
2105
- return _context25.stop();
2142
+ return _context26.stop();
2106
2143
  }
2107
- }, _callee25, this, [[0, 7]]);
2144
+ }, _callee26, this, [[0, 7]]);
2108
2145
  }));
2109
2146
  function getPartiallyPaidOrdersAsync() {
2110
2147
  return _getPartiallyPaidOrdersAsync.apply(this, arguments);
@@ -2125,17 +2162,17 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
2125
2162
  }, {
2126
2163
  key: "roundAmountAsync",
2127
2164
  value: function () {
2128
- var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(originalAmount, interval, rule) {
2165
+ var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(originalAmount, interval, rule) {
2129
2166
  var amount, roundingInterval, supportedIntervals, intervalValue, baseValue, roundedValue, finalAmount, originalAmountStr, roundedAmountStr, roundingDifference, roundingDifferenceStr;
2130
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
2131
- while (1) switch (_context26.prev = _context26.next) {
2167
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
2168
+ while (1) switch (_context27.prev = _context27.next) {
2132
2169
  case 0:
2133
- _context26.prev = 0;
2170
+ _context27.prev = 0;
2134
2171
  // 参数验证
2135
2172
  amount = new Decimal(originalAmount);
2136
2173
  roundingInterval = new Decimal(interval);
2137
2174
  if (!roundingInterval.lte(0)) {
2138
- _context26.next = 5;
2175
+ _context27.next = 5;
2139
2176
  break;
2140
2177
  }
2141
2178
  throw new Error('舍入间隔必须大于 0');
@@ -2150,25 +2187,25 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
2150
2187
  // 计算基础值:x / interval
2151
2188
  baseValue = amount.div(roundingInterval);
2152
2189
  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));
2153
- _context26.t0 = rule;
2154
- _context26.next = _context26.t0 === RoundingRule.Standard ? 13 : _context26.t0 === 'standard' ? 13 : _context26.t0 === RoundingRule.StandardDown ? 15 : _context26.t0 === 'standard_down' ? 15 : _context26.t0 === RoundingRule.AlwaysUp ? 17 : _context26.t0 === 'always_up' ? 17 : _context26.t0 === RoundingRule.AlwaysDown ? 19 : _context26.t0 === 'always_down' ? 19 : 21;
2190
+ _context27.t0 = rule;
2191
+ _context27.next = _context27.t0 === RoundingRule.Standard ? 13 : _context27.t0 === 'standard' ? 13 : _context27.t0 === RoundingRule.StandardDown ? 15 : _context27.t0 === 'standard_down' ? 15 : _context27.t0 === RoundingRule.AlwaysUp ? 17 : _context27.t0 === 'always_up' ? 17 : _context27.t0 === RoundingRule.AlwaysDown ? 19 : _context27.t0 === 'always_down' ? 19 : 21;
2155
2192
  break;
2156
2193
  case 13:
2157
2194
  // 标准舍入(中点向上)
2158
2195
  roundedValue = this.standardRound(baseValue, true);
2159
- return _context26.abrupt("break", 22);
2196
+ return _context27.abrupt("break", 22);
2160
2197
  case 15:
2161
2198
  // 标准舍入(中点向下)
2162
2199
  roundedValue = this.standardRound(baseValue, false);
2163
- return _context26.abrupt("break", 22);
2200
+ return _context27.abrupt("break", 22);
2164
2201
  case 17:
2165
2202
  // 总是向上舍入
2166
2203
  roundedValue = baseValue.ceil();
2167
- return _context26.abrupt("break", 22);
2204
+ return _context27.abrupt("break", 22);
2168
2205
  case 19:
2169
2206
  // 总是向下舍入
2170
2207
  roundedValue = baseValue.floor();
2171
- return _context26.abrupt("break", 22);
2208
+ return _context27.abrupt("break", 22);
2172
2209
  case 21:
2173
2210
  throw new Error("\u4E0D\u652F\u6301\u7684\u820D\u5165\u89C4\u5219: ".concat(rule));
2174
2211
  case 22:
@@ -2176,11 +2213,11 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
2176
2213
  finalAmount = roundedValue.mul(roundingInterval);
2177
2214
  originalAmountStr = amount.toFixed(2); // 如果最终金额是 0 元,则不采用舍入金额,返回原始金额
2178
2215
  if (!finalAmount.eq(0)) {
2179
- _context26.next = 27;
2216
+ _context27.next = 27;
2180
2217
  break;
2181
2218
  }
2182
2219
  console.log("[PaymentModule] \u6700\u7EC8\u91D1\u989D\u4E3A0\uFF0C\u8FD4\u56DE\u539F\u59CB\u91D1\u989D: ".concat(originalAmountStr));
2183
- return _context26.abrupt("return", {
2220
+ return _context27.abrupt("return", {
2184
2221
  originalAmount: originalAmountStr,
2185
2222
  roundedAmount: originalAmountStr,
2186
2223
  roundingDifference: '0.00'
@@ -2190,23 +2227,23 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
2190
2227
  roundingDifference = finalAmount.sub(amount);
2191
2228
  roundingDifferenceStr = roundingDifference.toFixed(2);
2192
2229
  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));
2193
- return _context26.abrupt("return", {
2230
+ return _context27.abrupt("return", {
2194
2231
  originalAmount: originalAmountStr,
2195
2232
  roundedAmount: roundedAmountStr,
2196
2233
  roundingDifference: roundingDifferenceStr
2197
2234
  });
2198
2235
  case 34:
2199
- _context26.prev = 34;
2200
- _context26.t1 = _context26["catch"](0);
2201
- console.error('[PaymentModule] 金额舍入失败:', _context26.t1);
2202
- throw new Error("\u91D1\u989D\u820D\u5165\u5931\u8D25: ".concat(_context26.t1 instanceof Error ? _context26.t1.message : String(_context26.t1)));
2236
+ _context27.prev = 34;
2237
+ _context27.t1 = _context27["catch"](0);
2238
+ console.error('[PaymentModule] 金额舍入失败:', _context27.t1);
2239
+ throw new Error("\u91D1\u989D\u820D\u5165\u5931\u8D25: ".concat(_context27.t1 instanceof Error ? _context27.t1.message : String(_context27.t1)));
2203
2240
  case 38:
2204
2241
  case "end":
2205
- return _context26.stop();
2242
+ return _context27.stop();
2206
2243
  }
2207
- }, _callee26, this, [[0, 34]]);
2244
+ }, _callee27, this, [[0, 34]]);
2208
2245
  }));
2209
- function roundAmountAsync(_x28, _x29, _x30) {
2246
+ function roundAmountAsync(_x29, _x30, _x31) {
2210
2247
  return _roundAmountAsync.apply(this, arguments);
2211
2248
  }
2212
2249
  return roundAmountAsync;