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