@pisell/pisellos 0.0.195 → 0.0.196
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/modules/Payment/index.d.ts +38 -0
- package/dist/modules/Payment/index.js +725 -504
- package/dist/modules/Payment/types.d.ts +2 -0
- package/lib/modules/Payment/index.d.ts +38 -0
- package/lib/modules/Payment/index.js +127 -4
- package/lib/modules/Payment/types.d.ts +2 -0
- package/package.json +1 -1
|
@@ -241,17 +241,44 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
241
241
|
var _this2 = this;
|
|
242
242
|
var network = this.app.plugins.get('network');
|
|
243
243
|
this.logInfo('Registering network status listener');
|
|
244
|
-
network === null || network === void 0 || network.addListener('networkStatusChange', function (
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
244
|
+
network === null || network === void 0 || network.addListener('networkStatusChange', /*#__PURE__*/function () {
|
|
245
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(status) {
|
|
246
|
+
var requeuedCount;
|
|
247
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
248
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
249
|
+
case 0:
|
|
250
|
+
console.log('网络状态:', status.connected);
|
|
251
|
+
_this2.logInfo('Network status changed', {
|
|
252
|
+
connected: status.connected,
|
|
253
|
+
previousStatus: status.previousStatus
|
|
254
|
+
});
|
|
255
|
+
if (!status.connected) {
|
|
256
|
+
_context2.next = 10;
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
_this2.logInfo('Network reconnected - triggering payment sync queue');
|
|
260
|
+
// this.runPaymentSyncQueue();
|
|
261
|
+
// 1. 先检查并重新排队未同步订单,然后执行队列
|
|
262
|
+
_context2.next = 6;
|
|
263
|
+
return _this2.recheckAndRequeueUnsyncedOrders();
|
|
264
|
+
case 6:
|
|
265
|
+
requeuedCount = _context2.sent;
|
|
266
|
+
if (!(requeuedCount > 0)) {
|
|
267
|
+
_context2.next = 10;
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
_context2.next = 10;
|
|
271
|
+
return _this2.runPaymentSyncQueue();
|
|
272
|
+
case 10:
|
|
273
|
+
case "end":
|
|
274
|
+
return _context2.stop();
|
|
275
|
+
}
|
|
276
|
+
}, _callee2);
|
|
277
|
+
}));
|
|
278
|
+
return function (_x3) {
|
|
279
|
+
return _ref.apply(this, arguments);
|
|
280
|
+
};
|
|
281
|
+
}());
|
|
255
282
|
}
|
|
256
283
|
|
|
257
284
|
/**
|
|
@@ -260,96 +287,96 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
260
287
|
}, {
|
|
261
288
|
key: "getPayMethodListAsync",
|
|
262
289
|
value: (function () {
|
|
263
|
-
var _getPayMethodListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
290
|
+
var _getPayMethodListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
264
291
|
var cachedMethods, hasCache, response, payMethods, _iterator, _step, method;
|
|
265
|
-
return _regeneratorRuntime().wrap(function
|
|
266
|
-
while (1) switch (
|
|
292
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
293
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
267
294
|
case 0:
|
|
268
295
|
this.logInfo('Starting getPayMethodListAsync');
|
|
269
|
-
|
|
296
|
+
_context3.prev = 1;
|
|
270
297
|
// 先尝试从 IndexDB 获取缓存
|
|
271
298
|
cachedMethods = [];
|
|
272
|
-
|
|
273
|
-
|
|
299
|
+
_context3.prev = 3;
|
|
300
|
+
_context3.next = 6;
|
|
274
301
|
return this.dbManager.getAll('pay_method');
|
|
275
302
|
case 6:
|
|
276
|
-
cachedMethods =
|
|
277
|
-
|
|
303
|
+
cachedMethods = _context3.sent;
|
|
304
|
+
_context3.next = 12;
|
|
278
305
|
break;
|
|
279
306
|
case 9:
|
|
280
|
-
|
|
281
|
-
|
|
307
|
+
_context3.prev = 9;
|
|
308
|
+
_context3.t0 = _context3["catch"](3);
|
|
282
309
|
console.warn('[PaymentModule] pay_method 表不存在,将从服务器获取数据');
|
|
283
310
|
case 12:
|
|
284
311
|
// 如果有缓存,先返回缓存数据
|
|
285
312
|
hasCache = cachedMethods.length > 0;
|
|
286
313
|
if (!hasCache) {
|
|
287
|
-
|
|
314
|
+
_context3.next = 16;
|
|
288
315
|
break;
|
|
289
316
|
}
|
|
290
317
|
// 后台异步获取最新数据
|
|
291
318
|
this.refreshPaymentMethodsInBackground(cachedMethods);
|
|
292
|
-
return
|
|
319
|
+
return _context3.abrupt("return", cachedMethods);
|
|
293
320
|
case 16:
|
|
294
|
-
|
|
321
|
+
_context3.next = 18;
|
|
295
322
|
return this.request.get('/pay/custom-payment/available');
|
|
296
323
|
case 18:
|
|
297
|
-
response =
|
|
324
|
+
response = _context3.sent;
|
|
298
325
|
payMethods = response.data || []; // 尝试缓存到 IndexDB
|
|
299
|
-
|
|
326
|
+
_context3.prev = 20;
|
|
300
327
|
_iterator = _createForOfIteratorHelper(payMethods);
|
|
301
|
-
|
|
328
|
+
_context3.prev = 22;
|
|
302
329
|
_iterator.s();
|
|
303
330
|
case 24:
|
|
304
331
|
if ((_step = _iterator.n()).done) {
|
|
305
|
-
|
|
332
|
+
_context3.next = 30;
|
|
306
333
|
break;
|
|
307
334
|
}
|
|
308
335
|
method = _step.value;
|
|
309
|
-
|
|
336
|
+
_context3.next = 28;
|
|
310
337
|
return this.dbManager.update('pay_method', method);
|
|
311
338
|
case 28:
|
|
312
|
-
|
|
339
|
+
_context3.next = 24;
|
|
313
340
|
break;
|
|
314
341
|
case 30:
|
|
315
|
-
|
|
342
|
+
_context3.next = 35;
|
|
316
343
|
break;
|
|
317
344
|
case 32:
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
_iterator.e(
|
|
345
|
+
_context3.prev = 32;
|
|
346
|
+
_context3.t1 = _context3["catch"](22);
|
|
347
|
+
_iterator.e(_context3.t1);
|
|
321
348
|
case 35:
|
|
322
|
-
|
|
349
|
+
_context3.prev = 35;
|
|
323
350
|
_iterator.f();
|
|
324
|
-
return
|
|
351
|
+
return _context3.finish(35);
|
|
325
352
|
case 38:
|
|
326
|
-
|
|
353
|
+
_context3.next = 43;
|
|
327
354
|
break;
|
|
328
355
|
case 40:
|
|
329
|
-
|
|
330
|
-
|
|
356
|
+
_context3.prev = 40;
|
|
357
|
+
_context3.t2 = _context3["catch"](20);
|
|
331
358
|
console.warn('[PaymentModule] 无法缓存支付方式,pay_method 表不存在');
|
|
332
359
|
case 43:
|
|
333
|
-
|
|
360
|
+
_context3.next = 45;
|
|
334
361
|
return this.core.effects.emit(PaymentHooks.OnPaymentMethodsLoaded, payMethods);
|
|
335
362
|
case 45:
|
|
336
363
|
this.logInfo('getPayMethodListAsync completed successfully', {
|
|
337
364
|
methodCount: payMethods.length,
|
|
338
365
|
hasCache: cachedMethods.length > 0
|
|
339
366
|
});
|
|
340
|
-
return
|
|
367
|
+
return _context3.abrupt("return", payMethods);
|
|
341
368
|
case 49:
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
console.error('[PaymentModule] 获取支付方式列表失败',
|
|
345
|
-
this.logError('getPayMethodListAsync failed',
|
|
369
|
+
_context3.prev = 49;
|
|
370
|
+
_context3.t3 = _context3["catch"](1);
|
|
371
|
+
console.error('[PaymentModule] 获取支付方式列表失败', _context3.t3);
|
|
372
|
+
this.logError('getPayMethodListAsync failed', _context3.t3);
|
|
346
373
|
// 如果所有操作都失败,返回空数组
|
|
347
|
-
return
|
|
374
|
+
return _context3.abrupt("return", []);
|
|
348
375
|
case 54:
|
|
349
376
|
case "end":
|
|
350
|
-
return
|
|
377
|
+
return _context3.stop();
|
|
351
378
|
}
|
|
352
|
-
},
|
|
379
|
+
}, _callee3, this, [[1, 49], [3, 9], [20, 40], [22, 32, 35, 38]]);
|
|
353
380
|
}));
|
|
354
381
|
function getPayMethodListAsync() {
|
|
355
382
|
return _getPayMethodListAsync.apply(this, arguments);
|
|
@@ -363,26 +390,26 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
363
390
|
}, {
|
|
364
391
|
key: "refreshPaymentMethodsInBackground",
|
|
365
392
|
value: (function () {
|
|
366
|
-
var _refreshPaymentMethodsInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
393
|
+
var _refreshPaymentMethodsInBackground = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(cachedMethods) {
|
|
367
394
|
var response, newPayMethods, hasChanges, _iterator2, _step2, method, _iterator3, _step3, _method, eventData;
|
|
368
|
-
return _regeneratorRuntime().wrap(function
|
|
369
|
-
while (1) switch (
|
|
395
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
396
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
370
397
|
case 0:
|
|
371
398
|
this.logInfo('Starting refreshPaymentMethodsInBackground', {
|
|
372
399
|
cachedMethodsCount: cachedMethods.length
|
|
373
400
|
});
|
|
374
|
-
|
|
401
|
+
_context4.prev = 1;
|
|
375
402
|
console.log('[PaymentModule] 后台刷新支付方式列表...');
|
|
376
403
|
|
|
377
404
|
// 从服务器获取最新数据
|
|
378
|
-
|
|
405
|
+
_context4.next = 5;
|
|
379
406
|
return this.request.get('/pay/custom-payment/available');
|
|
380
407
|
case 5:
|
|
381
|
-
response =
|
|
408
|
+
response = _context4.sent;
|
|
382
409
|
newPayMethods = response.data || []; // 检查是否有变化
|
|
383
410
|
hasChanges = this.hasPaymentMethodsChanged(cachedMethods, newPayMethods);
|
|
384
411
|
if (!hasChanges) {
|
|
385
|
-
|
|
412
|
+
_context4.next = 56;
|
|
386
413
|
break;
|
|
387
414
|
}
|
|
388
415
|
console.log('[PaymentModule] 支付方式列表已更新');
|
|
@@ -392,94 +419,94 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
392
419
|
});
|
|
393
420
|
|
|
394
421
|
// 更新缓存
|
|
395
|
-
|
|
422
|
+
_context4.prev = 11;
|
|
396
423
|
// 先清除旧数据
|
|
397
424
|
_iterator2 = _createForOfIteratorHelper(cachedMethods);
|
|
398
|
-
|
|
425
|
+
_context4.prev = 13;
|
|
399
426
|
_iterator2.s();
|
|
400
427
|
case 15:
|
|
401
428
|
if ((_step2 = _iterator2.n()).done) {
|
|
402
|
-
|
|
429
|
+
_context4.next = 21;
|
|
403
430
|
break;
|
|
404
431
|
}
|
|
405
432
|
method = _step2.value;
|
|
406
|
-
|
|
433
|
+
_context4.next = 19;
|
|
407
434
|
return this.dbManager.delete('pay_method', method.id);
|
|
408
435
|
case 19:
|
|
409
|
-
|
|
436
|
+
_context4.next = 15;
|
|
410
437
|
break;
|
|
411
438
|
case 21:
|
|
412
|
-
|
|
439
|
+
_context4.next = 26;
|
|
413
440
|
break;
|
|
414
441
|
case 23:
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
_iterator2.e(
|
|
442
|
+
_context4.prev = 23;
|
|
443
|
+
_context4.t0 = _context4["catch"](13);
|
|
444
|
+
_iterator2.e(_context4.t0);
|
|
418
445
|
case 26:
|
|
419
|
-
|
|
446
|
+
_context4.prev = 26;
|
|
420
447
|
_iterator2.f();
|
|
421
|
-
return
|
|
448
|
+
return _context4.finish(26);
|
|
422
449
|
case 29:
|
|
423
450
|
// 添加新数据
|
|
424
451
|
_iterator3 = _createForOfIteratorHelper(newPayMethods);
|
|
425
|
-
|
|
452
|
+
_context4.prev = 30;
|
|
426
453
|
_iterator3.s();
|
|
427
454
|
case 32:
|
|
428
455
|
if ((_step3 = _iterator3.n()).done) {
|
|
429
|
-
|
|
456
|
+
_context4.next = 38;
|
|
430
457
|
break;
|
|
431
458
|
}
|
|
432
459
|
_method = _step3.value;
|
|
433
|
-
|
|
460
|
+
_context4.next = 36;
|
|
434
461
|
return this.dbManager.update('pay_method', _method);
|
|
435
462
|
case 36:
|
|
436
|
-
|
|
463
|
+
_context4.next = 32;
|
|
437
464
|
break;
|
|
438
465
|
case 38:
|
|
439
|
-
|
|
466
|
+
_context4.next = 43;
|
|
440
467
|
break;
|
|
441
468
|
case 40:
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
_iterator3.e(
|
|
469
|
+
_context4.prev = 40;
|
|
470
|
+
_context4.t1 = _context4["catch"](30);
|
|
471
|
+
_iterator3.e(_context4.t1);
|
|
445
472
|
case 43:
|
|
446
|
-
|
|
473
|
+
_context4.prev = 43;
|
|
447
474
|
_iterator3.f();
|
|
448
|
-
return
|
|
475
|
+
return _context4.finish(43);
|
|
449
476
|
case 46:
|
|
450
|
-
|
|
477
|
+
_context4.next = 51;
|
|
451
478
|
break;
|
|
452
479
|
case 48:
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
console.warn('[PaymentModule] 无法更新支付方式缓存',
|
|
480
|
+
_context4.prev = 48;
|
|
481
|
+
_context4.t2 = _context4["catch"](11);
|
|
482
|
+
console.warn('[PaymentModule] 无法更新支付方式缓存', _context4.t2);
|
|
456
483
|
case 51:
|
|
457
484
|
// 通知外部支付方式已变化
|
|
458
485
|
eventData = {
|
|
459
486
|
oldMethods: cachedMethods,
|
|
460
487
|
newMethods: newPayMethods
|
|
461
488
|
};
|
|
462
|
-
|
|
489
|
+
_context4.next = 54;
|
|
463
490
|
return this.core.effects.emit(PaymentHooks.OnPaymentMethodsChanged, eventData);
|
|
464
491
|
case 54:
|
|
465
|
-
|
|
492
|
+
_context4.next = 57;
|
|
466
493
|
break;
|
|
467
494
|
case 56:
|
|
468
495
|
console.log('[PaymentModule] 支付方式列表无变化');
|
|
469
496
|
case 57:
|
|
470
|
-
|
|
497
|
+
_context4.next = 62;
|
|
471
498
|
break;
|
|
472
499
|
case 59:
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
console.error('[PaymentModule] 后台刷新支付方式失败',
|
|
500
|
+
_context4.prev = 59;
|
|
501
|
+
_context4.t3 = _context4["catch"](1);
|
|
502
|
+
console.error('[PaymentModule] 后台刷新支付方式失败', _context4.t3);
|
|
476
503
|
case 62:
|
|
477
504
|
case "end":
|
|
478
|
-
return
|
|
505
|
+
return _context4.stop();
|
|
479
506
|
}
|
|
480
|
-
},
|
|
507
|
+
}, _callee4, this, [[1, 59], [11, 48], [13, 23, 26, 29], [30, 40, 43, 46]]);
|
|
481
508
|
}));
|
|
482
|
-
function refreshPaymentMethodsInBackground(
|
|
509
|
+
function refreshPaymentMethodsInBackground(_x4) {
|
|
483
510
|
return _refreshPaymentMethodsInBackground.apply(this, arguments);
|
|
484
511
|
}
|
|
485
512
|
return refreshPaymentMethodsInBackground;
|
|
@@ -530,25 +557,25 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
530
557
|
}, {
|
|
531
558
|
key: "getOrderListAsync",
|
|
532
559
|
value: (function () {
|
|
533
|
-
var _getOrderListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
534
|
-
return _regeneratorRuntime().wrap(function
|
|
535
|
-
while (1) switch (
|
|
560
|
+
var _getOrderListAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
561
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
562
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
536
563
|
case 0:
|
|
537
|
-
|
|
538
|
-
|
|
564
|
+
_context5.prev = 0;
|
|
565
|
+
_context5.next = 3;
|
|
539
566
|
return this.dbManager.getAll('order');
|
|
540
567
|
case 3:
|
|
541
|
-
return
|
|
568
|
+
return _context5.abrupt("return", _context5.sent);
|
|
542
569
|
case 6:
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
console.error('[PaymentModule] 获取订单列表失败',
|
|
546
|
-
return
|
|
570
|
+
_context5.prev = 6;
|
|
571
|
+
_context5.t0 = _context5["catch"](0);
|
|
572
|
+
console.error('[PaymentModule] 获取订单列表失败', _context5.t0);
|
|
573
|
+
return _context5.abrupt("return", []);
|
|
547
574
|
case 10:
|
|
548
575
|
case "end":
|
|
549
|
-
return
|
|
576
|
+
return _context5.stop();
|
|
550
577
|
}
|
|
551
|
-
},
|
|
578
|
+
}, _callee5, this, [[0, 6]]);
|
|
552
579
|
}));
|
|
553
580
|
function getOrderListAsync() {
|
|
554
581
|
return _getOrderListAsync.apply(this, arguments);
|
|
@@ -562,27 +589,27 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
562
589
|
}, {
|
|
563
590
|
key: "getOrderByUuidAsync",
|
|
564
591
|
value: (function () {
|
|
565
|
-
var _getOrderByUuidAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
566
|
-
return _regeneratorRuntime().wrap(function
|
|
567
|
-
while (1) switch (
|
|
592
|
+
var _getOrderByUuidAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(orderUuid) {
|
|
593
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
594
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
568
595
|
case 0:
|
|
569
|
-
|
|
570
|
-
|
|
596
|
+
_context6.prev = 0;
|
|
597
|
+
_context6.next = 3;
|
|
571
598
|
return this.dbManager.get('order', orderUuid);
|
|
572
599
|
case 3:
|
|
573
|
-
return
|
|
600
|
+
return _context6.abrupt("return", _context6.sent);
|
|
574
601
|
case 6:
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
console.error('[PaymentModule] 获取订单失败',
|
|
578
|
-
return
|
|
602
|
+
_context6.prev = 6;
|
|
603
|
+
_context6.t0 = _context6["catch"](0);
|
|
604
|
+
console.error('[PaymentModule] 获取订单失败', _context6.t0);
|
|
605
|
+
return _context6.abrupt("return", null);
|
|
579
606
|
case 10:
|
|
580
607
|
case "end":
|
|
581
|
-
return
|
|
608
|
+
return _context6.stop();
|
|
582
609
|
}
|
|
583
|
-
},
|
|
610
|
+
}, _callee6, this, [[0, 6]]);
|
|
584
611
|
}));
|
|
585
|
-
function getOrderByUuidAsync(
|
|
612
|
+
function getOrderByUuidAsync(_x5) {
|
|
586
613
|
return _getOrderByUuidAsync.apply(this, arguments);
|
|
587
614
|
}
|
|
588
615
|
return getOrderByUuidAsync;
|
|
@@ -594,25 +621,25 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
594
621
|
}, {
|
|
595
622
|
key: "pushOrderAsync",
|
|
596
623
|
value: (function () {
|
|
597
|
-
var _pushOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
624
|
+
var _pushOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(params) {
|
|
598
625
|
var existingOrders, existingOrder, originalOrder, newOrder;
|
|
599
|
-
return _regeneratorRuntime().wrap(function
|
|
600
|
-
while (1) switch (
|
|
626
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
627
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
601
628
|
case 0:
|
|
602
629
|
this.logInfo('Starting pushOrderAsync', {
|
|
603
630
|
orderId: params.order_info.order_id,
|
|
604
631
|
totalAmount: params.order_info.total_amount
|
|
605
632
|
});
|
|
606
|
-
|
|
607
|
-
|
|
633
|
+
_context7.prev = 1;
|
|
634
|
+
_context7.next = 4;
|
|
608
635
|
return this.dbManager.getAll('order');
|
|
609
636
|
case 4:
|
|
610
|
-
existingOrders =
|
|
637
|
+
existingOrders = _context7.sent;
|
|
611
638
|
existingOrder = existingOrders.find(function (order) {
|
|
612
639
|
return order.id === params.order_info.order_id;
|
|
613
640
|
});
|
|
614
641
|
if (!existingOrder) {
|
|
615
|
-
|
|
642
|
+
_context7.next = 21;
|
|
616
643
|
break;
|
|
617
644
|
}
|
|
618
645
|
// 如果存在相同 order_id 的订单,更新该订单的 order_info
|
|
@@ -625,20 +652,20 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
625
652
|
this.recalculateOrderAmount(existingOrder);
|
|
626
653
|
|
|
627
654
|
// 更新到数据库
|
|
628
|
-
|
|
655
|
+
_context7.next = 14;
|
|
629
656
|
return this.dbManager.update('order', existingOrder);
|
|
630
657
|
case 14:
|
|
631
|
-
|
|
658
|
+
_context7.next = 16;
|
|
632
659
|
return this.core.effects.emit(PaymentHooks.OnOrderUpdated, existingOrder);
|
|
633
660
|
case 16:
|
|
634
|
-
|
|
661
|
+
_context7.next = 18;
|
|
635
662
|
return this.core.effects.emit(PaymentHooks.OnOrderChanged, {
|
|
636
663
|
action: 'update',
|
|
637
664
|
order: existingOrder,
|
|
638
665
|
originalOrder: originalOrder
|
|
639
666
|
});
|
|
640
667
|
case 18:
|
|
641
|
-
return
|
|
668
|
+
return _context7.abrupt("return", existingOrder);
|
|
642
669
|
case 21:
|
|
643
670
|
// 如果不存在相同 order_id 的订单,创建新订单
|
|
644
671
|
newOrder = {
|
|
@@ -652,13 +679,13 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
652
679
|
expect_amount: params.order_info.total_amount,
|
|
653
680
|
tax_fee: '0.00'
|
|
654
681
|
};
|
|
655
|
-
|
|
682
|
+
_context7.next = 24;
|
|
656
683
|
return this.dbManager.add('order', newOrder);
|
|
657
684
|
case 24:
|
|
658
|
-
|
|
685
|
+
_context7.next = 26;
|
|
659
686
|
return this.core.effects.emit(PaymentHooks.OnOrderAdded, newOrder);
|
|
660
687
|
case 26:
|
|
661
|
-
|
|
688
|
+
_context7.next = 28;
|
|
662
689
|
return this.core.effects.emit(PaymentHooks.OnOrderChanged, {
|
|
663
690
|
action: 'add',
|
|
664
691
|
order: newOrder
|
|
@@ -668,25 +695,25 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
668
695
|
orderUuid: newOrder.uuid,
|
|
669
696
|
orderId: newOrder.id
|
|
670
697
|
});
|
|
671
|
-
return
|
|
698
|
+
return _context7.abrupt("return", newOrder);
|
|
672
699
|
case 30:
|
|
673
|
-
|
|
700
|
+
_context7.next = 37;
|
|
674
701
|
break;
|
|
675
702
|
case 32:
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
console.error('[PaymentModule] 添加订单失败',
|
|
679
|
-
this.logError('pushOrderAsync failed',
|
|
703
|
+
_context7.prev = 32;
|
|
704
|
+
_context7.t0 = _context7["catch"](1);
|
|
705
|
+
console.error('[PaymentModule] 添加订单失败', _context7.t0);
|
|
706
|
+
this.logError('pushOrderAsync failed', _context7.t0, {
|
|
680
707
|
orderId: params.order_info.order_id
|
|
681
708
|
});
|
|
682
|
-
throw
|
|
709
|
+
throw _context7.t0;
|
|
683
710
|
case 37:
|
|
684
711
|
case "end":
|
|
685
|
-
return
|
|
712
|
+
return _context7.stop();
|
|
686
713
|
}
|
|
687
|
-
},
|
|
714
|
+
}, _callee7, this, [[1, 32]]);
|
|
688
715
|
}));
|
|
689
|
-
function pushOrderAsync(
|
|
716
|
+
function pushOrderAsync(_x6) {
|
|
690
717
|
return _pushOrderAsync.apply(this, arguments);
|
|
691
718
|
}
|
|
692
719
|
return pushOrderAsync;
|
|
@@ -698,46 +725,46 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
698
725
|
}, {
|
|
699
726
|
key: "deleteOrderAsync",
|
|
700
727
|
value: (function () {
|
|
701
|
-
var _deleteOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
728
|
+
var _deleteOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(orderUuid) {
|
|
702
729
|
var order;
|
|
703
|
-
return _regeneratorRuntime().wrap(function
|
|
704
|
-
while (1) switch (
|
|
730
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
731
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
705
732
|
case 0:
|
|
706
|
-
|
|
707
|
-
|
|
733
|
+
_context8.prev = 0;
|
|
734
|
+
_context8.next = 3;
|
|
708
735
|
return this.dbManager.get('order', orderUuid);
|
|
709
736
|
case 3:
|
|
710
|
-
order =
|
|
737
|
+
order = _context8.sent;
|
|
711
738
|
if (!order) {
|
|
712
|
-
|
|
739
|
+
_context8.next = 11;
|
|
713
740
|
break;
|
|
714
741
|
}
|
|
715
|
-
|
|
742
|
+
_context8.next = 7;
|
|
716
743
|
return this.dbManager.delete('order', orderUuid);
|
|
717
744
|
case 7:
|
|
718
|
-
|
|
745
|
+
_context8.next = 9;
|
|
719
746
|
return this.core.effects.emit(PaymentHooks.OnOrderDeleted, order);
|
|
720
747
|
case 9:
|
|
721
|
-
|
|
748
|
+
_context8.next = 11;
|
|
722
749
|
return this.core.effects.emit(PaymentHooks.OnOrderChanged, {
|
|
723
750
|
action: 'delete',
|
|
724
751
|
order: order
|
|
725
752
|
});
|
|
726
753
|
case 11:
|
|
727
|
-
|
|
754
|
+
_context8.next = 17;
|
|
728
755
|
break;
|
|
729
756
|
case 13:
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
console.error('[PaymentModule] 删除订单失败',
|
|
733
|
-
throw
|
|
757
|
+
_context8.prev = 13;
|
|
758
|
+
_context8.t0 = _context8["catch"](0);
|
|
759
|
+
console.error('[PaymentModule] 删除订单失败', _context8.t0);
|
|
760
|
+
throw _context8.t0;
|
|
734
761
|
case 17:
|
|
735
762
|
case "end":
|
|
736
|
-
return
|
|
763
|
+
return _context8.stop();
|
|
737
764
|
}
|
|
738
|
-
},
|
|
765
|
+
}, _callee8, this, [[0, 13]]);
|
|
739
766
|
}));
|
|
740
|
-
function deleteOrderAsync(
|
|
767
|
+
function deleteOrderAsync(_x7) {
|
|
741
768
|
return _deleteOrderAsync.apply(this, arguments);
|
|
742
769
|
}
|
|
743
770
|
return deleteOrderAsync;
|
|
@@ -749,48 +776,48 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
749
776
|
}, {
|
|
750
777
|
key: "updateOrderAsync",
|
|
751
778
|
value: (function () {
|
|
752
|
-
var _updateOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
779
|
+
var _updateOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(orderUuid, params) {
|
|
753
780
|
var order, updatedOrder;
|
|
754
|
-
return _regeneratorRuntime().wrap(function
|
|
755
|
-
while (1) switch (
|
|
781
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
782
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
756
783
|
case 0:
|
|
757
|
-
|
|
758
|
-
|
|
784
|
+
_context9.prev = 0;
|
|
785
|
+
_context9.next = 3;
|
|
759
786
|
return this.dbManager.get('order', orderUuid);
|
|
760
787
|
case 3:
|
|
761
|
-
order =
|
|
788
|
+
order = _context9.sent;
|
|
762
789
|
if (!order) {
|
|
763
|
-
|
|
790
|
+
_context9.next = 12;
|
|
764
791
|
break;
|
|
765
792
|
}
|
|
766
793
|
updatedOrder = _objectSpread(_objectSpread({}, order), params);
|
|
767
|
-
|
|
794
|
+
_context9.next = 8;
|
|
768
795
|
return this.dbManager.update('order', updatedOrder);
|
|
769
796
|
case 8:
|
|
770
|
-
|
|
797
|
+
_context9.next = 10;
|
|
771
798
|
return this.core.effects.emit(PaymentHooks.OnOrderUpdated, updatedOrder);
|
|
772
799
|
case 10:
|
|
773
|
-
|
|
800
|
+
_context9.next = 12;
|
|
774
801
|
return this.core.effects.emit(PaymentHooks.OnOrderChanged, {
|
|
775
802
|
action: 'update',
|
|
776
803
|
order: updatedOrder,
|
|
777
804
|
originalOrder: order
|
|
778
805
|
});
|
|
779
806
|
case 12:
|
|
780
|
-
|
|
807
|
+
_context9.next = 18;
|
|
781
808
|
break;
|
|
782
809
|
case 14:
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
console.error('[PaymentModule] 更新订单失败',
|
|
786
|
-
throw
|
|
810
|
+
_context9.prev = 14;
|
|
811
|
+
_context9.t0 = _context9["catch"](0);
|
|
812
|
+
console.error('[PaymentModule] 更新订单失败', _context9.t0);
|
|
813
|
+
throw _context9.t0;
|
|
787
814
|
case 18:
|
|
788
815
|
case "end":
|
|
789
|
-
return
|
|
816
|
+
return _context9.stop();
|
|
790
817
|
}
|
|
791
|
-
},
|
|
818
|
+
}, _callee9, this, [[0, 14]]);
|
|
792
819
|
}));
|
|
793
|
-
function updateOrderAsync(
|
|
820
|
+
function updateOrderAsync(_x8, _x9) {
|
|
794
821
|
return _updateOrderAsync.apply(this, arguments);
|
|
795
822
|
}
|
|
796
823
|
return updateOrderAsync;
|
|
@@ -802,29 +829,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
802
829
|
}, {
|
|
803
830
|
key: "getPaymentAsync",
|
|
804
831
|
value: (function () {
|
|
805
|
-
var _getPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
832
|
+
var _getPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(orderUuid) {
|
|
806
833
|
var order;
|
|
807
|
-
return _regeneratorRuntime().wrap(function
|
|
808
|
-
while (1) switch (
|
|
834
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
835
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
809
836
|
case 0:
|
|
810
837
|
if (orderUuid) {
|
|
811
|
-
|
|
838
|
+
_context10.next = 2;
|
|
812
839
|
break;
|
|
813
840
|
}
|
|
814
841
|
throw new Error('orderUuid is required');
|
|
815
842
|
case 2:
|
|
816
|
-
|
|
843
|
+
_context10.next = 4;
|
|
817
844
|
return this.getOrderByUuidAsync(orderUuid);
|
|
818
845
|
case 4:
|
|
819
|
-
order =
|
|
820
|
-
return
|
|
846
|
+
order = _context10.sent;
|
|
847
|
+
return _context10.abrupt("return", (order === null || order === void 0 ? void 0 : order.payment) || []);
|
|
821
848
|
case 6:
|
|
822
849
|
case "end":
|
|
823
|
-
return
|
|
850
|
+
return _context10.stop();
|
|
824
851
|
}
|
|
825
|
-
},
|
|
852
|
+
}, _callee10, this);
|
|
826
853
|
}));
|
|
827
|
-
function getPaymentAsync(
|
|
854
|
+
function getPaymentAsync(_x10) {
|
|
828
855
|
return _getPaymentAsync.apply(this, arguments);
|
|
829
856
|
}
|
|
830
857
|
return getPaymentAsync;
|
|
@@ -836,23 +863,23 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
836
863
|
}, {
|
|
837
864
|
key: "pushPaymentAsync",
|
|
838
865
|
value: (function () {
|
|
839
|
-
var _pushPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
866
|
+
var _pushPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(orderUuid, paymentItem) {
|
|
840
867
|
var order, newPaymentItem;
|
|
841
|
-
return _regeneratorRuntime().wrap(function
|
|
842
|
-
while (1) switch (
|
|
868
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
869
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
843
870
|
case 0:
|
|
844
871
|
this.logInfo('Starting pushPaymentAsync', {
|
|
845
872
|
orderUuid: orderUuid,
|
|
846
873
|
paymentAmount: paymentItem.amount,
|
|
847
874
|
paymentCode: paymentItem.code
|
|
848
875
|
});
|
|
849
|
-
|
|
850
|
-
|
|
876
|
+
_context11.prev = 1;
|
|
877
|
+
_context11.next = 4;
|
|
851
878
|
return this.dbManager.get('order', orderUuid);
|
|
852
879
|
case 4:
|
|
853
|
-
order =
|
|
880
|
+
order = _context11.sent;
|
|
854
881
|
if (order) {
|
|
855
|
-
|
|
882
|
+
_context11.next = 7;
|
|
856
883
|
break;
|
|
857
884
|
}
|
|
858
885
|
throw new Error('订单不存在');
|
|
@@ -869,16 +896,16 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
869
896
|
this.recalculateOrderAmount(order);
|
|
870
897
|
|
|
871
898
|
// 更新到 IndexDB
|
|
872
|
-
|
|
899
|
+
_context11.next = 12;
|
|
873
900
|
return this.dbManager.update('order', order);
|
|
874
901
|
case 12:
|
|
875
|
-
|
|
902
|
+
_context11.next = 14;
|
|
876
903
|
return this.core.effects.emit(PaymentHooks.OnPaymentAdded, {
|
|
877
904
|
order: order,
|
|
878
905
|
paymentItem: newPaymentItem
|
|
879
906
|
});
|
|
880
907
|
case 14:
|
|
881
|
-
|
|
908
|
+
_context11.next = 16;
|
|
882
909
|
return this.core.effects.emit(PaymentHooks.OnOrderChanged, {
|
|
883
910
|
action: 'payment_add',
|
|
884
911
|
order: order,
|
|
@@ -890,24 +917,24 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
890
917
|
paymentUuid: newPaymentItem.uuid,
|
|
891
918
|
newExpectAmount: order.expect_amount
|
|
892
919
|
});
|
|
893
|
-
|
|
920
|
+
_context11.next = 24;
|
|
894
921
|
break;
|
|
895
922
|
case 19:
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
console.error('[PaymentModule] 添加支付项失败',
|
|
899
|
-
this.logError('pushPaymentAsync failed',
|
|
923
|
+
_context11.prev = 19;
|
|
924
|
+
_context11.t0 = _context11["catch"](1);
|
|
925
|
+
console.error('[PaymentModule] 添加支付项失败', _context11.t0);
|
|
926
|
+
this.logError('pushPaymentAsync failed', _context11.t0, {
|
|
900
927
|
orderUuid: orderUuid,
|
|
901
928
|
paymentItem: paymentItem
|
|
902
929
|
});
|
|
903
|
-
throw
|
|
930
|
+
throw _context11.t0;
|
|
904
931
|
case 24:
|
|
905
932
|
case "end":
|
|
906
|
-
return
|
|
933
|
+
return _context11.stop();
|
|
907
934
|
}
|
|
908
|
-
},
|
|
935
|
+
}, _callee11, this, [[1, 19]]);
|
|
909
936
|
}));
|
|
910
|
-
function pushPaymentAsync(
|
|
937
|
+
function pushPaymentAsync(_x11, _x12) {
|
|
911
938
|
return _pushPaymentAsync.apply(this, arguments);
|
|
912
939
|
}
|
|
913
940
|
return pushPaymentAsync;
|
|
@@ -919,22 +946,22 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
919
946
|
}, {
|
|
920
947
|
key: "deletePaymentAsync",
|
|
921
948
|
value: (function () {
|
|
922
|
-
var _deletePaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
949
|
+
var _deletePaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(orderUuid, paymentUuid) {
|
|
923
950
|
var order, index, deletedPayment;
|
|
924
|
-
return _regeneratorRuntime().wrap(function
|
|
925
|
-
while (1) switch (
|
|
951
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
952
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
926
953
|
case 0:
|
|
927
954
|
this.logInfo('Starting deletePaymentAsync', {
|
|
928
955
|
orderUuid: orderUuid,
|
|
929
956
|
paymentUuid: paymentUuid
|
|
930
957
|
});
|
|
931
|
-
|
|
932
|
-
|
|
958
|
+
_context12.prev = 1;
|
|
959
|
+
_context12.next = 4;
|
|
933
960
|
return this.dbManager.get('order', orderUuid);
|
|
934
961
|
case 4:
|
|
935
|
-
order =
|
|
962
|
+
order = _context12.sent;
|
|
936
963
|
if (order) {
|
|
937
|
-
|
|
964
|
+
_context12.next = 7;
|
|
938
965
|
break;
|
|
939
966
|
}
|
|
940
967
|
throw new Error('订单不存在');
|
|
@@ -943,43 +970,43 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
943
970
|
return payment.uuid === paymentUuid;
|
|
944
971
|
});
|
|
945
972
|
if (!(index > -1)) {
|
|
946
|
-
|
|
973
|
+
_context12.next = 17;
|
|
947
974
|
break;
|
|
948
975
|
}
|
|
949
976
|
deletedPayment = order.payment.splice(index, 1)[0]; // 重新计算待付金额
|
|
950
977
|
this.recalculateOrderAmount(order);
|
|
951
978
|
|
|
952
979
|
// 更新到 IndexDB
|
|
953
|
-
|
|
980
|
+
_context12.next = 13;
|
|
954
981
|
return this.dbManager.update('order', order);
|
|
955
982
|
case 13:
|
|
956
|
-
|
|
983
|
+
_context12.next = 15;
|
|
957
984
|
return this.core.effects.emit(PaymentHooks.OnPaymentDeleted, {
|
|
958
985
|
order: order,
|
|
959
986
|
paymentItem: deletedPayment
|
|
960
987
|
});
|
|
961
988
|
case 15:
|
|
962
|
-
|
|
989
|
+
_context12.next = 17;
|
|
963
990
|
return this.core.effects.emit(PaymentHooks.OnOrderChanged, {
|
|
964
991
|
action: 'payment_delete',
|
|
965
992
|
order: order,
|
|
966
993
|
paymentItem: deletedPayment
|
|
967
994
|
});
|
|
968
995
|
case 17:
|
|
969
|
-
|
|
996
|
+
_context12.next = 23;
|
|
970
997
|
break;
|
|
971
998
|
case 19:
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
console.error('[PaymentModule] 删除支付项失败',
|
|
975
|
-
throw
|
|
999
|
+
_context12.prev = 19;
|
|
1000
|
+
_context12.t0 = _context12["catch"](1);
|
|
1001
|
+
console.error('[PaymentModule] 删除支付项失败', _context12.t0);
|
|
1002
|
+
throw _context12.t0;
|
|
976
1003
|
case 23:
|
|
977
1004
|
case "end":
|
|
978
|
-
return
|
|
1005
|
+
return _context12.stop();
|
|
979
1006
|
}
|
|
980
|
-
},
|
|
1007
|
+
}, _callee12, this, [[1, 19]]);
|
|
981
1008
|
}));
|
|
982
|
-
function deletePaymentAsync(
|
|
1009
|
+
function deletePaymentAsync(_x13, _x14) {
|
|
983
1010
|
return _deletePaymentAsync.apply(this, arguments);
|
|
984
1011
|
}
|
|
985
1012
|
return deletePaymentAsync;
|
|
@@ -991,18 +1018,18 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
991
1018
|
}, {
|
|
992
1019
|
key: "updatePaymentAsync",
|
|
993
1020
|
value: (function () {
|
|
994
|
-
var _updatePaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1021
|
+
var _updatePaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderUuid, paymentUuid, params) {
|
|
995
1022
|
var order, paymentItem, formattedParams;
|
|
996
|
-
return _regeneratorRuntime().wrap(function
|
|
997
|
-
while (1) switch (
|
|
1023
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1024
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
998
1025
|
case 0:
|
|
999
|
-
|
|
1000
|
-
|
|
1026
|
+
_context13.prev = 0;
|
|
1027
|
+
_context13.next = 3;
|
|
1001
1028
|
return this.dbManager.get('order', orderUuid);
|
|
1002
1029
|
case 3:
|
|
1003
|
-
order =
|
|
1030
|
+
order = _context13.sent;
|
|
1004
1031
|
if (order) {
|
|
1005
|
-
|
|
1032
|
+
_context13.next = 6;
|
|
1006
1033
|
break;
|
|
1007
1034
|
}
|
|
1008
1035
|
throw new Error('订单不存在');
|
|
@@ -1011,7 +1038,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1011
1038
|
return payment.uuid === paymentUuid;
|
|
1012
1039
|
});
|
|
1013
1040
|
if (!paymentItem) {
|
|
1014
|
-
|
|
1041
|
+
_context13.next = 18;
|
|
1015
1042
|
break;
|
|
1016
1043
|
}
|
|
1017
1044
|
// 如果更新参数中包含 amount,先格式化
|
|
@@ -1025,36 +1052,36 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1025
1052
|
this.recalculateOrderAmount(order);
|
|
1026
1053
|
|
|
1027
1054
|
// 更新到 IndexDB
|
|
1028
|
-
|
|
1055
|
+
_context13.next = 14;
|
|
1029
1056
|
return this.dbManager.update('order', order);
|
|
1030
1057
|
case 14:
|
|
1031
|
-
|
|
1058
|
+
_context13.next = 16;
|
|
1032
1059
|
return this.core.effects.emit(PaymentHooks.OnPaymentUpdated, {
|
|
1033
1060
|
order: order,
|
|
1034
1061
|
paymentItem: paymentItem
|
|
1035
1062
|
});
|
|
1036
1063
|
case 16:
|
|
1037
|
-
|
|
1064
|
+
_context13.next = 18;
|
|
1038
1065
|
return this.core.effects.emit(PaymentHooks.OnOrderChanged, {
|
|
1039
1066
|
action: 'payment_update',
|
|
1040
1067
|
order: order,
|
|
1041
1068
|
paymentItem: paymentItem
|
|
1042
1069
|
});
|
|
1043
1070
|
case 18:
|
|
1044
|
-
|
|
1071
|
+
_context13.next = 24;
|
|
1045
1072
|
break;
|
|
1046
1073
|
case 20:
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
console.error('[PaymentModule] 更新支付项失败',
|
|
1050
|
-
throw
|
|
1074
|
+
_context13.prev = 20;
|
|
1075
|
+
_context13.t0 = _context13["catch"](0);
|
|
1076
|
+
console.error('[PaymentModule] 更新支付项失败', _context13.t0);
|
|
1077
|
+
throw _context13.t0;
|
|
1051
1078
|
case 24:
|
|
1052
1079
|
case "end":
|
|
1053
|
-
return
|
|
1080
|
+
return _context13.stop();
|
|
1054
1081
|
}
|
|
1055
|
-
},
|
|
1082
|
+
}, _callee13, this, [[0, 20]]);
|
|
1056
1083
|
}));
|
|
1057
|
-
function updatePaymentAsync(
|
|
1084
|
+
function updatePaymentAsync(_x15, _x16, _x17) {
|
|
1058
1085
|
return _updatePaymentAsync.apply(this, arguments);
|
|
1059
1086
|
}
|
|
1060
1087
|
return updatePaymentAsync;
|
|
@@ -1066,76 +1093,76 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1066
1093
|
}, {
|
|
1067
1094
|
key: "submitPayAsync",
|
|
1068
1095
|
value: (function () {
|
|
1069
|
-
var _submitPayAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1096
|
+
var _submitPayAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(orderUuid) {
|
|
1070
1097
|
var orderToSubmit, order, _allOrders, _iterator5, _step5, _order, allOrders, allOrdersProcessed, result;
|
|
1071
|
-
return _regeneratorRuntime().wrap(function
|
|
1072
|
-
while (1) switch (
|
|
1098
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1099
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1073
1100
|
case 0:
|
|
1074
1101
|
this.logInfo('Starting submitPayAsync', {
|
|
1075
1102
|
orderUuid: orderUuid
|
|
1076
1103
|
});
|
|
1077
|
-
|
|
1104
|
+
_context14.prev = 1;
|
|
1078
1105
|
if (!orderUuid) {
|
|
1079
|
-
|
|
1106
|
+
_context14.next = 9;
|
|
1080
1107
|
break;
|
|
1081
1108
|
}
|
|
1082
|
-
|
|
1109
|
+
_context14.next = 5;
|
|
1083
1110
|
return this.dbManager.get('order', orderUuid);
|
|
1084
1111
|
case 5:
|
|
1085
|
-
order =
|
|
1112
|
+
order = _context14.sent;
|
|
1086
1113
|
orderToSubmit = order ? [order] : [];
|
|
1087
|
-
|
|
1114
|
+
_context14.next = 13;
|
|
1088
1115
|
break;
|
|
1089
1116
|
case 9:
|
|
1090
|
-
|
|
1117
|
+
_context14.next = 11;
|
|
1091
1118
|
return this.dbManager.getAll('order');
|
|
1092
1119
|
case 11:
|
|
1093
|
-
_allOrders =
|
|
1120
|
+
_allOrders = _context14.sent;
|
|
1094
1121
|
// 包括正在处理中的订单和部分支付的订单(可能添加了新的支付项)
|
|
1095
1122
|
orderToSubmit = _allOrders.filter(function (order) {
|
|
1096
1123
|
return order.payment_status === PaymentStatus.Processing || order.payment_status === PaymentStatus.PartiallyPaid;
|
|
1097
1124
|
});
|
|
1098
1125
|
case 13:
|
|
1099
1126
|
_iterator5 = _createForOfIteratorHelper(orderToSubmit);
|
|
1100
|
-
|
|
1127
|
+
_context14.prev = 14;
|
|
1101
1128
|
_iterator5.s();
|
|
1102
1129
|
case 16:
|
|
1103
1130
|
if ((_step5 = _iterator5.n()).done) {
|
|
1104
|
-
|
|
1131
|
+
_context14.next = 22;
|
|
1105
1132
|
break;
|
|
1106
1133
|
}
|
|
1107
1134
|
_order = _step5.value;
|
|
1108
|
-
|
|
1135
|
+
_context14.next = 20;
|
|
1109
1136
|
return this.submitSingleOrderPayment(_order);
|
|
1110
1137
|
case 20:
|
|
1111
|
-
|
|
1138
|
+
_context14.next = 16;
|
|
1112
1139
|
break;
|
|
1113
1140
|
case 22:
|
|
1114
|
-
|
|
1141
|
+
_context14.next = 27;
|
|
1115
1142
|
break;
|
|
1116
1143
|
case 24:
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
_iterator5.e(
|
|
1144
|
+
_context14.prev = 24;
|
|
1145
|
+
_context14.t0 = _context14["catch"](14);
|
|
1146
|
+
_iterator5.e(_context14.t0);
|
|
1120
1147
|
case 27:
|
|
1121
|
-
|
|
1148
|
+
_context14.prev = 27;
|
|
1122
1149
|
_iterator5.f();
|
|
1123
|
-
return
|
|
1150
|
+
return _context14.finish(27);
|
|
1124
1151
|
case 30:
|
|
1125
|
-
|
|
1152
|
+
_context14.next = 32;
|
|
1126
1153
|
return this.runPaymentSyncQueue();
|
|
1127
1154
|
case 32:
|
|
1128
|
-
|
|
1155
|
+
_context14.next = 34;
|
|
1129
1156
|
return this.dbManager.getAll('order');
|
|
1130
1157
|
case 34:
|
|
1131
|
-
allOrders =
|
|
1158
|
+
allOrders = _context14.sent;
|
|
1132
1159
|
allOrdersProcessed = allOrders.every(function (order) {
|
|
1133
1160
|
return order.payment.every(function (payment) {
|
|
1134
1161
|
return payment.isSynced === true;
|
|
1135
1162
|
});
|
|
1136
1163
|
});
|
|
1137
1164
|
if (!allOrdersProcessed) {
|
|
1138
|
-
|
|
1165
|
+
_context14.next = 42;
|
|
1139
1166
|
break;
|
|
1140
1167
|
}
|
|
1141
1168
|
result = {
|
|
@@ -1145,34 +1172,34 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1145
1172
|
result: result.status,
|
|
1146
1173
|
processedOrdersCount: allOrders.length
|
|
1147
1174
|
});
|
|
1148
|
-
return
|
|
1175
|
+
return _context14.abrupt("return", result);
|
|
1149
1176
|
case 42:
|
|
1150
1177
|
this.logWarning('submitPayAsync completed with unprocessed orders', {
|
|
1151
1178
|
totalOrders: allOrders.length
|
|
1152
1179
|
});
|
|
1153
|
-
return
|
|
1180
|
+
return _context14.abrupt("return", {
|
|
1154
1181
|
status: 'failed'
|
|
1155
1182
|
});
|
|
1156
1183
|
case 44:
|
|
1157
|
-
|
|
1184
|
+
_context14.next = 51;
|
|
1158
1185
|
break;
|
|
1159
1186
|
case 46:
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
console.error('[PaymentModule] 提交支付失败',
|
|
1163
|
-
this.logError('submitPayAsync failed',
|
|
1187
|
+
_context14.prev = 46;
|
|
1188
|
+
_context14.t1 = _context14["catch"](1);
|
|
1189
|
+
console.error('[PaymentModule] 提交支付失败', _context14.t1);
|
|
1190
|
+
this.logError('submitPayAsync failed', _context14.t1, {
|
|
1164
1191
|
orderUuid: orderUuid
|
|
1165
1192
|
});
|
|
1166
|
-
return
|
|
1193
|
+
return _context14.abrupt("return", {
|
|
1167
1194
|
status: 'failed'
|
|
1168
1195
|
});
|
|
1169
1196
|
case 51:
|
|
1170
1197
|
case "end":
|
|
1171
|
-
return
|
|
1198
|
+
return _context14.stop();
|
|
1172
1199
|
}
|
|
1173
|
-
},
|
|
1200
|
+
}, _callee14, this, [[1, 46], [14, 24, 27, 30]]);
|
|
1174
1201
|
}));
|
|
1175
|
-
function submitPayAsync(
|
|
1202
|
+
function submitPayAsync(_x18) {
|
|
1176
1203
|
return _submitPayAsync.apply(this, arguments);
|
|
1177
1204
|
}
|
|
1178
1205
|
return submitPayAsync;
|
|
@@ -1184,12 +1211,12 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1184
1211
|
}, {
|
|
1185
1212
|
key: "submitSingleOrderPayment",
|
|
1186
1213
|
value: (function () {
|
|
1187
|
-
var _submitSingleOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1214
|
+
var _submitSingleOrderPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(order) {
|
|
1188
1215
|
var paymentData, totalPaidAmount, orderTotalAmount;
|
|
1189
|
-
return _regeneratorRuntime().wrap(function
|
|
1190
|
-
while (1) switch (
|
|
1216
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1217
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1191
1218
|
case 0:
|
|
1192
|
-
|
|
1219
|
+
_context15.prev = 0;
|
|
1193
1220
|
paymentData = {
|
|
1194
1221
|
payments: order.payment.map(function (payment) {
|
|
1195
1222
|
return payment;
|
|
@@ -1215,35 +1242,35 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1215
1242
|
|
|
1216
1243
|
// 更新订单状态到数据库
|
|
1217
1244
|
// 注意:isSynced 保持为 false,直到网络同步成功后才设为 true
|
|
1218
|
-
|
|
1245
|
+
_context15.next = 8;
|
|
1219
1246
|
return this.dbManager.update('order', order);
|
|
1220
1247
|
case 8:
|
|
1221
|
-
|
|
1248
|
+
_context15.next = 10;
|
|
1222
1249
|
return this.addToSyncQueue(order, paymentData);
|
|
1223
1250
|
case 10:
|
|
1224
|
-
|
|
1251
|
+
_context15.next = 12;
|
|
1225
1252
|
return this.core.effects.emit(PaymentHooks.OnPaymentSubmitted, order);
|
|
1226
1253
|
case 12:
|
|
1227
|
-
|
|
1254
|
+
_context15.next = 14;
|
|
1228
1255
|
return this.core.effects.emit(PaymentHooks.OnOrderChanged, {
|
|
1229
1256
|
action: 'submit',
|
|
1230
1257
|
order: order
|
|
1231
1258
|
});
|
|
1232
1259
|
case 14:
|
|
1233
|
-
|
|
1260
|
+
_context15.next = 20;
|
|
1234
1261
|
break;
|
|
1235
1262
|
case 16:
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
console.error("[PaymentModule] \u8BA2\u5355 ".concat(order.uuid, " \u652F\u4ED8\u63D0\u4EA4\u5931\u8D25"),
|
|
1239
|
-
throw
|
|
1263
|
+
_context15.prev = 16;
|
|
1264
|
+
_context15.t0 = _context15["catch"](0);
|
|
1265
|
+
console.error("[PaymentModule] \u8BA2\u5355 ".concat(order.uuid, " \u652F\u4ED8\u63D0\u4EA4\u5931\u8D25"), _context15.t0);
|
|
1266
|
+
throw _context15.t0;
|
|
1240
1267
|
case 20:
|
|
1241
1268
|
case "end":
|
|
1242
|
-
return
|
|
1269
|
+
return _context15.stop();
|
|
1243
1270
|
}
|
|
1244
|
-
},
|
|
1271
|
+
}, _callee15, this, [[0, 16]]);
|
|
1245
1272
|
}));
|
|
1246
|
-
function submitSingleOrderPayment(
|
|
1273
|
+
function submitSingleOrderPayment(_x19) {
|
|
1247
1274
|
return _submitSingleOrderPayment.apply(this, arguments);
|
|
1248
1275
|
}
|
|
1249
1276
|
return submitSingleOrderPayment;
|
|
@@ -1255,9 +1282,9 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1255
1282
|
}, {
|
|
1256
1283
|
key: "addToSyncQueue",
|
|
1257
1284
|
value: (function () {
|
|
1258
|
-
var _addToSyncQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1259
|
-
return _regeneratorRuntime().wrap(function
|
|
1260
|
-
while (1) switch (
|
|
1285
|
+
var _addToSyncQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(order, paymentData) {
|
|
1286
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1287
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1261
1288
|
case 0:
|
|
1262
1289
|
try {
|
|
1263
1290
|
console.log("[PaymentModule] \u8BA2\u5355 ".concat(order.uuid, " \u5DF2\u6DFB\u52A0\u5230\u540C\u6B65\u961F\u5217"));
|
|
@@ -1289,11 +1316,11 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1289
1316
|
}
|
|
1290
1317
|
case 1:
|
|
1291
1318
|
case "end":
|
|
1292
|
-
return
|
|
1319
|
+
return _context16.stop();
|
|
1293
1320
|
}
|
|
1294
|
-
},
|
|
1321
|
+
}, _callee16, this);
|
|
1295
1322
|
}));
|
|
1296
|
-
function addToSyncQueue(
|
|
1323
|
+
function addToSyncQueue(_x20, _x21) {
|
|
1297
1324
|
return _addToSyncQueue.apply(this, arguments);
|
|
1298
1325
|
}
|
|
1299
1326
|
return addToSyncQueue;
|
|
@@ -1305,29 +1332,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1305
1332
|
}, {
|
|
1306
1333
|
key: "getRemainingOrderAmountAsync",
|
|
1307
1334
|
value: (function () {
|
|
1308
|
-
var _getRemainingOrderAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1335
|
+
var _getRemainingOrderAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(orderUuid) {
|
|
1309
1336
|
var order;
|
|
1310
|
-
return _regeneratorRuntime().wrap(function
|
|
1311
|
-
while (1) switch (
|
|
1337
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1338
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1312
1339
|
case 0:
|
|
1313
|
-
|
|
1340
|
+
_context17.next = 2;
|
|
1314
1341
|
return this.getOrderByUuidAsync(orderUuid);
|
|
1315
1342
|
case 2:
|
|
1316
|
-
order =
|
|
1343
|
+
order = _context17.sent;
|
|
1317
1344
|
if (order) {
|
|
1318
|
-
|
|
1345
|
+
_context17.next = 5;
|
|
1319
1346
|
break;
|
|
1320
1347
|
}
|
|
1321
1348
|
throw new Error('订单不存在');
|
|
1322
1349
|
case 5:
|
|
1323
|
-
return
|
|
1350
|
+
return _context17.abrupt("return", new Decimal(order.expect_amount).toNumber());
|
|
1324
1351
|
case 6:
|
|
1325
1352
|
case "end":
|
|
1326
|
-
return
|
|
1353
|
+
return _context17.stop();
|
|
1327
1354
|
}
|
|
1328
|
-
},
|
|
1355
|
+
}, _callee17, this);
|
|
1329
1356
|
}));
|
|
1330
|
-
function getRemainingOrderAmountAsync(
|
|
1357
|
+
function getRemainingOrderAmountAsync(_x22) {
|
|
1331
1358
|
return _getRemainingOrderAmountAsync.apply(this, arguments);
|
|
1332
1359
|
}
|
|
1333
1360
|
return getRemainingOrderAmountAsync;
|
|
@@ -1339,65 +1366,65 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1339
1366
|
}, {
|
|
1340
1367
|
key: "getRemainingOrderAmountWithInputAsync",
|
|
1341
1368
|
value: (function () {
|
|
1342
|
-
var _getRemainingOrderAmountWithInputAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1369
|
+
var _getRemainingOrderAmountWithInputAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(inputAmount, orderUuid) {
|
|
1343
1370
|
var order, inputDecimal;
|
|
1344
|
-
return _regeneratorRuntime().wrap(function
|
|
1345
|
-
while (1) switch (
|
|
1371
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1372
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1346
1373
|
case 0:
|
|
1347
|
-
|
|
1374
|
+
_context18.next = 2;
|
|
1348
1375
|
return this.getOrderByUuidAsync(orderUuid);
|
|
1349
1376
|
case 2:
|
|
1350
|
-
order =
|
|
1377
|
+
order = _context18.sent;
|
|
1351
1378
|
if (order) {
|
|
1352
|
-
|
|
1379
|
+
_context18.next = 5;
|
|
1353
1380
|
break;
|
|
1354
1381
|
}
|
|
1355
1382
|
throw new Error('订单不存在');
|
|
1356
1383
|
case 5:
|
|
1357
1384
|
if (!(inputAmount === null || inputAmount === undefined)) {
|
|
1358
|
-
|
|
1385
|
+
_context18.next = 7;
|
|
1359
1386
|
break;
|
|
1360
1387
|
}
|
|
1361
|
-
return
|
|
1388
|
+
return _context18.abrupt("return", new Decimal(order.expect_amount).toNumber());
|
|
1362
1389
|
case 7:
|
|
1363
1390
|
if (!(typeof inputAmount === 'string')) {
|
|
1364
|
-
|
|
1391
|
+
_context18.next = 10;
|
|
1365
1392
|
break;
|
|
1366
1393
|
}
|
|
1367
1394
|
if (!(inputAmount.trim() === '')) {
|
|
1368
|
-
|
|
1395
|
+
_context18.next = 10;
|
|
1369
1396
|
break;
|
|
1370
1397
|
}
|
|
1371
|
-
return
|
|
1398
|
+
return _context18.abrupt("return", new Decimal(order.expect_amount).toNumber());
|
|
1372
1399
|
case 10:
|
|
1373
1400
|
if (!(typeof inputAmount === 'number')) {
|
|
1374
|
-
|
|
1401
|
+
_context18.next = 14;
|
|
1375
1402
|
break;
|
|
1376
1403
|
}
|
|
1377
1404
|
if (!(isNaN(inputAmount) || !isFinite(inputAmount))) {
|
|
1378
|
-
|
|
1405
|
+
_context18.next = 14;
|
|
1379
1406
|
break;
|
|
1380
1407
|
}
|
|
1381
1408
|
// 如果输入是 NaN 或无穷大,返回原始的待付金额
|
|
1382
1409
|
console.warn("[PaymentModule] \u8F93\u5165\u91D1\u989D\u4E0D\u662F\u6709\u6548\u6570\u5B57: ".concat(inputAmount, "\uFF0C\u8FD4\u56DE\u539F\u59CB\u5F85\u4ED8\u91D1\u989D"));
|
|
1383
|
-
return
|
|
1410
|
+
return _context18.abrupt("return", new Decimal(order.expect_amount).toNumber());
|
|
1384
1411
|
case 14:
|
|
1385
|
-
|
|
1412
|
+
_context18.prev = 14;
|
|
1386
1413
|
inputDecimal = new Decimal(inputAmount);
|
|
1387
|
-
return
|
|
1414
|
+
return _context18.abrupt("return", new Decimal(order.expect_amount).minus(inputDecimal).toNumber());
|
|
1388
1415
|
case 19:
|
|
1389
|
-
|
|
1390
|
-
|
|
1416
|
+
_context18.prev = 19;
|
|
1417
|
+
_context18.t0 = _context18["catch"](14);
|
|
1391
1418
|
// 如果输入不是有效的数字,返回原始的待付金额
|
|
1392
1419
|
console.warn("[PaymentModule] \u8F93\u5165\u91D1\u989D\u683C\u5F0F\u65E0\u6548: ".concat(inputAmount, "\uFF0C\u8FD4\u56DE\u539F\u59CB\u5F85\u4ED8\u91D1\u989D"));
|
|
1393
|
-
return
|
|
1420
|
+
return _context18.abrupt("return", new Decimal(order.expect_amount).toNumber());
|
|
1394
1421
|
case 23:
|
|
1395
1422
|
case "end":
|
|
1396
|
-
return
|
|
1423
|
+
return _context18.stop();
|
|
1397
1424
|
}
|
|
1398
|
-
},
|
|
1425
|
+
}, _callee18, this, [[14, 19]]);
|
|
1399
1426
|
}));
|
|
1400
|
-
function getRemainingOrderAmountWithInputAsync(
|
|
1427
|
+
function getRemainingOrderAmountWithInputAsync(_x23, _x24) {
|
|
1401
1428
|
return _getRemainingOrderAmountWithInputAsync.apply(this, arguments);
|
|
1402
1429
|
}
|
|
1403
1430
|
return getRemainingOrderAmountWithInputAsync;
|
|
@@ -1423,29 +1450,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1423
1450
|
}, {
|
|
1424
1451
|
key: "getCashPaymentMethod",
|
|
1425
1452
|
value: (function () {
|
|
1426
|
-
var _getCashPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1453
|
+
var _getCashPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
1427
1454
|
var payMethods;
|
|
1428
|
-
return _regeneratorRuntime().wrap(function
|
|
1429
|
-
while (1) switch (
|
|
1455
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1456
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1430
1457
|
case 0:
|
|
1431
|
-
|
|
1432
|
-
|
|
1458
|
+
_context19.prev = 0;
|
|
1459
|
+
_context19.next = 3;
|
|
1433
1460
|
return this.dbManager.getAll('pay_method');
|
|
1434
1461
|
case 3:
|
|
1435
|
-
payMethods =
|
|
1436
|
-
return
|
|
1462
|
+
payMethods = _context19.sent;
|
|
1463
|
+
return _context19.abrupt("return", payMethods.find(function (method) {
|
|
1437
1464
|
return method.code === PaymentMethodType.Cash;
|
|
1438
1465
|
}) || null);
|
|
1439
1466
|
case 7:
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
console.error('[PaymentModule] 获取现金支付方式失败',
|
|
1443
|
-
return
|
|
1467
|
+
_context19.prev = 7;
|
|
1468
|
+
_context19.t0 = _context19["catch"](0);
|
|
1469
|
+
console.error('[PaymentModule] 获取现金支付方式失败', _context19.t0);
|
|
1470
|
+
return _context19.abrupt("return", null);
|
|
1444
1471
|
case 11:
|
|
1445
1472
|
case "end":
|
|
1446
|
-
return
|
|
1473
|
+
return _context19.stop();
|
|
1447
1474
|
}
|
|
1448
|
-
},
|
|
1475
|
+
}, _callee19, this, [[0, 7]]);
|
|
1449
1476
|
}));
|
|
1450
1477
|
function getCashPaymentMethod() {
|
|
1451
1478
|
return _getCashPaymentMethod.apply(this, arguments);
|
|
@@ -1459,29 +1486,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1459
1486
|
}, {
|
|
1460
1487
|
key: "getEftposPaymentMethod",
|
|
1461
1488
|
value: (function () {
|
|
1462
|
-
var _getEftposPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1489
|
+
var _getEftposPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
1463
1490
|
var payMethods;
|
|
1464
|
-
return _regeneratorRuntime().wrap(function
|
|
1465
|
-
while (1) switch (
|
|
1491
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1492
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1466
1493
|
case 0:
|
|
1467
|
-
|
|
1468
|
-
|
|
1494
|
+
_context20.prev = 0;
|
|
1495
|
+
_context20.next = 3;
|
|
1469
1496
|
return this.dbManager.getAll('pay_method');
|
|
1470
1497
|
case 3:
|
|
1471
|
-
payMethods =
|
|
1472
|
-
return
|
|
1498
|
+
payMethods = _context20.sent;
|
|
1499
|
+
return _context20.abrupt("return", payMethods.find(function (method) {
|
|
1473
1500
|
return method.code === PaymentMethodType.Eftpos;
|
|
1474
1501
|
}) || null);
|
|
1475
1502
|
case 7:
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
console.error('[PaymentModule] 获取Eftpos支付方式失败',
|
|
1479
|
-
return
|
|
1503
|
+
_context20.prev = 7;
|
|
1504
|
+
_context20.t0 = _context20["catch"](0);
|
|
1505
|
+
console.error('[PaymentModule] 获取Eftpos支付方式失败', _context20.t0);
|
|
1506
|
+
return _context20.abrupt("return", null);
|
|
1480
1507
|
case 11:
|
|
1481
1508
|
case "end":
|
|
1482
|
-
return
|
|
1509
|
+
return _context20.stop();
|
|
1483
1510
|
}
|
|
1484
|
-
},
|
|
1511
|
+
}, _callee20, this, [[0, 7]]);
|
|
1485
1512
|
}));
|
|
1486
1513
|
function getEftposPaymentMethod() {
|
|
1487
1514
|
return _getEftposPaymentMethod.apply(this, arguments);
|
|
@@ -1495,29 +1522,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1495
1522
|
}, {
|
|
1496
1523
|
key: "getWalletPaymentMethod",
|
|
1497
1524
|
value: (function () {
|
|
1498
|
-
var _getWalletPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1525
|
+
var _getWalletPaymentMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
|
|
1499
1526
|
var payMethods;
|
|
1500
|
-
return _regeneratorRuntime().wrap(function
|
|
1501
|
-
while (1) switch (
|
|
1527
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1528
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1502
1529
|
case 0:
|
|
1503
|
-
|
|
1504
|
-
|
|
1530
|
+
_context21.prev = 0;
|
|
1531
|
+
_context21.next = 3;
|
|
1505
1532
|
return this.dbManager.getAll('pay_method');
|
|
1506
1533
|
case 3:
|
|
1507
|
-
payMethods =
|
|
1508
|
-
return
|
|
1534
|
+
payMethods = _context21.sent;
|
|
1535
|
+
return _context21.abrupt("return", payMethods.find(function (method) {
|
|
1509
1536
|
return method.code === PaymentMethodType.Wallet;
|
|
1510
1537
|
}) || null);
|
|
1511
1538
|
case 7:
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
console.error('[PaymentModule] 获取钱包支付方式失败',
|
|
1515
|
-
return
|
|
1539
|
+
_context21.prev = 7;
|
|
1540
|
+
_context21.t0 = _context21["catch"](0);
|
|
1541
|
+
console.error('[PaymentModule] 获取钱包支付方式失败', _context21.t0);
|
|
1542
|
+
return _context21.abrupt("return", null);
|
|
1516
1543
|
case 11:
|
|
1517
1544
|
case "end":
|
|
1518
|
-
return
|
|
1545
|
+
return _context21.stop();
|
|
1519
1546
|
}
|
|
1520
|
-
},
|
|
1547
|
+
}, _callee21, this, [[0, 7]]);
|
|
1521
1548
|
}));
|
|
1522
1549
|
function getWalletPaymentMethod() {
|
|
1523
1550
|
return _getWalletPaymentMethod.apply(this, arguments);
|
|
@@ -1551,38 +1578,38 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1551
1578
|
* 确保支付模块所需的数据库表已创建
|
|
1552
1579
|
*/
|
|
1553
1580
|
function () {
|
|
1554
|
-
var _ensurePaymentTables = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1555
|
-
return _regeneratorRuntime().wrap(function
|
|
1556
|
-
while (1) switch (
|
|
1581
|
+
var _ensurePaymentTables = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22() {
|
|
1582
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1583
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1557
1584
|
case 0:
|
|
1558
|
-
|
|
1559
|
-
|
|
1585
|
+
_context22.prev = 0;
|
|
1586
|
+
_context22.next = 3;
|
|
1560
1587
|
return this.dbManager.getAll('pay_method');
|
|
1561
1588
|
case 3:
|
|
1562
|
-
|
|
1589
|
+
_context22.next = 9;
|
|
1563
1590
|
break;
|
|
1564
1591
|
case 5:
|
|
1565
|
-
|
|
1566
|
-
|
|
1592
|
+
_context22.prev = 5;
|
|
1593
|
+
_context22.t0 = _context22["catch"](0);
|
|
1567
1594
|
console.warn('[PaymentModule] pay_method 表不存在,请在数据库配置中添加以下配置:');
|
|
1568
1595
|
console.warn('{ name: "pay_method", keyPath: "id" }');
|
|
1569
1596
|
case 9:
|
|
1570
|
-
|
|
1571
|
-
|
|
1597
|
+
_context22.prev = 9;
|
|
1598
|
+
_context22.next = 12;
|
|
1572
1599
|
return this.dbManager.getAll('order');
|
|
1573
1600
|
case 12:
|
|
1574
|
-
|
|
1601
|
+
_context22.next = 18;
|
|
1575
1602
|
break;
|
|
1576
1603
|
case 14:
|
|
1577
|
-
|
|
1578
|
-
|
|
1604
|
+
_context22.prev = 14;
|
|
1605
|
+
_context22.t1 = _context22["catch"](9);
|
|
1579
1606
|
console.warn('[PaymentModule] order 表不存在,请在数据库配置中添加以下配置:');
|
|
1580
1607
|
console.warn('{ name: "order", keyPath: "uuid" }');
|
|
1581
1608
|
case 18:
|
|
1582
1609
|
case "end":
|
|
1583
|
-
return
|
|
1610
|
+
return _context22.stop();
|
|
1584
1611
|
}
|
|
1585
|
-
},
|
|
1612
|
+
}, _callee22, this, [[0, 5], [9, 14]]);
|
|
1586
1613
|
}));
|
|
1587
1614
|
function ensurePaymentTables() {
|
|
1588
1615
|
return _ensurePaymentTables.apply(this, arguments);
|
|
@@ -1596,29 +1623,29 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1596
1623
|
}, {
|
|
1597
1624
|
key: "getPartiallyPaidOrdersAsync",
|
|
1598
1625
|
value: (function () {
|
|
1599
|
-
var _getPartiallyPaidOrdersAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1626
|
+
var _getPartiallyPaidOrdersAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
1600
1627
|
var allOrders;
|
|
1601
|
-
return _regeneratorRuntime().wrap(function
|
|
1602
|
-
while (1) switch (
|
|
1628
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
1629
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1603
1630
|
case 0:
|
|
1604
|
-
|
|
1605
|
-
|
|
1631
|
+
_context23.prev = 0;
|
|
1632
|
+
_context23.next = 3;
|
|
1606
1633
|
return this.dbManager.getAll('order');
|
|
1607
1634
|
case 3:
|
|
1608
|
-
allOrders =
|
|
1609
|
-
return
|
|
1635
|
+
allOrders = _context23.sent;
|
|
1636
|
+
return _context23.abrupt("return", allOrders.filter(function (order) {
|
|
1610
1637
|
return order.payment_status === PaymentStatus.PartiallyPaid;
|
|
1611
1638
|
}));
|
|
1612
1639
|
case 7:
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
console.error('[PaymentModule] 获取部分支付订单失败',
|
|
1616
|
-
return
|
|
1640
|
+
_context23.prev = 7;
|
|
1641
|
+
_context23.t0 = _context23["catch"](0);
|
|
1642
|
+
console.error('[PaymentModule] 获取部分支付订单失败', _context23.t0);
|
|
1643
|
+
return _context23.abrupt("return", []);
|
|
1617
1644
|
case 11:
|
|
1618
1645
|
case "end":
|
|
1619
|
-
return
|
|
1646
|
+
return _context23.stop();
|
|
1620
1647
|
}
|
|
1621
|
-
},
|
|
1648
|
+
}, _callee23, this, [[0, 7]]);
|
|
1622
1649
|
}));
|
|
1623
1650
|
function getPartiallyPaidOrdersAsync() {
|
|
1624
1651
|
return _getPartiallyPaidOrdersAsync.apply(this, arguments);
|
|
@@ -1632,32 +1659,32 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1632
1659
|
}, {
|
|
1633
1660
|
key: "getUnsyncedOrdersAsync",
|
|
1634
1661
|
value: (function () {
|
|
1635
|
-
var _getUnsyncedOrdersAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1662
|
+
var _getUnsyncedOrdersAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
1636
1663
|
var allOrders;
|
|
1637
|
-
return _regeneratorRuntime().wrap(function
|
|
1638
|
-
while (1) switch (
|
|
1664
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1665
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1639
1666
|
case 0:
|
|
1640
|
-
|
|
1641
|
-
|
|
1667
|
+
_context24.prev = 0;
|
|
1668
|
+
_context24.next = 3;
|
|
1642
1669
|
return this.dbManager.getAll('order');
|
|
1643
1670
|
case 3:
|
|
1644
|
-
allOrders =
|
|
1645
|
-
return
|
|
1671
|
+
allOrders = _context24.sent;
|
|
1672
|
+
return _context24.abrupt("return", allOrders.filter(function (order) {
|
|
1646
1673
|
// 订单已完成或部分支付,但支付项还未同步
|
|
1647
1674
|
return (order.payment_status === PaymentStatus.Finished || order.payment_status === PaymentStatus.PartiallyPaid) && order.payment.some(function (payment) {
|
|
1648
1675
|
return !payment.isSynced;
|
|
1649
1676
|
});
|
|
1650
1677
|
}));
|
|
1651
1678
|
case 7:
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
console.error('[PaymentModule] 获取未同步订单失败',
|
|
1655
|
-
return
|
|
1679
|
+
_context24.prev = 7;
|
|
1680
|
+
_context24.t0 = _context24["catch"](0);
|
|
1681
|
+
console.error('[PaymentModule] 获取未同步订单失败', _context24.t0);
|
|
1682
|
+
return _context24.abrupt("return", []);
|
|
1656
1683
|
case 11:
|
|
1657
1684
|
case "end":
|
|
1658
|
-
return
|
|
1685
|
+
return _context24.stop();
|
|
1659
1686
|
}
|
|
1660
|
-
},
|
|
1687
|
+
}, _callee24, this, [[0, 7]]);
|
|
1661
1688
|
}));
|
|
1662
1689
|
function getUnsyncedOrdersAsync() {
|
|
1663
1690
|
return _getUnsyncedOrdersAsync.apply(this, arguments);
|
|
@@ -1672,103 +1699,225 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1672
1699
|
}, {
|
|
1673
1700
|
key: "cleanupFinishedOrders",
|
|
1674
1701
|
value: (function () {
|
|
1675
|
-
var _cleanupFinishedOrders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1702
|
+
var _cleanupFinishedOrders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
|
|
1676
1703
|
var allOrders, finishedAndSyncedOrders, _iterator6, _step6, order;
|
|
1677
|
-
return _regeneratorRuntime().wrap(function
|
|
1678
|
-
while (1) switch (
|
|
1704
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1705
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1679
1706
|
case 0:
|
|
1680
|
-
|
|
1681
|
-
|
|
1707
|
+
_context25.prev = 0;
|
|
1708
|
+
_context25.next = 3;
|
|
1682
1709
|
return this.dbManager.getAll('order');
|
|
1683
1710
|
case 3:
|
|
1684
|
-
allOrders =
|
|
1711
|
+
allOrders = _context25.sent;
|
|
1685
1712
|
finishedAndSyncedOrders = allOrders.filter(function (order) {
|
|
1686
1713
|
return order.payment_status === PaymentStatus.Finished && order.payment.every(function (payment) {
|
|
1687
1714
|
return payment.isSynced;
|
|
1688
1715
|
});
|
|
1689
1716
|
});
|
|
1690
1717
|
_iterator6 = _createForOfIteratorHelper(finishedAndSyncedOrders);
|
|
1691
|
-
|
|
1718
|
+
_context25.prev = 6;
|
|
1692
1719
|
_iterator6.s();
|
|
1693
1720
|
case 8:
|
|
1694
1721
|
if ((_step6 = _iterator6.n()).done) {
|
|
1695
|
-
|
|
1722
|
+
_context25.next = 14;
|
|
1696
1723
|
break;
|
|
1697
1724
|
}
|
|
1698
1725
|
order = _step6.value;
|
|
1699
|
-
|
|
1726
|
+
_context25.next = 12;
|
|
1700
1727
|
return this.deleteOrderAsync(order.uuid);
|
|
1701
1728
|
case 12:
|
|
1702
|
-
|
|
1729
|
+
_context25.next = 8;
|
|
1703
1730
|
break;
|
|
1704
1731
|
case 14:
|
|
1705
|
-
|
|
1732
|
+
_context25.next = 19;
|
|
1706
1733
|
break;
|
|
1707
1734
|
case 16:
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
_iterator6.e(
|
|
1735
|
+
_context25.prev = 16;
|
|
1736
|
+
_context25.t0 = _context25["catch"](6);
|
|
1737
|
+
_iterator6.e(_context25.t0);
|
|
1711
1738
|
case 19:
|
|
1712
|
-
|
|
1739
|
+
_context25.prev = 19;
|
|
1713
1740
|
_iterator6.f();
|
|
1714
|
-
return
|
|
1741
|
+
return _context25.finish(19);
|
|
1715
1742
|
case 22:
|
|
1716
1743
|
console.log("[PaymentModule] \u6E05\u7406\u4E86 ".concat(finishedAndSyncedOrders.length, " \u4E2A\u5DF2\u5B8C\u6210\u4E14\u5DF2\u540C\u6B65\u7684\u8BA2\u5355"));
|
|
1717
|
-
|
|
1744
|
+
_context25.next = 28;
|
|
1718
1745
|
break;
|
|
1719
1746
|
case 25:
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
console.error('[PaymentModule] 清理已完成订单失败',
|
|
1747
|
+
_context25.prev = 25;
|
|
1748
|
+
_context25.t1 = _context25["catch"](0);
|
|
1749
|
+
console.error('[PaymentModule] 清理已完成订单失败', _context25.t1);
|
|
1723
1750
|
case 28:
|
|
1724
1751
|
case "end":
|
|
1725
|
-
return
|
|
1752
|
+
return _context25.stop();
|
|
1726
1753
|
}
|
|
1727
|
-
},
|
|
1754
|
+
}, _callee25, this, [[0, 25], [6, 16, 19, 22]]);
|
|
1728
1755
|
}));
|
|
1729
1756
|
function cleanupFinishedOrders() {
|
|
1730
1757
|
return _cleanupFinishedOrders.apply(this, arguments);
|
|
1731
1758
|
}
|
|
1732
1759
|
return cleanupFinishedOrders;
|
|
1733
1760
|
}()
|
|
1761
|
+
/**
|
|
1762
|
+
* 检测未同步的订单并重新加入任务队列
|
|
1763
|
+
*
|
|
1764
|
+
* 此方法专门用于处理因网络问题导致任务队列执行失败但队列被清空的情况。
|
|
1765
|
+
* 它会检查本地 IndexDB 中所有未同步的订单(isSynced: false),
|
|
1766
|
+
* 并将这些订单重新添加到任务队列中。
|
|
1767
|
+
*
|
|
1768
|
+
* 使用场景:
|
|
1769
|
+
* - 网络恢复后重新检查未同步的订单
|
|
1770
|
+
* - 应用启动时检查并重新排队未完成的支付
|
|
1771
|
+
* - 用户手动重试前的预检查
|
|
1772
|
+
*
|
|
1773
|
+
* @returns Promise<number> 返回重新加入队列的订单数量
|
|
1774
|
+
*/
|
|
1775
|
+
)
|
|
1776
|
+
}, {
|
|
1777
|
+
key: "recheckAndRequeueUnsyncedOrders",
|
|
1778
|
+
value: (function () {
|
|
1779
|
+
var _recheckAndRequeueUnsyncedOrders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26() {
|
|
1780
|
+
var unsyncedOrders, requeuedCount, _iterator7, _step7, order, success;
|
|
1781
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
1782
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
1783
|
+
case 0:
|
|
1784
|
+
this.logInfo('Starting recheckAndRequeueUnsyncedOrders');
|
|
1785
|
+
_context26.prev = 1;
|
|
1786
|
+
if (this.app.tasksManager) {
|
|
1787
|
+
_context26.next = 6;
|
|
1788
|
+
break;
|
|
1789
|
+
}
|
|
1790
|
+
console.warn('[PaymentModule] TasksManager 未初始化,无法重新排队未同步订单');
|
|
1791
|
+
this.logWarning('TasksManager not initialized, cannot requeue unsynced orders');
|
|
1792
|
+
return _context26.abrupt("return", 0);
|
|
1793
|
+
case 6:
|
|
1794
|
+
_context26.next = 8;
|
|
1795
|
+
return this.getUnsyncedOrdersAsync();
|
|
1796
|
+
case 8:
|
|
1797
|
+
unsyncedOrders = _context26.sent;
|
|
1798
|
+
if (!(unsyncedOrders.length === 0)) {
|
|
1799
|
+
_context26.next = 13;
|
|
1800
|
+
break;
|
|
1801
|
+
}
|
|
1802
|
+
console.log('[PaymentModule] 没有发现未同步的订单');
|
|
1803
|
+
this.logInfo('No unsynced orders found');
|
|
1804
|
+
return _context26.abrupt("return", 0);
|
|
1805
|
+
case 13:
|
|
1806
|
+
console.log("[PaymentModule] \u53D1\u73B0 ".concat(unsyncedOrders.length, " \u4E2A\u672A\u540C\u6B65\u7684\u8BA2\u5355\uFF0C\u5F00\u59CB\u91CD\u65B0\u52A0\u5165\u4EFB\u52A1\u961F\u5217"));
|
|
1807
|
+
this.logInfo('Found unsynced orders, adding to sync queue', {
|
|
1808
|
+
unsyncedCount: unsyncedOrders.length,
|
|
1809
|
+
orderUuids: unsyncedOrders.map(function (o) {
|
|
1810
|
+
return o.uuid;
|
|
1811
|
+
})
|
|
1812
|
+
});
|
|
1813
|
+
requeuedCount = 0; // 将未同步的订单重新添加到任务队列
|
|
1814
|
+
_iterator7 = _createForOfIteratorHelper(unsyncedOrders);
|
|
1815
|
+
_context26.prev = 17;
|
|
1816
|
+
_iterator7.s();
|
|
1817
|
+
case 19:
|
|
1818
|
+
if ((_step7 = _iterator7.n()).done) {
|
|
1819
|
+
_context26.next = 27;
|
|
1820
|
+
break;
|
|
1821
|
+
}
|
|
1822
|
+
order = _step7.value;
|
|
1823
|
+
_context26.next = 23;
|
|
1824
|
+
return this.reAddOrderToSyncQueue(order);
|
|
1825
|
+
case 23:
|
|
1826
|
+
success = _context26.sent;
|
|
1827
|
+
if (success) {
|
|
1828
|
+
requeuedCount++;
|
|
1829
|
+
}
|
|
1830
|
+
case 25:
|
|
1831
|
+
_context26.next = 19;
|
|
1832
|
+
break;
|
|
1833
|
+
case 27:
|
|
1834
|
+
_context26.next = 32;
|
|
1835
|
+
break;
|
|
1836
|
+
case 29:
|
|
1837
|
+
_context26.prev = 29;
|
|
1838
|
+
_context26.t0 = _context26["catch"](17);
|
|
1839
|
+
_iterator7.e(_context26.t0);
|
|
1840
|
+
case 32:
|
|
1841
|
+
_context26.prev = 32;
|
|
1842
|
+
_iterator7.f();
|
|
1843
|
+
return _context26.finish(32);
|
|
1844
|
+
case 35:
|
|
1845
|
+
console.log("[PaymentModule] \u6210\u529F\u91CD\u65B0\u52A0\u5165 ".concat(requeuedCount, " \u4E2A\u8BA2\u5355\u5230\u4EFB\u52A1\u961F\u5217"));
|
|
1846
|
+
this.logInfo('Successfully requeued unsynced orders', {
|
|
1847
|
+
requeuedCount: requeuedCount,
|
|
1848
|
+
totalFound: unsyncedOrders.length
|
|
1849
|
+
});
|
|
1850
|
+
return _context26.abrupt("return", requeuedCount);
|
|
1851
|
+
case 40:
|
|
1852
|
+
_context26.prev = 40;
|
|
1853
|
+
_context26.t1 = _context26["catch"](1);
|
|
1854
|
+
console.error('[PaymentModule] 重新排队未同步订单失败', _context26.t1);
|
|
1855
|
+
this.logError('recheckAndRequeueUnsyncedOrders failed', _context26.t1);
|
|
1856
|
+
return _context26.abrupt("return", 0);
|
|
1857
|
+
case 45:
|
|
1858
|
+
case "end":
|
|
1859
|
+
return _context26.stop();
|
|
1860
|
+
}
|
|
1861
|
+
}, _callee26, this, [[1, 40], [17, 29, 32, 35]]);
|
|
1862
|
+
}));
|
|
1863
|
+
function recheckAndRequeueUnsyncedOrders() {
|
|
1864
|
+
return _recheckAndRequeueUnsyncedOrders.apply(this, arguments);
|
|
1865
|
+
}
|
|
1866
|
+
return recheckAndRequeueUnsyncedOrders;
|
|
1867
|
+
}()
|
|
1734
1868
|
/**
|
|
1735
1869
|
* 手动执行支付同步队列
|
|
1736
1870
|
* 外部可以调用此方法来触发支付同步任务的执行
|
|
1871
|
+
*
|
|
1872
|
+
* 注意:此方法只执行现有队列中的任务,不会检查未同步的订单。
|
|
1873
|
+
* 如果需要检查未同步订单,请先调用 recheckAndRequeueUnsyncedOrders()
|
|
1874
|
+
*
|
|
1875
|
+
* 使用示例:
|
|
1876
|
+
* ```typescript
|
|
1877
|
+
* // 1. 先检查并重新排队未同步订单,然后执行队列
|
|
1878
|
+
* const requeuedCount = await paymentModule.recheckAndRequeueUnsyncedOrders();
|
|
1879
|
+
* if (requeuedCount > 0) {
|
|
1880
|
+
* await paymentModule.runPaymentSyncQueue();
|
|
1881
|
+
* }
|
|
1882
|
+
*
|
|
1883
|
+
* // 2. 或者直接执行现有队列(不检查未同步订单)
|
|
1884
|
+
* await paymentModule.runPaymentSyncQueue();
|
|
1885
|
+
* ```
|
|
1737
1886
|
*/
|
|
1738
1887
|
)
|
|
1739
1888
|
}, {
|
|
1740
1889
|
key: "runPaymentSyncQueue",
|
|
1741
1890
|
value: (function () {
|
|
1742
|
-
var _runPaymentSyncQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1891
|
+
var _runPaymentSyncQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27() {
|
|
1743
1892
|
var _this3 = this;
|
|
1744
|
-
var
|
|
1745
|
-
return _regeneratorRuntime().wrap(function
|
|
1746
|
-
while (1) switch (
|
|
1893
|
+
var queue;
|
|
1894
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
1895
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
1747
1896
|
case 0:
|
|
1748
1897
|
this.logInfo('Starting runPaymentSyncQueue');
|
|
1749
|
-
|
|
1898
|
+
_context27.prev = 1;
|
|
1750
1899
|
if (this.app.tasksManager) {
|
|
1751
|
-
|
|
1900
|
+
_context27.next = 6;
|
|
1752
1901
|
break;
|
|
1753
1902
|
}
|
|
1754
1903
|
console.warn('[PaymentModule] TasksManager 未初始化,无法执行同步队列');
|
|
1755
1904
|
this.logWarning('TasksManager not initialized, cannot run sync queue');
|
|
1756
|
-
return
|
|
1905
|
+
return _context27.abrupt("return");
|
|
1757
1906
|
case 6:
|
|
1758
1907
|
// 检查队列里有没有要跑的东西,没有就不 run 了
|
|
1759
1908
|
queue = this.app.tasksManager.getTaskQueue({
|
|
1760
1909
|
module: 'payment',
|
|
1761
1910
|
queueId: 'payment_sync'
|
|
1762
1911
|
});
|
|
1763
|
-
if (queue !== null && queue !== void 0 &&
|
|
1764
|
-
|
|
1912
|
+
if (queue !== null && queue !== void 0 && queue.length) {
|
|
1913
|
+
_context27.next = 10;
|
|
1765
1914
|
break;
|
|
1766
1915
|
}
|
|
1767
1916
|
console.log('[PaymentModule] 支付同步队列无内容,不执行');
|
|
1768
|
-
return
|
|
1917
|
+
return _context27.abrupt("return");
|
|
1769
1918
|
case 10:
|
|
1770
1919
|
console.log('[PaymentModule] 开始执行支付同步队列');
|
|
1771
|
-
|
|
1920
|
+
_context27.next = 13;
|
|
1772
1921
|
return this.app.tasksManager.run({
|
|
1773
1922
|
module: 'payment',
|
|
1774
1923
|
queueId: 'payment_sync',
|
|
@@ -1785,32 +1934,104 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1785
1934
|
});
|
|
1786
1935
|
case 13:
|
|
1787
1936
|
this.logInfo('runPaymentSyncQueue completed successfully');
|
|
1788
|
-
|
|
1937
|
+
_context27.next = 20;
|
|
1789
1938
|
break;
|
|
1790
1939
|
case 16:
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
console.error('[PaymentModule] 执行支付同步队列失败',
|
|
1794
|
-
this.logError('runPaymentSyncQueue failed',
|
|
1940
|
+
_context27.prev = 16;
|
|
1941
|
+
_context27.t0 = _context27["catch"](1);
|
|
1942
|
+
console.error('[PaymentModule] 执行支付同步队列失败', _context27.t0);
|
|
1943
|
+
this.logError('runPaymentSyncQueue failed', _context27.t0);
|
|
1795
1944
|
// 不抛出错误,避免影响主流程
|
|
1796
1945
|
case 20:
|
|
1797
1946
|
case "end":
|
|
1798
|
-
return
|
|
1947
|
+
return _context27.stop();
|
|
1799
1948
|
}
|
|
1800
|
-
},
|
|
1949
|
+
}, _callee27, this, [[1, 16]]);
|
|
1801
1950
|
}));
|
|
1802
1951
|
function runPaymentSyncQueue() {
|
|
1803
1952
|
return _runPaymentSyncQueue.apply(this, arguments);
|
|
1804
1953
|
}
|
|
1805
1954
|
return runPaymentSyncQueue;
|
|
1955
|
+
}()
|
|
1956
|
+
/**
|
|
1957
|
+
* 重新将订单添加到同步队列
|
|
1958
|
+
* 用于处理因网络问题导致任务队列清空但订单未同步的情况
|
|
1959
|
+
*
|
|
1960
|
+
* @param order 要重新添加的订单
|
|
1961
|
+
* @returns Promise<boolean> 是否成功添加到队列
|
|
1962
|
+
*/
|
|
1963
|
+
)
|
|
1964
|
+
}, {
|
|
1965
|
+
key: "reAddOrderToSyncQueue",
|
|
1966
|
+
value: (function () {
|
|
1967
|
+
var _reAddOrderToSyncQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(order) {
|
|
1968
|
+
var paymentData, existingQueue, taskId, taskExists;
|
|
1969
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
1970
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
1971
|
+
case 0:
|
|
1972
|
+
_context28.prev = 0;
|
|
1973
|
+
// 构造支付数据
|
|
1974
|
+
paymentData = {
|
|
1975
|
+
payments: order.payment.map(function (payment) {
|
|
1976
|
+
return payment;
|
|
1977
|
+
}),
|
|
1978
|
+
payment_status: order.payment_status === PaymentStatus.Finished ? 'paid' : 'partially_paid'
|
|
1979
|
+
}; // 检查是否已经在队列中,避免重复添加
|
|
1980
|
+
existingQueue = this.app.tasksManager.getTaskQueue({
|
|
1981
|
+
module: 'payment',
|
|
1982
|
+
queueId: 'payment_sync'
|
|
1983
|
+
});
|
|
1984
|
+
taskId = "payment_".concat(order.uuid);
|
|
1985
|
+
taskExists = existingQueue === null || existingQueue === void 0 ? void 0 : existingQueue.some(function (task) {
|
|
1986
|
+
return task.id === taskId;
|
|
1987
|
+
});
|
|
1988
|
+
if (!taskExists) {
|
|
1989
|
+
_context28.next = 8;
|
|
1990
|
+
break;
|
|
1991
|
+
}
|
|
1992
|
+
console.log("[PaymentModule] \u4EFB\u52A1 ".concat(taskId, " \u5DF2\u5B58\u5728\u4E8E\u961F\u5217\u4E2D\uFF0C\u8DF3\u8FC7\u91CD\u590D\u6DFB\u52A0"));
|
|
1993
|
+
return _context28.abrupt("return", false);
|
|
1994
|
+
case 8:
|
|
1995
|
+
_context28.next = 10;
|
|
1996
|
+
return this.addToSyncQueue(order, paymentData);
|
|
1997
|
+
case 10:
|
|
1998
|
+
console.log("[PaymentModule] \u8BA2\u5355 ".concat(order.uuid, " \u5DF2\u91CD\u65B0\u6DFB\u52A0\u5230\u540C\u6B65\u961F\u5217"));
|
|
1999
|
+
this.logInfo('Order re-added to sync queue', {
|
|
2000
|
+
orderUuid: order.uuid,
|
|
2001
|
+
orderId: order.order_info.order_id,
|
|
2002
|
+
paymentStatus: order.payment_status,
|
|
2003
|
+
unsyncedPayments: order.payment.filter(function (p) {
|
|
2004
|
+
return !p.isSynced;
|
|
2005
|
+
}).length
|
|
2006
|
+
});
|
|
2007
|
+
return _context28.abrupt("return", true);
|
|
2008
|
+
case 15:
|
|
2009
|
+
_context28.prev = 15;
|
|
2010
|
+
_context28.t0 = _context28["catch"](0);
|
|
2011
|
+
console.error("[PaymentModule] \u91CD\u65B0\u6DFB\u52A0\u8BA2\u5355 ".concat(order.uuid, " \u5230\u540C\u6B65\u961F\u5217\u5931\u8D25"), _context28.t0);
|
|
2012
|
+
this.logError('Failed to re-add order to sync queue', _context28.t0, {
|
|
2013
|
+
orderUuid: order.uuid,
|
|
2014
|
+
orderId: order.order_info.order_id
|
|
2015
|
+
});
|
|
2016
|
+
return _context28.abrupt("return", false);
|
|
2017
|
+
case 20:
|
|
2018
|
+
case "end":
|
|
2019
|
+
return _context28.stop();
|
|
2020
|
+
}
|
|
2021
|
+
}, _callee28, this, [[0, 15]]);
|
|
2022
|
+
}));
|
|
2023
|
+
function reAddOrderToSyncQueue(_x25) {
|
|
2024
|
+
return _reAddOrderToSyncQueue.apply(this, arguments);
|
|
2025
|
+
}
|
|
2026
|
+
return reAddOrderToSyncQueue;
|
|
1806
2027
|
}())
|
|
1807
2028
|
}], [{
|
|
1808
2029
|
key: "syncPaymentTask",
|
|
1809
2030
|
value: (function () {
|
|
1810
|
-
var _syncPaymentTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2031
|
+
var _syncPaymentTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(payload) {
|
|
1811
2032
|
var _payload$task$payload, orderUuid, orderId, paymentData, core, app, logger, request, dbManager, requestRes, order, businessError, _error$message, _error$message2, _error$message3, isNetworkError, _error$response3, _error$response, errorData, _error$response2, _order2;
|
|
1812
|
-
return _regeneratorRuntime().wrap(function
|
|
1813
|
-
while (1) switch (
|
|
2033
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2034
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
1814
2035
|
case 0:
|
|
1815
2036
|
_payload$task$payload = payload.task.payload, orderUuid = _payload$task$payload.orderUuid, orderId = _payload$task$payload.orderId, paymentData = _payload$task$payload.paymentData, core = _payload$task$payload.core;
|
|
1816
2037
|
console.log("[PaymentModule] \u5F00\u59CB\u540E\u53F0\u540C\u6B65\u652F\u4ED8\uFF0C\u8BA2\u5355ID: ".concat(orderId));
|
|
@@ -1833,42 +2054,42 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1833
2054
|
});
|
|
1834
2055
|
}
|
|
1835
2056
|
if (app) {
|
|
1836
|
-
|
|
2057
|
+
_context29.next = 8;
|
|
1837
2058
|
break;
|
|
1838
2059
|
}
|
|
1839
2060
|
throw new Error('App 实例未找到');
|
|
1840
2061
|
case 8:
|
|
1841
2062
|
request = app.request;
|
|
1842
2063
|
if (request) {
|
|
1843
|
-
|
|
2064
|
+
_context29.next = 11;
|
|
1844
2065
|
break;
|
|
1845
2066
|
}
|
|
1846
2067
|
throw new Error('Request 插件未找到');
|
|
1847
2068
|
case 11:
|
|
1848
2069
|
dbManager = app.dbManager;
|
|
1849
2070
|
if (dbManager) {
|
|
1850
|
-
|
|
2071
|
+
_context29.next = 14;
|
|
1851
2072
|
break;
|
|
1852
2073
|
}
|
|
1853
2074
|
throw new Error('DBManager 未找到');
|
|
1854
2075
|
case 14:
|
|
1855
|
-
|
|
1856
|
-
|
|
2076
|
+
_context29.prev = 14;
|
|
2077
|
+
_context29.next = 17;
|
|
1857
2078
|
return request.post("/shop/order/".concat(orderId, "/order-payment"), paymentData, {
|
|
1858
2079
|
noToast: true
|
|
1859
2080
|
});
|
|
1860
2081
|
case 17:
|
|
1861
|
-
requestRes =
|
|
2082
|
+
requestRes = _context29.sent;
|
|
1862
2083
|
if (!(requestRes.status === true)) {
|
|
1863
|
-
|
|
2084
|
+
_context29.next = 35;
|
|
1864
2085
|
break;
|
|
1865
2086
|
}
|
|
1866
|
-
|
|
2087
|
+
_context29.next = 21;
|
|
1867
2088
|
return dbManager.get('order', orderUuid);
|
|
1868
2089
|
case 21:
|
|
1869
|
-
order =
|
|
2090
|
+
order = _context29.sent;
|
|
1870
2091
|
if (!order) {
|
|
1871
|
-
|
|
2092
|
+
_context29.next = 27;
|
|
1872
2093
|
break;
|
|
1873
2094
|
}
|
|
1874
2095
|
order.payment.forEach(function (payment) {
|
|
@@ -1876,13 +2097,13 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1876
2097
|
// 清除之前的错误状态
|
|
1877
2098
|
delete payment.syncError;
|
|
1878
2099
|
});
|
|
1879
|
-
|
|
2100
|
+
_context29.next = 26;
|
|
1880
2101
|
return dbManager.update('order', order);
|
|
1881
2102
|
case 26:
|
|
1882
2103
|
console.log("[PaymentModule] \u8BA2\u5355 ".concat(orderUuid, " \u540C\u6B65\u72B6\u6001\u5DF2\u66F4\u65B0"));
|
|
1883
2104
|
case 27:
|
|
1884
2105
|
console.log("[PaymentModule] \u8BA2\u5355 ".concat(orderUuid, " \u540E\u53F0\u540C\u6B65\u6210\u529F"));
|
|
1885
|
-
|
|
2106
|
+
_context29.next = 30;
|
|
1886
2107
|
return core.effects.emit('payment:onPaymentSyncSuccess', {
|
|
1887
2108
|
orderUuid: orderUuid,
|
|
1888
2109
|
orderId: orderId,
|
|
@@ -1902,7 +2123,7 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1902
2123
|
}
|
|
1903
2124
|
});
|
|
1904
2125
|
}
|
|
1905
|
-
return
|
|
2126
|
+
return _context29.abrupt("return", {
|
|
1906
2127
|
status: 'success',
|
|
1907
2128
|
orderUuid: orderUuid,
|
|
1908
2129
|
orderId: orderId
|
|
@@ -1920,17 +2141,17 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1920
2141
|
businessError.responseData = requestRes;
|
|
1921
2142
|
throw businessError;
|
|
1922
2143
|
case 41:
|
|
1923
|
-
|
|
2144
|
+
_context29.next = 80;
|
|
1924
2145
|
break;
|
|
1925
2146
|
case 43:
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
console.error('[PaymentModule] 后台同步失败:',
|
|
2147
|
+
_context29.prev = 43;
|
|
2148
|
+
_context29.t0 = _context29["catch"](14);
|
|
2149
|
+
console.error('[PaymentModule] 后台同步失败:', _context29.t0);
|
|
1929
2150
|
|
|
1930
2151
|
// 检查是否是网络错误(没有响应码)还是业务错误(有响应码)
|
|
1931
|
-
isNetworkError = !
|
|
2152
|
+
isNetworkError = !_context29.t0.response && !_context29.t0.status && (_context29.t0.code === 'NETWORK_ERROR' || _context29.t0.code === 'ERR_NETWORK' || _context29.t0.code === 'ECONNREFUSED' || _context29.t0.code === 'ENOTFOUND' || _context29.t0.code === 'ETIMEDOUT' || ((_error$message = _context29.t0.message) === null || _error$message === void 0 ? void 0 : _error$message.includes('网络')) || ((_error$message2 = _context29.t0.message) === null || _error$message2 === void 0 ? void 0 : _error$message2.includes('network')) || ((_error$message3 = _context29.t0.message) === null || _error$message3 === void 0 ? void 0 : _error$message3.includes('fetch')));
|
|
1932
2153
|
if (!isNetworkError) {
|
|
1933
|
-
|
|
2154
|
+
_context29.next = 53;
|
|
1934
2155
|
break;
|
|
1935
2156
|
}
|
|
1936
2157
|
// 网络错误:重试
|
|
@@ -1944,39 +2165,39 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1944
2165
|
metadata: {
|
|
1945
2166
|
orderUuid: orderUuid,
|
|
1946
2167
|
orderId: orderId,
|
|
1947
|
-
errorCode:
|
|
1948
|
-
errorMessage:
|
|
2168
|
+
errorCode: _context29.t0.code,
|
|
2169
|
+
errorMessage: _context29.t0.message
|
|
1949
2170
|
}
|
|
1950
2171
|
});
|
|
1951
2172
|
}
|
|
1952
|
-
throw
|
|
2173
|
+
throw _context29.t0;
|
|
1953
2174
|
case 53:
|
|
1954
2175
|
// 业务错误(有响应码):不标记为已同步,通过 effects 通知前端,但不重试
|
|
1955
2176
|
console.log("[PaymentModule] \u4E1A\u52A1\u9519\u8BEF\uFF0C\u8BA2\u5355 ".concat(orderUuid, " \u540C\u6B65\u5931\u8D25\uFF0C\u901A\u77E5\u524D\u7AEF"));
|
|
1956
|
-
|
|
2177
|
+
_context29.prev = 54;
|
|
1957
2178
|
if (!(core && core.effects)) {
|
|
1958
|
-
|
|
2179
|
+
_context29.next = 63;
|
|
1959
2180
|
break;
|
|
1960
2181
|
}
|
|
1961
2182
|
// 通过 effects 通知前端同步错误
|
|
1962
2183
|
errorData = {
|
|
1963
2184
|
orderUuid: orderUuid,
|
|
1964
2185
|
orderId: orderId,
|
|
1965
|
-
error:
|
|
1966
|
-
errorCode:
|
|
1967
|
-
statusCode: ((_error$response =
|
|
2186
|
+
error: _context29.t0.message || '业务错误',
|
|
2187
|
+
errorCode: _context29.t0.code,
|
|
2188
|
+
statusCode: ((_error$response = _context29.t0.response) === null || _error$response === void 0 ? void 0 : _error$response.status) || _context29.t0.status,
|
|
1968
2189
|
timestamp: Date.now()
|
|
1969
2190
|
}; // 如果是业务错误,添加响应数据
|
|
1970
|
-
if (
|
|
1971
|
-
errorData.error =
|
|
2191
|
+
if (_context29.t0.isBusinessError && _context29.t0.responseData) {
|
|
2192
|
+
errorData.error = _context29.t0.responseData.message || _context29.t0.message || '接口返回失败';
|
|
1972
2193
|
// 可以添加更多响应数据
|
|
1973
|
-
errorData.responseData =
|
|
2194
|
+
errorData.responseData = _context29.t0.responseData;
|
|
1974
2195
|
}
|
|
1975
|
-
|
|
2196
|
+
_context29.next = 60;
|
|
1976
2197
|
return core.effects.emit('payment:onPaymentSyncError', errorData);
|
|
1977
2198
|
case 60:
|
|
1978
2199
|
console.log("[PaymentModule] \u5DF2\u901A\u8FC7 effects \u901A\u77E5\u524D\u7AEF\u8BA2\u5355 ".concat(orderUuid, " \u540C\u6B65\u9519\u8BEF"));
|
|
1979
|
-
|
|
2200
|
+
_context29.next = 64;
|
|
1980
2201
|
break;
|
|
1981
2202
|
case 63:
|
|
1982
2203
|
console.warn("[PaymentModule] \u65E0\u6CD5\u83B7\u53D6 core \u5B9E\u4F8B\uFF0C\u65E0\u6CD5\u901A\u77E5\u524D\u7AEF\u9519\u8BEF");
|
|
@@ -1989,19 +2210,19 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1989
2210
|
metadata: {
|
|
1990
2211
|
orderUuid: orderUuid,
|
|
1991
2212
|
orderId: orderId,
|
|
1992
|
-
errorCode:
|
|
1993
|
-
errorMessage:
|
|
1994
|
-
statusCode: ((_error$response2 =
|
|
1995
|
-
isBusinessError:
|
|
2213
|
+
errorCode: _context29.t0.code,
|
|
2214
|
+
errorMessage: _context29.t0.message,
|
|
2215
|
+
statusCode: ((_error$response2 = _context29.t0.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.status) || _context29.t0.status,
|
|
2216
|
+
isBusinessError: _context29.t0.isBusinessError
|
|
1996
2217
|
}
|
|
1997
2218
|
});
|
|
1998
2219
|
}
|
|
1999
|
-
|
|
2220
|
+
_context29.next = 71;
|
|
2000
2221
|
break;
|
|
2001
2222
|
case 67:
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
console.error("[PaymentModule] \u901A\u77E5\u524D\u7AEF\u540C\u6B65\u9519\u8BEF\u5931\u8D25:",
|
|
2223
|
+
_context29.prev = 67;
|
|
2224
|
+
_context29.t1 = _context29["catch"](54);
|
|
2225
|
+
console.error("[PaymentModule] \u901A\u77E5\u524D\u7AEF\u540C\u6B65\u9519\u8BEF\u5931\u8D25:", _context29.t1);
|
|
2005
2226
|
|
|
2006
2227
|
// 记录通知错误日志
|
|
2007
2228
|
if (logger) {
|
|
@@ -2011,41 +2232,41 @@ export var PaymentModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2011
2232
|
metadata: {
|
|
2012
2233
|
orderUuid: orderUuid,
|
|
2013
2234
|
orderId: orderId,
|
|
2014
|
-
notifyError:
|
|
2235
|
+
notifyError: _context29.t1 instanceof Error ? _context29.t1.message : String(_context29.t1)
|
|
2015
2236
|
}
|
|
2016
2237
|
});
|
|
2017
2238
|
}
|
|
2018
2239
|
case 71:
|
|
2019
|
-
|
|
2240
|
+
_context29.next = 73;
|
|
2020
2241
|
return dbManager.get('order', orderUuid);
|
|
2021
2242
|
case 73:
|
|
2022
|
-
_order2 =
|
|
2243
|
+
_order2 = _context29.sent;
|
|
2023
2244
|
if (!_order2) {
|
|
2024
|
-
|
|
2245
|
+
_context29.next = 79;
|
|
2025
2246
|
break;
|
|
2026
2247
|
}
|
|
2027
2248
|
_order2.payment.forEach(function (payment) {
|
|
2028
2249
|
payment.isSynced = true;
|
|
2029
2250
|
});
|
|
2030
|
-
|
|
2251
|
+
_context29.next = 78;
|
|
2031
2252
|
return dbManager.update('order', _order2);
|
|
2032
2253
|
case 78:
|
|
2033
2254
|
console.log("[PaymentModule] \u8BA2\u5355 ".concat(orderUuid, " \u4E1A\u52A1\u9519\u8BEF\uFF0C\u5DF2\u6807\u8BB0\u4E3A\u5DF2\u540C\u6B65"));
|
|
2034
2255
|
case 79:
|
|
2035
|
-
return
|
|
2256
|
+
return _context29.abrupt("return", {
|
|
2036
2257
|
status: 'completed_with_error',
|
|
2037
2258
|
orderUuid: orderUuid,
|
|
2038
2259
|
orderId: orderId,
|
|
2039
|
-
error:
|
|
2040
|
-
statusCode: ((_error$response3 =
|
|
2260
|
+
error: _context29.t0.message || '业务错误',
|
|
2261
|
+
statusCode: ((_error$response3 = _context29.t0.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.status) || _context29.t0.status
|
|
2041
2262
|
});
|
|
2042
2263
|
case 80:
|
|
2043
2264
|
case "end":
|
|
2044
|
-
return
|
|
2265
|
+
return _context29.stop();
|
|
2045
2266
|
}
|
|
2046
|
-
},
|
|
2267
|
+
}, _callee29, null, [[14, 43], [54, 67]]);
|
|
2047
2268
|
}));
|
|
2048
|
-
function syncPaymentTask(
|
|
2269
|
+
function syncPaymentTask(_x26) {
|
|
2049
2270
|
return _syncPaymentTask.apply(this, arguments);
|
|
2050
2271
|
}
|
|
2051
2272
|
return syncPaymentTask;
|