@pisell/pisellos 0.0.321 → 0.0.324
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/ProductList/index.js +2 -1
- package/dist/modules/Rules/types.d.ts +1 -1
- package/dist/modules/Schedule/type.d.ts +7 -7
- package/dist/modules/Schedule/types.d.ts +9 -9
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingByStep/utils/resources.d.ts +1 -1
- package/dist/solution/ShopDiscount/types.d.ts +1 -1
- 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 +11 -9
- 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 +80 -69
- 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 +7 -4
- package/lib/modules/Resource/index.js +8 -12
- package/lib/modules/Rules/index.js +12 -17
- package/lib/modules/Rules/types.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/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 +70 -104
- 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 +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 +206 -199
- package/lib/solution/Checkout/utils/index.js +18 -22
- package/lib/solution/ShopDiscount/index.js +15 -11
- package/lib/solution/ShopDiscount/types.d.ts +1 -1
- package/lib/types/index.d.ts +1 -1
- package/lib/utils/task.d.ts +2 -2
- package/lib/utils/task.js +3 -3
- package/lib/utils/watch.d.ts +2 -2
- package/lib/utils/watch.js +5 -7
- package/package.json +1 -1
|
@@ -43,23 +43,30 @@ 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
|
+
order;
|
|
56
|
+
payment;
|
|
46
57
|
constructor(name, version) {
|
|
47
58
|
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
59
|
}
|
|
53
60
|
async initialize(core, options) {
|
|
54
61
|
this.core = core;
|
|
55
62
|
this.otherParams = options.otherParams || {};
|
|
56
63
|
this.request = core.getPlugin("request");
|
|
57
64
|
if (!this.request) {
|
|
58
|
-
throw new Error("Checkout
|
|
65
|
+
throw new Error("Checkout \u89E3\u51B3\u65B9\u6848\u9700\u8981 request \u63D2\u4EF6\u652F\u6301");
|
|
59
66
|
}
|
|
60
67
|
const appPlugin = core.getPlugin("app");
|
|
61
68
|
if (!appPlugin) {
|
|
62
|
-
throw new Error("Checkout
|
|
69
|
+
throw new Error("Checkout \u89E3\u51B3\u65B9\u6848\u9700\u8981 app \u63D2\u4EF6\u652F\u6301");
|
|
63
70
|
}
|
|
64
71
|
const app = appPlugin.getApp();
|
|
65
72
|
this.logger = app.logger;
|
|
@@ -77,7 +84,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
77
84
|
await this.initializeSubModules(core, options);
|
|
78
85
|
await this.preloadPaymentMethods();
|
|
79
86
|
await this.cleanupExpiredOrdersAsync();
|
|
80
|
-
console.log("[Checkout]
|
|
87
|
+
console.log("[Checkout] \u521D\u59CB\u5316\u5B8C\u6210");
|
|
81
88
|
await this.core.effects.emit(import_types.CheckoutHooks.OnCheckoutInitialized, {
|
|
82
89
|
timestamp: Date.now()
|
|
83
90
|
});
|
|
@@ -153,14 +160,14 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
153
160
|
this.core.effects.on(
|
|
154
161
|
import_types2.PaymentHooks.OnPaymentMethodsLoaded,
|
|
155
162
|
async (methods) => {
|
|
156
|
-
console.log("[Checkout]
|
|
163
|
+
console.log("[Checkout] \u6536\u5230\u652F\u4ED8\u65B9\u5F0F\u52A0\u8F7D\u5B8C\u6210\u4E8B\u4EF6:", methods.length);
|
|
157
164
|
this.store.paymentMethods = methods;
|
|
158
165
|
}
|
|
159
166
|
);
|
|
160
167
|
this.core.effects.on(
|
|
161
168
|
import_types2.PaymentHooks.OnPaymentMethodsChanged,
|
|
162
169
|
async (data) => {
|
|
163
|
-
console.log("[Checkout]
|
|
170
|
+
console.log("[Checkout] \u6536\u5230\u652F\u4ED8\u65B9\u5F0F\u53D8\u66F4\u4E8B\u4EF6:", {
|
|
164
171
|
oldCount: data.oldMethods.length,
|
|
165
172
|
newCount: data.newMethods.length
|
|
166
173
|
});
|
|
@@ -183,11 +190,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
183
190
|
if (!validation.valid) {
|
|
184
191
|
throw (0, import_utils.createCheckoutError)(
|
|
185
192
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
186
|
-
|
|
193
|
+
`\u53C2\u6570\u9A8C\u8BC1\u5931\u8D25: ${validation.errors.join(", ")}`
|
|
187
194
|
);
|
|
188
195
|
}
|
|
189
196
|
this.store.cartItems = params.cartItems;
|
|
190
|
-
console.log("[Checkout]
|
|
197
|
+
console.log("[Checkout] \u7ED3\u8D26\u6D41\u7A0B\u521D\u59CB\u5316\u5B8C\u6210");
|
|
191
198
|
} catch (error) {
|
|
192
199
|
await this.handleError(error, import_types.CheckoutErrorType.UnknownError);
|
|
193
200
|
throw error;
|
|
@@ -247,13 +254,13 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
247
254
|
if (this.store.isOrderSynced) {
|
|
248
255
|
walletBusinessData.payment_order_id = (_f = this.store.currentOrder) == null ? void 0 : _f.order_id;
|
|
249
256
|
}
|
|
250
|
-
this.logInfo("
|
|
257
|
+
this.logInfo("\u5F00\u59CB\u62C9\u53D6:initializeWalletDataFromBusinessAsync", {
|
|
251
258
|
walletBusinessData
|
|
252
259
|
});
|
|
253
260
|
await this.payment.wallet.initializeWalletDataFromBusinessAsync(
|
|
254
261
|
walletBusinessData
|
|
255
262
|
);
|
|
256
|
-
this.logInfo("
|
|
263
|
+
this.logInfo("\u8C03\u7528\u7ED3\u675F:initializeWalletDataFromBusinessAsync", {
|
|
257
264
|
walletBusinessData
|
|
258
265
|
});
|
|
259
266
|
if (!this.store.currentOrder) {
|
|
@@ -349,7 +356,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
349
356
|
if (!validation.valid) {
|
|
350
357
|
throw (0, import_utils.createCheckoutError)(
|
|
351
358
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
352
|
-
|
|
359
|
+
`\u8BA2\u5355\u6570\u636E\u9A8C\u8BC1\u5931\u8D25: ${validation.errors.join(", ")}`
|
|
353
360
|
);
|
|
354
361
|
}
|
|
355
362
|
const localOrderId = (0, import_utils.generateLocalOrderId)();
|
|
@@ -368,10 +375,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
368
375
|
};
|
|
369
376
|
if (customerInfo.customer_id || customerInfo.customer_name) {
|
|
370
377
|
this.store.currentCustomer = customerInfo;
|
|
371
|
-
console.log("[Checkout]
|
|
378
|
+
console.log("[Checkout] \u4FDD\u5B58\u5BA2\u6237\u4FE1\u606F:", customerInfo);
|
|
372
379
|
} else {
|
|
373
380
|
this.store.currentCustomer = void 0;
|
|
374
|
-
console.log("[Checkout]
|
|
381
|
+
console.log("[Checkout] \u672A\u63D0\u4F9B\u5BA2\u6237\u4FE1\u606F");
|
|
375
382
|
}
|
|
376
383
|
const isNeedDeposit = this.checkIsNeedDepositAsync(
|
|
377
384
|
params.orderData.bookings,
|
|
@@ -401,7 +408,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
401
408
|
timestamp: Date.now()
|
|
402
409
|
});
|
|
403
410
|
await this.updateStateAmountToRemaining(false);
|
|
404
|
-
this.logInfo("
|
|
411
|
+
this.logInfo("\u672C\u5730\u8BA2\u5355\u521B\u5EFA\u6210\u529F:", {
|
|
405
412
|
localOrderId,
|
|
406
413
|
uuid: paymentOrder.uuid,
|
|
407
414
|
totalAmount: amountInfo.totalAmount,
|
|
@@ -416,7 +423,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
416
423
|
error,
|
|
417
424
|
import_types.CheckoutErrorType.OrderCreationFailed
|
|
418
425
|
);
|
|
419
|
-
this.logError("
|
|
426
|
+
this.logError("\u672C\u5730\u8BA2\u5355\u521B\u5EFA\u5931\u8D25:", error);
|
|
420
427
|
this.core.effects.emit(import_types.CheckoutHooks.OnOrderCreationFailed, {
|
|
421
428
|
error: this.store.lastError,
|
|
422
429
|
timestamp: Date.now()
|
|
@@ -443,7 +450,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
443
450
|
if (!validation.valid) {
|
|
444
451
|
throw (0, import_utils.createCheckoutError)(
|
|
445
452
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
446
|
-
|
|
453
|
+
`\u8BA2\u5355\u6570\u636E\u9A8C\u8BC1\u5931\u8D25: ${validation.errors.join(", ")}`
|
|
447
454
|
);
|
|
448
455
|
}
|
|
449
456
|
const amountInfo = (0, import_utils.extractAmountFromCartSummary)(params.cartSummary);
|
|
@@ -507,11 +514,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
507
514
|
if (!updated)
|
|
508
515
|
throw (0, import_utils.createCheckoutError)(
|
|
509
516
|
import_types.CheckoutErrorType.UnknownError,
|
|
510
|
-
"
|
|
517
|
+
"\u8BA2\u5355\u66F4\u65B0\u5931\u8D25"
|
|
511
518
|
);
|
|
512
519
|
this.store.currentOrder = updated;
|
|
513
520
|
await this.updateStateAmountToRemaining(false);
|
|
514
|
-
this.logInfo("
|
|
521
|
+
this.logInfo("\u672C\u5730\u8BA2\u5355\u66F4\u65B0\u6210\u529F(\u4FDD\u7559\u652F\u4ED8\u9879):", {
|
|
515
522
|
orderId: params.orderId,
|
|
516
523
|
uuid: updated.uuid,
|
|
517
524
|
payments: ((_m = updated.payment) == null ? void 0 : _m.length) || 0,
|
|
@@ -571,7 +578,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
571
578
|
if (!this.store.currentOrder) {
|
|
572
579
|
throw (0, import_utils.createCheckoutError)(
|
|
573
580
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
574
|
-
"
|
|
581
|
+
"\u672A\u627E\u5230\u5F53\u524D\u8BA2\u5355"
|
|
575
582
|
);
|
|
576
583
|
}
|
|
577
584
|
const order = await this.payment.getPaymentOrderByUuidAsync(
|
|
@@ -580,7 +587,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
580
587
|
if (!order || order.payment_status !== import_types2.PaymentStatus.Finished) {
|
|
581
588
|
throw (0, import_utils.createCheckoutError)(
|
|
582
589
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
583
|
-
"
|
|
590
|
+
"\u8BA2\u5355\u652F\u4ED8\u672A\u5B8C\u6210\uFF0C\u65E0\u6CD5\u5B8C\u6210\u7ED3\u8D26"
|
|
584
591
|
);
|
|
585
592
|
}
|
|
586
593
|
this.payment.wallet.clearAllCache();
|
|
@@ -588,7 +595,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
588
595
|
orderId: order.id,
|
|
589
596
|
timestamp: Date.now()
|
|
590
597
|
});
|
|
591
|
-
console.log("[Checkout]
|
|
598
|
+
console.log("[Checkout] \u7ED3\u8D26\u6D41\u7A0B\u5B8C\u6210:", order.id);
|
|
592
599
|
await this.resetStoreStateAsync();
|
|
593
600
|
return {
|
|
594
601
|
success: true,
|
|
@@ -615,7 +622,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
615
622
|
try {
|
|
616
623
|
const { currentOrder, cartItems, localOrderData } = this.store;
|
|
617
624
|
if (!currentOrder) {
|
|
618
|
-
console.log("[Checkout]
|
|
625
|
+
console.log("[Checkout] \u5F53\u524D\u6CA1\u6709\u6D3B\u8DC3\u8BA2\u5355");
|
|
619
626
|
return null;
|
|
620
627
|
}
|
|
621
628
|
const orderInfo = currentOrder.order_info || {};
|
|
@@ -638,7 +645,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
638
645
|
};
|
|
639
646
|
return result;
|
|
640
647
|
} catch (error) {
|
|
641
|
-
console.error("[Checkout]
|
|
648
|
+
console.error("[Checkout] \u83B7\u53D6\u5F53\u524D\u8BA2\u5355\u57FA\u7840\u4FE1\u606F\u5931\u8D25:", error);
|
|
642
649
|
return null;
|
|
643
650
|
}
|
|
644
651
|
}
|
|
@@ -651,7 +658,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
651
658
|
try {
|
|
652
659
|
const { currentOrder } = this.store;
|
|
653
660
|
if (!currentOrder) {
|
|
654
|
-
console.log("[Checkout]
|
|
661
|
+
console.log("[Checkout] \u5F53\u524D\u6CA1\u6709\u6D3B\u8DC3\u8BA2\u5355\uFF0C\u65E0\u6CD5\u83B7\u53D6\u652F\u4ED8\u9879");
|
|
655
662
|
return [];
|
|
656
663
|
}
|
|
657
664
|
const paymentItems = await this.payment.getPaymentItemsAsync(
|
|
@@ -659,7 +666,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
659
666
|
);
|
|
660
667
|
return paymentItems;
|
|
661
668
|
} catch (error) {
|
|
662
|
-
console.error("[Checkout]
|
|
669
|
+
console.error("[Checkout] \u83B7\u53D6\u5F53\u524D\u8BA2\u5355\u652F\u4ED8\u9879\u5931\u8D25:", error);
|
|
663
670
|
return [];
|
|
664
671
|
}
|
|
665
672
|
}
|
|
@@ -686,7 +693,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
686
693
|
async replaceLocalOrderIdAsync(newOrderId) {
|
|
687
694
|
try {
|
|
688
695
|
if (!this.store.currentOrder) {
|
|
689
|
-
console.warn("[Checkout]
|
|
696
|
+
console.warn("[Checkout] \u6CA1\u6709\u5F53\u524D\u8BA2\u5355\uFF0C\u65E0\u6CD5\u66FF\u6362\u8BA2\u5355ID");
|
|
690
697
|
return null;
|
|
691
698
|
}
|
|
692
699
|
const updatedOrder = await this.payment.replaceOrderIdByUuidAsync(
|
|
@@ -699,7 +706,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
699
706
|
order: updatedOrder,
|
|
700
707
|
timestamp: Date.now()
|
|
701
708
|
});
|
|
702
|
-
console.log("[Checkout]
|
|
709
|
+
console.log("[Checkout] \u672C\u5730\u8BA2\u5355ID\u66FF\u6362\u6210\u529F:", {
|
|
703
710
|
uuid: updatedOrder.uuid,
|
|
704
711
|
newOrderId: updatedOrder.id
|
|
705
712
|
});
|
|
@@ -708,7 +715,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
708
715
|
}
|
|
709
716
|
return updatedOrder;
|
|
710
717
|
} catch (error) {
|
|
711
|
-
console.error("[Checkout]
|
|
718
|
+
console.error("[Checkout] \u66FF\u6362\u8BA2\u5355ID\u5931\u8D25:", error);
|
|
712
719
|
await this.handleError(error, import_types.CheckoutErrorType.UnknownError);
|
|
713
720
|
return null;
|
|
714
721
|
}
|
|
@@ -724,14 +731,14 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
724
731
|
try {
|
|
725
732
|
const numAmount = parseFloat(amount);
|
|
726
733
|
if (isNaN(numAmount) || numAmount < 0) {
|
|
727
|
-
throw new Error(
|
|
734
|
+
throw new Error(`\u65E0\u6548\u7684\u652F\u4ED8\u91D1\u989D: ${amount}`);
|
|
728
735
|
}
|
|
729
736
|
const oldAmount = this.store.stateAmount;
|
|
730
737
|
const formattedAmount = numAmount.toFixed(2);
|
|
731
738
|
if (oldAmount === formattedAmount) {
|
|
732
739
|
return;
|
|
733
740
|
}
|
|
734
|
-
this.logInfo("[Checkout]
|
|
741
|
+
this.logInfo("[Checkout] \u8BBE\u7F6E\u81EA\u5B9A\u4E49\u652F\u4ED8\u91D1\u989D:", {
|
|
735
742
|
oldAmount,
|
|
736
743
|
newAmount: formattedAmount
|
|
737
744
|
});
|
|
@@ -742,8 +749,8 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
742
749
|
timestamp: Date.now()
|
|
743
750
|
});
|
|
744
751
|
} catch (error) {
|
|
745
|
-
const errorMessage = error instanceof Error ? error.message : "
|
|
746
|
-
console.error("[Checkout]
|
|
752
|
+
const errorMessage = error instanceof Error ? error.message : "\u8BBE\u7F6E\u652F\u4ED8\u91D1\u989D\u5931\u8D25";
|
|
753
|
+
console.error("[Checkout] \u8BBE\u7F6E\u81EA\u5B9A\u4E49\u652F\u4ED8\u91D1\u989D\u5931\u8D25:", errorMessage);
|
|
747
754
|
await this.handleError(
|
|
748
755
|
new Error(errorMessage),
|
|
749
756
|
import_types.CheckoutErrorType.ValidationFailed
|
|
@@ -778,10 +785,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
778
785
|
*/
|
|
779
786
|
getCartSummary() {
|
|
780
787
|
if (!this.store.cartSummary || this.store.cartSummary.length === 0) {
|
|
781
|
-
console.warn("[Checkout]
|
|
788
|
+
console.warn("[Checkout] \u6CA1\u6709\u53EF\u7528\u7684\u8D2D\u7269\u8F66\u5C0F\u8BA1\u6570\u636E");
|
|
782
789
|
return null;
|
|
783
790
|
}
|
|
784
|
-
this.logInfo("
|
|
791
|
+
this.logInfo("\u83B7\u53D6\u8D2D\u7269\u8F66\u5C0F\u8BA1\u6570\u636E:", {
|
|
785
792
|
itemCount: this.store.cartSummary.length,
|
|
786
793
|
items: this.store.cartSummary.map((item) => ({
|
|
787
794
|
key: item.key,
|
|
@@ -802,20 +809,20 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
802
809
|
async getPaymentMethodsAsync() {
|
|
803
810
|
if (this.store.paymentMethods && this.store.paymentMethods.length > 0) {
|
|
804
811
|
this.logInfo(
|
|
805
|
-
|
|
812
|
+
`\u4F7F\u7528\u7F13\u5B58\u7684\u652F\u4ED8\u65B9\u5F0F\u6570\u636E\uFF0C\u5171 ${this.store.paymentMethods.length} \u79CD`
|
|
806
813
|
);
|
|
807
814
|
return this.store.paymentMethods;
|
|
808
815
|
}
|
|
809
|
-
this.logInfo("store
|
|
816
|
+
this.logInfo("store \u4E2D\u65E0\u7F13\u5B58\uFF0C\u4ECE Payment \u6A21\u5757\u83B7\u53D6\u652F\u4ED8\u65B9\u5F0F...");
|
|
810
817
|
try {
|
|
811
818
|
const methods = await this.payment.getPayMethodListAsync();
|
|
812
819
|
this.store.paymentMethods = methods;
|
|
813
820
|
this.logInfo(
|
|
814
|
-
|
|
821
|
+
`\u4ECE Payment \u6A21\u5757\u83B7\u53D6\u5230 ${methods.length} \u79CD\u652F\u4ED8\u65B9\u5F0F\uFF0C\u5DF2\u66F4\u65B0\u7F13\u5B58`
|
|
815
822
|
);
|
|
816
823
|
return methods;
|
|
817
824
|
} catch (error) {
|
|
818
|
-
this.logError("
|
|
825
|
+
this.logError("\u83B7\u53D6\u652F\u4ED8\u65B9\u5F0F\u5931\u8D25:", error);
|
|
819
826
|
return [];
|
|
820
827
|
}
|
|
821
828
|
}
|
|
@@ -834,7 +841,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
834
841
|
if (!this.store.currentOrder) {
|
|
835
842
|
throw (0, import_utils.createCheckoutError)(
|
|
836
843
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
837
|
-
"
|
|
844
|
+
"\u672A\u627E\u5230\u5F53\u524D\u8BA2\u5355\uFF0C\u65E0\u6CD5\u6DFB\u52A0\u652F\u4ED8\u9879"
|
|
838
845
|
);
|
|
839
846
|
}
|
|
840
847
|
const orderPaymentType = this.store.currentOrder.is_deposit === 1 ? "deposit" : "normal";
|
|
@@ -853,34 +860,34 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
853
860
|
this.store.currentOrder.uuid,
|
|
854
861
|
paymentItemWithType
|
|
855
862
|
);
|
|
856
|
-
this.logInfo("
|
|
863
|
+
this.logInfo("\u652F\u4ED8\u9879\u6DFB\u52A0\u6210\u529F");
|
|
857
864
|
await this.updateStateAmountToRemaining();
|
|
858
865
|
const remainingAmount = await this.calculateRemainingAmountAsync();
|
|
859
866
|
if (Number(remainingAmount) > 0) {
|
|
860
|
-
this.logInfo("
|
|
867
|
+
this.logInfo("\u8BA2\u5355\u91D1\u989D\u8FD8\u6709\u5F85\u4ED8\u7684\uFF0C\u540C\u6B65 EFTPOS \u652F\u4ED8");
|
|
861
868
|
const isEftposPayment = ((_a = paymentItem.type) == null ? void 0 : _a.toLowerCase()) === "eftpos" || ((_b = paymentItem.code) == null ? void 0 : _b.toUpperCase().includes("EFTPOS"));
|
|
862
869
|
const isCashPayment2 = paymentItem.code === "CASHMANUAL";
|
|
863
870
|
const isCustomePayment = paymentItem.type === "custom";
|
|
864
|
-
this.logInfo("EFTPOS
|
|
871
|
+
this.logInfo("EFTPOS \u652F\u4ED8\u68C0\u67E5:", {
|
|
865
872
|
paymentCode: paymentItem.code,
|
|
866
873
|
paymentType: paymentItem.type,
|
|
867
874
|
isEftposPayment,
|
|
868
875
|
currentOrderSynced: this.store.isOrderSynced
|
|
869
876
|
});
|
|
870
877
|
if (isEftposPayment || isCashPayment2 || isCustomePayment) {
|
|
871
|
-
this.logInfo("
|
|
878
|
+
this.logInfo("\u68C0\u6D4B\u5230 EFTPOS \u652F\u4ED8\uFF0C\u7ACB\u5373\u540C\u6B65\u8BA2\u5355\u5230\u540E\u7AEF...");
|
|
872
879
|
try {
|
|
873
880
|
const syncResult = await this.syncOrderToBackendWithReturn(true);
|
|
874
|
-
this.logInfo("EFTPOS
|
|
881
|
+
this.logInfo("EFTPOS \u652F\u4ED8\u540E\u8BA2\u5355\u540C\u6B65\u5B8C\u6210 (\u5DF2\u6807\u8BB0\u4E3A\u624B\u52A8\u540C\u6B65):", {
|
|
875
882
|
orderId: syncResult.orderId,
|
|
876
883
|
isOrderSynced: this.store.isOrderSynced,
|
|
877
884
|
backendResponse: syncResult.response
|
|
878
885
|
});
|
|
879
886
|
} catch (error) {
|
|
880
|
-
this.logError("EFTPOS
|
|
887
|
+
this.logError("EFTPOS \u652F\u4ED8\u540E\u8BA2\u5355\u540C\u6B65\u5931\u8D25:", error);
|
|
881
888
|
await this.handleError(
|
|
882
889
|
new Error(
|
|
883
|
-
`EFTPOS
|
|
890
|
+
`EFTPOS \u652F\u4ED8\u540E\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`
|
|
884
891
|
),
|
|
885
892
|
import_types.CheckoutErrorType.OrderCreationFailed
|
|
886
893
|
);
|
|
@@ -895,7 +902,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
895
902
|
timestamp: Date.now()
|
|
896
903
|
});
|
|
897
904
|
} catch (error) {
|
|
898
|
-
this.logError("
|
|
905
|
+
this.logError("\u6DFB\u52A0\u652F\u4ED8\u9879\u5931\u8D25:", error);
|
|
899
906
|
await this.handleError(error, import_types.CheckoutErrorType.PaymentFailed);
|
|
900
907
|
throw error;
|
|
901
908
|
}
|
|
@@ -914,10 +921,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
914
921
|
if (!this.store.currentOrder) {
|
|
915
922
|
throw (0, import_utils.createCheckoutError)(
|
|
916
923
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
917
|
-
"
|
|
924
|
+
"\u5F53\u524D\u6CA1\u6709\u6D3B\u8DC3\u8BA2\u5355\uFF0C\u65E0\u6CD5\u5220\u9664\u652F\u4ED8\u9879"
|
|
918
925
|
);
|
|
919
926
|
}
|
|
920
|
-
this.logWarning("
|
|
927
|
+
this.logWarning("\u5F00\u59CB\u5220\u9664\u652F\u4ED8\u9879:", {
|
|
921
928
|
orderUuid: this.store.currentOrder.uuid,
|
|
922
929
|
paymentUuid
|
|
923
930
|
});
|
|
@@ -930,10 +937,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
930
937
|
if (!paymentItem) {
|
|
931
938
|
throw (0, import_utils.createCheckoutError)(
|
|
932
939
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
933
|
-
|
|
940
|
+
`\u652F\u4ED8\u9879\u4E0D\u5B58\u5728: ${paymentUuid}`
|
|
934
941
|
);
|
|
935
942
|
}
|
|
936
|
-
this.logInfo("
|
|
943
|
+
this.logInfo("\u627E\u5230\u8981\u5220\u9664\u7684\u652F\u4ED8\u9879:", {
|
|
937
944
|
uuid: paymentItem.uuid,
|
|
938
945
|
code: paymentItem.code,
|
|
939
946
|
amount: paymentItem.amount,
|
|
@@ -943,7 +950,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
943
950
|
this.store.currentOrder.uuid,
|
|
944
951
|
paymentUuid
|
|
945
952
|
);
|
|
946
|
-
this.logInfo("Payment
|
|
953
|
+
this.logInfo("Payment\u652F\u4ED8\u9879\u5220\u9664\u5B8C\u6210", paymentItem);
|
|
947
954
|
const currentOrderId = this.store.currentOrder.order_id;
|
|
948
955
|
const isCurrentOrderReal = currentOrderId && !(0, import_utils.isVirtualOrderId)(currentOrderId);
|
|
949
956
|
const updatedOrder = await this.payment.getPaymentOrderByUuidAsync(
|
|
@@ -952,7 +959,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
952
959
|
if (updatedOrder) {
|
|
953
960
|
if (isCurrentOrderReal && (0, import_utils.isVirtualOrderId)(updatedOrder.order_id)) {
|
|
954
961
|
this.logWarning(
|
|
955
|
-
"[Checkout] deletePaymentItemAsync:
|
|
962
|
+
"[Checkout] deletePaymentItemAsync: \u68C0\u6D4B\u5230\u8BA2\u5355ID\u56DE\u9000\uFF0C\u4FDD\u62A4\u771F\u5B9E\u8BA2\u5355ID:",
|
|
956
963
|
{
|
|
957
964
|
currentRealId: currentOrderId,
|
|
958
965
|
retrievedVirtualId: updatedOrder.order_id
|
|
@@ -971,7 +978,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
971
978
|
timestamp: Date.now()
|
|
972
979
|
});
|
|
973
980
|
} catch (error) {
|
|
974
|
-
this.logError("
|
|
981
|
+
this.logError("\u5220\u9664\u652F\u4ED8\u9879\u5931\u8D25:", error);
|
|
975
982
|
await this.handleError(error, import_types.CheckoutErrorType.PaymentFailed);
|
|
976
983
|
throw error;
|
|
977
984
|
}
|
|
@@ -991,7 +998,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
991
998
|
if (!this.store.currentOrder) {
|
|
992
999
|
throw (0, import_utils.createCheckoutError)(
|
|
993
1000
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
994
|
-
"
|
|
1001
|
+
"\u5F53\u524D\u6CA1\u6709\u6D3B\u8DC3\u8BA2\u5355\uFF0C\u65E0\u6CD5\u66F4\u65B0\u4EE3\u91D1\u5238\u652F\u4ED8\u9879"
|
|
995
1002
|
);
|
|
996
1003
|
}
|
|
997
1004
|
const paymentItems = await this.payment.getPaymentItemsAsync(
|
|
@@ -1002,7 +1009,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1002
1009
|
const remainingValue = new import_decimal.default(remainingAmount);
|
|
1003
1010
|
const isOrderSynced = this.store.isOrderSynced;
|
|
1004
1011
|
if (remainingValue.lte(0) && isOrderSynced && voucherPaymentItems.length === 0 && allPaymentItemsSynced) {
|
|
1005
|
-
this.logInfo("
|
|
1012
|
+
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:", {
|
|
1006
1013
|
orderUuid: this.store.currentOrder.uuid,
|
|
1007
1014
|
orderId: this.store.currentOrder.order_id,
|
|
1008
1015
|
remainingAmount,
|
|
@@ -1012,7 +1019,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1012
1019
|
});
|
|
1013
1020
|
return;
|
|
1014
1021
|
}
|
|
1015
|
-
this.logInfo("
|
|
1022
|
+
this.logInfo("\u5F00\u59CB\u6279\u91CF\u66F4\u65B0\u4EE3\u91D1\u5238\u652F\u4ED8\u9879:", {
|
|
1016
1023
|
voucherPaymentItems
|
|
1017
1024
|
});
|
|
1018
1025
|
const orderPaymentType = this.store.currentOrder.is_deposit === 1 ? "deposit" : "normal";
|
|
@@ -1020,7 +1027,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1020
1027
|
if (!item.voucher_id) {
|
|
1021
1028
|
throw (0, import_utils.createCheckoutError)(
|
|
1022
1029
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
1023
|
-
|
|
1030
|
+
`\u4EE3\u91D1\u5238\u652F\u4ED8\u9879\u7F3A\u5C11 voucher_id: ${JSON.stringify(item)}`
|
|
1024
1031
|
);
|
|
1025
1032
|
}
|
|
1026
1033
|
const metadata = {
|
|
@@ -1046,7 +1053,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1046
1053
|
if (updatedOrder) {
|
|
1047
1054
|
if (isCurrentOrderReal && (0, import_utils.isVirtualOrderId)(updatedOrder.order_id)) {
|
|
1048
1055
|
this.logWarning(
|
|
1049
|
-
"updateVoucherPaymentItemsAsync:
|
|
1056
|
+
"updateVoucherPaymentItemsAsync: \u68C0\u6D4B\u5230\u8BA2\u5355ID\u56DE\u9000\uFF0C\u4FDD\u62A4\u771F\u5B9E\u8BA2\u5355ID:",
|
|
1050
1057
|
{
|
|
1051
1058
|
currentRealId: currentOrderId,
|
|
1052
1059
|
retrievedVirtualId: updatedOrder.order_id
|
|
@@ -1063,9 +1070,9 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1063
1070
|
amount: voucherPaymentItems.reduce((sum, item) => sum + parseFloat(String(item.amount)), 0).toFixed(2),
|
|
1064
1071
|
timestamp: Date.now()
|
|
1065
1072
|
});
|
|
1066
|
-
this.logInfo("
|
|
1073
|
+
this.logInfo("\u4EE3\u91D1\u5238\u652F\u4ED8\u9879\u6279\u91CF\u66F4\u65B0\u6210\u529F");
|
|
1067
1074
|
} catch (error) {
|
|
1068
|
-
this.logError("[Checkout]
|
|
1075
|
+
this.logError("[Checkout] \u6279\u91CF\u66F4\u65B0\u4EE3\u91D1\u5238\u652F\u4ED8\u9879\u5931\u8D25:", error);
|
|
1069
1076
|
await this.handleError(error, import_types.CheckoutErrorType.PaymentFailed);
|
|
1070
1077
|
throw error;
|
|
1071
1078
|
}
|
|
@@ -1083,19 +1090,19 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1083
1090
|
if (isDeposit !== 0 && isDeposit !== 1) {
|
|
1084
1091
|
throw (0, import_utils.createCheckoutError)(
|
|
1085
1092
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
1086
|
-
"isDeposit
|
|
1093
|
+
"isDeposit \u53C2\u6570\u53EA\u80FD\u662F 0\uFF08\u5168\u6B3E\u8BA2\u5355\uFF09\u6216 1\uFF08\u5B9A\u91D1\u8BA2\u5355\uFF09"
|
|
1087
1094
|
);
|
|
1088
1095
|
}
|
|
1089
1096
|
if (!this.store.currentOrder) {
|
|
1090
1097
|
throw (0, import_utils.createCheckoutError)(
|
|
1091
1098
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
1092
|
-
"
|
|
1099
|
+
"\u672A\u627E\u5230\u5F53\u524D\u8BA2\u5355\uFF0C\u65E0\u6CD5\u4FEE\u6539\u5B9A\u91D1\u72B6\u6001"
|
|
1093
1100
|
);
|
|
1094
1101
|
}
|
|
1095
1102
|
const newDepositValue = isDeposit;
|
|
1096
1103
|
const oldDepositValue = this.store.currentOrder.is_deposit;
|
|
1097
1104
|
if (oldDepositValue === newDepositValue) {
|
|
1098
|
-
console.log("[Checkout]
|
|
1105
|
+
console.log("[Checkout] \u5B9A\u91D1\u72B6\u6001\u65E0\u53D8\u5316\uFF0C\u8DF3\u8FC7\u66F4\u65B0");
|
|
1099
1106
|
return;
|
|
1100
1107
|
}
|
|
1101
1108
|
let deposit_amount = this.store.currentOrder.deposit_amount || "0.00";
|
|
@@ -1122,12 +1129,12 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1122
1129
|
order: this.store.currentOrder,
|
|
1123
1130
|
timestamp: Date.now()
|
|
1124
1131
|
});
|
|
1125
|
-
this.logInfo("
|
|
1132
|
+
this.logInfo("\u8BA2\u5355\u5B9A\u91D1\u72B6\u6001\u66F4\u65B0\u6210\u529F:", {
|
|
1126
1133
|
isDeposit: newDepositValue,
|
|
1127
1134
|
depositAmount: this.store.currentOrder.deposit_amount
|
|
1128
1135
|
});
|
|
1129
1136
|
} catch (error) {
|
|
1130
|
-
this.logError("
|
|
1137
|
+
this.logError("\u66F4\u65B0\u8BA2\u5355\u5B9A\u91D1\u72B6\u6001\u5931\u8D25:", error);
|
|
1131
1138
|
await this.handleError(
|
|
1132
1139
|
error,
|
|
1133
1140
|
import_types.CheckoutErrorType.ValidationFailed
|
|
@@ -1157,25 +1164,25 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1157
1164
|
if (depositValue.isNaN() || depositValue.lt(0)) {
|
|
1158
1165
|
throw (0, import_utils.createCheckoutError)(
|
|
1159
1166
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
1160
|
-
|
|
1167
|
+
`\u65E0\u6548\u7684\u5B9A\u91D1\u91D1\u989D\u683C\u5F0F: ${depositAmount}`
|
|
1161
1168
|
);
|
|
1162
1169
|
}
|
|
1163
1170
|
if (!this.store.currentOrder) {
|
|
1164
1171
|
throw (0, import_utils.createCheckoutError)(
|
|
1165
1172
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
1166
|
-
"
|
|
1173
|
+
"\u672A\u627E\u5230\u5F53\u524D\u8BA2\u5355\uFF0C\u65E0\u6CD5\u8BBE\u7F6E\u5B9A\u91D1\u91D1\u989D"
|
|
1167
1174
|
);
|
|
1168
1175
|
}
|
|
1169
1176
|
const formattedDepositAmount = depositValue.toFixed(2);
|
|
1170
1177
|
const oldDepositAmount = this.store.currentOrder.deposit_amount || "0.00";
|
|
1171
1178
|
if (formattedDepositAmount === oldDepositAmount) {
|
|
1172
|
-
this.logInfo("
|
|
1179
|
+
this.logInfo("\u5B9A\u91D1\u91D1\u989D\u65E0\u53D8\u5316\uFF0C\u8DF3\u8FC7\u66F4\u65B0:", {
|
|
1173
1180
|
currentAmount: oldDepositAmount,
|
|
1174
1181
|
newAmount: formattedDepositAmount
|
|
1175
1182
|
});
|
|
1176
1183
|
return;
|
|
1177
1184
|
}
|
|
1178
|
-
this.logInfo("
|
|
1185
|
+
this.logInfo("\u5F00\u59CB\u8BBE\u7F6E\u8BA2\u5355\u5B9A\u91D1\u91D1\u989D:", {
|
|
1179
1186
|
orderUuid: this.store.currentOrder.uuid,
|
|
1180
1187
|
orderId: this.store.currentOrder.order_id,
|
|
1181
1188
|
oldDepositAmount,
|
|
@@ -1187,10 +1194,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1187
1194
|
};
|
|
1188
1195
|
if (depositValue.gt(0) && this.store.currentOrder.is_deposit !== 1) {
|
|
1189
1196
|
updateParams.is_deposit = 1;
|
|
1190
|
-
this.logInfo("
|
|
1197
|
+
this.logInfo("\u5B9A\u91D1\u91D1\u989D\u5927\u4E8E0\uFF0C\u81EA\u52A8\u8BBE\u7F6E\u4E3A\u5B9A\u91D1\u8BA2\u5355");
|
|
1191
1198
|
} else if (depositValue.eq(0) && this.store.currentOrder.is_deposit === 1) {
|
|
1192
1199
|
updateParams.is_deposit = 0;
|
|
1193
|
-
this.logInfo("
|
|
1200
|
+
this.logInfo("\u5B9A\u91D1\u91D1\u989D\u4E3A0\uFF0C\u81EA\u52A8\u8BBE\u7F6E\u4E3A\u5168\u6B3E\u8BA2\u5355");
|
|
1194
1201
|
}
|
|
1195
1202
|
await this.payment.updateOrderAsync(
|
|
1196
1203
|
this.store.currentOrder.uuid,
|
|
@@ -1213,7 +1220,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1213
1220
|
order: this.store.currentOrder,
|
|
1214
1221
|
timestamp: Date.now()
|
|
1215
1222
|
});
|
|
1216
|
-
this.logInfo("
|
|
1223
|
+
this.logInfo("\u8BA2\u5355\u5B9A\u91D1\u91D1\u989D\u8BBE\u7F6E\u6210\u529F:", {
|
|
1217
1224
|
orderUuid: this.store.currentOrder.uuid,
|
|
1218
1225
|
orderId: this.store.currentOrder.order_id,
|
|
1219
1226
|
oldDepositAmount,
|
|
@@ -1222,7 +1229,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1222
1229
|
totalAmount: this.store.currentOrder.total_amount
|
|
1223
1230
|
});
|
|
1224
1231
|
} catch (error) {
|
|
1225
|
-
this.logError("
|
|
1232
|
+
this.logError("\u8BBE\u7F6E\u8BA2\u5355\u5B9A\u91D1\u91D1\u989D\u5931\u8D25:", error);
|
|
1226
1233
|
await this.handleError(
|
|
1227
1234
|
error,
|
|
1228
1235
|
import_types.CheckoutErrorType.ValidationFailed
|
|
@@ -1249,22 +1256,22 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1249
1256
|
if (!this.store.currentOrder) {
|
|
1250
1257
|
return {
|
|
1251
1258
|
success: false,
|
|
1252
|
-
message: "
|
|
1259
|
+
message: "\u5F53\u524D\u6CA1\u6709\u6D3B\u8DC3\u8BA2\u5355\uFF0C\u65E0\u6CD5\u540C\u6B65"
|
|
1253
1260
|
};
|
|
1254
1261
|
}
|
|
1255
1262
|
const orderUuid = this.store.currentOrder.uuid;
|
|
1256
1263
|
const oldOrderId = this.store.currentOrder.order_id;
|
|
1257
1264
|
if (this.store.isOrderSynced) {
|
|
1258
|
-
this.logInfo("
|
|
1265
|
+
this.logInfo("\u8BA2\u5355\u5DF2\u540C\u6B65\u8FC7\uFF0C\u5C06\u6267\u884C\u66F4\u65B0\u64CD\u4F5C");
|
|
1259
1266
|
}
|
|
1260
|
-
this.logInfo("
|
|
1267
|
+
this.logInfo("\u5F00\u59CB\u624B\u52A8\u540C\u6B65\u8BA2\u5355\u5230\u540E\u7AEF:", {
|
|
1261
1268
|
orderUuid,
|
|
1262
1269
|
orderId: oldOrderId,
|
|
1263
1270
|
totalAmount: this.store.currentOrder.total_amount,
|
|
1264
1271
|
remainingAmount: await this.calculateRemainingAmountAsync()
|
|
1265
1272
|
});
|
|
1266
1273
|
const syncResult = await this.syncOrderToBackendWithReturn(true);
|
|
1267
|
-
this.logInfo("
|
|
1274
|
+
this.logInfo("\u624B\u52A8\u540C\u6B65\u8BA2\u5355\u5B8C\u6210:", {
|
|
1268
1275
|
orderUuid,
|
|
1269
1276
|
syncResult,
|
|
1270
1277
|
oldOrderId,
|
|
@@ -1274,11 +1281,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1274
1281
|
const finalOrderId = this.store.currentOrder.order_id;
|
|
1275
1282
|
const finalIsVirtual = (0, import_utils.isVirtualOrderId)(finalOrderId);
|
|
1276
1283
|
if (finalIsVirtual) {
|
|
1277
|
-
this.logError("
|
|
1284
|
+
this.logError("\u4E25\u91CD\u8B66\u544A\uFF1A\u624B\u52A8\u540C\u6B65\u5B8C\u6210\u540E\u8BA2\u5355ID\u4ECD\u4E3A\u865A\u62DFID\uFF01");
|
|
1278
1285
|
}
|
|
1279
1286
|
if (syncResult.orderId !== finalOrderId) {
|
|
1280
1287
|
this.logError(
|
|
1281
|
-
"[Checkout]
|
|
1288
|
+
"[Checkout] \u4E25\u91CD\u8B66\u544A\uFF1A\u8FD4\u56DE\u7684\u8BA2\u5355ID\u4E0E\u5B58\u50A8\u7684\u8BA2\u5355ID\u4E0D\u4E00\u81F4\uFF01"
|
|
1282
1289
|
);
|
|
1283
1290
|
}
|
|
1284
1291
|
let newRes = {
|
|
@@ -1288,11 +1295,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1288
1295
|
await this.updateStateAmountToRemaining(false);
|
|
1289
1296
|
return newRes;
|
|
1290
1297
|
} catch (error) {
|
|
1291
|
-
this.logError("
|
|
1292
|
-
const errorMessage = error instanceof Error ? error.message : "
|
|
1298
|
+
this.logError("\u624B\u52A8\u540C\u6B65\u8BA2\u5355\u5931\u8D25:", error);
|
|
1299
|
+
const errorMessage = error instanceof Error ? error.message : "\u540C\u6B65\u5931\u8D25";
|
|
1293
1300
|
return {
|
|
1294
1301
|
success: false,
|
|
1295
|
-
message:
|
|
1302
|
+
message: `\u8BA2\u5355\u540C\u6B65\u5931\u8D25: ${errorMessage}`,
|
|
1296
1303
|
orderUuid: (_e = this.store.currentOrder) == null ? void 0 : _e.uuid
|
|
1297
1304
|
};
|
|
1298
1305
|
}
|
|
@@ -1304,7 +1311,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1304
1311
|
*/
|
|
1305
1312
|
getOrderNote() {
|
|
1306
1313
|
if (!this.store.localOrderData) {
|
|
1307
|
-
console.log("[Checkout]
|
|
1314
|
+
console.log("[Checkout] \u6CA1\u6709\u672C\u5730\u8BA2\u5355\u6570\u636E\uFF0C\u65E0\u6CD5\u83B7\u53D6\u5907\u6CE8");
|
|
1308
1315
|
return "";
|
|
1309
1316
|
}
|
|
1310
1317
|
return this.store.localOrderData.shop_note || "";
|
|
@@ -1327,11 +1334,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1327
1334
|
*/
|
|
1328
1335
|
isCurrentOrderSynced() {
|
|
1329
1336
|
if (!this.store.currentOrder) {
|
|
1330
|
-
console.log("[Checkout]
|
|
1337
|
+
console.log("[Checkout] \u6CA1\u6709\u5F53\u524D\u8BA2\u5355\uFF0C\u540C\u6B65\u72B6\u6001\u4E3Afalse");
|
|
1331
1338
|
return false;
|
|
1332
1339
|
}
|
|
1333
1340
|
const syncStatus = this.store.isOrderSynced;
|
|
1334
|
-
console.log("[Checkout]
|
|
1341
|
+
console.log("[Checkout] \u5F53\u524D\u8BA2\u5355\u540C\u6B65\u72B6\u6001:", {
|
|
1335
1342
|
orderUuid: this.store.currentOrder.uuid,
|
|
1336
1343
|
orderId: this.store.currentOrder.order_id,
|
|
1337
1344
|
isOrderSynced: syncStatus
|
|
@@ -1349,7 +1356,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1349
1356
|
async cancelCurrentOrderAsync(cancelReason) {
|
|
1350
1357
|
var _a, _b;
|
|
1351
1358
|
try {
|
|
1352
|
-
this.logInfo("
|
|
1359
|
+
this.logInfo("\u5F00\u59CB\u53D6\u6D88\u5F53\u524D\u672C\u5730\u8BA2\u5355:", {
|
|
1353
1360
|
hasCurrentOrder: !!this.store.currentOrder,
|
|
1354
1361
|
orderUuid: (_a = this.store.currentOrder) == null ? void 0 : _a.uuid,
|
|
1355
1362
|
orderId: (_b = this.store.currentOrder) == null ? void 0 : _b.order_id,
|
|
@@ -1357,34 +1364,34 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1357
1364
|
cancelReason
|
|
1358
1365
|
});
|
|
1359
1366
|
if (!this.store.currentOrder) {
|
|
1360
|
-
this.logInfo("
|
|
1367
|
+
this.logInfo("\u6CA1\u6709\u5F53\u524D\u8BA2\u5355\uFF0C\u65E0\u9700\u53D6\u6D88");
|
|
1361
1368
|
return {
|
|
1362
1369
|
success: false,
|
|
1363
|
-
message: "
|
|
1370
|
+
message: "\u6CA1\u6709\u5F53\u524D\u8BA2\u5355\u53EF\u53D6\u6D88"
|
|
1364
1371
|
};
|
|
1365
1372
|
}
|
|
1366
1373
|
const currentOrderUuid = this.store.currentOrder.uuid;
|
|
1367
1374
|
const currentOrderId = this.store.currentOrder.order_id;
|
|
1368
1375
|
const isOrderSynced = this.store.isOrderSynced;
|
|
1369
1376
|
if (isOrderSynced) {
|
|
1370
|
-
this.logInfo("
|
|
1377
|
+
this.logInfo("\u8BA2\u5355\u5DF2\u540C\u6B65\u5230\u540E\u7AEF\uFF0C\u4E0D\u80FD\u53D6\u6D88:", {
|
|
1371
1378
|
orderId: currentOrderId,
|
|
1372
1379
|
orderUuid: currentOrderUuid
|
|
1373
1380
|
});
|
|
1374
1381
|
return {
|
|
1375
1382
|
success: false,
|
|
1376
|
-
message: "
|
|
1383
|
+
message: "\u8BA2\u5355\u5DF2\u540C\u6B65\u5230\u540E\u7AEF\uFF0C\u65E0\u6CD5\u53D6\u6D88",
|
|
1377
1384
|
orderId: currentOrderId
|
|
1378
1385
|
};
|
|
1379
1386
|
}
|
|
1380
1387
|
try {
|
|
1381
|
-
this.logInfo("
|
|
1388
|
+
this.logInfo("\u5220\u9664\u672C\u5730\u8BA2\u5355\u6570\u636E");
|
|
1382
1389
|
await this.payment.deletePaymentOrderAsync(currentOrderUuid);
|
|
1383
|
-
this.logInfo("
|
|
1390
|
+
this.logInfo("\u672C\u5730\u8BA2\u5355\u6570\u636E\u5220\u9664\u6210\u529F");
|
|
1384
1391
|
} catch (error) {
|
|
1385
|
-
this.logWarning("
|
|
1392
|
+
this.logWarning("\u5220\u9664\u672C\u5730\u8BA2\u5355\u6570\u636E\u5931\u8D25\uFF0C\u4F46\u7EE7\u7EED\u6267\u884C:", error);
|
|
1386
1393
|
}
|
|
1387
|
-
this.logInfo("
|
|
1394
|
+
this.logInfo("\u6E05\u7406\u8BA2\u5355\u76F8\u5173\u72B6\u6001");
|
|
1388
1395
|
this.store.currentOrder = void 0;
|
|
1389
1396
|
this.store.localOrderData = void 0;
|
|
1390
1397
|
this.store.stateAmount = "0.00";
|
|
@@ -1392,7 +1399,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1392
1399
|
this.store.isOrderSynced = false;
|
|
1393
1400
|
this.store.currentCustomer = void 0;
|
|
1394
1401
|
this.payment.wallet.clearAllCache();
|
|
1395
|
-
this.logInfo("
|
|
1402
|
+
this.logInfo("\u8BA2\u5355\u72B6\u6001\u6E05\u7406\u5B8C\u6210\uFF0CcurrentOrder\u5DF2\u91CA\u653E");
|
|
1396
1403
|
await this.core.effects.emit(import_types.CheckoutHooks.OnOrderCancelled, {
|
|
1397
1404
|
orderUuid: currentOrderUuid,
|
|
1398
1405
|
orderId: currentOrderId,
|
|
@@ -1401,22 +1408,22 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1401
1408
|
// 只有未同步订单可以被取消
|
|
1402
1409
|
timestamp: Date.now()
|
|
1403
1410
|
});
|
|
1404
|
-
this.logInfo("
|
|
1411
|
+
this.logInfo("\u672C\u5730\u8BA2\u5355\u53D6\u6D88\u5B8C\u6210:", {
|
|
1405
1412
|
orderUuid: currentOrderUuid,
|
|
1406
1413
|
orderId: currentOrderId,
|
|
1407
1414
|
cancelReason
|
|
1408
1415
|
});
|
|
1409
1416
|
return {
|
|
1410
1417
|
success: true,
|
|
1411
|
-
message: "
|
|
1418
|
+
message: "\u672C\u5730\u8BA2\u5355\u5DF2\u6210\u529F\u53D6\u6D88",
|
|
1412
1419
|
orderId: currentOrderId
|
|
1413
1420
|
};
|
|
1414
1421
|
} catch (error) {
|
|
1415
|
-
this.logError("
|
|
1416
|
-
const errorMessage = error instanceof Error ? error.message : "
|
|
1422
|
+
this.logError("\u53D6\u6D88\u672C\u5730\u8BA2\u5355\u5931\u8D25:", error);
|
|
1423
|
+
const errorMessage = error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF";
|
|
1417
1424
|
return {
|
|
1418
1425
|
success: false,
|
|
1419
|
-
message:
|
|
1426
|
+
message: `\u53D6\u6D88\u8BA2\u5355\u5931\u8D25: ${errorMessage}`
|
|
1420
1427
|
};
|
|
1421
1428
|
}
|
|
1422
1429
|
}
|
|
@@ -1432,12 +1439,12 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1432
1439
|
if (!this.store.currentOrder) {
|
|
1433
1440
|
return {
|
|
1434
1441
|
success: false,
|
|
1435
|
-
message: "
|
|
1442
|
+
message: "\u5F53\u524D\u6CA1\u6709\u6D3B\u8DC3\u8BA2\u5355\uFF0C\u65E0\u6CD5\u4FDD\u5B58"
|
|
1436
1443
|
};
|
|
1437
1444
|
}
|
|
1438
1445
|
const orderUuid = this.store.currentOrder.uuid;
|
|
1439
1446
|
const currentOrderId = this.store.currentOrder.order_id;
|
|
1440
|
-
this.logInfo("
|
|
1447
|
+
this.logInfo("\u5F00\u59CB\u4FDD\u5B58\u8BA2\u5355\u5E76\u7A0D\u540E\u652F\u4ED8:", {
|
|
1441
1448
|
orderUuid,
|
|
1442
1449
|
orderId: currentOrderId,
|
|
1443
1450
|
totalAmount: this.store.currentOrder.total_amount
|
|
@@ -1449,7 +1456,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1449
1456
|
true,
|
|
1450
1457
|
allPaymentItems
|
|
1451
1458
|
);
|
|
1452
|
-
this.logInfo("
|
|
1459
|
+
this.logInfo("\u4FDD\u5B58\u8BA2\u5355\u5B8C\u6210:", {
|
|
1453
1460
|
orderUuid,
|
|
1454
1461
|
oldOrderId: currentOrderId,
|
|
1455
1462
|
syncResult,
|
|
@@ -1459,17 +1466,17 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1459
1466
|
});
|
|
1460
1467
|
return {
|
|
1461
1468
|
success: true,
|
|
1462
|
-
message: "
|
|
1469
|
+
message: "\u8BA2\u5355\u4FDD\u5B58\u6210\u529F\uFF0C\u53EF\u7A0D\u540E\u7EE7\u7EED\u652F\u4ED8",
|
|
1463
1470
|
orderId: syncResult.orderId,
|
|
1464
1471
|
orderUuid,
|
|
1465
1472
|
response: syncResult.response
|
|
1466
1473
|
};
|
|
1467
1474
|
} catch (error) {
|
|
1468
|
-
this.logError("
|
|
1469
|
-
const errorMessage = error instanceof Error ? error.message : "
|
|
1475
|
+
this.logError("\u4FDD\u5B58\u8BA2\u5355\u5931\u8D25:", error);
|
|
1476
|
+
const errorMessage = error instanceof Error ? error.message : "\u4FDD\u5B58\u5931\u8D25";
|
|
1470
1477
|
return {
|
|
1471
1478
|
success: false,
|
|
1472
|
-
message:
|
|
1479
|
+
message: `\u8BA2\u5355\u4FDD\u5B58\u5931\u8D25: ${errorMessage}`,
|
|
1473
1480
|
orderUuid: (_a = this.store.currentOrder) == null ? void 0 : _a.uuid
|
|
1474
1481
|
};
|
|
1475
1482
|
}
|
|
@@ -1485,10 +1492,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1485
1492
|
if (!this.store.localOrderData) {
|
|
1486
1493
|
throw (0, import_utils.createCheckoutError)(
|
|
1487
1494
|
import_types.CheckoutErrorType.ValidationFailed,
|
|
1488
|
-
"
|
|
1495
|
+
"\u6CA1\u6709\u672C\u5730\u8BA2\u5355\u6570\u636E\uFF0C\u65E0\u6CD5\u66F4\u65B0\u5907\u6CE8"
|
|
1489
1496
|
);
|
|
1490
1497
|
}
|
|
1491
|
-
console.log("[Checkout]
|
|
1498
|
+
console.log("[Checkout] \u66F4\u65B0\u8BA2\u5355\u5907\u6CE8:", {
|
|
1492
1499
|
orderUuid: (_a = this.store.currentOrder) == null ? void 0 : _a.uuid,
|
|
1493
1500
|
oldNote: this.store.localOrderData.shop_note,
|
|
1494
1501
|
newNote: note
|
|
@@ -1501,11 +1508,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1501
1508
|
this.store.currentOrder.uuid
|
|
1502
1509
|
);
|
|
1503
1510
|
if (orderInPayment && orderInPayment.note !== void 0) {
|
|
1504
|
-
console.log("[Checkout]
|
|
1511
|
+
console.log("[Checkout] \u540C\u6B65\u5907\u6CE8\u5230Payment\u6A21\u5757\u7684\u8BA2\u5355\u6570\u636E\u4E2D");
|
|
1505
1512
|
}
|
|
1506
1513
|
} catch (syncError) {
|
|
1507
1514
|
console.warn(
|
|
1508
|
-
"[Checkout]
|
|
1515
|
+
"[Checkout] \u540C\u6B65\u5907\u6CE8\u5230Payment\u6A21\u5757\u5931\u8D25\uFF0C\u4F46\u672C\u5730\u66F4\u65B0\u6210\u529F:",
|
|
1509
1516
|
syncError
|
|
1510
1517
|
);
|
|
1511
1518
|
}
|
|
@@ -1516,12 +1523,12 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1516
1523
|
newNote: note,
|
|
1517
1524
|
timestamp: Date.now()
|
|
1518
1525
|
});
|
|
1519
|
-
console.log("[Checkout]
|
|
1526
|
+
console.log("[Checkout] \u8BA2\u5355\u5907\u6CE8\u66F4\u65B0\u6210\u529F:", {
|
|
1520
1527
|
oldNote,
|
|
1521
1528
|
newNote: note
|
|
1522
1529
|
});
|
|
1523
1530
|
} catch (error) {
|
|
1524
|
-
console.error("[Checkout]
|
|
1531
|
+
console.error("[Checkout] \u66F4\u65B0\u8BA2\u5355\u5907\u6CE8\u5931\u8D25:", error);
|
|
1525
1532
|
await this.handleError(
|
|
1526
1533
|
error,
|
|
1527
1534
|
import_types.CheckoutErrorType.ValidationFailed
|
|
@@ -1540,7 +1547,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1540
1547
|
context: {},
|
|
1541
1548
|
timestamp: Date.now()
|
|
1542
1549
|
});
|
|
1543
|
-
console.error("[Checkout]
|
|
1550
|
+
console.error("[Checkout] \u9519\u8BEF:", checkoutError);
|
|
1544
1551
|
}
|
|
1545
1552
|
/**
|
|
1546
1553
|
* 处理支付成功
|
|
@@ -1563,7 +1570,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1563
1570
|
var _a;
|
|
1564
1571
|
const error = (0, import_utils.createCheckoutError)(
|
|
1565
1572
|
import_types.CheckoutErrorType.PaymentFailed,
|
|
1566
|
-
data.error || "
|
|
1573
|
+
data.error || "\u652F\u4ED8\u540C\u6B65\u5931\u8D25"
|
|
1567
1574
|
);
|
|
1568
1575
|
await this.handleError(
|
|
1569
1576
|
error instanceof Error ? error : new Error(String(error)),
|
|
@@ -1637,7 +1644,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1637
1644
|
});
|
|
1638
1645
|
return processedPaymentItem;
|
|
1639
1646
|
} catch (error) {
|
|
1640
|
-
this.logError("
|
|
1647
|
+
this.logError("\u5904\u7406\u73B0\u91D1\u652F\u4ED8\u9879\u65F6\u51FA\u9519:", error);
|
|
1641
1648
|
return paymentItem;
|
|
1642
1649
|
}
|
|
1643
1650
|
}
|
|
@@ -1646,12 +1653,12 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1646
1653
|
*/
|
|
1647
1654
|
async preloadPaymentMethods() {
|
|
1648
1655
|
try {
|
|
1649
|
-
console.log("[Checkout]
|
|
1656
|
+
console.log("[Checkout] \u9884\u52A0\u8F7D\u652F\u4ED8\u65B9\u5F0F...");
|
|
1650
1657
|
const methods = await this.payment.getPayMethodListAsync();
|
|
1651
1658
|
this.store.paymentMethods = methods;
|
|
1652
|
-
console.log(`[Checkout]
|
|
1659
|
+
console.log(`[Checkout] \u9884\u52A0\u8F7D\u5B8C\u6210\uFF0C\u5171 ${methods.length} \u79CD\u652F\u4ED8\u65B9\u5F0F`);
|
|
1653
1660
|
} catch (error) {
|
|
1654
|
-
console.error("[Checkout]
|
|
1661
|
+
console.error("[Checkout] \u9884\u52A0\u8F7D\u652F\u4ED8\u65B9\u5F0F\u5931\u8D25:", error);
|
|
1655
1662
|
this.store.paymentMethods = [];
|
|
1656
1663
|
}
|
|
1657
1664
|
}
|
|
@@ -1668,15 +1675,15 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1668
1675
|
const retentionDays = cleanupConfig.retentionDays || 7;
|
|
1669
1676
|
const maxOrdersToDelete = cleanupConfig.maxOrdersToDelete || 100;
|
|
1670
1677
|
if (!isCleanupEnabled) {
|
|
1671
|
-
console.log("[Checkout]
|
|
1678
|
+
console.log("[Checkout] \u8BA2\u5355\u6570\u636E\u6E05\u7406\u529F\u80FD\u5DF2\u7981\u7528");
|
|
1672
1679
|
return;
|
|
1673
1680
|
}
|
|
1674
1681
|
console.log(
|
|
1675
|
-
`[Checkout]
|
|
1682
|
+
`[Checkout] \u5F00\u59CB\u6E05\u7406\u8FC7\u671F\u8BA2\u5355\u6570\u636E\uFF08\u4FDD\u7559 ${retentionDays} \u5929\u5185\u7684\u6570\u636E\uFF09...`
|
|
1676
1683
|
);
|
|
1677
1684
|
const allOrders = await this.payment.getOrderListAsync();
|
|
1678
1685
|
if (!allOrders || allOrders.length === 0) {
|
|
1679
|
-
console.log("[Checkout]
|
|
1686
|
+
console.log("[Checkout] \u6CA1\u6709\u627E\u5230\u9700\u8981\u6E05\u7406\u7684\u8BA2\u5355\u6570\u636E");
|
|
1680
1687
|
return;
|
|
1681
1688
|
}
|
|
1682
1689
|
const thresholdDate = /* @__PURE__ */ new Date();
|
|
@@ -1711,7 +1718,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1711
1718
|
});
|
|
1712
1719
|
}
|
|
1713
1720
|
} catch (error) {
|
|
1714
|
-
console.warn(`[Checkout]
|
|
1721
|
+
console.warn(`[Checkout] \u5904\u7406\u8BA2\u5355 ${order.uuid} \u65F6\u51FA\u9519:`, error);
|
|
1715
1722
|
continue;
|
|
1716
1723
|
}
|
|
1717
1724
|
}
|
|
@@ -1724,10 +1731,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1724
1731
|
await this.payment.deletePaymentOrderAsync(orderInfo.uuid);
|
|
1725
1732
|
deletedCount++;
|
|
1726
1733
|
console.log(
|
|
1727
|
-
`[Checkout]
|
|
1734
|
+
`[Checkout] \u5DF2\u5220\u9664\u8FC7\u671F\u8BA2\u5355: ${orderInfo.orderId} (${orderInfo.daysSinceCreated} \u5929\u524D\u521B\u5EFA)`
|
|
1728
1735
|
);
|
|
1729
1736
|
} catch (error) {
|
|
1730
|
-
console.error(`[Checkout]
|
|
1737
|
+
console.error(`[Checkout] \u5220\u9664\u8BA2\u5355 ${orderInfo.uuid} \u5931\u8D25:`, error);
|
|
1731
1738
|
}
|
|
1732
1739
|
}
|
|
1733
1740
|
const summary = {
|
|
@@ -1743,16 +1750,16 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1743
1750
|
this.logInfo("Expired orders cleanup completed", summary);
|
|
1744
1751
|
if (ordersToDelete.length > maxOrdersToDelete) {
|
|
1745
1752
|
console.log(
|
|
1746
|
-
`[Checkout]
|
|
1753
|
+
`[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`
|
|
1747
1754
|
);
|
|
1748
1755
|
} else {
|
|
1749
1756
|
console.log(
|
|
1750
|
-
`[Checkout]
|
|
1757
|
+
`[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`
|
|
1751
1758
|
);
|
|
1752
1759
|
}
|
|
1753
1760
|
} catch (error) {
|
|
1754
1761
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1755
|
-
console.error("[Checkout]
|
|
1762
|
+
console.error("[Checkout] \u6E05\u7406\u8FC7\u671F\u8BA2\u5355\u6570\u636E\u5931\u8D25:", error);
|
|
1756
1763
|
this.logError("Expired orders cleanup failed", { error: errorMessage });
|
|
1757
1764
|
}
|
|
1758
1765
|
}
|
|
@@ -1761,7 +1768,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1761
1768
|
*/
|
|
1762
1769
|
async calculatePaidAmountAsync() {
|
|
1763
1770
|
if (!this.store.currentOrder) {
|
|
1764
|
-
this.logWarning("[Checkout] calculatePaidAmountAsync:
|
|
1771
|
+
this.logWarning("[Checkout] calculatePaidAmountAsync: \u6CA1\u6709\u5F53\u524D\u8BA2\u5355");
|
|
1765
1772
|
return "0.00";
|
|
1766
1773
|
}
|
|
1767
1774
|
try {
|
|
@@ -1774,11 +1781,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1774
1781
|
const amount = new import_decimal.default(payment.amount || "0");
|
|
1775
1782
|
const roundingAmount = new import_decimal.default(payment.rounding_amount || "0");
|
|
1776
1783
|
const effectiveAmount = amount.add(roundingAmount.isNegative() ? roundingAmount.abs() : 0);
|
|
1777
|
-
console.log(`[Checkout]
|
|
1784
|
+
console.log(`[Checkout] \u8BA1\u7B97\u652F\u4ED8\u9879: ${payment.code}`, {
|
|
1778
1785
|
originalAmount: amount.toFixed(2),
|
|
1779
1786
|
roundingAmount: roundingAmount.toFixed(2),
|
|
1780
1787
|
effectiveAmount: effectiveAmount.toFixed(2),
|
|
1781
|
-
description: !roundingAmount.isZero() ?
|
|
1788
|
+
description: !roundingAmount.isZero() ? `\u62B9\u96F6\u91D1\u989D ${roundingAmount.toFixed(2)} \u5143\uFF0C\u6709\u6548\u652F\u4ED8\u589E\u52A0 ${roundingAmount.abs().toFixed(2)} \u5143` : "\u65E0\u62B9\u96F6",
|
|
1782
1789
|
// Decimal 精度验证
|
|
1783
1790
|
preciseCalculationValues: {
|
|
1784
1791
|
amount: amount.toString(),
|
|
@@ -1789,10 +1796,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1789
1796
|
return sum.add(effectiveAmount);
|
|
1790
1797
|
}, new import_decimal.default(0));
|
|
1791
1798
|
const result = paidAmount.toFixed(2);
|
|
1792
|
-
this.logInfo("calculatePaidAmountAsync:
|
|
1799
|
+
this.logInfo("calculatePaidAmountAsync: \u8BA1\u7B97\u7ED3\u679C =", result);
|
|
1793
1800
|
return result;
|
|
1794
1801
|
} catch (error) {
|
|
1795
|
-
this.logError("calculatePaidAmountAsync
|
|
1802
|
+
this.logError("calculatePaidAmountAsync \u5931\u8D25:", error);
|
|
1796
1803
|
return "0.00";
|
|
1797
1804
|
}
|
|
1798
1805
|
}
|
|
@@ -1801,7 +1808,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1801
1808
|
*/
|
|
1802
1809
|
async calculateRemainingAmountAsync() {
|
|
1803
1810
|
if (!this.store.currentOrder) {
|
|
1804
|
-
this.logWarning("calculateRemainingAmountAsync:
|
|
1811
|
+
this.logWarning("calculateRemainingAmountAsync: \u6CA1\u6709\u5F53\u524D\u8BA2\u5355");
|
|
1805
1812
|
return "0.00";
|
|
1806
1813
|
}
|
|
1807
1814
|
let totalAmount = new import_decimal.default(this.store.currentOrder.total_amount || "0");
|
|
@@ -1815,7 +1822,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1815
1822
|
const paidAmount = new import_decimal.default(paidAmountStr);
|
|
1816
1823
|
const remainingAmount = totalAmount.sub(paidAmount);
|
|
1817
1824
|
const result = import_decimal.default.max(0, remainingAmount).toFixed(2);
|
|
1818
|
-
this.logInfo("calculateRemainingAmountAsync:
|
|
1825
|
+
this.logInfo("calculateRemainingAmountAsync: \u8BA1\u7B97=", result);
|
|
1819
1826
|
return result;
|
|
1820
1827
|
}
|
|
1821
1828
|
/**
|
|
@@ -1823,7 +1830,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1823
1830
|
*/
|
|
1824
1831
|
async calculateRemainingTotalAmountAsync() {
|
|
1825
1832
|
if (!this.store.currentOrder) {
|
|
1826
|
-
this.logWarning("calculateRemainingTotalAmountAsync:
|
|
1833
|
+
this.logWarning("calculateRemainingTotalAmountAsync: \u6CA1\u6709\u5F53\u524D\u8BA2\u5355");
|
|
1827
1834
|
return "0.00";
|
|
1828
1835
|
}
|
|
1829
1836
|
const totalAmount = new import_decimal.default(this.store.currentOrder.total_amount || "0");
|
|
@@ -1831,7 +1838,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1831
1838
|
const paidAmount = new import_decimal.default(paidAmountStr);
|
|
1832
1839
|
const remainingAmount = totalAmount.sub(paidAmount);
|
|
1833
1840
|
const result = import_decimal.default.max(0, remainingAmount).toFixed(2);
|
|
1834
|
-
this.logInfo("calculateRemainingTotalAmountAsync:
|
|
1841
|
+
this.logInfo("calculateRemainingTotalAmountAsync: \u8BA1\u7B97=", result);
|
|
1835
1842
|
return result;
|
|
1836
1843
|
}
|
|
1837
1844
|
/**
|
|
@@ -1850,18 +1857,18 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1850
1857
|
timestamp: Date.now(),
|
|
1851
1858
|
totalAmount: remainingTotalAmount
|
|
1852
1859
|
});
|
|
1853
|
-
this.logInfo("balanceDueAmount
|
|
1860
|
+
this.logInfo("balanceDueAmount \u5DF2\u81EA\u52A8\u66F4\u65B0:", {
|
|
1854
1861
|
oldAmount: currentBalanceDueAmount,
|
|
1855
1862
|
newAmount: remainingAmount
|
|
1856
1863
|
});
|
|
1857
1864
|
} else {
|
|
1858
|
-
this.logInfo("balanceDueAmount
|
|
1865
|
+
this.logInfo("balanceDueAmount \u65E0\u9700\u66F4\u65B0\uFF0C\u5F53\u524D\u503C\u5DF2\u662F\u6700\u65B0:", {
|
|
1859
1866
|
balanceDueAmount: currentBalanceDueAmount,
|
|
1860
1867
|
remainingAmount
|
|
1861
1868
|
});
|
|
1862
1869
|
}
|
|
1863
1870
|
} catch (error) {
|
|
1864
|
-
this.logError("
|
|
1871
|
+
this.logError("\u66F4\u65B0 balanceDueAmount \u5931\u8D25:", error);
|
|
1865
1872
|
}
|
|
1866
1873
|
}
|
|
1867
1874
|
/**
|
|
@@ -1905,12 +1912,12 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1905
1912
|
timestamp: Date.now(),
|
|
1906
1913
|
totalAmount: remainingTotalAmount
|
|
1907
1914
|
});
|
|
1908
|
-
this.logInfo("stateAmount
|
|
1915
|
+
this.logInfo("stateAmount \u5DF2\u81EA\u52A8\u66F4\u65B0\u4E3A\u5269\u4F59\u91D1\u989D:", {
|
|
1909
1916
|
oldAmount: currentStateAmount,
|
|
1910
1917
|
newAmount: remainingAmount
|
|
1911
1918
|
});
|
|
1912
1919
|
} else {
|
|
1913
|
-
this.logInfo("stateAmount
|
|
1920
|
+
this.logInfo("stateAmount \u65E0\u9700\u66F4\u65B0\uFF0C\u5F53\u524D\u503C\u5DF2\u662F\u6700\u65B0:", {
|
|
1914
1921
|
stateAmount: currentStateAmount,
|
|
1915
1922
|
remainingAmount
|
|
1916
1923
|
});
|
|
@@ -1919,10 +1926,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1919
1926
|
if (checkOrder) {
|
|
1920
1927
|
await this.checkOrderPaymentCompletion();
|
|
1921
1928
|
} else {
|
|
1922
|
-
this.logInfo("
|
|
1929
|
+
this.logInfo("\u5916\u90E8\u4F20\u5165\u65E0\u9700 checkOrder\uFF0C\u4E0D\u6267\u884C\u8BA2\u5355\u652F\u4ED8\u5B8C\u6210\u68C0\u6D4B\u548C\u540C\u6B65");
|
|
1923
1930
|
}
|
|
1924
1931
|
} catch (error) {
|
|
1925
|
-
this.logError("
|
|
1932
|
+
this.logError("\u66F4\u65B0 stateAmount \u4E3A\u5269\u4F59\u91D1\u989D\u5931\u8D25:", error);
|
|
1926
1933
|
}
|
|
1927
1934
|
}
|
|
1928
1935
|
/**
|
|
@@ -1940,7 +1947,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1940
1947
|
if (remainingValue.lte(0)) {
|
|
1941
1948
|
const totalAmount = this.store.currentOrder.total_amount;
|
|
1942
1949
|
const paidAmount = await this.calculatePaidAmountAsync();
|
|
1943
|
-
this.logInfo("
|
|
1950
|
+
this.logInfo("\u68C0\u6D4B\u5230\u8BA2\u5355\u652F\u4ED8\u5B8C\u6210:", {
|
|
1944
1951
|
orderUuid: this.store.currentOrder.uuid,
|
|
1945
1952
|
orderId: this.store.currentOrder.order_id,
|
|
1946
1953
|
totalAmount,
|
|
@@ -1958,13 +1965,13 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1958
1965
|
(item) => item.status !== "voided" && item.voucher_id
|
|
1959
1966
|
);
|
|
1960
1967
|
const shouldAutoSync = hasPaymentItems && !allPaymentsHaveVoucherId;
|
|
1961
|
-
this.logInfo("
|
|
1968
|
+
this.logInfo("\u81EA\u52A8\u540C\u6B65\u8BA2\u5355\u6761\u4EF6\u68C0\u67E5:", {
|
|
1962
1969
|
paymentCount: currentPayments.length,
|
|
1963
1970
|
hasPaymentItems,
|
|
1964
1971
|
allHaveVoucherId: allPaymentsHaveVoucherId,
|
|
1965
1972
|
isOrderSynced: this.store.isOrderSynced,
|
|
1966
1973
|
shouldAutoSync,
|
|
1967
|
-
reason: shouldAutoSync ? "
|
|
1974
|
+
reason: shouldAutoSync ? "\u652F\u4ED8\u5B8C\u6210\uFF0C\u9700\u8981\u540C\u6B65\u6700\u7EC8\u652F\u4ED8\u72B6\u6001" : "\u8DF3\u8FC7\u540C\u6B65",
|
|
1968
1975
|
paymentItems: currentPayments.map((p) => ({
|
|
1969
1976
|
uuid: p.uuid,
|
|
1970
1977
|
code: p.code,
|
|
@@ -1976,13 +1983,13 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1976
1983
|
}))
|
|
1977
1984
|
});
|
|
1978
1985
|
if (shouldAutoSync) {
|
|
1979
|
-
this.logInfo("
|
|
1986
|
+
this.logInfo("\u6EE1\u8DB3\u81EA\u52A8\u540C\u6B65\u6761\u4EF6\uFF0C\u5F00\u59CB\u540C\u6B65\u8BA2\u5355\u5230\u540E\u7AEF...");
|
|
1980
1987
|
await this.syncOrderToBackendWithReturn(false);
|
|
1981
1988
|
} else {
|
|
1982
1989
|
if (!hasPaymentItems) {
|
|
1983
|
-
this.logInfo("
|
|
1990
|
+
this.logInfo("\u6CA1\u6709\u652F\u4ED8\u9879\uFF0C\u8DF3\u8FC7\u8BA2\u5355\u540C\u6B65");
|
|
1984
1991
|
} else if (allPaymentsHaveVoucherId) {
|
|
1985
|
-
this.logInfo("
|
|
1992
|
+
this.logInfo("\u6240\u6709\u652F\u4ED8\u9879\u5747\u4E3A\u4EE3\u91D1\u5238\u7C7B\u578B\uFF0C\u8DF3\u8FC7\u8BA2\u5355\u540C\u6B65");
|
|
1986
1993
|
}
|
|
1987
1994
|
}
|
|
1988
1995
|
await this.core.effects.emit(import_types.CheckoutHooks.OnOrderPaymentCompleted, {
|
|
@@ -1995,7 +2002,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
1995
2002
|
});
|
|
1996
2003
|
}
|
|
1997
2004
|
} catch (error) {
|
|
1998
|
-
this.logError("
|
|
2005
|
+
this.logError("\u68C0\u67E5\u8BA2\u5355\u652F\u4ED8\u5B8C\u6210\u72B6\u6001\u5931\u8D25:", error);
|
|
1999
2006
|
}
|
|
2000
2007
|
}
|
|
2001
2008
|
/**
|
|
@@ -2008,12 +2015,12 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2008
2015
|
async syncOrderToBackendWithReturn(isManual = false, customPaymentItems) {
|
|
2009
2016
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2010
2017
|
if (!this.store.localOrderData || !this.store.currentOrder) {
|
|
2011
|
-
throw new Error("
|
|
2018
|
+
throw new Error("\u7F3A\u5C11\u5FC5\u8981\u7684\u8BA2\u5355\u6570\u636E\uFF0C\u65E0\u6CD5\u540C\u6B65\u5230\u540E\u7AEF");
|
|
2012
2019
|
}
|
|
2013
2020
|
this.logInfo("syncOrderToBackendWithReturn called", { isManual });
|
|
2014
2021
|
const currentOrderId = this.store.currentOrder.order_id;
|
|
2015
2022
|
const isUpdateOperation = this.store.isOrderSynced || !(0, import_utils.isVirtualOrderId)(currentOrderId);
|
|
2016
|
-
this.logInfo(
|
|
2023
|
+
this.logInfo(`\u5F00\u59CB\u540C\u6B65\u8BA2\u5355\u5230\u540E\u7AEF...`, {
|
|
2017
2024
|
currentOrderId,
|
|
2018
2025
|
isVirtualId: (0, import_utils.isVirtualOrderId)(currentOrderId || ""),
|
|
2019
2026
|
orderUuid: this.store.currentOrder.uuid,
|
|
@@ -2037,15 +2044,15 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2037
2044
|
const manualDepositValue = new import_decimal.default(manualDepositAmount);
|
|
2038
2045
|
if (manualDepositValue.gt(0)) {
|
|
2039
2046
|
finalDepositAmount = manualDepositAmount;
|
|
2040
|
-
this.logInfo("
|
|
2047
|
+
this.logInfo("\u4F7F\u7528\u624B\u52A8\u8BBE\u7F6E\u7684\u5B9A\u91D1\u91D1\u989D", {
|
|
2041
2048
|
manualDepositAmount,
|
|
2042
|
-
reason: "
|
|
2049
|
+
reason: "\u7528\u6237\u901A\u8FC7setDepositAmountAsync\u624B\u52A8\u8BBE\u7F6E\u4E86\u5B9A\u91D1\u91D1\u989D"
|
|
2043
2050
|
});
|
|
2044
2051
|
} else {
|
|
2045
2052
|
finalDepositAmount = "0.00";
|
|
2046
|
-
this.logInfo("
|
|
2053
|
+
this.logInfo("\u5B9A\u91D1\u91D1\u989D\u4E3A0", {
|
|
2047
2054
|
manualDepositAmount,
|
|
2048
|
-
reason: "
|
|
2055
|
+
reason: "\u624B\u52A8\u8BBE\u7F6E\u548C\u8BA1\u7B97\u503C\u5747\u4E3A0"
|
|
2049
2056
|
});
|
|
2050
2057
|
}
|
|
2051
2058
|
if (this.store.currentOrder.is_deposit === 0 && processedPaymentItems.every((item) => item.order_payment_type !== "deposit")) {
|
|
@@ -2066,7 +2073,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2066
2073
|
return sum.plus(amt).sub(rounding);
|
|
2067
2074
|
}, new import_decimal.default(0)).toFixed(2);
|
|
2068
2075
|
}
|
|
2069
|
-
this.logInfo("
|
|
2076
|
+
this.logInfo("\u5B9A\u91D1\u91D1\u989D\u786E\u5B9A\u7ED3\u679C", {
|
|
2070
2077
|
depositPaymentItemsCount: processedPaymentItems.length,
|
|
2071
2078
|
depositPaymentItems: processedPaymentItems.map((item) => ({
|
|
2072
2079
|
uuid: item.uuid,
|
|
@@ -2127,7 +2134,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2127
2134
|
if (isUpdateOperation) {
|
|
2128
2135
|
if ((0, import_utils.isVirtualOrderId)(currentOrderId)) {
|
|
2129
2136
|
this.logWarning(
|
|
2130
|
-
"
|
|
2137
|
+
"\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"
|
|
2131
2138
|
);
|
|
2132
2139
|
} else {
|
|
2133
2140
|
orderParams.order_id = currentOrderId;
|
|
@@ -2152,11 +2159,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2152
2159
|
});
|
|
2153
2160
|
checkoutResponse = await this.order.createOrderByCheckout(orderParams);
|
|
2154
2161
|
submitSuccess = true;
|
|
2155
|
-
this.logInfo("
|
|
2162
|
+
this.logInfo("\u4E0B\u5355\u63A5\u53E3\u8C03\u7528\u6210\u529F", checkoutResponse);
|
|
2156
2163
|
} catch (error) {
|
|
2157
2164
|
submitSuccess = false;
|
|
2158
2165
|
submitError = error instanceof Error ? error.message : String(error);
|
|
2159
|
-
this.logError("
|
|
2166
|
+
this.logError("\u4E0B\u5355\u63A5\u53E3\u8C03\u7528\u5931\u8D25:", submitError);
|
|
2160
2167
|
await this.core.effects.emit(import_types.CheckoutHooks.OnOrderSyncFailed, {
|
|
2161
2168
|
orderUuid: this.store.currentOrder.uuid,
|
|
2162
2169
|
operation: isUpdateOperation ? "update" : "create",
|
|
@@ -2182,7 +2189,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2182
2189
|
const responseStatus = checkoutResponse == null ? void 0 : checkoutResponse.status;
|
|
2183
2190
|
const isSuccessResponse = responseStatus === true || responseStatus === 200 || responseStatus === "success" || responseStatus === 1 && (checkoutResponse == null ? void 0 : checkoutResponse.code) === 200;
|
|
2184
2191
|
if (!isSuccessResponse) {
|
|
2185
|
-
const errorMessage = (checkoutResponse == null ? void 0 : checkoutResponse.message) || "
|
|
2192
|
+
const errorMessage = (checkoutResponse == null ? void 0 : checkoutResponse.message) || "\u8BA2\u5355\u540C\u6B65\u5931\u8D25\uFF0C\u540E\u7AEF\u8FD4\u56DE\u975E\u6210\u529F\u72B6\u6001";
|
|
2186
2193
|
await this.core.effects.emit(import_types.CheckoutHooks.OnOrderSyncFailed, {
|
|
2187
2194
|
orderUuid: this.store.currentOrder.uuid,
|
|
2188
2195
|
operation: isUpdateOperation ? "update" : "create",
|
|
@@ -2207,10 +2214,10 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2207
2214
|
extractedOrderId = String(extractedOrderId);
|
|
2208
2215
|
}
|
|
2209
2216
|
if (!extractedOrderId) {
|
|
2210
|
-
this.logError("
|
|
2217
|
+
this.logError("\u540E\u7AEF\u8FD4\u56DE\u7684\u8BA2\u5355\u4FE1\u606F\u4E2D\u672A\u5305\u542B\u8BA2\u5355ID");
|
|
2211
2218
|
}
|
|
2212
2219
|
realOrderId = extractedOrderId;
|
|
2213
|
-
this.logInfo("
|
|
2220
|
+
this.logInfo("\u51C6\u5907\u66FF\u6362\u8BA2\u5355ID:", {
|
|
2214
2221
|
orderUuid: this.store.currentOrder.uuid,
|
|
2215
2222
|
oldOrderId: this.store.currentOrder.order_id,
|
|
2216
2223
|
newOrderId: realOrderId
|
|
@@ -2220,38 +2227,38 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2220
2227
|
this.store.currentOrder.uuid,
|
|
2221
2228
|
realOrderId
|
|
2222
2229
|
);
|
|
2223
|
-
this.logInfo("Payment
|
|
2230
|
+
this.logInfo("Payment\u6A21\u5757\u66FF\u6362\u8BA2\u5355ID\u7ED3\u679C:", {
|
|
2224
2231
|
wasSuccessful: !!updatedOrder,
|
|
2225
2232
|
returnedOrderId: updatedOrder == null ? void 0 : updatedOrder.order_id,
|
|
2226
2233
|
expectedOrderId: realOrderId
|
|
2227
2234
|
});
|
|
2228
2235
|
if (updatedOrder) {
|
|
2229
|
-
this.logInfo("Payment
|
|
2236
|
+
this.logInfo("Payment\u6A21\u5757\u8FD4\u56DE\u7684\u66F4\u65B0\u540E\u8BA2\u5355:", {
|
|
2230
2237
|
uuid: updatedOrder.uuid,
|
|
2231
2238
|
orderId: updatedOrder.order_id,
|
|
2232
2239
|
totalAmount: updatedOrder.total_amount
|
|
2233
2240
|
});
|
|
2234
2241
|
this.store.currentOrder = updatedOrder;
|
|
2235
2242
|
this.logInfo(
|
|
2236
|
-
"[Checkout]
|
|
2243
|
+
"[Checkout] \u8BA2\u5355ID\u66FF\u6362\u6210\u529F\uFF0C\u5F53\u524D\u8BA2\u5355ID:",
|
|
2237
2244
|
this.store.currentOrder.order_id
|
|
2238
2245
|
);
|
|
2239
2246
|
} else {
|
|
2240
2247
|
this.logError(
|
|
2241
|
-
"[Checkout] Payment
|
|
2248
|
+
"[Checkout] Payment\u6A21\u5757\u8FD4\u56DE\u7A7A\u8BA2\u5355\uFF0C\u8BA2\u5355ID\u66FF\u6362\u5931\u8D25\uFF0C\u5F00\u59CB\u624B\u52A8\u66FF\u6362"
|
|
2242
2249
|
);
|
|
2243
2250
|
const beforeManualUpdate = this.store.currentOrder.order_id;
|
|
2244
2251
|
this.store.currentOrder.order_id = realOrderId;
|
|
2245
|
-
this.logInfo("
|
|
2252
|
+
this.logInfo("\u624B\u52A8\u8BBE\u7F6E\u8BA2\u5355ID:", {
|
|
2246
2253
|
beforeReplacement: beforeManualUpdate,
|
|
2247
2254
|
afterReplacement: this.store.currentOrder.order_id,
|
|
2248
|
-
|
|
2255
|
+
\u76EE\u6807ID: realOrderId
|
|
2249
2256
|
});
|
|
2250
2257
|
}
|
|
2251
2258
|
} catch (error) {
|
|
2252
|
-
this.logError("
|
|
2259
|
+
this.logError("\u8C03\u7528Payment\u6A21\u5757\u66FF\u6362\u8BA2\u5355ID\u65F6\u53D1\u751F\u9519\u8BEF:", error);
|
|
2253
2260
|
this.store.currentOrder.order_id = realOrderId;
|
|
2254
|
-
this.logInfo("
|
|
2261
|
+
this.logInfo("\u9519\u8BEF\u6062\u590D\uFF1A\u624B\u52A8\u8BBE\u7F6E\u8BA2\u5355ID:", realOrderId);
|
|
2255
2262
|
}
|
|
2256
2263
|
}
|
|
2257
2264
|
try {
|
|
@@ -2264,7 +2271,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2264
2271
|
);
|
|
2265
2272
|
}
|
|
2266
2273
|
} catch (e) {
|
|
2267
|
-
this.logWarning("
|
|
2274
|
+
this.logWarning("\u6807\u8BB0\u652F\u4ED8\u9879\u5DF2\u540C\u6B65\u5931\u8D25\uFF08\u4E0D\u963B\u585E\u4E3B\u6D41\u7A0B\uFF09", { error: e });
|
|
2268
2275
|
}
|
|
2269
2276
|
this.store.isOrderSynced = true;
|
|
2270
2277
|
await this.core.effects.emit(import_types.CheckoutHooks.OnOrderSynced, {
|
|
@@ -2308,7 +2315,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2308
2315
|
if (!orderId) {
|
|
2309
2316
|
return {
|
|
2310
2317
|
success: false,
|
|
2311
|
-
message: "
|
|
2318
|
+
message: "\u8BA2\u5355ID\u4E0D\u80FD\u4E3A\u7A7A",
|
|
2312
2319
|
orderId
|
|
2313
2320
|
};
|
|
2314
2321
|
}
|
|
@@ -2322,7 +2329,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2322
2329
|
const response = await this.request.put(`/order/order/${orderId}/note`, {
|
|
2323
2330
|
note
|
|
2324
2331
|
});
|
|
2325
|
-
this.logInfo("
|
|
2332
|
+
this.logInfo("\u8BA2\u5355\u5907\u6CE8\u7F16\u8F91\u54CD\u5E94:", {
|
|
2326
2333
|
orderId,
|
|
2327
2334
|
status: response.status,
|
|
2328
2335
|
message: response.message,
|
|
@@ -2343,12 +2350,12 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2343
2350
|
}
|
|
2344
2351
|
return {
|
|
2345
2352
|
success: true,
|
|
2346
|
-
message: response.message || "
|
|
2353
|
+
message: response.message || "\u8BA2\u5355\u5907\u6CE8\u4FEE\u6539\u6210\u529F",
|
|
2347
2354
|
orderId
|
|
2348
2355
|
};
|
|
2349
2356
|
} else {
|
|
2350
|
-
const errorMessage = response.message || "
|
|
2351
|
-
this.logError(
|
|
2357
|
+
const errorMessage = response.message || "\u8BA2\u5355\u5907\u6CE8\u4FEE\u6539\u5931\u8D25";
|
|
2358
|
+
this.logError(`\u8BA2\u5355 ${orderId} \u5907\u6CE8\u4FEE\u6539\u5931\u8D25:`, errorMessage);
|
|
2352
2359
|
return {
|
|
2353
2360
|
success: false,
|
|
2354
2361
|
message: errorMessage,
|
|
@@ -2356,11 +2363,11 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2356
2363
|
};
|
|
2357
2364
|
}
|
|
2358
2365
|
} catch (error) {
|
|
2359
|
-
this.logError("
|
|
2360
|
-
const errorMessage = error instanceof Error ? error.message : "
|
|
2366
|
+
this.logError("\u7F16\u8F91\u8BA2\u5355\u5907\u6CE8\u5931\u8D25:", error);
|
|
2367
|
+
const errorMessage = error instanceof Error ? error.message : "\u7F51\u7EDC\u9519\u8BEF\u6216\u670D\u52A1\u5668\u5F02\u5E38";
|
|
2361
2368
|
return {
|
|
2362
2369
|
success: false,
|
|
2363
|
-
message:
|
|
2370
|
+
message: `\u7F16\u8F91\u8BA2\u5355\u5907\u6CE8\u5931\u8D25: ${errorMessage}`,
|
|
2364
2371
|
orderId
|
|
2365
2372
|
};
|
|
2366
2373
|
}
|
|
@@ -2386,13 +2393,13 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2386
2393
|
if (!params.order_ids || params.order_ids.length === 0) {
|
|
2387
2394
|
return {
|
|
2388
2395
|
success: false,
|
|
2389
|
-
message: "
|
|
2396
|
+
message: "\u8BA2\u5355ID\u5217\u8868\u4E0D\u80FD\u4E3A\u7A7A"
|
|
2390
2397
|
};
|
|
2391
2398
|
}
|
|
2392
2399
|
if (!params.emails || params.emails.length === 0) {
|
|
2393
2400
|
return {
|
|
2394
2401
|
success: false,
|
|
2395
|
-
message: "
|
|
2402
|
+
message: "\u90AE\u7BB1\u5730\u5740\u5217\u8868\u4E0D\u80FD\u4E3A\u7A7A"
|
|
2396
2403
|
};
|
|
2397
2404
|
}
|
|
2398
2405
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
@@ -2402,7 +2409,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2402
2409
|
if (invalidEmails.length > 0) {
|
|
2403
2410
|
return {
|
|
2404
2411
|
success: false,
|
|
2405
|
-
message:
|
|
2412
|
+
message: `\u90AE\u7BB1\u683C\u5F0F\u65E0\u6548: ${invalidEmails.join(", ")}`
|
|
2406
2413
|
};
|
|
2407
2414
|
}
|
|
2408
2415
|
const requestBody = {
|
|
@@ -2418,7 +2425,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2418
2425
|
"/order/batch-email",
|
|
2419
2426
|
requestBody
|
|
2420
2427
|
);
|
|
2421
|
-
this.logInfo("
|
|
2428
|
+
this.logInfo("\u652F\u4ED8\u94FE\u63A5\u90AE\u4EF6\u53D1\u9001\u54CD\u5E94:", {
|
|
2422
2429
|
status: response.status,
|
|
2423
2430
|
message: response.message,
|
|
2424
2431
|
data: response.data,
|
|
@@ -2427,22 +2434,22 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2427
2434
|
if (response.status === true || response.status === 200) {
|
|
2428
2435
|
return {
|
|
2429
2436
|
success: true,
|
|
2430
|
-
message: response.message || "
|
|
2437
|
+
message: response.message || "\u652F\u4ED8\u94FE\u63A5\u90AE\u4EF6\u53D1\u9001\u6210\u529F"
|
|
2431
2438
|
};
|
|
2432
2439
|
} else {
|
|
2433
|
-
const errorMessage = response.message || "
|
|
2434
|
-
console.error("[Checkout]
|
|
2440
|
+
const errorMessage = response.message || "\u652F\u4ED8\u94FE\u63A5\u90AE\u4EF6\u53D1\u9001\u5931\u8D25";
|
|
2441
|
+
console.error("[Checkout] \u652F\u4ED8\u94FE\u63A5\u90AE\u4EF6\u53D1\u9001\u5931\u8D25:", errorMessage);
|
|
2435
2442
|
return {
|
|
2436
2443
|
success: false,
|
|
2437
2444
|
message: errorMessage
|
|
2438
2445
|
};
|
|
2439
2446
|
}
|
|
2440
2447
|
} catch (error) {
|
|
2441
|
-
this.logError("
|
|
2442
|
-
const errorMessage = error instanceof Error ? error.message : "
|
|
2448
|
+
this.logError("\u53D1\u9001\u5BA2\u6237\u652F\u4ED8\u94FE\u63A5\u90AE\u4EF6\u5931\u8D25:", error);
|
|
2449
|
+
const errorMessage = error instanceof Error ? error.message : "\u7F51\u7EDC\u9519\u8BEF\u6216\u670D\u52A1\u5668\u5F02\u5E38";
|
|
2443
2450
|
return {
|
|
2444
2451
|
success: false,
|
|
2445
|
-
message:
|
|
2452
|
+
message: `\u53D1\u9001\u652F\u4ED8\u94FE\u63A5\u90AE\u4EF6\u5931\u8D25: ${errorMessage}`
|
|
2446
2453
|
};
|
|
2447
2454
|
}
|
|
2448
2455
|
}
|
|
@@ -2476,7 +2483,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2476
2483
|
await ((_b = (_a = this.order) == null ? void 0 : _a.destroy) == null ? void 0 : _b.call(_a));
|
|
2477
2484
|
await ((_d = (_c = this.payment) == null ? void 0 : _c.destroy) == null ? void 0 : _d.call(_c));
|
|
2478
2485
|
this.core.unregisterModule(this);
|
|
2479
|
-
console.log("[Checkout]
|
|
2486
|
+
console.log("[Checkout] \u5DF2\u9500\u6BC1");
|
|
2480
2487
|
}
|
|
2481
2488
|
/**
|
|
2482
2489
|
* 重置 store 状态
|
|
@@ -2489,7 +2496,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2489
2496
|
uuid: this.store.currentOrder.uuid,
|
|
2490
2497
|
orderId: this.store.currentOrder.order_id
|
|
2491
2498
|
} : null;
|
|
2492
|
-
console.log("[Checkout]
|
|
2499
|
+
console.log("[Checkout] \u91CD\u7F6E store \u72B6\u6001\uFF0C\u51C6\u5907\u521B\u5EFA\u65B0\u8BA2\u5355", prevOrderInfo);
|
|
2493
2500
|
this.store.currentOrder = void 0;
|
|
2494
2501
|
this.store.localOrderData = void 0;
|
|
2495
2502
|
this.store.cartSummary = void 0;
|
|
@@ -2500,7 +2507,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2500
2507
|
this.store.lastError = void 0;
|
|
2501
2508
|
this.store.cartItems = [];
|
|
2502
2509
|
this.payment.wallet.clearAllCache();
|
|
2503
|
-
console.log("[Checkout] Store
|
|
2510
|
+
console.log("[Checkout] Store \u72B6\u6001\u91CD\u7F6E\u5B8C\u6210");
|
|
2504
2511
|
if (prevOrderInfo) {
|
|
2505
2512
|
await this.core.effects.emit(import_types.CheckoutHooks.OnOrderCleared, {
|
|
2506
2513
|
previousOrder: prevOrderInfo,
|
|
@@ -2508,7 +2515,7 @@ var CheckoutImpl = class extends import_BaseModule.BaseModule {
|
|
|
2508
2515
|
});
|
|
2509
2516
|
}
|
|
2510
2517
|
} catch (error) {
|
|
2511
|
-
console.error("[Checkout]
|
|
2518
|
+
console.error("[Checkout] \u91CD\u7F6E store \u72B6\u6001\u5931\u8D25:", error);
|
|
2512
2519
|
}
|
|
2513
2520
|
}
|
|
2514
2521
|
};
|