@pisell/pisellos 2.1.100 → 2.1.101
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/modules/Customer/types.d.ts +1 -1
- package/dist/modules/Payment/types.d.ts +7 -7
- package/dist/modules/Rules/types.d.ts +1 -1
- package/dist/modules/Schedule/getDateIsInSchedule.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 +1 -1
- package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
- 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/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 +7 -10
- 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 +73 -84
- package/lib/modules/Payment/types.d.ts +7 -7
- package/lib/modules/Payment/utils.js +6 -3
- package/lib/modules/Payment/walletpass.js +31 -31
- 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 +35 -21
- package/lib/modules/Rules/types.d.ts +1 -1
- package/lib/modules/Schedule/getDateIsInSchedule.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/modules/Summary/utils.js +16 -8
- package/lib/plugins/request.js +33 -34
- package/lib/plugins/window.js +113 -101
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +177 -110
- package/lib/solution/BookingByStep/utils/capacity.js +16 -11
- 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 +211 -216
- 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/solution/ShopDiscount/utils.js +2 -1
- 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 +17 -16
|
@@ -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;
|
|
@@ -315,13 +310,13 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
315
310
|
if (this.store.isOrderSynced) {
|
|
316
311
|
walletBusinessData.payment_order_id = (_f = this.store.currentOrder) == null ? void 0 : _f.order_id;
|
|
317
312
|
}
|
|
318
|
-
this.logInfo("
|
|
313
|
+
this.logInfo("开始拉取:initializeWalletDataFromBusinessAsync", {
|
|
319
314
|
walletBusinessData
|
|
320
315
|
});
|
|
321
316
|
await this.payment.wallet.initializeWalletDataFromBusinessAsync(
|
|
322
317
|
walletBusinessData
|
|
323
318
|
);
|
|
324
|
-
this.logInfo("
|
|
319
|
+
this.logInfo("调用结束:initializeWalletDataFromBusinessAsync", {
|
|
325
320
|
walletBusinessData
|
|
326
321
|
});
|
|
327
322
|
if (!this.store.currentOrder) {
|
|
@@ -417,7 +412,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
417
412
|
if (!validation.valid) {
|
|
418
413
|
throw (0, import_utils.createCheckoutError)(
|
|
419
414
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
420
|
-
|
|
415
|
+
`订单数据验证失败: ${validation.errors.join(", ")}`
|
|
421
416
|
);
|
|
422
417
|
}
|
|
423
418
|
const localOrderId = (0, import_utils.generateLocalOrderId)();
|
|
@@ -436,10 +431,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
436
431
|
};
|
|
437
432
|
if (customerInfo.customer_id || customerInfo.customer_name) {
|
|
438
433
|
this.store.currentCustomer = customerInfo;
|
|
439
|
-
console.log("[Checkout]
|
|
434
|
+
console.log("[Checkout] 保存客户信息:", customerInfo);
|
|
440
435
|
} else {
|
|
441
436
|
this.store.currentCustomer = void 0;
|
|
442
|
-
console.log("[Checkout]
|
|
437
|
+
console.log("[Checkout] 未提供客户信息");
|
|
443
438
|
}
|
|
444
439
|
const isNeedDeposit = this.checkIsNeedDepositAsync(
|
|
445
440
|
params.orderData.bookings,
|
|
@@ -476,7 +471,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
476
471
|
duration: `${updateAmountDuration}ms`,
|
|
477
472
|
performance: updateAmountDuration > 200 ? "slow" : updateAmountDuration > 100 ? "medium" : "fast"
|
|
478
473
|
});
|
|
479
|
-
this.logInfo("
|
|
474
|
+
this.logInfo("本地订单创建成功:", {
|
|
480
475
|
localOrderId,
|
|
481
476
|
uuid: paymentOrder.uuid,
|
|
482
477
|
totalAmount: amountInfo.totalAmount,
|
|
@@ -491,7 +486,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
491
486
|
error,
|
|
492
487
|
import_types.CheckoutErrorType.OrderCreationFailed
|
|
493
488
|
);
|
|
494
|
-
this.logError("
|
|
489
|
+
this.logError("本地订单创建失败:", error);
|
|
495
490
|
this.core.effects.emit(`${this.name}:onOrderCreationFailed`, {
|
|
496
491
|
error: this.store.lastError,
|
|
497
492
|
timestamp: Date.now()
|
|
@@ -518,7 +513,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
518
513
|
if (!validation.valid) {
|
|
519
514
|
throw (0, import_utils.createCheckoutError)(
|
|
520
515
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
521
|
-
|
|
516
|
+
`订单数据验证失败: ${validation.errors.join(", ")}`
|
|
522
517
|
);
|
|
523
518
|
}
|
|
524
519
|
const amountInfo = (0, import_utils.extractAmountFromCartSummary)(params.cartSummary);
|
|
@@ -582,11 +577,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
582
577
|
if (!updated)
|
|
583
578
|
throw (0, import_utils.createCheckoutError)(
|
|
584
579
|
import_types.CheckoutErrorType.UnknownError,
|
|
585
|
-
"
|
|
580
|
+
"订单更新失败"
|
|
586
581
|
);
|
|
587
582
|
this.store.currentOrder = updated;
|
|
588
583
|
await this.updateStateAmountToRemaining(false);
|
|
589
|
-
this.logInfo("
|
|
584
|
+
this.logInfo("本地订单更新成功(保留支付项):", {
|
|
590
585
|
orderId: params.orderId,
|
|
591
586
|
uuid: updated.uuid,
|
|
592
587
|
payments: ((_m = updated.payment) == null ? void 0 : _m.length) || 0,
|
|
@@ -646,7 +641,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
646
641
|
if (!this.store.currentOrder) {
|
|
647
642
|
throw (0, import_utils.createCheckoutError)(
|
|
648
643
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
649
|
-
"
|
|
644
|
+
"未找到当前订单"
|
|
650
645
|
);
|
|
651
646
|
}
|
|
652
647
|
const order = await this.payment.getPaymentOrderByUuidAsync(
|
|
@@ -655,7 +650,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
655
650
|
if (!order || order.payment_status !== import_types2.PaymentStatus.Finished) {
|
|
656
651
|
throw (0, import_utils.createCheckoutError)(
|
|
657
652
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
658
|
-
"
|
|
653
|
+
"订单支付未完成,无法完成结账"
|
|
659
654
|
);
|
|
660
655
|
}
|
|
661
656
|
this.payment.wallet.clearAllCache();
|
|
@@ -663,7 +658,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
663
658
|
orderId: order.id,
|
|
664
659
|
timestamp: Date.now()
|
|
665
660
|
});
|
|
666
|
-
console.log("[Checkout]
|
|
661
|
+
console.log("[Checkout] 结账流程完成:", order.id);
|
|
667
662
|
this.resetStoreState();
|
|
668
663
|
return {
|
|
669
664
|
success: true,
|
|
@@ -690,7 +685,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
690
685
|
try {
|
|
691
686
|
const { currentOrder, cartItems, localOrderData } = this.store;
|
|
692
687
|
if (!currentOrder) {
|
|
693
|
-
console.log("[Checkout]
|
|
688
|
+
console.log("[Checkout] 当前没有活跃订单");
|
|
694
689
|
return null;
|
|
695
690
|
}
|
|
696
691
|
const orderInfo = currentOrder.order_info || {};
|
|
@@ -713,7 +708,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
713
708
|
};
|
|
714
709
|
return result;
|
|
715
710
|
} catch (error) {
|
|
716
|
-
console.error("[Checkout]
|
|
711
|
+
console.error("[Checkout] 获取当前订单基础信息失败:", error);
|
|
717
712
|
return null;
|
|
718
713
|
}
|
|
719
714
|
}
|
|
@@ -726,7 +721,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
726
721
|
try {
|
|
727
722
|
const { currentOrder } = this.store;
|
|
728
723
|
if (!currentOrder) {
|
|
729
|
-
console.log("[Checkout]
|
|
724
|
+
console.log("[Checkout] 当前没有活跃订单,无法获取支付项");
|
|
730
725
|
return [];
|
|
731
726
|
}
|
|
732
727
|
const paymentItems = await this.payment.getPaymentItemsAsync(
|
|
@@ -734,7 +729,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
734
729
|
);
|
|
735
730
|
return paymentItems;
|
|
736
731
|
} catch (error) {
|
|
737
|
-
console.error("[Checkout]
|
|
732
|
+
console.error("[Checkout] 获取当前订单支付项失败:", error);
|
|
738
733
|
return [];
|
|
739
734
|
}
|
|
740
735
|
}
|
|
@@ -761,7 +756,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
761
756
|
async replaceLocalOrderIdAsync(newOrderId) {
|
|
762
757
|
try {
|
|
763
758
|
if (!this.store.currentOrder) {
|
|
764
|
-
console.warn("[Checkout]
|
|
759
|
+
console.warn("[Checkout] 没有当前订单,无法替换订单ID");
|
|
765
760
|
return null;
|
|
766
761
|
}
|
|
767
762
|
const updatedOrder = await this.payment.replaceOrderIdByUuidAsync(
|
|
@@ -774,7 +769,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
774
769
|
order: updatedOrder,
|
|
775
770
|
timestamp: Date.now()
|
|
776
771
|
});
|
|
777
|
-
console.log("[Checkout]
|
|
772
|
+
console.log("[Checkout] 本地订单ID替换成功:", {
|
|
778
773
|
uuid: updatedOrder.uuid,
|
|
779
774
|
newOrderId: updatedOrder.id
|
|
780
775
|
});
|
|
@@ -783,7 +778,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
783
778
|
}
|
|
784
779
|
return updatedOrder;
|
|
785
780
|
} catch (error) {
|
|
786
|
-
console.error("[Checkout]
|
|
781
|
+
console.error("[Checkout] 替换订单ID失败:", error);
|
|
787
782
|
await this.handleError(error, import_types.CheckoutErrorType.UnknownError);
|
|
788
783
|
return null;
|
|
789
784
|
}
|
|
@@ -799,14 +794,14 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
799
794
|
try {
|
|
800
795
|
const numAmount = parseFloat(amount);
|
|
801
796
|
if (isNaN(numAmount) || numAmount < 0) {
|
|
802
|
-
throw new Error(
|
|
797
|
+
throw new Error(`无效的支付金额: ${amount}`);
|
|
803
798
|
}
|
|
804
799
|
const oldAmount = this.store.stateAmount;
|
|
805
800
|
const formattedAmount = numAmount.toFixed(2);
|
|
806
801
|
if (oldAmount === formattedAmount) {
|
|
807
802
|
return;
|
|
808
803
|
}
|
|
809
|
-
this.logInfo("[Checkout]
|
|
804
|
+
this.logInfo("[Checkout] 设置自定义支付金额:", {
|
|
810
805
|
oldAmount,
|
|
811
806
|
newAmount: formattedAmount
|
|
812
807
|
});
|
|
@@ -817,8 +812,8 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
817
812
|
timestamp: Date.now()
|
|
818
813
|
});
|
|
819
814
|
} catch (error) {
|
|
820
|
-
const errorMessage = error instanceof Error ? error.message : "
|
|
821
|
-
console.error("[Checkout]
|
|
815
|
+
const errorMessage = error instanceof Error ? error.message : "设置支付金额失败";
|
|
816
|
+
console.error("[Checkout] 设置自定义支付金额失败:", errorMessage);
|
|
822
817
|
await this.handleError(
|
|
823
818
|
new Error(errorMessage),
|
|
824
819
|
import_types.CheckoutErrorType.ValidationFailed
|
|
@@ -853,10 +848,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
853
848
|
*/
|
|
854
849
|
getCartSummary() {
|
|
855
850
|
if (!this.store.cartSummary || this.store.cartSummary.length === 0) {
|
|
856
|
-
console.warn("[Checkout]
|
|
851
|
+
console.warn("[Checkout] 没有可用的购物车小计数据");
|
|
857
852
|
return null;
|
|
858
853
|
}
|
|
859
|
-
this.logInfo("
|
|
854
|
+
this.logInfo("获取购物车小计数据:", {
|
|
860
855
|
itemCount: this.store.cartSummary.length,
|
|
861
856
|
items: this.store.cartSummary.map((item) => ({
|
|
862
857
|
key: item.key,
|
|
@@ -877,20 +872,20 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
877
872
|
async getPaymentMethodsAsync() {
|
|
878
873
|
if (this.store.paymentMethods && this.store.paymentMethods.length > 0) {
|
|
879
874
|
this.logInfo(
|
|
880
|
-
|
|
875
|
+
`使用缓存的支付方式数据,共 ${this.store.paymentMethods.length} 种`
|
|
881
876
|
);
|
|
882
877
|
return this.store.paymentMethods;
|
|
883
878
|
}
|
|
884
|
-
this.logInfo("store
|
|
879
|
+
this.logInfo("store 中无缓存,从 Payment 模块获取支付方式...");
|
|
885
880
|
try {
|
|
886
881
|
const methods = await this.payment.getPayMethodListAsync();
|
|
887
882
|
this.store.paymentMethods = methods;
|
|
888
883
|
this.logInfo(
|
|
889
|
-
|
|
884
|
+
`从 Payment 模块获取到 ${methods.length} 种支付方式,已更新缓存`
|
|
890
885
|
);
|
|
891
886
|
return methods;
|
|
892
887
|
} catch (error) {
|
|
893
|
-
this.logError("
|
|
888
|
+
this.logError("获取支付方式失败:", error);
|
|
894
889
|
return [];
|
|
895
890
|
}
|
|
896
891
|
}
|
|
@@ -909,7 +904,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
909
904
|
if (!this.store.currentOrder) {
|
|
910
905
|
throw (0, import_utils.createCheckoutError)(
|
|
911
906
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
912
|
-
"
|
|
907
|
+
"未找到当前订单,无法添加支付项"
|
|
913
908
|
);
|
|
914
909
|
}
|
|
915
910
|
const orderPaymentType = this.store.currentOrder.is_deposit === 1 ? "deposit" : "normal";
|
|
@@ -928,35 +923,35 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
928
923
|
this.store.currentOrder.uuid,
|
|
929
924
|
paymentItemWithType
|
|
930
925
|
);
|
|
931
|
-
this.logInfo("
|
|
926
|
+
this.logInfo("支付项添加成功");
|
|
932
927
|
this.clearCalculationCache();
|
|
933
928
|
await this.updateStateAmountToRemaining();
|
|
934
929
|
const remainingAmount = await this.calculateRemainingAmountAsync();
|
|
935
930
|
if (Number(remainingAmount) > 0) {
|
|
936
|
-
this.logInfo("
|
|
931
|
+
this.logInfo("订单金额还有待付的,同步 EFTPOS 支付");
|
|
937
932
|
const isEftposPayment = ((_a = paymentItem.type) == null ? void 0 : _a.toLowerCase()) === "eftpos" || ((_b = paymentItem.code) == null ? void 0 : _b.toUpperCase().includes("EFTPOS"));
|
|
938
933
|
const isCashPayment2 = paymentItem.code === "CASHMANUAL";
|
|
939
934
|
const isCustomePayment = paymentItem.type === "custom";
|
|
940
|
-
this.logInfo("EFTPOS
|
|
935
|
+
this.logInfo("EFTPOS 支付检查:", {
|
|
941
936
|
paymentCode: paymentItem.code,
|
|
942
937
|
paymentType: paymentItem.type,
|
|
943
938
|
isEftposPayment,
|
|
944
939
|
currentOrderSynced: this.store.isOrderSynced
|
|
945
940
|
});
|
|
946
941
|
if (isEftposPayment || isCashPayment2 || isCustomePayment) {
|
|
947
|
-
this.logInfo("
|
|
942
|
+
this.logInfo("检测到 EFTPOS 支付,立即同步订单到后端...");
|
|
948
943
|
try {
|
|
949
944
|
const syncResult = await this.syncOrderToBackendWithReturn(true);
|
|
950
|
-
this.logInfo("EFTPOS
|
|
945
|
+
this.logInfo("EFTPOS 支付后订单同步完成 (已标记为手动同步):", {
|
|
951
946
|
orderId: syncResult.orderId,
|
|
952
947
|
isOrderSynced: this.store.isOrderSynced,
|
|
953
948
|
backendResponse: syncResult.response
|
|
954
949
|
});
|
|
955
950
|
} catch (error) {
|
|
956
|
-
this.logError("EFTPOS
|
|
951
|
+
this.logError("EFTPOS 支付后订单同步失败:", error);
|
|
957
952
|
await this.handleError(
|
|
958
953
|
new Error(
|
|
959
|
-
`EFTPOS
|
|
954
|
+
`EFTPOS 支付后订单同步失败: ${error instanceof Error ? error.message : String(error)}`
|
|
960
955
|
),
|
|
961
956
|
import_types.CheckoutErrorType.OrderCreationFailed
|
|
962
957
|
);
|
|
@@ -971,7 +966,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
971
966
|
timestamp: Date.now()
|
|
972
967
|
});
|
|
973
968
|
} catch (error) {
|
|
974
|
-
this.logError("
|
|
969
|
+
this.logError("添加支付项失败:", error);
|
|
975
970
|
await this.handleError(error, import_types.CheckoutErrorType.PaymentFailed);
|
|
976
971
|
throw error;
|
|
977
972
|
}
|
|
@@ -990,10 +985,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
990
985
|
if (!this.store.currentOrder) {
|
|
991
986
|
throw (0, import_utils.createCheckoutError)(
|
|
992
987
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
993
|
-
"
|
|
988
|
+
"当前没有活跃订单,无法删除支付项"
|
|
994
989
|
);
|
|
995
990
|
}
|
|
996
|
-
this.logWarning("
|
|
991
|
+
this.logWarning("开始删除支付项:", {
|
|
997
992
|
orderUuid: this.store.currentOrder.uuid,
|
|
998
993
|
paymentUuid
|
|
999
994
|
});
|
|
@@ -1006,10 +1001,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1006
1001
|
if (!paymentItem) {
|
|
1007
1002
|
throw (0, import_utils.createCheckoutError)(
|
|
1008
1003
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
1009
|
-
|
|
1004
|
+
`支付项不存在: ${paymentUuid}`
|
|
1010
1005
|
);
|
|
1011
1006
|
}
|
|
1012
|
-
this.logInfo("
|
|
1007
|
+
this.logInfo("找到要删除的支付项:", {
|
|
1013
1008
|
uuid: paymentItem.uuid,
|
|
1014
1009
|
code: paymentItem.code,
|
|
1015
1010
|
amount: paymentItem.amount,
|
|
@@ -1019,7 +1014,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1019
1014
|
this.store.currentOrder.uuid,
|
|
1020
1015
|
paymentUuid
|
|
1021
1016
|
);
|
|
1022
|
-
this.logInfo("Payment
|
|
1017
|
+
this.logInfo("Payment支付项删除完成", paymentItem);
|
|
1023
1018
|
this.clearCalculationCache();
|
|
1024
1019
|
const currentOrderId = this.store.currentOrder.order_id;
|
|
1025
1020
|
const isCurrentOrderReal = currentOrderId && !(0, import_utils.isVirtualOrderId)(currentOrderId);
|
|
@@ -1029,7 +1024,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1029
1024
|
if (updatedOrder) {
|
|
1030
1025
|
if (isCurrentOrderReal && (0, import_utils.isVirtualOrderId)(updatedOrder.order_id)) {
|
|
1031
1026
|
this.logWarning(
|
|
1032
|
-
"[Checkout] deletePaymentItemAsync:
|
|
1027
|
+
"[Checkout] deletePaymentItemAsync: 检测到订单ID回退,保护真实订单ID:",
|
|
1033
1028
|
{
|
|
1034
1029
|
currentRealId: currentOrderId,
|
|
1035
1030
|
retrievedVirtualId: updatedOrder.order_id
|
|
@@ -1048,7 +1043,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1048
1043
|
timestamp: Date.now()
|
|
1049
1044
|
});
|
|
1050
1045
|
} catch (error) {
|
|
1051
|
-
this.logError("
|
|
1046
|
+
this.logError("删除支付项失败:", error);
|
|
1052
1047
|
await this.handleError(error, import_types.CheckoutErrorType.PaymentFailed);
|
|
1053
1048
|
throw error;
|
|
1054
1049
|
}
|
|
@@ -1068,7 +1063,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1068
1063
|
if (!this.store.currentOrder) {
|
|
1069
1064
|
throw (0, import_utils.createCheckoutError)(
|
|
1070
1065
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
1071
|
-
"
|
|
1066
|
+
"当前没有活跃订单,无法更新代金券支付项"
|
|
1072
1067
|
);
|
|
1073
1068
|
}
|
|
1074
1069
|
const paymentItems = await this.payment.getPaymentItemsAsync(
|
|
@@ -1079,7 +1074,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1079
1074
|
const remainingValue = new import_decimal.default(remainingAmount);
|
|
1080
1075
|
const isOrderSynced = this.store.isOrderSynced;
|
|
1081
1076
|
if (remainingValue.lte(0) && isOrderSynced && voucherPaymentItems.length === 0 && allPaymentItemsSynced) {
|
|
1082
|
-
this.logInfo("
|
|
1077
|
+
this.logInfo("订单已同步且支付完成,跳过清空代金券操作避免重复同步:", {
|
|
1083
1078
|
orderUuid: this.store.currentOrder.uuid,
|
|
1084
1079
|
orderId: this.store.currentOrder.order_id,
|
|
1085
1080
|
remainingAmount,
|
|
@@ -1089,7 +1084,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1089
1084
|
});
|
|
1090
1085
|
return;
|
|
1091
1086
|
}
|
|
1092
|
-
this.logInfo("
|
|
1087
|
+
this.logInfo("开始批量更新代金券支付项:", {
|
|
1093
1088
|
voucherPaymentItems
|
|
1094
1089
|
});
|
|
1095
1090
|
const orderPaymentType = this.store.currentOrder.is_deposit === 1 ? "deposit" : "normal";
|
|
@@ -1097,7 +1092,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1097
1092
|
if (!item.voucher_id) {
|
|
1098
1093
|
throw (0, import_utils.createCheckoutError)(
|
|
1099
1094
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
1100
|
-
|
|
1095
|
+
`代金券支付项缺少 voucher_id: ${JSON.stringify(item)}`
|
|
1101
1096
|
);
|
|
1102
1097
|
}
|
|
1103
1098
|
const metadata = {
|
|
@@ -1124,7 +1119,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1124
1119
|
if (updatedOrder) {
|
|
1125
1120
|
if (isCurrentOrderReal && (0, import_utils.isVirtualOrderId)(updatedOrder.order_id)) {
|
|
1126
1121
|
this.logWarning(
|
|
1127
|
-
"updateVoucherPaymentItemsAsync:
|
|
1122
|
+
"updateVoucherPaymentItemsAsync: 检测到订单ID回退,保护真实订单ID:",
|
|
1128
1123
|
{
|
|
1129
1124
|
currentRealId: currentOrderId,
|
|
1130
1125
|
retrievedVirtualId: updatedOrder.order_id
|
|
@@ -1141,9 +1136,9 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1141
1136
|
amount: voucherPaymentItems.reduce((sum, item) => sum + parseFloat(String(item.amount)), 0).toFixed(2),
|
|
1142
1137
|
timestamp: Date.now()
|
|
1143
1138
|
});
|
|
1144
|
-
this.logInfo("
|
|
1139
|
+
this.logInfo("代金券支付项批量更新成功");
|
|
1145
1140
|
} catch (error) {
|
|
1146
|
-
this.logError("[Checkout]
|
|
1141
|
+
this.logError("[Checkout] 批量更新代金券支付项失败:", error);
|
|
1147
1142
|
await this.handleError(error, import_types.CheckoutErrorType.PaymentFailed);
|
|
1148
1143
|
throw error;
|
|
1149
1144
|
}
|
|
@@ -1161,19 +1156,19 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1161
1156
|
if (isDeposit !== 0 && isDeposit !== 1) {
|
|
1162
1157
|
throw (0, import_utils.createCheckoutError)(
|
|
1163
1158
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
1164
|
-
"isDeposit
|
|
1159
|
+
"isDeposit 参数只能是 0(全款订单)或 1(定金订单)"
|
|
1165
1160
|
);
|
|
1166
1161
|
}
|
|
1167
1162
|
if (!this.store.currentOrder) {
|
|
1168
1163
|
throw (0, import_utils.createCheckoutError)(
|
|
1169
1164
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
1170
|
-
"
|
|
1165
|
+
"未找到当前订单,无法修改定金状态"
|
|
1171
1166
|
);
|
|
1172
1167
|
}
|
|
1173
1168
|
const newDepositValue = isDeposit;
|
|
1174
1169
|
const oldDepositValue = this.store.currentOrder.is_deposit;
|
|
1175
1170
|
if (oldDepositValue === newDepositValue) {
|
|
1176
|
-
console.log("[Checkout]
|
|
1171
|
+
console.log("[Checkout] 定金状态无变化,跳过更新");
|
|
1177
1172
|
return;
|
|
1178
1173
|
}
|
|
1179
1174
|
let deposit_amount = this.store.currentOrder.deposit_amount || "0.00";
|
|
@@ -1201,12 +1196,12 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1201
1196
|
order: this.store.currentOrder,
|
|
1202
1197
|
timestamp: Date.now()
|
|
1203
1198
|
});
|
|
1204
|
-
this.logInfo("
|
|
1199
|
+
this.logInfo("订单定金状态更新成功:", {
|
|
1205
1200
|
isDeposit: newDepositValue,
|
|
1206
1201
|
depositAmount: this.store.currentOrder.deposit_amount
|
|
1207
1202
|
});
|
|
1208
1203
|
} catch (error) {
|
|
1209
|
-
this.logError("
|
|
1204
|
+
this.logError("更新订单定金状态失败:", error);
|
|
1210
1205
|
await this.handleError(
|
|
1211
1206
|
error,
|
|
1212
1207
|
import_types.CheckoutErrorType.ValidationFailed
|
|
@@ -1236,25 +1231,25 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1236
1231
|
if (depositValue.isNaN() || depositValue.lt(0)) {
|
|
1237
1232
|
throw (0, import_utils.createCheckoutError)(
|
|
1238
1233
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
1239
|
-
|
|
1234
|
+
`无效的定金金额格式: ${depositAmount}`
|
|
1240
1235
|
);
|
|
1241
1236
|
}
|
|
1242
1237
|
if (!this.store.currentOrder) {
|
|
1243
1238
|
throw (0, import_utils.createCheckoutError)(
|
|
1244
1239
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
1245
|
-
"
|
|
1240
|
+
"未找到当前订单,无法设置定金金额"
|
|
1246
1241
|
);
|
|
1247
1242
|
}
|
|
1248
1243
|
const formattedDepositAmount = depositValue.toFixed(2);
|
|
1249
1244
|
const oldDepositAmount = this.store.currentOrder.deposit_amount || "0.00";
|
|
1250
1245
|
if (formattedDepositAmount === oldDepositAmount) {
|
|
1251
|
-
this.logInfo("
|
|
1246
|
+
this.logInfo("定金金额无变化,跳过更新:", {
|
|
1252
1247
|
currentAmount: oldDepositAmount,
|
|
1253
1248
|
newAmount: formattedDepositAmount
|
|
1254
1249
|
});
|
|
1255
1250
|
return;
|
|
1256
1251
|
}
|
|
1257
|
-
this.logInfo("
|
|
1252
|
+
this.logInfo("开始设置订单定金金额:", {
|
|
1258
1253
|
orderUuid: this.store.currentOrder.uuid,
|
|
1259
1254
|
orderId: this.store.currentOrder.order_id,
|
|
1260
1255
|
oldDepositAmount,
|
|
@@ -1266,10 +1261,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1266
1261
|
};
|
|
1267
1262
|
if (depositValue.gt(0) && this.store.currentOrder.is_deposit !== 1) {
|
|
1268
1263
|
updateParams.is_deposit = 1;
|
|
1269
|
-
this.logInfo("
|
|
1264
|
+
this.logInfo("定金金额大于0,自动设置为定金订单");
|
|
1270
1265
|
} else if (depositValue.eq(0) && this.store.currentOrder.is_deposit === 1) {
|
|
1271
1266
|
updateParams.is_deposit = 0;
|
|
1272
|
-
this.logInfo("
|
|
1267
|
+
this.logInfo("定金金额为0,自动设置为全款订单");
|
|
1273
1268
|
}
|
|
1274
1269
|
await this.payment.updateOrderAsync(
|
|
1275
1270
|
this.store.currentOrder.uuid,
|
|
@@ -1293,7 +1288,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1293
1288
|
order: this.store.currentOrder,
|
|
1294
1289
|
timestamp: Date.now()
|
|
1295
1290
|
});
|
|
1296
|
-
this.logInfo("
|
|
1291
|
+
this.logInfo("订单定金金额设置成功:", {
|
|
1297
1292
|
orderUuid: this.store.currentOrder.uuid,
|
|
1298
1293
|
orderId: this.store.currentOrder.order_id,
|
|
1299
1294
|
oldDepositAmount,
|
|
@@ -1302,7 +1297,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1302
1297
|
totalAmount: this.store.currentOrder.total_amount
|
|
1303
1298
|
});
|
|
1304
1299
|
} catch (error) {
|
|
1305
|
-
this.logError("
|
|
1300
|
+
this.logError("设置订单定金金额失败:", error);
|
|
1306
1301
|
await this.handleError(
|
|
1307
1302
|
error,
|
|
1308
1303
|
import_types.CheckoutErrorType.ValidationFailed
|
|
@@ -1330,15 +1325,15 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1330
1325
|
if (!this.store.currentOrder) {
|
|
1331
1326
|
return {
|
|
1332
1327
|
success: false,
|
|
1333
|
-
message: "
|
|
1328
|
+
message: "当前没有活跃订单,无法同步"
|
|
1334
1329
|
};
|
|
1335
1330
|
}
|
|
1336
1331
|
const orderUuid = this.store.currentOrder.uuid;
|
|
1337
1332
|
const oldOrderId = this.store.currentOrder.order_id;
|
|
1338
1333
|
if (this.store.isOrderSynced) {
|
|
1339
|
-
this.logInfo("
|
|
1334
|
+
this.logInfo("订单已同步过,将执行更新操作");
|
|
1340
1335
|
}
|
|
1341
|
-
this.logInfo("
|
|
1336
|
+
this.logInfo("开始手动同步订单到后端:", {
|
|
1342
1337
|
orderUuid,
|
|
1343
1338
|
orderId: oldOrderId,
|
|
1344
1339
|
totalAmount: this.store.currentOrder.total_amount,
|
|
@@ -1347,7 +1342,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1347
1342
|
console.time("manualSyncOrderAsync");
|
|
1348
1343
|
const syncResult = await this.syncOrderToBackendWithReturn(true);
|
|
1349
1344
|
console.timeEnd("manualSyncOrderAsync");
|
|
1350
|
-
this.logInfo("
|
|
1345
|
+
this.logInfo("手动同步订单完成:", {
|
|
1351
1346
|
orderUuid,
|
|
1352
1347
|
syncResult,
|
|
1353
1348
|
oldOrderId,
|
|
@@ -1357,11 +1352,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1357
1352
|
const finalOrderId = this.store.currentOrder.order_id;
|
|
1358
1353
|
const finalIsVirtual = (0, import_utils.isVirtualOrderId)(finalOrderId);
|
|
1359
1354
|
if (finalIsVirtual) {
|
|
1360
|
-
this.logError("
|
|
1355
|
+
this.logError("严重警告:手动同步完成后订单ID仍为虚拟ID!");
|
|
1361
1356
|
}
|
|
1362
1357
|
if (syncResult.orderId !== finalOrderId) {
|
|
1363
1358
|
this.logError(
|
|
1364
|
-
"[Checkout]
|
|
1359
|
+
"[Checkout] 严重警告:返回的订单ID与存储的订单ID不一致!"
|
|
1365
1360
|
);
|
|
1366
1361
|
}
|
|
1367
1362
|
let newRes = {
|
|
@@ -1371,11 +1366,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1371
1366
|
await this.updateStateAmountToRemaining(false);
|
|
1372
1367
|
return newRes;
|
|
1373
1368
|
} catch (error) {
|
|
1374
|
-
this.logError("
|
|
1375
|
-
const errorMessage = error instanceof Error ? error.message : "
|
|
1369
|
+
this.logError("手动同步订单失败:", error);
|
|
1370
|
+
const errorMessage = error instanceof Error ? error.message : "同步失败";
|
|
1376
1371
|
return {
|
|
1377
1372
|
success: false,
|
|
1378
|
-
message:
|
|
1373
|
+
message: `订单同步失败: ${errorMessage}`,
|
|
1379
1374
|
orderUuid: (_e = this.store.currentOrder) == null ? void 0 : _e.uuid
|
|
1380
1375
|
};
|
|
1381
1376
|
}
|
|
@@ -1387,7 +1382,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1387
1382
|
*/
|
|
1388
1383
|
getOrderNote() {
|
|
1389
1384
|
if (!this.store.localOrderData) {
|
|
1390
|
-
console.log("[Checkout]
|
|
1385
|
+
console.log("[Checkout] 没有本地订单数据,无法获取备注");
|
|
1391
1386
|
return "";
|
|
1392
1387
|
}
|
|
1393
1388
|
return this.store.localOrderData.shop_note || "";
|
|
@@ -1410,11 +1405,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1410
1405
|
*/
|
|
1411
1406
|
isCurrentOrderSynced() {
|
|
1412
1407
|
if (!this.store.currentOrder) {
|
|
1413
|
-
console.log("[Checkout]
|
|
1408
|
+
console.log("[Checkout] 没有当前订单,同步状态为false");
|
|
1414
1409
|
return false;
|
|
1415
1410
|
}
|
|
1416
1411
|
const syncStatus = this.store.isOrderSynced;
|
|
1417
|
-
console.log("[Checkout]
|
|
1412
|
+
console.log("[Checkout] 当前订单同步状态:", {
|
|
1418
1413
|
orderUuid: this.store.currentOrder.uuid,
|
|
1419
1414
|
orderId: this.store.currentOrder.order_id,
|
|
1420
1415
|
isOrderSynced: syncStatus
|
|
@@ -1432,7 +1427,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1432
1427
|
async cancelCurrentOrderAsync(cancelReason) {
|
|
1433
1428
|
var _a, _b;
|
|
1434
1429
|
try {
|
|
1435
|
-
this.logInfo("
|
|
1430
|
+
this.logInfo("开始取消当前本地订单:", {
|
|
1436
1431
|
hasCurrentOrder: !!this.store.currentOrder,
|
|
1437
1432
|
orderUuid: (_a = this.store.currentOrder) == null ? void 0 : _a.uuid,
|
|
1438
1433
|
orderId: (_b = this.store.currentOrder) == null ? void 0 : _b.order_id,
|
|
@@ -1440,34 +1435,34 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1440
1435
|
cancelReason
|
|
1441
1436
|
});
|
|
1442
1437
|
if (!this.store.currentOrder) {
|
|
1443
|
-
this.logInfo("
|
|
1438
|
+
this.logInfo("没有当前订单,无需取消");
|
|
1444
1439
|
return {
|
|
1445
1440
|
success: false,
|
|
1446
|
-
message: "
|
|
1441
|
+
message: "没有当前订单可取消"
|
|
1447
1442
|
};
|
|
1448
1443
|
}
|
|
1449
1444
|
const currentOrderUuid = this.store.currentOrder.uuid;
|
|
1450
1445
|
const currentOrderId = this.store.currentOrder.order_id;
|
|
1451
1446
|
const isOrderSynced = this.store.isOrderSynced;
|
|
1452
1447
|
if (isOrderSynced) {
|
|
1453
|
-
this.logInfo("
|
|
1448
|
+
this.logInfo("订单已同步到后端,不能取消:", {
|
|
1454
1449
|
orderId: currentOrderId,
|
|
1455
1450
|
orderUuid: currentOrderUuid
|
|
1456
1451
|
});
|
|
1457
1452
|
return {
|
|
1458
1453
|
success: false,
|
|
1459
|
-
message: "
|
|
1454
|
+
message: "订单已同步到后端,无法取消",
|
|
1460
1455
|
orderId: currentOrderId
|
|
1461
1456
|
};
|
|
1462
1457
|
}
|
|
1463
1458
|
try {
|
|
1464
|
-
this.logInfo("
|
|
1459
|
+
this.logInfo("删除本地订单数据");
|
|
1465
1460
|
await this.payment.deletePaymentOrderAsync(currentOrderUuid);
|
|
1466
|
-
this.logInfo("
|
|
1461
|
+
this.logInfo("本地订单数据删除成功");
|
|
1467
1462
|
} catch (error) {
|
|
1468
|
-
this.logWarning("
|
|
1463
|
+
this.logWarning("删除本地订单数据失败,但继续执行:", error);
|
|
1469
1464
|
}
|
|
1470
|
-
this.logInfo("
|
|
1465
|
+
this.logInfo("清理订单相关状态");
|
|
1471
1466
|
this.store.currentOrder = void 0;
|
|
1472
1467
|
this.store.localOrderData = void 0;
|
|
1473
1468
|
this.store.stateAmount = "0.00";
|
|
@@ -1475,7 +1470,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1475
1470
|
this.store.isOrderSynced = false;
|
|
1476
1471
|
this.store.currentCustomer = void 0;
|
|
1477
1472
|
this.payment.wallet.clearAllCache();
|
|
1478
|
-
this.logInfo("
|
|
1473
|
+
this.logInfo("订单状态清理完成,currentOrder已释放");
|
|
1479
1474
|
await this.core.effects.emit(`${this.name}:onOrderCancelled`, {
|
|
1480
1475
|
orderUuid: currentOrderUuid,
|
|
1481
1476
|
orderId: currentOrderId,
|
|
@@ -1484,22 +1479,22 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1484
1479
|
// 只有未同步订单可以被取消
|
|
1485
1480
|
timestamp: Date.now()
|
|
1486
1481
|
});
|
|
1487
|
-
this.logInfo("
|
|
1482
|
+
this.logInfo("本地订单取消完成:", {
|
|
1488
1483
|
orderUuid: currentOrderUuid,
|
|
1489
1484
|
orderId: currentOrderId,
|
|
1490
1485
|
cancelReason
|
|
1491
1486
|
});
|
|
1492
1487
|
return {
|
|
1493
1488
|
success: true,
|
|
1494
|
-
message: "
|
|
1489
|
+
message: "本地订单已成功取消",
|
|
1495
1490
|
orderId: currentOrderId
|
|
1496
1491
|
};
|
|
1497
1492
|
} catch (error) {
|
|
1498
|
-
this.logError("
|
|
1499
|
-
const errorMessage = error instanceof Error ? error.message : "
|
|
1493
|
+
this.logError("取消本地订单失败:", error);
|
|
1494
|
+
const errorMessage = error instanceof Error ? error.message : "未知错误";
|
|
1500
1495
|
return {
|
|
1501
1496
|
success: false,
|
|
1502
|
-
message:
|
|
1497
|
+
message: `取消订单失败: ${errorMessage}`
|
|
1503
1498
|
};
|
|
1504
1499
|
}
|
|
1505
1500
|
}
|
|
@@ -1515,12 +1510,12 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1515
1510
|
if (!this.store.currentOrder) {
|
|
1516
1511
|
return {
|
|
1517
1512
|
success: false,
|
|
1518
|
-
message: "
|
|
1513
|
+
message: "当前没有活跃订单,无法保存"
|
|
1519
1514
|
};
|
|
1520
1515
|
}
|
|
1521
1516
|
const orderUuid = this.store.currentOrder.uuid;
|
|
1522
1517
|
const currentOrderId = this.store.currentOrder.order_id;
|
|
1523
|
-
this.logInfo("
|
|
1518
|
+
this.logInfo("开始保存订单并稍后支付:", {
|
|
1524
1519
|
orderUuid,
|
|
1525
1520
|
orderId: currentOrderId,
|
|
1526
1521
|
totalAmount: this.store.currentOrder.total_amount
|
|
@@ -1532,7 +1527,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1532
1527
|
true,
|
|
1533
1528
|
allPaymentItems
|
|
1534
1529
|
);
|
|
1535
|
-
this.logInfo("
|
|
1530
|
+
this.logInfo("保存订单完成:", {
|
|
1536
1531
|
orderUuid,
|
|
1537
1532
|
oldOrderId: currentOrderId,
|
|
1538
1533
|
syncResult,
|
|
@@ -1542,17 +1537,17 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1542
1537
|
});
|
|
1543
1538
|
return {
|
|
1544
1539
|
success: true,
|
|
1545
|
-
message: "
|
|
1540
|
+
message: "订单保存成功,可稍后继续支付",
|
|
1546
1541
|
orderId: syncResult.orderId,
|
|
1547
1542
|
orderUuid,
|
|
1548
1543
|
response: syncResult.response
|
|
1549
1544
|
};
|
|
1550
1545
|
} catch (error) {
|
|
1551
|
-
this.logError("
|
|
1552
|
-
const errorMessage = error instanceof Error ? error.message : "
|
|
1546
|
+
this.logError("保存订单失败:", error);
|
|
1547
|
+
const errorMessage = error instanceof Error ? error.message : "保存失败";
|
|
1553
1548
|
return {
|
|
1554
1549
|
success: false,
|
|
1555
|
-
message:
|
|
1550
|
+
message: `订单保存失败: ${errorMessage}`,
|
|
1556
1551
|
orderUuid: (_a = this.store.currentOrder) == null ? void 0 : _a.uuid
|
|
1557
1552
|
};
|
|
1558
1553
|
}
|
|
@@ -1568,10 +1563,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1568
1563
|
if (!this.store.localOrderData) {
|
|
1569
1564
|
throw (0, import_utils.createCheckoutError)(
|
|
1570
1565
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
1571
|
-
"
|
|
1566
|
+
"没有本地订单数据,无法更新备注"
|
|
1572
1567
|
);
|
|
1573
1568
|
}
|
|
1574
|
-
console.log("[Checkout]
|
|
1569
|
+
console.log("[Checkout] 更新订单备注:", {
|
|
1575
1570
|
orderUuid: (_a = this.store.currentOrder) == null ? void 0 : _a.uuid,
|
|
1576
1571
|
oldNote: this.store.localOrderData.shop_note,
|
|
1577
1572
|
newNote: note
|
|
@@ -1584,11 +1579,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1584
1579
|
this.store.currentOrder.uuid
|
|
1585
1580
|
);
|
|
1586
1581
|
if (orderInPayment && orderInPayment.note !== void 0) {
|
|
1587
|
-
console.log("[Checkout]
|
|
1582
|
+
console.log("[Checkout] 同步备注到Payment模块的订单数据中");
|
|
1588
1583
|
}
|
|
1589
1584
|
} catch (syncError) {
|
|
1590
1585
|
console.warn(
|
|
1591
|
-
"[Checkout]
|
|
1586
|
+
"[Checkout] 同步备注到Payment模块失败,但本地更新成功:",
|
|
1592
1587
|
syncError
|
|
1593
1588
|
);
|
|
1594
1589
|
}
|
|
@@ -1599,12 +1594,12 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1599
1594
|
newNote: note,
|
|
1600
1595
|
timestamp: Date.now()
|
|
1601
1596
|
});
|
|
1602
|
-
console.log("[Checkout]
|
|
1597
|
+
console.log("[Checkout] 订单备注更新成功:", {
|
|
1603
1598
|
oldNote,
|
|
1604
1599
|
newNote: note
|
|
1605
1600
|
});
|
|
1606
1601
|
} catch (error) {
|
|
1607
|
-
console.error("[Checkout]
|
|
1602
|
+
console.error("[Checkout] 更新订单备注失败:", error);
|
|
1608
1603
|
await this.handleError(
|
|
1609
1604
|
error,
|
|
1610
1605
|
import_types.CheckoutErrorType.ValidationFailed
|
|
@@ -1623,7 +1618,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1623
1618
|
context: {},
|
|
1624
1619
|
timestamp: Date.now()
|
|
1625
1620
|
});
|
|
1626
|
-
console.error("[Checkout]
|
|
1621
|
+
console.error("[Checkout] 错误:", checkoutError);
|
|
1627
1622
|
}
|
|
1628
1623
|
/**
|
|
1629
1624
|
* 处理支付成功
|
|
@@ -1646,7 +1641,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1646
1641
|
var _a;
|
|
1647
1642
|
const error = (0, import_utils.createCheckoutError)(
|
|
1648
1643
|
import_types.CheckoutErrorType.PaymentFailed,
|
|
1649
|
-
data.error || "
|
|
1644
|
+
data.error || "支付同步失败"
|
|
1650
1645
|
);
|
|
1651
1646
|
await this.handleError(
|
|
1652
1647
|
error instanceof Error ? error : new Error(String(error)),
|
|
@@ -1720,7 +1715,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1720
1715
|
});
|
|
1721
1716
|
return processedPaymentItem;
|
|
1722
1717
|
} catch (error) {
|
|
1723
|
-
this.logError("
|
|
1718
|
+
this.logError("处理现金支付项时出错:", error);
|
|
1724
1719
|
return paymentItem;
|
|
1725
1720
|
}
|
|
1726
1721
|
}
|
|
@@ -1729,12 +1724,12 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1729
1724
|
*/
|
|
1730
1725
|
async preloadPaymentMethods() {
|
|
1731
1726
|
try {
|
|
1732
|
-
console.log("[Checkout]
|
|
1727
|
+
console.log("[Checkout] 预加载支付方式...");
|
|
1733
1728
|
const methods = await this.payment.getPayMethodListAsync();
|
|
1734
1729
|
this.store.paymentMethods = methods;
|
|
1735
|
-
console.log(`[Checkout]
|
|
1730
|
+
console.log(`[Checkout] 预加载完成,共 ${methods.length} 种支付方式`);
|
|
1736
1731
|
} catch (error) {
|
|
1737
|
-
console.error("[Checkout]
|
|
1732
|
+
console.error("[Checkout] 预加载支付方式失败:", error);
|
|
1738
1733
|
this.store.paymentMethods = [];
|
|
1739
1734
|
}
|
|
1740
1735
|
}
|
|
@@ -1751,15 +1746,15 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1751
1746
|
const retentionDays = cleanupConfig.retentionDays || 7;
|
|
1752
1747
|
const maxOrdersToDelete = cleanupConfig.maxOrdersToDelete || 100;
|
|
1753
1748
|
if (!isCleanupEnabled) {
|
|
1754
|
-
console.log("[Checkout]
|
|
1749
|
+
console.log("[Checkout] 订单数据清理功能已禁用");
|
|
1755
1750
|
return;
|
|
1756
1751
|
}
|
|
1757
1752
|
console.log(
|
|
1758
|
-
`[Checkout]
|
|
1753
|
+
`[Checkout] 开始清理过期订单数据(保留 ${retentionDays} 天内的数据)...`
|
|
1759
1754
|
);
|
|
1760
1755
|
const allOrders = await this.payment.getOrderListAsync();
|
|
1761
1756
|
if (!allOrders || allOrders.length === 0) {
|
|
1762
|
-
console.log("[Checkout]
|
|
1757
|
+
console.log("[Checkout] 没有找到需要清理的订单数据");
|
|
1763
1758
|
return;
|
|
1764
1759
|
}
|
|
1765
1760
|
const thresholdDate = /* @__PURE__ */ new Date();
|
|
@@ -1794,7 +1789,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1794
1789
|
});
|
|
1795
1790
|
}
|
|
1796
1791
|
} catch (error) {
|
|
1797
|
-
console.warn(`[Checkout]
|
|
1792
|
+
console.warn(`[Checkout] 处理订单 ${order.uuid} 时出错:`, error);
|
|
1798
1793
|
continue;
|
|
1799
1794
|
}
|
|
1800
1795
|
}
|
|
@@ -1807,10 +1802,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1807
1802
|
await this.payment.deletePaymentOrderAsync(orderInfo.uuid);
|
|
1808
1803
|
deletedCount++;
|
|
1809
1804
|
console.log(
|
|
1810
|
-
`[Checkout]
|
|
1805
|
+
`[Checkout] 已删除过期订单: ${orderInfo.orderId} (${orderInfo.daysSinceCreated} 天前创建)`
|
|
1811
1806
|
);
|
|
1812
1807
|
} catch (error) {
|
|
1813
|
-
console.error(`[Checkout]
|
|
1808
|
+
console.error(`[Checkout] 删除订单 ${orderInfo.uuid} 失败:`, error);
|
|
1814
1809
|
}
|
|
1815
1810
|
}
|
|
1816
1811
|
const summary = {
|
|
@@ -1826,16 +1821,16 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1826
1821
|
this.logInfo("Expired orders cleanup completed", summary);
|
|
1827
1822
|
if (ordersToDelete.length > maxOrdersToDelete) {
|
|
1828
1823
|
console.log(
|
|
1829
|
-
`[Checkout]
|
|
1824
|
+
`[Checkout] 过期订单清理完成: 总计 ${allOrders.length} 个订单,发现 ${ordersToDelete.length} 个过期已同步订单,删除了 ${deletedCount} 个(限制为 ${maxOrdersToDelete} 个)`
|
|
1830
1825
|
);
|
|
1831
1826
|
} else {
|
|
1832
1827
|
console.log(
|
|
1833
|
-
`[Checkout]
|
|
1828
|
+
`[Checkout] 过期订单清理完成: 总计 ${allOrders.length} 个订单,删除了 ${deletedCount} 个过期已同步订单`
|
|
1834
1829
|
);
|
|
1835
1830
|
}
|
|
1836
1831
|
} catch (error) {
|
|
1837
1832
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1838
|
-
console.error("[Checkout]
|
|
1833
|
+
console.error("[Checkout] 清理过期订单数据失败:", error);
|
|
1839
1834
|
this.logError("Expired orders cleanup failed", { error: errorMessage });
|
|
1840
1835
|
}
|
|
1841
1836
|
}
|
|
@@ -1894,7 +1889,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1894
1889
|
*/
|
|
1895
1890
|
async calculatePaidAmountAsync() {
|
|
1896
1891
|
if (!this.store.currentOrder) {
|
|
1897
|
-
this.logWarning("[Checkout] calculatePaidAmountAsync:
|
|
1892
|
+
this.logWarning("[Checkout] calculatePaidAmountAsync: 没有当前订单");
|
|
1898
1893
|
return "0.00";
|
|
1899
1894
|
}
|
|
1900
1895
|
try {
|
|
@@ -1910,10 +1905,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1910
1905
|
);
|
|
1911
1906
|
const result = this.calculatePaidAmountFromItems(payments);
|
|
1912
1907
|
this.calculationCache.paidAmount = result;
|
|
1913
|
-
this.logInfo("calculatePaidAmountAsync:
|
|
1908
|
+
this.logInfo("calculatePaidAmountAsync: 计算结果 =", result);
|
|
1914
1909
|
return result;
|
|
1915
1910
|
} catch (error) {
|
|
1916
|
-
this.logError("calculatePaidAmountAsync
|
|
1911
|
+
this.logError("calculatePaidAmountAsync 失败:", error);
|
|
1917
1912
|
return "0.00";
|
|
1918
1913
|
}
|
|
1919
1914
|
}
|
|
@@ -1946,7 +1941,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1946
1941
|
*/
|
|
1947
1942
|
async calculateRemainingAmountAsync() {
|
|
1948
1943
|
if (!this.store.currentOrder) {
|
|
1949
|
-
this.logWarning("calculateRemainingAmountAsync:
|
|
1944
|
+
this.logWarning("calculateRemainingAmountAsync: 没有当前订单");
|
|
1950
1945
|
return "0.00";
|
|
1951
1946
|
}
|
|
1952
1947
|
const { currentOrder } = await this.fetchOrderDataBatch();
|
|
@@ -1955,7 +1950,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1955
1950
|
}
|
|
1956
1951
|
const paidAmountStr = await this.calculatePaidAmountAsync();
|
|
1957
1952
|
const result = this.calculateRemainingAmountFromData(currentOrder, paidAmountStr);
|
|
1958
|
-
this.logInfo("calculateRemainingAmountAsync:
|
|
1953
|
+
this.logInfo("calculateRemainingAmountAsync: 计算=", result);
|
|
1959
1954
|
return result;
|
|
1960
1955
|
}
|
|
1961
1956
|
/**
|
|
@@ -1966,7 +1961,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1966
1961
|
*/
|
|
1967
1962
|
async calculateRemainingTotalAmountAsync() {
|
|
1968
1963
|
if (!this.store.currentOrder) {
|
|
1969
|
-
this.logWarning("calculateRemainingTotalAmountAsync:
|
|
1964
|
+
this.logWarning("calculateRemainingTotalAmountAsync: 没有当前订单");
|
|
1970
1965
|
return "0.00";
|
|
1971
1966
|
}
|
|
1972
1967
|
const { currentOrder } = await this.fetchOrderDataBatch();
|
|
@@ -1975,7 +1970,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1975
1970
|
}
|
|
1976
1971
|
const paidAmountStr = await this.calculatePaidAmountAsync();
|
|
1977
1972
|
const result = this.calculateRemainingTotalAmountFromData(currentOrder, paidAmountStr);
|
|
1978
|
-
this.logInfo("calculateRemainingTotalAmountAsync:
|
|
1973
|
+
this.logInfo("calculateRemainingTotalAmountAsync: 计算=", result);
|
|
1979
1974
|
return result;
|
|
1980
1975
|
}
|
|
1981
1976
|
/**
|
|
@@ -1994,18 +1989,18 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1994
1989
|
timestamp: Date.now(),
|
|
1995
1990
|
totalAmount: remainingTotalAmount
|
|
1996
1991
|
});
|
|
1997
|
-
this.logInfo("balanceDueAmount
|
|
1992
|
+
this.logInfo("balanceDueAmount 已自动更新:", {
|
|
1998
1993
|
oldAmount: currentBalanceDueAmount,
|
|
1999
1994
|
newAmount: remainingAmount
|
|
2000
1995
|
});
|
|
2001
1996
|
} else {
|
|
2002
|
-
this.logInfo("balanceDueAmount
|
|
1997
|
+
this.logInfo("balanceDueAmount 无需更新,当前值已是最新:", {
|
|
2003
1998
|
balanceDueAmount: currentBalanceDueAmount,
|
|
2004
1999
|
remainingAmount
|
|
2005
2000
|
});
|
|
2006
2001
|
}
|
|
2007
2002
|
} catch (error) {
|
|
2008
|
-
this.logError("
|
|
2003
|
+
this.logError("更新 balanceDueAmount 失败:", error);
|
|
2009
2004
|
}
|
|
2010
2005
|
}
|
|
2011
2006
|
/**
|
|
@@ -2022,7 +2017,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2022
2017
|
const { paymentItems, currentOrder } = await this.fetchOrderDataBatch();
|
|
2023
2018
|
console.timeEnd("updateStateAmountToRemaining");
|
|
2024
2019
|
if (!currentOrder) {
|
|
2025
|
-
this.logWarning("updateStateAmountToRemaining:
|
|
2020
|
+
this.logWarning("updateStateAmountToRemaining: 未找到当前订单");
|
|
2026
2021
|
return;
|
|
2027
2022
|
}
|
|
2028
2023
|
const paidAmount = this.calculatePaidAmountFromItems(paymentItems);
|
|
@@ -2071,7 +2066,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2071
2066
|
totalAmount: remainingTotalAmount
|
|
2072
2067
|
});
|
|
2073
2068
|
}, 0);
|
|
2074
|
-
this.logInfo("stateAmount
|
|
2069
|
+
this.logInfo("stateAmount 已自动更新为剩余金额:", {
|
|
2075
2070
|
oldAmount: currentStateAmount,
|
|
2076
2071
|
newAmount: remainingAmount
|
|
2077
2072
|
});
|
|
@@ -2089,14 +2084,14 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2089
2084
|
totalAmount: remainingTotalAmount
|
|
2090
2085
|
});
|
|
2091
2086
|
}, 0);
|
|
2092
|
-
this.logInfo("balanceDueAmount
|
|
2087
|
+
this.logInfo("balanceDueAmount 已自动更新:", {
|
|
2093
2088
|
oldAmount: currentBalanceDueAmount,
|
|
2094
2089
|
newAmount: remainingAmount
|
|
2095
2090
|
});
|
|
2096
2091
|
}
|
|
2097
2092
|
console.timeEnd("updateStateAmountToRemaining: updateStateAmountToRemaining");
|
|
2098
2093
|
if (!hasStateChanged) {
|
|
2099
|
-
this.logInfo("
|
|
2094
|
+
this.logInfo("状态无需更新,当前值已是最新:", {
|
|
2100
2095
|
stateAmount: currentStateAmount,
|
|
2101
2096
|
remainingAmount
|
|
2102
2097
|
});
|
|
@@ -2104,10 +2099,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2104
2099
|
if (checkOrder) {
|
|
2105
2100
|
await this.checkOrderPaymentCompletionOptimized(paymentItems, remainingAmount);
|
|
2106
2101
|
} else {
|
|
2107
|
-
this.logInfo("
|
|
2102
|
+
this.logInfo("外部传入无需 checkOrder,不执行订单支付完成检测和同步");
|
|
2108
2103
|
}
|
|
2109
2104
|
} catch (error) {
|
|
2110
|
-
this.logError("
|
|
2105
|
+
this.logError("更新 stateAmount 为剩余金额失败:", error);
|
|
2111
2106
|
}
|
|
2112
2107
|
}
|
|
2113
2108
|
/**
|
|
@@ -2125,7 +2120,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2125
2120
|
if (remainingValue.lte(0)) {
|
|
2126
2121
|
const totalAmount = this.store.currentOrder.total_amount;
|
|
2127
2122
|
const paidAmount = this.calculationCache.paidAmount || "0.00";
|
|
2128
|
-
this.logInfo("
|
|
2123
|
+
this.logInfo("检测到订单支付完成:", {
|
|
2129
2124
|
orderUuid: this.store.currentOrder.uuid,
|
|
2130
2125
|
orderId: this.store.currentOrder.order_id,
|
|
2131
2126
|
totalAmount,
|
|
@@ -2138,13 +2133,13 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2138
2133
|
(item) => item.status !== "voided" && item.voucher_id
|
|
2139
2134
|
);
|
|
2140
2135
|
const shouldAutoSync = hasPaymentItems && !allPaymentsHaveVoucherId;
|
|
2141
|
-
this.logInfo("
|
|
2136
|
+
this.logInfo("自动同步订单条件检查:", {
|
|
2142
2137
|
paymentCount: paymentItems.length,
|
|
2143
2138
|
hasPaymentItems,
|
|
2144
2139
|
allHaveVoucherId: allPaymentsHaveVoucherId,
|
|
2145
2140
|
isOrderSynced: this.store.isOrderSynced,
|
|
2146
2141
|
shouldAutoSync,
|
|
2147
|
-
reason: shouldAutoSync ? "
|
|
2142
|
+
reason: shouldAutoSync ? "支付完成,需要同步最终支付状态" : "跳过同步",
|
|
2148
2143
|
paymentItems: paymentItems.map((p) => ({
|
|
2149
2144
|
uuid: p.uuid,
|
|
2150
2145
|
code: p.code,
|
|
@@ -2156,13 +2151,13 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2156
2151
|
}))
|
|
2157
2152
|
});
|
|
2158
2153
|
if (shouldAutoSync) {
|
|
2159
|
-
this.logInfo("
|
|
2154
|
+
this.logInfo("满足自动同步条件,开始同步订单到后端...");
|
|
2160
2155
|
await this.syncOrderToBackendWithReturn(false);
|
|
2161
2156
|
} else {
|
|
2162
2157
|
if (!hasPaymentItems) {
|
|
2163
|
-
this.logInfo("
|
|
2158
|
+
this.logInfo("没有支付项,跳过订单同步");
|
|
2164
2159
|
} else if (allPaymentsHaveVoucherId) {
|
|
2165
|
-
this.logInfo("
|
|
2160
|
+
this.logInfo("所有支付项均为代金券类型,跳过订单同步");
|
|
2166
2161
|
}
|
|
2167
2162
|
}
|
|
2168
2163
|
await this.core.effects.emit(`${this.name}:onOrderPaymentCompleted`, {
|
|
@@ -2175,7 +2170,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2175
2170
|
});
|
|
2176
2171
|
}
|
|
2177
2172
|
} catch (error) {
|
|
2178
|
-
this.logError("
|
|
2173
|
+
this.logError("检查订单支付完成状态失败:", error);
|
|
2179
2174
|
}
|
|
2180
2175
|
}
|
|
2181
2176
|
/**
|
|
@@ -2196,7 +2191,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2196
2191
|
if (remainingValue.lte(0)) {
|
|
2197
2192
|
const totalAmount = this.store.currentOrder.total_amount;
|
|
2198
2193
|
const paidAmount = await this.calculatePaidAmountAsync();
|
|
2199
|
-
this.logInfo("
|
|
2194
|
+
this.logInfo("检测到订单支付完成:", {
|
|
2200
2195
|
orderUuid: this.store.currentOrder.uuid,
|
|
2201
2196
|
orderId: this.store.currentOrder.order_id,
|
|
2202
2197
|
totalAmount,
|
|
@@ -2214,13 +2209,13 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2214
2209
|
(item) => item.status !== "voided" && item.voucher_id
|
|
2215
2210
|
);
|
|
2216
2211
|
const shouldAutoSync = hasPaymentItems && !allPaymentsHaveVoucherId;
|
|
2217
|
-
this.logInfo("
|
|
2212
|
+
this.logInfo("自动同步订单条件检查:", {
|
|
2218
2213
|
paymentCount: currentPayments.length,
|
|
2219
2214
|
hasPaymentItems,
|
|
2220
2215
|
allHaveVoucherId: allPaymentsHaveVoucherId,
|
|
2221
2216
|
isOrderSynced: this.store.isOrderSynced,
|
|
2222
2217
|
shouldAutoSync,
|
|
2223
|
-
reason: shouldAutoSync ? "
|
|
2218
|
+
reason: shouldAutoSync ? "支付完成,需要同步最终支付状态" : "跳过同步",
|
|
2224
2219
|
paymentItems: currentPayments.map((p) => ({
|
|
2225
2220
|
uuid: p.uuid,
|
|
2226
2221
|
code: p.code,
|
|
@@ -2232,13 +2227,13 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2232
2227
|
}))
|
|
2233
2228
|
});
|
|
2234
2229
|
if (shouldAutoSync) {
|
|
2235
|
-
this.logInfo("
|
|
2230
|
+
this.logInfo("满足自动同步条件,开始同步订单到后端...");
|
|
2236
2231
|
await this.syncOrderToBackendWithReturn(false);
|
|
2237
2232
|
} else {
|
|
2238
2233
|
if (!hasPaymentItems) {
|
|
2239
|
-
this.logInfo("
|
|
2234
|
+
this.logInfo("没有支付项,跳过订单同步");
|
|
2240
2235
|
} else if (allPaymentsHaveVoucherId) {
|
|
2241
|
-
this.logInfo("
|
|
2236
|
+
this.logInfo("所有支付项均为代金券类型,跳过订单同步");
|
|
2242
2237
|
}
|
|
2243
2238
|
}
|
|
2244
2239
|
await this.core.effects.emit(`${this.name}:onOrderPaymentCompleted`, {
|
|
@@ -2251,7 +2246,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2251
2246
|
});
|
|
2252
2247
|
}
|
|
2253
2248
|
} catch (error) {
|
|
2254
|
-
this.logError("
|
|
2249
|
+
this.logError("检查订单支付完成状态失败:", error);
|
|
2255
2250
|
}
|
|
2256
2251
|
}
|
|
2257
2252
|
/**
|
|
@@ -2264,12 +2259,12 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2264
2259
|
async syncOrderToBackendWithReturn(isManual = false, customPaymentItems) {
|
|
2265
2260
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2266
2261
|
if (!this.store.localOrderData || !this.store.currentOrder) {
|
|
2267
|
-
throw new Error("
|
|
2262
|
+
throw new Error("缺少必要的订单数据,无法同步到后端");
|
|
2268
2263
|
}
|
|
2269
2264
|
this.logInfo("syncOrderToBackendWithReturn called", { isManual });
|
|
2270
2265
|
const currentOrderId = this.store.currentOrder.order_id;
|
|
2271
2266
|
const isUpdateOperation = this.store.isOrderSynced || !(0, import_utils.isVirtualOrderId)(currentOrderId);
|
|
2272
|
-
this.logInfo(
|
|
2267
|
+
this.logInfo(`开始同步订单到后端...`, {
|
|
2273
2268
|
currentOrderId,
|
|
2274
2269
|
isVirtualId: (0, import_utils.isVirtualOrderId)(currentOrderId || ""),
|
|
2275
2270
|
orderUuid: this.store.currentOrder.uuid,
|
|
@@ -2293,15 +2288,15 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2293
2288
|
const manualDepositValue = new import_decimal.default(manualDepositAmount);
|
|
2294
2289
|
if (manualDepositValue.gt(0)) {
|
|
2295
2290
|
finalDepositAmount = manualDepositAmount;
|
|
2296
|
-
this.logInfo("
|
|
2291
|
+
this.logInfo("使用手动设置的定金金额", {
|
|
2297
2292
|
manualDepositAmount,
|
|
2298
|
-
reason: "
|
|
2293
|
+
reason: "用户通过setDepositAmountAsync手动设置了定金金额"
|
|
2299
2294
|
});
|
|
2300
2295
|
} else {
|
|
2301
2296
|
finalDepositAmount = "0.00";
|
|
2302
|
-
this.logInfo("
|
|
2297
|
+
this.logInfo("定金金额为0", {
|
|
2303
2298
|
manualDepositAmount,
|
|
2304
|
-
reason: "
|
|
2299
|
+
reason: "手动设置和计算值均为0"
|
|
2305
2300
|
});
|
|
2306
2301
|
}
|
|
2307
2302
|
if (this.store.currentOrder.is_deposit === 0 && processedPaymentItems.every((item) => item.order_payment_type !== "deposit")) {
|
|
@@ -2322,7 +2317,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2322
2317
|
return sum.plus(amt).sub(rounding);
|
|
2323
2318
|
}, new import_decimal.default(0)).toFixed(2);
|
|
2324
2319
|
}
|
|
2325
|
-
this.logInfo("
|
|
2320
|
+
this.logInfo("定金金额确定结果", {
|
|
2326
2321
|
depositPaymentItemsCount: processedPaymentItems.length,
|
|
2327
2322
|
depositPaymentItems: processedPaymentItems.map((item) => ({
|
|
2328
2323
|
uuid: item.uuid,
|
|
@@ -2383,7 +2378,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2383
2378
|
if (isUpdateOperation) {
|
|
2384
2379
|
if ((0, import_utils.isVirtualOrderId)(currentOrderId)) {
|
|
2385
2380
|
this.logWarning(
|
|
2386
|
-
"
|
|
2381
|
+
"尝试数据修复:暂时不包含order_id,注意:这次调用将作为创建操作处理,但后续会修复数据一致性"
|
|
2387
2382
|
);
|
|
2388
2383
|
} else {
|
|
2389
2384
|
orderParams.order_id = currentOrderId;
|
|
@@ -2408,11 +2403,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2408
2403
|
});
|
|
2409
2404
|
checkoutResponse = await this.order.createOrderByCheckout(orderParams);
|
|
2410
2405
|
submitSuccess = true;
|
|
2411
|
-
this.logInfo("
|
|
2406
|
+
this.logInfo("下单接口调用成功", checkoutResponse);
|
|
2412
2407
|
} catch (error) {
|
|
2413
2408
|
submitSuccess = false;
|
|
2414
2409
|
submitError = error instanceof Error ? error.message : String(error);
|
|
2415
|
-
this.logError("
|
|
2410
|
+
this.logError("下单接口调用失败:", submitError);
|
|
2416
2411
|
await this.core.effects.emit(`${this.name}:onOrderSyncFailed`, {
|
|
2417
2412
|
orderUuid: this.store.currentOrder.uuid,
|
|
2418
2413
|
operation: isUpdateOperation ? "update" : "create",
|
|
@@ -2438,7 +2433,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2438
2433
|
const responseStatus = checkoutResponse == null ? void 0 : checkoutResponse.status;
|
|
2439
2434
|
const isSuccessResponse = responseStatus === true || responseStatus === 200 || responseStatus === "success" || responseStatus === 1 && (checkoutResponse == null ? void 0 : checkoutResponse.code) === 200;
|
|
2440
2435
|
if (!isSuccessResponse) {
|
|
2441
|
-
const errorMessage = (checkoutResponse == null ? void 0 : checkoutResponse.message) || "
|
|
2436
|
+
const errorMessage = (checkoutResponse == null ? void 0 : checkoutResponse.message) || "订单同步失败,后端返回非成功状态";
|
|
2442
2437
|
await this.core.effects.emit(`${this.name}:onOrderSyncFailed`, {
|
|
2443
2438
|
orderUuid: this.store.currentOrder.uuid,
|
|
2444
2439
|
operation: isUpdateOperation ? "update" : "create",
|
|
@@ -2463,10 +2458,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2463
2458
|
extractedOrderId = String(extractedOrderId);
|
|
2464
2459
|
}
|
|
2465
2460
|
if (!extractedOrderId) {
|
|
2466
|
-
this.logError("
|
|
2461
|
+
this.logError("后端返回的订单信息中未包含订单ID");
|
|
2467
2462
|
}
|
|
2468
2463
|
realOrderId = extractedOrderId;
|
|
2469
|
-
this.logInfo("
|
|
2464
|
+
this.logInfo("准备替换订单ID:", {
|
|
2470
2465
|
orderUuid: this.store.currentOrder.uuid,
|
|
2471
2466
|
oldOrderId: this.store.currentOrder.order_id,
|
|
2472
2467
|
newOrderId: realOrderId
|
|
@@ -2476,38 +2471,38 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2476
2471
|
this.store.currentOrder.uuid,
|
|
2477
2472
|
realOrderId
|
|
2478
2473
|
);
|
|
2479
|
-
this.logInfo("Payment
|
|
2474
|
+
this.logInfo("Payment模块替换订单ID结果:", {
|
|
2480
2475
|
wasSuccessful: !!updatedOrder,
|
|
2481
2476
|
returnedOrderId: updatedOrder == null ? void 0 : updatedOrder.order_id,
|
|
2482
2477
|
expectedOrderId: realOrderId
|
|
2483
2478
|
});
|
|
2484
2479
|
if (updatedOrder) {
|
|
2485
|
-
this.logInfo("Payment
|
|
2480
|
+
this.logInfo("Payment模块返回的更新后订单:", {
|
|
2486
2481
|
uuid: updatedOrder.uuid,
|
|
2487
2482
|
orderId: updatedOrder.order_id,
|
|
2488
2483
|
totalAmount: updatedOrder.total_amount
|
|
2489
2484
|
});
|
|
2490
2485
|
this.store.currentOrder = updatedOrder;
|
|
2491
2486
|
this.logInfo(
|
|
2492
|
-
"[Checkout]
|
|
2487
|
+
"[Checkout] 订单ID替换成功,当前订单ID:",
|
|
2493
2488
|
this.store.currentOrder.order_id
|
|
2494
2489
|
);
|
|
2495
2490
|
} else {
|
|
2496
2491
|
this.logError(
|
|
2497
|
-
"[Checkout] Payment
|
|
2492
|
+
"[Checkout] Payment模块返回空订单,订单ID替换失败,开始手动替换"
|
|
2498
2493
|
);
|
|
2499
2494
|
const beforeManualUpdate = this.store.currentOrder.order_id;
|
|
2500
2495
|
this.store.currentOrder.order_id = realOrderId;
|
|
2501
|
-
this.logInfo("
|
|
2496
|
+
this.logInfo("手动设置订单ID:", {
|
|
2502
2497
|
beforeReplacement: beforeManualUpdate,
|
|
2503
2498
|
afterReplacement: this.store.currentOrder.order_id,
|
|
2504
|
-
|
|
2499
|
+
目标ID: realOrderId
|
|
2505
2500
|
});
|
|
2506
2501
|
}
|
|
2507
2502
|
} catch (error) {
|
|
2508
|
-
this.logError("
|
|
2503
|
+
this.logError("调用Payment模块替换订单ID时发生错误:", error);
|
|
2509
2504
|
this.store.currentOrder.order_id = realOrderId;
|
|
2510
|
-
this.logInfo("
|
|
2505
|
+
this.logInfo("错误恢复:手动设置订单ID:", realOrderId);
|
|
2511
2506
|
}
|
|
2512
2507
|
}
|
|
2513
2508
|
try {
|
|
@@ -2520,7 +2515,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2520
2515
|
);
|
|
2521
2516
|
}
|
|
2522
2517
|
} catch (e) {
|
|
2523
|
-
this.logWarning("
|
|
2518
|
+
this.logWarning("标记支付项已同步失败(不阻塞主流程)", { error: e });
|
|
2524
2519
|
}
|
|
2525
2520
|
this.store.isOrderSynced = true;
|
|
2526
2521
|
this.clearCalculationCache();
|
|
@@ -2565,7 +2560,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2565
2560
|
if (!orderId) {
|
|
2566
2561
|
return {
|
|
2567
2562
|
success: false,
|
|
2568
|
-
message: "
|
|
2563
|
+
message: "订单ID不能为空",
|
|
2569
2564
|
orderId
|
|
2570
2565
|
};
|
|
2571
2566
|
}
|
|
@@ -2579,7 +2574,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2579
2574
|
const response = await this.request.put(`/order/order/${orderId}/note`, {
|
|
2580
2575
|
note
|
|
2581
2576
|
});
|
|
2582
|
-
this.logInfo("
|
|
2577
|
+
this.logInfo("订单备注编辑响应:", {
|
|
2583
2578
|
orderId,
|
|
2584
2579
|
status: response.status,
|
|
2585
2580
|
message: response.message,
|
|
@@ -2600,12 +2595,12 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2600
2595
|
}
|
|
2601
2596
|
return {
|
|
2602
2597
|
success: true,
|
|
2603
|
-
message: response.message || "
|
|
2598
|
+
message: response.message || "订单备注修改成功",
|
|
2604
2599
|
orderId
|
|
2605
2600
|
};
|
|
2606
2601
|
} else {
|
|
2607
|
-
const errorMessage = response.message || "
|
|
2608
|
-
this.logError(
|
|
2602
|
+
const errorMessage = response.message || "订单备注修改失败";
|
|
2603
|
+
this.logError(`订单 ${orderId} 备注修改失败:`, errorMessage);
|
|
2609
2604
|
return {
|
|
2610
2605
|
success: false,
|
|
2611
2606
|
message: errorMessage,
|
|
@@ -2613,11 +2608,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2613
2608
|
};
|
|
2614
2609
|
}
|
|
2615
2610
|
} catch (error) {
|
|
2616
|
-
this.logError("
|
|
2617
|
-
const errorMessage = error instanceof Error ? error.message : "
|
|
2611
|
+
this.logError("编辑订单备注失败:", error);
|
|
2612
|
+
const errorMessage = error instanceof Error ? error.message : "网络错误或服务器异常";
|
|
2618
2613
|
return {
|
|
2619
2614
|
success: false,
|
|
2620
|
-
message:
|
|
2615
|
+
message: `编辑订单备注失败: ${errorMessage}`,
|
|
2621
2616
|
orderId
|
|
2622
2617
|
};
|
|
2623
2618
|
}
|
|
@@ -2643,13 +2638,13 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2643
2638
|
if (!params.order_ids || params.order_ids.length === 0) {
|
|
2644
2639
|
return {
|
|
2645
2640
|
success: false,
|
|
2646
|
-
message: "
|
|
2641
|
+
message: "订单ID列表不能为空"
|
|
2647
2642
|
};
|
|
2648
2643
|
}
|
|
2649
2644
|
if (!params.emails || params.emails.length === 0) {
|
|
2650
2645
|
return {
|
|
2651
2646
|
success: false,
|
|
2652
|
-
message: "
|
|
2647
|
+
message: "邮箱地址列表不能为空"
|
|
2653
2648
|
};
|
|
2654
2649
|
}
|
|
2655
2650
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
@@ -2659,7 +2654,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2659
2654
|
if (invalidEmails.length > 0) {
|
|
2660
2655
|
return {
|
|
2661
2656
|
success: false,
|
|
2662
|
-
message:
|
|
2657
|
+
message: `邮箱格式无效: ${invalidEmails.join(", ")}`
|
|
2663
2658
|
};
|
|
2664
2659
|
}
|
|
2665
2660
|
const requestBody = {
|
|
@@ -2675,7 +2670,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2675
2670
|
"/order/batch-email",
|
|
2676
2671
|
requestBody
|
|
2677
2672
|
);
|
|
2678
|
-
this.logInfo("
|
|
2673
|
+
this.logInfo("支付链接邮件发送响应:", {
|
|
2679
2674
|
status: response.status,
|
|
2680
2675
|
message: response.message,
|
|
2681
2676
|
data: response.data,
|
|
@@ -2684,22 +2679,22 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2684
2679
|
if (response.status === true || response.status === 200) {
|
|
2685
2680
|
return {
|
|
2686
2681
|
success: true,
|
|
2687
|
-
message: response.message || "
|
|
2682
|
+
message: response.message || "支付链接邮件发送成功"
|
|
2688
2683
|
};
|
|
2689
2684
|
} else {
|
|
2690
|
-
const errorMessage = response.message || "
|
|
2691
|
-
console.error("[Checkout]
|
|
2685
|
+
const errorMessage = response.message || "支付链接邮件发送失败";
|
|
2686
|
+
console.error("[Checkout] 支付链接邮件发送失败:", errorMessage);
|
|
2692
2687
|
return {
|
|
2693
2688
|
success: false,
|
|
2694
2689
|
message: errorMessage
|
|
2695
2690
|
};
|
|
2696
2691
|
}
|
|
2697
2692
|
} catch (error) {
|
|
2698
|
-
this.logError("
|
|
2699
|
-
const errorMessage = error instanceof Error ? error.message : "
|
|
2693
|
+
this.logError("发送客户支付链接邮件失败:", error);
|
|
2694
|
+
const errorMessage = error instanceof Error ? error.message : "网络错误或服务器异常";
|
|
2700
2695
|
return {
|
|
2701
2696
|
success: false,
|
|
2702
|
-
message:
|
|
2697
|
+
message: `发送支付链接邮件失败: ${errorMessage}`
|
|
2703
2698
|
};
|
|
2704
2699
|
}
|
|
2705
2700
|
}
|
|
@@ -2733,7 +2728,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2733
2728
|
await ((_b = (_a = this.order) == null ? void 0 : _a.destroy) == null ? void 0 : _b.call(_a));
|
|
2734
2729
|
await ((_d = (_c = this.payment) == null ? void 0 : _c.destroy) == null ? void 0 : _d.call(_c));
|
|
2735
2730
|
this.core.unregisterModule(this);
|
|
2736
|
-
console.log("[Checkout]
|
|
2731
|
+
console.log("[Checkout] 已销毁");
|
|
2737
2732
|
}
|
|
2738
2733
|
/**
|
|
2739
2734
|
* 重置 store 状态
|
|
@@ -2748,7 +2743,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2748
2743
|
uuid: this.store.currentOrder.uuid,
|
|
2749
2744
|
orderId: this.store.currentOrder.order_id
|
|
2750
2745
|
} : null;
|
|
2751
|
-
console.log("[Checkout]
|
|
2746
|
+
console.log("[Checkout] 重置 store 状态,准备创建新订单", prevOrderInfo);
|
|
2752
2747
|
this.store.currentOrder = void 0;
|
|
2753
2748
|
this.store.localOrderData = void 0;
|
|
2754
2749
|
this.store.cartSummary = void 0;
|
|
@@ -2760,7 +2755,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2760
2755
|
this.store.cartItems = [];
|
|
2761
2756
|
this.payment.wallet.clearAllCache();
|
|
2762
2757
|
this.clearCalculationCache();
|
|
2763
|
-
console.log("[Checkout] Store
|
|
2758
|
+
console.log("[Checkout] Store 状态重置完成");
|
|
2764
2759
|
if (prevOrderInfo) {
|
|
2765
2760
|
setTimeout(() => {
|
|
2766
2761
|
this.core.effects.emit(`${this.name}:onOrderCleared`, {
|
|
@@ -2770,7 +2765,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2770
2765
|
}, 0);
|
|
2771
2766
|
}
|
|
2772
2767
|
} catch (error) {
|
|
2773
|
-
console.error("[Checkout]
|
|
2768
|
+
console.error("[Checkout] 重置 store 状态失败:", error);
|
|
2774
2769
|
}
|
|
2775
2770
|
}
|
|
2776
2771
|
};
|