@pisell/pisellos 0.0.373 → 0.0.376
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/effects/index.d.ts +2 -2
- package/dist/model/strategy/adapter/walletPass/utils.js +7 -2
- package/dist/model/strategy/type.d.ts +1 -1
- package/dist/modules/Customer/types.d.ts +1 -1
- package/dist/modules/Payment/index.js +35 -7
- package/dist/modules/Payment/types.d.ts +9 -7
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/modules/Rules/types.d.ts +1 -1
- package/dist/modules/Schedule/type.d.ts +7 -7
- package/dist/modules/Schedule/types.d.ts +9 -9
- package/dist/solution/BookingByStep/index.d.ts +2 -2
- package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
- package/dist/solution/Checkout/index.js +31 -2
- package/dist/solution/Checkout/types.d.ts +2 -0
- package/dist/solution/ShopDiscount/types.d.ts +1 -1
- package/dist/solution/ShopDiscount/utils.d.ts +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/task.d.ts +2 -2
- package/dist/utils/watch.d.ts +2 -2
- package/lib/core/index.js +28 -27
- package/lib/effects/index.d.ts +2 -2
- package/lib/effects/index.js +7 -3
- package/lib/model/strategy/adapter/walletPass/evaluator.js +2 -3
- package/lib/model/strategy/adapter/walletPass/example.js +21 -21
- package/lib/model/strategy/adapter/walletPass/index.js +4 -2
- package/lib/model/strategy/adapter/walletPass/locales.js +10 -10
- package/lib/model/strategy/adapter/walletPass/utils.js +9 -4
- package/lib/model/strategy/index.js +10 -7
- package/lib/model/strategy/strategy-example.js +19 -19
- package/lib/model/strategy/type.d.ts +1 -1
- package/lib/modules/Account/index.js +10 -9
- package/lib/modules/AccountList/index.js +11 -14
- package/lib/modules/BaseModule.js +3 -6
- package/lib/modules/Cart/index.js +9 -14
- package/lib/modules/Cart/utils/cartProduct.js +6 -3
- package/lib/modules/Customer/constants.js +1 -1
- package/lib/modules/Customer/index.js +15 -18
- package/lib/modules/Customer/types.d.ts +1 -1
- package/lib/modules/Date/index.js +6 -10
- package/lib/modules/Date/types.js +0 -1
- package/lib/modules/Discount/index.js +6 -11
- package/lib/modules/Guests/index.js +15 -10
- package/lib/modules/Order/index.js +9 -11
- package/lib/modules/Payment/cash.js +1 -1
- package/lib/modules/Payment/cashRecommendationAlgorithm.js +1 -1
- package/lib/modules/Payment/eftpos.js +1 -1
- package/lib/modules/Payment/index.js +94 -86
- package/lib/modules/Payment/types.d.ts +9 -7
- package/lib/modules/Payment/utils.js +6 -3
- package/lib/modules/Payment/walletpass.js +33 -33
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Product/index.js +5 -6
- package/lib/modules/ProductList/index.js +3 -5
- package/lib/modules/Resource/index.js +12 -8
- package/lib/modules/Rules/index.js +21 -16
- package/lib/modules/Rules/types.d.ts +1 -1
- package/lib/modules/Schedule/index.js +5 -8
- package/lib/modules/Schedule/type.d.ts +7 -7
- package/lib/modules/Schedule/types.d.ts +9 -9
- package/lib/modules/Schedule/utils.js +4 -2
- package/lib/modules/Step/index.js +4 -7
- package/lib/modules/Summary/index.js +4 -9
- package/lib/plugins/request.js +33 -34
- package/lib/plugins/window.js +113 -101
- package/lib/solution/BookingByStep/index.d.ts +2 -2
- package/lib/solution/BookingByStep/index.js +129 -86
- package/lib/solution/BookingByStep/utils/capacity.js +15 -10
- package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
- package/lib/solution/BookingByStep/utils/resources.js +8 -4
- package/lib/solution/BookingByStep/utils/stock.js +6 -3
- package/lib/solution/BookingByStep/utils/timeslots.js +27 -24
- package/lib/solution/BookingTicket/index.js +14 -19
- package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +3 -3
- package/lib/solution/BookingTicket/utils/scan/handleScan.js +6 -6
- package/lib/solution/BookingTicket/utils/scan/index.js +1 -3
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +9 -10
- package/lib/solution/BuyTickets/index.js +15 -15
- package/lib/solution/Checkout/index.js +233 -217
- package/lib/solution/Checkout/types.d.ts +2 -0
- package/lib/solution/Checkout/utils/index.js +22 -18
- package/lib/solution/RegisterAndLogin/config.js +2 -2
- package/lib/solution/RegisterAndLogin/index.js +110 -114
- package/lib/solution/RegisterAndLogin/utils.js +9 -9
- package/lib/solution/ShopDiscount/index.js +13 -16
- package/lib/solution/ShopDiscount/types.d.ts +1 -1
- package/lib/solution/ShopDiscount/utils.d.ts +2 -2
- package/lib/types/index.d.ts +1 -1
- package/lib/utils/task.d.ts +2 -2
- package/lib/utils/task.js +3 -3
- package/lib/utils/watch.d.ts +2 -2
- package/lib/utils/watch.js +7 -5
- package/package.json +18 -17
|
@@ -43,32 +43,26 @@ var import_utils = require("./utils");
|
|
|
43
43
|
var import_utils2 = require("../../modules/Cart/utils");
|
|
44
44
|
__reExport(Checkout_exports, require("./types"), module.exports);
|
|
45
45
|
var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
46
|
-
defaultName = "checkout";
|
|
47
|
-
defaultVersion = "1.0.0";
|
|
48
|
-
isSolution = true;
|
|
49
|
-
request;
|
|
50
|
-
store;
|
|
51
|
-
otherParams = {};
|
|
52
|
-
logger;
|
|
53
|
-
// LoggerManager 实例
|
|
54
|
-
// 计算缓存(用于性能优化)
|
|
55
|
-
calculationCache = {};
|
|
56
|
-
// 直接挂载的模块
|
|
57
|
-
order;
|
|
58
|
-
payment;
|
|
59
46
|
constructor(name, version) {
|
|
60
47
|
super(name || "checkout", version || "1.0.0");
|
|
48
|
+
this.defaultName = "checkout";
|
|
49
|
+
this.defaultVersion = "1.0.0";
|
|
50
|
+
this.isSolution = true;
|
|
51
|
+
this.otherParams = {};
|
|
52
|
+
// LoggerManager 实例
|
|
53
|
+
// 计算缓存(用于性能优化)
|
|
54
|
+
this.calculationCache = {};
|
|
61
55
|
}
|
|
62
56
|
async initialize(core, options) {
|
|
63
57
|
this.core = core;
|
|
64
58
|
this.otherParams = options.otherParams || {};
|
|
65
59
|
this.request = core.getPlugin("request");
|
|
66
60
|
if (!this.request) {
|
|
67
|
-
throw new Error("Checkout
|
|
61
|
+
throw new Error("Checkout 解决方案需要 request 插件支持");
|
|
68
62
|
}
|
|
69
63
|
const appPlugin = core.getPlugin("app");
|
|
70
64
|
if (!appPlugin) {
|
|
71
|
-
throw new Error("Checkout
|
|
65
|
+
throw new Error("Checkout 解决方案需要 app 插件支持");
|
|
72
66
|
}
|
|
73
67
|
const app = appPlugin.getApp();
|
|
74
68
|
this.logger = app.logger;
|
|
@@ -86,7 +80,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
86
80
|
await this.initializeSubModules(core, options);
|
|
87
81
|
await this.preloadPaymentMethods();
|
|
88
82
|
await this.cleanupExpiredOrdersAsync();
|
|
89
|
-
console.log("[Checkout]
|
|
83
|
+
console.log("[Checkout] 初始化完成");
|
|
90
84
|
await this.core.effects.emit(`${this.name}:onCheckoutInitialized`, {
|
|
91
85
|
timestamp: Date.now()
|
|
92
86
|
});
|
|
@@ -162,14 +156,14 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
162
156
|
this.core.effects.on(
|
|
163
157
|
import_types2.PaymentHooks.OnPaymentMethodsLoaded,
|
|
164
158
|
async (methods) => {
|
|
165
|
-
console.log("[Checkout]
|
|
159
|
+
console.log("[Checkout] 收到支付方式加载完成事件:", methods.length);
|
|
166
160
|
this.store.paymentMethods = methods;
|
|
167
161
|
}
|
|
168
162
|
);
|
|
169
163
|
this.core.effects.on(
|
|
170
164
|
import_types2.PaymentHooks.OnPaymentMethodsChanged,
|
|
171
165
|
async (data) => {
|
|
172
|
-
console.log("[Checkout]
|
|
166
|
+
console.log("[Checkout] 收到支付方式变更事件:", {
|
|
173
167
|
oldCount: data.oldMethods.length,
|
|
174
168
|
newCount: data.newMethods.length
|
|
175
169
|
});
|
|
@@ -192,11 +186,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
192
186
|
if (!validation.valid) {
|
|
193
187
|
throw (0, import_utils.createCheckoutError)(
|
|
194
188
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
195
|
-
|
|
189
|
+
`参数验证失败: ${validation.errors.join(", ")}`
|
|
196
190
|
);
|
|
197
191
|
}
|
|
198
192
|
this.store.cartItems = params.cartItems;
|
|
199
|
-
console.log("[Checkout]
|
|
193
|
+
console.log("[Checkout] 结账流程初始化完成");
|
|
200
194
|
} catch (error) {
|
|
201
195
|
await this.handleError(error, import_types.CheckoutErrorType.UnknownError);
|
|
202
196
|
throw error;
|
|
@@ -204,7 +198,8 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
204
198
|
}
|
|
205
199
|
getHolderIdFromBooking(obj) {
|
|
206
200
|
var _a;
|
|
207
|
-
if (!obj)
|
|
201
|
+
if (!obj)
|
|
202
|
+
return void 0;
|
|
208
203
|
let ret = obj.holder_id || ((_a = obj.holder) == null ? void 0 : _a.form_record);
|
|
209
204
|
if (Array.isArray(ret)) {
|
|
210
205
|
return ret.length > 0 ? Number(ret[0]) : void 0;
|
|
@@ -316,13 +311,13 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
316
311
|
if (this.store.isOrderSynced) {
|
|
317
312
|
walletBusinessData.payment_order_id = (_i = this.store.currentOrder) == null ? void 0 : _i.order_id;
|
|
318
313
|
}
|
|
319
|
-
this.logInfo("
|
|
314
|
+
this.logInfo("开始拉取:initializeWalletDataFromBusinessAsync", {
|
|
320
315
|
walletBusinessData
|
|
321
316
|
});
|
|
322
317
|
await this.payment.wallet.initializeWalletDataFromBusinessAsync(
|
|
323
318
|
walletBusinessData
|
|
324
319
|
);
|
|
325
|
-
this.logInfo("
|
|
320
|
+
this.logInfo("调用结束:initializeWalletDataFromBusinessAsync", {
|
|
326
321
|
walletBusinessData
|
|
327
322
|
});
|
|
328
323
|
if (!this.store.currentOrder) {
|
|
@@ -418,7 +413,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
418
413
|
if (!validation.valid) {
|
|
419
414
|
throw (0, import_utils.createCheckoutError)(
|
|
420
415
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
421
|
-
|
|
416
|
+
`订单数据验证失败: ${validation.errors.join(", ")}`
|
|
422
417
|
);
|
|
423
418
|
}
|
|
424
419
|
const localOrderId = (0, import_utils.generateLocalOrderId)();
|
|
@@ -437,10 +432,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
437
432
|
};
|
|
438
433
|
if (customerInfo.customer_id || customerInfo.customer_name) {
|
|
439
434
|
this.store.currentCustomer = customerInfo;
|
|
440
|
-
console.log("[Checkout]
|
|
435
|
+
console.log("[Checkout] 保存客户信息:", customerInfo);
|
|
441
436
|
} else {
|
|
442
437
|
this.store.currentCustomer = void 0;
|
|
443
|
-
console.log("[Checkout]
|
|
438
|
+
console.log("[Checkout] 未提供客户信息");
|
|
444
439
|
}
|
|
445
440
|
const isNeedDeposit = this.checkIsNeedDepositAsync(
|
|
446
441
|
params.orderData.bookings,
|
|
@@ -477,7 +472,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
477
472
|
duration: `${updateAmountDuration}ms`,
|
|
478
473
|
performance: updateAmountDuration > 200 ? "slow" : updateAmountDuration > 100 ? "medium" : "fast"
|
|
479
474
|
});
|
|
480
|
-
this.logInfo("
|
|
475
|
+
this.logInfo("本地订单创建成功:", {
|
|
481
476
|
localOrderId,
|
|
482
477
|
uuid: paymentOrder.uuid,
|
|
483
478
|
totalAmount: amountInfo.totalAmount,
|
|
@@ -492,7 +487,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
492
487
|
error,
|
|
493
488
|
import_types.CheckoutErrorType.OrderCreationFailed
|
|
494
489
|
);
|
|
495
|
-
this.logError("
|
|
490
|
+
this.logError("本地订单创建失败:", error);
|
|
496
491
|
this.core.effects.emit(`${this.name}:onOrderCreationFailed`, {
|
|
497
492
|
error: this.store.lastError,
|
|
498
493
|
timestamp: Date.now()
|
|
@@ -519,7 +514,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
519
514
|
if (!validation.valid) {
|
|
520
515
|
throw (0, import_utils.createCheckoutError)(
|
|
521
516
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
522
|
-
|
|
517
|
+
`订单数据验证失败: ${validation.errors.join(", ")}`
|
|
523
518
|
);
|
|
524
519
|
}
|
|
525
520
|
const amountInfo = (0, import_utils.extractAmountFromCartSummary)(params.cartSummary);
|
|
@@ -583,11 +578,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
583
578
|
if (!updated)
|
|
584
579
|
throw (0, import_utils.createCheckoutError)(
|
|
585
580
|
import_types.CheckoutErrorType.UnknownError,
|
|
586
|
-
"
|
|
581
|
+
"订单更新失败"
|
|
587
582
|
);
|
|
588
583
|
this.store.currentOrder = updated;
|
|
589
584
|
await this.updateStateAmountToRemaining(false);
|
|
590
|
-
this.logInfo("
|
|
585
|
+
this.logInfo("本地订单更新成功(保留支付项):", {
|
|
591
586
|
orderId: params.orderId,
|
|
592
587
|
uuid: updated.uuid,
|
|
593
588
|
payments: ((_m = updated.payment) == null ? void 0 : _m.length) || 0,
|
|
@@ -624,6 +619,8 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
624
619
|
total_amount: amountInfo.totalAmount,
|
|
625
620
|
is_deposit: isNeedDeposit.hasDeposit ? 1 : 0,
|
|
626
621
|
deposit_amount: isNeedDeposit.total ? isNeedDeposit.total.toString() : "0.00",
|
|
622
|
+
existPayment: params.existPayment,
|
|
623
|
+
// 🔧 新增: 传递云端支付项
|
|
627
624
|
order_info: {
|
|
628
625
|
original_order_data: params.orderData,
|
|
629
626
|
cart_summary: params.cartSummary,
|
|
@@ -636,7 +633,26 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
636
633
|
}
|
|
637
634
|
});
|
|
638
635
|
this.store.currentOrder = created;
|
|
639
|
-
|
|
636
|
+
if (params.existPayment && params.existPayment.length > 0) {
|
|
637
|
+
const syncedPayments = created.payment.filter((p) => p.isSynced && p.status !== "voided");
|
|
638
|
+
const syncedAmount = syncedPayments.reduce((sum, p) => {
|
|
639
|
+
const amt = new import_decimal.default(p.amount || "0");
|
|
640
|
+
const rounding = new import_decimal.default(Number(p.rounding_amount) > 0 ? 0 : p.rounding_amount || "0").abs();
|
|
641
|
+
return sum.plus(amt).plus(rounding);
|
|
642
|
+
}, new import_decimal.default(0));
|
|
643
|
+
this.logInfo("云端订单初始化钱包数据", {
|
|
644
|
+
orderId: params.orderId,
|
|
645
|
+
totalAmount: created.total_amount,
|
|
646
|
+
expectAmount: created.expect_amount,
|
|
647
|
+
syncedAmount: syncedAmount.toFixed(2),
|
|
648
|
+
syncedPaymentCount: syncedPayments.length
|
|
649
|
+
});
|
|
650
|
+
this.initWalletData({
|
|
651
|
+
order_wait_pay_amount: Number(created.expect_amount)
|
|
652
|
+
});
|
|
653
|
+
} else {
|
|
654
|
+
this.initWalletData();
|
|
655
|
+
}
|
|
640
656
|
return created;
|
|
641
657
|
}
|
|
642
658
|
/**
|
|
@@ -647,7 +663,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
647
663
|
if (!this.store.currentOrder) {
|
|
648
664
|
throw (0, import_utils.createCheckoutError)(
|
|
649
665
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
650
|
-
"
|
|
666
|
+
"未找到当前订单"
|
|
651
667
|
);
|
|
652
668
|
}
|
|
653
669
|
const order = await this.payment.getPaymentOrderByUuidAsync(
|
|
@@ -656,7 +672,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
656
672
|
if (!order || order.payment_status !== import_types2.PaymentStatus.Finished) {
|
|
657
673
|
throw (0, import_utils.createCheckoutError)(
|
|
658
674
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
659
|
-
"
|
|
675
|
+
"订单支付未完成,无法完成结账"
|
|
660
676
|
);
|
|
661
677
|
}
|
|
662
678
|
this.payment.wallet.clearAllCache();
|
|
@@ -664,7 +680,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
664
680
|
orderId: order.id,
|
|
665
681
|
timestamp: Date.now()
|
|
666
682
|
});
|
|
667
|
-
console.log("[Checkout]
|
|
683
|
+
console.log("[Checkout] 结账流程完成:", order.id);
|
|
668
684
|
this.resetStoreState();
|
|
669
685
|
return {
|
|
670
686
|
success: true,
|
|
@@ -691,7 +707,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
691
707
|
try {
|
|
692
708
|
const { currentOrder, cartItems, localOrderData } = this.store;
|
|
693
709
|
if (!currentOrder) {
|
|
694
|
-
console.log("[Checkout]
|
|
710
|
+
console.log("[Checkout] 当前没有活跃订单");
|
|
695
711
|
return null;
|
|
696
712
|
}
|
|
697
713
|
const orderInfo = currentOrder.order_info || {};
|
|
@@ -714,7 +730,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
714
730
|
};
|
|
715
731
|
return result;
|
|
716
732
|
} catch (error) {
|
|
717
|
-
console.error("[Checkout]
|
|
733
|
+
console.error("[Checkout] 获取当前订单基础信息失败:", error);
|
|
718
734
|
return null;
|
|
719
735
|
}
|
|
720
736
|
}
|
|
@@ -727,7 +743,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
727
743
|
try {
|
|
728
744
|
const { currentOrder } = this.store;
|
|
729
745
|
if (!currentOrder) {
|
|
730
|
-
console.log("[Checkout]
|
|
746
|
+
console.log("[Checkout] 当前没有活跃订单,无法获取支付项");
|
|
731
747
|
return [];
|
|
732
748
|
}
|
|
733
749
|
const paymentItems = await this.payment.getPaymentItemsAsync(
|
|
@@ -735,7 +751,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
735
751
|
);
|
|
736
752
|
return paymentItems;
|
|
737
753
|
} catch (error) {
|
|
738
|
-
console.error("[Checkout]
|
|
754
|
+
console.error("[Checkout] 获取当前订单支付项失败:", error);
|
|
739
755
|
return [];
|
|
740
756
|
}
|
|
741
757
|
}
|
|
@@ -762,7 +778,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
762
778
|
async replaceLocalOrderIdAsync(newOrderId) {
|
|
763
779
|
try {
|
|
764
780
|
if (!this.store.currentOrder) {
|
|
765
|
-
console.warn("[Checkout]
|
|
781
|
+
console.warn("[Checkout] 没有当前订单,无法替换订单ID");
|
|
766
782
|
return null;
|
|
767
783
|
}
|
|
768
784
|
const updatedOrder = await this.payment.replaceOrderIdByUuidAsync(
|
|
@@ -775,7 +791,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
775
791
|
order: updatedOrder,
|
|
776
792
|
timestamp: Date.now()
|
|
777
793
|
});
|
|
778
|
-
console.log("[Checkout]
|
|
794
|
+
console.log("[Checkout] 本地订单ID替换成功:", {
|
|
779
795
|
uuid: updatedOrder.uuid,
|
|
780
796
|
newOrderId: updatedOrder.id
|
|
781
797
|
});
|
|
@@ -784,7 +800,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
784
800
|
}
|
|
785
801
|
return updatedOrder;
|
|
786
802
|
} catch (error) {
|
|
787
|
-
console.error("[Checkout]
|
|
803
|
+
console.error("[Checkout] 替换订单ID失败:", error);
|
|
788
804
|
await this.handleError(error, import_types.CheckoutErrorType.UnknownError);
|
|
789
805
|
return null;
|
|
790
806
|
}
|
|
@@ -800,14 +816,14 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
800
816
|
try {
|
|
801
817
|
const numAmount = parseFloat(amount);
|
|
802
818
|
if (isNaN(numAmount) || numAmount < 0) {
|
|
803
|
-
throw new Error(
|
|
819
|
+
throw new Error(`无效的支付金额: ${amount}`);
|
|
804
820
|
}
|
|
805
821
|
const oldAmount = this.store.stateAmount;
|
|
806
822
|
const formattedAmount = numAmount.toFixed(2);
|
|
807
823
|
if (oldAmount === formattedAmount) {
|
|
808
824
|
return;
|
|
809
825
|
}
|
|
810
|
-
this.logInfo("[Checkout]
|
|
826
|
+
this.logInfo("[Checkout] 设置自定义支付金额:", {
|
|
811
827
|
oldAmount,
|
|
812
828
|
newAmount: formattedAmount
|
|
813
829
|
});
|
|
@@ -818,8 +834,8 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
818
834
|
timestamp: Date.now()
|
|
819
835
|
});
|
|
820
836
|
} catch (error) {
|
|
821
|
-
const errorMessage = error instanceof Error ? error.message : "
|
|
822
|
-
console.error("[Checkout]
|
|
837
|
+
const errorMessage = error instanceof Error ? error.message : "设置支付金额失败";
|
|
838
|
+
console.error("[Checkout] 设置自定义支付金额失败:", errorMessage);
|
|
823
839
|
await this.handleError(
|
|
824
840
|
new Error(errorMessage),
|
|
825
841
|
import_types.CheckoutErrorType.ValidationFailed
|
|
@@ -854,10 +870,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
854
870
|
*/
|
|
855
871
|
getCartSummary() {
|
|
856
872
|
if (!this.store.cartSummary || this.store.cartSummary.length === 0) {
|
|
857
|
-
console.warn("[Checkout]
|
|
873
|
+
console.warn("[Checkout] 没有可用的购物车小计数据");
|
|
858
874
|
return null;
|
|
859
875
|
}
|
|
860
|
-
this.logInfo("
|
|
876
|
+
this.logInfo("获取购物车小计数据:", {
|
|
861
877
|
itemCount: this.store.cartSummary.length,
|
|
862
878
|
items: this.store.cartSummary.map((item) => ({
|
|
863
879
|
key: item.key,
|
|
@@ -878,20 +894,20 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
878
894
|
async getPaymentMethodsAsync() {
|
|
879
895
|
if (this.store.paymentMethods && this.store.paymentMethods.length > 0) {
|
|
880
896
|
this.logInfo(
|
|
881
|
-
|
|
897
|
+
`使用缓存的支付方式数据,共 ${this.store.paymentMethods.length} 种`
|
|
882
898
|
);
|
|
883
899
|
return this.store.paymentMethods;
|
|
884
900
|
}
|
|
885
|
-
this.logInfo("store
|
|
901
|
+
this.logInfo("store 中无缓存,从 Payment 模块获取支付方式...");
|
|
886
902
|
try {
|
|
887
903
|
const methods = await this.payment.getPayMethodListAsync();
|
|
888
904
|
this.store.paymentMethods = methods;
|
|
889
905
|
this.logInfo(
|
|
890
|
-
|
|
906
|
+
`从 Payment 模块获取到 ${methods.length} 种支付方式,已更新缓存`
|
|
891
907
|
);
|
|
892
908
|
return methods;
|
|
893
909
|
} catch (error) {
|
|
894
|
-
this.logError("
|
|
910
|
+
this.logError("获取支付方式失败:", error);
|
|
895
911
|
return [];
|
|
896
912
|
}
|
|
897
913
|
}
|
|
@@ -910,7 +926,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
910
926
|
if (!this.store.currentOrder) {
|
|
911
927
|
throw (0, import_utils.createCheckoutError)(
|
|
912
928
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
913
|
-
"
|
|
929
|
+
"未找到当前订单,无法添加支付项"
|
|
914
930
|
);
|
|
915
931
|
}
|
|
916
932
|
const orderPaymentType = this.store.currentOrder.is_deposit === 1 ? "deposit" : "normal";
|
|
@@ -929,35 +945,35 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
929
945
|
this.store.currentOrder.uuid,
|
|
930
946
|
paymentItemWithType
|
|
931
947
|
);
|
|
932
|
-
this.logInfo("
|
|
948
|
+
this.logInfo("支付项添加成功");
|
|
933
949
|
this.clearCalculationCache();
|
|
934
950
|
await this.updateStateAmountToRemaining();
|
|
935
951
|
const remainingAmount = await this.calculateRemainingAmountAsync();
|
|
936
952
|
if (Number(remainingAmount) > 0) {
|
|
937
|
-
this.logInfo("
|
|
953
|
+
this.logInfo("订单金额还有待付的,同步 EFTPOS 支付");
|
|
938
954
|
const isEftposPayment = ((_a = paymentItem.type) == null ? void 0 : _a.toLowerCase()) === "eftpos" || ((_b = paymentItem.code) == null ? void 0 : _b.toUpperCase().includes("EFTPOS"));
|
|
939
955
|
const isCashPayment2 = paymentItem.code === "CASHMANUAL";
|
|
940
956
|
const isCustomePayment = paymentItem.type === "custom";
|
|
941
|
-
this.logInfo("EFTPOS
|
|
957
|
+
this.logInfo("EFTPOS 支付检查:", {
|
|
942
958
|
paymentCode: paymentItem.code,
|
|
943
959
|
paymentType: paymentItem.type,
|
|
944
960
|
isEftposPayment,
|
|
945
961
|
currentOrderSynced: this.store.isOrderSynced
|
|
946
962
|
});
|
|
947
963
|
if (isEftposPayment || isCashPayment2 || isCustomePayment) {
|
|
948
|
-
this.logInfo("
|
|
964
|
+
this.logInfo("检测到 EFTPOS 支付,立即同步订单到后端...");
|
|
949
965
|
try {
|
|
950
966
|
const syncResult = await this.syncOrderToBackendWithReturn(true);
|
|
951
|
-
this.logInfo("EFTPOS
|
|
967
|
+
this.logInfo("EFTPOS 支付后订单同步完成 (已标记为手动同步):", {
|
|
952
968
|
orderId: syncResult.orderId,
|
|
953
969
|
isOrderSynced: this.store.isOrderSynced,
|
|
954
970
|
backendResponse: syncResult.response
|
|
955
971
|
});
|
|
956
972
|
} catch (error) {
|
|
957
|
-
this.logError("EFTPOS
|
|
973
|
+
this.logError("EFTPOS 支付后订单同步失败:", error);
|
|
958
974
|
await this.handleError(
|
|
959
975
|
new Error(
|
|
960
|
-
`EFTPOS
|
|
976
|
+
`EFTPOS 支付后订单同步失败: ${error instanceof Error ? error.message : String(error)}`
|
|
961
977
|
),
|
|
962
978
|
import_types.CheckoutErrorType.OrderCreationFailed
|
|
963
979
|
);
|
|
@@ -972,7 +988,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
972
988
|
timestamp: Date.now()
|
|
973
989
|
});
|
|
974
990
|
} catch (error) {
|
|
975
|
-
this.logError("
|
|
991
|
+
this.logError("添加支付项失败:", error);
|
|
976
992
|
await this.handleError(error, import_types.CheckoutErrorType.PaymentFailed);
|
|
977
993
|
throw error;
|
|
978
994
|
}
|
|
@@ -991,10 +1007,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
991
1007
|
if (!this.store.currentOrder) {
|
|
992
1008
|
throw (0, import_utils.createCheckoutError)(
|
|
993
1009
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
994
|
-
"
|
|
1010
|
+
"当前没有活跃订单,无法删除支付项"
|
|
995
1011
|
);
|
|
996
1012
|
}
|
|
997
|
-
this.logWarning("
|
|
1013
|
+
this.logWarning("开始删除支付项:", {
|
|
998
1014
|
orderUuid: this.store.currentOrder.uuid,
|
|
999
1015
|
paymentUuid
|
|
1000
1016
|
});
|
|
@@ -1007,10 +1023,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1007
1023
|
if (!paymentItem) {
|
|
1008
1024
|
throw (0, import_utils.createCheckoutError)(
|
|
1009
1025
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
1010
|
-
|
|
1026
|
+
`支付项不存在: ${paymentUuid}`
|
|
1011
1027
|
);
|
|
1012
1028
|
}
|
|
1013
|
-
this.logInfo("
|
|
1029
|
+
this.logInfo("找到要删除的支付项:", {
|
|
1014
1030
|
uuid: paymentItem.uuid,
|
|
1015
1031
|
code: paymentItem.code,
|
|
1016
1032
|
amount: paymentItem.amount,
|
|
@@ -1020,7 +1036,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1020
1036
|
this.store.currentOrder.uuid,
|
|
1021
1037
|
paymentUuid
|
|
1022
1038
|
);
|
|
1023
|
-
this.logInfo("Payment
|
|
1039
|
+
this.logInfo("Payment支付项删除完成", paymentItem);
|
|
1024
1040
|
this.clearCalculationCache();
|
|
1025
1041
|
const currentOrderId = this.store.currentOrder.order_id;
|
|
1026
1042
|
const isCurrentOrderReal = currentOrderId && !(0, import_utils.isVirtualOrderId)(currentOrderId);
|
|
@@ -1030,7 +1046,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1030
1046
|
if (updatedOrder) {
|
|
1031
1047
|
if (isCurrentOrderReal && (0, import_utils.isVirtualOrderId)(updatedOrder.order_id)) {
|
|
1032
1048
|
this.logWarning(
|
|
1033
|
-
"[Checkout] deletePaymentItemAsync:
|
|
1049
|
+
"[Checkout] deletePaymentItemAsync: 检测到订单ID回退,保护真实订单ID:",
|
|
1034
1050
|
{
|
|
1035
1051
|
currentRealId: currentOrderId,
|
|
1036
1052
|
retrievedVirtualId: updatedOrder.order_id
|
|
@@ -1049,7 +1065,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1049
1065
|
timestamp: Date.now()
|
|
1050
1066
|
});
|
|
1051
1067
|
} catch (error) {
|
|
1052
|
-
this.logError("
|
|
1068
|
+
this.logError("删除支付项失败:", error);
|
|
1053
1069
|
await this.handleError(error, import_types.CheckoutErrorType.PaymentFailed);
|
|
1054
1070
|
throw error;
|
|
1055
1071
|
}
|
|
@@ -1069,7 +1085,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1069
1085
|
if (!this.store.currentOrder) {
|
|
1070
1086
|
throw (0, import_utils.createCheckoutError)(
|
|
1071
1087
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
1072
|
-
"
|
|
1088
|
+
"当前没有活跃订单,无法更新代金券支付项"
|
|
1073
1089
|
);
|
|
1074
1090
|
}
|
|
1075
1091
|
const paymentItems = await this.payment.getPaymentItemsAsync(
|
|
@@ -1080,7 +1096,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1080
1096
|
const remainingValue = new import_decimal.default(remainingAmount);
|
|
1081
1097
|
const isOrderSynced = this.store.isOrderSynced;
|
|
1082
1098
|
if (remainingValue.lte(0) && isOrderSynced && voucherPaymentItems.length === 0 && allPaymentItemsSynced) {
|
|
1083
|
-
this.logInfo("
|
|
1099
|
+
this.logInfo("订单已同步且支付完成,跳过清空代金券操作避免重复同步:", {
|
|
1084
1100
|
orderUuid: this.store.currentOrder.uuid,
|
|
1085
1101
|
orderId: this.store.currentOrder.order_id,
|
|
1086
1102
|
remainingAmount,
|
|
@@ -1090,7 +1106,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1090
1106
|
});
|
|
1091
1107
|
return;
|
|
1092
1108
|
}
|
|
1093
|
-
this.logInfo("
|
|
1109
|
+
this.logInfo("开始批量更新代金券支付项:", {
|
|
1094
1110
|
voucherPaymentItems
|
|
1095
1111
|
});
|
|
1096
1112
|
const orderPaymentType = this.store.currentOrder.is_deposit === 1 ? "deposit" : "normal";
|
|
@@ -1098,7 +1114,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1098
1114
|
if (!item.voucher_id) {
|
|
1099
1115
|
throw (0, import_utils.createCheckoutError)(
|
|
1100
1116
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
1101
|
-
|
|
1117
|
+
`代金券支付项缺少 voucher_id: ${JSON.stringify(item)}`
|
|
1102
1118
|
);
|
|
1103
1119
|
}
|
|
1104
1120
|
const metadata = {
|
|
@@ -1125,7 +1141,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1125
1141
|
if (updatedOrder) {
|
|
1126
1142
|
if (isCurrentOrderReal && (0, import_utils.isVirtualOrderId)(updatedOrder.order_id)) {
|
|
1127
1143
|
this.logWarning(
|
|
1128
|
-
"updateVoucherPaymentItemsAsync:
|
|
1144
|
+
"updateVoucherPaymentItemsAsync: 检测到订单ID回退,保护真实订单ID:",
|
|
1129
1145
|
{
|
|
1130
1146
|
currentRealId: currentOrderId,
|
|
1131
1147
|
retrievedVirtualId: updatedOrder.order_id
|
|
@@ -1142,9 +1158,9 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1142
1158
|
amount: voucherPaymentItems.reduce((sum, item) => sum + parseFloat(String(item.amount)), 0).toFixed(2),
|
|
1143
1159
|
timestamp: Date.now()
|
|
1144
1160
|
});
|
|
1145
|
-
this.logInfo("
|
|
1161
|
+
this.logInfo("代金券支付项批量更新成功");
|
|
1146
1162
|
} catch (error) {
|
|
1147
|
-
this.logError("[Checkout]
|
|
1163
|
+
this.logError("[Checkout] 批量更新代金券支付项失败:", error);
|
|
1148
1164
|
await this.handleError(error, import_types.CheckoutErrorType.PaymentFailed);
|
|
1149
1165
|
throw error;
|
|
1150
1166
|
}
|
|
@@ -1162,19 +1178,19 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1162
1178
|
if (isDeposit !== 0 && isDeposit !== 1) {
|
|
1163
1179
|
throw (0, import_utils.createCheckoutError)(
|
|
1164
1180
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
1165
|
-
"isDeposit
|
|
1181
|
+
"isDeposit 参数只能是 0(全款订单)或 1(定金订单)"
|
|
1166
1182
|
);
|
|
1167
1183
|
}
|
|
1168
1184
|
if (!this.store.currentOrder) {
|
|
1169
1185
|
throw (0, import_utils.createCheckoutError)(
|
|
1170
1186
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
1171
|
-
"
|
|
1187
|
+
"未找到当前订单,无法修改定金状态"
|
|
1172
1188
|
);
|
|
1173
1189
|
}
|
|
1174
1190
|
const newDepositValue = isDeposit;
|
|
1175
1191
|
const oldDepositValue = this.store.currentOrder.is_deposit;
|
|
1176
1192
|
if (oldDepositValue === newDepositValue) {
|
|
1177
|
-
console.log("[Checkout]
|
|
1193
|
+
console.log("[Checkout] 定金状态无变化,跳过更新");
|
|
1178
1194
|
return;
|
|
1179
1195
|
}
|
|
1180
1196
|
let deposit_amount = this.store.currentOrder.deposit_amount || "0.00";
|
|
@@ -1202,12 +1218,12 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1202
1218
|
order: this.store.currentOrder,
|
|
1203
1219
|
timestamp: Date.now()
|
|
1204
1220
|
});
|
|
1205
|
-
this.logInfo("
|
|
1221
|
+
this.logInfo("订单定金状态更新成功:", {
|
|
1206
1222
|
isDeposit: newDepositValue,
|
|
1207
1223
|
depositAmount: this.store.currentOrder.deposit_amount
|
|
1208
1224
|
});
|
|
1209
1225
|
} catch (error) {
|
|
1210
|
-
this.logError("
|
|
1226
|
+
this.logError("更新订单定金状态失败:", error);
|
|
1211
1227
|
await this.handleError(
|
|
1212
1228
|
error,
|
|
1213
1229
|
import_types.CheckoutErrorType.ValidationFailed
|
|
@@ -1237,25 +1253,25 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1237
1253
|
if (depositValue.isNaN() || depositValue.lt(0)) {
|
|
1238
1254
|
throw (0, import_utils.createCheckoutError)(
|
|
1239
1255
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
1240
|
-
|
|
1256
|
+
`无效的定金金额格式: ${depositAmount}`
|
|
1241
1257
|
);
|
|
1242
1258
|
}
|
|
1243
1259
|
if (!this.store.currentOrder) {
|
|
1244
1260
|
throw (0, import_utils.createCheckoutError)(
|
|
1245
1261
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
1246
|
-
"
|
|
1262
|
+
"未找到当前订单,无法设置定金金额"
|
|
1247
1263
|
);
|
|
1248
1264
|
}
|
|
1249
1265
|
const formattedDepositAmount = depositValue.toFixed(2);
|
|
1250
1266
|
const oldDepositAmount = this.store.currentOrder.deposit_amount || "0.00";
|
|
1251
1267
|
if (formattedDepositAmount === oldDepositAmount) {
|
|
1252
|
-
this.logInfo("
|
|
1268
|
+
this.logInfo("定金金额无变化,跳过更新:", {
|
|
1253
1269
|
currentAmount: oldDepositAmount,
|
|
1254
1270
|
newAmount: formattedDepositAmount
|
|
1255
1271
|
});
|
|
1256
1272
|
return;
|
|
1257
1273
|
}
|
|
1258
|
-
this.logInfo("
|
|
1274
|
+
this.logInfo("开始设置订单定金金额:", {
|
|
1259
1275
|
orderUuid: this.store.currentOrder.uuid,
|
|
1260
1276
|
orderId: this.store.currentOrder.order_id,
|
|
1261
1277
|
oldDepositAmount,
|
|
@@ -1267,10 +1283,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1267
1283
|
};
|
|
1268
1284
|
if (depositValue.gt(0) && this.store.currentOrder.is_deposit !== 1) {
|
|
1269
1285
|
updateParams.is_deposit = 1;
|
|
1270
|
-
this.logInfo("
|
|
1286
|
+
this.logInfo("定金金额大于0,自动设置为定金订单");
|
|
1271
1287
|
} else if (depositValue.eq(0) && this.store.currentOrder.is_deposit === 1) {
|
|
1272
1288
|
updateParams.is_deposit = 0;
|
|
1273
|
-
this.logInfo("
|
|
1289
|
+
this.logInfo("定金金额为0,自动设置为全款订单");
|
|
1274
1290
|
}
|
|
1275
1291
|
await this.payment.updateOrderAsync(
|
|
1276
1292
|
this.store.currentOrder.uuid,
|
|
@@ -1294,7 +1310,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1294
1310
|
order: this.store.currentOrder,
|
|
1295
1311
|
timestamp: Date.now()
|
|
1296
1312
|
});
|
|
1297
|
-
this.logInfo("
|
|
1313
|
+
this.logInfo("订单定金金额设置成功:", {
|
|
1298
1314
|
orderUuid: this.store.currentOrder.uuid,
|
|
1299
1315
|
orderId: this.store.currentOrder.order_id,
|
|
1300
1316
|
oldDepositAmount,
|
|
@@ -1303,7 +1319,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1303
1319
|
totalAmount: this.store.currentOrder.total_amount
|
|
1304
1320
|
});
|
|
1305
1321
|
} catch (error) {
|
|
1306
|
-
this.logError("
|
|
1322
|
+
this.logError("设置订单定金金额失败:", error);
|
|
1307
1323
|
await this.handleError(
|
|
1308
1324
|
error,
|
|
1309
1325
|
import_types.CheckoutErrorType.ValidationFailed
|
|
@@ -1331,15 +1347,15 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1331
1347
|
if (!this.store.currentOrder) {
|
|
1332
1348
|
return {
|
|
1333
1349
|
success: false,
|
|
1334
|
-
message: "
|
|
1350
|
+
message: "当前没有活跃订单,无法同步"
|
|
1335
1351
|
};
|
|
1336
1352
|
}
|
|
1337
1353
|
const orderUuid = this.store.currentOrder.uuid;
|
|
1338
1354
|
const oldOrderId = this.store.currentOrder.order_id;
|
|
1339
1355
|
if (this.store.isOrderSynced) {
|
|
1340
|
-
this.logInfo("
|
|
1356
|
+
this.logInfo("订单已同步过,将执行更新操作");
|
|
1341
1357
|
}
|
|
1342
|
-
this.logInfo("
|
|
1358
|
+
this.logInfo("开始手动同步订单到后端:", {
|
|
1343
1359
|
orderUuid,
|
|
1344
1360
|
orderId: oldOrderId,
|
|
1345
1361
|
totalAmount: this.store.currentOrder.total_amount,
|
|
@@ -1348,7 +1364,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1348
1364
|
console.time("manualSyncOrderAsync");
|
|
1349
1365
|
const syncResult = await this.syncOrderToBackendWithReturn(true);
|
|
1350
1366
|
console.timeEnd("manualSyncOrderAsync");
|
|
1351
|
-
this.logInfo("
|
|
1367
|
+
this.logInfo("手动同步订单完成:", {
|
|
1352
1368
|
orderUuid,
|
|
1353
1369
|
syncResult,
|
|
1354
1370
|
oldOrderId,
|
|
@@ -1358,11 +1374,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1358
1374
|
const finalOrderId = this.store.currentOrder.order_id;
|
|
1359
1375
|
const finalIsVirtual = (0, import_utils.isVirtualOrderId)(finalOrderId);
|
|
1360
1376
|
if (finalIsVirtual) {
|
|
1361
|
-
this.logError("
|
|
1377
|
+
this.logError("严重警告:手动同步完成后订单ID仍为虚拟ID!");
|
|
1362
1378
|
}
|
|
1363
1379
|
if (syncResult.orderId !== finalOrderId) {
|
|
1364
1380
|
this.logError(
|
|
1365
|
-
"[Checkout]
|
|
1381
|
+
"[Checkout] 严重警告:返回的订单ID与存储的订单ID不一致!"
|
|
1366
1382
|
);
|
|
1367
1383
|
}
|
|
1368
1384
|
let newRes = {
|
|
@@ -1372,11 +1388,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1372
1388
|
await this.updateStateAmountToRemaining(false);
|
|
1373
1389
|
return newRes;
|
|
1374
1390
|
} catch (error) {
|
|
1375
|
-
this.logError("
|
|
1376
|
-
const errorMessage = error instanceof Error ? error.message : "
|
|
1391
|
+
this.logError("手动同步订单失败:", error);
|
|
1392
|
+
const errorMessage = error instanceof Error ? error.message : "同步失败";
|
|
1377
1393
|
return {
|
|
1378
1394
|
success: false,
|
|
1379
|
-
message:
|
|
1395
|
+
message: `订单同步失败: ${errorMessage}`,
|
|
1380
1396
|
orderUuid: (_e = this.store.currentOrder) == null ? void 0 : _e.uuid
|
|
1381
1397
|
};
|
|
1382
1398
|
}
|
|
@@ -1388,7 +1404,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1388
1404
|
*/
|
|
1389
1405
|
getOrderNote() {
|
|
1390
1406
|
if (!this.store.localOrderData) {
|
|
1391
|
-
console.log("[Checkout]
|
|
1407
|
+
console.log("[Checkout] 没有本地订单数据,无法获取备注");
|
|
1392
1408
|
return "";
|
|
1393
1409
|
}
|
|
1394
1410
|
return this.store.localOrderData.shop_note || "";
|
|
@@ -1411,11 +1427,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1411
1427
|
*/
|
|
1412
1428
|
isCurrentOrderSynced() {
|
|
1413
1429
|
if (!this.store.currentOrder) {
|
|
1414
|
-
console.log("[Checkout]
|
|
1430
|
+
console.log("[Checkout] 没有当前订单,同步状态为false");
|
|
1415
1431
|
return false;
|
|
1416
1432
|
}
|
|
1417
1433
|
const syncStatus = this.store.isOrderSynced;
|
|
1418
|
-
console.log("[Checkout]
|
|
1434
|
+
console.log("[Checkout] 当前订单同步状态:", {
|
|
1419
1435
|
orderUuid: this.store.currentOrder.uuid,
|
|
1420
1436
|
orderId: this.store.currentOrder.order_id,
|
|
1421
1437
|
isOrderSynced: syncStatus
|
|
@@ -1433,7 +1449,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1433
1449
|
async cancelCurrentOrderAsync(cancelReason) {
|
|
1434
1450
|
var _a, _b;
|
|
1435
1451
|
try {
|
|
1436
|
-
this.logInfo("
|
|
1452
|
+
this.logInfo("开始取消当前本地订单:", {
|
|
1437
1453
|
hasCurrentOrder: !!this.store.currentOrder,
|
|
1438
1454
|
orderUuid: (_a = this.store.currentOrder) == null ? void 0 : _a.uuid,
|
|
1439
1455
|
orderId: (_b = this.store.currentOrder) == null ? void 0 : _b.order_id,
|
|
@@ -1441,34 +1457,34 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1441
1457
|
cancelReason
|
|
1442
1458
|
});
|
|
1443
1459
|
if (!this.store.currentOrder) {
|
|
1444
|
-
this.logInfo("
|
|
1460
|
+
this.logInfo("没有当前订单,无需取消");
|
|
1445
1461
|
return {
|
|
1446
1462
|
success: false,
|
|
1447
|
-
message: "
|
|
1463
|
+
message: "没有当前订单可取消"
|
|
1448
1464
|
};
|
|
1449
1465
|
}
|
|
1450
1466
|
const currentOrderUuid = this.store.currentOrder.uuid;
|
|
1451
1467
|
const currentOrderId = this.store.currentOrder.order_id;
|
|
1452
1468
|
const isOrderSynced = this.store.isOrderSynced;
|
|
1453
1469
|
if (isOrderSynced) {
|
|
1454
|
-
this.logInfo("
|
|
1470
|
+
this.logInfo("订单已同步到后端,不能取消:", {
|
|
1455
1471
|
orderId: currentOrderId,
|
|
1456
1472
|
orderUuid: currentOrderUuid
|
|
1457
1473
|
});
|
|
1458
1474
|
return {
|
|
1459
1475
|
success: false,
|
|
1460
|
-
message: "
|
|
1476
|
+
message: "订单已同步到后端,无法取消",
|
|
1461
1477
|
orderId: currentOrderId
|
|
1462
1478
|
};
|
|
1463
1479
|
}
|
|
1464
1480
|
try {
|
|
1465
|
-
this.logInfo("
|
|
1481
|
+
this.logInfo("删除本地订单数据");
|
|
1466
1482
|
await this.payment.deletePaymentOrderAsync(currentOrderUuid);
|
|
1467
|
-
this.logInfo("
|
|
1483
|
+
this.logInfo("本地订单数据删除成功");
|
|
1468
1484
|
} catch (error) {
|
|
1469
|
-
this.logWarning("
|
|
1485
|
+
this.logWarning("删除本地订单数据失败,但继续执行:", error);
|
|
1470
1486
|
}
|
|
1471
|
-
this.logInfo("
|
|
1487
|
+
this.logInfo("清理订单相关状态");
|
|
1472
1488
|
this.store.currentOrder = void 0;
|
|
1473
1489
|
this.store.localOrderData = void 0;
|
|
1474
1490
|
this.store.stateAmount = "0.00";
|
|
@@ -1476,7 +1492,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1476
1492
|
this.store.isOrderSynced = false;
|
|
1477
1493
|
this.store.currentCustomer = void 0;
|
|
1478
1494
|
this.payment.wallet.clearAllCache();
|
|
1479
|
-
this.logInfo("
|
|
1495
|
+
this.logInfo("订单状态清理完成,currentOrder已释放");
|
|
1480
1496
|
await this.core.effects.emit(`${this.name}:onOrderCancelled`, {
|
|
1481
1497
|
orderUuid: currentOrderUuid,
|
|
1482
1498
|
orderId: currentOrderId,
|
|
@@ -1485,22 +1501,22 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1485
1501
|
// 只有未同步订单可以被取消
|
|
1486
1502
|
timestamp: Date.now()
|
|
1487
1503
|
});
|
|
1488
|
-
this.logInfo("
|
|
1504
|
+
this.logInfo("本地订单取消完成:", {
|
|
1489
1505
|
orderUuid: currentOrderUuid,
|
|
1490
1506
|
orderId: currentOrderId,
|
|
1491
1507
|
cancelReason
|
|
1492
1508
|
});
|
|
1493
1509
|
return {
|
|
1494
1510
|
success: true,
|
|
1495
|
-
message: "
|
|
1511
|
+
message: "本地订单已成功取消",
|
|
1496
1512
|
orderId: currentOrderId
|
|
1497
1513
|
};
|
|
1498
1514
|
} catch (error) {
|
|
1499
|
-
this.logError("
|
|
1500
|
-
const errorMessage = error instanceof Error ? error.message : "
|
|
1515
|
+
this.logError("取消本地订单失败:", error);
|
|
1516
|
+
const errorMessage = error instanceof Error ? error.message : "未知错误";
|
|
1501
1517
|
return {
|
|
1502
1518
|
success: false,
|
|
1503
|
-
message:
|
|
1519
|
+
message: `取消订单失败: ${errorMessage}`
|
|
1504
1520
|
};
|
|
1505
1521
|
}
|
|
1506
1522
|
}
|
|
@@ -1516,12 +1532,12 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1516
1532
|
if (!this.store.currentOrder) {
|
|
1517
1533
|
return {
|
|
1518
1534
|
success: false,
|
|
1519
|
-
message: "
|
|
1535
|
+
message: "当前没有活跃订单,无法保存"
|
|
1520
1536
|
};
|
|
1521
1537
|
}
|
|
1522
1538
|
const orderUuid = this.store.currentOrder.uuid;
|
|
1523
1539
|
const currentOrderId = this.store.currentOrder.order_id;
|
|
1524
|
-
this.logInfo("
|
|
1540
|
+
this.logInfo("开始保存订单并稍后支付:", {
|
|
1525
1541
|
orderUuid,
|
|
1526
1542
|
orderId: currentOrderId,
|
|
1527
1543
|
totalAmount: this.store.currentOrder.total_amount
|
|
@@ -1533,7 +1549,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1533
1549
|
true,
|
|
1534
1550
|
allPaymentItems
|
|
1535
1551
|
);
|
|
1536
|
-
this.logInfo("
|
|
1552
|
+
this.logInfo("保存订单完成:", {
|
|
1537
1553
|
orderUuid,
|
|
1538
1554
|
oldOrderId: currentOrderId,
|
|
1539
1555
|
syncResult,
|
|
@@ -1543,17 +1559,17 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1543
1559
|
});
|
|
1544
1560
|
return {
|
|
1545
1561
|
success: true,
|
|
1546
|
-
message: "
|
|
1562
|
+
message: "订单保存成功,可稍后继续支付",
|
|
1547
1563
|
orderId: syncResult.orderId,
|
|
1548
1564
|
orderUuid,
|
|
1549
1565
|
response: syncResult.response
|
|
1550
1566
|
};
|
|
1551
1567
|
} catch (error) {
|
|
1552
|
-
this.logError("
|
|
1553
|
-
const errorMessage = error instanceof Error ? error.message : "
|
|
1568
|
+
this.logError("保存订单失败:", error);
|
|
1569
|
+
const errorMessage = error instanceof Error ? error.message : "保存失败";
|
|
1554
1570
|
return {
|
|
1555
1571
|
success: false,
|
|
1556
|
-
message:
|
|
1572
|
+
message: `订单保存失败: ${errorMessage}`,
|
|
1557
1573
|
orderUuid: (_a = this.store.currentOrder) == null ? void 0 : _a.uuid
|
|
1558
1574
|
};
|
|
1559
1575
|
}
|
|
@@ -1569,10 +1585,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1569
1585
|
if (!this.store.localOrderData) {
|
|
1570
1586
|
throw (0, import_utils.createCheckoutError)(
|
|
1571
1587
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
1572
|
-
"
|
|
1588
|
+
"没有本地订单数据,无法更新备注"
|
|
1573
1589
|
);
|
|
1574
1590
|
}
|
|
1575
|
-
console.log("[Checkout]
|
|
1591
|
+
console.log("[Checkout] 更新订单备注:", {
|
|
1576
1592
|
orderUuid: (_a = this.store.currentOrder) == null ? void 0 : _a.uuid,
|
|
1577
1593
|
oldNote: this.store.localOrderData.shop_note,
|
|
1578
1594
|
newNote: note
|
|
@@ -1585,11 +1601,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1585
1601
|
this.store.currentOrder.uuid
|
|
1586
1602
|
);
|
|
1587
1603
|
if (orderInPayment && orderInPayment.note !== void 0) {
|
|
1588
|
-
console.log("[Checkout]
|
|
1604
|
+
console.log("[Checkout] 同步备注到Payment模块的订单数据中");
|
|
1589
1605
|
}
|
|
1590
1606
|
} catch (syncError) {
|
|
1591
1607
|
console.warn(
|
|
1592
|
-
"[Checkout]
|
|
1608
|
+
"[Checkout] 同步备注到Payment模块失败,但本地更新成功:",
|
|
1593
1609
|
syncError
|
|
1594
1610
|
);
|
|
1595
1611
|
}
|
|
@@ -1600,12 +1616,12 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1600
1616
|
newNote: note,
|
|
1601
1617
|
timestamp: Date.now()
|
|
1602
1618
|
});
|
|
1603
|
-
console.log("[Checkout]
|
|
1619
|
+
console.log("[Checkout] 订单备注更新成功:", {
|
|
1604
1620
|
oldNote,
|
|
1605
1621
|
newNote: note
|
|
1606
1622
|
});
|
|
1607
1623
|
} catch (error) {
|
|
1608
|
-
console.error("[Checkout]
|
|
1624
|
+
console.error("[Checkout] 更新订单备注失败:", error);
|
|
1609
1625
|
await this.handleError(
|
|
1610
1626
|
error,
|
|
1611
1627
|
import_types.CheckoutErrorType.ValidationFailed
|
|
@@ -1624,7 +1640,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1624
1640
|
context: {},
|
|
1625
1641
|
timestamp: Date.now()
|
|
1626
1642
|
});
|
|
1627
|
-
console.error("[Checkout]
|
|
1643
|
+
console.error("[Checkout] 错误:", checkoutError);
|
|
1628
1644
|
}
|
|
1629
1645
|
/**
|
|
1630
1646
|
* 处理支付成功
|
|
@@ -1647,7 +1663,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1647
1663
|
var _a;
|
|
1648
1664
|
const error = (0, import_utils.createCheckoutError)(
|
|
1649
1665
|
import_types.CheckoutErrorType.PaymentFailed,
|
|
1650
|
-
data.error || "
|
|
1666
|
+
data.error || "支付同步失败"
|
|
1651
1667
|
);
|
|
1652
1668
|
await this.handleError(
|
|
1653
1669
|
error instanceof Error ? error : new Error(String(error)),
|
|
@@ -1721,7 +1737,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1721
1737
|
});
|
|
1722
1738
|
return processedPaymentItem;
|
|
1723
1739
|
} catch (error) {
|
|
1724
|
-
this.logError("
|
|
1740
|
+
this.logError("处理现金支付项时出错:", error);
|
|
1725
1741
|
return paymentItem;
|
|
1726
1742
|
}
|
|
1727
1743
|
}
|
|
@@ -1730,12 +1746,12 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1730
1746
|
*/
|
|
1731
1747
|
async preloadPaymentMethods() {
|
|
1732
1748
|
try {
|
|
1733
|
-
console.log("[Checkout]
|
|
1749
|
+
console.log("[Checkout] 预加载支付方式...");
|
|
1734
1750
|
const methods = await this.payment.getPayMethodListAsync();
|
|
1735
1751
|
this.store.paymentMethods = methods;
|
|
1736
|
-
console.log(`[Checkout]
|
|
1752
|
+
console.log(`[Checkout] 预加载完成,共 ${methods.length} 种支付方式`);
|
|
1737
1753
|
} catch (error) {
|
|
1738
|
-
console.error("[Checkout]
|
|
1754
|
+
console.error("[Checkout] 预加载支付方式失败:", error);
|
|
1739
1755
|
this.store.paymentMethods = [];
|
|
1740
1756
|
}
|
|
1741
1757
|
}
|
|
@@ -1752,15 +1768,15 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1752
1768
|
const retentionDays = cleanupConfig.retentionDays || 7;
|
|
1753
1769
|
const maxOrdersToDelete = cleanupConfig.maxOrdersToDelete || 100;
|
|
1754
1770
|
if (!isCleanupEnabled) {
|
|
1755
|
-
console.log("[Checkout]
|
|
1771
|
+
console.log("[Checkout] 订单数据清理功能已禁用");
|
|
1756
1772
|
return;
|
|
1757
1773
|
}
|
|
1758
1774
|
console.log(
|
|
1759
|
-
`[Checkout]
|
|
1775
|
+
`[Checkout] 开始清理过期订单数据(保留 ${retentionDays} 天内的数据)...`
|
|
1760
1776
|
);
|
|
1761
1777
|
const allOrders = await this.payment.getOrderListAsync();
|
|
1762
1778
|
if (!allOrders || allOrders.length === 0) {
|
|
1763
|
-
console.log("[Checkout]
|
|
1779
|
+
console.log("[Checkout] 没有找到需要清理的订单数据");
|
|
1764
1780
|
return;
|
|
1765
1781
|
}
|
|
1766
1782
|
const thresholdDate = /* @__PURE__ */ new Date();
|
|
@@ -1795,7 +1811,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1795
1811
|
});
|
|
1796
1812
|
}
|
|
1797
1813
|
} catch (error) {
|
|
1798
|
-
console.warn(`[Checkout]
|
|
1814
|
+
console.warn(`[Checkout] 处理订单 ${order.uuid} 时出错:`, error);
|
|
1799
1815
|
continue;
|
|
1800
1816
|
}
|
|
1801
1817
|
}
|
|
@@ -1808,10 +1824,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1808
1824
|
await this.payment.deletePaymentOrderAsync(orderInfo.uuid);
|
|
1809
1825
|
deletedCount++;
|
|
1810
1826
|
console.log(
|
|
1811
|
-
`[Checkout]
|
|
1827
|
+
`[Checkout] 已删除过期订单: ${orderInfo.orderId} (${orderInfo.daysSinceCreated} 天前创建)`
|
|
1812
1828
|
);
|
|
1813
1829
|
} catch (error) {
|
|
1814
|
-
console.error(`[Checkout]
|
|
1830
|
+
console.error(`[Checkout] 删除订单 ${orderInfo.uuid} 失败:`, error);
|
|
1815
1831
|
}
|
|
1816
1832
|
}
|
|
1817
1833
|
const summary = {
|
|
@@ -1827,16 +1843,16 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1827
1843
|
this.logInfo("Expired orders cleanup completed", summary);
|
|
1828
1844
|
if (ordersToDelete.length > maxOrdersToDelete) {
|
|
1829
1845
|
console.log(
|
|
1830
|
-
`[Checkout]
|
|
1846
|
+
`[Checkout] 过期订单清理完成: 总计 ${allOrders.length} 个订单,发现 ${ordersToDelete.length} 个过期已同步订单,删除了 ${deletedCount} 个(限制为 ${maxOrdersToDelete} 个)`
|
|
1831
1847
|
);
|
|
1832
1848
|
} else {
|
|
1833
1849
|
console.log(
|
|
1834
|
-
`[Checkout]
|
|
1850
|
+
`[Checkout] 过期订单清理完成: 总计 ${allOrders.length} 个订单,删除了 ${deletedCount} 个过期已同步订单`
|
|
1835
1851
|
);
|
|
1836
1852
|
}
|
|
1837
1853
|
} catch (error) {
|
|
1838
1854
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1839
|
-
console.error("[Checkout]
|
|
1855
|
+
console.error("[Checkout] 清理过期订单数据失败:", error);
|
|
1840
1856
|
this.logError("Expired orders cleanup failed", { error: errorMessage });
|
|
1841
1857
|
}
|
|
1842
1858
|
}
|
|
@@ -1895,7 +1911,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1895
1911
|
*/
|
|
1896
1912
|
async calculatePaidAmountAsync() {
|
|
1897
1913
|
if (!this.store.currentOrder) {
|
|
1898
|
-
this.logWarning("[Checkout] calculatePaidAmountAsync:
|
|
1914
|
+
this.logWarning("[Checkout] calculatePaidAmountAsync: 没有当前订单");
|
|
1899
1915
|
return "0.00";
|
|
1900
1916
|
}
|
|
1901
1917
|
try {
|
|
@@ -1911,10 +1927,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1911
1927
|
);
|
|
1912
1928
|
const result = this.calculatePaidAmountFromItems(payments);
|
|
1913
1929
|
this.calculationCache.paidAmount = result;
|
|
1914
|
-
this.logInfo("calculatePaidAmountAsync:
|
|
1930
|
+
this.logInfo("calculatePaidAmountAsync: 计算结果 =", result);
|
|
1915
1931
|
return result;
|
|
1916
1932
|
} catch (error) {
|
|
1917
|
-
this.logError("calculatePaidAmountAsync
|
|
1933
|
+
this.logError("calculatePaidAmountAsync 失败:", error);
|
|
1918
1934
|
return "0.00";
|
|
1919
1935
|
}
|
|
1920
1936
|
}
|
|
@@ -1947,7 +1963,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1947
1963
|
*/
|
|
1948
1964
|
async calculateRemainingAmountAsync() {
|
|
1949
1965
|
if (!this.store.currentOrder) {
|
|
1950
|
-
this.logWarning("calculateRemainingAmountAsync:
|
|
1966
|
+
this.logWarning("calculateRemainingAmountAsync: 没有当前订单");
|
|
1951
1967
|
return "0.00";
|
|
1952
1968
|
}
|
|
1953
1969
|
const { currentOrder } = await this.fetchOrderDataBatch();
|
|
@@ -1956,7 +1972,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1956
1972
|
}
|
|
1957
1973
|
const paidAmountStr = await this.calculatePaidAmountAsync();
|
|
1958
1974
|
const result = this.calculateRemainingAmountFromData(currentOrder, paidAmountStr);
|
|
1959
|
-
this.logInfo("calculateRemainingAmountAsync:
|
|
1975
|
+
this.logInfo("calculateRemainingAmountAsync: 计算=", result);
|
|
1960
1976
|
return result;
|
|
1961
1977
|
}
|
|
1962
1978
|
/**
|
|
@@ -1967,7 +1983,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1967
1983
|
*/
|
|
1968
1984
|
async calculateRemainingTotalAmountAsync() {
|
|
1969
1985
|
if (!this.store.currentOrder) {
|
|
1970
|
-
this.logWarning("calculateRemainingTotalAmountAsync:
|
|
1986
|
+
this.logWarning("calculateRemainingTotalAmountAsync: 没有当前订单");
|
|
1971
1987
|
return "0.00";
|
|
1972
1988
|
}
|
|
1973
1989
|
const { currentOrder } = await this.fetchOrderDataBatch();
|
|
@@ -1976,7 +1992,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1976
1992
|
}
|
|
1977
1993
|
const paidAmountStr = await this.calculatePaidAmountAsync();
|
|
1978
1994
|
const result = this.calculateRemainingTotalAmountFromData(currentOrder, paidAmountStr);
|
|
1979
|
-
this.logInfo("calculateRemainingTotalAmountAsync:
|
|
1995
|
+
this.logInfo("calculateRemainingTotalAmountAsync: 计算=", result);
|
|
1980
1996
|
return result;
|
|
1981
1997
|
}
|
|
1982
1998
|
/**
|
|
@@ -1995,18 +2011,18 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1995
2011
|
timestamp: Date.now(),
|
|
1996
2012
|
totalAmount: remainingTotalAmount
|
|
1997
2013
|
});
|
|
1998
|
-
this.logInfo("balanceDueAmount
|
|
2014
|
+
this.logInfo("balanceDueAmount 已自动更新:", {
|
|
1999
2015
|
oldAmount: currentBalanceDueAmount,
|
|
2000
2016
|
newAmount: remainingAmount
|
|
2001
2017
|
});
|
|
2002
2018
|
} else {
|
|
2003
|
-
this.logInfo("balanceDueAmount
|
|
2019
|
+
this.logInfo("balanceDueAmount 无需更新,当前值已是最新:", {
|
|
2004
2020
|
balanceDueAmount: currentBalanceDueAmount,
|
|
2005
2021
|
remainingAmount
|
|
2006
2022
|
});
|
|
2007
2023
|
}
|
|
2008
2024
|
} catch (error) {
|
|
2009
|
-
this.logError("
|
|
2025
|
+
this.logError("更新 balanceDueAmount 失败:", error);
|
|
2010
2026
|
}
|
|
2011
2027
|
}
|
|
2012
2028
|
/**
|
|
@@ -2023,7 +2039,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2023
2039
|
const { paymentItems, currentOrder } = await this.fetchOrderDataBatch();
|
|
2024
2040
|
console.timeEnd("updateStateAmountToRemaining");
|
|
2025
2041
|
if (!currentOrder) {
|
|
2026
|
-
this.logWarning("updateStateAmountToRemaining:
|
|
2042
|
+
this.logWarning("updateStateAmountToRemaining: 未找到当前订单");
|
|
2027
2043
|
return;
|
|
2028
2044
|
}
|
|
2029
2045
|
const paidAmount = this.calculatePaidAmountFromItems(paymentItems);
|
|
@@ -2072,7 +2088,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2072
2088
|
totalAmount: remainingTotalAmount
|
|
2073
2089
|
});
|
|
2074
2090
|
}, 0);
|
|
2075
|
-
this.logInfo("stateAmount
|
|
2091
|
+
this.logInfo("stateAmount 已自动更新为剩余金额:", {
|
|
2076
2092
|
oldAmount: currentStateAmount,
|
|
2077
2093
|
newAmount: remainingAmount
|
|
2078
2094
|
});
|
|
@@ -2090,14 +2106,14 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2090
2106
|
totalAmount: remainingTotalAmount
|
|
2091
2107
|
});
|
|
2092
2108
|
}, 0);
|
|
2093
|
-
this.logInfo("balanceDueAmount
|
|
2109
|
+
this.logInfo("balanceDueAmount 已自动更新:", {
|
|
2094
2110
|
oldAmount: currentBalanceDueAmount,
|
|
2095
2111
|
newAmount: remainingAmount
|
|
2096
2112
|
});
|
|
2097
2113
|
}
|
|
2098
2114
|
console.timeEnd("updateStateAmountToRemaining: updateStateAmountToRemaining");
|
|
2099
2115
|
if (!hasStateChanged) {
|
|
2100
|
-
this.logInfo("
|
|
2116
|
+
this.logInfo("状态无需更新,当前值已是最新:", {
|
|
2101
2117
|
stateAmount: currentStateAmount,
|
|
2102
2118
|
remainingAmount
|
|
2103
2119
|
});
|
|
@@ -2105,10 +2121,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2105
2121
|
if (checkOrder) {
|
|
2106
2122
|
await this.checkOrderPaymentCompletionOptimized(paymentItems, remainingAmount);
|
|
2107
2123
|
} else {
|
|
2108
|
-
this.logInfo("
|
|
2124
|
+
this.logInfo("外部传入无需 checkOrder,不执行订单支付完成检测和同步");
|
|
2109
2125
|
}
|
|
2110
2126
|
} catch (error) {
|
|
2111
|
-
this.logError("
|
|
2127
|
+
this.logError("更新 stateAmount 为剩余金额失败:", error);
|
|
2112
2128
|
}
|
|
2113
2129
|
}
|
|
2114
2130
|
/**
|
|
@@ -2126,7 +2142,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2126
2142
|
if (remainingValue.lte(0)) {
|
|
2127
2143
|
const totalAmount = this.store.currentOrder.total_amount;
|
|
2128
2144
|
const paidAmount = this.calculationCache.paidAmount || "0.00";
|
|
2129
|
-
this.logInfo("
|
|
2145
|
+
this.logInfo("检测到订单支付完成:", {
|
|
2130
2146
|
orderUuid: this.store.currentOrder.uuid,
|
|
2131
2147
|
orderId: this.store.currentOrder.order_id,
|
|
2132
2148
|
totalAmount,
|
|
@@ -2139,13 +2155,13 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2139
2155
|
(item) => item.status !== "voided" && item.voucher_id
|
|
2140
2156
|
);
|
|
2141
2157
|
const shouldAutoSync = hasPaymentItems && !allPaymentsHaveVoucherId;
|
|
2142
|
-
this.logInfo("
|
|
2158
|
+
this.logInfo("自动同步订单条件检查:", {
|
|
2143
2159
|
paymentCount: paymentItems.length,
|
|
2144
2160
|
hasPaymentItems,
|
|
2145
2161
|
allHaveVoucherId: allPaymentsHaveVoucherId,
|
|
2146
2162
|
isOrderSynced: this.store.isOrderSynced,
|
|
2147
2163
|
shouldAutoSync,
|
|
2148
|
-
reason: shouldAutoSync ? "
|
|
2164
|
+
reason: shouldAutoSync ? "支付完成,需要同步最终支付状态" : "跳过同步",
|
|
2149
2165
|
paymentItems: paymentItems.map((p) => ({
|
|
2150
2166
|
uuid: p.uuid,
|
|
2151
2167
|
code: p.code,
|
|
@@ -2157,13 +2173,13 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2157
2173
|
}))
|
|
2158
2174
|
});
|
|
2159
2175
|
if (shouldAutoSync) {
|
|
2160
|
-
this.logInfo("
|
|
2176
|
+
this.logInfo("满足自动同步条件,开始同步订单到后端...");
|
|
2161
2177
|
await this.syncOrderToBackendWithReturn(false);
|
|
2162
2178
|
} else {
|
|
2163
2179
|
if (!hasPaymentItems) {
|
|
2164
|
-
this.logInfo("
|
|
2180
|
+
this.logInfo("没有支付项,跳过订单同步");
|
|
2165
2181
|
} else if (allPaymentsHaveVoucherId) {
|
|
2166
|
-
this.logInfo("
|
|
2182
|
+
this.logInfo("所有支付项均为代金券类型,跳过订单同步");
|
|
2167
2183
|
}
|
|
2168
2184
|
}
|
|
2169
2185
|
await this.core.effects.emit(`${this.name}:onOrderPaymentCompleted`, {
|
|
@@ -2176,7 +2192,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2176
2192
|
});
|
|
2177
2193
|
}
|
|
2178
2194
|
} catch (error) {
|
|
2179
|
-
this.logError("
|
|
2195
|
+
this.logError("检查订单支付完成状态失败:", error);
|
|
2180
2196
|
}
|
|
2181
2197
|
}
|
|
2182
2198
|
/**
|
|
@@ -2197,7 +2213,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2197
2213
|
if (remainingValue.lte(0)) {
|
|
2198
2214
|
const totalAmount = this.store.currentOrder.total_amount;
|
|
2199
2215
|
const paidAmount = await this.calculatePaidAmountAsync();
|
|
2200
|
-
this.logInfo("
|
|
2216
|
+
this.logInfo("检测到订单支付完成:", {
|
|
2201
2217
|
orderUuid: this.store.currentOrder.uuid,
|
|
2202
2218
|
orderId: this.store.currentOrder.order_id,
|
|
2203
2219
|
totalAmount,
|
|
@@ -2215,13 +2231,13 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2215
2231
|
(item) => item.status !== "voided" && item.voucher_id
|
|
2216
2232
|
);
|
|
2217
2233
|
const shouldAutoSync = hasPaymentItems && !allPaymentsHaveVoucherId;
|
|
2218
|
-
this.logInfo("
|
|
2234
|
+
this.logInfo("自动同步订单条件检查:", {
|
|
2219
2235
|
paymentCount: currentPayments.length,
|
|
2220
2236
|
hasPaymentItems,
|
|
2221
2237
|
allHaveVoucherId: allPaymentsHaveVoucherId,
|
|
2222
2238
|
isOrderSynced: this.store.isOrderSynced,
|
|
2223
2239
|
shouldAutoSync,
|
|
2224
|
-
reason: shouldAutoSync ? "
|
|
2240
|
+
reason: shouldAutoSync ? "支付完成,需要同步最终支付状态" : "跳过同步",
|
|
2225
2241
|
paymentItems: currentPayments.map((p) => ({
|
|
2226
2242
|
uuid: p.uuid,
|
|
2227
2243
|
code: p.code,
|
|
@@ -2233,13 +2249,13 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2233
2249
|
}))
|
|
2234
2250
|
});
|
|
2235
2251
|
if (shouldAutoSync) {
|
|
2236
|
-
this.logInfo("
|
|
2252
|
+
this.logInfo("满足自动同步条件,开始同步订单到后端...");
|
|
2237
2253
|
await this.syncOrderToBackendWithReturn(false);
|
|
2238
2254
|
} else {
|
|
2239
2255
|
if (!hasPaymentItems) {
|
|
2240
|
-
this.logInfo("
|
|
2256
|
+
this.logInfo("没有支付项,跳过订单同步");
|
|
2241
2257
|
} else if (allPaymentsHaveVoucherId) {
|
|
2242
|
-
this.logInfo("
|
|
2258
|
+
this.logInfo("所有支付项均为代金券类型,跳过订单同步");
|
|
2243
2259
|
}
|
|
2244
2260
|
}
|
|
2245
2261
|
await this.core.effects.emit(`${this.name}:onOrderPaymentCompleted`, {
|
|
@@ -2252,7 +2268,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2252
2268
|
});
|
|
2253
2269
|
}
|
|
2254
2270
|
} catch (error) {
|
|
2255
|
-
this.logError("
|
|
2271
|
+
this.logError("检查订单支付完成状态失败:", error);
|
|
2256
2272
|
}
|
|
2257
2273
|
}
|
|
2258
2274
|
/**
|
|
@@ -2265,12 +2281,12 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2265
2281
|
async syncOrderToBackendWithReturn(isManual = false, customPaymentItems) {
|
|
2266
2282
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2267
2283
|
if (!this.store.localOrderData || !this.store.currentOrder) {
|
|
2268
|
-
throw new Error("
|
|
2284
|
+
throw new Error("缺少必要的订单数据,无法同步到后端");
|
|
2269
2285
|
}
|
|
2270
2286
|
this.logInfo("syncOrderToBackendWithReturn called", { isManual });
|
|
2271
2287
|
const currentOrderId = this.store.currentOrder.order_id;
|
|
2272
2288
|
const isUpdateOperation = this.store.isOrderSynced || !(0, import_utils.isVirtualOrderId)(currentOrderId);
|
|
2273
|
-
this.logInfo(
|
|
2289
|
+
this.logInfo(`开始同步订单到后端...`, {
|
|
2274
2290
|
currentOrderId,
|
|
2275
2291
|
isVirtualId: (0, import_utils.isVirtualOrderId)(currentOrderId || ""),
|
|
2276
2292
|
orderUuid: this.store.currentOrder.uuid,
|
|
@@ -2294,15 +2310,15 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2294
2310
|
const manualDepositValue = new import_decimal.default(manualDepositAmount);
|
|
2295
2311
|
if (manualDepositValue.gt(0)) {
|
|
2296
2312
|
finalDepositAmount = manualDepositAmount;
|
|
2297
|
-
this.logInfo("
|
|
2313
|
+
this.logInfo("使用手动设置的定金金额", {
|
|
2298
2314
|
manualDepositAmount,
|
|
2299
|
-
reason: "
|
|
2315
|
+
reason: "用户通过setDepositAmountAsync手动设置了定金金额"
|
|
2300
2316
|
});
|
|
2301
2317
|
} else {
|
|
2302
2318
|
finalDepositAmount = "0.00";
|
|
2303
|
-
this.logInfo("
|
|
2319
|
+
this.logInfo("定金金额为0", {
|
|
2304
2320
|
manualDepositAmount,
|
|
2305
|
-
reason: "
|
|
2321
|
+
reason: "手动设置和计算值均为0"
|
|
2306
2322
|
});
|
|
2307
2323
|
}
|
|
2308
2324
|
if (this.store.currentOrder.is_deposit === 0 && processedPaymentItems.every((item) => item.order_payment_type !== "deposit")) {
|
|
@@ -2323,7 +2339,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2323
2339
|
return sum.plus(amt).sub(rounding);
|
|
2324
2340
|
}, new import_decimal.default(0)).toFixed(2);
|
|
2325
2341
|
}
|
|
2326
|
-
this.logInfo("
|
|
2342
|
+
this.logInfo("定金金额确定结果", {
|
|
2327
2343
|
depositPaymentItemsCount: processedPaymentItems.length,
|
|
2328
2344
|
depositPaymentItems: processedPaymentItems.map((item) => ({
|
|
2329
2345
|
uuid: item.uuid,
|
|
@@ -2384,7 +2400,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2384
2400
|
if (isUpdateOperation) {
|
|
2385
2401
|
if ((0, import_utils.isVirtualOrderId)(currentOrderId)) {
|
|
2386
2402
|
this.logWarning(
|
|
2387
|
-
"
|
|
2403
|
+
"尝试数据修复:暂时不包含order_id,注意:这次调用将作为创建操作处理,但后续会修复数据一致性"
|
|
2388
2404
|
);
|
|
2389
2405
|
} else {
|
|
2390
2406
|
orderParams.order_id = currentOrderId;
|
|
@@ -2409,11 +2425,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2409
2425
|
});
|
|
2410
2426
|
checkoutResponse = await this.order.createOrderByCheckout(orderParams);
|
|
2411
2427
|
submitSuccess = true;
|
|
2412
|
-
this.logInfo("
|
|
2428
|
+
this.logInfo("下单接口调用成功", checkoutResponse);
|
|
2413
2429
|
} catch (error) {
|
|
2414
2430
|
submitSuccess = false;
|
|
2415
2431
|
submitError = error instanceof Error ? error.message : String(error);
|
|
2416
|
-
this.logError("
|
|
2432
|
+
this.logError("下单接口调用失败:", submitError);
|
|
2417
2433
|
await this.core.effects.emit(`${this.name}:onOrderSyncFailed`, {
|
|
2418
2434
|
orderUuid: this.store.currentOrder.uuid,
|
|
2419
2435
|
operation: isUpdateOperation ? "update" : "create",
|
|
@@ -2439,7 +2455,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2439
2455
|
const responseStatus = checkoutResponse == null ? void 0 : checkoutResponse.status;
|
|
2440
2456
|
const isSuccessResponse = responseStatus === true || responseStatus === 200 || responseStatus === "success" || responseStatus === 1 && (checkoutResponse == null ? void 0 : checkoutResponse.code) === 200;
|
|
2441
2457
|
if (!isSuccessResponse) {
|
|
2442
|
-
const errorMessage = (checkoutResponse == null ? void 0 : checkoutResponse.message) || "
|
|
2458
|
+
const errorMessage = (checkoutResponse == null ? void 0 : checkoutResponse.message) || "订单同步失败,后端返回非成功状态";
|
|
2443
2459
|
await this.core.effects.emit(`${this.name}:onOrderSyncFailed`, {
|
|
2444
2460
|
orderUuid: this.store.currentOrder.uuid,
|
|
2445
2461
|
operation: isUpdateOperation ? "update" : "create",
|
|
@@ -2464,10 +2480,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2464
2480
|
extractedOrderId = String(extractedOrderId);
|
|
2465
2481
|
}
|
|
2466
2482
|
if (!extractedOrderId) {
|
|
2467
|
-
this.logError("
|
|
2483
|
+
this.logError("后端返回的订单信息中未包含订单ID");
|
|
2468
2484
|
}
|
|
2469
2485
|
realOrderId = extractedOrderId;
|
|
2470
|
-
this.logInfo("
|
|
2486
|
+
this.logInfo("准备替换订单ID:", {
|
|
2471
2487
|
orderUuid: this.store.currentOrder.uuid,
|
|
2472
2488
|
oldOrderId: this.store.currentOrder.order_id,
|
|
2473
2489
|
newOrderId: realOrderId
|
|
@@ -2477,38 +2493,38 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2477
2493
|
this.store.currentOrder.uuid,
|
|
2478
2494
|
realOrderId
|
|
2479
2495
|
);
|
|
2480
|
-
this.logInfo("Payment
|
|
2496
|
+
this.logInfo("Payment模块替换订单ID结果:", {
|
|
2481
2497
|
wasSuccessful: !!updatedOrder,
|
|
2482
2498
|
returnedOrderId: updatedOrder == null ? void 0 : updatedOrder.order_id,
|
|
2483
2499
|
expectedOrderId: realOrderId
|
|
2484
2500
|
});
|
|
2485
2501
|
if (updatedOrder) {
|
|
2486
|
-
this.logInfo("Payment
|
|
2502
|
+
this.logInfo("Payment模块返回的更新后订单:", {
|
|
2487
2503
|
uuid: updatedOrder.uuid,
|
|
2488
2504
|
orderId: updatedOrder.order_id,
|
|
2489
2505
|
totalAmount: updatedOrder.total_amount
|
|
2490
2506
|
});
|
|
2491
2507
|
this.store.currentOrder = updatedOrder;
|
|
2492
2508
|
this.logInfo(
|
|
2493
|
-
"[Checkout]
|
|
2509
|
+
"[Checkout] 订单ID替换成功,当前订单ID:",
|
|
2494
2510
|
this.store.currentOrder.order_id
|
|
2495
2511
|
);
|
|
2496
2512
|
} else {
|
|
2497
2513
|
this.logError(
|
|
2498
|
-
"[Checkout] Payment
|
|
2514
|
+
"[Checkout] Payment模块返回空订单,订单ID替换失败,开始手动替换"
|
|
2499
2515
|
);
|
|
2500
2516
|
const beforeManualUpdate = this.store.currentOrder.order_id;
|
|
2501
2517
|
this.store.currentOrder.order_id = realOrderId;
|
|
2502
|
-
this.logInfo("
|
|
2518
|
+
this.logInfo("手动设置订单ID:", {
|
|
2503
2519
|
beforeReplacement: beforeManualUpdate,
|
|
2504
2520
|
afterReplacement: this.store.currentOrder.order_id,
|
|
2505
|
-
|
|
2521
|
+
目标ID: realOrderId
|
|
2506
2522
|
});
|
|
2507
2523
|
}
|
|
2508
2524
|
} catch (error) {
|
|
2509
|
-
this.logError("
|
|
2525
|
+
this.logError("调用Payment模块替换订单ID时发生错误:", error);
|
|
2510
2526
|
this.store.currentOrder.order_id = realOrderId;
|
|
2511
|
-
this.logInfo("
|
|
2527
|
+
this.logInfo("错误恢复:手动设置订单ID:", realOrderId);
|
|
2512
2528
|
}
|
|
2513
2529
|
}
|
|
2514
2530
|
try {
|
|
@@ -2521,7 +2537,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2521
2537
|
);
|
|
2522
2538
|
}
|
|
2523
2539
|
} catch (e) {
|
|
2524
|
-
this.logWarning("
|
|
2540
|
+
this.logWarning("标记支付项已同步失败(不阻塞主流程)", { error: e });
|
|
2525
2541
|
}
|
|
2526
2542
|
this.store.isOrderSynced = true;
|
|
2527
2543
|
this.clearCalculationCache();
|
|
@@ -2566,7 +2582,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2566
2582
|
if (!orderId) {
|
|
2567
2583
|
return {
|
|
2568
2584
|
success: false,
|
|
2569
|
-
message: "
|
|
2585
|
+
message: "订单ID不能为空",
|
|
2570
2586
|
orderId
|
|
2571
2587
|
};
|
|
2572
2588
|
}
|
|
@@ -2580,7 +2596,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2580
2596
|
const response = await this.request.put(`/order/order/${orderId}/note`, {
|
|
2581
2597
|
note
|
|
2582
2598
|
});
|
|
2583
|
-
this.logInfo("
|
|
2599
|
+
this.logInfo("订单备注编辑响应:", {
|
|
2584
2600
|
orderId,
|
|
2585
2601
|
status: response.status,
|
|
2586
2602
|
message: response.message,
|
|
@@ -2601,12 +2617,12 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2601
2617
|
}
|
|
2602
2618
|
return {
|
|
2603
2619
|
success: true,
|
|
2604
|
-
message: response.message || "
|
|
2620
|
+
message: response.message || "订单备注修改成功",
|
|
2605
2621
|
orderId
|
|
2606
2622
|
};
|
|
2607
2623
|
} else {
|
|
2608
|
-
const errorMessage = response.message || "
|
|
2609
|
-
this.logError(
|
|
2624
|
+
const errorMessage = response.message || "订单备注修改失败";
|
|
2625
|
+
this.logError(`订单 ${orderId} 备注修改失败:`, errorMessage);
|
|
2610
2626
|
return {
|
|
2611
2627
|
success: false,
|
|
2612
2628
|
message: errorMessage,
|
|
@@ -2614,11 +2630,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2614
2630
|
};
|
|
2615
2631
|
}
|
|
2616
2632
|
} catch (error) {
|
|
2617
|
-
this.logError("
|
|
2618
|
-
const errorMessage = error instanceof Error ? error.message : "
|
|
2633
|
+
this.logError("编辑订单备注失败:", error);
|
|
2634
|
+
const errorMessage = error instanceof Error ? error.message : "网络错误或服务器异常";
|
|
2619
2635
|
return {
|
|
2620
2636
|
success: false,
|
|
2621
|
-
message:
|
|
2637
|
+
message: `编辑订单备注失败: ${errorMessage}`,
|
|
2622
2638
|
orderId
|
|
2623
2639
|
};
|
|
2624
2640
|
}
|
|
@@ -2644,13 +2660,13 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2644
2660
|
if (!params.order_ids || params.order_ids.length === 0) {
|
|
2645
2661
|
return {
|
|
2646
2662
|
success: false,
|
|
2647
|
-
message: "
|
|
2663
|
+
message: "订单ID列表不能为空"
|
|
2648
2664
|
};
|
|
2649
2665
|
}
|
|
2650
2666
|
if (!params.emails || params.emails.length === 0) {
|
|
2651
2667
|
return {
|
|
2652
2668
|
success: false,
|
|
2653
|
-
message: "
|
|
2669
|
+
message: "邮箱地址列表不能为空"
|
|
2654
2670
|
};
|
|
2655
2671
|
}
|
|
2656
2672
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
@@ -2660,7 +2676,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2660
2676
|
if (invalidEmails.length > 0) {
|
|
2661
2677
|
return {
|
|
2662
2678
|
success: false,
|
|
2663
|
-
message:
|
|
2679
|
+
message: `邮箱格式无效: ${invalidEmails.join(", ")}`
|
|
2664
2680
|
};
|
|
2665
2681
|
}
|
|
2666
2682
|
const requestBody = {
|
|
@@ -2676,7 +2692,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2676
2692
|
"/order/batch-email",
|
|
2677
2693
|
requestBody
|
|
2678
2694
|
);
|
|
2679
|
-
this.logInfo("
|
|
2695
|
+
this.logInfo("支付链接邮件发送响应:", {
|
|
2680
2696
|
status: response.status,
|
|
2681
2697
|
message: response.message,
|
|
2682
2698
|
data: response.data,
|
|
@@ -2685,22 +2701,22 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2685
2701
|
if (response.status === true || response.status === 200) {
|
|
2686
2702
|
return {
|
|
2687
2703
|
success: true,
|
|
2688
|
-
message: response.message || "
|
|
2704
|
+
message: response.message || "支付链接邮件发送成功"
|
|
2689
2705
|
};
|
|
2690
2706
|
} else {
|
|
2691
|
-
const errorMessage = response.message || "
|
|
2692
|
-
console.error("[Checkout]
|
|
2707
|
+
const errorMessage = response.message || "支付链接邮件发送失败";
|
|
2708
|
+
console.error("[Checkout] 支付链接邮件发送失败:", errorMessage);
|
|
2693
2709
|
return {
|
|
2694
2710
|
success: false,
|
|
2695
2711
|
message: errorMessage
|
|
2696
2712
|
};
|
|
2697
2713
|
}
|
|
2698
2714
|
} catch (error) {
|
|
2699
|
-
this.logError("
|
|
2700
|
-
const errorMessage = error instanceof Error ? error.message : "
|
|
2715
|
+
this.logError("发送客户支付链接邮件失败:", error);
|
|
2716
|
+
const errorMessage = error instanceof Error ? error.message : "网络错误或服务器异常";
|
|
2701
2717
|
return {
|
|
2702
2718
|
success: false,
|
|
2703
|
-
message:
|
|
2719
|
+
message: `发送支付链接邮件失败: ${errorMessage}`
|
|
2704
2720
|
};
|
|
2705
2721
|
}
|
|
2706
2722
|
}
|
|
@@ -2734,7 +2750,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2734
2750
|
await ((_b = (_a = this.order) == null ? void 0 : _a.destroy) == null ? void 0 : _b.call(_a));
|
|
2735
2751
|
await ((_d = (_c = this.payment) == null ? void 0 : _c.destroy) == null ? void 0 : _d.call(_c));
|
|
2736
2752
|
this.core.unregisterModule(this);
|
|
2737
|
-
console.log("[Checkout]
|
|
2753
|
+
console.log("[Checkout] 已销毁");
|
|
2738
2754
|
}
|
|
2739
2755
|
/**
|
|
2740
2756
|
* 重置 store 状态
|
|
@@ -2749,7 +2765,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2749
2765
|
uuid: this.store.currentOrder.uuid,
|
|
2750
2766
|
orderId: this.store.currentOrder.order_id
|
|
2751
2767
|
} : null;
|
|
2752
|
-
console.log("[Checkout]
|
|
2768
|
+
console.log("[Checkout] 重置 store 状态,准备创建新订单", prevOrderInfo);
|
|
2753
2769
|
this.store.currentOrder = void 0;
|
|
2754
2770
|
this.store.localOrderData = void 0;
|
|
2755
2771
|
this.store.cartSummary = void 0;
|
|
@@ -2761,7 +2777,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2761
2777
|
this.store.cartItems = [];
|
|
2762
2778
|
this.payment.wallet.clearAllCache();
|
|
2763
2779
|
this.clearCalculationCache();
|
|
2764
|
-
console.log("[Checkout] Store
|
|
2780
|
+
console.log("[Checkout] Store 状态重置完成");
|
|
2765
2781
|
if (prevOrderInfo) {
|
|
2766
2782
|
setTimeout(() => {
|
|
2767
2783
|
this.core.effects.emit(`${this.name}:onOrderCleared`, {
|
|
@@ -2771,7 +2787,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2771
2787
|
}, 0);
|
|
2772
2788
|
}
|
|
2773
2789
|
} catch (error) {
|
|
2774
|
-
console.error("[Checkout]
|
|
2790
|
+
console.error("[Checkout] 重置 store 状态失败:", error);
|
|
2775
2791
|
}
|
|
2776
2792
|
}
|
|
2777
2793
|
};
|