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