@pisell/pisellos 0.0.234 → 0.0.236
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/Order/index.d.ts +1 -1
- package/dist/modules/Payment/index.d.ts +3 -3
- package/dist/modules/Payment/index.js +74 -10
- package/dist/modules/Payment/types.d.ts +24 -3
- package/dist/modules/Payment/types.js +9 -1
- package/dist/modules/Payment/utils.js +1 -1
- package/dist/modules/Payment/walletpass.d.ts +5 -2
- package/dist/modules/Payment/walletpass.js +63 -11
- package/dist/solution/BookingTicket/index.d.ts +8 -0
- package/dist/solution/BookingTicket/index.js +27 -3
- package/dist/solution/BookingTicket/utils/scan/handleScan.d.ts +6 -0
- package/dist/solution/BookingTicket/utils/scan/handleScan.js +43 -28
- package/dist/solution/Checkout/index.d.ts +73 -8
- package/dist/solution/Checkout/index.js +1540 -926
- package/dist/solution/Checkout/types.d.ts +79 -3
- package/dist/solution/Checkout/types.js +6 -0
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Payment/index.d.ts +3 -3
- package/lib/modules/Payment/index.js +30 -5
- package/lib/modules/Payment/types.d.ts +24 -3
- package/lib/modules/Payment/types.js +1 -1
- package/lib/modules/Payment/utils.js +1 -1
- package/lib/modules/Payment/walletpass.d.ts +5 -2
- package/lib/modules/Payment/walletpass.js +30 -2
- package/lib/solution/BookingTicket/index.d.ts +8 -0
- package/lib/solution/BookingTicket/index.js +23 -2
- package/lib/solution/BookingTicket/utils/scan/handleScan.d.ts +6 -0
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +21 -14
- package/lib/solution/Checkout/index.d.ts +73 -8
- package/lib/solution/Checkout/index.js +582 -200
- package/lib/solution/Checkout/types.d.ts +79 -3
- package/lib/solution/Checkout/types.js +2 -0
- package/package.json +1 -1
|
@@ -28,13 +28,13 @@ import { BaseModule } from "../../modules/BaseModule";
|
|
|
28
28
|
import { OrderModule } from "../../modules/Order";
|
|
29
29
|
import { PaymentModule } from "../../modules/Payment";
|
|
30
30
|
import { CheckoutStatus, CheckoutStep, CheckoutHooks, CheckoutErrorType } from "./types";
|
|
31
|
-
import { PaymentStatus, PaymentMethodType } from "../../modules/Payment/types";
|
|
31
|
+
import { PaymentStatus, PaymentHooks, PaymentMethodType } from "../../modules/Payment/types";
|
|
32
32
|
import { validateCheckoutData, createCheckoutError, calculateProgress } from "./utils";
|
|
33
33
|
export * from "./types";
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* 结账解决方案实现
|
|
37
|
-
*
|
|
37
|
+
*
|
|
38
38
|
* 整合订单处理和支付功能,提供完整的结账流程管理。
|
|
39
39
|
* 支持多种支付方式,提供实时状态跟踪和错误处理。
|
|
40
40
|
*/
|
|
@@ -211,6 +211,47 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
211
211
|
return _ref2.apply(this, arguments);
|
|
212
212
|
};
|
|
213
213
|
}());
|
|
214
|
+
|
|
215
|
+
// 监听支付方式加载完成事件
|
|
216
|
+
this.core.effects.on(PaymentHooks.OnPaymentMethodsLoaded, /*#__PURE__*/function () {
|
|
217
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(methods) {
|
|
218
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
219
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
220
|
+
case 0:
|
|
221
|
+
console.log('[Checkout] 收到支付方式加载完成事件:', methods.length);
|
|
222
|
+
_this2.store.paymentMethods = methods;
|
|
223
|
+
case 2:
|
|
224
|
+
case "end":
|
|
225
|
+
return _context5.stop();
|
|
226
|
+
}
|
|
227
|
+
}, _callee5);
|
|
228
|
+
}));
|
|
229
|
+
return function (_x7) {
|
|
230
|
+
return _ref3.apply(this, arguments);
|
|
231
|
+
};
|
|
232
|
+
}());
|
|
233
|
+
|
|
234
|
+
// 监听支付方式变更事件
|
|
235
|
+
this.core.effects.on(PaymentHooks.OnPaymentMethodsChanged, /*#__PURE__*/function () {
|
|
236
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(data) {
|
|
237
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
238
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
239
|
+
case 0:
|
|
240
|
+
console.log('[Checkout] 收到支付方式变更事件:', {
|
|
241
|
+
oldCount: data.oldMethods.length,
|
|
242
|
+
newCount: data.newMethods.length
|
|
243
|
+
});
|
|
244
|
+
_this2.store.paymentMethods = data.newMethods;
|
|
245
|
+
case 2:
|
|
246
|
+
case "end":
|
|
247
|
+
return _context6.stop();
|
|
248
|
+
}
|
|
249
|
+
}, _callee6);
|
|
250
|
+
}));
|
|
251
|
+
return function (_x8) {
|
|
252
|
+
return _ref4.apply(this, arguments);
|
|
253
|
+
};
|
|
254
|
+
}());
|
|
214
255
|
}
|
|
215
256
|
|
|
216
257
|
/**
|
|
@@ -219,21 +260,21 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
219
260
|
}, {
|
|
220
261
|
key: "initializeCheckoutAsync",
|
|
221
262
|
value: (function () {
|
|
222
|
-
var _initializeCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
263
|
+
var _initializeCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(params) {
|
|
223
264
|
var validation;
|
|
224
|
-
return _regeneratorRuntime().wrap(function
|
|
225
|
-
while (1) switch (
|
|
265
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
266
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
226
267
|
case 0:
|
|
227
|
-
|
|
228
|
-
|
|
268
|
+
_context7.prev = 0;
|
|
269
|
+
_context7.next = 3;
|
|
229
270
|
return this.setStatus(CheckoutStatus.Initializing);
|
|
230
271
|
case 3:
|
|
231
|
-
|
|
272
|
+
_context7.next = 5;
|
|
232
273
|
return this.validateCheckoutParams(params);
|
|
233
274
|
case 5:
|
|
234
|
-
validation =
|
|
275
|
+
validation = _context7.sent;
|
|
235
276
|
if (validation.valid) {
|
|
236
|
-
|
|
277
|
+
_context7.next = 8;
|
|
237
278
|
break;
|
|
238
279
|
}
|
|
239
280
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u53C2\u6570\u9A8C\u8BC1\u5931\u8D25: ".concat(validation.errors.join(', ')));
|
|
@@ -242,29 +283,29 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
242
283
|
this.store.cartItems = params.cartItems;
|
|
243
284
|
|
|
244
285
|
// 设置为就绪状态
|
|
245
|
-
|
|
286
|
+
_context7.next = 11;
|
|
246
287
|
return this.setStatus(CheckoutStatus.Ready);
|
|
247
288
|
case 11:
|
|
248
|
-
|
|
289
|
+
_context7.next = 13;
|
|
249
290
|
return this.setStep(CheckoutStep.OrderConfirmation);
|
|
250
291
|
case 13:
|
|
251
292
|
console.log('[Checkout] 结账流程初始化完成');
|
|
252
|
-
|
|
293
|
+
_context7.next = 21;
|
|
253
294
|
break;
|
|
254
295
|
case 16:
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
return this.handleError(
|
|
296
|
+
_context7.prev = 16;
|
|
297
|
+
_context7.t0 = _context7["catch"](0);
|
|
298
|
+
_context7.next = 20;
|
|
299
|
+
return this.handleError(_context7.t0, CheckoutErrorType.UnknownError);
|
|
259
300
|
case 20:
|
|
260
|
-
throw
|
|
301
|
+
throw _context7.t0;
|
|
261
302
|
case 21:
|
|
262
303
|
case "end":
|
|
263
|
-
return
|
|
304
|
+
return _context7.stop();
|
|
264
305
|
}
|
|
265
|
-
},
|
|
306
|
+
}, _callee7, this, [[0, 16]]);
|
|
266
307
|
}));
|
|
267
|
-
function initializeCheckoutAsync(
|
|
308
|
+
function initializeCheckoutAsync(_x9) {
|
|
268
309
|
return _initializeCheckoutAsync.apply(this, arguments);
|
|
269
310
|
}
|
|
270
311
|
return initializeCheckoutAsync;
|
|
@@ -294,18 +335,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
294
335
|
}, {
|
|
295
336
|
key: "initWalletData",
|
|
296
337
|
value: function () {
|
|
297
|
-
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
338
|
+
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
|
|
298
339
|
var _this$store$currentOr2, _this$store$currentCu;
|
|
299
340
|
var amountInfo, walletBusinessData;
|
|
300
|
-
return _regeneratorRuntime().wrap(function
|
|
301
|
-
while (1) switch (
|
|
341
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
342
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
302
343
|
case 0:
|
|
303
344
|
amountInfo = (_this$store$currentOr2 = this.store.currentOrder) === null || _this$store$currentOr2 === void 0 || (_this$store$currentOr2 = _this$store$currentOr2.order_info) === null || _this$store$currentOr2 === void 0 ? void 0 : _this$store$currentOr2.amount_breakdown;
|
|
304
345
|
if (amountInfo) {
|
|
305
|
-
|
|
346
|
+
_context8.next = 3;
|
|
306
347
|
break;
|
|
307
348
|
}
|
|
308
|
-
return
|
|
349
|
+
return _context8.abrupt("return");
|
|
309
350
|
case 3:
|
|
310
351
|
// 准备钱包初始化的业务数据
|
|
311
352
|
walletBusinessData = _objectSpread({
|
|
@@ -316,22 +357,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
316
357
|
},
|
|
317
358
|
products: this.getProductListByOrder()
|
|
318
359
|
}, params);
|
|
319
|
-
|
|
360
|
+
_context8.next = 6;
|
|
320
361
|
return this.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
|
|
321
362
|
case 6:
|
|
322
363
|
case "end":
|
|
323
|
-
return
|
|
364
|
+
return _context8.stop();
|
|
324
365
|
}
|
|
325
|
-
},
|
|
366
|
+
}, _callee8, this);
|
|
326
367
|
}));
|
|
327
|
-
function initWalletData(
|
|
368
|
+
function initWalletData(_x10) {
|
|
328
369
|
return _initWalletData.apply(this, arguments);
|
|
329
370
|
}
|
|
330
371
|
return initWalletData;
|
|
331
372
|
}()
|
|
332
373
|
/**
|
|
333
374
|
* 创建本地订单 (前端模拟下单流程)
|
|
334
|
-
*
|
|
375
|
+
*
|
|
335
376
|
* 此方法用于在前端模拟整个下单流程,创建一个本地的虚拟订单。
|
|
336
377
|
* 用户在购物车点击下单时,会把购物车参数传递给此方法,
|
|
337
378
|
* 方法会记录参数并创建本地虚拟订单,然后用 Payment 模块管理支付流程。
|
|
@@ -339,28 +380,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
339
380
|
}, {
|
|
340
381
|
key: "createLocalOrderAsync",
|
|
341
382
|
value: (function () {
|
|
342
|
-
var _createLocalOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
383
|
+
var _createLocalOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
|
|
343
384
|
var _params$totalInfo, _params$totalInfo2, validation, localOrderId, amountInfo, customerInfo, paymentOrder;
|
|
344
|
-
return _regeneratorRuntime().wrap(function
|
|
345
|
-
while (1) switch (
|
|
385
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
386
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
346
387
|
case 0:
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
return this.
|
|
388
|
+
_context9.prev = 0;
|
|
389
|
+
_context9.next = 3;
|
|
390
|
+
return this.resetStoreStateAsync();
|
|
350
391
|
case 3:
|
|
351
|
-
|
|
352
|
-
return this.
|
|
392
|
+
_context9.next = 5;
|
|
393
|
+
return this.setStatus(CheckoutStatus.CreatingOrder);
|
|
353
394
|
case 5:
|
|
354
|
-
|
|
395
|
+
_context9.next = 7;
|
|
396
|
+
return this.validateLocalOrderData(params.orderData);
|
|
397
|
+
case 7:
|
|
398
|
+
validation = _context9.sent;
|
|
355
399
|
if (validation.valid) {
|
|
356
|
-
|
|
400
|
+
_context9.next = 10;
|
|
357
401
|
break;
|
|
358
402
|
}
|
|
359
403
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u8BA2\u5355\u6570\u636E\u9A8C\u8BC1\u5931\u8D25: ".concat(validation.errors.join(', ')));
|
|
360
|
-
case
|
|
404
|
+
case 10:
|
|
361
405
|
// 生成本地虚拟订单ID (后续可以被真实订单ID替换)
|
|
362
406
|
localOrderId = this.generateLocalOrderId(); // 从购物车小计数据中提取金额信息
|
|
363
|
-
amountInfo = this.extractAmountFromCartSummary(params.cartSummary); // TODO: 外面传的是 pos ,但是现在 后端只有 shop 和 kiosk
|
|
407
|
+
amountInfo = this.extractAmountFromCartSummary(params.cartSummary); // TODO: 外面传的是 pos ,但是现在 后端只有 shop 和 kiosk
|
|
364
408
|
params.orderData.platform = 'pos';
|
|
365
409
|
// 补充 created_at 时间 (YYYY-MM-DD hh:mm:ss 格式)
|
|
366
410
|
params.orderData.created_at = this.formatDateTime(new Date());
|
|
@@ -387,7 +431,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
387
431
|
}
|
|
388
432
|
|
|
389
433
|
// 创建支付订单对象
|
|
390
|
-
|
|
434
|
+
_context9.next = 22;
|
|
391
435
|
return this.payment.createPaymentOrderAsync({
|
|
392
436
|
order_id: localOrderId,
|
|
393
437
|
total_amount: amountInfo.totalAmount,
|
|
@@ -404,34 +448,34 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
404
448
|
amount_breakdown: amountInfo
|
|
405
449
|
}
|
|
406
450
|
});
|
|
407
|
-
case
|
|
408
|
-
paymentOrder =
|
|
451
|
+
case 22:
|
|
452
|
+
paymentOrder = _context9.sent;
|
|
409
453
|
this.store.currentOrder = paymentOrder;
|
|
410
|
-
|
|
454
|
+
_context9.next = 26;
|
|
411
455
|
return this.initWalletData();
|
|
412
|
-
case 24:
|
|
413
|
-
_context7.next = 26;
|
|
414
|
-
return this.setStatus(CheckoutStatus.OrderCreated);
|
|
415
456
|
case 26:
|
|
416
|
-
|
|
417
|
-
return this.
|
|
457
|
+
_context9.next = 28;
|
|
458
|
+
return this.setStatus(CheckoutStatus.OrderCreated);
|
|
418
459
|
case 28:
|
|
460
|
+
_context9.next = 30;
|
|
461
|
+
return this.setStep(CheckoutStep.PaymentMethod);
|
|
462
|
+
case 30:
|
|
419
463
|
if (!params.autoPayment) {
|
|
420
|
-
|
|
464
|
+
_context9.next = 33;
|
|
421
465
|
break;
|
|
422
466
|
}
|
|
423
|
-
|
|
467
|
+
_context9.next = 33;
|
|
424
468
|
return this.setStep(CheckoutStep.PaymentProcessing);
|
|
425
|
-
case
|
|
426
|
-
|
|
469
|
+
case 33:
|
|
470
|
+
_context9.next = 35;
|
|
427
471
|
return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
|
|
428
472
|
order: paymentOrder,
|
|
429
473
|
timestamp: Date.now()
|
|
430
474
|
});
|
|
431
|
-
case 33:
|
|
432
|
-
_context7.next = 35;
|
|
433
|
-
return this.updateStateAmountToRemaining();
|
|
434
475
|
case 35:
|
|
476
|
+
_context9.next = 37;
|
|
477
|
+
return this.updateStateAmountToRemaining();
|
|
478
|
+
case 37:
|
|
435
479
|
console.log('[Checkout] 本地订单创建成功:', {
|
|
436
480
|
localOrderId: localOrderId,
|
|
437
481
|
uuid: paymentOrder.uuid,
|
|
@@ -440,41 +484,41 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
440
484
|
taxAmount: amountInfo.taxAmount,
|
|
441
485
|
stateAmount: this.store.stateAmount
|
|
442
486
|
});
|
|
443
|
-
return
|
|
444
|
-
case
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
return this.handleError(
|
|
449
|
-
case
|
|
450
|
-
|
|
487
|
+
return _context9.abrupt("return", paymentOrder);
|
|
488
|
+
case 41:
|
|
489
|
+
_context9.prev = 41;
|
|
490
|
+
_context9.t0 = _context9["catch"](0);
|
|
491
|
+
_context9.next = 45;
|
|
492
|
+
return this.handleError(_context9.t0, CheckoutErrorType.OrderCreationFailed);
|
|
493
|
+
case 45:
|
|
494
|
+
_context9.next = 47;
|
|
451
495
|
return this.core.effects.emit(CheckoutHooks.OnOrderCreationFailed, {
|
|
452
496
|
error: this.store.lastError,
|
|
453
497
|
timestamp: Date.now()
|
|
454
498
|
});
|
|
455
|
-
case
|
|
456
|
-
throw
|
|
457
|
-
case
|
|
499
|
+
case 47:
|
|
500
|
+
throw _context9.t0;
|
|
501
|
+
case 48:
|
|
458
502
|
case "end":
|
|
459
|
-
return
|
|
503
|
+
return _context9.stop();
|
|
460
504
|
}
|
|
461
|
-
},
|
|
505
|
+
}, _callee9, this, [[0, 41]]);
|
|
462
506
|
}));
|
|
463
|
-
function createLocalOrderAsync(
|
|
507
|
+
function createLocalOrderAsync(_x11) {
|
|
464
508
|
return _createLocalOrderAsync.apply(this, arguments);
|
|
465
509
|
}
|
|
466
510
|
return createLocalOrderAsync;
|
|
467
511
|
}()
|
|
468
512
|
/**
|
|
469
513
|
* 手动下单 (根据虚拟订单生成实际订单)
|
|
470
|
-
*
|
|
514
|
+
*
|
|
471
515
|
* 使用当前存储的本地订单数据调用 Order 模块创建真实订单
|
|
472
516
|
*/
|
|
473
517
|
)
|
|
474
518
|
}, {
|
|
475
519
|
key: "placeOrderAsync",
|
|
476
520
|
value: (function () {
|
|
477
|
-
var _placeOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
521
|
+
var _placeOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
478
522
|
var params,
|
|
479
523
|
_data,
|
|
480
524
|
orderData,
|
|
@@ -482,26 +526,26 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
482
526
|
realOrderId,
|
|
483
527
|
updatedOrder,
|
|
484
528
|
errorMessage,
|
|
485
|
-
|
|
486
|
-
return _regeneratorRuntime().wrap(function
|
|
487
|
-
while (1) switch (
|
|
529
|
+
_args10 = arguments;
|
|
530
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
531
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
488
532
|
case 0:
|
|
489
|
-
params =
|
|
490
|
-
|
|
533
|
+
params = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : {};
|
|
534
|
+
_context10.prev = 1;
|
|
491
535
|
if (this.store.localOrderData) {
|
|
492
|
-
|
|
536
|
+
_context10.next = 4;
|
|
493
537
|
break;
|
|
494
538
|
}
|
|
495
539
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '没有找到本地订单数据,请先调用 createLocalOrderAsync 创建虚拟订单');
|
|
496
540
|
case 4:
|
|
497
541
|
if (this.store.currentOrder) {
|
|
498
|
-
|
|
542
|
+
_context10.next = 6;
|
|
499
543
|
break;
|
|
500
544
|
}
|
|
501
545
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '没有找到当前订单,请先创建虚拟订单');
|
|
502
546
|
case 6:
|
|
503
547
|
console.log('[Checkout] 开始手动下单流程...');
|
|
504
|
-
|
|
548
|
+
_context10.next = 9;
|
|
505
549
|
return this.setStatus(CheckoutStatus.CreatingOrder);
|
|
506
550
|
case 9:
|
|
507
551
|
// 准备订单数据,使用 Order 模块期望的格式
|
|
@@ -510,18 +554,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
510
554
|
type: this.store.localOrderData.type,
|
|
511
555
|
platform: this.store.localOrderData.platform
|
|
512
556
|
}; // 调用 Order 模块提交订单
|
|
513
|
-
|
|
557
|
+
_context10.next = 12;
|
|
514
558
|
return this.order.submitOrder({
|
|
515
559
|
url: params.url,
|
|
516
560
|
// 可选的自定义 URL
|
|
517
561
|
query: orderData
|
|
518
562
|
});
|
|
519
563
|
case 12:
|
|
520
|
-
orderResponse =
|
|
564
|
+
orderResponse = _context10.sent;
|
|
521
565
|
// 提取真实订单ID(假设返回格式包含 order_id)
|
|
522
566
|
realOrderId = (orderResponse === null || orderResponse === void 0 || (_data = orderResponse.data) === null || _data === void 0 ? void 0 : _data.order_id) || (orderResponse === null || orderResponse === void 0 ? void 0 : orderResponse.order_id);
|
|
523
567
|
if (realOrderId) {
|
|
524
|
-
|
|
568
|
+
_context10.next = 16;
|
|
525
569
|
break;
|
|
526
570
|
}
|
|
527
571
|
throw createCheckoutError(CheckoutErrorType.OrderCreationFailed, '订单创建成功但未返回订单ID');
|
|
@@ -530,15 +574,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
530
574
|
|
|
531
575
|
// 如果设置了自动替换订单ID,则替换虚拟订单ID
|
|
532
576
|
if (!(params.autoReplaceOrderId !== false)) {
|
|
533
|
-
|
|
577
|
+
_context10.next = 23;
|
|
534
578
|
break;
|
|
535
579
|
}
|
|
536
580
|
// 默认为 true
|
|
537
581
|
console.log('[Checkout] 自动替换虚拟订单ID为真实订单ID...');
|
|
538
|
-
|
|
582
|
+
_context10.next = 21;
|
|
539
583
|
return this.replaceLocalOrderIdAsync(realOrderId);
|
|
540
584
|
case 21:
|
|
541
|
-
updatedOrder =
|
|
585
|
+
updatedOrder = _context10.sent;
|
|
542
586
|
if (updatedOrder) {
|
|
543
587
|
console.log('[Checkout] 订单ID替换成功:', {
|
|
544
588
|
oldId: this.store.currentOrder.order_id,
|
|
@@ -546,10 +590,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
546
590
|
});
|
|
547
591
|
}
|
|
548
592
|
case 23:
|
|
549
|
-
|
|
593
|
+
_context10.next = 25;
|
|
550
594
|
return this.setStatus(CheckoutStatus.OrderCreated);
|
|
551
595
|
case 25:
|
|
552
|
-
|
|
596
|
+
_context10.next = 27;
|
|
553
597
|
return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
|
|
554
598
|
order: this.store.currentOrder,
|
|
555
599
|
timestamp: Date.now()
|
|
@@ -558,33 +602,33 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
558
602
|
// 标记订单已同步
|
|
559
603
|
this.store.isOrderSynced = true;
|
|
560
604
|
console.log('[Checkout] 手动下单流程完成');
|
|
561
|
-
return
|
|
605
|
+
return _context10.abrupt("return", {
|
|
562
606
|
success: true,
|
|
563
607
|
orderId: realOrderId
|
|
564
608
|
});
|
|
565
609
|
case 32:
|
|
566
|
-
|
|
567
|
-
|
|
610
|
+
_context10.prev = 32;
|
|
611
|
+
_context10.t0 = _context10["catch"](1);
|
|
568
612
|
// 处理 CheckoutError 对象
|
|
569
613
|
errorMessage = '下单失败';
|
|
570
|
-
if (
|
|
571
|
-
errorMessage =
|
|
572
|
-
} else if (
|
|
573
|
-
errorMessage =
|
|
614
|
+
if (_context10.t0 && _typeof(_context10.t0) === 'object' && 'message' in _context10.t0) {
|
|
615
|
+
errorMessage = _context10.t0.message;
|
|
616
|
+
} else if (_context10.t0 instanceof Error) {
|
|
617
|
+
errorMessage = _context10.t0.message;
|
|
574
618
|
}
|
|
575
619
|
console.error('[Checkout] 手动下单失败:', errorMessage);
|
|
576
|
-
|
|
577
|
-
return this.handleError(
|
|
620
|
+
_context10.next = 39;
|
|
621
|
+
return this.handleError(_context10.t0, CheckoutErrorType.OrderCreationFailed);
|
|
578
622
|
case 39:
|
|
579
|
-
return
|
|
623
|
+
return _context10.abrupt("return", {
|
|
580
624
|
success: false,
|
|
581
625
|
error: errorMessage
|
|
582
626
|
});
|
|
583
627
|
case 40:
|
|
584
628
|
case "end":
|
|
585
|
-
return
|
|
629
|
+
return _context10.stop();
|
|
586
630
|
}
|
|
587
|
-
},
|
|
631
|
+
}, _callee10, this, [[1, 32]]);
|
|
588
632
|
}));
|
|
589
633
|
function placeOrderAsync() {
|
|
590
634
|
return _placeOrderAsync.apply(this, arguments);
|
|
@@ -598,13 +642,13 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
598
642
|
}, {
|
|
599
643
|
key: "createOrderAsync",
|
|
600
644
|
value: (function () {
|
|
601
|
-
var _createOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
645
|
+
var _createOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(params) {
|
|
602
646
|
var _data2, checkResult, orderResponse, paymentOrder;
|
|
603
|
-
return _regeneratorRuntime().wrap(function
|
|
604
|
-
while (1) switch (
|
|
647
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
648
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
605
649
|
case 0:
|
|
606
|
-
|
|
607
|
-
|
|
650
|
+
_context11.prev = 0;
|
|
651
|
+
_context11.next = 3;
|
|
608
652
|
return this.setStatus(CheckoutStatus.CreatingOrder);
|
|
609
653
|
case 3:
|
|
610
654
|
// 验证购物车数据
|
|
@@ -613,12 +657,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
613
657
|
type: 'account' // 默认使用 account 类型
|
|
614
658
|
});
|
|
615
659
|
if (checkResult) {
|
|
616
|
-
|
|
660
|
+
_context11.next = 6;
|
|
617
661
|
break;
|
|
618
662
|
}
|
|
619
663
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '购物车数据验证失败,请检查商品信息');
|
|
620
664
|
case 6:
|
|
621
|
-
|
|
665
|
+
_context11.next = 8;
|
|
622
666
|
return this.order.submitOrder({
|
|
623
667
|
query: {
|
|
624
668
|
cartItems: params.cartItems,
|
|
@@ -627,23 +671,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
627
671
|
}
|
|
628
672
|
});
|
|
629
673
|
case 8:
|
|
630
|
-
orderResponse =
|
|
631
|
-
|
|
674
|
+
orderResponse = _context11.sent;
|
|
675
|
+
_context11.next = 11;
|
|
632
676
|
return this.payment.createPaymentOrderAsync({
|
|
633
677
|
order_id: (orderResponse === null || orderResponse === void 0 || (_data2 = orderResponse.data) === null || _data2 === void 0 ? void 0 : _data2.order_id) || "order_".concat(Date.now()),
|
|
634
678
|
total_amount: this.calculateTotalAmount(params.cartItems),
|
|
635
679
|
order_info: orderResponse === null || orderResponse === void 0 ? void 0 : orderResponse.data
|
|
636
680
|
});
|
|
637
681
|
case 11:
|
|
638
|
-
paymentOrder =
|
|
682
|
+
paymentOrder = _context11.sent;
|
|
639
683
|
this.store.currentOrder = paymentOrder;
|
|
640
|
-
|
|
684
|
+
_context11.next = 15;
|
|
641
685
|
return this.setStatus(CheckoutStatus.OrderCreated);
|
|
642
686
|
case 15:
|
|
643
|
-
|
|
687
|
+
_context11.next = 17;
|
|
644
688
|
return this.setStep(CheckoutStep.PaymentMethod);
|
|
645
689
|
case 17:
|
|
646
|
-
|
|
690
|
+
_context11.next = 19;
|
|
647
691
|
return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
|
|
648
692
|
order: paymentOrder,
|
|
649
693
|
timestamp: Date.now()
|
|
@@ -653,31 +697,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
653
697
|
this.store.isOrderSynced = true;
|
|
654
698
|
|
|
655
699
|
// 自动设置 stateAmount 为剩余未支付金额
|
|
656
|
-
|
|
700
|
+
_context11.next = 22;
|
|
657
701
|
return this.updateStateAmountToRemaining();
|
|
658
702
|
case 22:
|
|
659
703
|
console.log('[Checkout] 订单创建成功:', paymentOrder.id);
|
|
660
|
-
return
|
|
704
|
+
return _context11.abrupt("return", paymentOrder);
|
|
661
705
|
case 26:
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
return this.handleError(
|
|
706
|
+
_context11.prev = 26;
|
|
707
|
+
_context11.t0 = _context11["catch"](0);
|
|
708
|
+
_context11.next = 30;
|
|
709
|
+
return this.handleError(_context11.t0, CheckoutErrorType.OrderCreationFailed);
|
|
666
710
|
case 30:
|
|
667
|
-
|
|
711
|
+
_context11.next = 32;
|
|
668
712
|
return this.core.effects.emit(CheckoutHooks.OnOrderCreationFailed, {
|
|
669
713
|
error: this.store.lastError,
|
|
670
714
|
timestamp: Date.now()
|
|
671
715
|
});
|
|
672
716
|
case 32:
|
|
673
|
-
throw
|
|
717
|
+
throw _context11.t0;
|
|
674
718
|
case 33:
|
|
675
719
|
case "end":
|
|
676
|
-
return
|
|
720
|
+
return _context11.stop();
|
|
677
721
|
}
|
|
678
|
-
},
|
|
722
|
+
}, _callee11, this, [[0, 26]]);
|
|
679
723
|
}));
|
|
680
|
-
function createOrderAsync(
|
|
724
|
+
function createOrderAsync(_x12) {
|
|
681
725
|
return _createOrderAsync.apply(this, arguments);
|
|
682
726
|
}
|
|
683
727
|
return createOrderAsync;
|
|
@@ -689,22 +733,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
689
733
|
}, {
|
|
690
734
|
key: "processPaymentAsync",
|
|
691
735
|
value: (function () {
|
|
692
|
-
var _processPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
736
|
+
var _processPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(params) {
|
|
693
737
|
var paymentMethod, paymentItem, result;
|
|
694
|
-
return _regeneratorRuntime().wrap(function
|
|
695
|
-
while (1) switch (
|
|
738
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
739
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
696
740
|
case 0:
|
|
697
|
-
|
|
741
|
+
_context12.prev = 0;
|
|
698
742
|
if (this.store.currentOrder) {
|
|
699
|
-
|
|
743
|
+
_context12.next = 3;
|
|
700
744
|
break;
|
|
701
745
|
}
|
|
702
746
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '未找到当前订单,请先创建订单');
|
|
703
747
|
case 3:
|
|
704
|
-
|
|
748
|
+
_context12.next = 5;
|
|
705
749
|
return this.setStatus(CheckoutStatus.ProcessingPayment);
|
|
706
750
|
case 5:
|
|
707
|
-
|
|
751
|
+
_context12.next = 7;
|
|
708
752
|
return this.setStep(CheckoutStep.PaymentProcessing);
|
|
709
753
|
case 7:
|
|
710
754
|
// 查找支付方式
|
|
@@ -712,7 +756,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
712
756
|
return method.code === params.paymentMethodCode;
|
|
713
757
|
});
|
|
714
758
|
if (paymentMethod) {
|
|
715
|
-
|
|
759
|
+
_context12.next = 10;
|
|
716
760
|
break;
|
|
717
761
|
}
|
|
718
762
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u672A\u627E\u5230\u652F\u4ED8\u65B9\u5F0F: ".concat(params.paymentMethodCode));
|
|
@@ -725,14 +769,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
725
769
|
amount: String(params.amount),
|
|
726
770
|
id: paymentMethod.id
|
|
727
771
|
}; // 添加支付项到订单
|
|
728
|
-
|
|
772
|
+
_context12.next = 13;
|
|
729
773
|
return this.payment.addPaymentItemAsync(this.store.currentOrder.uuid, paymentItem);
|
|
730
774
|
case 13:
|
|
731
|
-
|
|
775
|
+
_context12.next = 15;
|
|
732
776
|
return this.payment.submitPayAsync(this.store.currentOrder.uuid);
|
|
733
777
|
case 15:
|
|
734
|
-
result =
|
|
735
|
-
|
|
778
|
+
result = _context12.sent;
|
|
779
|
+
_context12.next = 18;
|
|
736
780
|
return this.core.effects.emit(CheckoutHooks.OnPaymentStarted, {
|
|
737
781
|
orderUuid: this.store.currentOrder.uuid,
|
|
738
782
|
paymentMethodCode: params.paymentMethodCode,
|
|
@@ -741,42 +785,42 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
741
785
|
});
|
|
742
786
|
case 18:
|
|
743
787
|
if (!(result.status === 'success')) {
|
|
744
|
-
|
|
788
|
+
_context12.next = 27;
|
|
745
789
|
break;
|
|
746
790
|
}
|
|
747
|
-
|
|
791
|
+
_context12.next = 21;
|
|
748
792
|
return this.setStatus(CheckoutStatus.PaymentCompleted);
|
|
749
793
|
case 21:
|
|
750
|
-
|
|
794
|
+
_context12.next = 23;
|
|
751
795
|
return this.updateStateAmountToRemaining();
|
|
752
796
|
case 23:
|
|
753
|
-
|
|
797
|
+
_context12.next = 25;
|
|
754
798
|
return this.handlePaymentSuccess({
|
|
755
799
|
orderUuid: this.store.currentOrder.uuid,
|
|
756
800
|
timestamp: Date.now()
|
|
757
801
|
});
|
|
758
802
|
case 25:
|
|
759
|
-
|
|
803
|
+
_context12.next = 28;
|
|
760
804
|
break;
|
|
761
805
|
case 27:
|
|
762
806
|
throw createCheckoutError(CheckoutErrorType.PaymentFailed, '支付处理失败,请重试');
|
|
763
807
|
case 28:
|
|
764
|
-
|
|
808
|
+
_context12.next = 35;
|
|
765
809
|
break;
|
|
766
810
|
case 30:
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
return this.handleError(
|
|
811
|
+
_context12.prev = 30;
|
|
812
|
+
_context12.t0 = _context12["catch"](0);
|
|
813
|
+
_context12.next = 34;
|
|
814
|
+
return this.handleError(_context12.t0, CheckoutErrorType.PaymentFailed);
|
|
771
815
|
case 34:
|
|
772
|
-
throw
|
|
816
|
+
throw _context12.t0;
|
|
773
817
|
case 35:
|
|
774
818
|
case "end":
|
|
775
|
-
return
|
|
819
|
+
return _context12.stop();
|
|
776
820
|
}
|
|
777
|
-
},
|
|
821
|
+
}, _callee12, this, [[0, 30]]);
|
|
778
822
|
}));
|
|
779
|
-
function processPaymentAsync(
|
|
823
|
+
function processPaymentAsync(_x13) {
|
|
780
824
|
return _processPaymentAsync.apply(this, arguments);
|
|
781
825
|
}
|
|
782
826
|
return processPaymentAsync;
|
|
@@ -788,61 +832,66 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
788
832
|
}, {
|
|
789
833
|
key: "completeCheckoutAsync",
|
|
790
834
|
value: (function () {
|
|
791
|
-
var _completeCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
835
|
+
var _completeCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
792
836
|
var order;
|
|
793
|
-
return _regeneratorRuntime().wrap(function
|
|
794
|
-
while (1) switch (
|
|
837
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
838
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
795
839
|
case 0:
|
|
796
|
-
|
|
840
|
+
_context13.prev = 0;
|
|
797
841
|
if (this.store.currentOrder) {
|
|
798
|
-
|
|
842
|
+
_context13.next = 3;
|
|
799
843
|
break;
|
|
800
844
|
}
|
|
801
845
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '未找到当前订单');
|
|
802
846
|
case 3:
|
|
803
|
-
|
|
847
|
+
_context13.next = 5;
|
|
804
848
|
return this.payment.getPaymentOrderByUuidAsync(this.store.currentOrder.uuid);
|
|
805
849
|
case 5:
|
|
806
|
-
order =
|
|
850
|
+
order = _context13.sent;
|
|
807
851
|
if (!(!order || order.payment_status !== PaymentStatus.Finished)) {
|
|
808
|
-
|
|
852
|
+
_context13.next = 8;
|
|
809
853
|
break;
|
|
810
854
|
}
|
|
811
855
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '订单支付未完成,无法完成结账');
|
|
812
856
|
case 8:
|
|
813
857
|
// 清理钱包模块的所有缓存数据
|
|
814
858
|
this.payment.wallet.clearAllCache();
|
|
815
|
-
|
|
859
|
+
_context13.next = 11;
|
|
816
860
|
return this.setStatus(CheckoutStatus.Completed);
|
|
817
861
|
case 11:
|
|
818
|
-
|
|
862
|
+
_context13.next = 13;
|
|
819
863
|
return this.setStep(CheckoutStep.Complete);
|
|
820
864
|
case 13:
|
|
821
|
-
|
|
865
|
+
_context13.next = 15;
|
|
822
866
|
return this.core.effects.emit(CheckoutHooks.OnCheckoutCompleted, {
|
|
823
867
|
orderId: order.id,
|
|
824
868
|
timestamp: Date.now()
|
|
825
869
|
});
|
|
826
870
|
case 15:
|
|
827
871
|
console.log('[Checkout] 结账流程完成:', order.id);
|
|
828
|
-
|
|
872
|
+
|
|
873
|
+
// 🔧 新增:自动重置 store 状态
|
|
874
|
+
_context13.next = 18;
|
|
875
|
+
return this.resetStoreStateAsync();
|
|
876
|
+
case 18:
|
|
877
|
+
return _context13.abrupt("return", {
|
|
829
878
|
success: true,
|
|
830
879
|
orderId: String(order.id)
|
|
831
880
|
});
|
|
832
|
-
case
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
return this.handleError(
|
|
837
|
-
case
|
|
838
|
-
return
|
|
881
|
+
case 21:
|
|
882
|
+
_context13.prev = 21;
|
|
883
|
+
_context13.t0 = _context13["catch"](0);
|
|
884
|
+
_context13.next = 25;
|
|
885
|
+
return this.handleError(_context13.t0, CheckoutErrorType.UnknownError);
|
|
886
|
+
case 25:
|
|
887
|
+
return _context13.abrupt("return", {
|
|
839
888
|
success: false
|
|
840
889
|
});
|
|
841
|
-
case
|
|
890
|
+
case 26:
|
|
842
891
|
case "end":
|
|
843
|
-
return
|
|
892
|
+
return _context13.stop();
|
|
844
893
|
}
|
|
845
|
-
},
|
|
894
|
+
}, _callee13, this, [[0, 21]]);
|
|
846
895
|
}));
|
|
847
896
|
function completeCheckoutAsync() {
|
|
848
897
|
return _completeCheckoutAsync.apply(this, arguments);
|
|
@@ -856,16 +905,16 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
856
905
|
}, {
|
|
857
906
|
key: "cancelCheckoutAsync",
|
|
858
907
|
value: (function () {
|
|
859
|
-
var _cancelCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
860
|
-
return _regeneratorRuntime().wrap(function
|
|
861
|
-
while (1) switch (
|
|
908
|
+
var _cancelCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
909
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
910
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
862
911
|
case 0:
|
|
863
|
-
|
|
912
|
+
_context14.prev = 0;
|
|
864
913
|
if (!this.store.currentOrder) {
|
|
865
|
-
|
|
914
|
+
_context14.next = 5;
|
|
866
915
|
break;
|
|
867
916
|
}
|
|
868
|
-
|
|
917
|
+
_context14.next = 4;
|
|
869
918
|
return this.payment.deletePaymentOrderAsync(this.store.currentOrder.uuid);
|
|
870
919
|
case 4:
|
|
871
920
|
this.store.currentOrder = undefined;
|
|
@@ -878,28 +927,28 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
878
927
|
this.store.stateAmount = '0.00';
|
|
879
928
|
this.store.isOrderSynced = false;
|
|
880
929
|
this.store.currentCustomer = undefined;
|
|
881
|
-
|
|
930
|
+
_context14.next = 14;
|
|
882
931
|
return this.setStatus(CheckoutStatus.Cancelled);
|
|
883
932
|
case 14:
|
|
884
|
-
|
|
933
|
+
_context14.next = 16;
|
|
885
934
|
return this.core.effects.emit(CheckoutHooks.OnCheckoutCancelled, {
|
|
886
935
|
timestamp: Date.now()
|
|
887
936
|
});
|
|
888
937
|
case 16:
|
|
889
938
|
console.log('[Checkout] 结账流程已取消');
|
|
890
|
-
|
|
939
|
+
_context14.next = 24;
|
|
891
940
|
break;
|
|
892
941
|
case 19:
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
console.error('[Checkout] 取消结账失败:',
|
|
896
|
-
|
|
897
|
-
return this.handleError(
|
|
942
|
+
_context14.prev = 19;
|
|
943
|
+
_context14.t0 = _context14["catch"](0);
|
|
944
|
+
console.error('[Checkout] 取消结账失败:', _context14.t0);
|
|
945
|
+
_context14.next = 24;
|
|
946
|
+
return this.handleError(_context14.t0, CheckoutErrorType.UnknownError);
|
|
898
947
|
case 24:
|
|
899
948
|
case "end":
|
|
900
|
-
return
|
|
949
|
+
return _context14.stop();
|
|
901
950
|
}
|
|
902
|
-
},
|
|
951
|
+
}, _callee14, this, [[0, 19]]);
|
|
903
952
|
}));
|
|
904
953
|
function cancelCheckoutAsync() {
|
|
905
954
|
return _cancelCheckoutAsync.apply(this, arguments);
|
|
@@ -928,16 +977,22 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
928
977
|
}, {
|
|
929
978
|
key: "getCheckoutSummaryAsync",
|
|
930
979
|
value: (function () {
|
|
931
|
-
var _getCheckoutSummaryAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
980
|
+
var _getCheckoutSummaryAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
932
981
|
var _this$store$currentOr3, _this$store$currentOr4;
|
|
933
982
|
var totalAmount, paidAmount, remainingAmount;
|
|
934
|
-
return _regeneratorRuntime().wrap(function
|
|
935
|
-
while (1) switch (
|
|
983
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
984
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
936
985
|
case 0:
|
|
937
986
|
totalAmount = ((_this$store$currentOr3 = this.store.currentOrder) === null || _this$store$currentOr3 === void 0 ? void 0 : _this$store$currentOr3.total_amount) || '0.00';
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
987
|
+
_context15.next = 3;
|
|
988
|
+
return this.calculatePaidAmountAsync();
|
|
989
|
+
case 3:
|
|
990
|
+
paidAmount = _context15.sent;
|
|
991
|
+
_context15.next = 6;
|
|
992
|
+
return this.calculateRemainingAmountAsync();
|
|
993
|
+
case 6:
|
|
994
|
+
remainingAmount = _context15.sent;
|
|
995
|
+
return _context15.abrupt("return", {
|
|
941
996
|
order: this.store.currentOrder,
|
|
942
997
|
totalAmount: totalAmount,
|
|
943
998
|
paidAmount: paidAmount,
|
|
@@ -945,11 +1000,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
945
1000
|
paymentStatus: ((_this$store$currentOr4 = this.store.currentOrder) === null || _this$store$currentOr4 === void 0 ? void 0 : _this$store$currentOr4.payment_status) || PaymentStatus.Processing,
|
|
946
1001
|
availablePaymentMethods: this.store.paymentMethods
|
|
947
1002
|
});
|
|
948
|
-
case
|
|
1003
|
+
case 8:
|
|
949
1004
|
case "end":
|
|
950
|
-
return
|
|
1005
|
+
return _context15.stop();
|
|
951
1006
|
}
|
|
952
|
-
},
|
|
1007
|
+
}, _callee15, this);
|
|
953
1008
|
}));
|
|
954
1009
|
function getCheckoutSummaryAsync() {
|
|
955
1010
|
return _getCheckoutSummaryAsync.apply(this, arguments);
|
|
@@ -963,24 +1018,19 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
963
1018
|
}, {
|
|
964
1019
|
key: "getAvailablePaymentMethodsAsync",
|
|
965
1020
|
value: (function () {
|
|
966
|
-
var _getAvailablePaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
967
|
-
return _regeneratorRuntime().wrap(function
|
|
968
|
-
while (1) switch (
|
|
1021
|
+
var _getAvailablePaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
1022
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1023
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
969
1024
|
case 0:
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
_context14.next = 4;
|
|
976
|
-
return this.preloadPaymentMethods();
|
|
977
|
-
case 4:
|
|
978
|
-
return _context14.abrupt("return", this.store.paymentMethods);
|
|
979
|
-
case 5:
|
|
1025
|
+
_context16.next = 2;
|
|
1026
|
+
return this.getPaymentMethodsAsync();
|
|
1027
|
+
case 2:
|
|
1028
|
+
return _context16.abrupt("return", _context16.sent);
|
|
1029
|
+
case 3:
|
|
980
1030
|
case "end":
|
|
981
|
-
return
|
|
1031
|
+
return _context16.stop();
|
|
982
1032
|
}
|
|
983
|
-
},
|
|
1033
|
+
}, _callee16, this);
|
|
984
1034
|
}));
|
|
985
1035
|
function getAvailablePaymentMethodsAsync() {
|
|
986
1036
|
return _getAvailablePaymentMethodsAsync.apply(this, arguments);
|
|
@@ -989,27 +1039,38 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
989
1039
|
}()
|
|
990
1040
|
/**
|
|
991
1041
|
* 刷新支付方式缓存
|
|
992
|
-
*
|
|
1042
|
+
*
|
|
993
1043
|
* 强制重新从服务器获取支付方式列表,更新本地缓存
|
|
994
1044
|
*/
|
|
995
1045
|
)
|
|
996
1046
|
}, {
|
|
997
1047
|
key: "refreshPaymentMethodsAsync",
|
|
998
1048
|
value: (function () {
|
|
999
|
-
var _refreshPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1000
|
-
|
|
1001
|
-
|
|
1049
|
+
var _refreshPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
1050
|
+
var methods;
|
|
1051
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1052
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1002
1053
|
case 0:
|
|
1003
1054
|
console.log('[Checkout] 强制刷新支付方式缓存...');
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
return _context15.abrupt("return", this.store.paymentMethods);
|
|
1055
|
+
_context17.prev = 1;
|
|
1056
|
+
_context17.next = 4;
|
|
1057
|
+
return this.payment.getPayMethodListAsync();
|
|
1008
1058
|
case 4:
|
|
1059
|
+
methods = _context17.sent;
|
|
1060
|
+
// 更新本地缓存
|
|
1061
|
+
this.store.paymentMethods = methods;
|
|
1062
|
+
console.log("[Checkout] \u5F3A\u5236\u5237\u65B0\u5B8C\u6210\uFF0C\u83B7\u53D6\u5230 ".concat(methods.length, " \u79CD\u652F\u4ED8\u65B9\u5F0F"));
|
|
1063
|
+
return _context17.abrupt("return", methods);
|
|
1064
|
+
case 10:
|
|
1065
|
+
_context17.prev = 10;
|
|
1066
|
+
_context17.t0 = _context17["catch"](1);
|
|
1067
|
+
console.error('[Checkout] 强制刷新支付方式失败:', _context17.t0);
|
|
1068
|
+
return _context17.abrupt("return", this.store.paymentMethods);
|
|
1069
|
+
case 14:
|
|
1009
1070
|
case "end":
|
|
1010
|
-
return
|
|
1071
|
+
return _context17.stop();
|
|
1011
1072
|
}
|
|
1012
|
-
},
|
|
1073
|
+
}, _callee17, this, [[1, 10]]);
|
|
1013
1074
|
}));
|
|
1014
1075
|
function refreshPaymentMethodsAsync() {
|
|
1015
1076
|
return _refreshPaymentMethodsAsync.apply(this, arguments);
|
|
@@ -1029,7 +1090,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1029
1090
|
|
|
1030
1091
|
/**
|
|
1031
1092
|
* 获取当前订单基础信息
|
|
1032
|
-
*
|
|
1093
|
+
*
|
|
1033
1094
|
* 返回当前订单的基础信息,包括订单状态、金额、支付状态等
|
|
1034
1095
|
*/
|
|
1035
1096
|
}, {
|
|
@@ -1084,25 +1145,25 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1084
1145
|
|
|
1085
1146
|
/**
|
|
1086
1147
|
* 获取当前订单的支付项
|
|
1087
|
-
*
|
|
1148
|
+
*
|
|
1088
1149
|
* 返回当前订单的所有支付项,包括活跃和已撤销的支付项
|
|
1089
1150
|
*/
|
|
1090
1151
|
}, {
|
|
1091
1152
|
key: "getCurrentOrderPaymentItemsAsync",
|
|
1092
1153
|
value: (function () {
|
|
1093
|
-
var _getCurrentOrderPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1154
|
+
var _getCurrentOrderPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
1094
1155
|
var _currentOrder2, paymentItems;
|
|
1095
|
-
return _regeneratorRuntime().wrap(function
|
|
1096
|
-
while (1) switch (
|
|
1156
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1157
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1097
1158
|
case 0:
|
|
1098
|
-
|
|
1159
|
+
_context18.prev = 0;
|
|
1099
1160
|
_currentOrder2 = this.store.currentOrder;
|
|
1100
1161
|
if (_currentOrder2) {
|
|
1101
|
-
|
|
1162
|
+
_context18.next = 5;
|
|
1102
1163
|
break;
|
|
1103
1164
|
}
|
|
1104
1165
|
console.log('[Checkout] 当前没有活跃订单,无法获取支付项');
|
|
1105
|
-
return
|
|
1166
|
+
return _context18.abrupt("return", []);
|
|
1106
1167
|
case 5:
|
|
1107
1168
|
console.log('[Checkout] 获取当前订单支付项:', {
|
|
1108
1169
|
orderUuid: _currentOrder2.uuid,
|
|
@@ -1110,10 +1171,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1110
1171
|
});
|
|
1111
1172
|
|
|
1112
1173
|
// 调用Payment模块获取支付项
|
|
1113
|
-
|
|
1174
|
+
_context18.next = 8;
|
|
1114
1175
|
return this.payment.getPaymentItemsAsync(_currentOrder2.uuid);
|
|
1115
1176
|
case 8:
|
|
1116
|
-
paymentItems =
|
|
1177
|
+
paymentItems = _context18.sent;
|
|
1117
1178
|
console.log('[Checkout] 成功获取支付项:', {
|
|
1118
1179
|
orderUuid: _currentOrder2.uuid,
|
|
1119
1180
|
paymentItemCount: paymentItems.length,
|
|
@@ -1138,17 +1199,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1138
1199
|
};
|
|
1139
1200
|
})
|
|
1140
1201
|
});
|
|
1141
|
-
return
|
|
1202
|
+
return _context18.abrupt("return", paymentItems);
|
|
1142
1203
|
case 13:
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
console.error('[Checkout] 获取当前订单支付项失败:',
|
|
1146
|
-
return
|
|
1204
|
+
_context18.prev = 13;
|
|
1205
|
+
_context18.t0 = _context18["catch"](0);
|
|
1206
|
+
console.error('[Checkout] 获取当前订单支付项失败:', _context18.t0);
|
|
1207
|
+
return _context18.abrupt("return", []);
|
|
1147
1208
|
case 17:
|
|
1148
1209
|
case "end":
|
|
1149
|
-
return
|
|
1210
|
+
return _context18.stop();
|
|
1150
1211
|
}
|
|
1151
|
-
},
|
|
1212
|
+
}, _callee18, this, [[0, 13]]);
|
|
1152
1213
|
}));
|
|
1153
1214
|
function getCurrentOrderPaymentItemsAsync() {
|
|
1154
1215
|
return _getCurrentOrderPaymentItemsAsync.apply(this, arguments);
|
|
@@ -1162,10 +1223,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1162
1223
|
}, {
|
|
1163
1224
|
key: "validateCheckoutAsync",
|
|
1164
1225
|
value: (function () {
|
|
1165
|
-
var _validateCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1226
|
+
var _validateCheckoutAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
|
|
1166
1227
|
var errors;
|
|
1167
|
-
return _regeneratorRuntime().wrap(function
|
|
1168
|
-
while (1) switch (
|
|
1228
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1229
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1169
1230
|
case 0:
|
|
1170
1231
|
errors = []; // 验证购物车
|
|
1171
1232
|
if (!this.store.cartItems || this.store.cartItems.length === 0) {
|
|
@@ -1181,15 +1242,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1181
1242
|
if (this.store.status === CheckoutStatus.Error) {
|
|
1182
1243
|
errors.push('结账流程存在错误');
|
|
1183
1244
|
}
|
|
1184
|
-
return
|
|
1245
|
+
return _context19.abrupt("return", {
|
|
1185
1246
|
valid: errors.length === 0,
|
|
1186
1247
|
errors: errors
|
|
1187
1248
|
});
|
|
1188
1249
|
case 5:
|
|
1189
1250
|
case "end":
|
|
1190
|
-
return
|
|
1251
|
+
return _context19.stop();
|
|
1191
1252
|
}
|
|
1192
|
-
},
|
|
1253
|
+
}, _callee19, this);
|
|
1193
1254
|
}));
|
|
1194
1255
|
function validateCheckoutAsync() {
|
|
1195
1256
|
return _validateCheckoutAsync.apply(this, arguments);
|
|
@@ -1203,44 +1264,44 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1203
1264
|
}, {
|
|
1204
1265
|
key: "retryFailedOperationAsync",
|
|
1205
1266
|
value: (function () {
|
|
1206
|
-
var _retryFailedOperationAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1207
|
-
return _regeneratorRuntime().wrap(function
|
|
1208
|
-
while (1) switch (
|
|
1267
|
+
var _retryFailedOperationAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
1268
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1269
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1209
1270
|
case 0:
|
|
1210
|
-
|
|
1271
|
+
_context20.prev = 0;
|
|
1211
1272
|
if (!(this.store.status === CheckoutStatus.Error && this.store.lastError)) {
|
|
1212
|
-
|
|
1273
|
+
_context20.next = 10;
|
|
1213
1274
|
break;
|
|
1214
1275
|
}
|
|
1215
|
-
|
|
1216
|
-
|
|
1276
|
+
_context20.t0 = this.store.lastError.type;
|
|
1277
|
+
_context20.next = _context20.t0 === CheckoutErrorType.OrderCreationFailed ? 5 : 9;
|
|
1217
1278
|
break;
|
|
1218
1279
|
case 5:
|
|
1219
1280
|
if (!(this.store.cartItems.length > 0)) {
|
|
1220
|
-
|
|
1281
|
+
_context20.next = 8;
|
|
1221
1282
|
break;
|
|
1222
1283
|
}
|
|
1223
|
-
|
|
1284
|
+
_context20.next = 8;
|
|
1224
1285
|
return this.createOrderAsync({
|
|
1225
1286
|
cartItems: this.store.cartItems
|
|
1226
1287
|
});
|
|
1227
1288
|
case 8:
|
|
1228
|
-
return
|
|
1289
|
+
return _context20.abrupt("break", 10);
|
|
1229
1290
|
case 9:
|
|
1230
1291
|
console.warn('[Checkout] 无法重试此类型的错误:', this.store.lastError.type);
|
|
1231
1292
|
case 10:
|
|
1232
|
-
|
|
1293
|
+
_context20.next = 16;
|
|
1233
1294
|
break;
|
|
1234
1295
|
case 12:
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
return this.handleError(
|
|
1296
|
+
_context20.prev = 12;
|
|
1297
|
+
_context20.t1 = _context20["catch"](0);
|
|
1298
|
+
_context20.next = 16;
|
|
1299
|
+
return this.handleError(_context20.t1, CheckoutErrorType.UnknownError);
|
|
1239
1300
|
case 16:
|
|
1240
1301
|
case "end":
|
|
1241
|
-
return
|
|
1302
|
+
return _context20.stop();
|
|
1242
1303
|
}
|
|
1243
|
-
},
|
|
1304
|
+
}, _callee20, this, [[0, 12]]);
|
|
1244
1305
|
}));
|
|
1245
1306
|
function retryFailedOperationAsync() {
|
|
1246
1307
|
return _retryFailedOperationAsync.apply(this, arguments);
|
|
@@ -1283,41 +1344,41 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1283
1344
|
|
|
1284
1345
|
/**
|
|
1285
1346
|
* 替换本地订单ID为真实订单ID
|
|
1286
|
-
*
|
|
1347
|
+
*
|
|
1287
1348
|
* 当后端订单创建完成后,调用此方法将本地虚拟订单ID替换为真实订单ID
|
|
1288
|
-
*
|
|
1349
|
+
*
|
|
1289
1350
|
* @param newOrderId 后端返回的真实订单ID
|
|
1290
1351
|
* @returns 更新后的订单对象,如果当前没有订单则返回null
|
|
1291
1352
|
*/
|
|
1292
1353
|
}, {
|
|
1293
1354
|
key: "replaceLocalOrderIdAsync",
|
|
1294
1355
|
value: (function () {
|
|
1295
|
-
var _replaceLocalOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1356
|
+
var _replaceLocalOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(newOrderId) {
|
|
1296
1357
|
var updatedOrder;
|
|
1297
|
-
return _regeneratorRuntime().wrap(function
|
|
1298
|
-
while (1) switch (
|
|
1358
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1359
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1299
1360
|
case 0:
|
|
1300
|
-
|
|
1361
|
+
_context21.prev = 0;
|
|
1301
1362
|
if (this.store.currentOrder) {
|
|
1302
|
-
|
|
1363
|
+
_context21.next = 4;
|
|
1303
1364
|
break;
|
|
1304
1365
|
}
|
|
1305
1366
|
console.warn('[Checkout] 没有当前订单,无法替换订单ID');
|
|
1306
|
-
return
|
|
1367
|
+
return _context21.abrupt("return", null);
|
|
1307
1368
|
case 4:
|
|
1308
|
-
|
|
1369
|
+
_context21.next = 6;
|
|
1309
1370
|
return this.payment.replaceOrderIdByUuidAsync(this.store.currentOrder.uuid, newOrderId);
|
|
1310
1371
|
case 6:
|
|
1311
|
-
updatedOrder =
|
|
1372
|
+
updatedOrder = _context21.sent;
|
|
1312
1373
|
if (!updatedOrder) {
|
|
1313
|
-
|
|
1374
|
+
_context21.next = 15;
|
|
1314
1375
|
break;
|
|
1315
1376
|
}
|
|
1316
1377
|
// 更新当前订单引用
|
|
1317
1378
|
this.store.currentOrder = updatedOrder;
|
|
1318
1379
|
|
|
1319
1380
|
// 触发订单更新事件
|
|
1320
|
-
|
|
1381
|
+
_context21.next = 11;
|
|
1321
1382
|
return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
|
|
1322
1383
|
order: updatedOrder,
|
|
1323
1384
|
timestamp: Date.now()
|
|
@@ -1332,50 +1393,50 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1332
1393
|
this.store.isOrderSynced = true;
|
|
1333
1394
|
|
|
1334
1395
|
// 订单ID替换后更新 stateAmount
|
|
1335
|
-
|
|
1396
|
+
_context21.next = 15;
|
|
1336
1397
|
return this.updateStateAmountToRemaining();
|
|
1337
1398
|
case 15:
|
|
1338
|
-
return
|
|
1399
|
+
return _context21.abrupt("return", updatedOrder);
|
|
1339
1400
|
case 18:
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
console.error('[Checkout] 替换订单ID失败:',
|
|
1343
|
-
|
|
1344
|
-
return this.handleError(
|
|
1401
|
+
_context21.prev = 18;
|
|
1402
|
+
_context21.t0 = _context21["catch"](0);
|
|
1403
|
+
console.error('[Checkout] 替换订单ID失败:', _context21.t0);
|
|
1404
|
+
_context21.next = 23;
|
|
1405
|
+
return this.handleError(_context21.t0, CheckoutErrorType.UnknownError);
|
|
1345
1406
|
case 23:
|
|
1346
|
-
return
|
|
1407
|
+
return _context21.abrupt("return", null);
|
|
1347
1408
|
case 24:
|
|
1348
1409
|
case "end":
|
|
1349
|
-
return
|
|
1410
|
+
return _context21.stop();
|
|
1350
1411
|
}
|
|
1351
|
-
},
|
|
1412
|
+
}, _callee21, this, [[0, 18]]);
|
|
1352
1413
|
}));
|
|
1353
|
-
function replaceLocalOrderIdAsync(
|
|
1414
|
+
function replaceLocalOrderIdAsync(_x14) {
|
|
1354
1415
|
return _replaceLocalOrderIdAsync.apply(this, arguments);
|
|
1355
1416
|
}
|
|
1356
1417
|
return replaceLocalOrderIdAsync;
|
|
1357
1418
|
}()
|
|
1358
1419
|
/**
|
|
1359
1420
|
* 设置自定义支付金额
|
|
1360
|
-
*
|
|
1421
|
+
*
|
|
1361
1422
|
* 允许UI自定义本次支付的金额,通常用于部分支付或调整支付金额场景
|
|
1362
|
-
*
|
|
1423
|
+
*
|
|
1363
1424
|
* @param amount 自定义支付金额,必须是有效的数字字符串
|
|
1364
1425
|
*/
|
|
1365
1426
|
)
|
|
1366
1427
|
}, {
|
|
1367
1428
|
key: "setStateAmountAsync",
|
|
1368
1429
|
value: (function () {
|
|
1369
|
-
var _setStateAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1430
|
+
var _setStateAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(amount) {
|
|
1370
1431
|
var numAmount, oldAmount, formattedAmount, errorMessage;
|
|
1371
|
-
return _regeneratorRuntime().wrap(function
|
|
1372
|
-
while (1) switch (
|
|
1432
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1433
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1373
1434
|
case 0:
|
|
1374
|
-
|
|
1435
|
+
_context22.prev = 0;
|
|
1375
1436
|
// 验证金额格式
|
|
1376
1437
|
numAmount = parseFloat(amount);
|
|
1377
1438
|
if (!(isNaN(numAmount) || numAmount < 0)) {
|
|
1378
|
-
|
|
1439
|
+
_context22.next = 4;
|
|
1379
1440
|
break;
|
|
1380
1441
|
}
|
|
1381
1442
|
throw new Error("\u65E0\u6548\u7684\u652F\u4ED8\u91D1\u989D: ".concat(amount));
|
|
@@ -1383,16 +1444,16 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1383
1444
|
oldAmount = this.store.stateAmount;
|
|
1384
1445
|
formattedAmount = numAmount.toFixed(2); // 如果金额没有变化,直接返回
|
|
1385
1446
|
if (!(oldAmount === formattedAmount)) {
|
|
1386
|
-
|
|
1447
|
+
_context22.next = 8;
|
|
1387
1448
|
break;
|
|
1388
1449
|
}
|
|
1389
|
-
return
|
|
1450
|
+
return _context22.abrupt("return");
|
|
1390
1451
|
case 8:
|
|
1391
1452
|
// 更新状态
|
|
1392
1453
|
this.store.stateAmount = formattedAmount;
|
|
1393
1454
|
|
|
1394
1455
|
// 触发金额变更事件
|
|
1395
|
-
|
|
1456
|
+
_context22.next = 11;
|
|
1396
1457
|
return this.core.effects.emit(CheckoutHooks.OnStateAmountChanged, {
|
|
1397
1458
|
oldAmount: oldAmount,
|
|
1398
1459
|
newAmount: formattedAmount,
|
|
@@ -1403,31 +1464,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1403
1464
|
oldAmount: oldAmount,
|
|
1404
1465
|
newAmount: formattedAmount
|
|
1405
1466
|
});
|
|
1406
|
-
|
|
1467
|
+
_context22.next = 21;
|
|
1407
1468
|
break;
|
|
1408
1469
|
case 14:
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
errorMessage =
|
|
1470
|
+
_context22.prev = 14;
|
|
1471
|
+
_context22.t0 = _context22["catch"](0);
|
|
1472
|
+
errorMessage = _context22.t0 instanceof Error ? _context22.t0.message : '设置支付金额失败';
|
|
1412
1473
|
console.error('[Checkout] 设置自定义支付金额失败:', errorMessage);
|
|
1413
|
-
|
|
1474
|
+
_context22.next = 20;
|
|
1414
1475
|
return this.handleError(new Error(errorMessage), CheckoutErrorType.ValidationFailed);
|
|
1415
1476
|
case 20:
|
|
1416
|
-
throw
|
|
1477
|
+
throw _context22.t0;
|
|
1417
1478
|
case 21:
|
|
1418
1479
|
case "end":
|
|
1419
|
-
return
|
|
1480
|
+
return _context22.stop();
|
|
1420
1481
|
}
|
|
1421
|
-
},
|
|
1482
|
+
}, _callee22, this, [[0, 14]]);
|
|
1422
1483
|
}));
|
|
1423
|
-
function setStateAmountAsync(
|
|
1484
|
+
function setStateAmountAsync(_x15) {
|
|
1424
1485
|
return _setStateAmountAsync.apply(this, arguments);
|
|
1425
1486
|
}
|
|
1426
1487
|
return setStateAmountAsync;
|
|
1427
1488
|
}()
|
|
1428
1489
|
/**
|
|
1429
1490
|
* 获取当前自定义支付金额
|
|
1430
|
-
*
|
|
1491
|
+
*
|
|
1431
1492
|
* @returns 当前设置的自定义支付金额
|
|
1432
1493
|
*/
|
|
1433
1494
|
)
|
|
@@ -1439,23 +1500,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1439
1500
|
|
|
1440
1501
|
/**
|
|
1441
1502
|
* 刷新 stateAmount 为当前剩余未支付金额
|
|
1442
|
-
*
|
|
1503
|
+
*
|
|
1443
1504
|
* UI 可以调用此方法来主动刷新支付金额状态
|
|
1444
1505
|
*/
|
|
1445
1506
|
}, {
|
|
1446
1507
|
key: "refreshStateAmountAsync",
|
|
1447
1508
|
value: (function () {
|
|
1448
|
-
var _refreshStateAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1449
|
-
return _regeneratorRuntime().wrap(function
|
|
1450
|
-
while (1) switch (
|
|
1509
|
+
var _refreshStateAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23() {
|
|
1510
|
+
return _regeneratorRuntime().wrap(function _callee23$(_context23) {
|
|
1511
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1451
1512
|
case 0:
|
|
1452
|
-
|
|
1513
|
+
_context23.next = 2;
|
|
1453
1514
|
return this.updateStateAmountToRemaining();
|
|
1454
1515
|
case 2:
|
|
1455
1516
|
case "end":
|
|
1456
|
-
return
|
|
1517
|
+
return _context23.stop();
|
|
1457
1518
|
}
|
|
1458
|
-
},
|
|
1519
|
+
}, _callee23, this);
|
|
1459
1520
|
}));
|
|
1460
1521
|
function refreshStateAmountAsync() {
|
|
1461
1522
|
return _refreshStateAmountAsync.apply(this, arguments);
|
|
@@ -1464,9 +1525,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1464
1525
|
}()
|
|
1465
1526
|
/**
|
|
1466
1527
|
* 获取购物车小计数据
|
|
1467
|
-
*
|
|
1528
|
+
*
|
|
1468
1529
|
* 返回当前结账流程中的购物车小计项数据,包含各种费用明细
|
|
1469
|
-
*
|
|
1530
|
+
*
|
|
1470
1531
|
* @returns 购物车小计数据数组,如果没有则返回 null
|
|
1471
1532
|
*/
|
|
1472
1533
|
)
|
|
@@ -1492,9 +1553,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1492
1553
|
|
|
1493
1554
|
/**
|
|
1494
1555
|
* 获取提取的金额详细信息
|
|
1495
|
-
*
|
|
1556
|
+
*
|
|
1496
1557
|
* 从当前的购物车小计数据中提取结构化的金额信息
|
|
1497
|
-
*
|
|
1558
|
+
*
|
|
1498
1559
|
* @returns 提取的金额信息对象,如果没有小计数据则返回 null
|
|
1499
1560
|
*/
|
|
1500
1561
|
}, {
|
|
@@ -1511,27 +1572,48 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1511
1572
|
|
|
1512
1573
|
/**
|
|
1513
1574
|
* 获取支付方式列表
|
|
1514
|
-
*
|
|
1515
|
-
*
|
|
1516
|
-
*
|
|
1575
|
+
*
|
|
1576
|
+
* 优先使用 store 中的缓存数据,避免重复接口调用。
|
|
1577
|
+
* 如果 store 中没有数据,则调用 Payment 模块的方法获取。
|
|
1578
|
+
*
|
|
1517
1579
|
* @returns 支付方式列表
|
|
1518
1580
|
*/
|
|
1519
1581
|
}, {
|
|
1520
1582
|
key: "getPaymentMethodsAsync",
|
|
1521
1583
|
value: (function () {
|
|
1522
|
-
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1523
|
-
|
|
1524
|
-
|
|
1584
|
+
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24() {
|
|
1585
|
+
var methods;
|
|
1586
|
+
return _regeneratorRuntime().wrap(function _callee24$(_context24) {
|
|
1587
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1525
1588
|
case 0:
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1589
|
+
if (!(this.store.paymentMethods && this.store.paymentMethods.length > 0)) {
|
|
1590
|
+
_context24.next = 3;
|
|
1591
|
+
break;
|
|
1592
|
+
}
|
|
1593
|
+
console.log("[Checkout] \u4F7F\u7528\u7F13\u5B58\u7684\u652F\u4ED8\u65B9\u5F0F\u6570\u636E\uFF0C\u5171 ".concat(this.store.paymentMethods.length, " \u79CD"));
|
|
1594
|
+
return _context24.abrupt("return", this.store.paymentMethods);
|
|
1530
1595
|
case 3:
|
|
1596
|
+
// 如果缓存为空,调用 Payment 模块获取
|
|
1597
|
+
console.log('[Checkout] store 中无缓存,从 Payment 模块获取支付方式...');
|
|
1598
|
+
_context24.prev = 4;
|
|
1599
|
+
_context24.next = 7;
|
|
1600
|
+
return this.payment.getPayMethodListAsync();
|
|
1601
|
+
case 7:
|
|
1602
|
+
methods = _context24.sent;
|
|
1603
|
+
// 更新缓存
|
|
1604
|
+
this.store.paymentMethods = methods;
|
|
1605
|
+
console.log("[Checkout] \u4ECE Payment \u6A21\u5757\u83B7\u53D6\u5230 ".concat(methods.length, " \u79CD\u652F\u4ED8\u65B9\u5F0F\uFF0C\u5DF2\u66F4\u65B0\u7F13\u5B58"));
|
|
1606
|
+
return _context24.abrupt("return", methods);
|
|
1607
|
+
case 13:
|
|
1608
|
+
_context24.prev = 13;
|
|
1609
|
+
_context24.t0 = _context24["catch"](4);
|
|
1610
|
+
console.error('[Checkout] 获取支付方式失败:', _context24.t0);
|
|
1611
|
+
return _context24.abrupt("return", []);
|
|
1612
|
+
case 17:
|
|
1531
1613
|
case "end":
|
|
1532
|
-
return
|
|
1614
|
+
return _context24.stop();
|
|
1533
1615
|
}
|
|
1534
|
-
},
|
|
1616
|
+
}, _callee24, this, [[4, 13]]);
|
|
1535
1617
|
}));
|
|
1536
1618
|
function getPaymentMethodsAsync() {
|
|
1537
1619
|
return _getPaymentMethodsAsync.apply(this, arguments);
|
|
@@ -1540,9 +1622,9 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1540
1622
|
}()
|
|
1541
1623
|
/**
|
|
1542
1624
|
* 为当前订单添加支付项
|
|
1543
|
-
*
|
|
1625
|
+
*
|
|
1544
1626
|
* 向当前活跃订单添加一个支付项,支付项包含支付方式信息和金额
|
|
1545
|
-
*
|
|
1627
|
+
*
|
|
1546
1628
|
* @param paymentItem 支付项数据
|
|
1547
1629
|
* @throws 当前没有活跃订单时抛出错误
|
|
1548
1630
|
*/
|
|
@@ -1550,14 +1632,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1550
1632
|
}, {
|
|
1551
1633
|
key: "addPaymentItemAsync",
|
|
1552
1634
|
value: (function () {
|
|
1553
|
-
var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1554
|
-
var currentOrderId, isCurrentOrderReal
|
|
1555
|
-
return _regeneratorRuntime().wrap(function
|
|
1556
|
-
while (1) switch (
|
|
1635
|
+
var _addPaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(paymentItem) {
|
|
1636
|
+
var currentOrderId, isCurrentOrderReal;
|
|
1637
|
+
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
|
1638
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1557
1639
|
case 0:
|
|
1558
|
-
|
|
1640
|
+
_context25.prev = 0;
|
|
1559
1641
|
if (this.store.currentOrder) {
|
|
1560
|
-
|
|
1642
|
+
_context25.next = 3;
|
|
1561
1643
|
break;
|
|
1562
1644
|
}
|
|
1563
1645
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '未找到当前订单,无法添加支付项');
|
|
@@ -1574,7 +1656,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1574
1656
|
});
|
|
1575
1657
|
|
|
1576
1658
|
// 添加支付项到订单
|
|
1577
|
-
|
|
1659
|
+
_context25.next = 6;
|
|
1578
1660
|
return this.payment.addPaymentItemAsync(this.store.currentOrder.uuid, paymentItem);
|
|
1579
1661
|
case 6:
|
|
1580
1662
|
console.log('[Checkout] 支付项添加成功');
|
|
@@ -1586,93 +1668,93 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1586
1668
|
当前订单ID: currentOrderId,
|
|
1587
1669
|
是否为真实ID: isCurrentOrderReal
|
|
1588
1670
|
});
|
|
1589
|
-
_context23.next = 12;
|
|
1590
|
-
return this.payment.getPaymentOrderByUuidAsync(this.store.currentOrder.uuid);
|
|
1591
|
-
case 12:
|
|
1592
|
-
updatedOrder = _context23.sent;
|
|
1593
|
-
if (updatedOrder) {
|
|
1594
|
-
// 如果当前订单ID是真实ID,但获取到的订单ID是虚拟ID,需要保护真实ID
|
|
1595
|
-
if (isCurrentOrderReal && this.isVirtualOrderId(updatedOrder.order_id)) {
|
|
1596
|
-
console.warn('[Checkout] 检测到订单ID回退,保护真实订单ID:', {
|
|
1597
|
-
当前真实ID: currentOrderId,
|
|
1598
|
-
获取到的虚拟ID: updatedOrder.order_id
|
|
1599
|
-
});
|
|
1600
|
-
updatedOrder.order_id = currentOrderId; // 恢复真实的订单ID
|
|
1601
|
-
}
|
|
1602
|
-
this.store.currentOrder = updatedOrder;
|
|
1603
|
-
console.log('[Checkout] 订单数据已同步:', {
|
|
1604
|
-
支付项数量: updatedOrder.payment.length,
|
|
1605
|
-
最终订单ID: updatedOrder.order_id,
|
|
1606
|
-
是否为虚拟ID: this.isVirtualOrderId(updatedOrder.order_id)
|
|
1607
|
-
});
|
|
1608
|
-
}
|
|
1609
1671
|
|
|
1610
|
-
//
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
}
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1672
|
+
// const updatedOrder = await this.payment.getPaymentOrderByUuidAsync(this.store.currentOrder.uuid);
|
|
1673
|
+
// if (updatedOrder) {
|
|
1674
|
+
// // 如果当前订单ID是真实ID,但获取到的订单ID是虚拟ID,需要保护真实ID
|
|
1675
|
+
// if (isCurrentOrderReal && this.isVirtualOrderId(updatedOrder.order_id)) {
|
|
1676
|
+
// console.warn('[Checkout] 检测到订单ID回退,保护真实订单ID:', {
|
|
1677
|
+
// 当前真实ID: currentOrderId,
|
|
1678
|
+
// 获取到的虚拟ID: updatedOrder.order_id
|
|
1679
|
+
// });
|
|
1680
|
+
// updatedOrder.order_id = currentOrderId; // 恢复真实的订单ID
|
|
1681
|
+
// }
|
|
1682
|
+
|
|
1683
|
+
// this.store.currentOrder = updatedOrder;
|
|
1684
|
+
// console.log('[Checkout] 订单数据已同步:', {
|
|
1685
|
+
// 支付项数量: updatedOrder.payment.length,
|
|
1686
|
+
// 最终订单ID: updatedOrder.order_id,
|
|
1687
|
+
// 是否为虚拟ID: this.isVirtualOrderId(updatedOrder.order_id)
|
|
1688
|
+
// });
|
|
1689
|
+
// }
|
|
1690
|
+
|
|
1691
|
+
// // 检查是否需要同步订单到后端
|
|
1692
|
+
// const needsOrderSync = this.shouldSyncOrderForPayment(paymentItem.code, paymentItem.type);
|
|
1693
|
+
|
|
1694
|
+
// console.log('[Checkout] 支付项同步检查:', {
|
|
1695
|
+
// paymentCode: paymentItem.code,
|
|
1696
|
+
// paymentType: paymentItem.type,
|
|
1697
|
+
// paymentAmount: paymentItem.amount,
|
|
1698
|
+
// expectedCashCode: PaymentMethodType.Cash,
|
|
1699
|
+
// needsOrderSync,
|
|
1700
|
+
// isOrderSynced: this.store.isOrderSynced
|
|
1701
|
+
// });
|
|
1702
|
+
|
|
1703
|
+
// if (needsOrderSync) {
|
|
1704
|
+
// console.log('[Checkout] 检测到非现金/自定义支付,开始同步订单到后端...', {
|
|
1705
|
+
// 同步前订单ID: this.store.currentOrder.order_id,
|
|
1706
|
+
// 是否为虚拟ID: this.isVirtualOrderId(this.store.currentOrder.order_id),
|
|
1707
|
+
// 订单同步状态: this.store.isOrderSynced,
|
|
1708
|
+
// 订单UUID: this.store.currentOrder.uuid
|
|
1709
|
+
// });
|
|
1710
|
+
|
|
1711
|
+
// await this.syncOrderToBackend();
|
|
1712
|
+
|
|
1713
|
+
// console.log('[Checkout] addPaymentItemAsync 中的同步完成:', {
|
|
1714
|
+
// 同步后订单ID: this.store.currentOrder.order_id,
|
|
1715
|
+
// 是否为虚拟ID: this.isVirtualOrderId(this.store.currentOrder.order_id),
|
|
1716
|
+
// 订单同步状态: this.store.isOrderSynced
|
|
1717
|
+
// });
|
|
1718
|
+
// }
|
|
1719
|
+
|
|
1720
|
+
// 支付项添加后,更新 stateAmount 为剩余未支付金额
|
|
1721
|
+
_context25.next = 12;
|
|
1640
1722
|
return this.updateStateAmountToRemaining();
|
|
1641
|
-
case
|
|
1642
|
-
|
|
1723
|
+
case 12:
|
|
1724
|
+
_context25.next = 14;
|
|
1643
1725
|
return this.core.effects.emit(CheckoutHooks.OnPaymentStarted, {
|
|
1644
1726
|
orderUuid: this.store.currentOrder.uuid,
|
|
1645
1727
|
paymentMethodCode: paymentItem.code,
|
|
1646
1728
|
amount: String(paymentItem.amount),
|
|
1647
1729
|
timestamp: Date.now()
|
|
1648
1730
|
});
|
|
1649
|
-
case
|
|
1650
|
-
|
|
1731
|
+
case 14:
|
|
1732
|
+
_context25.next = 22;
|
|
1651
1733
|
break;
|
|
1652
|
-
case
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
console.error('[Checkout] 添加支付项失败:',
|
|
1656
|
-
|
|
1657
|
-
return this.handleError(
|
|
1658
|
-
case
|
|
1659
|
-
throw
|
|
1660
|
-
case
|
|
1734
|
+
case 16:
|
|
1735
|
+
_context25.prev = 16;
|
|
1736
|
+
_context25.t0 = _context25["catch"](0);
|
|
1737
|
+
console.error('[Checkout] 添加支付项失败:', _context25.t0);
|
|
1738
|
+
_context25.next = 21;
|
|
1739
|
+
return this.handleError(_context25.t0, CheckoutErrorType.PaymentFailed);
|
|
1740
|
+
case 21:
|
|
1741
|
+
throw _context25.t0;
|
|
1742
|
+
case 22:
|
|
1661
1743
|
case "end":
|
|
1662
|
-
return
|
|
1744
|
+
return _context25.stop();
|
|
1663
1745
|
}
|
|
1664
|
-
},
|
|
1746
|
+
}, _callee25, this, [[0, 16]]);
|
|
1665
1747
|
}));
|
|
1666
|
-
function addPaymentItemAsync(
|
|
1748
|
+
function addPaymentItemAsync(_x16) {
|
|
1667
1749
|
return _addPaymentItemAsync.apply(this, arguments);
|
|
1668
1750
|
}
|
|
1669
1751
|
return addPaymentItemAsync;
|
|
1670
1752
|
}()
|
|
1671
1753
|
/**
|
|
1672
1754
|
* 删除当前订单的支付项
|
|
1673
|
-
*
|
|
1755
|
+
*
|
|
1674
1756
|
* 从当前活跃订单中删除指定的支付项,支付项将被标记为已撤销状态
|
|
1675
|
-
*
|
|
1757
|
+
*
|
|
1676
1758
|
* @param paymentUuid 要删除的支付项UUID
|
|
1677
1759
|
* @throws 当前没有活跃订单时抛出错误
|
|
1678
1760
|
* @throws 支付项不存在时抛出错误
|
|
@@ -1681,14 +1763,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1681
1763
|
}, {
|
|
1682
1764
|
key: "deletePaymentItemAsync",
|
|
1683
1765
|
value: (function () {
|
|
1684
|
-
var _deletePaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1685
|
-
var paymentItem, currentOrderId, isCurrentOrderReal, updatedOrder;
|
|
1686
|
-
return _regeneratorRuntime().wrap(function
|
|
1687
|
-
while (1) switch (
|
|
1766
|
+
var _deletePaymentItemAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(paymentUuid) {
|
|
1767
|
+
var currentPayments, paymentItem, currentOrderId, isCurrentOrderReal, updatedOrder;
|
|
1768
|
+
return _regeneratorRuntime().wrap(function _callee26$(_context26) {
|
|
1769
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
1688
1770
|
case 0:
|
|
1689
|
-
|
|
1771
|
+
_context26.prev = 0;
|
|
1690
1772
|
if (this.store.currentOrder) {
|
|
1691
|
-
|
|
1773
|
+
_context26.next = 3;
|
|
1692
1774
|
break;
|
|
1693
1775
|
}
|
|
1694
1776
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '当前没有活跃订单,无法删除支付项');
|
|
@@ -1698,16 +1780,21 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1698
1780
|
paymentUuid: paymentUuid
|
|
1699
1781
|
});
|
|
1700
1782
|
|
|
1701
|
-
//
|
|
1702
|
-
|
|
1783
|
+
// 从 Payment 模块验证支付项是否存在
|
|
1784
|
+
_context26.next = 6;
|
|
1785
|
+
return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid, true // 包括已撤销的支付项,因为我们需要验证是否存在
|
|
1786
|
+
);
|
|
1787
|
+
case 6:
|
|
1788
|
+
currentPayments = _context26.sent;
|
|
1789
|
+
paymentItem = currentPayments.find(function (p) {
|
|
1703
1790
|
return p.uuid === paymentUuid;
|
|
1704
1791
|
});
|
|
1705
1792
|
if (paymentItem) {
|
|
1706
|
-
|
|
1793
|
+
_context26.next = 10;
|
|
1707
1794
|
break;
|
|
1708
1795
|
}
|
|
1709
1796
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u652F\u4ED8\u9879\u4E0D\u5B58\u5728: ".concat(paymentUuid));
|
|
1710
|
-
case
|
|
1797
|
+
case 10:
|
|
1711
1798
|
console.log('[Checkout] 找到要删除的支付项:', {
|
|
1712
1799
|
uuid: paymentItem.uuid,
|
|
1713
1800
|
code: paymentItem.code,
|
|
@@ -1716,18 +1803,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1716
1803
|
});
|
|
1717
1804
|
|
|
1718
1805
|
// 调用 Payment 模块删除支付项
|
|
1719
|
-
|
|
1806
|
+
_context26.next = 13;
|
|
1720
1807
|
return this.payment.deletePaymentAsync(this.store.currentOrder.uuid, paymentUuid);
|
|
1721
|
-
case
|
|
1808
|
+
case 13:
|
|
1722
1809
|
console.log('[Checkout] Payment模块删除完成');
|
|
1723
1810
|
|
|
1724
1811
|
// 重新从Payment模块获取最新的订单数据,确保支付项同步
|
|
1725
1812
|
currentOrderId = this.store.currentOrder.order_id; // 保存当前的订单ID
|
|
1726
1813
|
isCurrentOrderReal = currentOrderId && !this.isVirtualOrderId(currentOrderId);
|
|
1727
|
-
|
|
1814
|
+
_context26.next = 18;
|
|
1728
1815
|
return this.payment.getPaymentOrderByUuidAsync(this.store.currentOrder.uuid);
|
|
1729
|
-
case
|
|
1730
|
-
updatedOrder =
|
|
1816
|
+
case 18:
|
|
1817
|
+
updatedOrder = _context26.sent;
|
|
1731
1818
|
if (updatedOrder) {
|
|
1732
1819
|
// 如果当前订单ID是真实ID,但获取到的订单ID是虚拟ID,需要保护真实ID
|
|
1733
1820
|
if (isCurrentOrderReal && this.isVirtualOrderId(updatedOrder.order_id)) {
|
|
@@ -1742,10 +1829,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1742
1829
|
}
|
|
1743
1830
|
|
|
1744
1831
|
// 更新 stateAmount 为剩余未支付金额
|
|
1745
|
-
|
|
1832
|
+
_context26.next = 22;
|
|
1746
1833
|
return this.updateStateAmountToRemaining();
|
|
1747
|
-
case
|
|
1748
|
-
|
|
1834
|
+
case 22:
|
|
1835
|
+
_context26.next = 24;
|
|
1749
1836
|
return this.core.effects.emit(CheckoutHooks.OnPaymentStarted, {
|
|
1750
1837
|
orderUuid: this.store.currentOrder.uuid,
|
|
1751
1838
|
paymentMethodCode: paymentItem.code,
|
|
@@ -1753,35 +1840,35 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1753
1840
|
// 负数表示删除
|
|
1754
1841
|
timestamp: Date.now()
|
|
1755
1842
|
});
|
|
1756
|
-
case
|
|
1843
|
+
case 24:
|
|
1757
1844
|
console.log('[Checkout] 支付项删除成功');
|
|
1758
|
-
|
|
1845
|
+
_context26.next = 33;
|
|
1759
1846
|
break;
|
|
1760
|
-
case
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
console.error('[Checkout] 删除支付项失败:',
|
|
1764
|
-
|
|
1765
|
-
return this.handleError(
|
|
1766
|
-
case
|
|
1767
|
-
throw
|
|
1768
|
-
case
|
|
1847
|
+
case 27:
|
|
1848
|
+
_context26.prev = 27;
|
|
1849
|
+
_context26.t0 = _context26["catch"](0);
|
|
1850
|
+
console.error('[Checkout] 删除支付项失败:', _context26.t0);
|
|
1851
|
+
_context26.next = 32;
|
|
1852
|
+
return this.handleError(_context26.t0, CheckoutErrorType.PaymentFailed);
|
|
1853
|
+
case 32:
|
|
1854
|
+
throw _context26.t0;
|
|
1855
|
+
case 33:
|
|
1769
1856
|
case "end":
|
|
1770
|
-
return
|
|
1857
|
+
return _context26.stop();
|
|
1771
1858
|
}
|
|
1772
|
-
},
|
|
1859
|
+
}, _callee26, this, [[0, 27]]);
|
|
1773
1860
|
}));
|
|
1774
|
-
function deletePaymentItemAsync(
|
|
1861
|
+
function deletePaymentItemAsync(_x17) {
|
|
1775
1862
|
return _deletePaymentItemAsync.apply(this, arguments);
|
|
1776
1863
|
}
|
|
1777
1864
|
return deletePaymentItemAsync;
|
|
1778
1865
|
}()
|
|
1779
1866
|
/**
|
|
1780
1867
|
* 批量更新当前订单的代金券支付项(覆盖更新)
|
|
1781
|
-
*
|
|
1868
|
+
*
|
|
1782
1869
|
* 删除所有现有的代金券支付项,然后添加新的代金券支付项。
|
|
1783
1870
|
* 这是一个覆盖式更新操作,确保代金券支付项的一致性。
|
|
1784
|
-
*
|
|
1871
|
+
*
|
|
1785
1872
|
* @param voucherPaymentItems 新的代金券支付项列表,每个都必须包含 voucher_id
|
|
1786
1873
|
* @throws 当前没有活跃订单时抛出错误
|
|
1787
1874
|
* @throws 支付项缺少 voucher_id 时抛出错误
|
|
@@ -1790,14 +1877,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1790
1877
|
}, {
|
|
1791
1878
|
key: "updateVoucherPaymentItemsAsync",
|
|
1792
1879
|
value: (function () {
|
|
1793
|
-
var _updateVoucherPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
1880
|
+
var _updateVoucherPaymentItemsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(voucherPaymentItems) {
|
|
1794
1881
|
var _iterator, _step, item, currentOrderId, isCurrentOrderReal, updatedOrder, voucherItems;
|
|
1795
|
-
return _regeneratorRuntime().wrap(function
|
|
1796
|
-
while (1) switch (
|
|
1882
|
+
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
1883
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
1797
1884
|
case 0:
|
|
1798
|
-
|
|
1885
|
+
_context27.prev = 0;
|
|
1799
1886
|
if (this.store.currentOrder) {
|
|
1800
|
-
|
|
1887
|
+
_context27.next = 3;
|
|
1801
1888
|
break;
|
|
1802
1889
|
}
|
|
1803
1890
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '当前没有活跃订单,无法更新代金券支付项');
|
|
@@ -1810,35 +1897,35 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1810
1897
|
|
|
1811
1898
|
// 验证所有支付项都包含 voucher_id
|
|
1812
1899
|
_iterator = _createForOfIteratorHelper(voucherPaymentItems);
|
|
1813
|
-
|
|
1900
|
+
_context27.prev = 5;
|
|
1814
1901
|
_iterator.s();
|
|
1815
1902
|
case 7:
|
|
1816
1903
|
if ((_step = _iterator.n()).done) {
|
|
1817
|
-
|
|
1904
|
+
_context27.next = 13;
|
|
1818
1905
|
break;
|
|
1819
1906
|
}
|
|
1820
1907
|
item = _step.value;
|
|
1821
1908
|
if (item.voucher_id) {
|
|
1822
|
-
|
|
1909
|
+
_context27.next = 11;
|
|
1823
1910
|
break;
|
|
1824
1911
|
}
|
|
1825
1912
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, "\u4EE3\u91D1\u5238\u652F\u4ED8\u9879\u7F3A\u5C11 voucher_id: ".concat(JSON.stringify(item)));
|
|
1826
1913
|
case 11:
|
|
1827
|
-
|
|
1914
|
+
_context27.next = 7;
|
|
1828
1915
|
break;
|
|
1829
1916
|
case 13:
|
|
1830
|
-
|
|
1917
|
+
_context27.next = 18;
|
|
1831
1918
|
break;
|
|
1832
1919
|
case 15:
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
_iterator.e(
|
|
1920
|
+
_context27.prev = 15;
|
|
1921
|
+
_context27.t0 = _context27["catch"](5);
|
|
1922
|
+
_iterator.e(_context27.t0);
|
|
1836
1923
|
case 18:
|
|
1837
|
-
|
|
1924
|
+
_context27.prev = 18;
|
|
1838
1925
|
_iterator.f();
|
|
1839
|
-
return
|
|
1926
|
+
return _context27.finish(18);
|
|
1840
1927
|
case 21:
|
|
1841
|
-
|
|
1928
|
+
_context27.next = 23;
|
|
1842
1929
|
return this.payment.updateVoucherPaymentItemsAsync(this.store.currentOrder.uuid, voucherPaymentItems);
|
|
1843
1930
|
case 23:
|
|
1844
1931
|
console.log('[Checkout] Payment模块批量更新完成');
|
|
@@ -1846,10 +1933,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1846
1933
|
// 重新从Payment模块获取最新的订单数据,确保支付项同步
|
|
1847
1934
|
currentOrderId = this.store.currentOrder.order_id; // 保存当前的订单ID
|
|
1848
1935
|
isCurrentOrderReal = currentOrderId && !this.isVirtualOrderId(currentOrderId);
|
|
1849
|
-
|
|
1936
|
+
_context27.next = 28;
|
|
1850
1937
|
return this.payment.getPaymentOrderByUuidAsync(this.store.currentOrder.uuid);
|
|
1851
1938
|
case 28:
|
|
1852
|
-
updatedOrder =
|
|
1939
|
+
updatedOrder = _context27.sent;
|
|
1853
1940
|
if (updatedOrder) {
|
|
1854
1941
|
// 如果当前订单ID是真实ID,但获取到的订单ID是虚拟ID,需要保护真实ID
|
|
1855
1942
|
if (isCurrentOrderReal && this.isVirtualOrderId(updatedOrder.order_id)) {
|
|
@@ -1880,10 +1967,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1880
1967
|
}
|
|
1881
1968
|
|
|
1882
1969
|
// 更新 stateAmount 为剩余未支付金额
|
|
1883
|
-
|
|
1970
|
+
_context27.next = 32;
|
|
1884
1971
|
return this.updateStateAmountToRemaining();
|
|
1885
1972
|
case 32:
|
|
1886
|
-
|
|
1973
|
+
_context27.next = 34;
|
|
1887
1974
|
return this.core.effects.emit(CheckoutHooks.OnPaymentStarted, {
|
|
1888
1975
|
orderUuid: this.store.currentOrder.uuid,
|
|
1889
1976
|
paymentMethodCode: 'VOUCHER_BATCH',
|
|
@@ -1894,32 +1981,32 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1894
1981
|
});
|
|
1895
1982
|
case 34:
|
|
1896
1983
|
console.log('[Checkout] 代金券支付项批量更新成功');
|
|
1897
|
-
|
|
1984
|
+
_context27.next = 43;
|
|
1898
1985
|
break;
|
|
1899
1986
|
case 37:
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
console.error('[Checkout] 批量更新代金券支付项失败:',
|
|
1903
|
-
|
|
1904
|
-
return this.handleError(
|
|
1987
|
+
_context27.prev = 37;
|
|
1988
|
+
_context27.t1 = _context27["catch"](0);
|
|
1989
|
+
console.error('[Checkout] 批量更新代金券支付项失败:', _context27.t1);
|
|
1990
|
+
_context27.next = 42;
|
|
1991
|
+
return this.handleError(_context27.t1, CheckoutErrorType.PaymentFailed);
|
|
1905
1992
|
case 42:
|
|
1906
|
-
throw
|
|
1993
|
+
throw _context27.t1;
|
|
1907
1994
|
case 43:
|
|
1908
1995
|
case "end":
|
|
1909
|
-
return
|
|
1996
|
+
return _context27.stop();
|
|
1910
1997
|
}
|
|
1911
|
-
},
|
|
1998
|
+
}, _callee27, this, [[0, 37], [5, 15, 18, 21]]);
|
|
1912
1999
|
}));
|
|
1913
|
-
function updateVoucherPaymentItemsAsync(
|
|
2000
|
+
function updateVoucherPaymentItemsAsync(_x18) {
|
|
1914
2001
|
return _updateVoucherPaymentItemsAsync.apply(this, arguments);
|
|
1915
2002
|
}
|
|
1916
2003
|
return updateVoucherPaymentItemsAsync;
|
|
1917
2004
|
}()
|
|
1918
2005
|
/**
|
|
1919
2006
|
* 修改当前订单的定金状态
|
|
1920
|
-
*
|
|
2007
|
+
*
|
|
1921
2008
|
* 更新当前订单的 is_deposit 字段,用于标识订单是否为定金订单
|
|
1922
|
-
*
|
|
2009
|
+
*
|
|
1923
2010
|
* @param isDeposit 定金状态 (1: 定金订单, 0: 全款订单)
|
|
1924
2011
|
* @throws 当前没有活跃订单时抛出错误
|
|
1925
2012
|
*/
|
|
@@ -1927,20 +2014,20 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1927
2014
|
}, {
|
|
1928
2015
|
key: "updateOrderDepositStatusAsync",
|
|
1929
2016
|
value: (function () {
|
|
1930
|
-
var _updateOrderDepositStatusAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2017
|
+
var _updateOrderDepositStatusAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(isDeposit) {
|
|
1931
2018
|
var newDepositValue, oldDepositValue, updateParams;
|
|
1932
|
-
return _regeneratorRuntime().wrap(function
|
|
1933
|
-
while (1) switch (
|
|
2019
|
+
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2020
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
1934
2021
|
case 0:
|
|
1935
|
-
|
|
2022
|
+
_context28.prev = 0;
|
|
1936
2023
|
if (!(isDeposit !== 0 && isDeposit !== 1)) {
|
|
1937
|
-
|
|
2024
|
+
_context28.next = 3;
|
|
1938
2025
|
break;
|
|
1939
2026
|
}
|
|
1940
2027
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, 'isDeposit 参数只能是 0(全款订单)或 1(定金订单)');
|
|
1941
2028
|
case 3:
|
|
1942
2029
|
if (this.store.currentOrder) {
|
|
1943
|
-
|
|
2030
|
+
_context28.next = 5;
|
|
1944
2031
|
break;
|
|
1945
2032
|
}
|
|
1946
2033
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '未找到当前订单,无法修改定金状态');
|
|
@@ -1948,11 +2035,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1948
2035
|
newDepositValue = isDeposit;
|
|
1949
2036
|
oldDepositValue = this.store.currentOrder.is_deposit; // 如果状态没有变化,直接返回
|
|
1950
2037
|
if (!(oldDepositValue === newDepositValue)) {
|
|
1951
|
-
|
|
2038
|
+
_context28.next = 10;
|
|
1952
2039
|
break;
|
|
1953
2040
|
}
|
|
1954
2041
|
console.log('[Checkout] 定金状态无变化,跳过更新');
|
|
1955
|
-
return
|
|
2042
|
+
return _context28.abrupt("return");
|
|
1956
2043
|
case 10:
|
|
1957
2044
|
console.log('[Checkout] 更新订单定金状态:', {
|
|
1958
2045
|
orderUuid: this.store.currentOrder.uuid,
|
|
@@ -1971,7 +2058,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1971
2058
|
}
|
|
1972
2059
|
|
|
1973
2060
|
// 调用 Payment 模块更新订单
|
|
1974
|
-
|
|
2061
|
+
_context28.next = 15;
|
|
1975
2062
|
return this.payment.updateOrderAsync(this.store.currentOrder.uuid, updateParams);
|
|
1976
2063
|
case 15:
|
|
1977
2064
|
// 更新本地缓存的订单对象
|
|
@@ -1983,7 +2070,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1983
2070
|
}
|
|
1984
2071
|
|
|
1985
2072
|
// 触发订单更新事件
|
|
1986
|
-
|
|
2073
|
+
_context28.next = 19;
|
|
1987
2074
|
return this.core.effects.emit(CheckoutHooks.OnOrderCreated, {
|
|
1988
2075
|
order: this.store.currentOrder,
|
|
1989
2076
|
timestamp: Date.now()
|
|
@@ -1993,32 +2080,32 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1993
2080
|
isDeposit: newDepositValue,
|
|
1994
2081
|
depositAmount: this.store.currentOrder.deposit_amount
|
|
1995
2082
|
});
|
|
1996
|
-
|
|
2083
|
+
_context28.next = 28;
|
|
1997
2084
|
break;
|
|
1998
2085
|
case 22:
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
console.error('[Checkout] 更新订单定金状态失败:',
|
|
2002
|
-
|
|
2003
|
-
return this.handleError(
|
|
2086
|
+
_context28.prev = 22;
|
|
2087
|
+
_context28.t0 = _context28["catch"](0);
|
|
2088
|
+
console.error('[Checkout] 更新订单定金状态失败:', _context28.t0);
|
|
2089
|
+
_context28.next = 27;
|
|
2090
|
+
return this.handleError(_context28.t0, CheckoutErrorType.ValidationFailed);
|
|
2004
2091
|
case 27:
|
|
2005
|
-
throw
|
|
2092
|
+
throw _context28.t0;
|
|
2006
2093
|
case 28:
|
|
2007
2094
|
case "end":
|
|
2008
|
-
return
|
|
2095
|
+
return _context28.stop();
|
|
2009
2096
|
}
|
|
2010
|
-
},
|
|
2097
|
+
}, _callee28, this, [[0, 22]]);
|
|
2011
2098
|
}));
|
|
2012
|
-
function updateOrderDepositStatusAsync(
|
|
2099
|
+
function updateOrderDepositStatusAsync(_x19) {
|
|
2013
2100
|
return _updateOrderDepositStatusAsync.apply(this, arguments);
|
|
2014
2101
|
}
|
|
2015
2102
|
return updateOrderDepositStatusAsync;
|
|
2016
2103
|
}()
|
|
2017
2104
|
/**
|
|
2018
2105
|
* 更新当前订单的客户信息
|
|
2019
|
-
*
|
|
2106
|
+
*
|
|
2020
2107
|
* 更新当前订单关联的客户信息,用于标识订单的所属客户
|
|
2021
|
-
*
|
|
2108
|
+
*
|
|
2022
2109
|
* @param customer 客户信息 (customer_id 和/或 customer_name)
|
|
2023
2110
|
* @throws 当前没有活跃订单时抛出错误
|
|
2024
2111
|
*/
|
|
@@ -2026,13 +2113,13 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2026
2113
|
}, {
|
|
2027
2114
|
key: "updateOrderCustomerAsync",
|
|
2028
2115
|
value: (function () {
|
|
2029
|
-
var _updateOrderCustomerAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2030
|
-
return _regeneratorRuntime().wrap(function
|
|
2031
|
-
while (1) switch (
|
|
2116
|
+
var _updateOrderCustomerAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(customer) {
|
|
2117
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2118
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
2032
2119
|
case 0:
|
|
2033
|
-
|
|
2120
|
+
_context29.prev = 0;
|
|
2034
2121
|
if (this.store.currentOrder) {
|
|
2035
|
-
|
|
2122
|
+
_context29.next = 3;
|
|
2036
2123
|
break;
|
|
2037
2124
|
}
|
|
2038
2125
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '未找到当前订单,无法更新客户信息');
|
|
@@ -2055,30 +2142,30 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2055
2142
|
this.store.localOrderData.customer_name = customer.customer_name;
|
|
2056
2143
|
}
|
|
2057
2144
|
console.log('[Checkout] 订单客户信息更新成功:', this.store.currentCustomer);
|
|
2058
|
-
|
|
2145
|
+
_context29.next = 15;
|
|
2059
2146
|
break;
|
|
2060
2147
|
case 9:
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
console.error('[Checkout] 更新订单客户信息失败:',
|
|
2064
|
-
|
|
2065
|
-
return this.handleError(
|
|
2148
|
+
_context29.prev = 9;
|
|
2149
|
+
_context29.t0 = _context29["catch"](0);
|
|
2150
|
+
console.error('[Checkout] 更新订单客户信息失败:', _context29.t0);
|
|
2151
|
+
_context29.next = 14;
|
|
2152
|
+
return this.handleError(_context29.t0, CheckoutErrorType.ValidationFailed);
|
|
2066
2153
|
case 14:
|
|
2067
|
-
throw
|
|
2154
|
+
throw _context29.t0;
|
|
2068
2155
|
case 15:
|
|
2069
2156
|
case "end":
|
|
2070
|
-
return
|
|
2157
|
+
return _context29.stop();
|
|
2071
2158
|
}
|
|
2072
|
-
},
|
|
2159
|
+
}, _callee29, this, [[0, 9]]);
|
|
2073
2160
|
}));
|
|
2074
|
-
function updateOrderCustomerAsync(
|
|
2161
|
+
function updateOrderCustomerAsync(_x20) {
|
|
2075
2162
|
return _updateOrderCustomerAsync.apply(this, arguments);
|
|
2076
2163
|
}
|
|
2077
2164
|
return updateOrderCustomerAsync;
|
|
2078
2165
|
}()
|
|
2079
2166
|
/**
|
|
2080
2167
|
* 获取当前订单的客户信息
|
|
2081
|
-
*
|
|
2168
|
+
*
|
|
2082
2169
|
* @returns 当前客户信息,如果没有则返回 null
|
|
2083
2170
|
*/
|
|
2084
2171
|
)
|
|
@@ -2089,65 +2176,98 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2089
2176
|
}
|
|
2090
2177
|
|
|
2091
2178
|
/**
|
|
2092
|
-
*
|
|
2093
|
-
*
|
|
2179
|
+
* 检查订单是否需要手动同步(异步版本)
|
|
2180
|
+
*
|
|
2094
2181
|
* 返回订单是否为纯代金券支付且待付金额<=0但未同步的状态
|
|
2182
|
+
* 从 Payment 模块获取最新的支付项数据
|
|
2095
2183
|
*/
|
|
2096
2184
|
}, {
|
|
2097
|
-
key: "
|
|
2098
|
-
value: function
|
|
2099
|
-
|
|
2100
|
-
var
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2185
|
+
key: "needsManualSyncAsync",
|
|
2186
|
+
value: (function () {
|
|
2187
|
+
var _needsManualSyncAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30() {
|
|
2188
|
+
var remainingAmount, remainingValue, currentPayments, allPaymentsHaveVoucherId;
|
|
2189
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2190
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
2191
|
+
case 0:
|
|
2192
|
+
_context30.prev = 0;
|
|
2193
|
+
if (!(!this.store.currentOrder || this.store.isOrderSynced)) {
|
|
2194
|
+
_context30.next = 3;
|
|
2195
|
+
break;
|
|
2196
|
+
}
|
|
2197
|
+
return _context30.abrupt("return", false);
|
|
2198
|
+
case 3:
|
|
2199
|
+
_context30.next = 5;
|
|
2200
|
+
return this.calculateRemainingAmountAsync();
|
|
2201
|
+
case 5:
|
|
2202
|
+
remainingAmount = _context30.sent;
|
|
2203
|
+
remainingValue = parseFloat(remainingAmount);
|
|
2204
|
+
if (!(remainingValue > 0)) {
|
|
2205
|
+
_context30.next = 9;
|
|
2206
|
+
break;
|
|
2207
|
+
}
|
|
2208
|
+
return _context30.abrupt("return", false);
|
|
2209
|
+
case 9:
|
|
2210
|
+
_context30.next = 11;
|
|
2211
|
+
return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid, false // 不包括已撤销的支付项
|
|
2212
|
+
);
|
|
2213
|
+
case 11:
|
|
2214
|
+
currentPayments = _context30.sent;
|
|
2215
|
+
allPaymentsHaveVoucherId = currentPayments.length > 0 && currentPayments.every(function (item) {
|
|
2216
|
+
return item.status !== 'voided' && item.voucher_id;
|
|
2217
|
+
});
|
|
2218
|
+
console.log('[Checkout] needsManualSyncAsync 检查结果:', {
|
|
2219
|
+
orderUuid: this.store.currentOrder.uuid,
|
|
2220
|
+
isOrderSynced: this.store.isOrderSynced,
|
|
2221
|
+
remainingAmount: remainingAmount,
|
|
2222
|
+
hasPayments: currentPayments.length > 0,
|
|
2223
|
+
allPaymentsHaveVoucherId: allPaymentsHaveVoucherId,
|
|
2224
|
+
needsManualSync: allPaymentsHaveVoucherId,
|
|
2225
|
+
paymentItems: currentPayments.map(function (p) {
|
|
2226
|
+
return {
|
|
2227
|
+
code: p.code,
|
|
2228
|
+
amount: p.amount,
|
|
2229
|
+
status: p.status,
|
|
2230
|
+
hasVoucherId: !!p.voucher_id
|
|
2231
|
+
};
|
|
2232
|
+
})
|
|
2233
|
+
});
|
|
2234
|
+
return _context30.abrupt("return", allPaymentsHaveVoucherId);
|
|
2235
|
+
case 17:
|
|
2236
|
+
_context30.prev = 17;
|
|
2237
|
+
_context30.t0 = _context30["catch"](0);
|
|
2238
|
+
console.error('[Checkout] needsManualSyncAsync 检查失败:', _context30.t0);
|
|
2239
|
+
return _context30.abrupt("return", false);
|
|
2240
|
+
case 21:
|
|
2241
|
+
case "end":
|
|
2242
|
+
return _context30.stop();
|
|
2243
|
+
}
|
|
2244
|
+
}, _callee30, this, [[0, 17]]);
|
|
2245
|
+
}));
|
|
2246
|
+
function needsManualSyncAsync() {
|
|
2247
|
+
return _needsManualSyncAsync.apply(this, arguments);
|
|
2129
2248
|
}
|
|
2130
|
-
|
|
2131
|
-
|
|
2249
|
+
return needsManualSyncAsync;
|
|
2250
|
+
}()
|
|
2132
2251
|
/**
|
|
2133
2252
|
* 手动同步订单到后端
|
|
2134
|
-
*
|
|
2253
|
+
*
|
|
2135
2254
|
* 用于强制同步订单到后端,特别适用于纯代金券支付完成的订单
|
|
2136
2255
|
*/
|
|
2256
|
+
)
|
|
2137
2257
|
}, {
|
|
2138
2258
|
key: "manualSyncOrderAsync",
|
|
2139
2259
|
value: (function () {
|
|
2140
|
-
var _manualSyncOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2141
|
-
var orderUuid, oldOrderId, realOrderId, finalOrderId, finalIsVirtual, _this$store$
|
|
2142
|
-
return _regeneratorRuntime().wrap(function
|
|
2143
|
-
while (1) switch (
|
|
2260
|
+
var _manualSyncOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
|
|
2261
|
+
var orderUuid, oldOrderId, realOrderId, finalOrderId, finalIsVirtual, _this$store$currentOr6, errorMessage;
|
|
2262
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2263
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
2144
2264
|
case 0:
|
|
2145
|
-
|
|
2265
|
+
_context31.prev = 0;
|
|
2146
2266
|
if (this.store.currentOrder) {
|
|
2147
|
-
|
|
2267
|
+
_context31.next = 3;
|
|
2148
2268
|
break;
|
|
2149
2269
|
}
|
|
2150
|
-
return
|
|
2270
|
+
return _context31.abrupt("return", {
|
|
2151
2271
|
success: false,
|
|
2152
2272
|
message: '当前没有活跃订单,无法同步'
|
|
2153
2273
|
});
|
|
@@ -2157,18 +2277,25 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2157
2277
|
if (this.store.isOrderSynced) {
|
|
2158
2278
|
console.log('[Checkout] 订单已同步过,将执行更新操作');
|
|
2159
2279
|
}
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2280
|
+
_context31.t0 = console;
|
|
2281
|
+
_context31.t1 = orderUuid;
|
|
2282
|
+
_context31.t2 = oldOrderId;
|
|
2283
|
+
_context31.t3 = this.store.currentOrder.total_amount;
|
|
2284
|
+
_context31.next = 12;
|
|
2285
|
+
return this.calculateRemainingAmountAsync();
|
|
2286
|
+
case 12:
|
|
2287
|
+
_context31.t4 = _context31.sent;
|
|
2288
|
+
_context31.t5 = {
|
|
2289
|
+
orderUuid: _context31.t1,
|
|
2290
|
+
orderId: _context31.t2,
|
|
2291
|
+
totalAmount: _context31.t3,
|
|
2292
|
+
remainingAmount: _context31.t4
|
|
2293
|
+
};
|
|
2294
|
+
_context31.t0.log.call(_context31.t0, '[Checkout] 开始手动同步订单到后端:', _context31.t5);
|
|
2295
|
+
_context31.next = 17;
|
|
2169
2296
|
return this.syncOrderToBackendWithReturn(true);
|
|
2170
|
-
case
|
|
2171
|
-
realOrderId =
|
|
2297
|
+
case 17:
|
|
2298
|
+
realOrderId = _context31.sent;
|
|
2172
2299
|
console.log('[Checkout] 手动同步订单完成:', {
|
|
2173
2300
|
orderUuid: orderUuid,
|
|
2174
2301
|
oldOrderId: oldOrderId,
|
|
@@ -2192,28 +2319,28 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2192
2319
|
if (realOrderId !== finalOrderId) {
|
|
2193
2320
|
console.error('[Checkout] 严重警告:返回的订单ID与存储的订单ID不一致!');
|
|
2194
2321
|
}
|
|
2195
|
-
return
|
|
2322
|
+
return _context31.abrupt("return", {
|
|
2196
2323
|
success: true,
|
|
2197
2324
|
message: '订单同步成功',
|
|
2198
2325
|
orderId: realOrderId,
|
|
2199
2326
|
// 直接返回从后端获取的真实订单ID
|
|
2200
2327
|
orderUuid: orderUuid
|
|
2201
2328
|
});
|
|
2202
|
-
case
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
console.error('[Checkout] 手动同步订单失败:',
|
|
2206
|
-
errorMessage =
|
|
2207
|
-
return
|
|
2329
|
+
case 27:
|
|
2330
|
+
_context31.prev = 27;
|
|
2331
|
+
_context31.t6 = _context31["catch"](0);
|
|
2332
|
+
console.error('[Checkout] 手动同步订单失败:', _context31.t6);
|
|
2333
|
+
errorMessage = _context31.t6 instanceof Error ? _context31.t6.message : '同步失败';
|
|
2334
|
+
return _context31.abrupt("return", {
|
|
2208
2335
|
success: false,
|
|
2209
2336
|
message: "\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(errorMessage),
|
|
2210
|
-
orderUuid: (_this$store$
|
|
2337
|
+
orderUuid: (_this$store$currentOr6 = this.store.currentOrder) === null || _this$store$currentOr6 === void 0 ? void 0 : _this$store$currentOr6.uuid
|
|
2211
2338
|
});
|
|
2212
|
-
case
|
|
2339
|
+
case 32:
|
|
2213
2340
|
case "end":
|
|
2214
|
-
return
|
|
2341
|
+
return _context31.stop();
|
|
2215
2342
|
}
|
|
2216
|
-
},
|
|
2343
|
+
}, _callee31, this, [[0, 27]]);
|
|
2217
2344
|
}));
|
|
2218
2345
|
function manualSyncOrderAsync() {
|
|
2219
2346
|
return _manualSyncOrderAsync.apply(this, arguments);
|
|
@@ -2222,7 +2349,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2222
2349
|
}()
|
|
2223
2350
|
/**
|
|
2224
2351
|
* 获取当前订单备注
|
|
2225
|
-
*
|
|
2352
|
+
*
|
|
2226
2353
|
* @returns 当前订单的备注内容,如果没有则返回空字符串
|
|
2227
2354
|
*/
|
|
2228
2355
|
)
|
|
@@ -2238,7 +2365,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2238
2365
|
|
|
2239
2366
|
/**
|
|
2240
2367
|
* 获取当前订单ID
|
|
2241
|
-
*
|
|
2368
|
+
*
|
|
2242
2369
|
* @returns 当前订单的ID,如果没有订单则返回null
|
|
2243
2370
|
*/
|
|
2244
2371
|
}, {
|
|
@@ -2250,26 +2377,171 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2250
2377
|
return this.store.currentOrder.order_id;
|
|
2251
2378
|
}
|
|
2252
2379
|
|
|
2380
|
+
/**
|
|
2381
|
+
* 获取当前订单是否已同步到后端
|
|
2382
|
+
*
|
|
2383
|
+
* @returns 当前订单是否已同步状态,如果没有订单则返回false
|
|
2384
|
+
*/
|
|
2385
|
+
}, {
|
|
2386
|
+
key: "isCurrentOrderSynced",
|
|
2387
|
+
value: function isCurrentOrderSynced() {
|
|
2388
|
+
// 如果没有当前订单,返回false
|
|
2389
|
+
if (!this.store.currentOrder) {
|
|
2390
|
+
console.log('[Checkout] 没有当前订单,同步状态为false');
|
|
2391
|
+
return false;
|
|
2392
|
+
}
|
|
2393
|
+
var syncStatus = this.store.isOrderSynced;
|
|
2394
|
+
console.log('[Checkout] 当前订单同步状态:', {
|
|
2395
|
+
orderUuid: this.store.currentOrder.uuid,
|
|
2396
|
+
orderId: this.store.currentOrder.order_id,
|
|
2397
|
+
isOrderSynced: syncStatus
|
|
2398
|
+
});
|
|
2399
|
+
return syncStatus;
|
|
2400
|
+
}
|
|
2401
|
+
|
|
2402
|
+
/**
|
|
2403
|
+
* 取消当前本地订单
|
|
2404
|
+
*
|
|
2405
|
+
* 只能取消未同步到后端的本地订单,如果订单已同步则不能取消
|
|
2406
|
+
*
|
|
2407
|
+
* @param cancelReason 取消原因(可选)
|
|
2408
|
+
* @returns 取消结果
|
|
2409
|
+
*/
|
|
2410
|
+
}, {
|
|
2411
|
+
key: "cancelCurrentOrderAsync",
|
|
2412
|
+
value: (function () {
|
|
2413
|
+
var _cancelCurrentOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(cancelReason) {
|
|
2414
|
+
var _this$store$currentOr7, _this$store$currentOr8, currentOrderUuid, currentOrderId, isOrderSynced, errorMessage;
|
|
2415
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
2416
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
2417
|
+
case 0:
|
|
2418
|
+
_context32.prev = 0;
|
|
2419
|
+
console.log('[Checkout] 开始取消当前本地订单:', {
|
|
2420
|
+
hasCurrentOrder: !!this.store.currentOrder,
|
|
2421
|
+
orderUuid: (_this$store$currentOr7 = this.store.currentOrder) === null || _this$store$currentOr7 === void 0 ? void 0 : _this$store$currentOr7.uuid,
|
|
2422
|
+
orderId: (_this$store$currentOr8 = this.store.currentOrder) === null || _this$store$currentOr8 === void 0 ? void 0 : _this$store$currentOr8.order_id,
|
|
2423
|
+
isOrderSynced: this.store.isOrderSynced,
|
|
2424
|
+
cancelReason: cancelReason
|
|
2425
|
+
});
|
|
2426
|
+
|
|
2427
|
+
// 检查是否有当前订单
|
|
2428
|
+
if (this.store.currentOrder) {
|
|
2429
|
+
_context32.next = 5;
|
|
2430
|
+
break;
|
|
2431
|
+
}
|
|
2432
|
+
console.log('[Checkout] 没有当前订单,无需取消');
|
|
2433
|
+
return _context32.abrupt("return", {
|
|
2434
|
+
success: false,
|
|
2435
|
+
message: '没有当前订单可取消'
|
|
2436
|
+
});
|
|
2437
|
+
case 5:
|
|
2438
|
+
currentOrderUuid = this.store.currentOrder.uuid;
|
|
2439
|
+
currentOrderId = this.store.currentOrder.order_id;
|
|
2440
|
+
isOrderSynced = this.store.isOrderSynced; // 检查订单是否已同步,已同步的订单不能取消
|
|
2441
|
+
if (!isOrderSynced) {
|
|
2442
|
+
_context32.next = 11;
|
|
2443
|
+
break;
|
|
2444
|
+
}
|
|
2445
|
+
console.log('[Checkout] 订单已同步到后端,不能取消:', {
|
|
2446
|
+
orderId: currentOrderId,
|
|
2447
|
+
orderUuid: currentOrderUuid
|
|
2448
|
+
});
|
|
2449
|
+
return _context32.abrupt("return", {
|
|
2450
|
+
success: false,
|
|
2451
|
+
message: '订单已同步到后端,无法取消',
|
|
2452
|
+
orderId: currentOrderId
|
|
2453
|
+
});
|
|
2454
|
+
case 11:
|
|
2455
|
+
console.log('[Checkout] 订单尚未同步,可以取消');
|
|
2456
|
+
|
|
2457
|
+
// 删除本地订单数据
|
|
2458
|
+
_context32.prev = 12;
|
|
2459
|
+
console.log('[Checkout] 删除本地订单数据');
|
|
2460
|
+
_context32.next = 16;
|
|
2461
|
+
return this.payment.deletePaymentOrderAsync(currentOrderUuid);
|
|
2462
|
+
case 16:
|
|
2463
|
+
console.log('[Checkout] 本地订单数据删除成功');
|
|
2464
|
+
_context32.next = 22;
|
|
2465
|
+
break;
|
|
2466
|
+
case 19:
|
|
2467
|
+
_context32.prev = 19;
|
|
2468
|
+
_context32.t0 = _context32["catch"](12);
|
|
2469
|
+
console.warn('[Checkout] 删除本地订单数据失败,但继续执行:', _context32.t0);
|
|
2470
|
+
case 22:
|
|
2471
|
+
// 清理订单相关状态,确保正确释放 currentOrder
|
|
2472
|
+
console.log('[Checkout] 清理订单相关状态');
|
|
2473
|
+
this.store.currentOrder = undefined; // 释放 currentOrder
|
|
2474
|
+
this.store.localOrderData = undefined;
|
|
2475
|
+
this.store.stateAmount = '0.00';
|
|
2476
|
+
this.store.isOrderSynced = false;
|
|
2477
|
+
this.store.currentCustomer = undefined;
|
|
2478
|
+
|
|
2479
|
+
// 清理钱包缓存
|
|
2480
|
+
this.payment.wallet.clearAllCache();
|
|
2481
|
+
console.log('[Checkout] 订单状态清理完成,currentOrder已释放');
|
|
2482
|
+
|
|
2483
|
+
// 触发订单取消事件
|
|
2484
|
+
_context32.next = 32;
|
|
2485
|
+
return this.core.effects.emit(CheckoutHooks.OnOrderCancelled, {
|
|
2486
|
+
orderUuid: currentOrderUuid,
|
|
2487
|
+
orderId: currentOrderId,
|
|
2488
|
+
cancelReason: cancelReason,
|
|
2489
|
+
wasSynced: false,
|
|
2490
|
+
// 只有未同步订单可以被取消
|
|
2491
|
+
timestamp: Date.now()
|
|
2492
|
+
});
|
|
2493
|
+
case 32:
|
|
2494
|
+
console.log('[Checkout] 本地订单取消完成:', {
|
|
2495
|
+
orderUuid: currentOrderUuid,
|
|
2496
|
+
orderId: currentOrderId,
|
|
2497
|
+
cancelReason: cancelReason
|
|
2498
|
+
});
|
|
2499
|
+
return _context32.abrupt("return", {
|
|
2500
|
+
success: true,
|
|
2501
|
+
message: '本地订单已成功取消',
|
|
2502
|
+
orderId: currentOrderId
|
|
2503
|
+
});
|
|
2504
|
+
case 36:
|
|
2505
|
+
_context32.prev = 36;
|
|
2506
|
+
_context32.t1 = _context32["catch"](0);
|
|
2507
|
+
console.error('[Checkout] 取消本地订单失败:', _context32.t1);
|
|
2508
|
+
errorMessage = _context32.t1 instanceof Error ? _context32.t1.message : '未知错误';
|
|
2509
|
+
return _context32.abrupt("return", {
|
|
2510
|
+
success: false,
|
|
2511
|
+
message: "\u53D6\u6D88\u8BA2\u5355\u5931\u8D25: ".concat(errorMessage)
|
|
2512
|
+
});
|
|
2513
|
+
case 41:
|
|
2514
|
+
case "end":
|
|
2515
|
+
return _context32.stop();
|
|
2516
|
+
}
|
|
2517
|
+
}, _callee32, this, [[0, 36], [12, 19]]);
|
|
2518
|
+
}));
|
|
2519
|
+
function cancelCurrentOrderAsync(_x21) {
|
|
2520
|
+
return _cancelCurrentOrderAsync.apply(this, arguments);
|
|
2521
|
+
}
|
|
2522
|
+
return cancelCurrentOrderAsync;
|
|
2523
|
+
}()
|
|
2253
2524
|
/**
|
|
2254
2525
|
* 保存订单并稍后支付
|
|
2255
|
-
*
|
|
2526
|
+
*
|
|
2256
2527
|
* 将当前订单保存到后端,但排除代金券类支付项(voucher_id),
|
|
2257
2528
|
* 适用于用户想要保存订单但稍后完成支付的场景
|
|
2258
2529
|
*/
|
|
2530
|
+
)
|
|
2259
2531
|
}, {
|
|
2260
2532
|
key: "saveForLaterPaymentAsync",
|
|
2261
2533
|
value: (function () {
|
|
2262
|
-
var _saveForLaterPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2263
|
-
var orderUuid, currentOrderId, allPaymentItems, filteredPaymentItems, voucherItems, realOrderId, finalOrderId, _this$store$
|
|
2264
|
-
return _regeneratorRuntime().wrap(function
|
|
2265
|
-
while (1) switch (
|
|
2534
|
+
var _saveForLaterPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
|
|
2535
|
+
var orderUuid, currentOrderId, allPaymentItems, filteredPaymentItems, voucherItems, realOrderId, finalOrderId, _this$store$currentOr9, errorMessage;
|
|
2536
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
2537
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
2266
2538
|
case 0:
|
|
2267
|
-
|
|
2539
|
+
_context33.prev = 0;
|
|
2268
2540
|
if (this.store.currentOrder) {
|
|
2269
|
-
|
|
2541
|
+
_context33.next = 3;
|
|
2270
2542
|
break;
|
|
2271
2543
|
}
|
|
2272
|
-
return
|
|
2544
|
+
return _context33.abrupt("return", {
|
|
2273
2545
|
success: false,
|
|
2274
2546
|
message: '当前没有活跃订单,无法保存'
|
|
2275
2547
|
});
|
|
@@ -2283,10 +2555,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2283
2555
|
});
|
|
2284
2556
|
|
|
2285
2557
|
// 获取当前订单的所有支付项
|
|
2286
|
-
|
|
2558
|
+
_context33.next = 8;
|
|
2287
2559
|
return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid);
|
|
2288
2560
|
case 8:
|
|
2289
|
-
allPaymentItems =
|
|
2561
|
+
allPaymentItems = _context33.sent;
|
|
2290
2562
|
// 过滤掉带有 voucher_id 的支付项(代金券类支付项)
|
|
2291
2563
|
filteredPaymentItems = allPaymentItems.filter(function (payment) {
|
|
2292
2564
|
return !payment.voucher_id || payment.voucher_id.trim() === '';
|
|
@@ -2316,10 +2588,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2316
2588
|
});
|
|
2317
2589
|
|
|
2318
2590
|
// 调用同步方法,传入过滤后的支付项
|
|
2319
|
-
|
|
2591
|
+
_context33.next = 14;
|
|
2320
2592
|
return this.syncOrderToBackendWithReturn(false, filteredPaymentItems);
|
|
2321
2593
|
case 14:
|
|
2322
|
-
realOrderId =
|
|
2594
|
+
realOrderId = _context33.sent;
|
|
2323
2595
|
console.log('[Checkout] 保存订单完成:', {
|
|
2324
2596
|
orderUuid: orderUuid,
|
|
2325
2597
|
oldOrderId: currentOrderId,
|
|
@@ -2336,27 +2608,27 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2336
2608
|
是否一致: realOrderId === finalOrderId,
|
|
2337
2609
|
同步状态: this.store.isOrderSynced
|
|
2338
2610
|
});
|
|
2339
|
-
return
|
|
2611
|
+
return _context33.abrupt("return", {
|
|
2340
2612
|
success: true,
|
|
2341
2613
|
message: '订单保存成功,可稍后继续支付',
|
|
2342
2614
|
orderId: realOrderId,
|
|
2343
2615
|
orderUuid: orderUuid
|
|
2344
2616
|
});
|
|
2345
2617
|
case 21:
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
console.error('[Checkout] 保存订单失败:',
|
|
2349
|
-
errorMessage =
|
|
2350
|
-
return
|
|
2618
|
+
_context33.prev = 21;
|
|
2619
|
+
_context33.t0 = _context33["catch"](0);
|
|
2620
|
+
console.error('[Checkout] 保存订单失败:', _context33.t0);
|
|
2621
|
+
errorMessage = _context33.t0 instanceof Error ? _context33.t0.message : '保存失败';
|
|
2622
|
+
return _context33.abrupt("return", {
|
|
2351
2623
|
success: false,
|
|
2352
2624
|
message: "\u8BA2\u5355\u4FDD\u5B58\u5931\u8D25: ".concat(errorMessage),
|
|
2353
|
-
orderUuid: (_this$store$
|
|
2625
|
+
orderUuid: (_this$store$currentOr9 = this.store.currentOrder) === null || _this$store$currentOr9 === void 0 ? void 0 : _this$store$currentOr9.uuid
|
|
2354
2626
|
});
|
|
2355
2627
|
case 26:
|
|
2356
2628
|
case "end":
|
|
2357
|
-
return
|
|
2629
|
+
return _context33.stop();
|
|
2358
2630
|
}
|
|
2359
|
-
},
|
|
2631
|
+
}, _callee33, this, [[0, 21]]);
|
|
2360
2632
|
}));
|
|
2361
2633
|
function saveForLaterPaymentAsync() {
|
|
2362
2634
|
return _saveForLaterPaymentAsync.apply(this, arguments);
|
|
@@ -2365,7 +2637,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2365
2637
|
}()
|
|
2366
2638
|
/**
|
|
2367
2639
|
* 获取当前商店折扣金额
|
|
2368
|
-
*
|
|
2640
|
+
*
|
|
2369
2641
|
* @returns 当前的商店折扣金额,如果没有则返回0
|
|
2370
2642
|
*/
|
|
2371
2643
|
)
|
|
@@ -2392,23 +2664,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2392
2664
|
|
|
2393
2665
|
/**
|
|
2394
2666
|
* 更新订单商店折扣
|
|
2395
|
-
*
|
|
2667
|
+
*
|
|
2396
2668
|
* 同时更新cartSummary和localOrderData中的shop_discount值
|
|
2397
|
-
*
|
|
2669
|
+
*
|
|
2398
2670
|
* @param discountAmount 商店折扣金额
|
|
2399
2671
|
*/
|
|
2400
2672
|
}, {
|
|
2401
2673
|
key: "updateShopDiscountAsync",
|
|
2402
2674
|
value: (function () {
|
|
2403
|
-
var _updateShopDiscountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2404
|
-
var _this$store$
|
|
2405
|
-
return _regeneratorRuntime().wrap(function
|
|
2406
|
-
while (1) switch (
|
|
2675
|
+
var _updateShopDiscountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(discountAmount) {
|
|
2676
|
+
var _this$store$currentOr10, _this$store$currentOr11, oldDiscount, shopDiscountItem, updatedAmountInfo;
|
|
2677
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
2678
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
2407
2679
|
case 0:
|
|
2408
|
-
|
|
2680
|
+
_context34.prev = 0;
|
|
2409
2681
|
oldDiscount = this.getShopDiscount();
|
|
2410
2682
|
console.log('[Checkout] 更新商店折扣:', {
|
|
2411
|
-
orderUuid: (_this$store$
|
|
2683
|
+
orderUuid: (_this$store$currentOr10 = this.store.currentOrder) === null || _this$store$currentOr10 === void 0 ? void 0 : _this$store$currentOr10.uuid,
|
|
2412
2684
|
oldDiscount: oldDiscount,
|
|
2413
2685
|
newDiscount: discountAmount
|
|
2414
2686
|
});
|
|
@@ -2453,12 +2725,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2453
2725
|
}
|
|
2454
2726
|
|
|
2455
2727
|
// 4. 更新 stateAmount 为剩余未支付金额
|
|
2456
|
-
|
|
2728
|
+
_context34.next = 8;
|
|
2457
2729
|
return this.updateStateAmountToRemaining();
|
|
2458
2730
|
case 8:
|
|
2459
|
-
|
|
2731
|
+
_context34.next = 10;
|
|
2460
2732
|
return this.core.effects.emit(CheckoutHooks.OnShopDiscountChanged, {
|
|
2461
|
-
orderUuid: (_this$store$
|
|
2733
|
+
orderUuid: (_this$store$currentOr11 = this.store.currentOrder) === null || _this$store$currentOr11 === void 0 ? void 0 : _this$store$currentOr11.uuid,
|
|
2462
2734
|
oldDiscount: oldDiscount,
|
|
2463
2735
|
newDiscount: discountAmount,
|
|
2464
2736
|
timestamp: Date.now()
|
|
@@ -2468,50 +2740,50 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2468
2740
|
oldDiscount: oldDiscount,
|
|
2469
2741
|
newDiscount: discountAmount
|
|
2470
2742
|
});
|
|
2471
|
-
|
|
2743
|
+
_context34.next = 19;
|
|
2472
2744
|
break;
|
|
2473
2745
|
case 13:
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
console.error('[Checkout] 更新商店折扣失败:',
|
|
2477
|
-
|
|
2478
|
-
return this.handleError(
|
|
2746
|
+
_context34.prev = 13;
|
|
2747
|
+
_context34.t0 = _context34["catch"](0);
|
|
2748
|
+
console.error('[Checkout] 更新商店折扣失败:', _context34.t0);
|
|
2749
|
+
_context34.next = 18;
|
|
2750
|
+
return this.handleError(_context34.t0, CheckoutErrorType.ValidationFailed);
|
|
2479
2751
|
case 18:
|
|
2480
|
-
throw
|
|
2752
|
+
throw _context34.t0;
|
|
2481
2753
|
case 19:
|
|
2482
2754
|
case "end":
|
|
2483
|
-
return
|
|
2755
|
+
return _context34.stop();
|
|
2484
2756
|
}
|
|
2485
|
-
},
|
|
2757
|
+
}, _callee34, this, [[0, 13]]);
|
|
2486
2758
|
}));
|
|
2487
|
-
function updateShopDiscountAsync(
|
|
2759
|
+
function updateShopDiscountAsync(_x22) {
|
|
2488
2760
|
return _updateShopDiscountAsync.apply(this, arguments);
|
|
2489
2761
|
}
|
|
2490
2762
|
return updateShopDiscountAsync;
|
|
2491
2763
|
}()
|
|
2492
2764
|
/**
|
|
2493
2765
|
* 更新订单备注
|
|
2494
|
-
*
|
|
2766
|
+
*
|
|
2495
2767
|
* @param note 订单备注内容
|
|
2496
2768
|
*/
|
|
2497
2769
|
)
|
|
2498
2770
|
}, {
|
|
2499
2771
|
key: "updateOrderNoteAsync",
|
|
2500
2772
|
value: (function () {
|
|
2501
|
-
var _updateOrderNoteAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2502
|
-
var _this$store$
|
|
2503
|
-
return _regeneratorRuntime().wrap(function
|
|
2504
|
-
while (1) switch (
|
|
2773
|
+
var _updateOrderNoteAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(note) {
|
|
2774
|
+
var _this$store$currentOr12, _this$store$currentOr13, oldNote, orderInPayment;
|
|
2775
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
2776
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
2505
2777
|
case 0:
|
|
2506
|
-
|
|
2778
|
+
_context35.prev = 0;
|
|
2507
2779
|
if (this.store.localOrderData) {
|
|
2508
|
-
|
|
2780
|
+
_context35.next = 3;
|
|
2509
2781
|
break;
|
|
2510
2782
|
}
|
|
2511
2783
|
throw createCheckoutError(CheckoutErrorType.ValidationFailed, '没有本地订单数据,无法更新备注');
|
|
2512
2784
|
case 3:
|
|
2513
2785
|
console.log('[Checkout] 更新订单备注:', {
|
|
2514
|
-
orderUuid: (_this$store$
|
|
2786
|
+
orderUuid: (_this$store$currentOr12 = this.store.currentOrder) === null || _this$store$currentOr12 === void 0 ? void 0 : _this$store$currentOr12.uuid,
|
|
2515
2787
|
oldNote: this.store.localOrderData.shop_note,
|
|
2516
2788
|
newNote: note
|
|
2517
2789
|
});
|
|
@@ -2522,29 +2794,29 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2522
2794
|
|
|
2523
2795
|
// 如果有当前订单,也同步到Payment模块中的订单数据
|
|
2524
2796
|
if (!this.store.currentOrder) {
|
|
2525
|
-
|
|
2797
|
+
_context35.next = 17;
|
|
2526
2798
|
break;
|
|
2527
2799
|
}
|
|
2528
|
-
|
|
2529
|
-
|
|
2800
|
+
_context35.prev = 7;
|
|
2801
|
+
_context35.next = 10;
|
|
2530
2802
|
return this.payment.getPaymentOrderByUuidAsync(this.store.currentOrder.uuid);
|
|
2531
2803
|
case 10:
|
|
2532
|
-
orderInPayment =
|
|
2804
|
+
orderInPayment = _context35.sent;
|
|
2533
2805
|
if (orderInPayment && orderInPayment.note !== undefined) {
|
|
2534
2806
|
// 使用Payment模块的更新方法(如果有的话)
|
|
2535
2807
|
// 这里可能需要根据Payment模块的实际API来调整
|
|
2536
2808
|
console.log('[Checkout] 同步备注到Payment模块的订单数据中');
|
|
2537
2809
|
}
|
|
2538
|
-
|
|
2810
|
+
_context35.next = 17;
|
|
2539
2811
|
break;
|
|
2540
2812
|
case 14:
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
console.warn('[Checkout] 同步备注到Payment模块失败,但本地更新成功:',
|
|
2813
|
+
_context35.prev = 14;
|
|
2814
|
+
_context35.t0 = _context35["catch"](7);
|
|
2815
|
+
console.warn('[Checkout] 同步备注到Payment模块失败,但本地更新成功:', _context35.t0);
|
|
2544
2816
|
case 17:
|
|
2545
|
-
|
|
2817
|
+
_context35.next = 19;
|
|
2546
2818
|
return this.core.effects.emit(CheckoutHooks.OnOrderNoteChanged, {
|
|
2547
|
-
orderUuid: (_this$store$
|
|
2819
|
+
orderUuid: (_this$store$currentOr13 = this.store.currentOrder) === null || _this$store$currentOr13 === void 0 ? void 0 : _this$store$currentOr13.uuid,
|
|
2548
2820
|
oldNote: oldNote,
|
|
2549
2821
|
newNote: note,
|
|
2550
2822
|
timestamp: Date.now()
|
|
@@ -2554,23 +2826,23 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2554
2826
|
oldNote: oldNote,
|
|
2555
2827
|
newNote: note
|
|
2556
2828
|
});
|
|
2557
|
-
|
|
2829
|
+
_context35.next = 28;
|
|
2558
2830
|
break;
|
|
2559
2831
|
case 22:
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
console.error('[Checkout] 更新订单备注失败:',
|
|
2563
|
-
|
|
2564
|
-
return this.handleError(
|
|
2832
|
+
_context35.prev = 22;
|
|
2833
|
+
_context35.t1 = _context35["catch"](0);
|
|
2834
|
+
console.error('[Checkout] 更新订单备注失败:', _context35.t1);
|
|
2835
|
+
_context35.next = 27;
|
|
2836
|
+
return this.handleError(_context35.t1, CheckoutErrorType.ValidationFailed);
|
|
2565
2837
|
case 27:
|
|
2566
|
-
throw
|
|
2838
|
+
throw _context35.t1;
|
|
2567
2839
|
case 28:
|
|
2568
2840
|
case "end":
|
|
2569
|
-
return
|
|
2841
|
+
return _context35.stop();
|
|
2570
2842
|
}
|
|
2571
|
-
},
|
|
2843
|
+
}, _callee35, this, [[0, 22], [7, 14]]);
|
|
2572
2844
|
}));
|
|
2573
|
-
function updateOrderNoteAsync(
|
|
2845
|
+
function updateOrderNoteAsync(_x23) {
|
|
2574
2846
|
return _updateOrderNoteAsync.apply(this, arguments);
|
|
2575
2847
|
}
|
|
2576
2848
|
return updateOrderNoteAsync;
|
|
@@ -2582,14 +2854,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2582
2854
|
}, {
|
|
2583
2855
|
key: "setStatus",
|
|
2584
2856
|
value: (function () {
|
|
2585
|
-
var _setStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2857
|
+
var _setStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(status) {
|
|
2586
2858
|
var oldStatus;
|
|
2587
|
-
return _regeneratorRuntime().wrap(function
|
|
2588
|
-
while (1) switch (
|
|
2859
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
2860
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
2589
2861
|
case 0:
|
|
2590
2862
|
oldStatus = this.store.status;
|
|
2591
2863
|
this.store.status = status;
|
|
2592
|
-
|
|
2864
|
+
_context36.next = 4;
|
|
2593
2865
|
return this.core.effects.emit(CheckoutHooks.OnStatusChanged, {
|
|
2594
2866
|
oldStatus: oldStatus,
|
|
2595
2867
|
newStatus: status,
|
|
@@ -2597,11 +2869,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2597
2869
|
});
|
|
2598
2870
|
case 4:
|
|
2599
2871
|
case "end":
|
|
2600
|
-
return
|
|
2872
|
+
return _context36.stop();
|
|
2601
2873
|
}
|
|
2602
|
-
},
|
|
2874
|
+
}, _callee36, this);
|
|
2603
2875
|
}));
|
|
2604
|
-
function setStatus(
|
|
2876
|
+
function setStatus(_x24) {
|
|
2605
2877
|
return _setStatus.apply(this, arguments);
|
|
2606
2878
|
}
|
|
2607
2879
|
return setStatus;
|
|
@@ -2613,14 +2885,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2613
2885
|
}, {
|
|
2614
2886
|
key: "setStep",
|
|
2615
2887
|
value: (function () {
|
|
2616
|
-
var _setStep = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2888
|
+
var _setStep = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(step) {
|
|
2617
2889
|
var oldStep;
|
|
2618
|
-
return _regeneratorRuntime().wrap(function
|
|
2619
|
-
while (1) switch (
|
|
2890
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
2891
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
2620
2892
|
case 0:
|
|
2621
2893
|
oldStep = this.store.step;
|
|
2622
2894
|
this.store.step = step;
|
|
2623
|
-
|
|
2895
|
+
_context37.next = 4;
|
|
2624
2896
|
return this.core.effects.emit(CheckoutHooks.OnStepChanged, {
|
|
2625
2897
|
oldStep: oldStep,
|
|
2626
2898
|
newStep: step,
|
|
@@ -2628,11 +2900,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2628
2900
|
});
|
|
2629
2901
|
case 4:
|
|
2630
2902
|
case "end":
|
|
2631
|
-
return
|
|
2903
|
+
return _context37.stop();
|
|
2632
2904
|
}
|
|
2633
|
-
},
|
|
2905
|
+
}, _callee37, this);
|
|
2634
2906
|
}));
|
|
2635
|
-
function setStep(
|
|
2907
|
+
function setStep(_x25) {
|
|
2636
2908
|
return _setStep.apply(this, arguments);
|
|
2637
2909
|
}
|
|
2638
2910
|
return setStep;
|
|
@@ -2644,17 +2916,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2644
2916
|
}, {
|
|
2645
2917
|
key: "handleError",
|
|
2646
2918
|
value: (function () {
|
|
2647
|
-
var _handleError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2919
|
+
var _handleError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(error, type) {
|
|
2648
2920
|
var checkoutError;
|
|
2649
|
-
return _regeneratorRuntime().wrap(function
|
|
2650
|
-
while (1) switch (
|
|
2921
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
2922
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
2651
2923
|
case 0:
|
|
2652
2924
|
checkoutError = error instanceof Error && 'type' in error ? error : createCheckoutError(type, error.message, error);
|
|
2653
2925
|
this.store.lastError = checkoutError;
|
|
2654
|
-
|
|
2926
|
+
_context38.next = 4;
|
|
2655
2927
|
return this.setStatus(CheckoutStatus.Error);
|
|
2656
2928
|
case 4:
|
|
2657
|
-
|
|
2929
|
+
_context38.next = 6;
|
|
2658
2930
|
return this.core.effects.emit(CheckoutHooks.OnError, {
|
|
2659
2931
|
error: checkoutError,
|
|
2660
2932
|
context: {
|
|
@@ -2667,11 +2939,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2667
2939
|
console.error('[Checkout] 错误:', checkoutError);
|
|
2668
2940
|
case 7:
|
|
2669
2941
|
case "end":
|
|
2670
|
-
return
|
|
2942
|
+
return _context38.stop();
|
|
2671
2943
|
}
|
|
2672
|
-
},
|
|
2944
|
+
}, _callee38, this);
|
|
2673
2945
|
}));
|
|
2674
|
-
function handleError(
|
|
2946
|
+
function handleError(_x26, _x27) {
|
|
2675
2947
|
return _handleError.apply(this, arguments);
|
|
2676
2948
|
}
|
|
2677
2949
|
return handleError;
|
|
@@ -2683,34 +2955,34 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2683
2955
|
}, {
|
|
2684
2956
|
key: "handlePaymentSuccess",
|
|
2685
2957
|
value: (function () {
|
|
2686
|
-
var _handlePaymentSuccess = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2687
|
-
var _this$store$
|
|
2688
|
-
return _regeneratorRuntime().wrap(function
|
|
2689
|
-
while (1) switch (
|
|
2958
|
+
var _handlePaymentSuccess = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(data) {
|
|
2959
|
+
var _this$store$currentOr14;
|
|
2960
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
2961
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
2690
2962
|
case 0:
|
|
2691
|
-
|
|
2963
|
+
_context39.next = 2;
|
|
2692
2964
|
return this.setStatus(CheckoutStatus.PaymentCompleted);
|
|
2693
2965
|
case 2:
|
|
2694
|
-
|
|
2966
|
+
_context39.next = 4;
|
|
2695
2967
|
return this.updateStateAmountToRemaining();
|
|
2696
2968
|
case 4:
|
|
2697
|
-
|
|
2969
|
+
_context39.next = 6;
|
|
2698
2970
|
return this.core.effects.emit(CheckoutHooks.OnPaymentSuccess, {
|
|
2699
2971
|
orderUuid: data.orderUuid,
|
|
2700
2972
|
paymentMethodCode: '',
|
|
2701
|
-
amount: ((_this$store$
|
|
2973
|
+
amount: ((_this$store$currentOr14 = this.store.currentOrder) === null || _this$store$currentOr14 === void 0 ? void 0 : _this$store$currentOr14.total_amount) || '0',
|
|
2702
2974
|
timestamp: data.timestamp
|
|
2703
2975
|
});
|
|
2704
2976
|
case 6:
|
|
2705
|
-
|
|
2977
|
+
_context39.next = 8;
|
|
2706
2978
|
return this.completeCheckoutAsync();
|
|
2707
2979
|
case 8:
|
|
2708
2980
|
case "end":
|
|
2709
|
-
return
|
|
2981
|
+
return _context39.stop();
|
|
2710
2982
|
}
|
|
2711
|
-
},
|
|
2983
|
+
}, _callee39, this);
|
|
2712
2984
|
}));
|
|
2713
|
-
function handlePaymentSuccess(
|
|
2985
|
+
function handlePaymentSuccess(_x28) {
|
|
2714
2986
|
return _handlePaymentSuccess.apply(this, arguments);
|
|
2715
2987
|
}
|
|
2716
2988
|
return handlePaymentSuccess;
|
|
@@ -2722,30 +2994,30 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2722
2994
|
}, {
|
|
2723
2995
|
key: "handlePaymentError",
|
|
2724
2996
|
value: (function () {
|
|
2725
|
-
var _handlePaymentError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2726
|
-
var _this$store$
|
|
2997
|
+
var _handlePaymentError = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(data) {
|
|
2998
|
+
var _this$store$currentOr15;
|
|
2727
2999
|
var error;
|
|
2728
|
-
return _regeneratorRuntime().wrap(function
|
|
2729
|
-
while (1) switch (
|
|
3000
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
3001
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
2730
3002
|
case 0:
|
|
2731
3003
|
error = createCheckoutError(CheckoutErrorType.PaymentFailed, data.error || '支付同步失败');
|
|
2732
|
-
|
|
3004
|
+
_context40.next = 3;
|
|
2733
3005
|
return this.handleError(error instanceof Error ? error : new Error(String(error)), CheckoutErrorType.PaymentFailed);
|
|
2734
3006
|
case 3:
|
|
2735
|
-
|
|
3007
|
+
_context40.next = 5;
|
|
2736
3008
|
return this.core.effects.emit(CheckoutHooks.OnPaymentFailed, {
|
|
2737
3009
|
orderUuid: data.orderUuid,
|
|
2738
3010
|
paymentMethodCode: '',
|
|
2739
|
-
amount: ((_this$store$
|
|
3011
|
+
amount: ((_this$store$currentOr15 = this.store.currentOrder) === null || _this$store$currentOr15 === void 0 ? void 0 : _this$store$currentOr15.total_amount) || '0',
|
|
2740
3012
|
timestamp: data.timestamp
|
|
2741
3013
|
});
|
|
2742
3014
|
case 5:
|
|
2743
3015
|
case "end":
|
|
2744
|
-
return
|
|
3016
|
+
return _context40.stop();
|
|
2745
3017
|
}
|
|
2746
|
-
},
|
|
3018
|
+
}, _callee40, this);
|
|
2747
3019
|
}));
|
|
2748
|
-
function handlePaymentError(
|
|
3020
|
+
function handlePaymentError(_x29) {
|
|
2749
3021
|
return _handlePaymentError.apply(this, arguments);
|
|
2750
3022
|
}
|
|
2751
3023
|
return handlePaymentError;
|
|
@@ -2757,18 +3029,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2757
3029
|
}, {
|
|
2758
3030
|
key: "validateCheckoutParams",
|
|
2759
3031
|
value: (function () {
|
|
2760
|
-
var _validateCheckoutParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2761
|
-
return _regeneratorRuntime().wrap(function
|
|
2762
|
-
while (1) switch (
|
|
3032
|
+
var _validateCheckoutParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(params) {
|
|
3033
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
3034
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
2763
3035
|
case 0:
|
|
2764
|
-
return
|
|
3036
|
+
return _context41.abrupt("return", validateCheckoutData(params));
|
|
2765
3037
|
case 1:
|
|
2766
3038
|
case "end":
|
|
2767
|
-
return
|
|
3039
|
+
return _context41.stop();
|
|
2768
3040
|
}
|
|
2769
|
-
},
|
|
3041
|
+
}, _callee41);
|
|
2770
3042
|
}));
|
|
2771
|
-
function validateCheckoutParams(
|
|
3043
|
+
function validateCheckoutParams(_x30) {
|
|
2772
3044
|
return _validateCheckoutParams.apply(this, arguments);
|
|
2773
3045
|
}
|
|
2774
3046
|
return validateCheckoutParams;
|
|
@@ -2780,10 +3052,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2780
3052
|
}, {
|
|
2781
3053
|
key: "validateLocalOrderData",
|
|
2782
3054
|
value: (function () {
|
|
2783
|
-
var _validateLocalOrderData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3055
|
+
var _validateLocalOrderData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(orderData) {
|
|
3056
|
+
var _orderData$relation_p;
|
|
2784
3057
|
var errors;
|
|
2785
|
-
return _regeneratorRuntime().wrap(function
|
|
2786
|
-
while (1) switch (
|
|
3058
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
3059
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
2787
3060
|
case 0:
|
|
2788
3061
|
errors = []; // 验证基本字段
|
|
2789
3062
|
if (!orderData.type) {
|
|
@@ -2792,7 +3065,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2792
3065
|
if (!orderData.platform) {
|
|
2793
3066
|
errors.push('平台信息不能为空');
|
|
2794
3067
|
}
|
|
2795
|
-
if (!orderData.bookings || orderData.bookings.length === 0) {
|
|
3068
|
+
if ((!orderData.bookings || orderData.bookings.length === 0) && !(orderData !== null && orderData !== void 0 && (_orderData$relation_p = orderData.relation_products) !== null && _orderData$relation_p !== void 0 && _orderData$relation_p.length)) {
|
|
2796
3069
|
errors.push('预订信息不能为空');
|
|
2797
3070
|
}
|
|
2798
3071
|
|
|
@@ -2810,17 +3083,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2810
3083
|
}
|
|
2811
3084
|
});
|
|
2812
3085
|
}
|
|
2813
|
-
return
|
|
3086
|
+
return _context42.abrupt("return", {
|
|
2814
3087
|
valid: errors.length === 0,
|
|
2815
3088
|
errors: errors
|
|
2816
3089
|
});
|
|
2817
3090
|
case 6:
|
|
2818
3091
|
case "end":
|
|
2819
|
-
return
|
|
3092
|
+
return _context42.stop();
|
|
2820
3093
|
}
|
|
2821
|
-
},
|
|
3094
|
+
}, _callee42);
|
|
2822
3095
|
}));
|
|
2823
|
-
function validateLocalOrderData(
|
|
3096
|
+
function validateLocalOrderData(_x31) {
|
|
2824
3097
|
return _validateLocalOrderData.apply(this, arguments);
|
|
2825
3098
|
}
|
|
2826
3099
|
return validateLocalOrderData;
|
|
@@ -2839,7 +3112,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2839
3112
|
|
|
2840
3113
|
/**
|
|
2841
3114
|
* 格式化日期时间为 YYYY-MM-DD hh:mm:ss 格式
|
|
2842
|
-
*
|
|
3115
|
+
*
|
|
2843
3116
|
* @param date 要格式化的日期对象
|
|
2844
3117
|
* @returns 格式化后的日期时间字符串
|
|
2845
3118
|
*/
|
|
@@ -2918,31 +3191,31 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2918
3191
|
}, {
|
|
2919
3192
|
key: "preloadPaymentMethods",
|
|
2920
3193
|
value: (function () {
|
|
2921
|
-
var _preloadPaymentMethods = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3194
|
+
var _preloadPaymentMethods = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43() {
|
|
2922
3195
|
var methods;
|
|
2923
|
-
return _regeneratorRuntime().wrap(function
|
|
2924
|
-
while (1) switch (
|
|
3196
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
3197
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
2925
3198
|
case 0:
|
|
2926
|
-
|
|
3199
|
+
_context43.prev = 0;
|
|
2927
3200
|
console.log('[Checkout] 预加载支付方式...');
|
|
2928
|
-
|
|
3201
|
+
_context43.next = 4;
|
|
2929
3202
|
return this.payment.getPayMethodListAsync();
|
|
2930
3203
|
case 4:
|
|
2931
|
-
methods =
|
|
3204
|
+
methods = _context43.sent;
|
|
2932
3205
|
this.store.paymentMethods = methods;
|
|
2933
3206
|
console.log("[Checkout] \u9884\u52A0\u8F7D\u5B8C\u6210\uFF0C\u5171 ".concat(methods.length, " \u79CD\u652F\u4ED8\u65B9\u5F0F"));
|
|
2934
|
-
|
|
3207
|
+
_context43.next = 13;
|
|
2935
3208
|
break;
|
|
2936
3209
|
case 9:
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
console.error('[Checkout] 预加载支付方式失败:',
|
|
3210
|
+
_context43.prev = 9;
|
|
3211
|
+
_context43.t0 = _context43["catch"](0);
|
|
3212
|
+
console.error('[Checkout] 预加载支付方式失败:', _context43.t0);
|
|
2940
3213
|
this.store.paymentMethods = [];
|
|
2941
3214
|
case 13:
|
|
2942
3215
|
case "end":
|
|
2943
|
-
return
|
|
3216
|
+
return _context43.stop();
|
|
2944
3217
|
}
|
|
2945
|
-
},
|
|
3218
|
+
}, _callee43, this, [[0, 9]]);
|
|
2946
3219
|
}));
|
|
2947
3220
|
function preloadPaymentMethods() {
|
|
2948
3221
|
return _preloadPaymentMethods.apply(this, arguments);
|
|
@@ -2965,126 +3238,180 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2965
3238
|
}
|
|
2966
3239
|
|
|
2967
3240
|
/**
|
|
2968
|
-
*
|
|
3241
|
+
* 计算已支付金额(从 Payment 模块获取最新数据)
|
|
2969
3242
|
*/
|
|
2970
3243
|
}, {
|
|
2971
|
-
key: "
|
|
2972
|
-
value: function
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
return
|
|
3244
|
+
key: "calculatePaidAmountAsync",
|
|
3245
|
+
value: (function () {
|
|
3246
|
+
var _calculatePaidAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
|
|
3247
|
+
var payments, paidAmount, result;
|
|
3248
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
3249
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
3250
|
+
case 0:
|
|
3251
|
+
if (this.store.currentOrder) {
|
|
3252
|
+
_context44.next = 3;
|
|
3253
|
+
break;
|
|
3254
|
+
}
|
|
3255
|
+
console.log('[Checkout] calculatePaidAmountAsync: 没有当前订单');
|
|
3256
|
+
return _context44.abrupt("return", '0.00');
|
|
3257
|
+
case 3:
|
|
3258
|
+
_context44.prev = 3;
|
|
3259
|
+
_context44.next = 6;
|
|
3260
|
+
return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid, false // 不包括已撤销的支付项
|
|
3261
|
+
);
|
|
3262
|
+
case 6:
|
|
3263
|
+
payments = _context44.sent;
|
|
3264
|
+
console.log('[Checkout] calculatePaidAmountAsync: 支付项详情:', {
|
|
3265
|
+
paymentCount: payments.length,
|
|
3266
|
+
payments: payments.map(function (p) {
|
|
3267
|
+
return {
|
|
3268
|
+
uuid: p.uuid,
|
|
3269
|
+
amount: p.amount,
|
|
3270
|
+
code: p.code,
|
|
3271
|
+
status: p.status
|
|
3272
|
+
};
|
|
3273
|
+
})
|
|
3274
|
+
});
|
|
3275
|
+
paidAmount = payments.filter(function (payment) {
|
|
3276
|
+
return payment.status !== 'voided';
|
|
3277
|
+
}) // 只计算未撤销的支付项
|
|
3278
|
+
.reduce(function (sum, payment) {
|
|
3279
|
+
var amount = parseFloat(payment.amount || '0');
|
|
3280
|
+
console.log("[Checkout] \u8BA1\u7B97\u652F\u4ED8\u9879: ".concat(payment.code, " = ").concat(amount));
|
|
3281
|
+
return sum + amount;
|
|
3282
|
+
}, 0);
|
|
3283
|
+
result = paidAmount.toFixed(2);
|
|
3284
|
+
console.log('[Checkout] calculatePaidAmountAsync: 计算结果 =', result);
|
|
3285
|
+
return _context44.abrupt("return", result);
|
|
3286
|
+
case 14:
|
|
3287
|
+
_context44.prev = 14;
|
|
3288
|
+
_context44.t0 = _context44["catch"](3);
|
|
3289
|
+
console.error('[Checkout] calculatePaidAmountAsync 失败:', _context44.t0);
|
|
3290
|
+
return _context44.abrupt("return", '0.00');
|
|
3291
|
+
case 18:
|
|
3292
|
+
case "end":
|
|
3293
|
+
return _context44.stop();
|
|
3294
|
+
}
|
|
3295
|
+
}, _callee44, this, [[3, 14]]);
|
|
3296
|
+
}));
|
|
3297
|
+
function calculatePaidAmountAsync() {
|
|
3298
|
+
return _calculatePaidAmountAsync.apply(this, arguments);
|
|
2976
3299
|
}
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
paymentCount: payments.length,
|
|
2980
|
-
payments: payments.map(function (p) {
|
|
2981
|
-
return {
|
|
2982
|
-
uuid: p.uuid,
|
|
2983
|
-
amount: p.amount,
|
|
2984
|
-
code: p.code,
|
|
2985
|
-
status: p.status
|
|
2986
|
-
};
|
|
2987
|
-
})
|
|
2988
|
-
});
|
|
2989
|
-
var paidAmount = payments.filter(function (payment) {
|
|
2990
|
-
return payment.status !== 'voided';
|
|
2991
|
-
}) // 只计算未撤销的支付项
|
|
2992
|
-
.reduce(function (sum, payment) {
|
|
2993
|
-
var amount = parseFloat(payment.amount || '0');
|
|
2994
|
-
console.log("[Checkout] \u8BA1\u7B97\u652F\u4ED8\u9879: ".concat(payment.code, " = ").concat(amount));
|
|
2995
|
-
return sum + amount;
|
|
2996
|
-
}, 0);
|
|
2997
|
-
var result = paidAmount.toFixed(2);
|
|
2998
|
-
console.log('[Checkout] calculatePaidAmount: 计算结果 =', result);
|
|
2999
|
-
return result;
|
|
3000
|
-
}
|
|
3001
|
-
|
|
3300
|
+
return calculatePaidAmountAsync;
|
|
3301
|
+
}()
|
|
3002
3302
|
/**
|
|
3003
|
-
*
|
|
3303
|
+
* 计算剩余未支付金额(从 Payment 模块获取最新数据)
|
|
3004
3304
|
*/
|
|
3305
|
+
)
|
|
3005
3306
|
}, {
|
|
3006
|
-
key: "
|
|
3007
|
-
value: function
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
return
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3307
|
+
key: "calculateRemainingAmountAsync",
|
|
3308
|
+
value: (function () {
|
|
3309
|
+
var _calculateRemainingAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45() {
|
|
3310
|
+
var totalAmount, paidAmount, remainingAmount, result;
|
|
3311
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context45) {
|
|
3312
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
3313
|
+
case 0:
|
|
3314
|
+
if (this.store.currentOrder) {
|
|
3315
|
+
_context45.next = 3;
|
|
3316
|
+
break;
|
|
3317
|
+
}
|
|
3318
|
+
console.log('[Checkout] calculateRemainingAmountAsync: 没有当前订单');
|
|
3319
|
+
return _context45.abrupt("return", '0.00');
|
|
3320
|
+
case 3:
|
|
3321
|
+
totalAmount = parseFloat(this.store.currentOrder.total_amount || '0');
|
|
3322
|
+
_context45.t0 = parseFloat;
|
|
3323
|
+
_context45.next = 7;
|
|
3324
|
+
return this.calculatePaidAmountAsync();
|
|
3325
|
+
case 7:
|
|
3326
|
+
_context45.t1 = _context45.sent;
|
|
3327
|
+
paidAmount = (0, _context45.t0)(_context45.t1);
|
|
3328
|
+
remainingAmount = totalAmount - paidAmount;
|
|
3329
|
+
result = Math.max(0, remainingAmount).toFixed(2);
|
|
3330
|
+
console.log('[Checkout] calculateRemainingAmountAsync: 计算详情:', {
|
|
3331
|
+
orderUuid: this.store.currentOrder.uuid,
|
|
3332
|
+
totalAmount: totalAmount.toFixed(2),
|
|
3333
|
+
paidAmount: paidAmount.toFixed(2),
|
|
3334
|
+
calculatedRemaining: remainingAmount.toFixed(2),
|
|
3335
|
+
finalResult: result
|
|
3336
|
+
});
|
|
3337
|
+
return _context45.abrupt("return", result);
|
|
3338
|
+
case 13:
|
|
3339
|
+
case "end":
|
|
3340
|
+
return _context45.stop();
|
|
3341
|
+
}
|
|
3342
|
+
}, _callee45, this);
|
|
3343
|
+
}));
|
|
3344
|
+
function calculateRemainingAmountAsync() {
|
|
3345
|
+
return _calculateRemainingAmountAsync.apply(this, arguments);
|
|
3346
|
+
}
|
|
3347
|
+
return calculateRemainingAmountAsync;
|
|
3348
|
+
}()
|
|
3026
3349
|
/**
|
|
3027
3350
|
* 更新 stateAmount 为当前剩余未支付金额
|
|
3028
3351
|
*/
|
|
3352
|
+
)
|
|
3029
3353
|
}, {
|
|
3030
3354
|
key: "updateStateAmountToRemaining",
|
|
3031
3355
|
value: (function () {
|
|
3032
|
-
var _updateStateAmountToRemaining = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3033
|
-
var _this$store$
|
|
3034
|
-
return _regeneratorRuntime().wrap(function
|
|
3035
|
-
while (1) switch (
|
|
3356
|
+
var _updateStateAmountToRemaining = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
|
|
3357
|
+
var _this$store$currentOr16, remainingAmount, currentStateAmount;
|
|
3358
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
3359
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
3036
3360
|
case 0:
|
|
3037
|
-
|
|
3038
|
-
|
|
3361
|
+
_context46.prev = 0;
|
|
3362
|
+
_context46.next = 3;
|
|
3363
|
+
return this.calculateRemainingAmountAsync();
|
|
3364
|
+
case 3:
|
|
3365
|
+
remainingAmount = _context46.sent;
|
|
3039
3366
|
currentStateAmount = this.store.stateAmount;
|
|
3040
3367
|
console.log('[Checkout] updateStateAmountToRemaining: 状态检查:', {
|
|
3041
3368
|
calculatedRemainingAmount: remainingAmount,
|
|
3042
3369
|
currentStateAmount: currentStateAmount,
|
|
3043
3370
|
needsUpdate: remainingAmount !== currentStateAmount,
|
|
3044
|
-
orderUuid: (_this$store$
|
|
3371
|
+
orderUuid: (_this$store$currentOr16 = this.store.currentOrder) === null || _this$store$currentOr16 === void 0 ? void 0 : _this$store$currentOr16.uuid
|
|
3045
3372
|
});
|
|
3046
3373
|
|
|
3047
3374
|
// 只有当剩余金额与当前 stateAmount 不同时才更新
|
|
3048
3375
|
if (!(remainingAmount !== currentStateAmount)) {
|
|
3049
|
-
|
|
3376
|
+
_context46.next = 13;
|
|
3050
3377
|
break;
|
|
3051
3378
|
}
|
|
3052
3379
|
this.store.stateAmount = remainingAmount;
|
|
3053
3380
|
|
|
3054
3381
|
// 发出 stateAmount 变更事件
|
|
3055
|
-
|
|
3382
|
+
_context46.next = 10;
|
|
3056
3383
|
return this.core.effects.emit(CheckoutHooks.OnStateAmountChanged, {
|
|
3057
3384
|
oldAmount: currentStateAmount,
|
|
3058
3385
|
newAmount: remainingAmount,
|
|
3059
3386
|
timestamp: Date.now()
|
|
3060
3387
|
});
|
|
3061
|
-
case
|
|
3388
|
+
case 10:
|
|
3062
3389
|
console.log('[Checkout] stateAmount 已自动更新为剩余金额:', {
|
|
3063
3390
|
oldAmount: currentStateAmount,
|
|
3064
3391
|
newAmount: remainingAmount
|
|
3065
3392
|
});
|
|
3066
|
-
|
|
3393
|
+
_context46.next = 14;
|
|
3067
3394
|
break;
|
|
3068
|
-
case
|
|
3395
|
+
case 13:
|
|
3069
3396
|
console.log('[Checkout] stateAmount 无需更新,当前值已是最新:', {
|
|
3070
3397
|
stateAmount: currentStateAmount,
|
|
3071
3398
|
remainingAmount: remainingAmount
|
|
3072
3399
|
});
|
|
3073
|
-
case 12:
|
|
3074
|
-
_context40.next = 14;
|
|
3075
|
-
return this.checkOrderPaymentCompletion();
|
|
3076
3400
|
case 14:
|
|
3077
|
-
|
|
3078
|
-
|
|
3401
|
+
_context46.next = 16;
|
|
3402
|
+
return this.checkOrderPaymentCompletion();
|
|
3079
3403
|
case 16:
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3404
|
+
_context46.next = 21;
|
|
3405
|
+
break;
|
|
3406
|
+
case 18:
|
|
3407
|
+
_context46.prev = 18;
|
|
3408
|
+
_context46.t0 = _context46["catch"](0);
|
|
3409
|
+
console.error('[Checkout] 更新 stateAmount 为剩余金额失败:', _context46.t0);
|
|
3410
|
+
case 21:
|
|
3084
3411
|
case "end":
|
|
3085
|
-
return
|
|
3412
|
+
return _context46.stop();
|
|
3086
3413
|
}
|
|
3087
|
-
},
|
|
3414
|
+
}, _callee46, this, [[0, 18]]);
|
|
3088
3415
|
}));
|
|
3089
3416
|
function updateStateAmountToRemaining() {
|
|
3090
3417
|
return _updateStateAmountToRemaining.apply(this, arguments);
|
|
@@ -3093,33 +3420,39 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3093
3420
|
}()
|
|
3094
3421
|
/**
|
|
3095
3422
|
* 检查订单支付是否完成
|
|
3096
|
-
*
|
|
3423
|
+
*
|
|
3097
3424
|
* 当剩余待付款金额 <= 0 时,触发订单支付完成事件
|
|
3098
3425
|
*/
|
|
3099
3426
|
)
|
|
3100
3427
|
}, {
|
|
3101
3428
|
key: "checkOrderPaymentCompletion",
|
|
3102
3429
|
value: (function () {
|
|
3103
|
-
var _checkOrderPaymentCompletion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3104
|
-
var remainingAmount, remainingValue,
|
|
3105
|
-
return _regeneratorRuntime().wrap(function
|
|
3106
|
-
while (1) switch (
|
|
3430
|
+
var _checkOrderPaymentCompletion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
|
|
3431
|
+
var remainingAmount, remainingValue, totalAmount, paidAmount, currentPayments, allPaymentsHaveVoucherId;
|
|
3432
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context47) {
|
|
3433
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
3107
3434
|
case 0:
|
|
3108
|
-
|
|
3435
|
+
_context47.prev = 0;
|
|
3109
3436
|
if (this.store.currentOrder) {
|
|
3110
|
-
|
|
3437
|
+
_context47.next = 3;
|
|
3111
3438
|
break;
|
|
3112
3439
|
}
|
|
3113
|
-
return
|
|
3440
|
+
return _context47.abrupt("return");
|
|
3114
3441
|
case 3:
|
|
3115
|
-
|
|
3442
|
+
_context47.next = 5;
|
|
3443
|
+
return this.calculateRemainingAmountAsync();
|
|
3444
|
+
case 5:
|
|
3445
|
+
remainingAmount = _context47.sent;
|
|
3116
3446
|
remainingValue = parseFloat(remainingAmount); // 当剩余金额小于等于0时,认为订单已完成支付
|
|
3117
3447
|
if (!(remainingValue <= 0)) {
|
|
3118
|
-
|
|
3448
|
+
_context47.next = 27;
|
|
3119
3449
|
break;
|
|
3120
3450
|
}
|
|
3121
3451
|
totalAmount = this.store.currentOrder.total_amount;
|
|
3122
|
-
|
|
3452
|
+
_context47.next = 11;
|
|
3453
|
+
return this.calculatePaidAmountAsync();
|
|
3454
|
+
case 11:
|
|
3455
|
+
paidAmount = _context47.sent;
|
|
3123
3456
|
console.log('[Checkout] 检测到订单支付完成:', {
|
|
3124
3457
|
orderUuid: this.store.currentOrder.uuid,
|
|
3125
3458
|
orderId: this.store.currentOrder.order_id,
|
|
@@ -3129,14 +3462,19 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3129
3462
|
isOrderSynced: this.store.isOrderSynced
|
|
3130
3463
|
});
|
|
3131
3464
|
|
|
3132
|
-
//
|
|
3133
|
-
|
|
3465
|
+
// 从 Payment 模块获取最新支付项,检查是否所有支付项都带有 voucher_id
|
|
3466
|
+
_context47.next = 15;
|
|
3467
|
+
return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid, false // 不包括已撤销的支付项
|
|
3468
|
+
);
|
|
3469
|
+
case 15:
|
|
3470
|
+
currentPayments = _context47.sent;
|
|
3471
|
+
allPaymentsHaveVoucherId = currentPayments.length > 0 && currentPayments.every(function (item) {
|
|
3134
3472
|
return item.status !== 'voided' && item.voucher_id;
|
|
3135
3473
|
});
|
|
3136
3474
|
console.log('[Checkout] 支付项voucher_id检查:', {
|
|
3137
|
-
paymentCount:
|
|
3475
|
+
paymentCount: currentPayments.length,
|
|
3138
3476
|
allHaveVoucherId: allPaymentsHaveVoucherId,
|
|
3139
|
-
paymentItems:
|
|
3477
|
+
paymentItems: currentPayments.map(function (p) {
|
|
3140
3478
|
return {
|
|
3141
3479
|
uuid: p.uuid,
|
|
3142
3480
|
code: p.code,
|
|
@@ -3147,24 +3485,28 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3147
3485
|
})
|
|
3148
3486
|
});
|
|
3149
3487
|
|
|
3150
|
-
// 如果支付完成但订单未同步,需要判断是否同步
|
|
3151
|
-
if (this.store.isOrderSynced) {
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
}
|
|
3488
|
+
// // 如果支付完成但订单未同步,需要判断是否同步
|
|
3489
|
+
// if (!this.store.isOrderSynced) {
|
|
3490
|
+
// if (allPaymentsHaveVoucherId) {
|
|
3491
|
+
// console.log('[Checkout] 所有支付项均为代金券类型,跳过订单同步');
|
|
3492
|
+
// } else {
|
|
3493
|
+
// console.log('[Checkout] 支付完成但订单未同步,开始同步订单到后端...');
|
|
3494
|
+
// await this.syncOrderToBackend();
|
|
3495
|
+
// }
|
|
3496
|
+
// }
|
|
3155
3497
|
if (!allPaymentsHaveVoucherId) {
|
|
3156
|
-
|
|
3498
|
+
_context47.next = 22;
|
|
3157
3499
|
break;
|
|
3158
3500
|
}
|
|
3159
3501
|
console.log('[Checkout] 所有支付项均为代金券类型,跳过订单同步');
|
|
3160
|
-
|
|
3502
|
+
_context47.next = 25;
|
|
3161
3503
|
break;
|
|
3162
|
-
case
|
|
3504
|
+
case 22:
|
|
3163
3505
|
console.log('[Checkout] 支付完成但订单未同步,开始同步订单到后端...');
|
|
3164
|
-
|
|
3506
|
+
_context47.next = 25;
|
|
3165
3507
|
return this.syncOrderToBackend();
|
|
3166
|
-
case
|
|
3167
|
-
|
|
3508
|
+
case 25:
|
|
3509
|
+
_context47.next = 27;
|
|
3168
3510
|
return this.core.effects.emit(CheckoutHooks.OnOrderPaymentCompleted, {
|
|
3169
3511
|
orderUuid: this.store.currentOrder.uuid,
|
|
3170
3512
|
orderId: this.store.currentOrder.order_id,
|
|
@@ -3173,18 +3515,18 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3173
3515
|
remainingAmount: remainingAmount,
|
|
3174
3516
|
timestamp: Date.now()
|
|
3175
3517
|
});
|
|
3176
|
-
case
|
|
3177
|
-
|
|
3518
|
+
case 27:
|
|
3519
|
+
_context47.next = 32;
|
|
3178
3520
|
break;
|
|
3179
|
-
case
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
console.error('[Checkout] 检查订单支付完成状态失败:',
|
|
3183
|
-
case
|
|
3521
|
+
case 29:
|
|
3522
|
+
_context47.prev = 29;
|
|
3523
|
+
_context47.t0 = _context47["catch"](0);
|
|
3524
|
+
console.error('[Checkout] 检查订单支付完成状态失败:', _context47.t0);
|
|
3525
|
+
case 32:
|
|
3184
3526
|
case "end":
|
|
3185
|
-
return
|
|
3527
|
+
return _context47.stop();
|
|
3186
3528
|
}
|
|
3187
|
-
},
|
|
3529
|
+
}, _callee47, this, [[0, 29]]);
|
|
3188
3530
|
}));
|
|
3189
3531
|
function checkOrderPaymentCompletion() {
|
|
3190
3532
|
return _checkOrderPaymentCompletion.apply(this, arguments);
|
|
@@ -3193,11 +3535,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3193
3535
|
}()
|
|
3194
3536
|
/**
|
|
3195
3537
|
* 判断支付方式是否需要同步订单到后端
|
|
3196
|
-
*
|
|
3538
|
+
*
|
|
3197
3539
|
* 现金支付(CASHMANUAL)和自定义支付不需要同步,其他支付方式需要同步
|
|
3198
|
-
*
|
|
3540
|
+
*
|
|
3199
3541
|
* @param paymentCode 支付方式代码
|
|
3200
|
-
* @param paymentType 支付方式类型
|
|
3542
|
+
* @param paymentType 支付方式类型
|
|
3201
3543
|
* @returns 是否需要同步订单
|
|
3202
3544
|
*/
|
|
3203
3545
|
)
|
|
@@ -3231,12 +3573,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3231
3573
|
|
|
3232
3574
|
/**
|
|
3233
3575
|
* 同步订单到后端
|
|
3234
|
-
*
|
|
3576
|
+
*
|
|
3235
3577
|
* 调用后端 /order/checkout 接口创建真实订单
|
|
3236
3578
|
*/
|
|
3237
3579
|
/**
|
|
3238
3580
|
* 判断订单ID是否为本地生成的虚拟ID
|
|
3239
|
-
*
|
|
3581
|
+
*
|
|
3240
3582
|
* @param orderId 订单ID
|
|
3241
3583
|
* @returns true 表示是虚拟ID,false 表示是真实的后端ID
|
|
3242
3584
|
*/
|
|
@@ -3248,7 +3590,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3248
3590
|
|
|
3249
3591
|
/**
|
|
3250
3592
|
* 同步订单到后端并返回真实订单ID
|
|
3251
|
-
*
|
|
3593
|
+
*
|
|
3252
3594
|
* @param isManual 是否为手动同步,默认为 false
|
|
3253
3595
|
* @param customPaymentItems 自定义支付项列表,如果提供则使用此列表而不是从数据库获取
|
|
3254
3596
|
* @returns 后端返回的真实订单ID
|
|
@@ -3256,8 +3598,8 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3256
3598
|
}, {
|
|
3257
3599
|
key: "syncOrderToBackendWithReturn",
|
|
3258
3600
|
value: (function () {
|
|
3259
|
-
var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3260
|
-
var _this$store$currentCu2, _this$store$
|
|
3601
|
+
var _syncOrderToBackendWithReturn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48() {
|
|
3602
|
+
var _this$store$currentCu2, _this$store$currentOr17, _this$store$currentOr18;
|
|
3261
3603
|
var isManual,
|
|
3262
3604
|
customPaymentItems,
|
|
3263
3605
|
syncType,
|
|
@@ -3276,14 +3618,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3276
3618
|
beforeManualUpdate,
|
|
3277
3619
|
finalOrderId,
|
|
3278
3620
|
finalIsVirtual,
|
|
3279
|
-
|
|
3280
|
-
return _regeneratorRuntime().wrap(function
|
|
3281
|
-
while (1) switch (
|
|
3621
|
+
_args48 = arguments;
|
|
3622
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context48) {
|
|
3623
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
3282
3624
|
case 0:
|
|
3283
|
-
isManual =
|
|
3284
|
-
customPaymentItems =
|
|
3625
|
+
isManual = _args48.length > 0 && _args48[0] !== undefined ? _args48[0] : false;
|
|
3626
|
+
customPaymentItems = _args48.length > 1 ? _args48[1] : undefined;
|
|
3285
3627
|
if (!(!this.store.localOrderData || !this.store.currentOrder)) {
|
|
3286
|
-
|
|
3628
|
+
_context48.next = 4;
|
|
3287
3629
|
break;
|
|
3288
3630
|
}
|
|
3289
3631
|
throw new Error('缺少必要的订单数据,无法同步到后端');
|
|
@@ -3324,17 +3666,17 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3324
3666
|
});
|
|
3325
3667
|
|
|
3326
3668
|
// 获取当前订单的支付项
|
|
3327
|
-
|
|
3328
|
-
if (
|
|
3329
|
-
|
|
3669
|
+
_context48.t0 = customPaymentItems;
|
|
3670
|
+
if (_context48.t0) {
|
|
3671
|
+
_context48.next = 18;
|
|
3330
3672
|
break;
|
|
3331
3673
|
}
|
|
3332
|
-
|
|
3674
|
+
_context48.next = 17;
|
|
3333
3675
|
return this.payment.getPaymentItemsAsync(this.store.currentOrder.uuid);
|
|
3334
3676
|
case 17:
|
|
3335
|
-
|
|
3677
|
+
_context48.t0 = _context48.sent;
|
|
3336
3678
|
case 18:
|
|
3337
|
-
paymentItems =
|
|
3679
|
+
paymentItems = _context48.t0;
|
|
3338
3680
|
console.log('[Checkout] 获取到支付项:', {
|
|
3339
3681
|
count: paymentItems.length,
|
|
3340
3682
|
isCustomFiltered: !!customPaymentItems,
|
|
@@ -3375,12 +3717,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3375
3717
|
currency_code: this.otherParams.currency_code,
|
|
3376
3718
|
currency_symbol: this.otherParams.currency_symbol,
|
|
3377
3719
|
currency_format: this.otherParams.currency_format,
|
|
3378
|
-
is_deposit: ((_this$store$
|
|
3379
|
-
deposit_amount: ((_this$store$
|
|
3720
|
+
is_deposit: ((_this$store$currentOr17 = this.store.currentOrder) === null || _this$store$currentOr17 === void 0 ? void 0 : _this$store$currentOr17.is_deposit) || 0,
|
|
3721
|
+
deposit_amount: ((_this$store$currentOr18 = this.store.currentOrder) === null || _this$store$currentOr18 === void 0 ? void 0 : _this$store$currentOr18.deposit_amount) || '0.00',
|
|
3380
3722
|
// surcharge_fee: this.otherParams.surcharge_fee,
|
|
3381
3723
|
// surcharges: ,
|
|
3382
3724
|
note: this.store.localOrderData.shop_note
|
|
3383
|
-
// deposit_amount:
|
|
3725
|
+
// deposit_amount:
|
|
3384
3726
|
}); // 如果是更新操作,需要在参数中包含真实的订单ID
|
|
3385
3727
|
|
|
3386
3728
|
if (isUpdateOperation) {
|
|
@@ -3406,10 +3748,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3406
3748
|
}
|
|
3407
3749
|
|
|
3408
3750
|
// 调用 Order 模块的专用 createOrderByCheckout 方法
|
|
3409
|
-
|
|
3751
|
+
_context48.next = 24;
|
|
3410
3752
|
return this.order.createOrderByCheckout(orderParams);
|
|
3411
3753
|
case 24:
|
|
3412
|
-
checkoutResponse =
|
|
3754
|
+
checkoutResponse = _context48.sent;
|
|
3413
3755
|
console.log('[Checkout] 后端返回的响应数据:', {
|
|
3414
3756
|
status: checkoutResponse === null || checkoutResponse === void 0 ? void 0 : checkoutResponse.status,
|
|
3415
3757
|
code: checkoutResponse === null || checkoutResponse === void 0 ? void 0 : checkoutResponse.code,
|
|
@@ -3417,13 +3759,13 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3417
3759
|
data: checkoutResponse === null || checkoutResponse === void 0 ? void 0 : checkoutResponse.data
|
|
3418
3760
|
});
|
|
3419
3761
|
if (!isUpdateOperation) {
|
|
3420
|
-
|
|
3762
|
+
_context48.next = 31;
|
|
3421
3763
|
break;
|
|
3422
3764
|
}
|
|
3423
3765
|
// 更新操作:使用现有的订单ID
|
|
3424
3766
|
realOrderId = currentOrderId;
|
|
3425
3767
|
console.log("[Checkout] \u8BA2\u5355\u66F4\u65B0\u6210\u529F\uFF0C\u8BA2\u5355ID: ".concat(realOrderId));
|
|
3426
|
-
|
|
3768
|
+
_context48.next = 52;
|
|
3427
3769
|
break;
|
|
3428
3770
|
case 31:
|
|
3429
3771
|
// 创建操作:从响应中提取新的订单ID
|
|
@@ -3437,7 +3779,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3437
3779
|
extractedOrderId = String(extractedOrderId);
|
|
3438
3780
|
}
|
|
3439
3781
|
if (extractedOrderId) {
|
|
3440
|
-
|
|
3782
|
+
_context48.next = 36;
|
|
3441
3783
|
break;
|
|
3442
3784
|
}
|
|
3443
3785
|
throw new Error('后端返回的订单信息中未包含订单ID');
|
|
@@ -3451,11 +3793,11 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3451
3793
|
oldOrderId: this.store.currentOrder.order_id,
|
|
3452
3794
|
newOrderId: realOrderId
|
|
3453
3795
|
});
|
|
3454
|
-
|
|
3455
|
-
|
|
3796
|
+
_context48.prev = 39;
|
|
3797
|
+
_context48.next = 42;
|
|
3456
3798
|
return this.payment.replaceOrderIdByUuidAsync(this.store.currentOrder.uuid, realOrderId);
|
|
3457
3799
|
case 42:
|
|
3458
|
-
updatedOrder =
|
|
3800
|
+
updatedOrder = _context48.sent;
|
|
3459
3801
|
console.log('[Checkout] Payment模块替换订单ID结果:', {
|
|
3460
3802
|
wasSuccessful: !!updatedOrder,
|
|
3461
3803
|
returnedOrderId: updatedOrder === null || updatedOrder === void 0 ? void 0 : updatedOrder.order_id,
|
|
@@ -3481,12 +3823,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3481
3823
|
目标ID: realOrderId
|
|
3482
3824
|
});
|
|
3483
3825
|
}
|
|
3484
|
-
|
|
3826
|
+
_context48.next = 52;
|
|
3485
3827
|
break;
|
|
3486
3828
|
case 47:
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
console.error('[Checkout] 调用Payment模块替换订单ID时发生错误:',
|
|
3829
|
+
_context48.prev = 47;
|
|
3830
|
+
_context48.t1 = _context48["catch"](39);
|
|
3831
|
+
console.error('[Checkout] 调用Payment模块替换订单ID时发生错误:', _context48.t1);
|
|
3490
3832
|
|
|
3491
3833
|
// 发生错误时也进行手动替换
|
|
3492
3834
|
this.store.currentOrder.order_id = realOrderId;
|
|
@@ -3496,7 +3838,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3496
3838
|
this.store.isOrderSynced = true;
|
|
3497
3839
|
|
|
3498
3840
|
// 触发订单同步完成事件
|
|
3499
|
-
|
|
3841
|
+
_context48.next = 55;
|
|
3500
3842
|
return this.core.effects.emit(CheckoutHooks.OnOrderSynced, {
|
|
3501
3843
|
orderUuid: this.store.currentOrder.uuid,
|
|
3502
3844
|
realOrderId: realOrderId,
|
|
@@ -3522,12 +3864,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3522
3864
|
}
|
|
3523
3865
|
|
|
3524
3866
|
// 返回真实订单ID
|
|
3525
|
-
return
|
|
3867
|
+
return _context48.abrupt("return", realOrderId);
|
|
3526
3868
|
case 60:
|
|
3527
3869
|
case "end":
|
|
3528
|
-
return
|
|
3870
|
+
return _context48.stop();
|
|
3529
3871
|
}
|
|
3530
|
-
},
|
|
3872
|
+
}, _callee48, this, [[39, 47]]);
|
|
3531
3873
|
}));
|
|
3532
3874
|
function syncOrderToBackendWithReturn() {
|
|
3533
3875
|
return _syncOrderToBackendWithReturn.apply(this, arguments);
|
|
@@ -3537,27 +3879,27 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3537
3879
|
}, {
|
|
3538
3880
|
key: "syncOrderToBackend",
|
|
3539
3881
|
value: function () {
|
|
3540
|
-
var _syncOrderToBackend = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3541
|
-
return _regeneratorRuntime().wrap(function
|
|
3542
|
-
while (1) switch (
|
|
3882
|
+
var _syncOrderToBackend = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49() {
|
|
3883
|
+
return _regeneratorRuntime().wrap(function _callee49$(_context49) {
|
|
3884
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
3543
3885
|
case 0:
|
|
3544
|
-
|
|
3545
|
-
|
|
3886
|
+
_context49.prev = 0;
|
|
3887
|
+
_context49.next = 3;
|
|
3546
3888
|
return this.syncOrderToBackendWithReturn(false);
|
|
3547
3889
|
case 3:
|
|
3548
|
-
|
|
3890
|
+
_context49.next = 10;
|
|
3549
3891
|
break;
|
|
3550
3892
|
case 5:
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
console.error('[Checkout] 同步订单到后端失败:',
|
|
3554
|
-
|
|
3555
|
-
return this.handleError(new Error("\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(
|
|
3893
|
+
_context49.prev = 5;
|
|
3894
|
+
_context49.t0 = _context49["catch"](0);
|
|
3895
|
+
console.error('[Checkout] 同步订单到后端失败:', _context49.t0);
|
|
3896
|
+
_context49.next = 10;
|
|
3897
|
+
return this.handleError(new Error("\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ".concat(_context49.t0 instanceof Error ? _context49.t0.message : String(_context49.t0))), CheckoutErrorType.OrderCreationFailed);
|
|
3556
3898
|
case 10:
|
|
3557
3899
|
case "end":
|
|
3558
|
-
return
|
|
3900
|
+
return _context49.stop();
|
|
3559
3901
|
}
|
|
3560
|
-
},
|
|
3902
|
+
}, _callee49, this, [[0, 5]]);
|
|
3561
3903
|
}));
|
|
3562
3904
|
function syncOrderToBackend() {
|
|
3563
3905
|
return _syncOrderToBackend.apply(this, arguments);
|
|
@@ -3597,15 +3939,15 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3597
3939
|
}, {
|
|
3598
3940
|
key: "setOtherParams",
|
|
3599
3941
|
value: function () {
|
|
3600
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3601
|
-
var
|
|
3602
|
-
|
|
3942
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(params) {
|
|
3943
|
+
var _ref5,
|
|
3944
|
+
_ref5$cover,
|
|
3603
3945
|
cover,
|
|
3604
|
-
|
|
3605
|
-
return _regeneratorRuntime().wrap(function
|
|
3606
|
-
while (1) switch (
|
|
3946
|
+
_args50 = arguments;
|
|
3947
|
+
return _regeneratorRuntime().wrap(function _callee50$(_context50) {
|
|
3948
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
3607
3949
|
case 0:
|
|
3608
|
-
|
|
3950
|
+
_ref5 = _args50.length > 1 && _args50[1] !== undefined ? _args50[1] : {}, _ref5$cover = _ref5.cover, cover = _ref5$cover === void 0 ? false : _ref5$cover;
|
|
3609
3951
|
if (cover) {
|
|
3610
3952
|
this.otherParams = params;
|
|
3611
3953
|
} else {
|
|
@@ -3613,20 +3955,20 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3613
3955
|
}
|
|
3614
3956
|
case 2:
|
|
3615
3957
|
case "end":
|
|
3616
|
-
return
|
|
3958
|
+
return _context50.stop();
|
|
3617
3959
|
}
|
|
3618
|
-
},
|
|
3960
|
+
}, _callee50, this);
|
|
3619
3961
|
}));
|
|
3620
|
-
function setOtherParams(
|
|
3962
|
+
function setOtherParams(_x32) {
|
|
3621
3963
|
return _setOtherParams.apply(this, arguments);
|
|
3622
3964
|
}
|
|
3623
3965
|
return setOtherParams;
|
|
3624
3966
|
}()
|
|
3625
3967
|
/**
|
|
3626
3968
|
* 通过订单ID编辑订单备注
|
|
3627
|
-
*
|
|
3969
|
+
*
|
|
3628
3970
|
* 用于修改已同步到后端的订单备注,通常在支付成功后的弹窗中使用
|
|
3629
|
-
*
|
|
3971
|
+
*
|
|
3630
3972
|
* @param orderId 后端订单ID
|
|
3631
3973
|
* @param note 新的订单备注
|
|
3632
3974
|
* @returns 修改结果
|
|
@@ -3634,12 +3976,12 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3634
3976
|
}, {
|
|
3635
3977
|
key: "editOrderNoteByOrderIdAsync",
|
|
3636
3978
|
value: (function () {
|
|
3637
|
-
var _editOrderNoteByOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3979
|
+
var _editOrderNoteByOrderIdAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(orderId, note) {
|
|
3638
3980
|
var response, previousNote, errorMessage, _errorMessage;
|
|
3639
|
-
return _regeneratorRuntime().wrap(function
|
|
3640
|
-
while (1) switch (
|
|
3981
|
+
return _regeneratorRuntime().wrap(function _callee51$(_context51) {
|
|
3982
|
+
while (1) switch (_context51.prev = _context51.next) {
|
|
3641
3983
|
case 0:
|
|
3642
|
-
|
|
3984
|
+
_context51.prev = 0;
|
|
3643
3985
|
console.log('[Checkout] 开始编辑订单备注:', {
|
|
3644
3986
|
orderId: orderId,
|
|
3645
3987
|
note: note,
|
|
@@ -3648,21 +3990,21 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3648
3990
|
|
|
3649
3991
|
// 参数验证
|
|
3650
3992
|
if (orderId) {
|
|
3651
|
-
|
|
3993
|
+
_context51.next = 4;
|
|
3652
3994
|
break;
|
|
3653
3995
|
}
|
|
3654
|
-
return
|
|
3996
|
+
return _context51.abrupt("return", {
|
|
3655
3997
|
success: false,
|
|
3656
3998
|
message: '订单ID不能为空',
|
|
3657
3999
|
orderId: orderId
|
|
3658
4000
|
});
|
|
3659
4001
|
case 4:
|
|
3660
|
-
|
|
4002
|
+
_context51.next = 6;
|
|
3661
4003
|
return this.request.put("/shop/order/order/".concat(orderId, "/note"), {
|
|
3662
4004
|
note: note
|
|
3663
4005
|
});
|
|
3664
4006
|
case 6:
|
|
3665
|
-
response =
|
|
4007
|
+
response = _context51.sent;
|
|
3666
4008
|
console.log('[Checkout] 订单备注编辑响应:', {
|
|
3667
4009
|
orderId: orderId,
|
|
3668
4010
|
status: response.status,
|
|
@@ -3672,14 +4014,14 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3672
4014
|
|
|
3673
4015
|
// 检查响应状态
|
|
3674
4016
|
if (!(response.status === true || response.status === 200)) {
|
|
3675
|
-
|
|
4017
|
+
_context51.next = 19;
|
|
3676
4018
|
break;
|
|
3677
4019
|
}
|
|
3678
4020
|
console.log("[Checkout] \u8BA2\u5355 ".concat(orderId, " \u5907\u6CE8\u4FEE\u6539\u6210\u529F"));
|
|
3679
4021
|
|
|
3680
4022
|
// 如果当前订单就是被修改的订单,同时更新本地状态
|
|
3681
4023
|
if (!(this.store.currentOrder && (String(this.store.currentOrder.order_id) === String(orderId) || String(this.store.currentOrder.id) === String(orderId)))) {
|
|
3682
|
-
|
|
4024
|
+
_context51.next = 16;
|
|
3683
4025
|
break;
|
|
3684
4026
|
}
|
|
3685
4027
|
console.log('[Checkout] 更新本地订单备注状态');
|
|
@@ -3691,7 +4033,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3691
4033
|
}
|
|
3692
4034
|
|
|
3693
4035
|
// 触发订单备注变更事件
|
|
3694
|
-
|
|
4036
|
+
_context51.next = 16;
|
|
3695
4037
|
return this.core.effects.emit(CheckoutHooks.OnOrderNoteChanged, {
|
|
3696
4038
|
orderUuid: this.store.currentOrder.uuid,
|
|
3697
4039
|
oldNote: previousNote,
|
|
@@ -3699,7 +4041,7 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3699
4041
|
timestamp: Date.now()
|
|
3700
4042
|
});
|
|
3701
4043
|
case 16:
|
|
3702
|
-
return
|
|
4044
|
+
return _context51.abrupt("return", {
|
|
3703
4045
|
success: true,
|
|
3704
4046
|
message: response.message || '订单备注修改成功',
|
|
3705
4047
|
orderId: orderId
|
|
@@ -3708,42 +4050,193 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3708
4050
|
// API返回失败状态
|
|
3709
4051
|
errorMessage = response.message || '订单备注修改失败';
|
|
3710
4052
|
console.error("[Checkout] \u8BA2\u5355 ".concat(orderId, " \u5907\u6CE8\u4FEE\u6539\u5931\u8D25:"), errorMessage);
|
|
3711
|
-
return
|
|
4053
|
+
return _context51.abrupt("return", {
|
|
3712
4054
|
success: false,
|
|
3713
4055
|
message: errorMessage,
|
|
3714
4056
|
orderId: orderId
|
|
3715
4057
|
});
|
|
3716
4058
|
case 22:
|
|
3717
|
-
|
|
4059
|
+
_context51.next = 29;
|
|
3718
4060
|
break;
|
|
3719
4061
|
case 24:
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
console.error('[Checkout] 编辑订单备注失败:',
|
|
3723
|
-
_errorMessage =
|
|
3724
|
-
return
|
|
4062
|
+
_context51.prev = 24;
|
|
4063
|
+
_context51.t0 = _context51["catch"](0);
|
|
4064
|
+
console.error('[Checkout] 编辑订单备注失败:', _context51.t0);
|
|
4065
|
+
_errorMessage = _context51.t0 instanceof Error ? _context51.t0.message : '网络错误或服务器异常';
|
|
4066
|
+
return _context51.abrupt("return", {
|
|
3725
4067
|
success: false,
|
|
3726
4068
|
message: "\u7F16\u8F91\u8BA2\u5355\u5907\u6CE8\u5931\u8D25: ".concat(_errorMessage),
|
|
3727
4069
|
orderId: orderId
|
|
3728
4070
|
});
|
|
3729
4071
|
case 29:
|
|
3730
4072
|
case "end":
|
|
3731
|
-
return
|
|
4073
|
+
return _context51.stop();
|
|
3732
4074
|
}
|
|
3733
|
-
},
|
|
4075
|
+
}, _callee51, this, [[0, 24]]);
|
|
3734
4076
|
}));
|
|
3735
|
-
function editOrderNoteByOrderIdAsync(
|
|
4077
|
+
function editOrderNoteByOrderIdAsync(_x33, _x34) {
|
|
3736
4078
|
return _editOrderNoteByOrderIdAsync.apply(this, arguments);
|
|
3737
4079
|
}
|
|
3738
4080
|
return editOrderNoteByOrderIdAsync;
|
|
4081
|
+
}()
|
|
4082
|
+
/**
|
|
4083
|
+
* 发送客户支付链接邮件
|
|
4084
|
+
*
|
|
4085
|
+
* 向指定邮箱发送订单支付提醒邮件
|
|
4086
|
+
*
|
|
4087
|
+
* @param params 发送参数
|
|
4088
|
+
* @returns 发送结果
|
|
4089
|
+
*/
|
|
4090
|
+
)
|
|
4091
|
+
}, {
|
|
4092
|
+
key: "sendCustomerPayLinkAsync",
|
|
4093
|
+
value: (function () {
|
|
4094
|
+
var _sendCustomerPayLinkAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
|
|
4095
|
+
var emailRegex, invalidEmails, requestBody, response, errorMessage, _errorMessage2;
|
|
4096
|
+
return _regeneratorRuntime().wrap(function _callee52$(_context52) {
|
|
4097
|
+
while (1) switch (_context52.prev = _context52.next) {
|
|
4098
|
+
case 0:
|
|
4099
|
+
_context52.prev = 0;
|
|
4100
|
+
console.log('[Checkout] 开始发送客户支付链接邮件:', {
|
|
4101
|
+
orderIds: params.order_ids,
|
|
4102
|
+
emails: params.emails,
|
|
4103
|
+
notifyAction: params.notify_action || 'order_payment_reminder'
|
|
4104
|
+
});
|
|
4105
|
+
|
|
4106
|
+
// 参数验证
|
|
4107
|
+
if (!(!params.order_ids || params.order_ids.length === 0)) {
|
|
4108
|
+
_context52.next = 4;
|
|
4109
|
+
break;
|
|
4110
|
+
}
|
|
4111
|
+
return _context52.abrupt("return", {
|
|
4112
|
+
success: false,
|
|
4113
|
+
message: '订单ID列表不能为空'
|
|
4114
|
+
});
|
|
4115
|
+
case 4:
|
|
4116
|
+
if (!(!params.emails || params.emails.length === 0)) {
|
|
4117
|
+
_context52.next = 6;
|
|
4118
|
+
break;
|
|
4119
|
+
}
|
|
4120
|
+
return _context52.abrupt("return", {
|
|
4121
|
+
success: false,
|
|
4122
|
+
message: '邮箱地址列表不能为空'
|
|
4123
|
+
});
|
|
4124
|
+
case 6:
|
|
4125
|
+
// 验证邮箱格式
|
|
4126
|
+
emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
4127
|
+
invalidEmails = params.emails.filter(function (email) {
|
|
4128
|
+
return !emailRegex.test(email);
|
|
4129
|
+
});
|
|
4130
|
+
if (!(invalidEmails.length > 0)) {
|
|
4131
|
+
_context52.next = 10;
|
|
4132
|
+
break;
|
|
4133
|
+
}
|
|
4134
|
+
return _context52.abrupt("return", {
|
|
4135
|
+
success: false,
|
|
4136
|
+
message: "\u90AE\u7BB1\u683C\u5F0F\u65E0\u6548: ".concat(invalidEmails.join(', '))
|
|
4137
|
+
});
|
|
4138
|
+
case 10:
|
|
4139
|
+
// 构建请求参数
|
|
4140
|
+
requestBody = {
|
|
4141
|
+
order_ids: params.order_ids,
|
|
4142
|
+
notify_action: params.notify_action || 'order_payment_reminder',
|
|
4143
|
+
emails: params.emails
|
|
4144
|
+
};
|
|
4145
|
+
console.log('[Checkout] 发送支付链接邮件请求参数:', requestBody);
|
|
4146
|
+
|
|
4147
|
+
// 调用后端API发送邮件
|
|
4148
|
+
_context52.next = 14;
|
|
4149
|
+
return this.request.post('/order/batch-email', requestBody);
|
|
4150
|
+
case 14:
|
|
4151
|
+
response = _context52.sent;
|
|
4152
|
+
console.log('[Checkout] 支付链接邮件发送响应:', {
|
|
4153
|
+
status: response.status,
|
|
4154
|
+
message: response.message,
|
|
4155
|
+
data: response.data,
|
|
4156
|
+
response: response
|
|
4157
|
+
});
|
|
4158
|
+
|
|
4159
|
+
// 检查响应状态
|
|
4160
|
+
if (!(response.status === true || response.status === 200)) {
|
|
4161
|
+
_context52.next = 21;
|
|
4162
|
+
break;
|
|
4163
|
+
}
|
|
4164
|
+
console.log('[Checkout] 支付链接邮件发送成功');
|
|
4165
|
+
return _context52.abrupt("return", {
|
|
4166
|
+
success: true,
|
|
4167
|
+
message: response.message || '支付链接邮件发送成功'
|
|
4168
|
+
});
|
|
4169
|
+
case 21:
|
|
4170
|
+
// API返回失败状态
|
|
4171
|
+
errorMessage = response.message || '支付链接邮件发送失败';
|
|
4172
|
+
console.error('[Checkout] 支付链接邮件发送失败:', errorMessage);
|
|
4173
|
+
return _context52.abrupt("return", {
|
|
4174
|
+
success: false,
|
|
4175
|
+
message: errorMessage
|
|
4176
|
+
});
|
|
4177
|
+
case 24:
|
|
4178
|
+
_context52.next = 31;
|
|
4179
|
+
break;
|
|
4180
|
+
case 26:
|
|
4181
|
+
_context52.prev = 26;
|
|
4182
|
+
_context52.t0 = _context52["catch"](0);
|
|
4183
|
+
console.error('[Checkout] 发送客户支付链接邮件失败:', _context52.t0);
|
|
4184
|
+
_errorMessage2 = _context52.t0 instanceof Error ? _context52.t0.message : '网络错误或服务器异常';
|
|
4185
|
+
return _context52.abrupt("return", {
|
|
4186
|
+
success: false,
|
|
4187
|
+
message: "\u53D1\u9001\u652F\u4ED8\u94FE\u63A5\u90AE\u4EF6\u5931\u8D25: ".concat(_errorMessage2)
|
|
4188
|
+
});
|
|
4189
|
+
case 31:
|
|
4190
|
+
case "end":
|
|
4191
|
+
return _context52.stop();
|
|
4192
|
+
}
|
|
4193
|
+
}, _callee52, this, [[0, 26]]);
|
|
4194
|
+
}));
|
|
4195
|
+
function sendCustomerPayLinkAsync(_x35) {
|
|
4196
|
+
return _sendCustomerPayLinkAsync.apply(this, arguments);
|
|
4197
|
+
}
|
|
4198
|
+
return sendCustomerPayLinkAsync;
|
|
4199
|
+
}()
|
|
4200
|
+
/**
|
|
4201
|
+
* 金额舍入
|
|
4202
|
+
*
|
|
4203
|
+
* @param amount 原始金额
|
|
4204
|
+
* @returns 舍入结果详情,包含原始金额、舍入后金额和舍入差额
|
|
4205
|
+
*/
|
|
4206
|
+
)
|
|
4207
|
+
}, {
|
|
4208
|
+
key: "roundAmountAsync",
|
|
4209
|
+
value: (function () {
|
|
4210
|
+
var _roundAmountAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(amount) {
|
|
4211
|
+
var _this$otherParams$ord, _this$otherParams$ord2;
|
|
4212
|
+
var result;
|
|
4213
|
+
return _regeneratorRuntime().wrap(function _callee53$(_context53) {
|
|
4214
|
+
while (1) switch (_context53.prev = _context53.next) {
|
|
4215
|
+
case 0:
|
|
4216
|
+
_context53.next = 2;
|
|
4217
|
+
return this.payment.roundAmountAsync(amount, (_this$otherParams$ord = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord === void 0 ? void 0 : _this$otherParams$ord.interval, (_this$otherParams$ord2 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord2 === void 0 ? void 0 : _this$otherParams$ord2.type);
|
|
4218
|
+
case 2:
|
|
4219
|
+
result = _context53.sent;
|
|
4220
|
+
console.log("[Checkout] \u91D1\u989D\u820D\u5165\u5B8C\u6210 - \u539F\u59CB: ".concat(result.originalAmount, ", \u820D\u5165\u540E: ").concat(result.roundedAmount, ", \u5DEE\u989D: ").concat(result.roundingDifference));
|
|
4221
|
+
return _context53.abrupt("return", result);
|
|
4222
|
+
case 5:
|
|
4223
|
+
case "end":
|
|
4224
|
+
return _context53.stop();
|
|
4225
|
+
}
|
|
4226
|
+
}, _callee53, this);
|
|
4227
|
+
}));
|
|
4228
|
+
function roundAmountAsync(_x36) {
|
|
4229
|
+
return _roundAmountAsync.apply(this, arguments);
|
|
4230
|
+
}
|
|
4231
|
+
return roundAmountAsync;
|
|
3739
4232
|
}())
|
|
3740
4233
|
}, {
|
|
3741
4234
|
key: "destroy",
|
|
3742
4235
|
value: function () {
|
|
3743
|
-
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4236
|
+
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54() {
|
|
3744
4237
|
var _this$order, _this$order$destroy, _this$payment, _this$payment$destroy;
|
|
3745
|
-
return _regeneratorRuntime().wrap(function
|
|
3746
|
-
while (1) switch (
|
|
4238
|
+
return _regeneratorRuntime().wrap(function _callee54$(_context54) {
|
|
4239
|
+
while (1) switch (_context54.prev = _context54.next) {
|
|
3747
4240
|
case 0:
|
|
3748
4241
|
// 清理钱包模块的所有缓存数据
|
|
3749
4242
|
this.payment.wallet.clearAllCache();
|
|
@@ -3752,10 +4245,10 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3752
4245
|
this.core.effects.offByModuleDestroy(this.name);
|
|
3753
4246
|
|
|
3754
4247
|
// 销毁子模块
|
|
3755
|
-
|
|
4248
|
+
_context54.next = 4;
|
|
3756
4249
|
return (_this$order = this.order) === null || _this$order === void 0 || (_this$order$destroy = _this$order.destroy) === null || _this$order$destroy === void 0 ? void 0 : _this$order$destroy.call(_this$order);
|
|
3757
4250
|
case 4:
|
|
3758
|
-
|
|
4251
|
+
_context54.next = 6;
|
|
3759
4252
|
return (_this$payment = this.payment) === null || _this$payment === void 0 || (_this$payment$destroy = _this$payment.destroy) === null || _this$payment$destroy === void 0 ? void 0 : _this$payment$destroy.call(_this$payment);
|
|
3760
4253
|
case 6:
|
|
3761
4254
|
// 取消注册模块
|
|
@@ -3763,15 +4256,136 @@ export var CheckoutImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3763
4256
|
console.log('[Checkout] 已销毁');
|
|
3764
4257
|
case 8:
|
|
3765
4258
|
case "end":
|
|
3766
|
-
return
|
|
4259
|
+
return _context54.stop();
|
|
3767
4260
|
}
|
|
3768
|
-
},
|
|
4261
|
+
}, _callee54, this);
|
|
3769
4262
|
}));
|
|
3770
4263
|
function destroy() {
|
|
3771
4264
|
return _destroy.apply(this, arguments);
|
|
3772
4265
|
}
|
|
3773
4266
|
return destroy;
|
|
3774
4267
|
}()
|
|
4268
|
+
/**
|
|
4269
|
+
* 重置 store 状态
|
|
4270
|
+
*
|
|
4271
|
+
* 在创建新订单前调用,确保状态完全干净
|
|
4272
|
+
*/
|
|
4273
|
+
}, {
|
|
4274
|
+
key: "resetStoreStateAsync",
|
|
4275
|
+
value: (function () {
|
|
4276
|
+
var _resetStoreStateAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55() {
|
|
4277
|
+
var prevOrderInfo;
|
|
4278
|
+
return _regeneratorRuntime().wrap(function _callee55$(_context55) {
|
|
4279
|
+
while (1) switch (_context55.prev = _context55.next) {
|
|
4280
|
+
case 0:
|
|
4281
|
+
_context55.prev = 0;
|
|
4282
|
+
prevOrderInfo = this.store.currentOrder ? {
|
|
4283
|
+
uuid: this.store.currentOrder.uuid,
|
|
4284
|
+
orderId: this.store.currentOrder.order_id
|
|
4285
|
+
} : null;
|
|
4286
|
+
console.log('[Checkout] 重置 store 状态,准备创建新订单', prevOrderInfo);
|
|
4287
|
+
|
|
4288
|
+
// 重置订单相关的 store 状态(保留 paymentMethods,因为支付方式数据变更不频繁)
|
|
4289
|
+
this.store.currentOrder = undefined;
|
|
4290
|
+
this.store.localOrderData = undefined;
|
|
4291
|
+
this.store.cartSummary = undefined;
|
|
4292
|
+
this.store.stateAmount = '0.00';
|
|
4293
|
+
this.store.isOrderSynced = false;
|
|
4294
|
+
this.store.currentCustomer = undefined;
|
|
4295
|
+
this.store.lastError = undefined;
|
|
4296
|
+
|
|
4297
|
+
// 清空购物车项目
|
|
4298
|
+
this.store.cartItems = [];
|
|
4299
|
+
|
|
4300
|
+
// 注意:故意保留 this.store.paymentMethods,因为支付方式数据不易变更,保留在内存中提高性能
|
|
4301
|
+
|
|
4302
|
+
// 重置状态和步骤为初始状态
|
|
4303
|
+
_context55.next = 13;
|
|
4304
|
+
return this.setStatus(CheckoutStatus.Ready);
|
|
4305
|
+
case 13:
|
|
4306
|
+
_context55.next = 15;
|
|
4307
|
+
return this.setStep(CheckoutStep.OrderConfirmation);
|
|
4308
|
+
case 15:
|
|
4309
|
+
// 清理钱包缓存
|
|
4310
|
+
this.payment.wallet.clearAllCache();
|
|
4311
|
+
console.log('[Checkout] Store 状态重置完成');
|
|
4312
|
+
|
|
4313
|
+
// 触发订单清理事件(如果之前有订单)
|
|
4314
|
+
if (!prevOrderInfo) {
|
|
4315
|
+
_context55.next = 20;
|
|
4316
|
+
break;
|
|
4317
|
+
}
|
|
4318
|
+
_context55.next = 20;
|
|
4319
|
+
return this.core.effects.emit(CheckoutHooks.OnOrderCleared, {
|
|
4320
|
+
previousOrder: prevOrderInfo,
|
|
4321
|
+
timestamp: Date.now()
|
|
4322
|
+
});
|
|
4323
|
+
case 20:
|
|
4324
|
+
_context55.next = 25;
|
|
4325
|
+
break;
|
|
4326
|
+
case 22:
|
|
4327
|
+
_context55.prev = 22;
|
|
4328
|
+
_context55.t0 = _context55["catch"](0);
|
|
4329
|
+
console.error('[Checkout] 重置 store 状态失败:', _context55.t0);
|
|
4330
|
+
case 25:
|
|
4331
|
+
case "end":
|
|
4332
|
+
return _context55.stop();
|
|
4333
|
+
}
|
|
4334
|
+
}, _callee55, this, [[0, 22]]);
|
|
4335
|
+
}));
|
|
4336
|
+
function resetStoreStateAsync() {
|
|
4337
|
+
return _resetStoreStateAsync.apply(this, arguments);
|
|
4338
|
+
}
|
|
4339
|
+
return resetStoreStateAsync;
|
|
4340
|
+
}()
|
|
4341
|
+
/**
|
|
4342
|
+
* 手动清理已完成的订单状态(公开方法)
|
|
4343
|
+
*
|
|
4344
|
+
* 供UI层调用的公开方法,用于手动清理订单状态
|
|
4345
|
+
*
|
|
4346
|
+
* @returns 清理结果
|
|
4347
|
+
*/
|
|
4348
|
+
)
|
|
4349
|
+
}, {
|
|
4350
|
+
key: "clearCompletedOrderAsync",
|
|
4351
|
+
value: (function () {
|
|
4352
|
+
var _clearCompletedOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56() {
|
|
4353
|
+
var prevOrderInfo;
|
|
4354
|
+
return _regeneratorRuntime().wrap(function _callee56$(_context56) {
|
|
4355
|
+
while (1) switch (_context56.prev = _context56.next) {
|
|
4356
|
+
case 0:
|
|
4357
|
+
_context56.prev = 0;
|
|
4358
|
+
prevOrderInfo = this.store.currentOrder ? {
|
|
4359
|
+
uuid: this.store.currentOrder.uuid,
|
|
4360
|
+
orderId: this.store.currentOrder.order_id
|
|
4361
|
+
} : null;
|
|
4362
|
+
_context56.next = 4;
|
|
4363
|
+
return this.resetStoreStateAsync();
|
|
4364
|
+
case 4:
|
|
4365
|
+
return _context56.abrupt("return", {
|
|
4366
|
+
success: true,
|
|
4367
|
+
message: prevOrderInfo ? '订单状态已成功清理' : '没有需要清理的订单状态',
|
|
4368
|
+
clearedOrder: prevOrderInfo
|
|
4369
|
+
});
|
|
4370
|
+
case 7:
|
|
4371
|
+
_context56.prev = 7;
|
|
4372
|
+
_context56.t0 = _context56["catch"](0);
|
|
4373
|
+
console.error('[Checkout] 手动清理订单状态失败:', _context56.t0);
|
|
4374
|
+
return _context56.abrupt("return", {
|
|
4375
|
+
success: false,
|
|
4376
|
+
message: _context56.t0 instanceof Error ? _context56.t0.message : '清理失败'
|
|
4377
|
+
});
|
|
4378
|
+
case 11:
|
|
4379
|
+
case "end":
|
|
4380
|
+
return _context56.stop();
|
|
4381
|
+
}
|
|
4382
|
+
}, _callee56, this, [[0, 7]]);
|
|
4383
|
+
}));
|
|
4384
|
+
function clearCompletedOrderAsync() {
|
|
4385
|
+
return _clearCompletedOrderAsync.apply(this, arguments);
|
|
4386
|
+
}
|
|
4387
|
+
return clearCompletedOrderAsync;
|
|
4388
|
+
}())
|
|
3775
4389
|
}]);
|
|
3776
4390
|
return CheckoutImpl;
|
|
3777
4391
|
}(BaseModule);
|