@pisell/pisellos 2.1.98 → 2.1.100
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/Product/index.d.ts +1 -1
- 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 +27 -28
- package/lib/effects/index.d.ts +2 -2
- package/lib/effects/index.js +3 -7
- package/lib/modules/Account/index.js +9 -10
- package/lib/modules/AccountList/index.js +14 -11
- package/lib/modules/BaseModule.js +6 -3
- package/lib/modules/Cart/index.js +14 -9
- package/lib/modules/Cart/utils/cartProduct.js +3 -6
- package/lib/modules/Customer/constants.js +1 -1
- package/lib/modules/Customer/index.js +18 -15
- package/lib/modules/Customer/types.d.ts +1 -1
- package/lib/modules/Date/index.js +10 -6
- package/lib/modules/Date/types.js +1 -0
- package/lib/modules/Discount/index.js +11 -6
- package/lib/modules/Guests/index.js +10 -15
- package/lib/modules/Order/index.js +10 -7
- 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 +84 -73
- package/lib/modules/Payment/types.d.ts +7 -7
- package/lib/modules/Payment/utils.js +3 -6
- package/lib/modules/Payment/walletpass.js +31 -31
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/modules/Product/index.js +6 -5
- package/lib/modules/ProductList/index.js +5 -3
- package/lib/modules/Resource/index.js +8 -12
- package/lib/modules/Rules/index.js +21 -35
- package/lib/modules/Rules/types.d.ts +1 -1
- package/lib/modules/Schedule/getDateIsInSchedule.d.ts +1 -1
- package/lib/modules/Schedule/index.js +8 -5
- package/lib/modules/Schedule/type.d.ts +7 -7
- package/lib/modules/Schedule/types.d.ts +9 -9
- package/lib/modules/Schedule/utils.js +2 -4
- package/lib/modules/Step/index.js +7 -4
- package/lib/modules/Summary/index.js +9 -4
- package/lib/modules/Summary/utils.js +8 -16
- package/lib/plugins/request.js +34 -33
- package/lib/plugins/window.js +101 -113
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingByStep/index.js +110 -177
- package/lib/solution/BookingByStep/utils/capacity.js +11 -16
- package/lib/solution/BookingByStep/utils/resources.d.ts +1 -1
- package/lib/solution/BookingByStep/utils/resources.js +4 -8
- package/lib/solution/BookingByStep/utils/stock.js +3 -6
- package/lib/solution/BookingByStep/utils/timeslots.js +24 -27
- package/lib/solution/BookingTicket/index.js +19 -14
- 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 +3 -1
- package/lib/solution/BookingTicket/utils/scan/scanCache.js +10 -9
- package/lib/solution/BuyTickets/index.js +15 -15
- package/lib/solution/Checkout/index.js +216 -211
- package/lib/solution/Checkout/utils/index.js +18 -22
- package/lib/solution/RegisterAndLogin/config.js +2 -2
- package/lib/solution/RegisterAndLogin/index.js +114 -110
- package/lib/solution/RegisterAndLogin/utils.js +9 -9
- package/lib/solution/ShopDiscount/index.js +16 -13
- package/lib/solution/ShopDiscount/types.d.ts +1 -1
- package/lib/solution/ShopDiscount/utils.d.ts +2 -2
- package/lib/solution/ShopDiscount/utils.js +1 -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 +5 -7
- package/package.json +16 -17
|
@@ -43,26 +43,32 @@ 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;
|
|
46
59
|
constructor(name, version) {
|
|
47
60
|
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 = {};
|
|
55
61
|
}
|
|
56
62
|
async initialize(core, options) {
|
|
57
63
|
this.core = core;
|
|
58
64
|
this.otherParams = options.otherParams || {};
|
|
59
65
|
this.request = core.getPlugin("request");
|
|
60
66
|
if (!this.request) {
|
|
61
|
-
throw new Error("Checkout
|
|
67
|
+
throw new Error("Checkout \u89E3\u51B3\u65B9\u6848\u9700\u8981 request \u63D2\u4EF6\u652F\u6301");
|
|
62
68
|
}
|
|
63
69
|
const appPlugin = core.getPlugin("app");
|
|
64
70
|
if (!appPlugin) {
|
|
65
|
-
throw new Error("Checkout
|
|
71
|
+
throw new Error("Checkout \u89E3\u51B3\u65B9\u6848\u9700\u8981 app \u63D2\u4EF6\u652F\u6301");
|
|
66
72
|
}
|
|
67
73
|
const app = appPlugin.getApp();
|
|
68
74
|
this.logger = app.logger;
|
|
@@ -80,7 +86,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
80
86
|
await this.initializeSubModules(core, options);
|
|
81
87
|
await this.preloadPaymentMethods();
|
|
82
88
|
await this.cleanupExpiredOrdersAsync();
|
|
83
|
-
console.log("[Checkout]
|
|
89
|
+
console.log("[Checkout] \u521D\u59CB\u5316\u5B8C\u6210");
|
|
84
90
|
await this.core.effects.emit(`${this.name}:onCheckoutInitialized`, {
|
|
85
91
|
timestamp: Date.now()
|
|
86
92
|
});
|
|
@@ -156,14 +162,14 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
156
162
|
this.core.effects.on(
|
|
157
163
|
import_types2.PaymentHooks.OnPaymentMethodsLoaded,
|
|
158
164
|
async (methods) => {
|
|
159
|
-
console.log("[Checkout]
|
|
165
|
+
console.log("[Checkout] \u6536\u5230\u652F\u4ED8\u65B9\u5F0F\u52A0\u8F7D\u5B8C\u6210\u4E8B\u4EF6:", methods.length);
|
|
160
166
|
this.store.paymentMethods = methods;
|
|
161
167
|
}
|
|
162
168
|
);
|
|
163
169
|
this.core.effects.on(
|
|
164
170
|
import_types2.PaymentHooks.OnPaymentMethodsChanged,
|
|
165
171
|
async (data) => {
|
|
166
|
-
console.log("[Checkout]
|
|
172
|
+
console.log("[Checkout] \u6536\u5230\u652F\u4ED8\u65B9\u5F0F\u53D8\u66F4\u4E8B\u4EF6:", {
|
|
167
173
|
oldCount: data.oldMethods.length,
|
|
168
174
|
newCount: data.newMethods.length
|
|
169
175
|
});
|
|
@@ -186,11 +192,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
186
192
|
if (!validation.valid) {
|
|
187
193
|
throw (0, import_utils.createCheckoutError)(
|
|
188
194
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
189
|
-
|
|
195
|
+
`\u53C2\u6570\u9A8C\u8BC1\u5931\u8D25: ${validation.errors.join(", ")}`
|
|
190
196
|
);
|
|
191
197
|
}
|
|
192
198
|
this.store.cartItems = params.cartItems;
|
|
193
|
-
console.log("[Checkout]
|
|
199
|
+
console.log("[Checkout] \u7ED3\u8D26\u6D41\u7A0B\u521D\u59CB\u5316\u5B8C\u6210");
|
|
194
200
|
} catch (error) {
|
|
195
201
|
await this.handleError(error, import_types.CheckoutErrorType.UnknownError);
|
|
196
202
|
throw error;
|
|
@@ -198,8 +204,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
198
204
|
}
|
|
199
205
|
getHolderIdFromBooking(obj) {
|
|
200
206
|
var _a;
|
|
201
|
-
if (!obj)
|
|
202
|
-
return void 0;
|
|
207
|
+
if (!obj) return void 0;
|
|
203
208
|
let ret = obj.holder_id || ((_a = obj.holder) == null ? void 0 : _a.form_record);
|
|
204
209
|
if (Array.isArray(ret)) {
|
|
205
210
|
return ret.length > 0 ? Number(ret[0]) : void 0;
|
|
@@ -310,13 +315,13 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
310
315
|
if (this.store.isOrderSynced) {
|
|
311
316
|
walletBusinessData.payment_order_id = (_f = this.store.currentOrder) == null ? void 0 : _f.order_id;
|
|
312
317
|
}
|
|
313
|
-
this.logInfo("
|
|
318
|
+
this.logInfo("\u5F00\u59CB\u62C9\u53D6:initializeWalletDataFromBusinessAsync", {
|
|
314
319
|
walletBusinessData
|
|
315
320
|
});
|
|
316
321
|
await this.payment.wallet.initializeWalletDataFromBusinessAsync(
|
|
317
322
|
walletBusinessData
|
|
318
323
|
);
|
|
319
|
-
this.logInfo("
|
|
324
|
+
this.logInfo("\u8C03\u7528\u7ED3\u675F:initializeWalletDataFromBusinessAsync", {
|
|
320
325
|
walletBusinessData
|
|
321
326
|
});
|
|
322
327
|
if (!this.store.currentOrder) {
|
|
@@ -412,7 +417,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
412
417
|
if (!validation.valid) {
|
|
413
418
|
throw (0, import_utils.createCheckoutError)(
|
|
414
419
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
415
|
-
|
|
420
|
+
`\u8BA2\u5355\u6570\u636E\u9A8C\u8BC1\u5931\u8D25: ${validation.errors.join(", ")}`
|
|
416
421
|
);
|
|
417
422
|
}
|
|
418
423
|
const localOrderId = (0, import_utils.generateLocalOrderId)();
|
|
@@ -431,10 +436,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
431
436
|
};
|
|
432
437
|
if (customerInfo.customer_id || customerInfo.customer_name) {
|
|
433
438
|
this.store.currentCustomer = customerInfo;
|
|
434
|
-
console.log("[Checkout]
|
|
439
|
+
console.log("[Checkout] \u4FDD\u5B58\u5BA2\u6237\u4FE1\u606F:", customerInfo);
|
|
435
440
|
} else {
|
|
436
441
|
this.store.currentCustomer = void 0;
|
|
437
|
-
console.log("[Checkout]
|
|
442
|
+
console.log("[Checkout] \u672A\u63D0\u4F9B\u5BA2\u6237\u4FE1\u606F");
|
|
438
443
|
}
|
|
439
444
|
const isNeedDeposit = this.checkIsNeedDepositAsync(
|
|
440
445
|
params.orderData.bookings,
|
|
@@ -471,7 +476,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
471
476
|
duration: `${updateAmountDuration}ms`,
|
|
472
477
|
performance: updateAmountDuration > 200 ? "slow" : updateAmountDuration > 100 ? "medium" : "fast"
|
|
473
478
|
});
|
|
474
|
-
this.logInfo("
|
|
479
|
+
this.logInfo("\u672C\u5730\u8BA2\u5355\u521B\u5EFA\u6210\u529F:", {
|
|
475
480
|
localOrderId,
|
|
476
481
|
uuid: paymentOrder.uuid,
|
|
477
482
|
totalAmount: amountInfo.totalAmount,
|
|
@@ -486,7 +491,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
486
491
|
error,
|
|
487
492
|
import_types.CheckoutErrorType.OrderCreationFailed
|
|
488
493
|
);
|
|
489
|
-
this.logError("
|
|
494
|
+
this.logError("\u672C\u5730\u8BA2\u5355\u521B\u5EFA\u5931\u8D25:", error);
|
|
490
495
|
this.core.effects.emit(`${this.name}:onOrderCreationFailed`, {
|
|
491
496
|
error: this.store.lastError,
|
|
492
497
|
timestamp: Date.now()
|
|
@@ -513,7 +518,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
513
518
|
if (!validation.valid) {
|
|
514
519
|
throw (0, import_utils.createCheckoutError)(
|
|
515
520
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
516
|
-
|
|
521
|
+
`\u8BA2\u5355\u6570\u636E\u9A8C\u8BC1\u5931\u8D25: ${validation.errors.join(", ")}`
|
|
517
522
|
);
|
|
518
523
|
}
|
|
519
524
|
const amountInfo = (0, import_utils.extractAmountFromCartSummary)(params.cartSummary);
|
|
@@ -577,11 +582,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
577
582
|
if (!updated)
|
|
578
583
|
throw (0, import_utils.createCheckoutError)(
|
|
579
584
|
import_types.CheckoutErrorType.UnknownError,
|
|
580
|
-
"
|
|
585
|
+
"\u8BA2\u5355\u66F4\u65B0\u5931\u8D25"
|
|
581
586
|
);
|
|
582
587
|
this.store.currentOrder = updated;
|
|
583
588
|
await this.updateStateAmountToRemaining(false);
|
|
584
|
-
this.logInfo("
|
|
589
|
+
this.logInfo("\u672C\u5730\u8BA2\u5355\u66F4\u65B0\u6210\u529F(\u4FDD\u7559\u652F\u4ED8\u9879):", {
|
|
585
590
|
orderId: params.orderId,
|
|
586
591
|
uuid: updated.uuid,
|
|
587
592
|
payments: ((_m = updated.payment) == null ? void 0 : _m.length) || 0,
|
|
@@ -641,7 +646,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
641
646
|
if (!this.store.currentOrder) {
|
|
642
647
|
throw (0, import_utils.createCheckoutError)(
|
|
643
648
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
644
|
-
"
|
|
649
|
+
"\u672A\u627E\u5230\u5F53\u524D\u8BA2\u5355"
|
|
645
650
|
);
|
|
646
651
|
}
|
|
647
652
|
const order = await this.payment.getPaymentOrderByUuidAsync(
|
|
@@ -650,7 +655,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
650
655
|
if (!order || order.payment_status !== import_types2.PaymentStatus.Finished) {
|
|
651
656
|
throw (0, import_utils.createCheckoutError)(
|
|
652
657
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
653
|
-
"
|
|
658
|
+
"\u8BA2\u5355\u652F\u4ED8\u672A\u5B8C\u6210\uFF0C\u65E0\u6CD5\u5B8C\u6210\u7ED3\u8D26"
|
|
654
659
|
);
|
|
655
660
|
}
|
|
656
661
|
this.payment.wallet.clearAllCache();
|
|
@@ -658,7 +663,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
658
663
|
orderId: order.id,
|
|
659
664
|
timestamp: Date.now()
|
|
660
665
|
});
|
|
661
|
-
console.log("[Checkout]
|
|
666
|
+
console.log("[Checkout] \u7ED3\u8D26\u6D41\u7A0B\u5B8C\u6210:", order.id);
|
|
662
667
|
this.resetStoreState();
|
|
663
668
|
return {
|
|
664
669
|
success: true,
|
|
@@ -685,7 +690,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
685
690
|
try {
|
|
686
691
|
const { currentOrder, cartItems, localOrderData } = this.store;
|
|
687
692
|
if (!currentOrder) {
|
|
688
|
-
console.log("[Checkout]
|
|
693
|
+
console.log("[Checkout] \u5F53\u524D\u6CA1\u6709\u6D3B\u8DC3\u8BA2\u5355");
|
|
689
694
|
return null;
|
|
690
695
|
}
|
|
691
696
|
const orderInfo = currentOrder.order_info || {};
|
|
@@ -708,7 +713,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
708
713
|
};
|
|
709
714
|
return result;
|
|
710
715
|
} catch (error) {
|
|
711
|
-
console.error("[Checkout]
|
|
716
|
+
console.error("[Checkout] \u83B7\u53D6\u5F53\u524D\u8BA2\u5355\u57FA\u7840\u4FE1\u606F\u5931\u8D25:", error);
|
|
712
717
|
return null;
|
|
713
718
|
}
|
|
714
719
|
}
|
|
@@ -721,7 +726,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
721
726
|
try {
|
|
722
727
|
const { currentOrder } = this.store;
|
|
723
728
|
if (!currentOrder) {
|
|
724
|
-
console.log("[Checkout]
|
|
729
|
+
console.log("[Checkout] \u5F53\u524D\u6CA1\u6709\u6D3B\u8DC3\u8BA2\u5355\uFF0C\u65E0\u6CD5\u83B7\u53D6\u652F\u4ED8\u9879");
|
|
725
730
|
return [];
|
|
726
731
|
}
|
|
727
732
|
const paymentItems = await this.payment.getPaymentItemsAsync(
|
|
@@ -729,7 +734,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
729
734
|
);
|
|
730
735
|
return paymentItems;
|
|
731
736
|
} catch (error) {
|
|
732
|
-
console.error("[Checkout]
|
|
737
|
+
console.error("[Checkout] \u83B7\u53D6\u5F53\u524D\u8BA2\u5355\u652F\u4ED8\u9879\u5931\u8D25:", error);
|
|
733
738
|
return [];
|
|
734
739
|
}
|
|
735
740
|
}
|
|
@@ -756,7 +761,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
756
761
|
async replaceLocalOrderIdAsync(newOrderId) {
|
|
757
762
|
try {
|
|
758
763
|
if (!this.store.currentOrder) {
|
|
759
|
-
console.warn("[Checkout]
|
|
764
|
+
console.warn("[Checkout] \u6CA1\u6709\u5F53\u524D\u8BA2\u5355\uFF0C\u65E0\u6CD5\u66FF\u6362\u8BA2\u5355ID");
|
|
760
765
|
return null;
|
|
761
766
|
}
|
|
762
767
|
const updatedOrder = await this.payment.replaceOrderIdByUuidAsync(
|
|
@@ -769,7 +774,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
769
774
|
order: updatedOrder,
|
|
770
775
|
timestamp: Date.now()
|
|
771
776
|
});
|
|
772
|
-
console.log("[Checkout]
|
|
777
|
+
console.log("[Checkout] \u672C\u5730\u8BA2\u5355ID\u66FF\u6362\u6210\u529F:", {
|
|
773
778
|
uuid: updatedOrder.uuid,
|
|
774
779
|
newOrderId: updatedOrder.id
|
|
775
780
|
});
|
|
@@ -778,7 +783,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
778
783
|
}
|
|
779
784
|
return updatedOrder;
|
|
780
785
|
} catch (error) {
|
|
781
|
-
console.error("[Checkout]
|
|
786
|
+
console.error("[Checkout] \u66FF\u6362\u8BA2\u5355ID\u5931\u8D25:", error);
|
|
782
787
|
await this.handleError(error, import_types.CheckoutErrorType.UnknownError);
|
|
783
788
|
return null;
|
|
784
789
|
}
|
|
@@ -794,14 +799,14 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
794
799
|
try {
|
|
795
800
|
const numAmount = parseFloat(amount);
|
|
796
801
|
if (isNaN(numAmount) || numAmount < 0) {
|
|
797
|
-
throw new Error(
|
|
802
|
+
throw new Error(`\u65E0\u6548\u7684\u652F\u4ED8\u91D1\u989D: ${amount}`);
|
|
798
803
|
}
|
|
799
804
|
const oldAmount = this.store.stateAmount;
|
|
800
805
|
const formattedAmount = numAmount.toFixed(2);
|
|
801
806
|
if (oldAmount === formattedAmount) {
|
|
802
807
|
return;
|
|
803
808
|
}
|
|
804
|
-
this.logInfo("[Checkout]
|
|
809
|
+
this.logInfo("[Checkout] \u8BBE\u7F6E\u81EA\u5B9A\u4E49\u652F\u4ED8\u91D1\u989D:", {
|
|
805
810
|
oldAmount,
|
|
806
811
|
newAmount: formattedAmount
|
|
807
812
|
});
|
|
@@ -812,8 +817,8 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
812
817
|
timestamp: Date.now()
|
|
813
818
|
});
|
|
814
819
|
} catch (error) {
|
|
815
|
-
const errorMessage = error instanceof Error ? error.message : "
|
|
816
|
-
console.error("[Checkout]
|
|
820
|
+
const errorMessage = error instanceof Error ? error.message : "\u8BBE\u7F6E\u652F\u4ED8\u91D1\u989D\u5931\u8D25";
|
|
821
|
+
console.error("[Checkout] \u8BBE\u7F6E\u81EA\u5B9A\u4E49\u652F\u4ED8\u91D1\u989D\u5931\u8D25:", errorMessage);
|
|
817
822
|
await this.handleError(
|
|
818
823
|
new Error(errorMessage),
|
|
819
824
|
import_types.CheckoutErrorType.ValidationFailed
|
|
@@ -848,10 +853,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
848
853
|
*/
|
|
849
854
|
getCartSummary() {
|
|
850
855
|
if (!this.store.cartSummary || this.store.cartSummary.length === 0) {
|
|
851
|
-
console.warn("[Checkout]
|
|
856
|
+
console.warn("[Checkout] \u6CA1\u6709\u53EF\u7528\u7684\u8D2D\u7269\u8F66\u5C0F\u8BA1\u6570\u636E");
|
|
852
857
|
return null;
|
|
853
858
|
}
|
|
854
|
-
this.logInfo("
|
|
859
|
+
this.logInfo("\u83B7\u53D6\u8D2D\u7269\u8F66\u5C0F\u8BA1\u6570\u636E:", {
|
|
855
860
|
itemCount: this.store.cartSummary.length,
|
|
856
861
|
items: this.store.cartSummary.map((item) => ({
|
|
857
862
|
key: item.key,
|
|
@@ -872,20 +877,20 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
872
877
|
async getPaymentMethodsAsync() {
|
|
873
878
|
if (this.store.paymentMethods && this.store.paymentMethods.length > 0) {
|
|
874
879
|
this.logInfo(
|
|
875
|
-
|
|
880
|
+
`\u4F7F\u7528\u7F13\u5B58\u7684\u652F\u4ED8\u65B9\u5F0F\u6570\u636E\uFF0C\u5171 ${this.store.paymentMethods.length} \u79CD`
|
|
876
881
|
);
|
|
877
882
|
return this.store.paymentMethods;
|
|
878
883
|
}
|
|
879
|
-
this.logInfo("store
|
|
884
|
+
this.logInfo("store \u4E2D\u65E0\u7F13\u5B58\uFF0C\u4ECE Payment \u6A21\u5757\u83B7\u53D6\u652F\u4ED8\u65B9\u5F0F...");
|
|
880
885
|
try {
|
|
881
886
|
const methods = await this.payment.getPayMethodListAsync();
|
|
882
887
|
this.store.paymentMethods = methods;
|
|
883
888
|
this.logInfo(
|
|
884
|
-
|
|
889
|
+
`\u4ECE Payment \u6A21\u5757\u83B7\u53D6\u5230 ${methods.length} \u79CD\u652F\u4ED8\u65B9\u5F0F\uFF0C\u5DF2\u66F4\u65B0\u7F13\u5B58`
|
|
885
890
|
);
|
|
886
891
|
return methods;
|
|
887
892
|
} catch (error) {
|
|
888
|
-
this.logError("
|
|
893
|
+
this.logError("\u83B7\u53D6\u652F\u4ED8\u65B9\u5F0F\u5931\u8D25:", error);
|
|
889
894
|
return [];
|
|
890
895
|
}
|
|
891
896
|
}
|
|
@@ -904,7 +909,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
904
909
|
if (!this.store.currentOrder) {
|
|
905
910
|
throw (0, import_utils.createCheckoutError)(
|
|
906
911
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
907
|
-
"
|
|
912
|
+
"\u672A\u627E\u5230\u5F53\u524D\u8BA2\u5355\uFF0C\u65E0\u6CD5\u6DFB\u52A0\u652F\u4ED8\u9879"
|
|
908
913
|
);
|
|
909
914
|
}
|
|
910
915
|
const orderPaymentType = this.store.currentOrder.is_deposit === 1 ? "deposit" : "normal";
|
|
@@ -923,35 +928,35 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
923
928
|
this.store.currentOrder.uuid,
|
|
924
929
|
paymentItemWithType
|
|
925
930
|
);
|
|
926
|
-
this.logInfo("
|
|
931
|
+
this.logInfo("\u652F\u4ED8\u9879\u6DFB\u52A0\u6210\u529F");
|
|
927
932
|
this.clearCalculationCache();
|
|
928
933
|
await this.updateStateAmountToRemaining();
|
|
929
934
|
const remainingAmount = await this.calculateRemainingAmountAsync();
|
|
930
935
|
if (Number(remainingAmount) > 0) {
|
|
931
|
-
this.logInfo("
|
|
936
|
+
this.logInfo("\u8BA2\u5355\u91D1\u989D\u8FD8\u6709\u5F85\u4ED8\u7684\uFF0C\u540C\u6B65 EFTPOS \u652F\u4ED8");
|
|
932
937
|
const isEftposPayment = ((_a = paymentItem.type) == null ? void 0 : _a.toLowerCase()) === "eftpos" || ((_b = paymentItem.code) == null ? void 0 : _b.toUpperCase().includes("EFTPOS"));
|
|
933
938
|
const isCashPayment2 = paymentItem.code === "CASHMANUAL";
|
|
934
939
|
const isCustomePayment = paymentItem.type === "custom";
|
|
935
|
-
this.logInfo("EFTPOS
|
|
940
|
+
this.logInfo("EFTPOS \u652F\u4ED8\u68C0\u67E5:", {
|
|
936
941
|
paymentCode: paymentItem.code,
|
|
937
942
|
paymentType: paymentItem.type,
|
|
938
943
|
isEftposPayment,
|
|
939
944
|
currentOrderSynced: this.store.isOrderSynced
|
|
940
945
|
});
|
|
941
946
|
if (isEftposPayment || isCashPayment2 || isCustomePayment) {
|
|
942
|
-
this.logInfo("
|
|
947
|
+
this.logInfo("\u68C0\u6D4B\u5230 EFTPOS \u652F\u4ED8\uFF0C\u7ACB\u5373\u540C\u6B65\u8BA2\u5355\u5230\u540E\u7AEF...");
|
|
943
948
|
try {
|
|
944
949
|
const syncResult = await this.syncOrderToBackendWithReturn(true);
|
|
945
|
-
this.logInfo("EFTPOS
|
|
950
|
+
this.logInfo("EFTPOS \u652F\u4ED8\u540E\u8BA2\u5355\u540C\u6B65\u5B8C\u6210 (\u5DF2\u6807\u8BB0\u4E3A\u624B\u52A8\u540C\u6B65):", {
|
|
946
951
|
orderId: syncResult.orderId,
|
|
947
952
|
isOrderSynced: this.store.isOrderSynced,
|
|
948
953
|
backendResponse: syncResult.response
|
|
949
954
|
});
|
|
950
955
|
} catch (error) {
|
|
951
|
-
this.logError("EFTPOS
|
|
956
|
+
this.logError("EFTPOS \u652F\u4ED8\u540E\u8BA2\u5355\u540C\u6B65\u5931\u8D25:", error);
|
|
952
957
|
await this.handleError(
|
|
953
958
|
new Error(
|
|
954
|
-
`EFTPOS
|
|
959
|
+
`EFTPOS \u652F\u4ED8\u540E\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`
|
|
955
960
|
),
|
|
956
961
|
import_types.CheckoutErrorType.OrderCreationFailed
|
|
957
962
|
);
|
|
@@ -966,7 +971,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
966
971
|
timestamp: Date.now()
|
|
967
972
|
});
|
|
968
973
|
} catch (error) {
|
|
969
|
-
this.logError("
|
|
974
|
+
this.logError("\u6DFB\u52A0\u652F\u4ED8\u9879\u5931\u8D25:", error);
|
|
970
975
|
await this.handleError(error, import_types.CheckoutErrorType.PaymentFailed);
|
|
971
976
|
throw error;
|
|
972
977
|
}
|
|
@@ -985,10 +990,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
985
990
|
if (!this.store.currentOrder) {
|
|
986
991
|
throw (0, import_utils.createCheckoutError)(
|
|
987
992
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
988
|
-
"
|
|
993
|
+
"\u5F53\u524D\u6CA1\u6709\u6D3B\u8DC3\u8BA2\u5355\uFF0C\u65E0\u6CD5\u5220\u9664\u652F\u4ED8\u9879"
|
|
989
994
|
);
|
|
990
995
|
}
|
|
991
|
-
this.logWarning("
|
|
996
|
+
this.logWarning("\u5F00\u59CB\u5220\u9664\u652F\u4ED8\u9879:", {
|
|
992
997
|
orderUuid: this.store.currentOrder.uuid,
|
|
993
998
|
paymentUuid
|
|
994
999
|
});
|
|
@@ -1001,10 +1006,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1001
1006
|
if (!paymentItem) {
|
|
1002
1007
|
throw (0, import_utils.createCheckoutError)(
|
|
1003
1008
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
1004
|
-
|
|
1009
|
+
`\u652F\u4ED8\u9879\u4E0D\u5B58\u5728: ${paymentUuid}`
|
|
1005
1010
|
);
|
|
1006
1011
|
}
|
|
1007
|
-
this.logInfo("
|
|
1012
|
+
this.logInfo("\u627E\u5230\u8981\u5220\u9664\u7684\u652F\u4ED8\u9879:", {
|
|
1008
1013
|
uuid: paymentItem.uuid,
|
|
1009
1014
|
code: paymentItem.code,
|
|
1010
1015
|
amount: paymentItem.amount,
|
|
@@ -1014,7 +1019,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1014
1019
|
this.store.currentOrder.uuid,
|
|
1015
1020
|
paymentUuid
|
|
1016
1021
|
);
|
|
1017
|
-
this.logInfo("Payment
|
|
1022
|
+
this.logInfo("Payment\u652F\u4ED8\u9879\u5220\u9664\u5B8C\u6210", paymentItem);
|
|
1018
1023
|
this.clearCalculationCache();
|
|
1019
1024
|
const currentOrderId = this.store.currentOrder.order_id;
|
|
1020
1025
|
const isCurrentOrderReal = currentOrderId && !(0, import_utils.isVirtualOrderId)(currentOrderId);
|
|
@@ -1024,7 +1029,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1024
1029
|
if (updatedOrder) {
|
|
1025
1030
|
if (isCurrentOrderReal && (0, import_utils.isVirtualOrderId)(updatedOrder.order_id)) {
|
|
1026
1031
|
this.logWarning(
|
|
1027
|
-
"[Checkout] deletePaymentItemAsync:
|
|
1032
|
+
"[Checkout] deletePaymentItemAsync: \u68C0\u6D4B\u5230\u8BA2\u5355ID\u56DE\u9000\uFF0C\u4FDD\u62A4\u771F\u5B9E\u8BA2\u5355ID:",
|
|
1028
1033
|
{
|
|
1029
1034
|
currentRealId: currentOrderId,
|
|
1030
1035
|
retrievedVirtualId: updatedOrder.order_id
|
|
@@ -1043,7 +1048,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1043
1048
|
timestamp: Date.now()
|
|
1044
1049
|
});
|
|
1045
1050
|
} catch (error) {
|
|
1046
|
-
this.logError("
|
|
1051
|
+
this.logError("\u5220\u9664\u652F\u4ED8\u9879\u5931\u8D25:", error);
|
|
1047
1052
|
await this.handleError(error, import_types.CheckoutErrorType.PaymentFailed);
|
|
1048
1053
|
throw error;
|
|
1049
1054
|
}
|
|
@@ -1063,7 +1068,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1063
1068
|
if (!this.store.currentOrder) {
|
|
1064
1069
|
throw (0, import_utils.createCheckoutError)(
|
|
1065
1070
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
1066
|
-
"
|
|
1071
|
+
"\u5F53\u524D\u6CA1\u6709\u6D3B\u8DC3\u8BA2\u5355\uFF0C\u65E0\u6CD5\u66F4\u65B0\u4EE3\u91D1\u5238\u652F\u4ED8\u9879"
|
|
1067
1072
|
);
|
|
1068
1073
|
}
|
|
1069
1074
|
const paymentItems = await this.payment.getPaymentItemsAsync(
|
|
@@ -1074,7 +1079,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1074
1079
|
const remainingValue = new import_decimal.default(remainingAmount);
|
|
1075
1080
|
const isOrderSynced = this.store.isOrderSynced;
|
|
1076
1081
|
if (remainingValue.lte(0) && isOrderSynced && voucherPaymentItems.length === 0 && allPaymentItemsSynced) {
|
|
1077
|
-
this.logInfo("
|
|
1082
|
+
this.logInfo("\u8BA2\u5355\u5DF2\u540C\u6B65\u4E14\u652F\u4ED8\u5B8C\u6210\uFF0C\u8DF3\u8FC7\u6E05\u7A7A\u4EE3\u91D1\u5238\u64CD\u4F5C\u907F\u514D\u91CD\u590D\u540C\u6B65:", {
|
|
1078
1083
|
orderUuid: this.store.currentOrder.uuid,
|
|
1079
1084
|
orderId: this.store.currentOrder.order_id,
|
|
1080
1085
|
remainingAmount,
|
|
@@ -1084,7 +1089,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1084
1089
|
});
|
|
1085
1090
|
return;
|
|
1086
1091
|
}
|
|
1087
|
-
this.logInfo("
|
|
1092
|
+
this.logInfo("\u5F00\u59CB\u6279\u91CF\u66F4\u65B0\u4EE3\u91D1\u5238\u652F\u4ED8\u9879:", {
|
|
1088
1093
|
voucherPaymentItems
|
|
1089
1094
|
});
|
|
1090
1095
|
const orderPaymentType = this.store.currentOrder.is_deposit === 1 ? "deposit" : "normal";
|
|
@@ -1092,7 +1097,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1092
1097
|
if (!item.voucher_id) {
|
|
1093
1098
|
throw (0, import_utils.createCheckoutError)(
|
|
1094
1099
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
1095
|
-
|
|
1100
|
+
`\u4EE3\u91D1\u5238\u652F\u4ED8\u9879\u7F3A\u5C11 voucher_id: ${JSON.stringify(item)}`
|
|
1096
1101
|
);
|
|
1097
1102
|
}
|
|
1098
1103
|
const metadata = {
|
|
@@ -1119,7 +1124,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1119
1124
|
if (updatedOrder) {
|
|
1120
1125
|
if (isCurrentOrderReal && (0, import_utils.isVirtualOrderId)(updatedOrder.order_id)) {
|
|
1121
1126
|
this.logWarning(
|
|
1122
|
-
"updateVoucherPaymentItemsAsync:
|
|
1127
|
+
"updateVoucherPaymentItemsAsync: \u68C0\u6D4B\u5230\u8BA2\u5355ID\u56DE\u9000\uFF0C\u4FDD\u62A4\u771F\u5B9E\u8BA2\u5355ID:",
|
|
1123
1128
|
{
|
|
1124
1129
|
currentRealId: currentOrderId,
|
|
1125
1130
|
retrievedVirtualId: updatedOrder.order_id
|
|
@@ -1136,9 +1141,9 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1136
1141
|
amount: voucherPaymentItems.reduce((sum, item) => sum + parseFloat(String(item.amount)), 0).toFixed(2),
|
|
1137
1142
|
timestamp: Date.now()
|
|
1138
1143
|
});
|
|
1139
|
-
this.logInfo("
|
|
1144
|
+
this.logInfo("\u4EE3\u91D1\u5238\u652F\u4ED8\u9879\u6279\u91CF\u66F4\u65B0\u6210\u529F");
|
|
1140
1145
|
} catch (error) {
|
|
1141
|
-
this.logError("[Checkout]
|
|
1146
|
+
this.logError("[Checkout] \u6279\u91CF\u66F4\u65B0\u4EE3\u91D1\u5238\u652F\u4ED8\u9879\u5931\u8D25:", error);
|
|
1142
1147
|
await this.handleError(error, import_types.CheckoutErrorType.PaymentFailed);
|
|
1143
1148
|
throw error;
|
|
1144
1149
|
}
|
|
@@ -1156,19 +1161,19 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1156
1161
|
if (isDeposit !== 0 && isDeposit !== 1) {
|
|
1157
1162
|
throw (0, import_utils.createCheckoutError)(
|
|
1158
1163
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
1159
|
-
"isDeposit
|
|
1164
|
+
"isDeposit \u53C2\u6570\u53EA\u80FD\u662F 0\uFF08\u5168\u6B3E\u8BA2\u5355\uFF09\u6216 1\uFF08\u5B9A\u91D1\u8BA2\u5355\uFF09"
|
|
1160
1165
|
);
|
|
1161
1166
|
}
|
|
1162
1167
|
if (!this.store.currentOrder) {
|
|
1163
1168
|
throw (0, import_utils.createCheckoutError)(
|
|
1164
1169
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
1165
|
-
"
|
|
1170
|
+
"\u672A\u627E\u5230\u5F53\u524D\u8BA2\u5355\uFF0C\u65E0\u6CD5\u4FEE\u6539\u5B9A\u91D1\u72B6\u6001"
|
|
1166
1171
|
);
|
|
1167
1172
|
}
|
|
1168
1173
|
const newDepositValue = isDeposit;
|
|
1169
1174
|
const oldDepositValue = this.store.currentOrder.is_deposit;
|
|
1170
1175
|
if (oldDepositValue === newDepositValue) {
|
|
1171
|
-
console.log("[Checkout]
|
|
1176
|
+
console.log("[Checkout] \u5B9A\u91D1\u72B6\u6001\u65E0\u53D8\u5316\uFF0C\u8DF3\u8FC7\u66F4\u65B0");
|
|
1172
1177
|
return;
|
|
1173
1178
|
}
|
|
1174
1179
|
let deposit_amount = this.store.currentOrder.deposit_amount || "0.00";
|
|
@@ -1196,12 +1201,12 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1196
1201
|
order: this.store.currentOrder,
|
|
1197
1202
|
timestamp: Date.now()
|
|
1198
1203
|
});
|
|
1199
|
-
this.logInfo("
|
|
1204
|
+
this.logInfo("\u8BA2\u5355\u5B9A\u91D1\u72B6\u6001\u66F4\u65B0\u6210\u529F:", {
|
|
1200
1205
|
isDeposit: newDepositValue,
|
|
1201
1206
|
depositAmount: this.store.currentOrder.deposit_amount
|
|
1202
1207
|
});
|
|
1203
1208
|
} catch (error) {
|
|
1204
|
-
this.logError("
|
|
1209
|
+
this.logError("\u66F4\u65B0\u8BA2\u5355\u5B9A\u91D1\u72B6\u6001\u5931\u8D25:", error);
|
|
1205
1210
|
await this.handleError(
|
|
1206
1211
|
error,
|
|
1207
1212
|
import_types.CheckoutErrorType.ValidationFailed
|
|
@@ -1231,25 +1236,25 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1231
1236
|
if (depositValue.isNaN() || depositValue.lt(0)) {
|
|
1232
1237
|
throw (0, import_utils.createCheckoutError)(
|
|
1233
1238
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
1234
|
-
|
|
1239
|
+
`\u65E0\u6548\u7684\u5B9A\u91D1\u91D1\u989D\u683C\u5F0F: ${depositAmount}`
|
|
1235
1240
|
);
|
|
1236
1241
|
}
|
|
1237
1242
|
if (!this.store.currentOrder) {
|
|
1238
1243
|
throw (0, import_utils.createCheckoutError)(
|
|
1239
1244
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
1240
|
-
"
|
|
1245
|
+
"\u672A\u627E\u5230\u5F53\u524D\u8BA2\u5355\uFF0C\u65E0\u6CD5\u8BBE\u7F6E\u5B9A\u91D1\u91D1\u989D"
|
|
1241
1246
|
);
|
|
1242
1247
|
}
|
|
1243
1248
|
const formattedDepositAmount = depositValue.toFixed(2);
|
|
1244
1249
|
const oldDepositAmount = this.store.currentOrder.deposit_amount || "0.00";
|
|
1245
1250
|
if (formattedDepositAmount === oldDepositAmount) {
|
|
1246
|
-
this.logInfo("
|
|
1251
|
+
this.logInfo("\u5B9A\u91D1\u91D1\u989D\u65E0\u53D8\u5316\uFF0C\u8DF3\u8FC7\u66F4\u65B0:", {
|
|
1247
1252
|
currentAmount: oldDepositAmount,
|
|
1248
1253
|
newAmount: formattedDepositAmount
|
|
1249
1254
|
});
|
|
1250
1255
|
return;
|
|
1251
1256
|
}
|
|
1252
|
-
this.logInfo("
|
|
1257
|
+
this.logInfo("\u5F00\u59CB\u8BBE\u7F6E\u8BA2\u5355\u5B9A\u91D1\u91D1\u989D:", {
|
|
1253
1258
|
orderUuid: this.store.currentOrder.uuid,
|
|
1254
1259
|
orderId: this.store.currentOrder.order_id,
|
|
1255
1260
|
oldDepositAmount,
|
|
@@ -1261,10 +1266,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1261
1266
|
};
|
|
1262
1267
|
if (depositValue.gt(0) && this.store.currentOrder.is_deposit !== 1) {
|
|
1263
1268
|
updateParams.is_deposit = 1;
|
|
1264
|
-
this.logInfo("
|
|
1269
|
+
this.logInfo("\u5B9A\u91D1\u91D1\u989D\u5927\u4E8E0\uFF0C\u81EA\u52A8\u8BBE\u7F6E\u4E3A\u5B9A\u91D1\u8BA2\u5355");
|
|
1265
1270
|
} else if (depositValue.eq(0) && this.store.currentOrder.is_deposit === 1) {
|
|
1266
1271
|
updateParams.is_deposit = 0;
|
|
1267
|
-
this.logInfo("
|
|
1272
|
+
this.logInfo("\u5B9A\u91D1\u91D1\u989D\u4E3A0\uFF0C\u81EA\u52A8\u8BBE\u7F6E\u4E3A\u5168\u6B3E\u8BA2\u5355");
|
|
1268
1273
|
}
|
|
1269
1274
|
await this.payment.updateOrderAsync(
|
|
1270
1275
|
this.store.currentOrder.uuid,
|
|
@@ -1288,7 +1293,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1288
1293
|
order: this.store.currentOrder,
|
|
1289
1294
|
timestamp: Date.now()
|
|
1290
1295
|
});
|
|
1291
|
-
this.logInfo("
|
|
1296
|
+
this.logInfo("\u8BA2\u5355\u5B9A\u91D1\u91D1\u989D\u8BBE\u7F6E\u6210\u529F:", {
|
|
1292
1297
|
orderUuid: this.store.currentOrder.uuid,
|
|
1293
1298
|
orderId: this.store.currentOrder.order_id,
|
|
1294
1299
|
oldDepositAmount,
|
|
@@ -1297,7 +1302,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1297
1302
|
totalAmount: this.store.currentOrder.total_amount
|
|
1298
1303
|
});
|
|
1299
1304
|
} catch (error) {
|
|
1300
|
-
this.logError("
|
|
1305
|
+
this.logError("\u8BBE\u7F6E\u8BA2\u5355\u5B9A\u91D1\u91D1\u989D\u5931\u8D25:", error);
|
|
1301
1306
|
await this.handleError(
|
|
1302
1307
|
error,
|
|
1303
1308
|
import_types.CheckoutErrorType.ValidationFailed
|
|
@@ -1325,15 +1330,15 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1325
1330
|
if (!this.store.currentOrder) {
|
|
1326
1331
|
return {
|
|
1327
1332
|
success: false,
|
|
1328
|
-
message: "
|
|
1333
|
+
message: "\u5F53\u524D\u6CA1\u6709\u6D3B\u8DC3\u8BA2\u5355\uFF0C\u65E0\u6CD5\u540C\u6B65"
|
|
1329
1334
|
};
|
|
1330
1335
|
}
|
|
1331
1336
|
const orderUuid = this.store.currentOrder.uuid;
|
|
1332
1337
|
const oldOrderId = this.store.currentOrder.order_id;
|
|
1333
1338
|
if (this.store.isOrderSynced) {
|
|
1334
|
-
this.logInfo("
|
|
1339
|
+
this.logInfo("\u8BA2\u5355\u5DF2\u540C\u6B65\u8FC7\uFF0C\u5C06\u6267\u884C\u66F4\u65B0\u64CD\u4F5C");
|
|
1335
1340
|
}
|
|
1336
|
-
this.logInfo("
|
|
1341
|
+
this.logInfo("\u5F00\u59CB\u624B\u52A8\u540C\u6B65\u8BA2\u5355\u5230\u540E\u7AEF:", {
|
|
1337
1342
|
orderUuid,
|
|
1338
1343
|
orderId: oldOrderId,
|
|
1339
1344
|
totalAmount: this.store.currentOrder.total_amount,
|
|
@@ -1342,7 +1347,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1342
1347
|
console.time("manualSyncOrderAsync");
|
|
1343
1348
|
const syncResult = await this.syncOrderToBackendWithReturn(true);
|
|
1344
1349
|
console.timeEnd("manualSyncOrderAsync");
|
|
1345
|
-
this.logInfo("
|
|
1350
|
+
this.logInfo("\u624B\u52A8\u540C\u6B65\u8BA2\u5355\u5B8C\u6210:", {
|
|
1346
1351
|
orderUuid,
|
|
1347
1352
|
syncResult,
|
|
1348
1353
|
oldOrderId,
|
|
@@ -1352,11 +1357,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1352
1357
|
const finalOrderId = this.store.currentOrder.order_id;
|
|
1353
1358
|
const finalIsVirtual = (0, import_utils.isVirtualOrderId)(finalOrderId);
|
|
1354
1359
|
if (finalIsVirtual) {
|
|
1355
|
-
this.logError("
|
|
1360
|
+
this.logError("\u4E25\u91CD\u8B66\u544A\uFF1A\u624B\u52A8\u540C\u6B65\u5B8C\u6210\u540E\u8BA2\u5355ID\u4ECD\u4E3A\u865A\u62DFID\uFF01");
|
|
1356
1361
|
}
|
|
1357
1362
|
if (syncResult.orderId !== finalOrderId) {
|
|
1358
1363
|
this.logError(
|
|
1359
|
-
"[Checkout]
|
|
1364
|
+
"[Checkout] \u4E25\u91CD\u8B66\u544A\uFF1A\u8FD4\u56DE\u7684\u8BA2\u5355ID\u4E0E\u5B58\u50A8\u7684\u8BA2\u5355ID\u4E0D\u4E00\u81F4\uFF01"
|
|
1360
1365
|
);
|
|
1361
1366
|
}
|
|
1362
1367
|
let newRes = {
|
|
@@ -1366,11 +1371,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1366
1371
|
await this.updateStateAmountToRemaining(false);
|
|
1367
1372
|
return newRes;
|
|
1368
1373
|
} catch (error) {
|
|
1369
|
-
this.logError("
|
|
1370
|
-
const errorMessage = error instanceof Error ? error.message : "
|
|
1374
|
+
this.logError("\u624B\u52A8\u540C\u6B65\u8BA2\u5355\u5931\u8D25:", error);
|
|
1375
|
+
const errorMessage = error instanceof Error ? error.message : "\u540C\u6B65\u5931\u8D25";
|
|
1371
1376
|
return {
|
|
1372
1377
|
success: false,
|
|
1373
|
-
message:
|
|
1378
|
+
message: `\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ${errorMessage}`,
|
|
1374
1379
|
orderUuid: (_e = this.store.currentOrder) == null ? void 0 : _e.uuid
|
|
1375
1380
|
};
|
|
1376
1381
|
}
|
|
@@ -1382,7 +1387,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1382
1387
|
*/
|
|
1383
1388
|
getOrderNote() {
|
|
1384
1389
|
if (!this.store.localOrderData) {
|
|
1385
|
-
console.log("[Checkout]
|
|
1390
|
+
console.log("[Checkout] \u6CA1\u6709\u672C\u5730\u8BA2\u5355\u6570\u636E\uFF0C\u65E0\u6CD5\u83B7\u53D6\u5907\u6CE8");
|
|
1386
1391
|
return "";
|
|
1387
1392
|
}
|
|
1388
1393
|
return this.store.localOrderData.shop_note || "";
|
|
@@ -1405,11 +1410,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1405
1410
|
*/
|
|
1406
1411
|
isCurrentOrderSynced() {
|
|
1407
1412
|
if (!this.store.currentOrder) {
|
|
1408
|
-
console.log("[Checkout]
|
|
1413
|
+
console.log("[Checkout] \u6CA1\u6709\u5F53\u524D\u8BA2\u5355\uFF0C\u540C\u6B65\u72B6\u6001\u4E3Afalse");
|
|
1409
1414
|
return false;
|
|
1410
1415
|
}
|
|
1411
1416
|
const syncStatus = this.store.isOrderSynced;
|
|
1412
|
-
console.log("[Checkout]
|
|
1417
|
+
console.log("[Checkout] \u5F53\u524D\u8BA2\u5355\u540C\u6B65\u72B6\u6001:", {
|
|
1413
1418
|
orderUuid: this.store.currentOrder.uuid,
|
|
1414
1419
|
orderId: this.store.currentOrder.order_id,
|
|
1415
1420
|
isOrderSynced: syncStatus
|
|
@@ -1427,7 +1432,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1427
1432
|
async cancelCurrentOrderAsync(cancelReason) {
|
|
1428
1433
|
var _a, _b;
|
|
1429
1434
|
try {
|
|
1430
|
-
this.logInfo("
|
|
1435
|
+
this.logInfo("\u5F00\u59CB\u53D6\u6D88\u5F53\u524D\u672C\u5730\u8BA2\u5355:", {
|
|
1431
1436
|
hasCurrentOrder: !!this.store.currentOrder,
|
|
1432
1437
|
orderUuid: (_a = this.store.currentOrder) == null ? void 0 : _a.uuid,
|
|
1433
1438
|
orderId: (_b = this.store.currentOrder) == null ? void 0 : _b.order_id,
|
|
@@ -1435,34 +1440,34 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1435
1440
|
cancelReason
|
|
1436
1441
|
});
|
|
1437
1442
|
if (!this.store.currentOrder) {
|
|
1438
|
-
this.logInfo("
|
|
1443
|
+
this.logInfo("\u6CA1\u6709\u5F53\u524D\u8BA2\u5355\uFF0C\u65E0\u9700\u53D6\u6D88");
|
|
1439
1444
|
return {
|
|
1440
1445
|
success: false,
|
|
1441
|
-
message: "
|
|
1446
|
+
message: "\u6CA1\u6709\u5F53\u524D\u8BA2\u5355\u53EF\u53D6\u6D88"
|
|
1442
1447
|
};
|
|
1443
1448
|
}
|
|
1444
1449
|
const currentOrderUuid = this.store.currentOrder.uuid;
|
|
1445
1450
|
const currentOrderId = this.store.currentOrder.order_id;
|
|
1446
1451
|
const isOrderSynced = this.store.isOrderSynced;
|
|
1447
1452
|
if (isOrderSynced) {
|
|
1448
|
-
this.logInfo("
|
|
1453
|
+
this.logInfo("\u8BA2\u5355\u5DF2\u540C\u6B65\u5230\u540E\u7AEF\uFF0C\u4E0D\u80FD\u53D6\u6D88:", {
|
|
1449
1454
|
orderId: currentOrderId,
|
|
1450
1455
|
orderUuid: currentOrderUuid
|
|
1451
1456
|
});
|
|
1452
1457
|
return {
|
|
1453
1458
|
success: false,
|
|
1454
|
-
message: "
|
|
1459
|
+
message: "\u8BA2\u5355\u5DF2\u540C\u6B65\u5230\u540E\u7AEF\uFF0C\u65E0\u6CD5\u53D6\u6D88",
|
|
1455
1460
|
orderId: currentOrderId
|
|
1456
1461
|
};
|
|
1457
1462
|
}
|
|
1458
1463
|
try {
|
|
1459
|
-
this.logInfo("
|
|
1464
|
+
this.logInfo("\u5220\u9664\u672C\u5730\u8BA2\u5355\u6570\u636E");
|
|
1460
1465
|
await this.payment.deletePaymentOrderAsync(currentOrderUuid);
|
|
1461
|
-
this.logInfo("
|
|
1466
|
+
this.logInfo("\u672C\u5730\u8BA2\u5355\u6570\u636E\u5220\u9664\u6210\u529F");
|
|
1462
1467
|
} catch (error) {
|
|
1463
|
-
this.logWarning("
|
|
1468
|
+
this.logWarning("\u5220\u9664\u672C\u5730\u8BA2\u5355\u6570\u636E\u5931\u8D25\uFF0C\u4F46\u7EE7\u7EED\u6267\u884C:", error);
|
|
1464
1469
|
}
|
|
1465
|
-
this.logInfo("
|
|
1470
|
+
this.logInfo("\u6E05\u7406\u8BA2\u5355\u76F8\u5173\u72B6\u6001");
|
|
1466
1471
|
this.store.currentOrder = void 0;
|
|
1467
1472
|
this.store.localOrderData = void 0;
|
|
1468
1473
|
this.store.stateAmount = "0.00";
|
|
@@ -1470,7 +1475,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1470
1475
|
this.store.isOrderSynced = false;
|
|
1471
1476
|
this.store.currentCustomer = void 0;
|
|
1472
1477
|
this.payment.wallet.clearAllCache();
|
|
1473
|
-
this.logInfo("
|
|
1478
|
+
this.logInfo("\u8BA2\u5355\u72B6\u6001\u6E05\u7406\u5B8C\u6210\uFF0CcurrentOrder\u5DF2\u91CA\u653E");
|
|
1474
1479
|
await this.core.effects.emit(`${this.name}:onOrderCancelled`, {
|
|
1475
1480
|
orderUuid: currentOrderUuid,
|
|
1476
1481
|
orderId: currentOrderId,
|
|
@@ -1479,22 +1484,22 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1479
1484
|
// 只有未同步订单可以被取消
|
|
1480
1485
|
timestamp: Date.now()
|
|
1481
1486
|
});
|
|
1482
|
-
this.logInfo("
|
|
1487
|
+
this.logInfo("\u672C\u5730\u8BA2\u5355\u53D6\u6D88\u5B8C\u6210:", {
|
|
1483
1488
|
orderUuid: currentOrderUuid,
|
|
1484
1489
|
orderId: currentOrderId,
|
|
1485
1490
|
cancelReason
|
|
1486
1491
|
});
|
|
1487
1492
|
return {
|
|
1488
1493
|
success: true,
|
|
1489
|
-
message: "
|
|
1494
|
+
message: "\u672C\u5730\u8BA2\u5355\u5DF2\u6210\u529F\u53D6\u6D88",
|
|
1490
1495
|
orderId: currentOrderId
|
|
1491
1496
|
};
|
|
1492
1497
|
} catch (error) {
|
|
1493
|
-
this.logError("
|
|
1494
|
-
const errorMessage = error instanceof Error ? error.message : "
|
|
1498
|
+
this.logError("\u53D6\u6D88\u672C\u5730\u8BA2\u5355\u5931\u8D25:", error);
|
|
1499
|
+
const errorMessage = error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF";
|
|
1495
1500
|
return {
|
|
1496
1501
|
success: false,
|
|
1497
|
-
message:
|
|
1502
|
+
message: `\u53D6\u6D88\u8BA2\u5355\u5931\u8D25: ${errorMessage}`
|
|
1498
1503
|
};
|
|
1499
1504
|
}
|
|
1500
1505
|
}
|
|
@@ -1510,12 +1515,12 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1510
1515
|
if (!this.store.currentOrder) {
|
|
1511
1516
|
return {
|
|
1512
1517
|
success: false,
|
|
1513
|
-
message: "
|
|
1518
|
+
message: "\u5F53\u524D\u6CA1\u6709\u6D3B\u8DC3\u8BA2\u5355\uFF0C\u65E0\u6CD5\u4FDD\u5B58"
|
|
1514
1519
|
};
|
|
1515
1520
|
}
|
|
1516
1521
|
const orderUuid = this.store.currentOrder.uuid;
|
|
1517
1522
|
const currentOrderId = this.store.currentOrder.order_id;
|
|
1518
|
-
this.logInfo("
|
|
1523
|
+
this.logInfo("\u5F00\u59CB\u4FDD\u5B58\u8BA2\u5355\u5E76\u7A0D\u540E\u652F\u4ED8:", {
|
|
1519
1524
|
orderUuid,
|
|
1520
1525
|
orderId: currentOrderId,
|
|
1521
1526
|
totalAmount: this.store.currentOrder.total_amount
|
|
@@ -1527,7 +1532,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1527
1532
|
true,
|
|
1528
1533
|
allPaymentItems
|
|
1529
1534
|
);
|
|
1530
|
-
this.logInfo("
|
|
1535
|
+
this.logInfo("\u4FDD\u5B58\u8BA2\u5355\u5B8C\u6210:", {
|
|
1531
1536
|
orderUuid,
|
|
1532
1537
|
oldOrderId: currentOrderId,
|
|
1533
1538
|
syncResult,
|
|
@@ -1537,17 +1542,17 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1537
1542
|
});
|
|
1538
1543
|
return {
|
|
1539
1544
|
success: true,
|
|
1540
|
-
message: "
|
|
1545
|
+
message: "\u8BA2\u5355\u4FDD\u5B58\u6210\u529F\uFF0C\u53EF\u7A0D\u540E\u7EE7\u7EED\u652F\u4ED8",
|
|
1541
1546
|
orderId: syncResult.orderId,
|
|
1542
1547
|
orderUuid,
|
|
1543
1548
|
response: syncResult.response
|
|
1544
1549
|
};
|
|
1545
1550
|
} catch (error) {
|
|
1546
|
-
this.logError("
|
|
1547
|
-
const errorMessage = error instanceof Error ? error.message : "
|
|
1551
|
+
this.logError("\u4FDD\u5B58\u8BA2\u5355\u5931\u8D25:", error);
|
|
1552
|
+
const errorMessage = error instanceof Error ? error.message : "\u4FDD\u5B58\u5931\u8D25";
|
|
1548
1553
|
return {
|
|
1549
1554
|
success: false,
|
|
1550
|
-
message:
|
|
1555
|
+
message: `\u8BA2\u5355\u4FDD\u5B58\u5931\u8D25: ${errorMessage}`,
|
|
1551
1556
|
orderUuid: (_a = this.store.currentOrder) == null ? void 0 : _a.uuid
|
|
1552
1557
|
};
|
|
1553
1558
|
}
|
|
@@ -1563,10 +1568,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1563
1568
|
if (!this.store.localOrderData) {
|
|
1564
1569
|
throw (0, import_utils.createCheckoutError)(
|
|
1565
1570
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
1566
|
-
"
|
|
1571
|
+
"\u6CA1\u6709\u672C\u5730\u8BA2\u5355\u6570\u636E\uFF0C\u65E0\u6CD5\u66F4\u65B0\u5907\u6CE8"
|
|
1567
1572
|
);
|
|
1568
1573
|
}
|
|
1569
|
-
console.log("[Checkout]
|
|
1574
|
+
console.log("[Checkout] \u66F4\u65B0\u8BA2\u5355\u5907\u6CE8:", {
|
|
1570
1575
|
orderUuid: (_a = this.store.currentOrder) == null ? void 0 : _a.uuid,
|
|
1571
1576
|
oldNote: this.store.localOrderData.shop_note,
|
|
1572
1577
|
newNote: note
|
|
@@ -1579,11 +1584,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1579
1584
|
this.store.currentOrder.uuid
|
|
1580
1585
|
);
|
|
1581
1586
|
if (orderInPayment && orderInPayment.note !== void 0) {
|
|
1582
|
-
console.log("[Checkout]
|
|
1587
|
+
console.log("[Checkout] \u540C\u6B65\u5907\u6CE8\u5230Payment\u6A21\u5757\u7684\u8BA2\u5355\u6570\u636E\u4E2D");
|
|
1583
1588
|
}
|
|
1584
1589
|
} catch (syncError) {
|
|
1585
1590
|
console.warn(
|
|
1586
|
-
"[Checkout]
|
|
1591
|
+
"[Checkout] \u540C\u6B65\u5907\u6CE8\u5230Payment\u6A21\u5757\u5931\u8D25\uFF0C\u4F46\u672C\u5730\u66F4\u65B0\u6210\u529F:",
|
|
1587
1592
|
syncError
|
|
1588
1593
|
);
|
|
1589
1594
|
}
|
|
@@ -1594,12 +1599,12 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1594
1599
|
newNote: note,
|
|
1595
1600
|
timestamp: Date.now()
|
|
1596
1601
|
});
|
|
1597
|
-
console.log("[Checkout]
|
|
1602
|
+
console.log("[Checkout] \u8BA2\u5355\u5907\u6CE8\u66F4\u65B0\u6210\u529F:", {
|
|
1598
1603
|
oldNote,
|
|
1599
1604
|
newNote: note
|
|
1600
1605
|
});
|
|
1601
1606
|
} catch (error) {
|
|
1602
|
-
console.error("[Checkout]
|
|
1607
|
+
console.error("[Checkout] \u66F4\u65B0\u8BA2\u5355\u5907\u6CE8\u5931\u8D25:", error);
|
|
1603
1608
|
await this.handleError(
|
|
1604
1609
|
error,
|
|
1605
1610
|
import_types.CheckoutErrorType.ValidationFailed
|
|
@@ -1618,7 +1623,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1618
1623
|
context: {},
|
|
1619
1624
|
timestamp: Date.now()
|
|
1620
1625
|
});
|
|
1621
|
-
console.error("[Checkout]
|
|
1626
|
+
console.error("[Checkout] \u9519\u8BEF:", checkoutError);
|
|
1622
1627
|
}
|
|
1623
1628
|
/**
|
|
1624
1629
|
* 处理支付成功
|
|
@@ -1641,7 +1646,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1641
1646
|
var _a;
|
|
1642
1647
|
const error = (0, import_utils.createCheckoutError)(
|
|
1643
1648
|
import_types.CheckoutErrorType.PaymentFailed,
|
|
1644
|
-
data.error || "
|
|
1649
|
+
data.error || "\u652F\u4ED8\u540C\u6B65\u5931\u8D25"
|
|
1645
1650
|
);
|
|
1646
1651
|
await this.handleError(
|
|
1647
1652
|
error instanceof Error ? error : new Error(String(error)),
|
|
@@ -1715,7 +1720,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1715
1720
|
});
|
|
1716
1721
|
return processedPaymentItem;
|
|
1717
1722
|
} catch (error) {
|
|
1718
|
-
this.logError("
|
|
1723
|
+
this.logError("\u5904\u7406\u73B0\u91D1\u652F\u4ED8\u9879\u65F6\u51FA\u9519:", error);
|
|
1719
1724
|
return paymentItem;
|
|
1720
1725
|
}
|
|
1721
1726
|
}
|
|
@@ -1724,12 +1729,12 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1724
1729
|
*/
|
|
1725
1730
|
async preloadPaymentMethods() {
|
|
1726
1731
|
try {
|
|
1727
|
-
console.log("[Checkout]
|
|
1732
|
+
console.log("[Checkout] \u9884\u52A0\u8F7D\u652F\u4ED8\u65B9\u5F0F...");
|
|
1728
1733
|
const methods = await this.payment.getPayMethodListAsync();
|
|
1729
1734
|
this.store.paymentMethods = methods;
|
|
1730
|
-
console.log(`[Checkout]
|
|
1735
|
+
console.log(`[Checkout] \u9884\u52A0\u8F7D\u5B8C\u6210\uFF0C\u5171 ${methods.length} \u79CD\u652F\u4ED8\u65B9\u5F0F`);
|
|
1731
1736
|
} catch (error) {
|
|
1732
|
-
console.error("[Checkout]
|
|
1737
|
+
console.error("[Checkout] \u9884\u52A0\u8F7D\u652F\u4ED8\u65B9\u5F0F\u5931\u8D25:", error);
|
|
1733
1738
|
this.store.paymentMethods = [];
|
|
1734
1739
|
}
|
|
1735
1740
|
}
|
|
@@ -1746,15 +1751,15 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1746
1751
|
const retentionDays = cleanupConfig.retentionDays || 7;
|
|
1747
1752
|
const maxOrdersToDelete = cleanupConfig.maxOrdersToDelete || 100;
|
|
1748
1753
|
if (!isCleanupEnabled) {
|
|
1749
|
-
console.log("[Checkout]
|
|
1754
|
+
console.log("[Checkout] \u8BA2\u5355\u6570\u636E\u6E05\u7406\u529F\u80FD\u5DF2\u7981\u7528");
|
|
1750
1755
|
return;
|
|
1751
1756
|
}
|
|
1752
1757
|
console.log(
|
|
1753
|
-
`[Checkout]
|
|
1758
|
+
`[Checkout] \u5F00\u59CB\u6E05\u7406\u8FC7\u671F\u8BA2\u5355\u6570\u636E\uFF08\u4FDD\u7559 ${retentionDays} \u5929\u5185\u7684\u6570\u636E\uFF09...`
|
|
1754
1759
|
);
|
|
1755
1760
|
const allOrders = await this.payment.getOrderListAsync();
|
|
1756
1761
|
if (!allOrders || allOrders.length === 0) {
|
|
1757
|
-
console.log("[Checkout]
|
|
1762
|
+
console.log("[Checkout] \u6CA1\u6709\u627E\u5230\u9700\u8981\u6E05\u7406\u7684\u8BA2\u5355\u6570\u636E");
|
|
1758
1763
|
return;
|
|
1759
1764
|
}
|
|
1760
1765
|
const thresholdDate = /* @__PURE__ */ new Date();
|
|
@@ -1789,7 +1794,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1789
1794
|
});
|
|
1790
1795
|
}
|
|
1791
1796
|
} catch (error) {
|
|
1792
|
-
console.warn(`[Checkout]
|
|
1797
|
+
console.warn(`[Checkout] \u5904\u7406\u8BA2\u5355 ${order.uuid} \u65F6\u51FA\u9519:`, error);
|
|
1793
1798
|
continue;
|
|
1794
1799
|
}
|
|
1795
1800
|
}
|
|
@@ -1802,10 +1807,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1802
1807
|
await this.payment.deletePaymentOrderAsync(orderInfo.uuid);
|
|
1803
1808
|
deletedCount++;
|
|
1804
1809
|
console.log(
|
|
1805
|
-
`[Checkout]
|
|
1810
|
+
`[Checkout] \u5DF2\u5220\u9664\u8FC7\u671F\u8BA2\u5355: ${orderInfo.orderId} (${orderInfo.daysSinceCreated} \u5929\u524D\u521B\u5EFA)`
|
|
1806
1811
|
);
|
|
1807
1812
|
} catch (error) {
|
|
1808
|
-
console.error(`[Checkout]
|
|
1813
|
+
console.error(`[Checkout] \u5220\u9664\u8BA2\u5355 ${orderInfo.uuid} \u5931\u8D25:`, error);
|
|
1809
1814
|
}
|
|
1810
1815
|
}
|
|
1811
1816
|
const summary = {
|
|
@@ -1821,16 +1826,16 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1821
1826
|
this.logInfo("Expired orders cleanup completed", summary);
|
|
1822
1827
|
if (ordersToDelete.length > maxOrdersToDelete) {
|
|
1823
1828
|
console.log(
|
|
1824
|
-
`[Checkout]
|
|
1829
|
+
`[Checkout] \u8FC7\u671F\u8BA2\u5355\u6E05\u7406\u5B8C\u6210: \u603B\u8BA1 ${allOrders.length} \u4E2A\u8BA2\u5355\uFF0C\u53D1\u73B0 ${ordersToDelete.length} \u4E2A\u8FC7\u671F\u5DF2\u540C\u6B65\u8BA2\u5355\uFF0C\u5220\u9664\u4E86 ${deletedCount} \u4E2A\uFF08\u9650\u5236\u4E3A ${maxOrdersToDelete} \u4E2A\uFF09`
|
|
1825
1830
|
);
|
|
1826
1831
|
} else {
|
|
1827
1832
|
console.log(
|
|
1828
|
-
`[Checkout]
|
|
1833
|
+
`[Checkout] \u8FC7\u671F\u8BA2\u5355\u6E05\u7406\u5B8C\u6210: \u603B\u8BA1 ${allOrders.length} \u4E2A\u8BA2\u5355\uFF0C\u5220\u9664\u4E86 ${deletedCount} \u4E2A\u8FC7\u671F\u5DF2\u540C\u6B65\u8BA2\u5355`
|
|
1829
1834
|
);
|
|
1830
1835
|
}
|
|
1831
1836
|
} catch (error) {
|
|
1832
1837
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1833
|
-
console.error("[Checkout]
|
|
1838
|
+
console.error("[Checkout] \u6E05\u7406\u8FC7\u671F\u8BA2\u5355\u6570\u636E\u5931\u8D25:", error);
|
|
1834
1839
|
this.logError("Expired orders cleanup failed", { error: errorMessage });
|
|
1835
1840
|
}
|
|
1836
1841
|
}
|
|
@@ -1889,7 +1894,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1889
1894
|
*/
|
|
1890
1895
|
async calculatePaidAmountAsync() {
|
|
1891
1896
|
if (!this.store.currentOrder) {
|
|
1892
|
-
this.logWarning("[Checkout] calculatePaidAmountAsync:
|
|
1897
|
+
this.logWarning("[Checkout] calculatePaidAmountAsync: \u6CA1\u6709\u5F53\u524D\u8BA2\u5355");
|
|
1893
1898
|
return "0.00";
|
|
1894
1899
|
}
|
|
1895
1900
|
try {
|
|
@@ -1905,10 +1910,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1905
1910
|
);
|
|
1906
1911
|
const result = this.calculatePaidAmountFromItems(payments);
|
|
1907
1912
|
this.calculationCache.paidAmount = result;
|
|
1908
|
-
this.logInfo("calculatePaidAmountAsync:
|
|
1913
|
+
this.logInfo("calculatePaidAmountAsync: \u8BA1\u7B97\u7ED3\u679C =", result);
|
|
1909
1914
|
return result;
|
|
1910
1915
|
} catch (error) {
|
|
1911
|
-
this.logError("calculatePaidAmountAsync
|
|
1916
|
+
this.logError("calculatePaidAmountAsync \u5931\u8D25:", error);
|
|
1912
1917
|
return "0.00";
|
|
1913
1918
|
}
|
|
1914
1919
|
}
|
|
@@ -1941,7 +1946,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1941
1946
|
*/
|
|
1942
1947
|
async calculateRemainingAmountAsync() {
|
|
1943
1948
|
if (!this.store.currentOrder) {
|
|
1944
|
-
this.logWarning("calculateRemainingAmountAsync:
|
|
1949
|
+
this.logWarning("calculateRemainingAmountAsync: \u6CA1\u6709\u5F53\u524D\u8BA2\u5355");
|
|
1945
1950
|
return "0.00";
|
|
1946
1951
|
}
|
|
1947
1952
|
const { currentOrder } = await this.fetchOrderDataBatch();
|
|
@@ -1950,7 +1955,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1950
1955
|
}
|
|
1951
1956
|
const paidAmountStr = await this.calculatePaidAmountAsync();
|
|
1952
1957
|
const result = this.calculateRemainingAmountFromData(currentOrder, paidAmountStr);
|
|
1953
|
-
this.logInfo("calculateRemainingAmountAsync:
|
|
1958
|
+
this.logInfo("calculateRemainingAmountAsync: \u8BA1\u7B97=", result);
|
|
1954
1959
|
return result;
|
|
1955
1960
|
}
|
|
1956
1961
|
/**
|
|
@@ -1961,7 +1966,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1961
1966
|
*/
|
|
1962
1967
|
async calculateRemainingTotalAmountAsync() {
|
|
1963
1968
|
if (!this.store.currentOrder) {
|
|
1964
|
-
this.logWarning("calculateRemainingTotalAmountAsync:
|
|
1969
|
+
this.logWarning("calculateRemainingTotalAmountAsync: \u6CA1\u6709\u5F53\u524D\u8BA2\u5355");
|
|
1965
1970
|
return "0.00";
|
|
1966
1971
|
}
|
|
1967
1972
|
const { currentOrder } = await this.fetchOrderDataBatch();
|
|
@@ -1970,7 +1975,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1970
1975
|
}
|
|
1971
1976
|
const paidAmountStr = await this.calculatePaidAmountAsync();
|
|
1972
1977
|
const result = this.calculateRemainingTotalAmountFromData(currentOrder, paidAmountStr);
|
|
1973
|
-
this.logInfo("calculateRemainingTotalAmountAsync:
|
|
1978
|
+
this.logInfo("calculateRemainingTotalAmountAsync: \u8BA1\u7B97=", result);
|
|
1974
1979
|
return result;
|
|
1975
1980
|
}
|
|
1976
1981
|
/**
|
|
@@ -1989,18 +1994,18 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1989
1994
|
timestamp: Date.now(),
|
|
1990
1995
|
totalAmount: remainingTotalAmount
|
|
1991
1996
|
});
|
|
1992
|
-
this.logInfo("balanceDueAmount
|
|
1997
|
+
this.logInfo("balanceDueAmount \u5DF2\u81EA\u52A8\u66F4\u65B0:", {
|
|
1993
1998
|
oldAmount: currentBalanceDueAmount,
|
|
1994
1999
|
newAmount: remainingAmount
|
|
1995
2000
|
});
|
|
1996
2001
|
} else {
|
|
1997
|
-
this.logInfo("balanceDueAmount
|
|
2002
|
+
this.logInfo("balanceDueAmount \u65E0\u9700\u66F4\u65B0\uFF0C\u5F53\u524D\u503C\u5DF2\u662F\u6700\u65B0:", {
|
|
1998
2003
|
balanceDueAmount: currentBalanceDueAmount,
|
|
1999
2004
|
remainingAmount
|
|
2000
2005
|
});
|
|
2001
2006
|
}
|
|
2002
2007
|
} catch (error) {
|
|
2003
|
-
this.logError("
|
|
2008
|
+
this.logError("\u66F4\u65B0 balanceDueAmount \u5931\u8D25:", error);
|
|
2004
2009
|
}
|
|
2005
2010
|
}
|
|
2006
2011
|
/**
|
|
@@ -2017,7 +2022,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2017
2022
|
const { paymentItems, currentOrder } = await this.fetchOrderDataBatch();
|
|
2018
2023
|
console.timeEnd("updateStateAmountToRemaining");
|
|
2019
2024
|
if (!currentOrder) {
|
|
2020
|
-
this.logWarning("updateStateAmountToRemaining:
|
|
2025
|
+
this.logWarning("updateStateAmountToRemaining: \u672A\u627E\u5230\u5F53\u524D\u8BA2\u5355");
|
|
2021
2026
|
return;
|
|
2022
2027
|
}
|
|
2023
2028
|
const paidAmount = this.calculatePaidAmountFromItems(paymentItems);
|
|
@@ -2066,7 +2071,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2066
2071
|
totalAmount: remainingTotalAmount
|
|
2067
2072
|
});
|
|
2068
2073
|
}, 0);
|
|
2069
|
-
this.logInfo("stateAmount
|
|
2074
|
+
this.logInfo("stateAmount \u5DF2\u81EA\u52A8\u66F4\u65B0\u4E3A\u5269\u4F59\u91D1\u989D:", {
|
|
2070
2075
|
oldAmount: currentStateAmount,
|
|
2071
2076
|
newAmount: remainingAmount
|
|
2072
2077
|
});
|
|
@@ -2084,14 +2089,14 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2084
2089
|
totalAmount: remainingTotalAmount
|
|
2085
2090
|
});
|
|
2086
2091
|
}, 0);
|
|
2087
|
-
this.logInfo("balanceDueAmount
|
|
2092
|
+
this.logInfo("balanceDueAmount \u5DF2\u81EA\u52A8\u66F4\u65B0:", {
|
|
2088
2093
|
oldAmount: currentBalanceDueAmount,
|
|
2089
2094
|
newAmount: remainingAmount
|
|
2090
2095
|
});
|
|
2091
2096
|
}
|
|
2092
2097
|
console.timeEnd("updateStateAmountToRemaining: updateStateAmountToRemaining");
|
|
2093
2098
|
if (!hasStateChanged) {
|
|
2094
|
-
this.logInfo("
|
|
2099
|
+
this.logInfo("\u72B6\u6001\u65E0\u9700\u66F4\u65B0\uFF0C\u5F53\u524D\u503C\u5DF2\u662F\u6700\u65B0:", {
|
|
2095
2100
|
stateAmount: currentStateAmount,
|
|
2096
2101
|
remainingAmount
|
|
2097
2102
|
});
|
|
@@ -2099,10 +2104,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2099
2104
|
if (checkOrder) {
|
|
2100
2105
|
await this.checkOrderPaymentCompletionOptimized(paymentItems, remainingAmount);
|
|
2101
2106
|
} else {
|
|
2102
|
-
this.logInfo("
|
|
2107
|
+
this.logInfo("\u5916\u90E8\u4F20\u5165\u65E0\u9700 checkOrder\uFF0C\u4E0D\u6267\u884C\u8BA2\u5355\u652F\u4ED8\u5B8C\u6210\u68C0\u6D4B\u548C\u540C\u6B65");
|
|
2103
2108
|
}
|
|
2104
2109
|
} catch (error) {
|
|
2105
|
-
this.logError("
|
|
2110
|
+
this.logError("\u66F4\u65B0 stateAmount \u4E3A\u5269\u4F59\u91D1\u989D\u5931\u8D25:", error);
|
|
2106
2111
|
}
|
|
2107
2112
|
}
|
|
2108
2113
|
/**
|
|
@@ -2120,7 +2125,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2120
2125
|
if (remainingValue.lte(0)) {
|
|
2121
2126
|
const totalAmount = this.store.currentOrder.total_amount;
|
|
2122
2127
|
const paidAmount = this.calculationCache.paidAmount || "0.00";
|
|
2123
|
-
this.logInfo("
|
|
2128
|
+
this.logInfo("\u68C0\u6D4B\u5230\u8BA2\u5355\u652F\u4ED8\u5B8C\u6210:", {
|
|
2124
2129
|
orderUuid: this.store.currentOrder.uuid,
|
|
2125
2130
|
orderId: this.store.currentOrder.order_id,
|
|
2126
2131
|
totalAmount,
|
|
@@ -2133,13 +2138,13 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2133
2138
|
(item) => item.status !== "voided" && item.voucher_id
|
|
2134
2139
|
);
|
|
2135
2140
|
const shouldAutoSync = hasPaymentItems && !allPaymentsHaveVoucherId;
|
|
2136
|
-
this.logInfo("
|
|
2141
|
+
this.logInfo("\u81EA\u52A8\u540C\u6B65\u8BA2\u5355\u6761\u4EF6\u68C0\u67E5:", {
|
|
2137
2142
|
paymentCount: paymentItems.length,
|
|
2138
2143
|
hasPaymentItems,
|
|
2139
2144
|
allHaveVoucherId: allPaymentsHaveVoucherId,
|
|
2140
2145
|
isOrderSynced: this.store.isOrderSynced,
|
|
2141
2146
|
shouldAutoSync,
|
|
2142
|
-
reason: shouldAutoSync ? "
|
|
2147
|
+
reason: shouldAutoSync ? "\u652F\u4ED8\u5B8C\u6210\uFF0C\u9700\u8981\u540C\u6B65\u6700\u7EC8\u652F\u4ED8\u72B6\u6001" : "\u8DF3\u8FC7\u540C\u6B65",
|
|
2143
2148
|
paymentItems: paymentItems.map((p) => ({
|
|
2144
2149
|
uuid: p.uuid,
|
|
2145
2150
|
code: p.code,
|
|
@@ -2151,13 +2156,13 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2151
2156
|
}))
|
|
2152
2157
|
});
|
|
2153
2158
|
if (shouldAutoSync) {
|
|
2154
|
-
this.logInfo("
|
|
2159
|
+
this.logInfo("\u6EE1\u8DB3\u81EA\u52A8\u540C\u6B65\u6761\u4EF6\uFF0C\u5F00\u59CB\u540C\u6B65\u8BA2\u5355\u5230\u540E\u7AEF...");
|
|
2155
2160
|
await this.syncOrderToBackendWithReturn(false);
|
|
2156
2161
|
} else {
|
|
2157
2162
|
if (!hasPaymentItems) {
|
|
2158
|
-
this.logInfo("
|
|
2163
|
+
this.logInfo("\u6CA1\u6709\u652F\u4ED8\u9879\uFF0C\u8DF3\u8FC7\u8BA2\u5355\u540C\u6B65");
|
|
2159
2164
|
} else if (allPaymentsHaveVoucherId) {
|
|
2160
|
-
this.logInfo("
|
|
2165
|
+
this.logInfo("\u6240\u6709\u652F\u4ED8\u9879\u5747\u4E3A\u4EE3\u91D1\u5238\u7C7B\u578B\uFF0C\u8DF3\u8FC7\u8BA2\u5355\u540C\u6B65");
|
|
2161
2166
|
}
|
|
2162
2167
|
}
|
|
2163
2168
|
await this.core.effects.emit(`${this.name}:onOrderPaymentCompleted`, {
|
|
@@ -2170,7 +2175,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2170
2175
|
});
|
|
2171
2176
|
}
|
|
2172
2177
|
} catch (error) {
|
|
2173
|
-
this.logError("
|
|
2178
|
+
this.logError("\u68C0\u67E5\u8BA2\u5355\u652F\u4ED8\u5B8C\u6210\u72B6\u6001\u5931\u8D25:", error);
|
|
2174
2179
|
}
|
|
2175
2180
|
}
|
|
2176
2181
|
/**
|
|
@@ -2191,7 +2196,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2191
2196
|
if (remainingValue.lte(0)) {
|
|
2192
2197
|
const totalAmount = this.store.currentOrder.total_amount;
|
|
2193
2198
|
const paidAmount = await this.calculatePaidAmountAsync();
|
|
2194
|
-
this.logInfo("
|
|
2199
|
+
this.logInfo("\u68C0\u6D4B\u5230\u8BA2\u5355\u652F\u4ED8\u5B8C\u6210:", {
|
|
2195
2200
|
orderUuid: this.store.currentOrder.uuid,
|
|
2196
2201
|
orderId: this.store.currentOrder.order_id,
|
|
2197
2202
|
totalAmount,
|
|
@@ -2209,13 +2214,13 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2209
2214
|
(item) => item.status !== "voided" && item.voucher_id
|
|
2210
2215
|
);
|
|
2211
2216
|
const shouldAutoSync = hasPaymentItems && !allPaymentsHaveVoucherId;
|
|
2212
|
-
this.logInfo("
|
|
2217
|
+
this.logInfo("\u81EA\u52A8\u540C\u6B65\u8BA2\u5355\u6761\u4EF6\u68C0\u67E5:", {
|
|
2213
2218
|
paymentCount: currentPayments.length,
|
|
2214
2219
|
hasPaymentItems,
|
|
2215
2220
|
allHaveVoucherId: allPaymentsHaveVoucherId,
|
|
2216
2221
|
isOrderSynced: this.store.isOrderSynced,
|
|
2217
2222
|
shouldAutoSync,
|
|
2218
|
-
reason: shouldAutoSync ? "
|
|
2223
|
+
reason: shouldAutoSync ? "\u652F\u4ED8\u5B8C\u6210\uFF0C\u9700\u8981\u540C\u6B65\u6700\u7EC8\u652F\u4ED8\u72B6\u6001" : "\u8DF3\u8FC7\u540C\u6B65",
|
|
2219
2224
|
paymentItems: currentPayments.map((p) => ({
|
|
2220
2225
|
uuid: p.uuid,
|
|
2221
2226
|
code: p.code,
|
|
@@ -2227,13 +2232,13 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2227
2232
|
}))
|
|
2228
2233
|
});
|
|
2229
2234
|
if (shouldAutoSync) {
|
|
2230
|
-
this.logInfo("
|
|
2235
|
+
this.logInfo("\u6EE1\u8DB3\u81EA\u52A8\u540C\u6B65\u6761\u4EF6\uFF0C\u5F00\u59CB\u540C\u6B65\u8BA2\u5355\u5230\u540E\u7AEF...");
|
|
2231
2236
|
await this.syncOrderToBackendWithReturn(false);
|
|
2232
2237
|
} else {
|
|
2233
2238
|
if (!hasPaymentItems) {
|
|
2234
|
-
this.logInfo("
|
|
2239
|
+
this.logInfo("\u6CA1\u6709\u652F\u4ED8\u9879\uFF0C\u8DF3\u8FC7\u8BA2\u5355\u540C\u6B65");
|
|
2235
2240
|
} else if (allPaymentsHaveVoucherId) {
|
|
2236
|
-
this.logInfo("
|
|
2241
|
+
this.logInfo("\u6240\u6709\u652F\u4ED8\u9879\u5747\u4E3A\u4EE3\u91D1\u5238\u7C7B\u578B\uFF0C\u8DF3\u8FC7\u8BA2\u5355\u540C\u6B65");
|
|
2237
2242
|
}
|
|
2238
2243
|
}
|
|
2239
2244
|
await this.core.effects.emit(`${this.name}:onOrderPaymentCompleted`, {
|
|
@@ -2246,7 +2251,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2246
2251
|
});
|
|
2247
2252
|
}
|
|
2248
2253
|
} catch (error) {
|
|
2249
|
-
this.logError("
|
|
2254
|
+
this.logError("\u68C0\u67E5\u8BA2\u5355\u652F\u4ED8\u5B8C\u6210\u72B6\u6001\u5931\u8D25:", error);
|
|
2250
2255
|
}
|
|
2251
2256
|
}
|
|
2252
2257
|
/**
|
|
@@ -2259,12 +2264,12 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2259
2264
|
async syncOrderToBackendWithReturn(isManual = false, customPaymentItems) {
|
|
2260
2265
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2261
2266
|
if (!this.store.localOrderData || !this.store.currentOrder) {
|
|
2262
|
-
throw new Error("
|
|
2267
|
+
throw new Error("\u7F3A\u5C11\u5FC5\u8981\u7684\u8BA2\u5355\u6570\u636E\uFF0C\u65E0\u6CD5\u540C\u6B65\u5230\u540E\u7AEF");
|
|
2263
2268
|
}
|
|
2264
2269
|
this.logInfo("syncOrderToBackendWithReturn called", { isManual });
|
|
2265
2270
|
const currentOrderId = this.store.currentOrder.order_id;
|
|
2266
2271
|
const isUpdateOperation = this.store.isOrderSynced || !(0, import_utils.isVirtualOrderId)(currentOrderId);
|
|
2267
|
-
this.logInfo(
|
|
2272
|
+
this.logInfo(`\u5F00\u59CB\u540C\u6B65\u8BA2\u5355\u5230\u540E\u7AEF...`, {
|
|
2268
2273
|
currentOrderId,
|
|
2269
2274
|
isVirtualId: (0, import_utils.isVirtualOrderId)(currentOrderId || ""),
|
|
2270
2275
|
orderUuid: this.store.currentOrder.uuid,
|
|
@@ -2288,15 +2293,15 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2288
2293
|
const manualDepositValue = new import_decimal.default(manualDepositAmount);
|
|
2289
2294
|
if (manualDepositValue.gt(0)) {
|
|
2290
2295
|
finalDepositAmount = manualDepositAmount;
|
|
2291
|
-
this.logInfo("
|
|
2296
|
+
this.logInfo("\u4F7F\u7528\u624B\u52A8\u8BBE\u7F6E\u7684\u5B9A\u91D1\u91D1\u989D", {
|
|
2292
2297
|
manualDepositAmount,
|
|
2293
|
-
reason: "
|
|
2298
|
+
reason: "\u7528\u6237\u901A\u8FC7setDepositAmountAsync\u624B\u52A8\u8BBE\u7F6E\u4E86\u5B9A\u91D1\u91D1\u989D"
|
|
2294
2299
|
});
|
|
2295
2300
|
} else {
|
|
2296
2301
|
finalDepositAmount = "0.00";
|
|
2297
|
-
this.logInfo("
|
|
2302
|
+
this.logInfo("\u5B9A\u91D1\u91D1\u989D\u4E3A0", {
|
|
2298
2303
|
manualDepositAmount,
|
|
2299
|
-
reason: "
|
|
2304
|
+
reason: "\u624B\u52A8\u8BBE\u7F6E\u548C\u8BA1\u7B97\u503C\u5747\u4E3A0"
|
|
2300
2305
|
});
|
|
2301
2306
|
}
|
|
2302
2307
|
if (this.store.currentOrder.is_deposit === 0 && processedPaymentItems.every((item) => item.order_payment_type !== "deposit")) {
|
|
@@ -2317,7 +2322,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2317
2322
|
return sum.plus(amt).sub(rounding);
|
|
2318
2323
|
}, new import_decimal.default(0)).toFixed(2);
|
|
2319
2324
|
}
|
|
2320
|
-
this.logInfo("
|
|
2325
|
+
this.logInfo("\u5B9A\u91D1\u91D1\u989D\u786E\u5B9A\u7ED3\u679C", {
|
|
2321
2326
|
depositPaymentItemsCount: processedPaymentItems.length,
|
|
2322
2327
|
depositPaymentItems: processedPaymentItems.map((item) => ({
|
|
2323
2328
|
uuid: item.uuid,
|
|
@@ -2378,7 +2383,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2378
2383
|
if (isUpdateOperation) {
|
|
2379
2384
|
if ((0, import_utils.isVirtualOrderId)(currentOrderId)) {
|
|
2380
2385
|
this.logWarning(
|
|
2381
|
-
"
|
|
2386
|
+
"\u5C1D\u8BD5\u6570\u636E\u4FEE\u590D\uFF1A\u6682\u65F6\u4E0D\u5305\u542Border_id\uFF0C\u6CE8\u610F\uFF1A\u8FD9\u6B21\u8C03\u7528\u5C06\u4F5C\u4E3A\u521B\u5EFA\u64CD\u4F5C\u5904\u7406\uFF0C\u4F46\u540E\u7EED\u4F1A\u4FEE\u590D\u6570\u636E\u4E00\u81F4\u6027"
|
|
2382
2387
|
);
|
|
2383
2388
|
} else {
|
|
2384
2389
|
orderParams.order_id = currentOrderId;
|
|
@@ -2403,11 +2408,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2403
2408
|
});
|
|
2404
2409
|
checkoutResponse = await this.order.createOrderByCheckout(orderParams);
|
|
2405
2410
|
submitSuccess = true;
|
|
2406
|
-
this.logInfo("
|
|
2411
|
+
this.logInfo("\u4E0B\u5355\u63A5\u53E3\u8C03\u7528\u6210\u529F", checkoutResponse);
|
|
2407
2412
|
} catch (error) {
|
|
2408
2413
|
submitSuccess = false;
|
|
2409
2414
|
submitError = error instanceof Error ? error.message : String(error);
|
|
2410
|
-
this.logError("
|
|
2415
|
+
this.logError("\u4E0B\u5355\u63A5\u53E3\u8C03\u7528\u5931\u8D25:", submitError);
|
|
2411
2416
|
await this.core.effects.emit(`${this.name}:onOrderSyncFailed`, {
|
|
2412
2417
|
orderUuid: this.store.currentOrder.uuid,
|
|
2413
2418
|
operation: isUpdateOperation ? "update" : "create",
|
|
@@ -2433,7 +2438,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2433
2438
|
const responseStatus = checkoutResponse == null ? void 0 : checkoutResponse.status;
|
|
2434
2439
|
const isSuccessResponse = responseStatus === true || responseStatus === 200 || responseStatus === "success" || responseStatus === 1 && (checkoutResponse == null ? void 0 : checkoutResponse.code) === 200;
|
|
2435
2440
|
if (!isSuccessResponse) {
|
|
2436
|
-
const errorMessage = (checkoutResponse == null ? void 0 : checkoutResponse.message) || "
|
|
2441
|
+
const errorMessage = (checkoutResponse == null ? void 0 : checkoutResponse.message) || "\u8BA2\u5355\u540C\u6B65\u5931\u8D25\uFF0C\u540E\u7AEF\u8FD4\u56DE\u975E\u6210\u529F\u72B6\u6001";
|
|
2437
2442
|
await this.core.effects.emit(`${this.name}:onOrderSyncFailed`, {
|
|
2438
2443
|
orderUuid: this.store.currentOrder.uuid,
|
|
2439
2444
|
operation: isUpdateOperation ? "update" : "create",
|
|
@@ -2458,10 +2463,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2458
2463
|
extractedOrderId = String(extractedOrderId);
|
|
2459
2464
|
}
|
|
2460
2465
|
if (!extractedOrderId) {
|
|
2461
|
-
this.logError("
|
|
2466
|
+
this.logError("\u540E\u7AEF\u8FD4\u56DE\u7684\u8BA2\u5355\u4FE1\u606F\u4E2D\u672A\u5305\u542B\u8BA2\u5355ID");
|
|
2462
2467
|
}
|
|
2463
2468
|
realOrderId = extractedOrderId;
|
|
2464
|
-
this.logInfo("
|
|
2469
|
+
this.logInfo("\u51C6\u5907\u66FF\u6362\u8BA2\u5355ID:", {
|
|
2465
2470
|
orderUuid: this.store.currentOrder.uuid,
|
|
2466
2471
|
oldOrderId: this.store.currentOrder.order_id,
|
|
2467
2472
|
newOrderId: realOrderId
|
|
@@ -2471,38 +2476,38 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2471
2476
|
this.store.currentOrder.uuid,
|
|
2472
2477
|
realOrderId
|
|
2473
2478
|
);
|
|
2474
|
-
this.logInfo("Payment
|
|
2479
|
+
this.logInfo("Payment\u6A21\u5757\u66FF\u6362\u8BA2\u5355ID\u7ED3\u679C:", {
|
|
2475
2480
|
wasSuccessful: !!updatedOrder,
|
|
2476
2481
|
returnedOrderId: updatedOrder == null ? void 0 : updatedOrder.order_id,
|
|
2477
2482
|
expectedOrderId: realOrderId
|
|
2478
2483
|
});
|
|
2479
2484
|
if (updatedOrder) {
|
|
2480
|
-
this.logInfo("Payment
|
|
2485
|
+
this.logInfo("Payment\u6A21\u5757\u8FD4\u56DE\u7684\u66F4\u65B0\u540E\u8BA2\u5355:", {
|
|
2481
2486
|
uuid: updatedOrder.uuid,
|
|
2482
2487
|
orderId: updatedOrder.order_id,
|
|
2483
2488
|
totalAmount: updatedOrder.total_amount
|
|
2484
2489
|
});
|
|
2485
2490
|
this.store.currentOrder = updatedOrder;
|
|
2486
2491
|
this.logInfo(
|
|
2487
|
-
"[Checkout]
|
|
2492
|
+
"[Checkout] \u8BA2\u5355ID\u66FF\u6362\u6210\u529F\uFF0C\u5F53\u524D\u8BA2\u5355ID:",
|
|
2488
2493
|
this.store.currentOrder.order_id
|
|
2489
2494
|
);
|
|
2490
2495
|
} else {
|
|
2491
2496
|
this.logError(
|
|
2492
|
-
"[Checkout] Payment
|
|
2497
|
+
"[Checkout] Payment\u6A21\u5757\u8FD4\u56DE\u7A7A\u8BA2\u5355\uFF0C\u8BA2\u5355ID\u66FF\u6362\u5931\u8D25\uFF0C\u5F00\u59CB\u624B\u52A8\u66FF\u6362"
|
|
2493
2498
|
);
|
|
2494
2499
|
const beforeManualUpdate = this.store.currentOrder.order_id;
|
|
2495
2500
|
this.store.currentOrder.order_id = realOrderId;
|
|
2496
|
-
this.logInfo("
|
|
2501
|
+
this.logInfo("\u624B\u52A8\u8BBE\u7F6E\u8BA2\u5355ID:", {
|
|
2497
2502
|
beforeReplacement: beforeManualUpdate,
|
|
2498
2503
|
afterReplacement: this.store.currentOrder.order_id,
|
|
2499
|
-
|
|
2504
|
+
\u76EE\u6807ID: realOrderId
|
|
2500
2505
|
});
|
|
2501
2506
|
}
|
|
2502
2507
|
} catch (error) {
|
|
2503
|
-
this.logError("
|
|
2508
|
+
this.logError("\u8C03\u7528Payment\u6A21\u5757\u66FF\u6362\u8BA2\u5355ID\u65F6\u53D1\u751F\u9519\u8BEF:", error);
|
|
2504
2509
|
this.store.currentOrder.order_id = realOrderId;
|
|
2505
|
-
this.logInfo("
|
|
2510
|
+
this.logInfo("\u9519\u8BEF\u6062\u590D\uFF1A\u624B\u52A8\u8BBE\u7F6E\u8BA2\u5355ID:", realOrderId);
|
|
2506
2511
|
}
|
|
2507
2512
|
}
|
|
2508
2513
|
try {
|
|
@@ -2515,7 +2520,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2515
2520
|
);
|
|
2516
2521
|
}
|
|
2517
2522
|
} catch (e) {
|
|
2518
|
-
this.logWarning("
|
|
2523
|
+
this.logWarning("\u6807\u8BB0\u652F\u4ED8\u9879\u5DF2\u540C\u6B65\u5931\u8D25\uFF08\u4E0D\u963B\u585E\u4E3B\u6D41\u7A0B\uFF09", { error: e });
|
|
2519
2524
|
}
|
|
2520
2525
|
this.store.isOrderSynced = true;
|
|
2521
2526
|
this.clearCalculationCache();
|
|
@@ -2560,7 +2565,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2560
2565
|
if (!orderId) {
|
|
2561
2566
|
return {
|
|
2562
2567
|
success: false,
|
|
2563
|
-
message: "
|
|
2568
|
+
message: "\u8BA2\u5355ID\u4E0D\u80FD\u4E3A\u7A7A",
|
|
2564
2569
|
orderId
|
|
2565
2570
|
};
|
|
2566
2571
|
}
|
|
@@ -2574,7 +2579,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2574
2579
|
const response = await this.request.put(`/order/order/${orderId}/note`, {
|
|
2575
2580
|
note
|
|
2576
2581
|
});
|
|
2577
|
-
this.logInfo("
|
|
2582
|
+
this.logInfo("\u8BA2\u5355\u5907\u6CE8\u7F16\u8F91\u54CD\u5E94:", {
|
|
2578
2583
|
orderId,
|
|
2579
2584
|
status: response.status,
|
|
2580
2585
|
message: response.message,
|
|
@@ -2595,12 +2600,12 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2595
2600
|
}
|
|
2596
2601
|
return {
|
|
2597
2602
|
success: true,
|
|
2598
|
-
message: response.message || "
|
|
2603
|
+
message: response.message || "\u8BA2\u5355\u5907\u6CE8\u4FEE\u6539\u6210\u529F",
|
|
2599
2604
|
orderId
|
|
2600
2605
|
};
|
|
2601
2606
|
} else {
|
|
2602
|
-
const errorMessage = response.message || "
|
|
2603
|
-
this.logError(
|
|
2607
|
+
const errorMessage = response.message || "\u8BA2\u5355\u5907\u6CE8\u4FEE\u6539\u5931\u8D25";
|
|
2608
|
+
this.logError(`\u8BA2\u5355 ${orderId} \u5907\u6CE8\u4FEE\u6539\u5931\u8D25:`, errorMessage);
|
|
2604
2609
|
return {
|
|
2605
2610
|
success: false,
|
|
2606
2611
|
message: errorMessage,
|
|
@@ -2608,11 +2613,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2608
2613
|
};
|
|
2609
2614
|
}
|
|
2610
2615
|
} catch (error) {
|
|
2611
|
-
this.logError("
|
|
2612
|
-
const errorMessage = error instanceof Error ? error.message : "
|
|
2616
|
+
this.logError("\u7F16\u8F91\u8BA2\u5355\u5907\u6CE8\u5931\u8D25:", error);
|
|
2617
|
+
const errorMessage = error instanceof Error ? error.message : "\u7F51\u7EDC\u9519\u8BEF\u6216\u670D\u52A1\u5668\u5F02\u5E38";
|
|
2613
2618
|
return {
|
|
2614
2619
|
success: false,
|
|
2615
|
-
message:
|
|
2620
|
+
message: `\u7F16\u8F91\u8BA2\u5355\u5907\u6CE8\u5931\u8D25: ${errorMessage}`,
|
|
2616
2621
|
orderId
|
|
2617
2622
|
};
|
|
2618
2623
|
}
|
|
@@ -2638,13 +2643,13 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2638
2643
|
if (!params.order_ids || params.order_ids.length === 0) {
|
|
2639
2644
|
return {
|
|
2640
2645
|
success: false,
|
|
2641
|
-
message: "
|
|
2646
|
+
message: "\u8BA2\u5355ID\u5217\u8868\u4E0D\u80FD\u4E3A\u7A7A"
|
|
2642
2647
|
};
|
|
2643
2648
|
}
|
|
2644
2649
|
if (!params.emails || params.emails.length === 0) {
|
|
2645
2650
|
return {
|
|
2646
2651
|
success: false,
|
|
2647
|
-
message: "
|
|
2652
|
+
message: "\u90AE\u7BB1\u5730\u5740\u5217\u8868\u4E0D\u80FD\u4E3A\u7A7A"
|
|
2648
2653
|
};
|
|
2649
2654
|
}
|
|
2650
2655
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
@@ -2654,7 +2659,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2654
2659
|
if (invalidEmails.length > 0) {
|
|
2655
2660
|
return {
|
|
2656
2661
|
success: false,
|
|
2657
|
-
message:
|
|
2662
|
+
message: `\u90AE\u7BB1\u683C\u5F0F\u65E0\u6548: ${invalidEmails.join(", ")}`
|
|
2658
2663
|
};
|
|
2659
2664
|
}
|
|
2660
2665
|
const requestBody = {
|
|
@@ -2670,7 +2675,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2670
2675
|
"/order/batch-email",
|
|
2671
2676
|
requestBody
|
|
2672
2677
|
);
|
|
2673
|
-
this.logInfo("
|
|
2678
|
+
this.logInfo("\u652F\u4ED8\u94FE\u63A5\u90AE\u4EF6\u53D1\u9001\u54CD\u5E94:", {
|
|
2674
2679
|
status: response.status,
|
|
2675
2680
|
message: response.message,
|
|
2676
2681
|
data: response.data,
|
|
@@ -2679,22 +2684,22 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2679
2684
|
if (response.status === true || response.status === 200) {
|
|
2680
2685
|
return {
|
|
2681
2686
|
success: true,
|
|
2682
|
-
message: response.message || "
|
|
2687
|
+
message: response.message || "\u652F\u4ED8\u94FE\u63A5\u90AE\u4EF6\u53D1\u9001\u6210\u529F"
|
|
2683
2688
|
};
|
|
2684
2689
|
} else {
|
|
2685
|
-
const errorMessage = response.message || "
|
|
2686
|
-
console.error("[Checkout]
|
|
2690
|
+
const errorMessage = response.message || "\u652F\u4ED8\u94FE\u63A5\u90AE\u4EF6\u53D1\u9001\u5931\u8D25";
|
|
2691
|
+
console.error("[Checkout] \u652F\u4ED8\u94FE\u63A5\u90AE\u4EF6\u53D1\u9001\u5931\u8D25:", errorMessage);
|
|
2687
2692
|
return {
|
|
2688
2693
|
success: false,
|
|
2689
2694
|
message: errorMessage
|
|
2690
2695
|
};
|
|
2691
2696
|
}
|
|
2692
2697
|
} catch (error) {
|
|
2693
|
-
this.logError("
|
|
2694
|
-
const errorMessage = error instanceof Error ? error.message : "
|
|
2698
|
+
this.logError("\u53D1\u9001\u5BA2\u6237\u652F\u4ED8\u94FE\u63A5\u90AE\u4EF6\u5931\u8D25:", error);
|
|
2699
|
+
const errorMessage = error instanceof Error ? error.message : "\u7F51\u7EDC\u9519\u8BEF\u6216\u670D\u52A1\u5668\u5F02\u5E38";
|
|
2695
2700
|
return {
|
|
2696
2701
|
success: false,
|
|
2697
|
-
message:
|
|
2702
|
+
message: `\u53D1\u9001\u652F\u4ED8\u94FE\u63A5\u90AE\u4EF6\u5931\u8D25: ${errorMessage}`
|
|
2698
2703
|
};
|
|
2699
2704
|
}
|
|
2700
2705
|
}
|
|
@@ -2728,7 +2733,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2728
2733
|
await ((_b = (_a = this.order) == null ? void 0 : _a.destroy) == null ? void 0 : _b.call(_a));
|
|
2729
2734
|
await ((_d = (_c = this.payment) == null ? void 0 : _c.destroy) == null ? void 0 : _d.call(_c));
|
|
2730
2735
|
this.core.unregisterModule(this);
|
|
2731
|
-
console.log("[Checkout]
|
|
2736
|
+
console.log("[Checkout] \u5DF2\u9500\u6BC1");
|
|
2732
2737
|
}
|
|
2733
2738
|
/**
|
|
2734
2739
|
* 重置 store 状态
|
|
@@ -2743,7 +2748,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2743
2748
|
uuid: this.store.currentOrder.uuid,
|
|
2744
2749
|
orderId: this.store.currentOrder.order_id
|
|
2745
2750
|
} : null;
|
|
2746
|
-
console.log("[Checkout]
|
|
2751
|
+
console.log("[Checkout] \u91CD\u7F6E store \u72B6\u6001\uFF0C\u51C6\u5907\u521B\u5EFA\u65B0\u8BA2\u5355", prevOrderInfo);
|
|
2747
2752
|
this.store.currentOrder = void 0;
|
|
2748
2753
|
this.store.localOrderData = void 0;
|
|
2749
2754
|
this.store.cartSummary = void 0;
|
|
@@ -2755,7 +2760,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2755
2760
|
this.store.cartItems = [];
|
|
2756
2761
|
this.payment.wallet.clearAllCache();
|
|
2757
2762
|
this.clearCalculationCache();
|
|
2758
|
-
console.log("[Checkout] Store
|
|
2763
|
+
console.log("[Checkout] Store \u72B6\u6001\u91CD\u7F6E\u5B8C\u6210");
|
|
2759
2764
|
if (prevOrderInfo) {
|
|
2760
2765
|
setTimeout(() => {
|
|
2761
2766
|
this.core.effects.emit(`${this.name}:onOrderCleared`, {
|
|
@@ -2765,7 +2770,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2765
2770
|
}, 0);
|
|
2766
2771
|
}
|
|
2767
2772
|
} catch (error) {
|
|
2768
|
-
console.error("[Checkout]
|
|
2773
|
+
console.error("[Checkout] \u91CD\u7F6E store \u72B6\u6001\u5931\u8D25:", error);
|
|
2769
2774
|
}
|
|
2770
2775
|
}
|
|
2771
2776
|
};
|