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